mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Set compiler by setter for better testability
This commit is contained in:
		
							parent
							
								
									e9ec99f318
								
							
						
					
					
						commit
						d58e89c41d
					
				@ -21,6 +21,21 @@ use Mage\Compiler;
 | 
			
		||||
 */
 | 
			
		||||
class CompileCommand extends AbstractCommand
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var Compiler
 | 
			
		||||
     */
 | 
			
		||||
    private $compiler;
 | 
			
		||||
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        $this->compiler = new Compiler();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setCompiler(Compiler $compiler)
 | 
			
		||||
    {
 | 
			
		||||
        $this->compiler = $compiler;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @see \Mage\Compile::compile()
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										51
									
								
								tests/MageTest/Command/BuiltIn/CompileCommandTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								tests/MageTest/Command/BuiltIn/CompileCommandTest.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,51 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace MageTest\Command\BuiltIn;
 | 
			
		||||
 | 
			
		||||
use Mage\Command\BuiltIn\CompileCommand;
 | 
			
		||||
use MageTest\TestHelper\BaseTest;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class CompileCommandTest
 | 
			
		||||
 * @package MageTest\Command\BuiltIn
 | 
			
		||||
 * @coversDefaultClass Mage\Command\BuiltIn\CompileCommand
 | 
			
		||||
 * @uses Mage\Compiler
 | 
			
		||||
 */
 | 
			
		||||
class CompileCommandTest extends BaseTest
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var CompileCommand
 | 
			
		||||
     */
 | 
			
		||||
    private $compileCommand;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @before
 | 
			
		||||
     */
 | 
			
		||||
    public function before()
 | 
			
		||||
    {
 | 
			
		||||
        $this->compileCommand = new CompileCommand();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @covers ::__construct
 | 
			
		||||
     */
 | 
			
		||||
    public function testConstruct()
 | 
			
		||||
    {
 | 
			
		||||
        $compileCommand = new CompileCommand();
 | 
			
		||||
 | 
			
		||||
        $compilerProperty = $this->getPropertyValue($compileCommand, 'compiler');
 | 
			
		||||
        $this->assertInstanceOf('Mage\Compiler', $compilerProperty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @covers ::setCompiler
 | 
			
		||||
     */
 | 
			
		||||
    public function testSetCompiler()
 | 
			
		||||
    {
 | 
			
		||||
        $compilerMock = $this->getMock('Mage\Compiler');
 | 
			
		||||
        $this->compileCommand->setCompiler($compilerMock);
 | 
			
		||||
 | 
			
		||||
        $compilerProperty = $this->getPropertyValue($this->compileCommand, 'compiler');
 | 
			
		||||
        $this->assertEquals($compilerMock, $compilerProperty);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user