misc_pterodactyl-panel/tests/Assertions/MiddlewareAttributeAssertionsTrait.php
Dane Everitt a043071e3c
Update to Laravel 8
Co-authored-by: Matthew Penner <me@matthewp.io>
2021-01-23 12:12:54 -08:00

39 lines
1.1 KiB
PHP

<?php
namespace Pterodactyl\Tests\Assertions;
use PHPUnit\Framework\Assert;
trait MiddlewareAttributeAssertionsTrait
{
/**
* Assert a request has an attribute assigned to it.
*
* @param string $attribute
*/
public function assertRequestHasAttribute(string $attribute)
{
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.
*
* @param string $attribute
*/
public function assertRequestMissingAttribute(string $attribute)
{
Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.');
}
/**
* Assert a request attribute matches an expected value.
*
* @param mixed $expected
* @param string $attribute
*/
public function assertRequestAttributeEquals($expected, string $attribute)
{
Assert::assertEquals($expected, $this->request->attributes->get($attribute));
}
}