Browse Source

ListCommandTests refactor

1.0
Jakub Turek 10 years ago
parent
commit
5944015b50
  1. 83
      tests/MageTest/Command/BuiltIn/ListCommandTest.php

83
tests/MageTest/Command/BuiltIn/ListCommandTest.php

@ -76,56 +76,56 @@ class ListCommandTest extends BaseTest
$configProperty->setValue($configMock); $configProperty->setValue($configMock);
} }
/** public function listEnvironmentsProvider()
* @covers ::run
* @covers ::listEnvironments
*/
public function testListEnvironment()
{ {
$expectedOutput = <<<OUTPUT return array(
\tThese are your configured environments: 'normal' => array(
\t\t* local 'environmentFiles' => array(
\t\t* production
\t\t* rc
\t\n
OUTPUT;
$this->expectOutputString($expectedOutput);
$environmentsFiles = [
'rc.yml', 'rc.yml',
'production.yml', 'production.yml',
'local.yml' 'local.yml'
]; ),
'expectedOutput' => "\tThese are your configured environments:\n"
$this->scandirValueObj->setValue($environmentsFiles); . "\t\t* local\n"
. "\t\t* production\n"
$configMock = $this->getMock('Mage\Config'); . "\t\t* rc\n"
$configMock->expects($this->once()) . "\t\n"
->method('getArgument') ),
->with(1) 'with_missing_yml_files' => array(
->willReturn('environments'); 'environmentFiles' => array(
$this->listCommand->setConfig($configMock); 'rc',
'production.yml'
$this->listCommand->run(); ),
'expectedOutput' => "\tThese are your configured environments:\n"
. "\t\t* production\n"
. "\t\n"
),
'with_no_yml_configs' => array(
'environmentFiles' => array(
'rc.ini',
'production.txt'
),
'expectedOutput' => "\tYou don't have any environment configured.\n\n"
),
'with_no_configs' => array(
'environmentFiles' => array(),
'expectedOutput' => "\tYou don't have any environment configured.\n\n"
)
);
} }
/** /**
* @covers ::run * @covers ::run
* @covers ::listEnvironments * @covers ::listEnvironments
* @dataProvider listEnvironmentsProvider
*/ */
public function testListEnvironmentWithNoEnvironments() public function testListEnvironment($environmentFiles, $expectedOutput)
{ {
$expectedOutput = "\tYou don't have any environment configured.\n\n";
$this->expectOutputString($expectedOutput); $this->expectOutputString($expectedOutput);
$this->scandirValueObj->setValue([]); $this->scandirValueObj->setValue($environmentFiles);
$this->mockInputArgument('environments');
$configMock = $this->getMock('Mage\Config');
$configMock->expects($this->once())
->method('getArgument')
->with(1)
->willReturn('environments');
$this->listCommand->setConfig($configMock);
$this->listCommand->run(); $this->listCommand->run();
} }
@ -137,12 +137,19 @@ OUTPUT;
$expectedOutput = "\tThe Type of Elements to List is needed.\n\n"; $expectedOutput = "\tThe Type of Elements to List is needed.\n\n";
$this->expectOutputString($expectedOutput); $this->expectOutputString($expectedOutput);
$this->mockInputArgument('abc');
$this->listCommand->run();
}
private function mockInputArgument($argumentValue)
{
$configMock = $this->getMock('Mage\Config'); $configMock = $this->getMock('Mage\Config');
$configMock->expects($this->once()) $configMock->expects($this->once())
->method('getArgument') ->method('getArgument')
->with(1) ->with(1)
->willReturn('abc'); ->willReturn($argumentValue);
$this->listCommand->setConfig($configMock); $this->listCommand->setConfig($configMock);
$this->listCommand->run();
} }
} }

Loading…
Cancel
Save