PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/dev/tests/integration/testsuite/Mage/DesignEditor/Model/HistoryTest.php

https://bitbucket.org/sunil_nextbits/magento2
PHP | 194 lines | 108 code | 14 blank | 72 comment | 0 complexity | 23d7f13f7183ae0a3b5e169191d794f2 MD5 | raw file
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Magento
  22. * @package Mage_DesignEditor
  23. * @subpackage integration_tests
  24. * @copyright Copyright (c) 2012 X.commerce, Inc. (http://www.magentocommerce.com)
  25. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  26. */
  27. class Mage_DesignEditor_Model_HistoryTest extends PHPUnit_Framework_TestCase
  28. {
  29. /**
  30. * @var Mage_DesignEditor_Model_History
  31. */
  32. protected $_historyObject;
  33. /**
  34. * Get clear history model
  35. *
  36. * @return Mage_DesignEditor_Model_History
  37. */
  38. protected function getClearHistoryModel()
  39. {
  40. return $this->_historyObject = Mage::getModel('Mage_DesignEditor_Model_History');
  41. }
  42. /**
  43. * Add change test
  44. *
  45. * @dataProvider getChange
  46. */
  47. public function testAddChange($change)
  48. {
  49. $historyModel = $this->getClearHistoryModel();
  50. $collection = $historyModel->addChange($change)->getChanges();
  51. $this->assertEquals(array($change), $collection->toArray());
  52. }
  53. /**
  54. * Add change with invalid data test
  55. *
  56. * @dataProvider getInvalidChange
  57. * @expectedException Magento_Exception
  58. */
  59. public function testAddChangeWithInvalidData($change)
  60. {
  61. $historyModel = $this->getClearHistoryModel();
  62. $historyModel->addChange($change)->getChanges();
  63. }
  64. /**
  65. * Set changes test
  66. *
  67. * @dataProvider getChanges
  68. */
  69. public function testSetChanges($changes)
  70. {
  71. $historyModel = $this->getClearHistoryModel();
  72. $collection = $historyModel->setChanges($changes)->getChanges();
  73. $this->assertEquals($changes, $collection->toArray());
  74. }
  75. /**
  76. * Test output(renderer)
  77. *
  78. * @dataProvider getChanges
  79. */
  80. public function testOutput($changes)
  81. {
  82. $historyModel = $this->getClearHistoryModel();
  83. /** @var $layoutRenderer Mage_DesignEditor_Model_History_Renderer_LayoutUpdate */
  84. $layoutRenderer = Mage::getModel('Mage_DesignEditor_Model_History_Renderer_LayoutUpdate');
  85. /** @var $collection Mage_DesignEditor_Model_Change_Collection */
  86. $collection = $historyModel->setChanges($changes)->getChanges();
  87. /** @var $historyCompactModel Mage_DesignEditor_Model_History_Compact */
  88. $historyCompactModel = Mage::getModel('Mage_DesignEditor_Model_History_Compact');
  89. $historyCompactModel->compact($collection);
  90. $this->assertXmlStringEqualsXmlFile(
  91. realpath(__DIR__) . '/../_files/history/layout_renderer.xml', $historyModel->output($layoutRenderer)
  92. );
  93. }
  94. /**
  95. * Get change
  96. *
  97. * @return array
  98. */
  99. public function getChange()
  100. {
  101. return array(array(
  102. array(
  103. 'handle' => 'customer_account',
  104. 'type' => 'layout',
  105. 'element_name' => 'customer_account_navigation',
  106. 'action_name' => 'move',
  107. 'destination_container' => 'content',
  108. 'destination_order' => '-',
  109. 'origin_container' => 'top.menu',
  110. 'origin_order' => '-'
  111. ),
  112. ));
  113. }
  114. /**
  115. * Get invalid change
  116. *
  117. * @return array
  118. */
  119. public function getInvalidChange()
  120. {
  121. return array(array(
  122. array(
  123. 'handle' => 'customer_account',
  124. 'type' => '',
  125. 'element_name' => '',
  126. 'action_name' => 'move',
  127. 'destination_container' => 'content',
  128. 'destination_order' => '-',
  129. 'origin_container' => 'top.menu',
  130. 'origin_order' => '-'
  131. ),
  132. ));
  133. }
  134. /**
  135. * Get changes
  136. *
  137. * @return array
  138. */
  139. public function getChanges()
  140. {
  141. return array(array(array(
  142. array(
  143. 'handle' => 'customer_account',
  144. 'type' => 'layout',
  145. 'element_name' => 'customer_account_navigation',
  146. 'action_name' => 'move',
  147. 'destination_container' => 'content',
  148. 'destination_order' => '-',
  149. 'origin_container' => 'top.menu',
  150. 'origin_order' => '-'
  151. ),
  152. array(
  153. 'handle' => 'customer_account',
  154. 'type' => 'layout',
  155. 'element_name' => 'customer_account_navigation',
  156. 'action_name' => 'move',
  157. 'destination_container' => 'right',
  158. 'destination_order' => '-',
  159. 'origin_container' => 'content',
  160. 'origin_order' => '-'
  161. ),
  162. array(
  163. 'handle' => 'catalog_category_view',
  164. 'type' => 'layout',
  165. 'element_name' => 'category.products',
  166. 'action_name' => 'move',
  167. 'destination_container' => 'content',
  168. 'destination_order' => '-',
  169. 'origin_container' => 'right',
  170. 'origin_order' => '-'
  171. ),
  172. array(
  173. 'handle' => 'catalog_category_view',
  174. 'type' => 'layout',
  175. 'element_name' => 'category.products',
  176. 'action_name' => 'remove',
  177. ),
  178. )));
  179. }
  180. }