mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-09-06 09:28:57 +02:00
Merge branch 'develop' into task-factory-test
Conflicts: Mage/Task/Factory.php
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace MageTest\Command;
|
||||
|
||||
use Mage\Command\Factory;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
/**
|
||||
* @group Mage_Command
|
||||
* @group Mage_Command_Factory
|
||||
*
|
||||
* @group issue-167
|
||||
*/
|
||||
class FactoryTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $config;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->config = $this->getMock('Mage\Config');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$command = Factory::get('add', $this->config);
|
||||
$this->assertInstanceOf('Mage\\Command\\BuiltIn\\AddCommand', $command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testGetClassNotFoundException()
|
||||
{
|
||||
$command = Factory::get('commanddoesntexist', $this->config);
|
||||
}
|
||||
|
||||
public function testGetCustomCommand()
|
||||
{
|
||||
$this->getMockBuilder('Mage\\Command\\AbstractCommand')
|
||||
->setMockClassName('MyCommand')
|
||||
->getMock();
|
||||
|
||||
/**
|
||||
* current workaround
|
||||
* @link https://github.com/sebastianbergmann/phpunit-mock-objects/issues/134
|
||||
*/
|
||||
class_alias('MyCommand', 'Command\\MyCommand');
|
||||
|
||||
$command = Factory::get('my-command', $this->config);
|
||||
$this->assertInstanceOf('Command\\MyCommand', $command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage The command MyInconsistentCommand must be an instance of Mage\Command\AbstractCommand.
|
||||
*/
|
||||
public function testGetInconsistencyException()
|
||||
{
|
||||
$this->getMock('Command\\MyInconsistentCommand');
|
||||
|
||||
$command = Factory::get('my-inconsistent-command', $this->config);
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,21 @@ use PHPUnit_Framework_TestCase;
|
||||
|
||||
/**
|
||||
* @group Mage_Console_Colors
|
||||
* @coversDefaultClass Mage\Console\Colors
|
||||
*/
|
||||
class ColorsTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $noColorParameter = "no-color";
|
||||
/**
|
||||
* @group 159
|
||||
* @covers ::color
|
||||
*/
|
||||
public function testColor()
|
||||
{
|
||||
$config = $this->getMock('Mage\Config');
|
||||
$config->expects($this->once())
|
||||
->method('getParameter')
|
||||
->with($this->noColorParameter)
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$string = '<green>FooBar</green>';
|
||||
@@ -31,12 +35,14 @@ class ColorsTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @group 159
|
||||
* @covers ::color
|
||||
*/
|
||||
public function testColorNoColor()
|
||||
{
|
||||
$config = $this->getMock('Mage\Config');
|
||||
$config->expects($this->once())
|
||||
->method('getParameter')
|
||||
->with($this->noColorParameter)
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$string = '<black>FooBar</black>';
|
||||
@@ -50,12 +56,14 @@ class ColorsTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @group 159
|
||||
* @covers ::color
|
||||
*/
|
||||
public function testColorUnknownColorName()
|
||||
{
|
||||
$config = $this->getMock('Mage\Config');
|
||||
$config->expects($this->once())
|
||||
->method('getParameter')
|
||||
->with($this->noColorParameter)
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$string = '<foo>FooBar</foo>';
|
||||
|
||||
Reference in New Issue
Block a user