Example #1
0
 /**
  * Test getting first store in ordered stores
  *
  * @return void
  */
 public function testGetFirstStoreId()
 {
     $data = $this->_getFixtureData();
     foreach ($data['stores'] as &$item) {
         $dataItem = $item;
         $item = $this->getMock('Varien_Object', array('initConfigCache'));
         $item->setData($dataItem);
         $item->expects($this->any())->method('initConfigCache')->will($this->returnValue($item));
     }
     unset($item);
     $list = array('websites' => 'core/website', 'groups' => 'core/store_group', 'stores' => 'core/store');
     $callback = array('websites' => 'getWebsiteById', 'groups' => 'getStoreGroupById', 'stores' => 'getStoreById');
     foreach ($list as $key => $model) {
         $collection = $this->mockCollection($model, $data[$key], array('initCache', 'count', 'load', 'getItemById'));
         $collection->expects($this->any())->method('initCache')->will($this->returnValue($collection));
         $collection->expects($this->any())->method('count')->will($this->returnValue(count($data[$key])));
         $collection->expects($this->any())->method('load')->will($this->returnValue($collection));
         $collection->expects($this->any())->method('getItemById')->will($this->returnCallback(array($this, $callback[$key])));
         $this->_collections[$key] = $collection;
     }
     Mage::app()->reinitStores();
     $result = 100;
     $this->assertEquals($result, $this->_object->getFirstStoreId());
     //TODO remove reinit store and DB usage
     Mage::clearRegistry();
     Mage::app()->reinitStores();
 }
Example #2
0
 /**
  * Clear registry on end test
  *
  * @return void
  */
 public function tearDown()
 {
     /**
      * Clear all registry with mock data
      */
     Mage::clearRegistry();
     parent::tearDown();
 }
Example #3
0
 public function testGetChannel()
 {
     Mage::clearRegistry();
     $this->assertNull($this->_object->getChannel());
     Mage::register('current_channel', new Varien_Object());
     $result = $this->_object->getChannel();
     $this->assertNotEmpty($result);
     $this->assertInstanceOf('Varien_Object', $result);
     Mage::clearRegistry();
 }
Example #4
0
 public function testGetValidatedAtText()
 {
     $validatedAt = date('Y-m-d');
     Mage::clearRegistry();
     Mage::register('current_account', new Varien_Object(array('validated_at' => $validatedAt)));
     $result = $this->_object->getValidatedAtText();
     $this->assertEquals("Valid Authorization Token.<br/>Valid until {$validatedAt}", $result);
     Mage::clearRegistry();
     Mage::register('current_account', new Varien_Object(array('validation_expired' => 1)));
     $result = $this->_object->getValidatedAtText();
     $this->assertEquals('<span class="error">Expired</span>', $result);
 }
Example #5
0
 public function testGetChannelType()
 {
     Mage::clearRegistry();
     Mage::register('current_channel', new Varien_Object(array('channeltype_code' => 'test_channeltype_code')));
     $result = $this->object->getChannelType();
     $this->assertInstanceOf('Varien_Object', $result);
     $this->assertFalse($result->hasData());
     $channel = Mage::getModel('xcom_ebay/channel');
     $channel->setId(1);
     $channel->setName('Ebay US');
     $channel->setChanneltypeCode('ebay');
     Mage::clearRegistry();
     Mage::register('current_channel', $channel);
     $result = $this->object->getChannelType();
     $this->assertInstanceOf('Varien_Object', $result);
     $this->assertTrue($result->hasData());
     $this->assertEquals('ebay', $result->getCode());
 }
Example #6
0
 public function testGetChannel()
 {
     $objectMock = $this->getMock('Xcom_Ebay_Block_Adminhtml_Channel_Edit_Tab_Policy', array('_construct'));
     $objectMock->expects($this->any())->method('_construct');
     Mage::clearRegistry();
     $this->assertNull($objectMock->getChannel());
     Mage::register('current_channel', new Varien_Object());
     $result = $objectMock->getChannel();
     $this->assertNotEmpty($result);
     $this->assertInstanceOf('Varien_Object', $result);
     Mage::clearRegistry();
 }