This repository was archived by the owner on Jan 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
This repository was archived by the owner on Jan 21, 2021. It is now read-only.
Interesting testing utilities to add #3
Copy link
Copy link
Open
Labels
hacktoberfestGood issue for Hacktoberfest participantsGood issue for Hacktoberfest participants
Description
What kind of testing utils would you like to have in this package?
I have some utilities from courses, screencasts and some made by my own. Would they fit in a package like this?, later should be, how would they be added? given they are macros
- asserting a collection has an item
Collection::macro('assertContains', function ($value) {
PHPUnit::assertTrue($this->contains($value), "Failed asserting that the collection contains the specified value.");
});
$collection->assertContains($model)
- assert a collection has no item
Collection::macro('assertNotContains', function ($value) {
PHPUnit::assertFalse($this->contains($value), "Failed asserting that the collection does not contain the specified value.");
});
$collection->assertNotContains($model)
- Get data from a returned view
TestResponse::macro('getData', function ($key) {
return $this->original->getData()[$key];
});
$response->getData('article')
- Assert response status is not Equal to.
TestResponse::macro('assertStatusNotEquals', function ($status) {
$actual = $this->getStatusCode();
PHPUnit::assertTrue(
$actual != $status,
"Expected status code different from {$status} but received {$actual}."
);
return $this;
});
$response->assertStatusNotEquals(200)
- Assert response location is not
TestResponse::macro('assertLocationDifferent', function ($uri) {
PHPUnit::assertNotEquals(
app('url')->to($uri),
app('url')->to($this->headers->get('Location'))
);
return $this;
});
$response->assertRedirect()->assertLocationDifferent('/home')
Metadata
Metadata
Assignees
Labels
hacktoberfestGood issue for Hacktoberfest participantsGood issue for Hacktoberfest participants