public function testDisplay() { $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 with FirePHP/1.6'; $this->_response->expects($this->atLeastOnce())->method('sendHeaders'); $this->_object->display(); $actualHeaders = $this->_response->getHeaders(); $this->assertNotEmpty($actualHeaders); $actualProtocol = false; $actualProfilerData = false; foreach ($actualHeaders as $oneHeader) { $headerName = $oneHeader['name']; $headerValue = $oneHeader['value']; if (!$actualProtocol && $headerName == 'X-Wf-Protocol-1') { $actualProtocol = $headerValue; } if (!$actualProfilerData && $headerName == 'X-Wf-1-1-1-1') { $actualProfilerData = $headerValue; } } $this->assertContains('Protocol/JsonStream', $actualProtocol); $this->assertContains('"Type":"TABLE","Label":"Code Profiler Title"', $actualProfilerData); $this->assertContains('[' . '["Timer Id","Time","Avg","Cnt","Emalloc","RealMem"],' . '["some_root_timer","0.080000","0.040000","2","51,000,000","50,000,000"],' . '[". some_nested_timer","0.080000","0.026667","3","42,000,000","40,000,000"],' . '[". . some_deeply_nested_timer","0.030000","0.010000","3","13,000,000","10,000,000"],' . '["one_more_root_timer","0.010000","0.010000","1","23,456,789","12,345,678"]]', $actualProfilerData); }
/** * Test for Mage_Adminhtml_Catalog_ProductController::quickCreateAction */ public function testQuickCreateActionWithDangerRequest() { $data = array('entity_id' => 234); $this->_request->expects($this->any())->method('getParam')->will($this->returnValue($data)); $typeInstance = $this->getMockBuilder('Mage_Catalog_Model_Product_Type')->setMethods(array('getConfigurableAttributes', 'getEditableAttributes'))->getMock(); $typeInstance->expects($this->any())->method('getEditableAttributes')->will($this->returnValue(array())); $typeInstance->expects($this->any())->method('getConfigurableAttributes')->will($this->returnValue(array())); $productMock = $this->getMockBuilder('Mage_Catalog_Model_Product')->setMethods(array('getIdFieldName', 'save', 'getSku', 'isConfigurable', 'setStoreId', 'load', 'setTypeId', 'setAttributeSetId', 'getAttributeSetId', 'getTypeInstance', 'getWebsiteIds'))->disableOriginalConstructor()->getMock(); $productMock->expects($this->any())->method('getIdFieldName')->will($this->returnValue('entity_id')); $productMock->expects($this->any())->method('isConfigurable')->will($this->returnValue(true)); $productMock->expects($this->any())->method('setStoreId')->will($this->returnSelf()); $productMock->expects($this->any())->method('load')->will($this->returnSelf()); $productMock->expects($this->any())->method('setTypeId')->will($this->returnSelf()); $productMock->expects($this->any())->method('setAttributeSetId')->will($this->returnSelf()); $productMock->expects($this->any())->method('getTypeInstance')->will($this->returnValue($typeInstance)); $productMock->expects($this->never())->method('save'); $this->_response->expects($this->once())->method('setBody')->with('{"attributes":[],"error":{"message":"Unable to create product"}}'); $helper = $this->getMockBuilder('Mage_Core_Helper_Data')->setMethods(array('jsonEncode'))->getMock(); $helper->expects($this->once())->method('jsonEncode')->with(array('attributes' => array(), 'error' => array('message' => 'Unable to create product', 'fields' => array('sku' => ''))))->will($this->returnValue('{"attributes":[],"error":{"message":"Unable to create product"}}')); $this->_objectManager->expects($this->any())->method('create')->with('Mage_Catalog_Model_Product', array(), true)->will($this->returnValue($productMock)); $this->_objectManager->expects($this->any())->method('get')->with('Mage_Core_Helper_Data', array())->will($this->returnValue($helper)); $this->_controller->quickCreateAction(); }