Skip to content

Commit d5359ff

Browse files
committed
Update tests
1 parent 42efcdc commit d5359ff

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

tests/DirectoryTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace MultiTester\Tests;
44

55
use MultiTester\Directory;
6-
use PHPUnit\Framework\TestCase;
76
use ReflectionMethod;
87

98
class DirectoryTest extends TestCase
@@ -16,17 +15,17 @@ public function testDirectoryTools(): void
1615
$this->assertTrue((new Directory(__DIR__ . '/dependency/vendor'))->copy("$testDirectory/dest", ['bin']));
1716

1817
$this->assertFileExists("$testDirectory/dest/my-org/my-project/readme.md");
19-
$this->assertFileNotExists("$testDirectory/dest/bin/program");
18+
$this->assertFileDoesNotExist("$testDirectory/dest/bin/program");
2019

2120
$this->assertTrue((new Directory("$testDirectory/dest"))->clean());
2221

23-
$this->assertFileNotExists("$testDirectory/dest/my-org/my-project/readme.md");
22+
$this->assertFileDoesNotExist("$testDirectory/dest/my-org/my-project/readme.md");
2423
$this->assertFileExists("$testDirectory/dest");
2524

2625
$this->assertTrue((new Directory("$testDirectory/dest"))->remove());
2726

28-
$this->assertFileNotExists("$testDirectory/dest/my-org/my-project/readme.md");
29-
$this->assertFileNotExists("$testDirectory/dest");
27+
$this->assertFileDoesNotExist("$testDirectory/dest/my-org/my-project/readme.md");
28+
$this->assertFileDoesNotExist("$testDirectory/dest");
3029

3130
$this->assertTrue((new Directory("$testDirectory/dest/foo"))->create());
3231

@@ -43,7 +42,7 @@ public function testDirectoryTools(): void
4342

4443
$this->assertTrue((new Directory("$testDirectory/dest/foo"))->create());
4544

46-
$this->assertFileNotExists("$testDirectory/dest/foo/bar");
45+
$this->assertFileDoesNotExist("$testDirectory/dest/foo/bar");
4746

4847
touch("$testDirectory/dest/foo/bar");
4948

@@ -57,7 +56,7 @@ public function testDirectoryTools(): void
5756

5857
$this->assertTrue((new Directory("$testDirectory/dest"))->remove());
5958

60-
$this->assertFileNotExists("$testDirectory/dest");
59+
$this->assertFileDoesNotExist("$testDirectory/dest");
6160

6261
mkdir("$testDirectory/dest/foo/bar/biz", 0777, true);
6362
touch("$testDirectory/dest/foo/bar/biz/bla");
@@ -68,7 +67,7 @@ public function testDirectoryTools(): void
6867

6968
$this->assertTrue((new Directory($testDirectory))->remove());
7069

71-
$this->assertFileNotExists($testDirectory);
70+
$this->assertFileDoesNotExist($testDirectory);
7271
}
7372

7473
public function testCopyItem(): void
@@ -88,7 +87,7 @@ public function testCopyItem(): void
8887

8988
$this->assertTrue((new Directory($testDirectory))->remove());
9089

91-
$this->assertFileNotExists($testDirectory);
90+
$this->assertFileDoesNotExist($testDirectory);
9291
}
9392

9493
public function testCleanItem(): void
@@ -108,6 +107,6 @@ public function testCleanItem(): void
108107

109108
$this->assertTrue((new Directory($testDirectory))->remove());
110109

111-
$this->assertFileNotExists($testDirectory);
110+
$this->assertFileDoesNotExist($testDirectory);
112111
}
113112
}

tests/GitHubTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function testClone(): void
283283
'source' => [
284284
'success_only' => true,
285285
'url' => 'https://github.com/BKWLD/laravel-pug.git',
286-
'reference' => 'multi-tester-labels',
286+
'reference' => 'master',
287287
],
288288
'install' => 'github',
289289
'script' => 'github',

tests/MultiTesterTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use MultiTester\MultiTesterException;
99
use MultiTester\Project;
1010
use MultiTester\SourceFinder;
11-
use PHPUnit\Framework\TestCase;
1211
use ReflectionMethod;
1312

1413
class MultiTesterTest extends TestCase
@@ -120,7 +119,7 @@ public function testGetConfig(): void
120119
$message = $exception->getMessage();
121120
}
122121

123-
$this->assertRegExp('/Multi-tester config file \'[^\']+\/project\/not-found\/\.multi-tester\.yml\' not found./', $message);
122+
$this->assertMatchesRegularExpression('/Multi-tester config file \'[^\']+\/project\/not-found\/\.multi-tester\.yml\' not found./', $message);
124123
}
125124

126125
/**

tests/ProjectTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use MultiTester\MultiTesterException;
99
use MultiTester\Project;
1010
use MultiTester\TestFailedException;
11-
use PHPUnit\Framework\TestCase;
1211
use ReflectionMethod;
1312

1413
class ProjectTest extends TestCase
@@ -609,7 +608,7 @@ public function testSeedCloneSetting(): void
609608
$this->assertIsArray($clone);
610609
$this->assertCount(2, $clone);
611610
$this->assertSame('git clone https://github.com/pug-php/pug.git .', $clone[0]);
612-
$this->assertRegExp('/^git checkout --detach [0-9a-f]+$/', $clone[1]);
611+
$this->assertMatchesRegularExpression('/^git checkout --detach [0-9a-f]+$/', $clone[1]);
613612
}
614613

615614
/**

tests/TestCase.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace MultiTester\Tests;
4+
5+
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
6+
7+
class TestCase extends PHPUnitTestCase
8+
{
9+
public static function assertFileDoesNotExist(string $filename, string $message = ''): void
10+
{
11+
if (method_exists(parent::class, 'assertFileDoesNotExist')) {
12+
parent::assertFileDoesNotExist($filename, $message);
13+
14+
return;
15+
}
16+
17+
parent::assertFileNotExists($filename, $message);
18+
}
19+
20+
public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
21+
{
22+
if (method_exists(parent::class, 'assertMatchesRegularExpression')) {
23+
parent::assertMatchesRegularExpression($pattern, $string, $message);
24+
25+
return;
26+
}
27+
28+
parent::assertRegExp($pattern, $string, $message);
29+
}
30+
}

0 commit comments

Comments
 (0)