Exemplo n.º 1
0
 public function testClearLayoutUpdates()
 {
     // mocks
     $helper = $this->getMock('Mage_DesignEditor_Helper_Data', array('getDaysToExpire'), array(), '', false);
     $helper->expects($this->once())->method('getDaysToExpire')->will($this->returnValue(self::TEST_DAYS_TO_EXPIRE));
     /** @var $linkCollection Mage_Core_Model_Resource_Layout_Link_Collection */
     $linkCollection = $this->getMock('Mage_Core_Model_Resource_Layout_Link_Collection', array('addTemporaryFilter', 'addUpdatedDaysBeforeFilter', 'load'), array(), '', false);
     $linkCollection->expects($this->once())->method('addTemporaryFilter')->with(true)->will($this->returnSelf());
     $linkCollection->expects($this->once())->method('addUpdatedDaysBeforeFilter')->with(self::TEST_DAYS_TO_EXPIRE)->will($this->returnSelf());
     for ($i = 0; $i < 3; $i++) {
         $link = $this->getMock('Mage_Core_Model_Layout_Link', array('delete'), array(), '', false);
         $link->expects($this->once())->method('delete');
         $linkCollection->addItem($link);
     }
     /** @var $layoutCollection Mage_Core_Model_Resource_Layout_Update_Collection */
     $layoutCollection = $this->getMock('Mage_Core_Model_Resource_Layout_Update_Collection', array('addNoLinksFilter', 'addUpdatedDaysBeforeFilter', 'load'), array(), '', false);
     $layoutCollection->expects($this->once())->method('addNoLinksFilter')->will($this->returnSelf());
     $layoutCollection->expects($this->once())->method('addUpdatedDaysBeforeFilter')->with(self::TEST_DAYS_TO_EXPIRE)->will($this->returnSelf());
     for ($i = 0; $i < 3; $i++) {
         $layout = $this->getMock('Mage_Core_Model_Layout_Update', array('delete'), array(), '', false);
         $layout->expects($this->once())->method('delete');
         $layoutCollection->addItem($layout);
     }
     $objectManager = $this->getMock('Magento_ObjectManager_Zend', array('create'), array(), '', false);
     $objectManager->expects($this->at(0))->method('create')->with('Mage_Core_Model_Resource_Layout_Link_Collection')->will($this->returnValue($linkCollection));
     $objectManager->expects($this->at(1))->method('create')->with('Mage_Core_Model_Resource_Layout_Update_Collection')->will($this->returnValue($layoutCollection));
     $cacheManager = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false);
     // test
     $this->_model = new Mage_DesignEditor_Model_Observer($objectManager, $helper, $cacheManager);
     $this->_model->clearLayoutUpdates();
 }
Exemplo n.º 2
0
 /**
  * @magentoDataFixture Mage/DesignEditor/_files/design_editor_active.php
  */
 public function testAdminSessionUserLogout()
 {
     /** @var $session Mage_DesignEditor_Model_Session */
     $session = Mage::getSingleton('Mage_DesignEditor_Model_Session');
     $this->assertTrue($session->isDesignEditorActive());
     $this->_observer->adminSessionUserLogout();
     $this->assertFalse($session->isDesignEditorActive());
 }