Files

35 lines
1017 B
PHP
Raw Permalink Normal View History

2017-11-01 20:45:43 -05:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2021-01-23 12:09:16 -08:00
namespace Pterodactyl\Tests\Assertions;
2017-11-01 20:45:43 -05:00
use PHPUnit\Framework\Assert;
trait MiddlewareAttributeAssertionsTrait
{
/**
* Assert a request has an attribute assigned to it.
*/
2022-10-14 10:59:20 -06:00
public function assertRequestHasAttribute(string $attribute): void
2017-11-01 20:45:43 -05:00
{
2026-10-05 18:10:18 -04:00
Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has '.$attribute.' attribute.');
2017-11-01 20:45:43 -05:00
}
/**
* Assert a request does not have an attribute assigned to it.
*/
2022-10-14 10:59:20 -06:00
public function assertRequestMissingAttribute(string $attribute): void
2017-11-01 20:45:43 -05:00
{
2026-10-05 18:10:18 -04:00
Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have '.$attribute.' attribute.');
2017-11-01 20:45:43 -05:00
}
/**
* Assert a request attribute matches an expected value.
*/
2022-10-14 10:59:20 -06:00
public function assertRequestAttributeEquals(mixed $expected, string $attribute): void
2017-11-01 20:45:43 -05:00
{
Assert::assertEquals($expected, $this->request->attributes->get($attribute));
}
}