Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WorkingDirectoryTest.php
Go to the documentation of this file.
1 <?php
10 namespace Magento\Test\Isolation;
11 
12 class WorkingDirectoryTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $_object;
18 
19  protected function setUp()
20  {
21  $this->_object = new \Magento\TestFramework\Isolation\WorkingDirectory();
22  }
23 
24  protected function tearDown()
25  {
26  $this->_object = null;
27  }
28 
29  public function testStartTestEndTest()
30  {
31  $oldWorkingDir = getcwd();
32  $newWorkingDir = __DIR__;
33  if ($oldWorkingDir == $newWorkingDir) {
34  $this->markTestSkipped("Test requires the current working directory to differ from '{$oldWorkingDir}'.");
35  }
36  $this->_object->startTest($this);
37  chdir($newWorkingDir);
38  $this->assertEquals($newWorkingDir, getcwd(), 'Unable to change the current working directory.');
39  $this->_object->endTest($this);
40  $this->assertEquals($oldWorkingDir, getcwd(), 'Current working directory was not restored.');
41  }
42 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60