1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* @author Nicolas Clavaud <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Ogone\Tests\DirectLink; |
7
|
|
|
|
8
|
|
|
use Ogone\Tests\ShaComposer\FakeShaComposer; |
9
|
|
|
use Ogone\DirectLink\DirectLinkQueryRequest; |
10
|
|
|
|
11
|
|
|
class DirectLinkQueryRequestTest extends \PHPUnit_Framework_TestCase |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** @test */ |
15
|
|
|
public function IsValidWhenRequiredFieldsAreFilledIn() |
16
|
|
|
{ |
17
|
|
|
$directLinkQueryRequest = $this->provideMinimalDirectLinkQueryRequest(); |
18
|
|
|
$directLinkQueryRequest->validate(); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @test |
23
|
|
|
* @expectedException \RuntimeException |
24
|
|
|
*/ |
25
|
|
|
public function IsInvalidWhenFieldsAreMissing() |
26
|
|
|
{ |
27
|
|
|
$directLinkQueryRequest = new DirectLinkQueryRequest(new FakeShaComposer); |
28
|
|
|
$directLinkQueryRequest->validate(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @test |
33
|
|
|
* @expectedException \InvalidArgumentException |
34
|
|
|
*/ |
35
|
|
|
public function isInvalidWithNonOgoneUrl() |
36
|
|
|
{ |
37
|
|
|
$directLinkQueryRequest = $this->provideMinimalDirectLinkQueryRequest(); |
38
|
|
|
$directLinkQueryRequest->setOgoneUri('http://example.com'); |
39
|
|
|
$directLinkQueryRequest->validate(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @test |
44
|
|
|
*/ |
45
|
|
|
public function isValidWithOgoneUrl() |
46
|
|
|
{ |
47
|
|
|
$directLinkQueryRequest = $this->provideMinimalDirectLinkQueryRequest(); |
48
|
|
|
$directLinkQueryRequest->setOgoneUri(DirectLinkQueryRequest::PRODUCTION); |
49
|
|
|
$directLinkQueryRequest->validate(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @test |
54
|
|
|
* @dataProvider provideBadParameters |
55
|
|
|
* @expectedException \InvalidArgumentException |
56
|
|
|
*/ |
57
|
|
|
public function BadParametersCauseExceptions($method, $value) |
58
|
|
|
{ |
59
|
|
|
$directLinkQueryRequest = new DirectLinkQueryRequest(new FakeShaComposer); |
60
|
|
|
$directLinkQueryRequest->$method($value); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function provideBadParameters() |
64
|
|
|
{ |
65
|
|
|
return array( |
66
|
|
|
array('setPassword', '12'), |
67
|
|
|
array('setUserid', '1'), |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** @return DirectLinkQueryRequest */ |
72
|
|
|
private function provideMinimalDirectLinkQueryRequest() |
73
|
|
|
{ |
74
|
|
|
$directLinkRequest = new DirectLinkQueryRequest(new FakeShaComposer()); |
75
|
|
|
$directLinkRequest->setPspid('123456'); |
76
|
|
|
$directLinkRequest->setUserId('user_1234'); |
77
|
|
|
$directLinkRequest->setPassword('abracadabra'); |
78
|
|
|
$directLinkRequest->setPayId('12345678'); |
79
|
|
|
|
80
|
|
|
return $directLinkRequest; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|