![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/integration/testsuite/Magento/ImportExport/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\ImportExport\Model; use ReflectionClass; class ExportTest extends \PHPUnit\Framework\TestCase { /** * Model object which used for tests * * @var \Magento\ImportExport\Model\Export */ protected $_model; protected function setUp(): void { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\ImportExport\Model\Export::class ); } /** * Test method '_getEntityAdapter' in case when entity is valid * * @param string $entity * @param string $expectedEntityType * @dataProvider getEntityDataProvider * @covers \Magento\ImportExport\Model\Export::_getEntityAdapter */ public function testGetEntityAdapterWithValidEntity($entity, $expectedEntityType) { $this->_model->setData(['entity' => $entity]); $this->_model->getEntityAttributeCollection(); $this->assertIsObject($this->_model); $this->assertTrue(property_exists($this->_model, '_entityAdapter')); $object = new ReflectionClass(get_class($this->_model)); $attribute = $object->getProperty('_entityAdapter'); $attribute->setAccessible(true); $propertyObject = $attribute->getValue($this->_model); $attribute->setAccessible(false); $this->assertInstanceOf($expectedEntityType, $propertyObject); } /** * @return array */ public function getEntityDataProvider() { return [ 'product' => [ '$entity' => 'catalog_product', '$expectedEntityType' => \Magento\CatalogImportExport\Model\Export\Product::class, ], 'customer main data' => [ '$entity' => 'customer', '$expectedEntityType' => \Magento\CustomerImportExport\Model\Export\Customer::class, ], 'customer address' => [ '$entity' => 'customer_address', '$expectedEntityType' => \Magento\CustomerImportExport\Model\Export\Address::class, ] ]; } /** * Test method '_getEntityAdapter' in case when entity is invalid * * @covers \Magento\ImportExport\Model\Export::_getEntityAdapter */ public function testGetEntityAdapterWithInvalidEntity() { $this->expectException(\Magento\Framework\Exception\LocalizedException::class); $this->_model->setData(['entity' => 'test']); $this->_model->getEntityAttributeCollection(); } }