misc_pterodactyl-panel/tests/Assertions/MiddlewareAttributeAssertionsTrait.php

33 lines
999 B
PHP
Raw Normal View History

2017-11-02 01:45:43 +00:00
<?php
namespace Pterodactyl\Tests\Assertions;
2017-11-02 01:45:43 +00:00
use PHPUnit\Framework\Assert;
trait MiddlewareAttributeAssertionsTrait
{
/**
* Assert a request has an attribute assigned to it.
*/
public function assertRequestHasAttribute(string $attribute): void
2017-11-02 01:45:43 +00:00
{
Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has ' . $attribute . ' attribute.');
}
/**
* Assert a request does not have an attribute assigned to it.
*/
public function assertRequestMissingAttribute(string $attribute): void
2017-11-02 01:45:43 +00:00
{
Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.');
}
/**
* Assert a request attribute matches an expected value.
*/
public function assertRequestAttributeEquals(mixed $expected, string $attribute): void
2017-11-02 01:45:43 +00:00
{
Assert::assertEquals($expected, $this->request->attributes->get($attribute));
}
}