We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 316fd3e3 authored by Mike Pretzlaw's avatar Mike Pretzlaw

Container will flush an restore each fixture loader

parent be87c2f4
...@@ -61,4 +61,32 @@ class EcomDev_PHPUnit_Model_Fixture_Loader_Container ...@@ -61,4 +61,32 @@ class EcomDev_PHPUnit_Model_Fixture_Loader_Container
{ {
return isset($this->_loaders[$code]); return isset($this->_loaders[$code]);
} }
}
\ No newline at end of file
/**
* Flush all loader in this container.
*
* @return void
*/
public function flush()
{
foreach ($this->_loaders as $loader)
{
$loader->flush();
}
}
/**
* Restore all loader in this container.
*
* @return void
*/
public function restore()
{
foreach ($this->_loaders as $loader)
{
$loader->restore();
}
}
}
...@@ -9,7 +9,7 @@ class EcomDev_PHPUnitTest_Test_Model_Fixture_Loader_Container ...@@ -9,7 +9,7 @@ class EcomDev_PHPUnitTest_Test_Model_Fixture_Loader_Container
* @var EcomDev_PHPUnit_Model_Fixture_Loader_Container * @var EcomDev_PHPUnit_Model_Fixture_Loader_Container
*/ */
protected $_factory; protected $_factory;
protected function setUp() protected function setUp()
{ {
$this->_factory = new EcomDev_PHPUnit_Model_Fixture_Loader_Container(); $this->_factory = new EcomDev_PHPUnit_Model_Fixture_Loader_Container();
...@@ -79,6 +79,45 @@ class EcomDev_PHPUnitTest_Test_Model_Fixture_Loader_Container ...@@ -79,6 +79,45 @@ class EcomDev_PHPUnitTest_Test_Model_Fixture_Loader_Container
); );
} }
/**
* Check if the methods are forwarded by the collection to it's elements.
*
* @dataProvider getMethods
*
* @param string $methodName
* @param array $args []
*
* @return void
*/
public function testFlushAndRestoreWillBeForwardedToEachLoader($methodName, $args)
{
$loaderSet = $this->_stubLoaders(2);
foreach ($loaderSet as $loader)
{
/** @var PHPUnit_Framework_MockObject_MockObject $loader */
$loader->expects($this->exactly(1))->method($methodName);
}
$this->_factory->$methodName();
}
/**
* Data provider for methods to check forwarding with.
*
* @see testFlushAndRestoreWillBeForwardedToEachLoader
*
* @return array
*/
public function getMethods()
{
return array(
array('flush', array()),
array('restore', array()),
);
}
/** /**
* Generates loaders for tests * Generates loaders for tests
* *
...@@ -112,4 +151,4 @@ class EcomDev_PHPUnitTest_Test_Model_Fixture_Loader_Container ...@@ -112,4 +151,4 @@ class EcomDev_PHPUnitTest_Test_Model_Fixture_Loader_Container
return $loaders; return $loaders;
} }
} }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment