diff --git a/tests/FileVersionTest.php b/tests/FileVersionTest.php index 3313217..cb562ea 100644 --- a/tests/FileVersionTest.php +++ b/tests/FileVersionTest.php @@ -32,7 +32,7 @@ class FileVersionTest extends TestCase protected function setUp(): void { parent::setUp(); - $this->tempDir = self::tempdir(); + $this->tempDir = $this->tempdir(); file_put_contents($this->tempDir.'/commit.json', json_encode([ 'branch' => 'master', 'commit' => '9c9e437' @@ -47,28 +47,26 @@ protected function setUp(): void protected function tearDown(): void { parent::tearDown(); - self::rmDir($this->tempDir); + $this->rmDir($this->tempDir); } /** * Test retrieving branch and commit from a JSON encoded file. - * @throws \PHPUnit_Framework_AssertionFailedError - * @throws \PHPUnit_Framework_Exception * @return void */ public function testFileVersionRetrieval() { $fileVersion = new FileVersion($this->tempDir.'/commit.json'); - static::assertInstanceOf(IVersion::class, $fileVersion); - static::assertTrue($fileVersion->exists()); - static::assertSame('master', $fileVersion->getBranch()); - static::assertSame('9c9e437', $fileVersion->getCommit()); + $this->assertInstanceOf(IVersion::class, $fileVersion); + $this->assertTrue($fileVersion->exists()); + $this->assertSame('master', $fileVersion->getBranch()); + $this->assertSame('9c9e437', $fileVersion->getCommit()); $actual = (string)json_encode($fileVersion); $expected = (string)json_encode([ 'branch' => 'master', 'commit' => '9c9e437' ]); - static::assertJsonStringEqualsJsonString($expected, $actual); + $this->assertJsonStringEqualsJsonString($expected, $actual); } /** @@ -78,7 +76,7 @@ public function testFileVersionRetrieval() public function testGettingCommit() { $fileVersion = new FileVersion($this->tempDir.'/commit.json'); - static::assertSame('9c9e437', $fileVersion->getCommit()); + $this->assertSame('9c9e437', $fileVersion->getCommit()); } /** @@ -88,6 +86,6 @@ public function testGettingCommit() public function testGettingBranch() { $fileVersion = new FileVersion($this->tempDir.'/commit.json'); - static::assertSame('master', $fileVersion->getBranch()); + $this->assertSame('master', $fileVersion->getBranch()); } } diff --git a/tests/GitVersionTest.php b/tests/GitVersionTest.php index 216c2ba..4b6a1dd 100644 --- a/tests/GitVersionTest.php +++ b/tests/GitVersionTest.php @@ -32,7 +32,7 @@ class GitVersionTest extends TestCase protected function setUp(): void { parent::setUp(); - $this->tempDir = self::tempdir(); + $this->tempDir = $this->tempdir(); mkdir($this->tempDir.'/.git/refs/heads/', 0777, true); file_put_contents($this->tempDir.'/.git/HEAD', 'ref: refs/heads/master'); file_put_contents($this->tempDir.'/.git/refs/heads/master', '9c9e4373dbd136a4f405a828a9ecf445f207e49c'); @@ -46,22 +46,20 @@ protected function setUp(): void protected function tearDown(): void { parent::tearDown(); - self::rmDir($this->tempDir); + $this->rmDir($this->tempDir); } /** * Test retrieving version information from git. - * @throws \PHPUnit_Framework_AssertionFailedError - * @throws \PHPUnit_Framework_Exception * @return void */ public function testGitVersionRetrieval() { $gitVersion = new GitVersion($this->tempDir); - static::assertInstanceOf(IVersion::class, $gitVersion); - static::assertTrue($gitVersion->exists()); - static::assertSame('master', $gitVersion->getBranch()); - static::assertSame('9c9e437', $gitVersion->getCommit()); + $this->assertInstanceOf(IVersion::class, $gitVersion); + $this->assertTrue($gitVersion->exists()); + $this->assertSame('master', $gitVersion->getBranch()); + $this->assertSame('9c9e437', $gitVersion->getCommit()); $actual = (string)json_encode($gitVersion); $expected = (string)json_encode([ 'branch' => 'master', diff --git a/tests/VersionTest.php b/tests/VersionTest.php index f2ce2e2..1d96f4f 100644 --- a/tests/VersionTest.php +++ b/tests/VersionTest.php @@ -34,7 +34,7 @@ class VersionTest extends TestCase protected function setUp(): void { parent::setUp(); - $this->tempDir = self::tempdir(); + $this->tempDir = $this->tempdir(); file_put_contents($this->tempDir.'/commit.json', json_encode([ 'branch' => 'retsam', 'commit' => '765e9c9' @@ -52,55 +52,51 @@ protected function setUp(): void protected function tearDown(): void { parent::tearDown(); - self::rmDir($this->tempDir); + $this->rmDir($this->tempDir); } /** * Test retrieving the version from the JSON encoded file rather that from the * git repository. - * @throws \PHPUnit_Framework_AssertionFailedError - * @throws \PHPUnit_Framework_Exception * @return void */ public function testRetrievingFileVersion() { $version = new Version(); - static::assertInstanceOf(IVersion::class, $version); + $this->assertInstanceOf(IVersion::class, $version); $version->register(new FileVersion($this->tempDir.'/commit.json')); //$version->register(new GitVersion($this->tempDir)); - static::assertTrue($version->exists()); - static::assertSame('retsam', $version->getBranch()); - static::assertSame('765e9c9', $version->getCommit()); + $this->assertTrue($version->exists()); + $this->assertSame('retsam', $version->getBranch()); + $this->assertSame('765e9c9', $version->getCommit()); $actual = (string)json_encode($version); $expected = (string)json_encode([ 'branch' => 'retsam', 'commit' => '765e9c9' ]); - static::assertJsonStringEqualsJsonString($expected, $actual); + $this->assertJsonStringEqualsJsonString($expected, $actual); } /** * Test retrieving the version from the git repository rather that from the JSON * encoded file. - * @throws \PHPUnit_Framework_AssertionFailedError - * @throws \PHPUnit_Framework_Exception * @return void */ public function testRetrievingGitVersion() { $version = new Version(); - static::assertInstanceOf(IVersion::class, $version); + $this->assertInstanceOf(IVersion::class, $version); $version->register(new GitVersion($this->tempDir)); $version->register(new FileVersion($this->tempDir.'/commit.json')); - static::assertSame('9c9e437', $version->getCommit()); - static::assertTrue($version->exists()); - static::assertSame('master', $version->getBranch()); + $this->assertSame('9c9e437', $version->getCommit()); + $this->assertTrue($version->exists()); + $this->assertSame('master', $version->getBranch()); $actual = (string)json_encode($version); $expected = (string)json_encode([ 'branch' => 'master', 'commit' => '9c9e437' ]); - static::assertJsonStringEqualsJsonString($expected, $actual); + $this->assertJsonStringEqualsJsonString($expected, $actual); } }