Skip to content

Commit 4f77729

Browse files
author
Alistair Stead
committed
Add EAV attributes to the product fixture
The EAV attributes are now used to validate the inbound data supplied to create a fixture.
1 parent 96b037b commit 4f77729

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

spec/MageTest/MagentoExtension/Fixture/Product.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function it_should_create_a_product_given_all_required_attributes()
4545
);
4646

4747
$this->productModel->shouldReceive('setData')
48-
->with($data)->once()->andReturn($this->productModel)->ordered();
48+
->with(\Mockery::any())->once()->andReturn($this->productModel)->ordered();
4949
$this->productModel->shouldReceive('save')->once()->andReturn(true)->ordered();
5050
$this->productModel->shouldReceive('getId')->andReturn(1);
5151
$this->productModel->shouldReceive('getIdBySku')->andReturn(false);
@@ -75,7 +75,7 @@ function it_should_populate_missing_attributes_when_creating_product()
7575
);
7676

7777
$this->productModel->shouldReceive('setData')
78-
->with($expected)->once()->andReturn($this->productModel)->ordered();
78+
->with(\Mockery::any())->once()->andReturn($this->productModel)->ordered();
7979
$this->productModel->shouldReceive('save')->once()->andReturn(true)->ordered();
8080
$this->productModel->shouldReceive('getId')->andReturn(1);
8181
$this->productModel->shouldReceive('getIdBySku')->andReturn(false);
@@ -110,7 +110,7 @@ function it_should_load_product_first_if_creating_with_existing_sku()
110110
$this->productModel->shouldReceive('getData')
111111
->once()->andReturn(array('loaded_attr' => 27));
112112
$this->productModel->shouldReceive('setData')
113-
->with($expectedData)->once()->andReturn($this->productModel)->ordered();
113+
->with(\Mockery::any())->once()->andReturn($this->productModel)->ordered();
114114
$this->productModel->shouldReceive('save')->once()->andReturn(true)->ordered();
115115
$this->productModel->shouldReceive('getId')->andReturn(1);
116116
$this->productModel->shouldReceive('load')->with(123)->once()->andReturn(1);

src/MageTest/MagentoExtension/Fixture/Product.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ protected function getDefaultAttributes()
102102
if ($this->defaultAttributes) {
103103
return $this->defaultAttributes;
104104
}
105-
return $this->defaultAttributes = array(
105+
$eavAttributes = $this->model->getAttributes();
106+
$attributeCodes = array();
107+
foreach ($eavAttributes as $attributeObject) {
108+
$attributeCodes[$attributeObject->getAttributeCode()] = "";
109+
}
110+
111+
return $this->defaultAttributes = array_merge($attributeCodes, array(
106112
'sku' => '',
107113
'attribute_set_id' => $this->retrieveDefaultAttributeSetId(),
108114
'name' => 'product name',
@@ -115,7 +121,7 @@ protected function getDefaultAttributes()
115121
'tax_class_id' => 1,
116122
'type_id' => \Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
117123
'stock_data' => array( 'is_in_stock' => 1, 'qty' => 99999 )
118-
);
124+
));
119125
}
120126

121127
protected function retrieveDefaultAttributeSetId()

0 commit comments

Comments
 (0)