Skip to content

Commit 0cdcb69

Browse files
Add test for restoration of current working directory
1 parent e6c0eac commit 0cdcb69

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/_files/CwdRestoreTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture;
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class CwdRestoreTest extends TestCase
15+
{
16+
public function testChangesCwd(): void
17+
{
18+
chdir(sys_get_temp_dir());
19+
20+
$this->assertTrue(true);
21+
}
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
phpunit ../../_files/CwdRestoreTest.php
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$cwd = getcwd();
6+
7+
$_SERVER['argv'][] = '--do-not-cache-result';
8+
$_SERVER['argv'][] = '--no-configuration';
9+
$_SERVER['argv'][] = '--no-output';
10+
$_SERVER['argv'][] = __DIR__ . '/../../_files/CwdRestoreTest.php';
11+
12+
require_once __DIR__ . '/../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
16+
var_dump($cwd === getcwd());
17+
--EXPECTF--
18+
bool(true)

0 commit comments

Comments
 (0)