Пример #1
0
 /**
  * Creates new helper for test
  */
 protected function setUp()
 {
     $this->helper = $this->getMockForAbstractClass('EcomDev_PHPUnit_HelperInterface');
     $this->helper->expects($this->any())->method('invoke')->with($this->equalTo('someCustomHelper'))->will($this->returnSelf());
     $this->helper->expects($this->any())->method('has')->will($this->returnValueMap(array(array('someCustomHelper', true))));
     EcomDev_PHPUnit_Helper::add($this->helper);
 }
Пример #2
0
 /**
  * Registers default test helpers
  *
  */
 public function registerDefaultTestHelpers()
 {
     foreach (Mage::getConfig()->getNode(self::XML_PATH_TEST_HELPERS)->children() as $helperNode) {
         $helperClass = (string) $helperNode;
         if ($helperClass && class_exists($helperClass)) {
             $helper = new $helperClass();
             if (!$helper instanceof EcomDev_PHPUnit_HelperInterface) {
                 throw new RuntimeException(sprintf('Test helpers should implement %s, but %s is not implementing it.', 'EcomDev_PHPUnit_HelperInterface', $helperClass));
             }
             EcomDev_PHPUnit_Helper::add($helper);
         }
     }
 }
Пример #3
0
 /**
  * Tests removal of each helper
  *
  */
 public function testRemoveByClassName()
 {
     $helpers = $this->getHelpersForTest(5, true);
     // Check helpers are exists before editing
     $this->assertAttributeSame($helpers, 'helpers', 'EcomDev_PHPUnit_Helper');
     Helper::add($helpers[4]);
     // Added two times
     Helper::removeByClass('Test_Helper_Name2');
     $this->assertAttributeSame(array($helpers[0], $helpers[1], $helpers[3], $helpers[4], $helpers[4]), 'helpers', 'EcomDev_PHPUnit_Helper');
     Helper::removeByClass('Test_Helper_Name4');
     $this->assertAttributeSame(array($helpers[0], $helpers[1], $helpers[3]), 'helpers', 'EcomDev_PHPUnit_Helper');
 }