Browse Source

dummy classes dependency removed from task factory unittests

1.0
Claudio Zizza 10 years ago
parent
commit
00ba38aea2
  1. 81
      tests/MageTest/Task/FactoryTest.php

81
tests/MageTest/Task/FactoryTest.php

@ -5,12 +5,11 @@ namespace MageTest\Task;
use Mage\Task\Factory; use Mage\Task\Factory;
use PHPUnit_Framework_TestCase; use PHPUnit_Framework_TestCase;
require_once(__DIR__ . '/../../Dummies/Task/MyTask.php');
require_once(__DIR__ . '/../../Dummies/Task/MyInconsistentTask.php');
/** /**
* @group MageTest_Task * @group MageTest_Task
* @group MageTest_Task_Factory * @group MageTest_Task_Factory
*
* @group issue-176
*/ */
class FactoryTest extends PHPUnit_Framework_TestCase class FactoryTest extends PHPUnit_Framework_TestCase
{ {
@ -18,25 +17,47 @@ class FactoryTest extends PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->config = $this->getMock('Mage\Config'); $this->config = $this->getMock('Mage\\Config');
} }
/** public function testGet()
* @dataProvider taskDataProvider {
*/ $task = Factory::get('composer/install', $this->config);
public function testGet($taskData) $this->assertInstanceOf('\\Mage\\Task\\BuiltIn\\Composer\\InstallTask', $task);
}
public function testGetTaskDataIsArray()
{ {
$taskData = array(
'name' => 'composer/install',
'parameters' => array(),
);
$task = Factory::get($taskData, $this->config); $task = Factory::get($taskData, $this->config);
$this->assertInstanceOf('\\Mage\\Task\\AbstractTask', $task); $this->assertInstanceOf('\\Mage\\Task\\BuiltIn\\Composer\\InstallTask', $task);
} }
public function testGetCustomTask()
{
$this->getMockBuilder('Mage\\Task\\AbstractTask')
->disableOriginalConstructor()
->setMockClassName('MyTask')
->getMock();
/** /**
* @dataProvider taskDataProvider * current workaround
* @link https://github.com/sebastianbergmann/phpunit-mock-objects/issues/134
*/ */
public function testGetWithOptionalParams($taskData) class_alias('MyTask', 'Task\\MyTask');
$task = Factory::get('my-task', $this->config);
$this->assertInstanceOf('Task\\MyTask', $task);
}
public function testGetWithOptionalParams()
{ {
$task = Factory::get($taskData, $this->config, true, 'production'); $task = Factory::get('composer/install', $this->config, true, 'production');
$this->assertInstanceOf('\\Mage\\Task\\AbstractTask', $task); $this->assertInstanceOf('\\Mage\\Task\\BuiltIn\\Composer\\InstallTask', $task);
} }
/** /**
@ -45,6 +66,7 @@ class FactoryTest extends PHPUnit_Framework_TestCase
*/ */
public function testGetInconsistentException() public function testGetInconsistentException()
{ {
$this->getMock('Task\\MyInconsistentTask');
Factory::get('my-inconsistent-task', $this->config); Factory::get('my-inconsistent-task', $this->config);
} }
@ -56,37 +78,4 @@ class FactoryTest extends PHPUnit_Framework_TestCase
{ {
Factory::get('unknowntask', $this->config); Factory::get('unknowntask', $this->config);
} }
/**
* Only build in tasks contains a slash
*
* @return array
*/
public function taskDataProvider()
{
return array(
array(
array(
'name' => 'my-task',
'parameters' => array(),
)
),
array('my-task'),
array(
array(
'name' => 'composer/install',
'parameters' => array(),
)
),
array('composer/install'),
array(
array(
'name' => 'magento/clear-cache',
'parameters' => array(),
)
),
array('magento/clear-cache'),
);
}
} }
Loading…
Cancel
Save