Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes
FixtureModelTest Class Reference
Inheritance diagram for FixtureModelTest:
TestCase

Public Member Functions

 testFixtureGeneration ()
 

Static Public Member Functions

static setUpBeforeClass ()
 
- Static Public Member Functions inherited from TestCase
static tearDownAfterClass ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Static Protected Attributes

static $_generatorWorkingDir
 

Detailed Description

Class Application test

@SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 18 of file FixtureModelTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Set indexer mode to "scheduled" for do not perform reindex after creation entity

Definition at line 50 of file FixtureModelTest.php.

51  {
52  $this->objectManager = Bootstrap::getObjectManager();
53  $this->indexerRegistry = $this->objectManager->get(IndexerRegistry::class);
54 
55  $this->entityAsserts[] = $this->objectManager->get(FixturesAsserts\SimpleProductsAssert::class);
56  $this->entityAsserts[] = $this->objectManager->get(FixturesAsserts\ConfigurableProductsAssert::class);
57  $this->entityAsserts[] = $this->objectManager->get(FixturesAsserts\BundleProductsAssert::class);
58  $this->entityAsserts[] = $this->objectManager->get(FixturesAsserts\ImagesAssert::class);
59 
60  foreach ($this->objectManager->get(Config::class)->getIndexers() as $indexerId) {
61  $indexer = $this->indexerRegistry->get($indexerId['indexer_id']);
62  $this->indexersState[$indexerId['indexer_id']] = $indexer->isScheduled();
63  $indexer->setScheduled(true);
64  }
65  }

◆ setUpBeforeClass()

static setUpBeforeClass ( )
static

Definition at line 78 of file FixtureModelTest.php.

79  {
80  $db = Bootstrap::getInstance()->getBootstrap()
81  ->getApplication()
82  ->getDbInstance();
83  if (!$db->isDbDumpExists()) {
84  throw new \LogicException('DB dump does not exist.');
85  }
86  $db->restoreFromDbDump();
87 
88  self::$_generatorWorkingDir = realpath(
89  __DIR__ . '/../../../../../../../setup/src/Magento/Setup/Fixtures/_files'
90  );
91  copy(
92  self::$_generatorWorkingDir . '/tax_rates.csv',
93  self::$_generatorWorkingDir . '/tax_rates.csv.bak'
94  );
95  copy(
96  __DIR__ . '/_files/tax_rates.csv',
97  self::$_generatorWorkingDir . '/tax_rates.csv'
98  );
99  parent::setUpBeforeClass();
100  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ tearDown()

tearDown ( )
protected

Return indexer to previous state

Definition at line 70 of file FixtureModelTest.php.

71  {
72  foreach ($this->indexersState as $indexerId => $state) {
73  $indexer = $this->indexerRegistry->get($indexerId);
74  $indexer->setScheduled($state);
75  }
76  }

◆ testFixtureGeneration()

testFixtureGeneration ( )

Generate test profile and performs assertions that generated entities are valid

Definition at line 105 of file FixtureModelTest.php.

106  {
107  $reindexCommand = Bootstrap::getObjectManager()->get(
108  \Magento\Indexer\Console\Command\IndexerReindexCommand::class
109  );
110  $itfApplication = Bootstrap::getInstance()->getBootstrap()->getApplication();
111  $model = new FixtureModel($reindexCommand, $itfApplication->getInitParams());
112  $model->loadConfig(__DIR__ . '/_files/small.xml');
113  $model->initObjectManager();
114 
115  foreach ($model->loadFixtures()->getFixtures() as $fixture) {
116  $fixture->execute();
117  }
118 
119  foreach ($this->entityAsserts as $entityAssert) {
120  try {
121  $this->assertTrue($entityAssert->assert());
122  } catch (\AssertionError $assertionError) {
123  $this->assertTrue(false, $assertionError->getMessage());
124  }
125  }
126  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

Field Documentation

◆ $_generatorWorkingDir

$_generatorWorkingDir
staticprotected

Definition at line 25 of file FixtureModelTest.php.


The documentation for this class was generated from the following file: