/**
  * @magentoDataFixture Mage/Core/_files/store.php
  * @magentoDbIsolation enabled
  * @dataProvider saveActionDataProvider
  * @param array $inputData
  * @param array $defaultAttributes
  * @param array $attributesSaved
  */
 public function testSaveAction($inputData, $defaultAttributes, $attributesSaved = array())
 {
     $store = new Mage_Core_Model_Store();
     $store->load('fixturestore', 'code');
     $storeId = $store->getId();
     $this->getRequest()->setPost($inputData);
     $this->getRequest()->setParam('store', $storeId);
     $this->getRequest()->setParam('id', 2);
     $this->dispatch('backend/admin/catalog_category/save');
     $messages = Mage::getSingleton('Mage_Backend_Model_Session')->getMessages(false)->getItemsByType(Mage_Core_Model_Message::SUCCESS);
     $this->assertNotEmpty($messages, "Could not save category");
     $this->assertEquals('The category has been saved.', current($messages)->getCode());
     $category = new Mage_Catalog_Model_Category();
     $category->setStoreId($storeId);
     $category->load(2);
     $errors = array();
     foreach ($attributesSaved as $attribute => $value) {
         $actualValue = $category->getData($attribute);
         if ($value !== $actualValue) {
             $errors[] = "value for '{$attribute}' attribute must be '{$value}', but '{$actualValue}' is found instead";
         }
     }
     foreach ($defaultAttributes as $attribute => $exists) {
         if ($exists !== $category->getExistsStoreValueFlag($attribute)) {
             if ($exists) {
                 $errors[] = "custom value for '{$attribute}' attribute is not found";
             } else {
                 $errors[] = "custom value for '{$attribute}' attribute is found, but default one must be used";
             }
         }
     }
     $this->assertEmpty($errors, "\n" . join("\n", $errors));
 }
Example #2
0
 public function testIsCanDelete()
 {
     $this->assertFalse($this->_model->isCanDelete());
     $this->_model->load(1);
     $this->assertFalse($this->_model->isCanDelete());
     $this->_model->setId(100);
     $this->assertTrue($this->_model->isCanDelete());
 }