/**
  * Apply fixture test
  *
  * @param array $initialFixtures
  * @param array $subsequentFixtures
  * @param array $subsequentExpected
  * @dataProvider applyFixturesSeveralTimesDataProvider
  *
  * @return void
  */
 public function testApplyFixturesSeveralTimes($initialFixtures, $subsequentFixtures, $subsequentExpected)
 {
     $this->_object->applyFixtures($initialFixtures);
     $this->_object->applied = [];
     $this->_object->applyFixtures($subsequentFixtures);
     $this->assertEquals($subsequentExpected, $this->_object->applied);
 }
Example #2
0
 /**
  * Apply fixtures test with no reinstall
  */
 public function testApplyFixturesIncompatibleSetReinstallation()
 {
     $this->_shell->expects($this->at(0))->method('execute')->with($this->anything(), $this->contains($this->_script));
     $this->_shell->expects($this->at(1))->method('execute')->with($this->anything(), $this->contains($this->_script));
     $fixtures = $this->_getFixtureFiles(['fixture1', 'fixture2']);
     $this->_object->applyFixtures($fixtures);
     $incompatibleSet = $this->_getFixtureFiles(['fixture1']);
     $this->_object->applyFixtures($incompatibleSet);
 }
Example #3
0
 /**
  * Apply fixtures test with no reinstall
  */
 public function testApplyFixturesIncompatibleSetReinstallation()
 {
     $this->_shell->expects($this->at(0))->method('execute')->with($this->stringContains('--uninstall'), $this->contains($this->_installerScript));
     $this->_shell->expects($this->at(1))->method('execute')->with($this->logicalNot($this->stringContains('--uninstall')), $this->contains($this->_installerScript));
     $this->_shell->expects($this->at(6))->method('execute')->with($this->stringContains('--uninstall'), $this->contains($this->_installerScript));
     $this->_shell->expects($this->at(7))->method('execute')->with($this->logicalNot($this->stringContains('--uninstall')), $this->contains($this->_installerScript));
     $fixtures = $this->_getFixtureFiles(array('fixture1', 'fixture2'));
     $this->_object->applyFixtures($fixtures);
     $incompatibleSet = $this->_getFixtureFiles(array('fixture1'));
     $this->_object->applyFixtures($incompatibleSet);
 }
Example #4
0
 /**
  * Test application of fixtures, asserting that proper fixtures have been applied,
  * and application events have happened
  *
  * @param Magento_Application|PHPUnit_Framework_MockObject_MockObject $application
  * @param array $fixtures
  * @param array $expectedFixtures
  * @param array $expectedEvents
  * @param string $message
  */
 protected function _testApplyFixtures($application, $fixtures, $expectedFixtures, $expectedEvents, $message)
 {
     // Prepare
     $nameToPathFunc = function ($fixture) {
         return __DIR__ . "/_files/application_test/{$fixture}.php";
     };
     $fixtures = array_map($nameToPathFunc, $fixtures);
     $this->_appEvents = array();
     $this->_fixtureEvents = array();
     // Run
     $GLOBALS['applicationTestForFixtures'] = $this;
     // Expose itself to fixtures
     try {
         $application->applyFixtures($fixtures);
         // Assert expectations
         $fixtureEvents = array_keys($this->_fixtureEvents);
         sort($fixtureEvents);
         sort($expectedFixtures);
         $this->assertEquals($expectedFixtures, $fixtureEvents, "{$message} - fixtures applied are wrong");
         $appEvents = array_keys($this->_appEvents);
         sort($appEvents);
         sort($expectedEvents);
         $this->assertEquals($expectedEvents, $appEvents, "{$message} - application management is wrong");
         unset($GLOBALS['applicationTestForFixtures']);
     } catch (Exception $e) {
         unset($GLOBALS['applicationTestForFixtures']);
         throw $e;
     }
 }