Browse Source

ListCommandTests refactor

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

89
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 'rc.yml',
\t\t* rc 'production.yml',
\t\n 'local.yml'
OUTPUT; ),
$this->expectOutputString($expectedOutput); 'expectedOutput' => "\tThese are your configured environments:\n"
. "\t\t* local\n"
$environmentsFiles = [ . "\t\t* production\n"
'rc.yml', . "\t\t* rc\n"
'production.yml', . "\t\n"
'local.yml' ),
]; 'with_missing_yml_files' => array(
'environmentFiles' => array(
$this->scandirValueObj->setValue($environmentsFiles); 'rc',
'production.yml'
$configMock = $this->getMock('Mage\Config'); ),
$configMock->expects($this->once()) 'expectedOutput' => "\tThese are your configured environments:\n"
->method('getArgument') . "\t\t* production\n"
->with(1) . "\t\n"
->willReturn('environments'); ),
$this->listCommand->setConfig($configMock); 'with_no_yml_configs' => array(
'environmentFiles' => array(
$this->listCommand->run(); '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