More middleware tests
This commit is contained in:
parent
d844a36167
commit
7b3393aff9
11 changed files with 547 additions and 56 deletions
39
tests/Assertions/MiddlewareAttributeAssertionsTrait.php
Normal file
39
tests/Assertions/MiddlewareAttributeAssertionsTrait.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace 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));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue