Skip to content

Commit

Permalink
test: Add tests for the Pharaoh class (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Mar 25, 2023
1 parent ad0ddc1 commit 9cc2cf3
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/Pharaoh/PharaohTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

/*
* This file is part of the box project.
*
* (c) Kevin Herrera <kevin@herrera.io>
* Théo Fidry <theo.fidry@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace KevinGH\RequirementChecker\Pharaoh;

use KevinGH\Box\Pharaoh\Pharaoh;
use KevinGH\Box\Test\RequiresPharReadonlyOff;
use PHPUnit\Framework\TestCase;

/**
* @covers \KevinGH\Box\Pharaoh\Pharaoh
*
* @internal
*/
final class PharaohTest extends TestCase
{
use RequiresPharReadonlyOff;

private const FIXTURES_DIR = __DIR__.'/../../fixtures/info';

protected function setUp(): void
{
$this->markAsSkippedIfPharReadonlyIsOn();
}

public function test_it_can_be_instantiated(): void
{
$file = self::FIXTURES_DIR.'/simple-phar.phar';
$pharInfo = new Pharaoh($file);

self::assertSame($file, $pharInfo->getFile());
self::assertSame('simple-phar.phar', $pharInfo->getFileName());
}

public function test_it_cleans_itself_up_upon_destruction(): void
{
$pharInfo = new Pharaoh(self::FIXTURES_DIR.'/simple-phar.phar');

$tmp = $pharInfo->getTmp();

self::assertDirectoryExists($tmp);

unset($pharInfo);

self::assertDirectoryDoesNotExist($tmp);
}

public function test_it_can_create_two_instances_of_the_same_phar(): void
{
$file = self::FIXTURES_DIR.'/simple-phar.phar';

$pharInfoA = new Pharaoh($file);
$pharInfoB = new Pharaoh($file);

self::assertNotSame($pharInfoA->getPhar(), $pharInfoB->getPhar());
}
}

0 comments on commit 9cc2cf3

Please sign in to comment.