Example #1
0
 public function testSetListCollection()
 {
     $childBlock = $this->_layout->addBlock('Mage_Core_Block_Text', 'search_result_list', 'block');
     $this->assertEmpty($childBlock->getCollection());
     $this->_block->setListCollection();
     $this->assertInstanceOf('Mage_CatalogSearch_Model_Resource_Advanced_Collection', $childBlock->getCollection());
 }
Example #2
0
 protected function setUp()
 {
     $this->_layoutMock = Mage::getModel('Mage_Core_Model_Layout');
     $this->_block = new Mage_Backend_Block_Widget_Grid_Extended(array('layout' => $this->_layoutMock));
     $this->_layoutMock->addBlock($this->_block, 'grid');
     $this->_block->addColumn('column1', array('id' => 'columnId1'));
     $this->_block->addColumn('column2', array('id' => 'columnId2'));
 }
Example #3
0
 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout');
     $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory');
     $this->_block = $this->_blockFactory->createBlock('Mage_Webapi_Block_Adminhtml_User_Edit_Tab_Main');
     $this->_layout->addBlock($this->_block);
 }
Example #4
0
 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     $this->_urlBuilder = $this->getMockBuilder('Mage_Backend_Model_Url')->disableOriginalConstructor()->getMock();
     $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout');
     $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory');
     $this->_block = $this->_blockFactory->createBlock($this->_formClass, array('urlBuilder' => $this->_urlBuilder));
     $this->_layout->addBlock($this->_block);
 }
Example #5
0
 public function testGetColumns()
 {
     $layout = new Mage_Core_Model_Layout();
     $block = $layout->addBlock('Mage_Wishlist_Block_Customer_Wishlist_Items', 'test');
     $child = $this->getMock('Mage_Core_Block_Text', array('isEnabled'));
     $child->expects($this->any())->method('isEnabled')->will($this->returnValue(true));
     $layout->addBlock($child, 'child', 'test');
     $this->assertSame(array($child), $block->getColumns());
 }
Example #6
0
 public function testSetListOrders()
 {
     $layout = new Mage_Core_Model_Layout();
     $layout->addBlock('Mage_Core_Block_Text', 'head');
     // The tested block is using head block
     $block = $layout->addBlock('Mage_CatalogSearch_Block_Result', 'block');
     $childBlock = $layout->addBlock('Mage_Core_Block_Text', 'search_result_list', 'block');
     $this->assertSame($childBlock, $block->getListBlock());
 }
Example #7
0
 protected function setUp()
 {
     $this->_layout = Mage::getModel('Mage_Core_Model_Layout');
     $this->_layout->addBlock('Mage_Core_Block_Text', 'root');
     $this->_layout->addBlock('Mage_Core_Block_Text', 'head');
     $this->_block = $this->_layout->createBlock('Mage_Tag_Block_Product_Result', 'test', array('layout' => $this->_layout));
     $this->_child = Mage::getObjectManager()->create('Mage_Core_Block_Text');
     $this->_layout->addBlock($this->_child, 'search_result_list', 'test');
 }
Example #8
0
 public function testGetMode()
 {
     $layout = new Mage_Core_Model_Layout();
     $layout->addBlock($this->_block, 'test');
     $expected = uniqid();
     $toolbar = new Mage_Core_Block_Text(array('current_mode' => $expected));
     $layout->addBlock($toolbar, 'toolbar', 'test');
     $this->assertEquals($expected, $this->_block->getMode());
 }
Example #9
0
 /**
  * Reuse code for testing getUploadButtonHtml()
  *
  * @param Mage_Core_Block_Abstract $block
  */
 public static function performUploadButtonTest(Mage_Core_Block_Abstract $block)
 {
     $layout = new Mage_Core_Model_Layout();
     $layout->addBlock($block, 'links');
     $expected = uniqid();
     $text = new Mage_Core_Block_Text(array('text' => $expected));
     $layout->addBlock($text, 'upload_button', 'links');
     self::assertEquals($expected, $block->getUploadButtonHtml());
 }
Example #10
0
 protected function setUp()
 {
     $this->_authorizationConfig = $this->getMockBuilder('Mage_Webapi_Model_Authorization_Config')->disableOriginalConstructor()->setMethods(array('getAclResourcesAsArray'))->getMock();
     $this->_ruleResource = $this->getMockBuilder('Mage_Webapi_Model_Resource_Acl_Rule')->disableOriginalConstructor()->setMethods(array('getResourceIdsByRole'))->getMock();
     $this->_objectManager = Mage::getObjectManager();
     $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout');
     $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory');
     $this->_block = $this->_blockFactory->createBlock('Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_Resource', array('authorizationConfig' => $this->_authorizationConfig, 'ruleResource' => $this->_ruleResource));
     $this->_layout->addBlock($this->_block);
 }
Example #11
0
 protected function setUp()
 {
     $this->_block = new Mage_Tag_Block_Product_Result();
     $this->_layout = new Mage_Core_Model_Layout();
     $this->_layout->addBlock('Mage_Core_Block_Text', 'root');
     $this->_layout->addBlock('Mage_Core_Block_Text', 'head');
     $this->_layout->addBlock($this->_block, 'test');
     $this->_child = new Mage_Core_Block_Text();
     $this->_layout->addBlock($this->_child, 'search_result_list', 'test');
 }
Example #12
0
 public function testSetLayout()
 {
     $layout = new Mage_Core_Model_Layout();
     $headBlock = new Mage_Core_Block_Template();
     $layout->addBlock($headBlock, 'head');
     $layout->addBlock($this->_block);
     $this->assertNotEmpty($headBlock->getTitle());
     $this->assertEquals($this->_product->getMetaTitle(), $headBlock->getTitle());
     $this->assertEquals($this->_product->getMetaKeyword(), $headBlock->getKeywords());
     $this->assertEquals($this->_product->getMetaDescription(), $headBlock->getDescription());
 }
Example #13
0
 public function testGetFormHtml()
 {
     $layout = new Mage_Core_Model_Layout();
     // Create block with blocking _prepateLayout(), which is used by block to instantly add 'form' child
     $block = $this->getMock('Mage_Adminhtml_Block_Widget_Form_Container', array('_prepareLayout'));
     $layout->addBlock($block, 'block');
     $form = $layout->addBlock('Mage_Core_Block_Text', 'form', 'block');
     $expectedHtml = '<b>html</b>';
     $this->assertNotEquals($expectedHtml, $block->getFormHtml());
     $form->setText($expectedHtml);
     $this->assertEquals($expectedHtml, $block->getFormHtml());
 }
Example #14
0
 public function testToHtmlFormId()
 {
     $layout = new Mage_Core_Model_Layout();
     $block = $layout->addBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Add', 'block');
     $block->setArea('adminhtml');
     $childBlock = $layout->addBlock('Mage_Core_Block_Template', 'setForm', 'block');
     $form = new Varien_Object();
     $childBlock->setForm($form);
     $expectedId = '12121212';
     $this->assertNotContains($expectedId, $block->toHtml());
     $form->setId($expectedId);
     $this->assertContains($expectedId, $block->toHtml());
 }
Example #15
0
 public function testGetItemExtraInfoHtml()
 {
     $layout = new Mage_Core_Model_Layout();
     $block = $this->getMockForAbstractClass('Mage_Adminhtml_Block_Sales_Items_Abstract');
     $layout->addBlock($block, 'block');
     $item = new Varien_Object();
     $this->assertEmpty($block->getItemExtraInfoHtml($item));
     $expectedHtml = '<html><body>some data</body></html>';
     $childBlock = $layout->addBlock('Mage_Core_Block_Text', 'other_block', 'block', 'order_item_extra_info');
     $childBlock->setText($expectedHtml);
     $this->assertEquals($expectedHtml, $block->getItemExtraInfoHtml($item));
     $this->assertSame($item, $childBlock->getItem());
 }
Example #16
0
 public function testToHtmlWithContainer()
 {
     $listName = $this->_block->getNameInLayout();
     $block1 = $this->_layout->addBlock('Mage_Core_Block_Text', '', $listName);
     $this->_layout->addContainer('container', 'Container', array(), $listName);
     $block2 = $this->_layout->addBlock('Mage_Core_Block_Text', '', 'container');
     $block3 = $this->_layout->addBlock('Mage_Core_Block_Text', '', $listName);
     $block1->setText('text1');
     $block2->setText('text2');
     $block3->setText('text3');
     $html = $this->_block->toHtml();
     $this->assertEquals('text1text2text3', $html);
 }
Example #17
0
 public function testGetInvoiceCommentsHtml()
 {
     $childBlock = $this->_layout->addBlock('Mage_Core_Block_Text', 'invoice_comments', 'block');
     $expectedHtml = '<b>Any html</b>';
     $this->assertEmpty($childBlock->getEntity());
     $this->assertEmpty($childBlock->getTitle());
     $this->assertNotEquals($expectedHtml, $this->_block->getInvoiceCommentsHtml($this->_invoice));
     $childBlock->setText($expectedHtml);
     $actualHtml = $this->_block->getInvoiceCommentsHtml($this->_invoice);
     $this->assertSame($this->_invoice, $childBlock->getEntity());
     $this->assertNotEmpty($childBlock->getTitle());
     $this->assertEquals($expectedHtml, $actualHtml);
 }
Example #18
0
 public function testToHtmlPropagatesUrl()
 {
     $this->_block->setShouldPrepareInfoTabs(true);
     $childOne = $this->_layout->addBlock('Mage_Core_Block_Text', 'child1', 'block');
     $this->_layout->addToParentGroup('child1', 'info_tabs');
     $childTwo = $this->_layout->addBlock('Mage_Core_Block_Text', 'child2', 'block');
     $this->_layout->addToParentGroup('child2', 'info_tabs');
     $this->assertEmpty($childOne->getViewUrl());
     $this->assertEmpty($childTwo->getViewUrl());
     $this->_block->toHtml();
     $this->assertNotEmpty($childOne->getViewUrl());
     $this->assertNotEmpty($childTwo->getViewUrl());
 }
Example #19
0
 public function testBeforeToHtml()
 {
     $this->markTestIncomplete('Mage_GoogleShopping is not implemented yet');
     $block = new Mage_GoogleShopping_Block_Adminhtml_Items_Product();
     $filter = new Mage_Core_Block_Text();
     $search = new Mage_Core_Block_Text();
     $layout = new Mage_Core_Model_Layout();
     $layout->addBlock($block, 'product');
     $layout->addBlock($filter, 'reset_filter_button', 'product');
     $layout->addBlock($search, 'search_button', 'product');
     $block->toHtml();
     $this->assertEquals('googleshopping_selection_search_grid_JsObject.resetFilter()', $filter->getData('onclick'));
     $this->assertEquals('googleshopping_selection_search_grid_JsObject.doFilter()', $search->getData('onclick'));
 }
Example #20
0
 /**
  * @magentoDataFixture Mage/Catalog/_files/product_simple.php
  * @magentoAppIsolation enabled
  */
 public function testPrepareLayout()
 {
     Mage::getConfig()->setCurrentAreaCode(Mage::helper("Mage_Backend_Helper_Data")->getAreaCode());
     $product = new Mage_Catalog_Model_Product();
     $product->load(1);
     // fixture
     Mage::register('product', $product);
     $layout = new Mage_Core_Model_Layout();
     $layout->addBlock('Mage_Core_Block_Text', 'head');
     $block = new Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs();
     $layout->addBlock($block);
     $this->assertArrayHasKey(0, $block->getTabsIds());
     $this->assertNotEmpty($layout->getBlock('adminhtml.catalog.product.edit.tab.attributes'));
 }
Example #21
0
 public function testToHtmlWithContainer()
 {
     $listName = $this->_block->getNameInLayout();
     $block1 = $this->_layout->addBlock('Mage_Core_Block_Text', '', $listName);
     //$this->_layout->insertContainer($listName, 'container');
     $block2 = $this->_layout->addBlock('Mage_Core_Block_Text', '', 'container');
     $block3 = $this->_layout->addBlock('Mage_Core_Block_Text', '', $listName);
     $block1->setText('text1');
     $block2->setText('text2');
     $block3->setText('text3');
     ob_start();
     $this->_block->toHtml();
     $html = ob_get_clean();
     $this->assertEquals('text1text2text3', $html);
 }
Example #22
0
 public function testToHtmlChildrenInitialized()
 {
     $block = new Mage_Sales_Block_Order_Totals();
     $block->setOrder(new Mage_Sales_Model_Order())->setTemplate('order/totals.phtml');
     $layout = new Mage_Core_Model_Layout();
     $layout->addBlock($block, 'block');
     $child1 = $this->getMock('Mage_Core_Block_Text', array('initTotals'));
     $child1->expects($this->once())->method('initTotals');
     $layout->addBlock($child1, 'child1', 'block');
     $layout->addBlock('Mage_Core_Block_Text', 'child2', 'block');
     $child3 = $this->getMock('Mage_Core_Block_Text', array('initTotals'));
     $child3->expects($this->once())->method('initTotals');
     $layout->addBlock($child3, 'child3', 'block');
     $block->toHtml();
 }
Example #23
0
 public function testGetAdditionalActionBlock()
 {
     $layout = new Mage_Core_Model_Layout();
     $block = $layout->createBlock('Mage_Adminhtml_Block_Widget_Grid_Massaction_Item', 'block');
     $expected = $layout->addBlock('Mage_Core_Block_Template', 'additional_action', 'block');
     $this->assertSame($expected, $block->getAdditionalActionBlock());
 }
Example #24
0
 public function testGetMassactionBlock()
 {
     $layout = new Mage_Core_Model_Layout();
     $block = $layout->createBlock('Mage_Adminhtml_Block_Widget_Grid', 'block');
     $child = $layout->addBlock('Mage_Core_Block_Template', 'massaction', 'block');
     $this->assertSame($child, $block->getMassactionBlock());
 }
Example #25
0
 public function testGetCommentsHtml()
 {
     $block = new Mage_Sales_Block_Order_Shipment_Items();
     $layout = new Mage_Core_Model_Layout();
     $layout->addBlock($block, 'block');
     $childBlock = $layout->addBlock('Mage_Core_Block_Text', 'shipment_comments', 'block');
     $shipment = new Mage_Sales_Model_Order_Shipment();
     $expectedHtml = '<b>Any html</b>';
     $this->assertEmpty($childBlock->getEntity());
     $this->assertEmpty($childBlock->getTitle());
     $this->assertNotEquals($expectedHtml, $block->getCommentsHtml($shipment));
     $childBlock->setText($expectedHtml);
     $actualHtml = $block->getCommentsHtml($shipment);
     $this->assertSame($shipment, $childBlock->getEntity());
     $this->assertNotEmpty($childBlock->getTitle());
     $this->assertEquals($expectedHtml, $actualHtml);
 }
Example #26
0
 public function testGetChildHtmlList()
 {
     $layout = new Mage_Core_Model_Layout();
     $block = new Mage_Catalog_Block_Product_View_Additional();
     $layout->addBlock($block, 'block');
     $child1 = $layout->addBlock('Mage_Core_Block_Text', 'child1', 'block');
     $expectedHtml1 = '<b>Any html of child1</b>';
     $child1->setText($expectedHtml1);
     $child2 = $layout->addBlock('Mage_Core_Block_Text', 'child2', 'block');
     $expectedHtml2 = '<b>Any html of child2</b>';
     $child2->setText($expectedHtml2);
     $list = $block->getChildHtmlList();
     $this->assertInternalType('array', $list);
     $this->assertCount(2, $list);
     $this->assertContains($expectedHtml1, $list);
     $this->assertContains($expectedHtml2, $list);
 }
Example #27
0
 /**
  * Test _beforeToHtml method
  */
 public function testBeforeToHtml()
 {
     // TODO Move to unit tests after MAGETWO-4015 complete
     /** @var Mage_Webapi_Block_Adminhtml_User_Edit_Tab_Main $mainTabBlock */
     $mainTabBlock = $this->_layout->addBlock('Mage_Core_Block_Text', 'webapi.user.edit.tab.main', 'webapi.user.edit.tabs')->setText('Main Block Content');
     $this->_layout->addBlock('Mage_Core_Block_Text', 'webapi.user.edit.tab.roles.grid', 'webapi.user.edit.tabs')->setText('Grid Block Content');
     $apiUser = new Varien_Object(array('role_id' => 1));
     $this->_block->setApiUser($apiUser);
     $this->_block->toHtml();
     $this->assertSame($apiUser, $mainTabBlock->getApiUser());
     $tabs = $this->_getProtectedTabsValue($this->_block);
     $this->assertArrayHasKey('main_section', $tabs);
     $this->assertInstanceOf('Varien_Object', $tabs['main_section']);
     $this->assertEquals(array('label' => 'User Info', 'title' => 'User Info', 'content' => 'Main Block Content', 'active' => '1', 'url' => '#', 'id' => 'main_section', 'tab_id' => 'main_section'), $tabs['main_section']->getData());
     $this->assertArrayHasKey('roles_section', $tabs);
     $this->assertInstanceOf('Varien_Object', $tabs['roles_section']);
     $this->assertEquals(array('label' => 'User Role', 'title' => 'User Role', 'content' => 'Grid Block Content', 'url' => '#', 'id' => 'roles_section', 'tab_id' => 'roles_section'), $tabs['roles_section']->getData());
 }
Example #28
0
 /**
  * Composes a container with several buttons in it
  *
  * @param array $titles
  * @return Mage_Adminhtml_Block_Widget_Container
  */
 protected function _buildBlock($titles)
 {
     $layout = new Mage_Core_Model_Layout();
     $block = new Mage_Adminhtml_Block_Widget_Container();
     foreach ($titles as $id => $title) {
         $block->addButton($id, array('title' => $title));
     }
     $layout->addBlock($block, 'block');
     return $block;
 }
Example #29
0
 public function testGetShowQueueAdd()
 {
     $layout = new Mage_Core_Model_Layout();
     $block = $layout->createBlock('Mage_Adminhtml_Block_Newsletter_Subscriber', 'block');
     $childBlock = $layout->addBlock('Mage_Core_Block_Template', 'grid', 'block');
     $expected = 'test_data';
     $this->assertNotEquals($expected, $block->getShowQueueAdd());
     $childBlock->setShowQueueAdd($expected);
     $this->assertEquals($expected, $block->getShowQueueAdd());
 }
Example #30
0
 public function testSetClassType()
 {
     $layout = new Mage_Core_Model_Layout();
     $block = $layout->createBlock('Mage_Adminhtml_Block_Tax_Class_Edit', 'block');
     $childBlock = $layout->addBlock('Mage_Core_Block_Template', 'form', 'block');
     $expected = 'a_class_type';
     $this->assertNotEquals($expected, $childBlock->getClassType());
     $block->setClassType($expected);
     $this->assertEquals($expected, $childBlock->getClassType());
 }