Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
Covered "expiresAt" field validation with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Free Man committed Aug 1, 2018
1 parent f04b718 commit 6139806
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions tests/Controller/Management/BannerAddEditControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ public function provideValidationTestCases(): array
'"imageUrl":["This value is not a valid URL."]'
]
],

'Expires at have incorrect format' => [
'requestData' => [
'active' => null,
'expiresAt' => 'something'
],
'expectedResponseMessageParts' => [
'"expiresAt":["This value is not valid."]'
]
],

'Expires at have correct format' => [
'requestData' => [
'active' => null,
'expiresAt' => '2050-05-30 07:30'
],
'expectedResponseMessageParts' => [],

'expectedResponseNotContainsParts' => [
'"expiresAt":["This value is not valid."]'
]
],

'Expires at is optional' => [
'requestData' => [
'active' => true
],
'expectedResponseMessageParts' => [],

'expectedResponseNotContainsParts' => [
'"expiresAt":["This value is not valid."]'
]
],
];


Expand All @@ -103,9 +136,13 @@ public function provideValidationTestCases(): array
*
* @param array $requestData
* @param array $expectedResponseMessageParts
* @param array $expectedNotContainsParts
*/
public function testEditBannerActionValidation(array $requestData, array $expectedResponseMessageParts): void
{
public function testEditBannerActionValidation(
array $requestData,
array $expectedResponseMessageParts,
array $expectedNotContainsParts = []
): void {
$manager = $this->createMock(BannerManager::class);
$repository = $this->createMock(BannerRepository::class);
$banner = new BannerElement();
Expand All @@ -128,6 +165,10 @@ public function testEditBannerActionValidation(array $requestData, array $expect
$this->assertContains($part, $client->getResponse()->getContent());
}

foreach ($expectedNotContainsParts as $part) {
$this->assertNotContains($part, $client->getResponse()->getContent());
}

$this->assertSame(400, $client->getResponse()->getStatusCode());
}

Expand Down

0 comments on commit 6139806

Please sign in to comment.