mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	using BaseTest class for VersionCommand test
This commit is contained in:
		
							parent
							
								
									00e36d7adc
								
							
						
					
					
						commit
						0d57e080e4
					
				@ -4,43 +4,27 @@ namespace MageTest\Command\BuiltIn;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use Mage\Command\BuiltIn\VersionCommand;
 | 
					use Mage\Command\BuiltIn\VersionCommand;
 | 
				
			||||||
use Mage\Console;
 | 
					use Mage\Console;
 | 
				
			||||||
 | 
					use MageTest\TestHelper\BaseTest;
 | 
				
			||||||
use PHPUnit_Framework_TestCase;
 | 
					use PHPUnit_Framework_TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 | 
					 * @coversDefaultClass Mage\Command\BuiltIn\VersionCommands
 | 
				
			||||||
 * @group Mage_Command_BuildIn_VersionCommand
 | 
					 * @group Mage_Command_BuildIn_VersionCommand
 | 
				
			||||||
 | 
					 * @uses Mage\Console
 | 
				
			||||||
 | 
					 * @uses Mage\Console\Colors
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class VersionCommandTest extends PHPUnit_Framework_TestCase
 | 
					class VersionCommandTest extends BaseTest
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @group 175
 | 
					     * @group 175
 | 
				
			||||||
 | 
					     * @covers Mage\Command\BuiltIn\VersionCommand::run()
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function testRun()
 | 
					    public function testRun()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->workAroundStatic();
 | 
					        $this->setUpConsoleStatics();
 | 
				
			||||||
        $command = new VersionCommand();
 | 
					        $command = new VersionCommand();
 | 
				
			||||||
        $command->run();
 | 
					        $command->run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->expectOutputString('Running Magallanes version 2' . str_repeat(PHP_EOL, 2));
 | 
					        $this->expectOutputString('Running Magallanes version 2' . str_repeat(PHP_EOL, 2));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * This is only needed as long as Console-class has static methods and properties
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private function workAroundStatic()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $refClass = new \ReflectionClass('Mage\Console');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $refProperty = $refClass->getProperty('logEnabled');
 | 
					 | 
				
			||||||
        $refProperty->setAccessible(true);
 | 
					 | 
				
			||||||
        $refProperty->setValue(false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $config = $this->getMock('Mage\Config');
 | 
					 | 
				
			||||||
        $config->expects($this->once())
 | 
					 | 
				
			||||||
            ->method('getParameter')
 | 
					 | 
				
			||||||
            ->will($this->returnValue(true));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $refProperty = $refClass->getProperty('config');
 | 
					 | 
				
			||||||
        $refProperty->setAccessible(true);
 | 
					 | 
				
			||||||
        $refProperty->setValue($config);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user