123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- /**
- * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
- */
- namespace Temando\Shipping\CustomerData;
- use Magento\TestFramework\Helper\Bootstrap;
- use Temando\Shipping\Model\Checkout\Schema\CheckoutField;
- /**
- * Temando Customer Data Checkout Fields Test
- *
- * @codingStandardsIgnoreFile
- *
- * @package Temando\Shipping\Test\Integration
- * @author Christoph Aßmann <christoph.assmann@netresearch.de>
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * @link http://www.temando.com/
- */
- class CheckoutFieldsTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @test
- * @magentoConfigFixture default/carriers/temando/active 0
- * @magentoConfigFixture default/carriers/temando/additional_checkout_fields [{"id":"signature","label":"Signature","fieldType":"checkbox","orderPath":"#/address/type"}]
- */
- public function sectionDataIsEmptyWhenShippingIsDisabledInCheckout()
- {
- /** @var CheckoutFields $customerData */
- $customerData = Bootstrap::getObjectManager()->create(CheckoutFields::class);
- $sectionData = $customerData->getSectionData();
- $this->assertArrayHasKey('fields', $sectionData);
- $this->assertInternalType('array', $sectionData['fields']);
- $this->assertEmpty($sectionData['fields']);
- }
- /**
- * @test
- * @magentoConfigFixture default_store carriers/temando/active 1
- * @magentoConfigFixture default/carriers/temando/additional_checkout_fields [{"id":"signature","label":"Signature","fieldType":"checkbox","orderPath":"#/address/type"}]
- */
- public function sectionDataIsNotEmptyWhenShippingIsEnabledInCheckout()
- {
- /** @var CheckoutFields $customerData */
- $customerData = Bootstrap::getObjectManager()->create(CheckoutFields::class);
- $sectionData = $customerData->getSectionData();
- $this->assertArrayHasKey('fields', $sectionData);
- $this->assertInternalType('array', $sectionData['fields']);
- $this->assertNotEmpty($sectionData['fields']);
- }
- /**
- * @test
- * @magentoConfigFixture default_store carriers/temando/active 1
- * @magentoConfigFixture default/carriers/temando/additional_checkout_fields [{"id":"signature","label":"Signature","fieldType":"checkbox","orderPath":"#/address/type","defaultValue": true}]
- */
- public function checkboxTypeIsPrepared()
- {
- /** @var CheckoutFields $customerData */
- $customerData = Bootstrap::getObjectManager()->create(CheckoutFields::class);
- $sectionData = $customerData->getSectionData();
- $fields = $sectionData['fields'];
- $this->assertInternalType('array', $fields);
- $this->assertCount(1, $fields);
- /** @var CheckoutField $checkboxField */
- $checkboxField = $fields['signature'];
- $this->assertEquals('signature', $checkboxField['id']);
- $this->assertEquals('Signature', $checkboxField['label']);
- $this->assertEquals('checkbox', $checkboxField['type']);
- $this->assertEquals('#/address/type', $checkboxField['orderPath']);
- $this->assertTrue($checkboxField['defaultValue']);
- $this->assertEmpty($checkboxField['options']);
- }
- /**
- * @test
- * @magentoConfigFixture default_store carriers/temando/active 1
- * @magentoConfigFixture default/carriers/temando/additional_checkout_fields [{"id": "text","label": "Text","orderPath": "#/address/text","fieldType": "inputText","defaultValue": "Default"}]
- */
- public function textTypeIsPrepared()
- {
- /** @var CheckoutFields $customerData */
- $customerData = Bootstrap::getObjectManager()->create(CheckoutFields::class);
- $sectionData = $customerData->getSectionData();
- $fields = $sectionData['fields'];
- $this->assertInternalType('array', $fields);
- $this->assertCount(1, $fields);
- /** @var CheckoutField $textField */
- $textField = $fields['text'];
- $this->assertEquals('text', $textField['id']);
- $this->assertEquals('Text', $textField['label']);
- $this->assertEquals('text', $textField['type']);
- $this->assertEquals('#/address/text', $textField['orderPath']);
- $this->assertEquals('Default', $textField['defaultValue']);
- $this->assertEmpty($textField['options']);
- }
- /**
- * @test
- * @magentoConfigFixture default_store carriers/temando/active 1
- * @magentoConfigFixture default/carriers/temando/additional_checkout_fields [{"id": "select","label": "Select","orderPath": "#/address/select","fieldType": "select","defaultValue": "Two","options": [{"name": "One","value": "one"},{"name": "Two","value": "two"}]}]
- */
- public function selectTypeIsPrepared()
- {
- /** @var CheckoutFields $customerData */
- $customerData = Bootstrap::getObjectManager()->create(CheckoutFields::class);
- $sectionData = $customerData->getSectionData();
- $fields = $sectionData['fields'];
- $this->assertInternalType('array', $fields);
- $this->assertCount(1, $fields);
- /** @var CheckoutField $selectField */
- $selectField = $fields['select'];
- $this->assertEquals('select', $selectField['id']);
- $this->assertEquals('Select', $selectField['label']);
- $this->assertEquals('select', $selectField['type']);
- $this->assertEquals('#/address/select', $selectField['orderPath']);
- $this->assertEquals('Two', $selectField['defaultValue']);
- $this->assertNotEmpty($selectField['options']);
- $this->assertInternalType('array', $selectField['options']);
- }
- }
|