|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Frontend\Tests\EdgeToEdge\Routes; |
|
6
|
|
|
|
|
7
|
|
|
use Symfony\Component\BrowserKit\Client; |
|
8
|
|
|
use Symfony\Component\BrowserKit\Cookie; |
|
9
|
|
|
use WMDE\Fundraising\Frontend\App\RouteHandlers\ShowDonationConfirmationHandler; |
|
10
|
|
|
use WMDE\Fundraising\Frontend\Factories\FunFunFactory; |
|
11
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Domain\Model\Application; |
|
12
|
|
|
use WMDE\Fundraising\Frontend\Tests\Data\ValidMembershipApplication; |
|
13
|
|
|
use WMDE\Fundraising\Frontend\Tests\EdgeToEdge\WebRouteTestCase; |
|
14
|
|
|
use WMDE\Fundraising\Frontend\Tests\Fixtures\FixedTokenGenerator; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @licence GNU GPL v2+ |
|
18
|
|
|
* @author Kai Nissen < [email protected] > |
|
19
|
|
|
*/ |
|
20
|
|
|
class ShowMembershipConfirmationRouteTest extends WebRouteTestCase { |
|
21
|
|
|
|
|
22
|
|
|
const CORRECT_ACCESS_TOKEN = 'justSomeToken'; |
|
23
|
|
|
|
|
24
|
|
|
private function newStoredMembershipApplication( FunFunFactory $factory ): Application { |
|
25
|
|
|
$factory->setTokenGenerator( new FixedTokenGenerator( |
|
26
|
|
|
self::CORRECT_ACCESS_TOKEN |
|
27
|
|
|
) ); |
|
28
|
|
|
|
|
29
|
|
|
$membershipApplication = ValidMembershipApplication::newDomainEntity(); |
|
30
|
|
|
|
|
31
|
|
|
$factory->getMembershipApplicationRepository()->storeApplication( $membershipApplication ); |
|
32
|
|
|
|
|
33
|
|
|
return $membershipApplication; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testWhenDonationTimestampCookieIsSet_itIsNotOverwritten() { |
|
37
|
|
|
$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) { |
|
38
|
|
|
$donation = $this->newStoredMembershipApplication( $factory ); |
|
39
|
|
|
|
|
40
|
|
|
$client->getCookieJar()->set( |
|
41
|
|
|
new Cookie( ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME, 'some value' ) |
|
42
|
|
|
); |
|
43
|
|
|
$client->request( |
|
44
|
|
|
'GET', |
|
45
|
|
|
'show-membership-confirmation', |
|
46
|
|
|
[ |
|
47
|
|
|
'id' => $donation->getId(), |
|
48
|
|
|
'accessToken' => self::CORRECT_ACCESS_TOKEN |
|
49
|
|
|
] |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertSame( |
|
53
|
|
|
'some value', |
|
54
|
|
|
$client->getCookieJar()->get( ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME )->getValue() |
|
55
|
|
|
); |
|
56
|
|
|
} ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
|