Exemple #1
0
 public function testSaveAttribute()
 {
     $data = array('id' => 'test_id', 'name' => 'test_name', 'channelAttributeDecorations' => array(0 => array('channelId' => 'test_channel_id_1', 'required' => true, 'supportsVariation' => true), 1 => array('channelId' => 'test_channel_id_2', 'required' => true, 'supportsVariation' => false)), 'description' => 'test_description', 'allowMultipleValues' => true, 'defaultValue' => 'test_value_id', 'locale' => array('country' => 'test_US', 'language' => 'test_en'));
     $productTypeMock = $this->mockModel('xcom_mapping/product_type');
     $productTypeMock->expects($this->any())->method('getId')->will($this->returnValue('100500'));
     $expectedData = array('attribute_id' => $data['id'], 'mapping_product_type_id' => $productTypeMock->getId(), 'name' => $data['name'], 'channel_decoration' => array(0 => array('channel_code' => $data['channelAttributeDecorations'][0]['channelId'], 'is_required' => $data['channelAttributeDecorations'][0]['required'], 'is_variation' => $data['channelAttributeDecorations'][0]['supportsVariation']), 1 => array('channel_code' => $data['channelAttributeDecorations'][1]['channelId'], 'is_required' => $data['channelAttributeDecorations'][1]['required'], 'is_variation' => $data['channelAttributeDecorations'][1]['supportsVariation'])), 'description' => $data['description'], 'is_multiselect' => $data['allowMultipleValues'], 'default_value_ids' => $data['defaultValue'], 'locale_code' => 'test_en_test_US', 'is_restricted' => 1);
     $attributeMock = $this->mockModel('xcom_mapping/attribute', array('deleteAllIds', 'save', 'addData'));
     $attributeMock->expects($this->any())->method('addData')->with($this->equalTo($expectedData))->will($this->returnValue($attributeMock));
     $attributeMock->expects($this->any())->method('save')->will($this->returnValue($attributeMock));
     $this->_object->setBody($data);
     $result = $this->_object->saveAttribute($productTypeMock, $attributeMock, $data);
     $this->assertInstanceOf($this->_instanceOf, $result);
 }