|
29 | 29 | */ |
30 | 30 | class HooksCreateResponseTest extends TestCase |
31 | 31 | { |
32 | | - private HooksCreateResponse $createResponse; |
| 32 | + private HooksCreateResponse $createResponseCreate; |
| 33 | + private HooksCreateResponse $createResponseError; |
| 34 | + private HooksCreateResponse $createResponseExisting; |
| 35 | + private HooksCreateResponse $createResponseNoHookId; |
33 | 36 |
|
34 | 37 | public function setUp(): void |
35 | 38 | { |
36 | 39 | parent::setUp(); |
37 | 40 |
|
38 | | - $xml = $this->loadXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'hooks_create.xml'); |
| 41 | + $xmlCreate = $this->loadXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'hooks_create.xml'); |
| 42 | + $xmlCreateError = $this->loadXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'hooks_create_error.xml'); |
| 43 | + $xmlCreateExisting = $this->loadXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'hooks_create_existing.xml'); |
| 44 | + $xmlCreateNoHookId = $this->loadXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'hooks_create_no_hook_id.xml'); |
39 | 45 |
|
40 | | - $this->createResponse = new HooksCreateResponse($xml); |
| 46 | + $this->createResponseCreate = new HooksCreateResponse($xmlCreate); |
| 47 | + $this->createResponseError = new HooksCreateResponse($xmlCreateError); |
| 48 | + $this->createResponseExisting = new HooksCreateResponse($xmlCreateExisting); |
| 49 | + $this->createResponseNoHookId = new HooksCreateResponse($xmlCreateNoHookId); |
41 | 50 | } |
42 | 51 |
|
43 | | - public function testHooksCreateResponseContent(): void |
| 52 | + public function testHooksCreateResponseCreateContent(): void |
44 | 53 | { |
45 | | - $this->assertEquals('SUCCESS', $this->createResponse->getReturnCode()); |
46 | | - $this->assertEquals(1, $this->createResponse->getHookId()); |
47 | | - $this->assertFalse($this->createResponse->isPermanentHook()); |
48 | | - $this->assertFalse($this->createResponse->hasRawData()); |
| 54 | + $this->assertEquals('SUCCESS', $this->createResponseCreate->getReturnCode()); |
| 55 | + $this->assertEquals('', $this->createResponseCreate->getMessageKey()); |
| 56 | + $this->assertTrue($this->createResponseCreate->success()); |
| 57 | + $this->assertFalse($this->createResponseCreate->failed()); |
| 58 | + $this->assertEquals(1, $this->createResponseCreate->getHookId()); |
| 59 | + $this->assertFalse($this->createResponseCreate->isPermanentHook()); |
| 60 | + $this->assertFalse($this->createResponseCreate->hasRawData()); |
| 61 | + } |
| 62 | + |
| 63 | + public function testHooksCreateResponseErrorContent(): void |
| 64 | + { |
| 65 | + $this->assertEquals('FAILED', $this->createResponseError->getReturnCode()); |
| 66 | + $this->assertEquals('createHookError', $this->createResponseError->getMessageKey()); |
| 67 | + $this->assertFalse($this->createResponseError->success()); |
| 68 | + $this->assertTrue($this->createResponseError->failed()); |
| 69 | + $this->assertNull($this->createResponseError->getHookId()); |
| 70 | + $this->assertNull($this->createResponseError->isPermanentHook()); |
| 71 | + $this->assertNull($this->createResponseError->hasRawData()); |
| 72 | + } |
| 73 | + |
| 74 | + public function testHooksCreateResponseExistingContent(): void |
| 75 | + { |
| 76 | + $this->assertEquals('SUCCESS', $this->createResponseExisting->getReturnCode()); |
| 77 | + $this->assertEquals('duplicateWarning', $this->createResponseExisting->getMessageKey()); |
| 78 | + $this->assertTrue($this->createResponseExisting->success()); |
| 79 | + $this->assertFalse($this->createResponseExisting->failed()); |
| 80 | + $this->assertEquals(1, $this->createResponseExisting->getHookId()); |
| 81 | + $this->assertNull($this->createResponseExisting->isPermanentHook()); |
| 82 | + $this->assertNull($this->createResponseExisting->hasRawData()); |
| 83 | + } |
| 84 | + |
| 85 | + public function testHooksCreateResponseNoHookIdContent(): void |
| 86 | + { |
| 87 | + $this->assertEquals('FAILED', $this->createResponseNoHookId->getReturnCode()); |
| 88 | + $this->assertEquals('missingParamHookID', $this->createResponseNoHookId->getMessageKey()); |
| 89 | + $this->assertFalse($this->createResponseNoHookId->success()); |
| 90 | + $this->assertTrue($this->createResponseNoHookId->failed()); |
| 91 | + $this->assertNull($this->createResponseNoHookId->getHookId()); |
| 92 | + $this->assertNull($this->createResponseNoHookId->isPermanentHook()); |
| 93 | + $this->assertNull($this->createResponseNoHookId->hasRawData()); |
49 | 94 | } |
50 | 95 |
|
51 | 96 | public function testHooksCreateResponseTypes(): void |
52 | 97 | { |
53 | | - $this->assertEachGetterValueIsString($this->createResponse, ['getReturnCode']); |
54 | | - $this->assertEachGetterValueIsInteger($this->createResponse, ['getHookId']); |
55 | | - $this->assertEachGetterValueIsBoolean($this->createResponse, ['isPermanentHook', 'hasRawData']); |
| 98 | + $this->assertEachGetterValueIsString($this->createResponseCreate, ['getReturnCode']); |
| 99 | + $this->assertEachGetterValueIsInteger($this->createResponseCreate, ['getHookId']); |
| 100 | + $this->assertEachGetterValueIsBoolean($this->createResponseCreate, ['isPermanentHook', 'hasRawData']); |
| 101 | + |
| 102 | + $this->assertEachGetterValueIsString($this->createResponseError, ['getReturnCode']); |
| 103 | + $this->assertEachGetterValueIsNull($this->createResponseError, ['getHookId', 'isPermanentHook', 'hasRawData']); |
| 104 | + |
| 105 | + $this->assertEachGetterValueIsString($this->createResponseExisting, ['getReturnCode']); |
| 106 | + $this->assertEachGetterValueIsInteger($this->createResponseExisting, ['getHookId']); |
| 107 | + $this->assertEachGetterValueIsNull($this->createResponseExisting, ['isPermanentHook', 'hasRawData']); |
| 108 | + |
| 109 | + $this->assertEachGetterValueIsString($this->createResponseNoHookId, ['getReturnCode']); |
| 110 | + $this->assertEachGetterValueIsNull($this->createResponseNoHookId, ['getHookId', 'isPermanentHook', 'hasRawData']); |
56 | 111 | } |
57 | 112 | } |
0 commit comments