-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added transport and payment to frontend API (#1726)
- Loading branch information
Showing
10 changed files
with
317 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Payment: | ||
type: object | ||
inherits: | ||
- 'PaymentDecorator' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Transport: | ||
type: object | ||
inherits: | ||
- 'TransportDecorator' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/FrontendApiBundle/Functional/Payment/PaymentTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\FrontendApiBundle\Functional\Payment; | ||
|
||
use Tests\FrontendApiBundle\Test\GraphQlTestCase; | ||
|
||
class PaymentTest extends GraphQlTestCase | ||
{ | ||
/** | ||
* @var \Shopsys\FrameworkBundle\Model\Payment\PaymentFacade | ||
* @inject | ||
*/ | ||
protected $paymentFacade; | ||
|
||
/** | ||
* @var \Shopsys\FrameworkBundle\Model\Payment\Payment | ||
*/ | ||
protected $payment; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->payment = $this->paymentFacade->getById(2); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testPaymentNameByUuid(): void | ||
{ | ||
$query = ' | ||
query { | ||
payment(uuid: "' . $this->payment->getUuid() . '") { | ||
name | ||
} | ||
} | ||
'; | ||
|
||
$arrayExpected = [ | ||
'data' => [ | ||
'payment' => [ | ||
'name' => t('Cash on delivery', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
], | ||
], | ||
]; | ||
|
||
$this->assertQueryWithExpectedArray($query, $arrayExpected); | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
tests/FrontendApiBundle/Functional/Payment/PaymentsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\FrontendApiBundle\Functional\Payment; | ||
|
||
use Tests\FrontendApiBundle\Test\GraphQlTestCase; | ||
|
||
class PaymentsTest extends GraphQlTestCase | ||
{ | ||
public function testPayments(): void | ||
{ | ||
$query = ' | ||
query { | ||
payments { | ||
name, | ||
description, | ||
instruction, | ||
position, | ||
price { | ||
priceWithVat | ||
priceWithoutVat | ||
vatAmount | ||
}, | ||
images { | ||
url | ||
}, | ||
transports { | ||
name | ||
} | ||
} | ||
} | ||
'; | ||
|
||
$arrayExpected = [ | ||
'data' => [ | ||
'payments' => [ | ||
[ | ||
'name' => t('Credit card', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
'description' => t('Quick, cheap and reliable!', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
'instruction' => null, | ||
'position' => 0, | ||
'price' => [ | ||
'priceWithVat' => '100', | ||
'priceWithoutVat' => '100.00', | ||
'vatAmount' => '0.00', | ||
], | ||
'images' => [ | ||
['url' => 'http://webserver:8080/content-test/images/payment/default/53.jpg'], | ||
['url' => 'http://webserver:8080/content-test/images/payment/original/53.jpg'], | ||
], | ||
'transports' => [ | ||
['name' => t('PPL', [], 'dataFixtures', $this->getLocaleForFirstDomain())], | ||
['name' => t('Personal collection', [], 'dataFixtures', $this->getLocaleForFirstDomain())], | ||
], | ||
], | ||
[ | ||
'name' => t('Cash on delivery', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
'description' => null, | ||
'instruction' => null, | ||
'position' => 1, | ||
'price' => [ | ||
'priceWithVat' => '50', | ||
'priceWithoutVat' => '50.00', | ||
'vatAmount' => '0.00', | ||
], | ||
'images' => [ | ||
['url' => 'http://webserver:8080/content-test/images/payment/default/55.jpg'], | ||
['url' => 'http://webserver:8080/content-test/images/payment/original/55.jpg'], | ||
], | ||
'transports' => [ | ||
['name' => t('Czech post', [], 'dataFixtures', $this->getLocaleForFirstDomain())], | ||
], | ||
], | ||
[ | ||
'name' => t('Cash', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
'description' => null, | ||
'instruction' => null, | ||
'position' => 2, | ||
'price' => [ | ||
'priceWithVat' => '0', | ||
'priceWithoutVat' => '0', | ||
'vatAmount' => '0', | ||
], | ||
'images' => [ | ||
['url' => 'http://webserver:8080/content-test/images/payment/default/54.jpg'], | ||
['url' => 'http://webserver:8080/content-test/images/payment/original/54.jpg'], | ||
], | ||
'transports' => [ | ||
['name' => t('Personal collection', [], 'dataFixtures', $this->getLocaleForFirstDomain())], | ||
], | ||
], | ||
], | ||
], | ||
]; | ||
|
||
$this->assertQueryWithExpectedArray($query, $arrayExpected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/FrontendApiBundle/Functional/Transport/TransportTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\FrontendApiBundle\Functional\Transport; | ||
|
||
use Tests\FrontendApiBundle\Test\GraphQlTestCase; | ||
|
||
class TransportTest extends GraphQlTestCase | ||
{ | ||
/** | ||
* @var \Shopsys\FrameworkBundle\Model\Transport\TransportFacade | ||
* @inject | ||
*/ | ||
protected $transportFacade; | ||
|
||
/** | ||
* @var \Shopsys\FrameworkBundle\Model\Transport\Transport | ||
*/ | ||
protected $transport; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->transport = $this->transportFacade->getById(2); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testTransportNameByUuid(): void | ||
{ | ||
$query = ' | ||
query { | ||
transport(uuid: "' . $this->transport->getUuid() . '") { | ||
name | ||
} | ||
} | ||
'; | ||
|
||
$arrayExpected = [ | ||
'data' => [ | ||
'transport' => [ | ||
'name' => t('PPL', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
], | ||
], | ||
]; | ||
|
||
$this->assertQueryWithExpectedArray($query, $arrayExpected); | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
tests/FrontendApiBundle/Functional/Transport/TransportsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\FrontendApiBundle\Functional\Transport; | ||
|
||
use Tests\FrontendApiBundle\Test\GraphQlTestCase; | ||
|
||
class TransportsTest extends GraphQlTestCase | ||
{ | ||
public function testPayments(): void | ||
{ | ||
$query = ' | ||
query { | ||
transports { | ||
name, | ||
description, | ||
instruction, | ||
position, | ||
price { | ||
priceWithVat | ||
priceWithoutVat | ||
vatAmount | ||
}, | ||
images { | ||
url | ||
}, | ||
payments { | ||
name | ||
} | ||
} | ||
} | ||
'; | ||
|
||
$arrayExpected = [ | ||
'data' => [ | ||
'transports' => [ | ||
[ | ||
'name' => t('Czech post', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
'description' => null, | ||
'instruction' => null, | ||
'position' => 0, | ||
'price' => [ | ||
'priceWithVat' => '121', | ||
'priceWithoutVat' => '100.00', | ||
'vatAmount' => '21.00', | ||
], | ||
'images' => [ | ||
['url' => 'http://webserver:8080/content-test/images/transport/default/56.jpg'], | ||
['url' => 'http://webserver:8080/content-test/images/transport/original/56.jpg'], | ||
], | ||
'payments' => [ | ||
['name' => t('Cash on delivery', [], 'dataFixtures', $this->getLocaleForFirstDomain())], | ||
], | ||
], | ||
[ | ||
'name' => t('PPL', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
'description' => null, | ||
'instruction' => null, | ||
'position' => 1, | ||
'price' => [ | ||
'priceWithVat' => '242', | ||
'priceWithoutVat' => '200.00', | ||
'vatAmount' => '42.00', | ||
], | ||
'images' => [ | ||
['url' => 'http://webserver:8080/content-test/images/transport/default/57.jpg'], | ||
['url' => 'http://webserver:8080/content-test/images/transport/original/57.jpg'], | ||
], | ||
'payments' => [ | ||
['name' => t('Credit card', [], 'dataFixtures', $this->getLocaleForFirstDomain())], | ||
], | ||
], | ||
[ | ||
'name' => t('Personal collection', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
'description' => t('You will be welcomed by friendly staff!', [], 'dataFixtures', $this->getLocaleForFirstDomain()), | ||
'instruction' => null, | ||
'position' => 2, | ||
'price' => [ | ||
'priceWithVat' => '0', | ||
'priceWithoutVat' => '0', | ||
'vatAmount' => '0', | ||
], | ||
'images' => [ | ||
['url' => 'http://webserver:8080/content-test/images/transport/default/58.jpg'], | ||
['url' => 'http://webserver:8080/content-test/images/transport/original/58.jpg'], | ||
], | ||
'payments' => [ | ||
['name' => t('Credit card', [], 'dataFixtures', $this->getLocaleForFirstDomain())], | ||
['name' => t('Cash', [], 'dataFixtures', $this->getLocaleForFirstDomain())], | ||
], | ||
], | ||
], | ||
], | ||
]; | ||
|
||
$this->assertQueryWithExpectedArray($query, $arrayExpected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters