Skip to content

Commit

Permalink
Remove deprecated phpunit calls
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed May 2, 2024
1 parent fb0bcd0 commit 2384ad4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
39 changes: 22 additions & 17 deletions tests/Unit/AbstractVaultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,53 @@
namespace Intervention\HttpAuth\Tests\Unit;

use Intervention\HttpAuth\AbstractVault;
use Intervention\HttpAuth\Directive;
use Intervention\HttpAuth\Key;
use PHPUnit\Framework\TestCase;

final class AbstractVaultTest extends TestCase
{
public function testConstructor(): void
private function getTestVault(string $realm, string $username, string $password): AbstractVault
{
$vault = $this->getMockForAbstractClass(
AbstractVault::class,
['myRealm', 'myUsername', 'myPassword']
);
return new class ($realm, $username, $password) extends AbstractVault
{
public function getDirective(): Directive
{
return new Directive('test');
}

public function unlocksWithKey(Key $key): bool
{
return false;
}
};
}

public function testConstructor(): void
{
$vault = $this->getTestVault('myRealm', 'myUsername', 'myPassword');
$this->assertEquals('myUsername', $vault->getUsername());
$this->assertEquals('myPassword', $vault->getPassword());
$this->assertEquals('myRealm', $vault->getRealm());
}

public function testSetGetUsername(): void
{
$vault = $this->getMockForAbstractClass(
AbstractVault::class,
['myRealm', 'myUsername', 'myPassword']
);
$vault = $this->getTestVault('myRealm', 'myUsername', 'myPassword');
$vault->withUsername('foo');
$this->assertEquals('foo', $vault->getUsername());
}

public function testSetGetPassword(): void
{
$vault = $this->getMockForAbstractClass(
AbstractVault::class,
['myRealm', 'myUsername', 'myPassword']
);
$vault = $this->getTestVault('myRealm', 'myUsername', 'myPassword');
$vault->withPassword('foo');
$this->assertEquals('foo', $vault->getPassword());
}

public function testSetGetRealm(): void
{
$vault = $this->getMockForAbstractClass(
AbstractVault::class,
['myRealm', 'myUsername', 'myPassword']
);
$vault = $this->getTestVault('myRealm', 'myUsername', 'myPassword');
$vault->withRealm('foo');
$this->assertEquals('foo', $vault->getRealm());
}
Expand Down
9 changes: 8 additions & 1 deletion tests/Unit/Token/AbstractTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ final class AbstractTokenTest extends AbstractTokenTestCase
{
public function testGetKey(): void
{
$token = $this->getMockForAbstractClass(AbstractToken::class);
$token = new class () extends AbstractToken
{
public function parseProperties(): array
{
return [];
}
};

$key = $token->getKey();
$this->assertInstanceOf(Key::class, $key);
}
Expand Down

0 comments on commit 2384ad4

Please sign in to comment.