32 private $productRepository;
37 \
Magento\Catalog\Model\Product::class
40 ProductRepositoryInterface::class
46 $collection = $this->_model->getResourceCollection();
48 $this->assertEquals($this->_model->getStoreId(),
$collection->getStoreId());
53 $model = $this->_model->getUrlModel();
55 $this->assertSame(
$model, $this->_model->getUrlModel());
60 $this->assertEmpty($this->_model->getName());
61 $this->_model->setName(
'test');
62 $this->assertEquals(
'test', $this->_model->getName());
67 $this->assertEmpty($this->_model->getTypeId());
68 $this->_model->setTypeId(
'simple');
69 $this->assertEquals(
'simple', $this->_model->getTypeId());
76 $this->_model->getStatus()
83 $this->_model->getStatus()
87 public function testGetSetTypeInstance()
92 $this->assertSame(
$typeInstance, $this->_model->getTypeInstance());
97 \
Magento\Catalog\Model\Product::class
99 $this->assertSame(
$typeInstance, $otherProduct->getTypeInstance());
105 $this->_model->setTypeInstance($simpleTypeInstance);
106 $this->assertSame($simpleTypeInstance, $this->_model->getTypeInstance());
111 $this->assertGreaterThan(0, (
int)$this->_model->getIdBySku(
'simple'));
117 $this->_model->load(1);
139 $this->assertEmpty($this->_model->{
$method}());
140 $this->_model->setData($key,
$value);
147 [
'calculated_final_price',
'getCalculatedFinalPrice'],
148 [
'minimal_price',
'getMinimalPrice'],
149 [
'special_price',
'getSpecialPrice'],
150 [
'special_from_date',
'getSpecialFromDate'],
151 [
'special_to_date',
'getSpecialToDate'],
152 [
'request_path',
'getRequestPath'],
153 [
'gift_message_available',
'getGiftMessageAvailable'],
160 \
Magento\Catalog\Model\Product::class,
161 [
'data' => [
'media_attributes' =>
'test']]
163 $this->assertEquals(
'test',
$model->getMediaAttributes());
167 $this->assertArrayHasKey(
'small_image',
$attributes);
168 $this->assertArrayHasKey(
'thumbnail',
$attributes);
172 public function testGetMediaGalleryImages()
176 \
Magento\Catalog\Model\Product::class
178 $this->assertEmpty(
$model->getMediaGalleryImages());
180 $this->_model->setMediaGallery([
'images' => [[
'file' =>
'magento_image.jpg']]]);
181 $images = $this->_model->getMediaGalleryImages();
182 $this->assertInstanceOf(\
Magento\Framework\Data\Collection::class, $images);
183 foreach ($images as
$image) {
184 $this->assertInstanceOf(\
Magento\Framework\DataObject::class,
$image);
186 $this->assertArrayHasKey(
'file',
$image);
187 $this->assertArrayHasKey(
'url',
$image);
188 $this->assertArrayHasKey(
'id',
$image);
189 $this->assertArrayHasKey(
'path',
$image);
190 $this->assertStringEndsWith(
'magento_image.jpg',
$image[
'file']);
191 $this->assertStringEndsWith(
'magento_image.jpg',
$image[
'url']);
192 $this->assertStringEndsWith(
'magento_image.jpg',
$image[
'path']);
198 $model = $this->_model->getMediaConfig();
200 $this->assertSame(
$model, $this->_model->getMediaConfig());
205 $this->assertNull($this->_model->getAttributeText(
'status'));
206 $this->_model->setStatus(\
Magento\Catalog\Model\
Product\Attribute\Source\Status::STATUS_ENABLED);
207 $this->assertEquals(
'Enabled', $this->_model->getAttributeText(
'status'));
215 $product = $this->productRepository->get(
'simple_ms_2');
216 $product->getAttributeText(
'multiselect_attribute');
224 $product->getAttributeText(
'multiselect_attribute')
230 $this->assertEquals([
'from' =>
null,
'to' =>
null], $this->_model->getCustomDesignDate());
231 $this->_model->setCustomDesignFrom(1)->setCustomDesignTo(2);
232 $this->assertEquals([
'from' => 1,
'to' => 2], $this->_model->getCustomDesignDate());
240 $this->assertEmpty($this->_model->getSku());
241 $this->_model->setSku(
'sku');
242 $this->assertEquals(
'sku', $this->_model->getSku());
247 $this->assertEmpty($this->_model->getWeight());
248 $this->_model->setWeight(10.22);
249 $this->assertEquals(10.22, $this->_model->getWeight());
254 $model = $this->_model->getOptionInstance();
256 $this->assertSame(
$model, $this->_model->getOptionInstance());
261 $setId = $this->_model->getDefaultAttributeSetId();
262 $this->assertNotEmpty($setId);
263 $this->assertRegExp(
'/^[0-9]+$/', $setId);
268 $this->assertInstanceOf(\
Magento\Framework\DataObject::class, $this->_model->getPreconfiguredValues());
269 $this->_model->setPreconfiguredValues(
'test');
270 $this->assertEquals(
'test', $this->_model->getPreconfiguredValues());
277 \
Magento\Framework\Filesystem::class
278 )->getDirectoryWrite(
testGetAttributeTextArray()
testGetResourceCollection()
testGetObsoleteGetters($key, $method)
static tearDownAfterClass()
testGetCustomDesignDate()
getObsoleteGettersDataProvider()
testGetDefaultAttributeSetId()
testGetPreconfiguredValues()
static getObjectManager()