From 62d174b0cd46fcaa57bbe8250f22a0606c1ba7d2 Mon Sep 17 00:00:00 2001 From: ruslan Date: Mon, 20 May 2019 16:45:25 +0600 Subject: [PATCH 1/4] QueueList timeMode requesting option. Fix style CI. Fix style CI. --- src/Amadeus/Client/RequestOptions/Queue.php | 11 ++++++-- src/Amadeus/Client/Struct/Queue/QueueDate.php | 10 +++++++ src/Amadeus/Client/Struct/Queue/QueueList.php | 4 +++ .../Amadeus/Client/Struct/Queue/ListTest.php | 28 +++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/Amadeus/Client/RequestOptions/Queue.php b/src/Amadeus/Client/RequestOptions/Queue.php index f289dde04..b5c6d14ae 100644 --- a/src/Amadeus/Client/RequestOptions/Queue.php +++ b/src/Amadeus/Client/RequestOptions/Queue.php @@ -65,8 +65,15 @@ class Queue * @var string */ public $officeId; - - + + /** + * OPTIONAL + * + * @var string + */ + public $timeMode; + + /** * Construct Queue with initialization array * diff --git a/src/Amadeus/Client/Struct/Queue/QueueDate.php b/src/Amadeus/Client/Struct/Queue/QueueDate.php index 8bdf22b31..712a015ef 100644 --- a/src/Amadeus/Client/Struct/Queue/QueueDate.php +++ b/src/Amadeus/Client/Struct/Queue/QueueDate.php @@ -33,4 +33,14 @@ class QueueDate * @var int */ public $timeMode; + + /** + * QueueDate constructor. + * + * @param int timeMode + */ + public function __construct($timeMode) + { + $this->timeMode = $timeMode; + } } diff --git a/src/Amadeus/Client/Struct/Queue/QueueList.php b/src/Amadeus/Client/Struct/Queue/QueueList.php index 6060443c3..3dc85f453 100644 --- a/src/Amadeus/Client/Struct/Queue/QueueList.php +++ b/src/Amadeus/Client/Struct/Queue/QueueList.php @@ -82,6 +82,10 @@ public function __construct(QueueListOptions $options) $this->categoryDetails = new CategoryDetails($options->queue->category); + if (!empty($options->queue->timeMode)) { + $this->date = new QueueDate($options->queue->timeMode); + } + if (!empty($options->queue->officeId)) { $this->targetOffice = new TargetOffice( SourceType::SOURCETYPE_OFFICE_SPECIFIED, diff --git a/tests/Amadeus/Client/Struct/Queue/ListTest.php b/tests/Amadeus/Client/Struct/Queue/ListTest.php index af164328a..49a23389b 100644 --- a/tests/Amadeus/Client/Struct/Queue/ListTest.php +++ b/tests/Amadeus/Client/Struct/Queue/ListTest.php @@ -63,6 +63,34 @@ public function testCanConstructQueueListMessage() $this->assertNull($struct->scroll); $this->assertEmpty($struct->searchCriteria); } + + public function testCanConstructQueueListMessageWithQueueDate() + { + + $struct = new QueueList(new QueueListOptions([ + 'queue' => new Queue([ + 'queue' => 50, + 'category' => 3, + 'timeMode' => 2 + ]) + ])); + + $this->assertCount(1, $struct->sortCriteria->sortOption); + $this->assertEquals(SelectionDetails::LIST_OPTION_SORT_CREATION, $struct->sortCriteria->sortOption[0]->selectionDetails->option); + $this->assertInstanceOf('Amadeus\Client\Struct\Queue\Dumbo', $struct->sortCriteria->dumbo); + $this->assertEquals(50, $struct->queueNumber->queueDetails->number); + $this->assertEquals(SubQueueInfoDetails::IDTYPE_CATEGORY, $struct->categoryDetails->subQueueInfoDetails->identificationType); + $this->assertEquals(3, $struct->categoryDetails->subQueueInfoDetails->itemNumber); + $this->assertNull($struct->categoryDetails->subQueueInfoDetails->itemDescription); + + $this->assertEquals(2, $struct->date->timeMode); + $this->assertNotNull($struct->date); + + $this->assertNull($struct->targetOffice); + $this->assertNull($struct->scanRange); + $this->assertNull($struct->scroll); + $this->assertEmpty($struct->searchCriteria); + } public function testCanConstructQueueListMessageWithOffice() { From a7e86e52ad1f1493ddf0ded88783f6fd2cdb131e Mon Sep 17 00:00:00 2001 From: ruslan Date: Mon, 20 May 2019 17:34:09 +0600 Subject: [PATCH 2/4] Fix tabulation. --- .../Amadeus/Client/Struct/Queue/ListTest.php | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/Amadeus/Client/Struct/Queue/ListTest.php b/tests/Amadeus/Client/Struct/Queue/ListTest.php index 49a23389b..6a780ba64 100644 --- a/tests/Amadeus/Client/Struct/Queue/ListTest.php +++ b/tests/Amadeus/Client/Struct/Queue/ListTest.php @@ -63,34 +63,34 @@ public function testCanConstructQueueListMessage() $this->assertNull($struct->scroll); $this->assertEmpty($struct->searchCriteria); } - - public function testCanConstructQueueListMessageWithQueueDate() - { - - $struct = new QueueList(new QueueListOptions([ - 'queue' => new Queue([ - 'queue' => 50, - 'category' => 3, - 'timeMode' => 2 - ]) - ])); - - $this->assertCount(1, $struct->sortCriteria->sortOption); - $this->assertEquals(SelectionDetails::LIST_OPTION_SORT_CREATION, $struct->sortCriteria->sortOption[0]->selectionDetails->option); - $this->assertInstanceOf('Amadeus\Client\Struct\Queue\Dumbo', $struct->sortCriteria->dumbo); - $this->assertEquals(50, $struct->queueNumber->queueDetails->number); - $this->assertEquals(SubQueueInfoDetails::IDTYPE_CATEGORY, $struct->categoryDetails->subQueueInfoDetails->identificationType); - $this->assertEquals(3, $struct->categoryDetails->subQueueInfoDetails->itemNumber); - $this->assertNull($struct->categoryDetails->subQueueInfoDetails->itemDescription); - - $this->assertEquals(2, $struct->date->timeMode); - $this->assertNotNull($struct->date); - - $this->assertNull($struct->targetOffice); - $this->assertNull($struct->scanRange); - $this->assertNull($struct->scroll); - $this->assertEmpty($struct->searchCriteria); - } + + public function testCanConstructQueueListMessageWithQueueDate() + { + + $struct = new QueueList(new QueueListOptions([ + 'queue' => new Queue([ + 'queue' => 50, + 'category' => 3, + 'timeMode' => 2 + ]) + ])); + + $this->assertCount(1, $struct->sortCriteria->sortOption); + $this->assertEquals(SelectionDetails::LIST_OPTION_SORT_CREATION, $struct->sortCriteria->sortOption[0]->selectionDetails->option); + $this->assertInstanceOf('Amadeus\Client\Struct\Queue\Dumbo', $struct->sortCriteria->dumbo); + $this->assertEquals(50, $struct->queueNumber->queueDetails->number); + $this->assertEquals(SubQueueInfoDetails::IDTYPE_CATEGORY, $struct->categoryDetails->subQueueInfoDetails->identificationType); + $this->assertEquals(3, $struct->categoryDetails->subQueueInfoDetails->itemNumber); + $this->assertNull($struct->categoryDetails->subQueueInfoDetails->itemDescription); + + $this->assertEquals(2, $struct->date->timeMode); + $this->assertNotNull($struct->date); + + $this->assertNull($struct->targetOffice); + $this->assertNull($struct->scanRange); + $this->assertNull($struct->scroll); + $this->assertEmpty($struct->searchCriteria); + } public function testCanConstructQueueListMessageWithOffice() { From d3f46ecd8cd4d68f492a8fcdac90f26d35de7f35 Mon Sep 17 00:00:00 2001 From: ruslan Date: Wed, 29 May 2019 10:17:08 +0600 Subject: [PATCH 3/4] Queue_RemoveItem missed property initialization is added. --- src/Amadeus/Client/Struct/Queue/TargetDetails.php | 1 + tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Amadeus/Client/Struct/Queue/TargetDetails.php b/src/Amadeus/Client/Struct/Queue/TargetDetails.php index 90a73e556..ddc69d81c 100644 --- a/src/Amadeus/Client/Struct/Queue/TargetDetails.php +++ b/src/Amadeus/Client/Struct/Queue/TargetDetails.php @@ -74,6 +74,7 @@ public function __construct($targetQueue, $recordLocators, $originatorOffice) $this->queueNumber = new QueueNumber($targetQueue->queue); $this->categoryDetails = new CategoryDetails($targetQueue->category); + $this->placementDate = new QueueDate($targetQueue->timeMode); foreach ($recordLocators as $recLoc) { $this->recordLocator[] = new RecordLocator($recLoc); diff --git a/tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php b/tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php index a5cd613c9..71a0f5def 100644 --- a/tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php +++ b/tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php @@ -42,7 +42,7 @@ public function testCanMakeRemoveItemMessage() $opt = new QueueRemoveItemOptions([ 'recordLocator' => 'ABC123', 'originatorOfficeId' => 'BRUXX0000', - 'queue' => new Queue(['queue' => 50, 'category' => 0]) + 'queue' => new Queue(['queue' => 50, 'category' => 0, 'timeMode' => 1]) ]); $msg = new RemoveItem( @@ -55,7 +55,8 @@ public function testCanMakeRemoveItemMessage() $this->assertEquals('ABC123', $msg->targetDetails[0]->recordLocator[0]->reservation->controlNumber); $this->assertEquals(1, count($msg->targetDetails)); $this->assertEquals('BRUXX0000', $msg->targetDetails[0]->targetOffice->originatorDetails->inHouseIdentification1); - $this->assertNull($msg->targetDetails[0]->placementDate); + $this->assertNotNull($msg->targetDetails[0]->placementDate); + $this->assertEquals(1, $msg->targetDetails[0]->placementDate->timeMode); $this->assertEquals(50, $msg->targetDetails[0]->queueNumber->queueDetails->number); $this->assertEquals(SubQueueInfoDetails::IDTYPE_CATEGORY, $msg->targetDetails[0]->categoryDetails->subQueueInfoDetails->identificationType); $this->assertEquals(0, $msg->targetDetails[0]->categoryDetails->subQueueInfoDetails->itemNumber); From 913d5d8d718d3149283a3cc6b7142ebb9d035162 Mon Sep 17 00:00:00 2001 From: ruslan Date: Wed, 29 May 2019 10:41:17 +0600 Subject: [PATCH 4/4] Fix test errors. --- .../Client/Struct/Queue/TargetDetails.php | 5 +++- .../Client/Struct/Queue/RemoveItemTest.php | 27 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Amadeus/Client/Struct/Queue/TargetDetails.php b/src/Amadeus/Client/Struct/Queue/TargetDetails.php index ddc69d81c..043a15304 100644 --- a/src/Amadeus/Client/Struct/Queue/TargetDetails.php +++ b/src/Amadeus/Client/Struct/Queue/TargetDetails.php @@ -74,7 +74,10 @@ public function __construct($targetQueue, $recordLocators, $originatorOffice) $this->queueNumber = new QueueNumber($targetQueue->queue); $this->categoryDetails = new CategoryDetails($targetQueue->category); - $this->placementDate = new QueueDate($targetQueue->timeMode); + + if (!empty($targetQueue->timeMode)) { + $this->placementDate = new QueueDate($targetQueue->timeMode); + } foreach ($recordLocators as $recLoc) { $this->recordLocator[] = new RecordLocator($recLoc); diff --git a/tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php b/tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php index 71a0f5def..142aff1ab 100644 --- a/tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php +++ b/tests/Amadeus/Client/Struct/Queue/RemoveItemTest.php @@ -42,7 +42,7 @@ public function testCanMakeRemoveItemMessage() $opt = new QueueRemoveItemOptions([ 'recordLocator' => 'ABC123', 'originatorOfficeId' => 'BRUXX0000', - 'queue' => new Queue(['queue' => 50, 'category' => 0, 'timeMode' => 1]) + 'queue' => new Queue(['queue' => 50, 'category' => 0]) ]); $msg = new RemoveItem( @@ -51,6 +51,31 @@ public function testCanMakeRemoveItemMessage() $opt->originatorOfficeId ); + $this->assertEquals(SourceType::SOURCETYPE_SAME_AS_ORIGINATOR, $msg->targetDetails[0]->targetOffice->sourceType->sourceQualifier1); + $this->assertEquals('ABC123', $msg->targetDetails[0]->recordLocator[0]->reservation->controlNumber); + $this->assertEquals(1, count($msg->targetDetails)); + $this->assertEquals('BRUXX0000', $msg->targetDetails[0]->targetOffice->originatorDetails->inHouseIdentification1); + $this->assertNull($msg->targetDetails[0]->placementDate); + $this->assertEquals(50, $msg->targetDetails[0]->queueNumber->queueDetails->number); + $this->assertEquals(SubQueueInfoDetails::IDTYPE_CATEGORY, $msg->targetDetails[0]->categoryDetails->subQueueInfoDetails->identificationType); + $this->assertEquals(0, $msg->targetDetails[0]->categoryDetails->subQueueInfoDetails->itemNumber); + } + + + public function testCanMakeRemoveItemMessageWithTimeMode() + { + $opt = new QueueRemoveItemOptions([ + 'recordLocator' => 'ABC123', + 'originatorOfficeId' => 'BRUXX0000', + 'queue' => new Queue(['queue' => 50, 'category' => 0, 'timeMode' => 1]) + ]); + + $msg = new RemoveItem( + $opt->queue, + $opt->recordLocator, + $opt->originatorOfficeId + ); + $this->assertEquals(SourceType::SOURCETYPE_SAME_AS_ORIGINATOR, $msg->targetDetails[0]->targetOffice->sourceType->sourceQualifier1); $this->assertEquals('ABC123', $msg->targetDetails[0]->recordLocator[0]->reservation->controlNumber); $this->assertEquals(1, count($msg->targetDetails));