Exemplo n.º 1
0
 public function testSinglePageConfig()
 {
     ShopTest::setConfiguration();
     //start a new order
     $order = new Order();
     $order->write();
     $config = new SinglePageCheckoutComponentConfig($order);
     $components = $config->getComponents();
     //assertions!
     $fields = $config->getFormFields();
     //assertions!
     $required = $config->getRequiredFields();
     //assertions!
     //$validateData = $config->validateData($data);
     //assertions!
     $data = $config->getData();
     //assertions!
     $config->setData($data);
     //assertions!
     //form field generation
     //validate data
     //set data
     //get data
     $this->markTestIncomplete('Lots missing here');
 }
 public function testSinglePageConfigForSingleCountrySiteWithReadonlyFieldsForCountry()
 {
     // Set as a single country site
     $this->loadFixture("shop/tests/fixtures/singlecountry.yml");
     $singlecountry = SiteConfig::current_site_config();
     $this->assertEquals("NZ", $singlecountry->getSingleCountry(), "Confirm that website is setup as a single country site");
     $order = new Order();
     //start a new order
     $order->write();
     $config = new SinglePageCheckoutComponentConfig($order);
     $customerdetailscomponent = $config->getComponentByType("CustomerDetailsCheckoutComponent");
     $customerdetailscomponent->setData($order, array("FirstName" => "John", "Surname" => "Walker", "Email" => "*****@*****.**"));
     $shippingaddresscomponent = $config->getComponentByType("ShippingAddressCheckoutComponent");
     $shippingaddresscomponent->setData($order, $this->addressNoCountry->toMap());
     $billingaddresscomponent = $config->getComponentByType("BillingAddressCheckoutComponent");
     $billingaddresscomponent->setData($order, $this->addressNoCountry->toMap());
     $paymentcomponent = $config->getComponentByType("PaymentCheckoutComponent");
     $paymentcomponent->setData($order, array("PaymentMethod" => "Dummy"));
     $fields = $config->getFormFields();
     $shippingaddressfield = $fields->fieldByName("ShippingAddressCheckoutComponent_Country_readonly");
     $billingaddressfield = $fields->fieldByName("BillingAddressCheckoutComponent_Country_readonly");
     $this->assertContains("New Zealand", $shippingaddressfield->Value(), "The value of the Shipping Country readonly field is 'New Zealand'");
     $this->assertContains("New Zealand", $billingaddressfield->Value(), "The value of the Billing Country readonly field is 'New Zealand'");
     $this->assertTrue($shippingaddressfield->isReadonly(), "The Shipping Address Country field is readonly");
     $this->assertTrue($shippingaddressfield->isReadonly(), "The Billing Address Country field is readonly");
     $required = $config->getRequiredFields();
     $requiredfieldswithCountryAbsent = array("CustomerDetailsCheckoutComponent_FirstName", "CustomerDetailsCheckoutComponent_Surname", "CustomerDetailsCheckoutComponent_Email", "ShippingAddressCheckoutComponent_State", "ShippingAddressCheckoutComponent_City", "ShippingAddressCheckoutComponent_Address", "BillingAddressCheckoutComponent_State", "BillingAddressCheckoutComponent_City", "BillingAddressCheckoutComponent_Address");
     $this->assertSame($requiredfieldswithCountryAbsent, $required, "getRequiredFields function returns required fields from numerous components except for the Country fields (no need to validate readonly fields)");
     $data = $config->getData();
     $this->assertEquals("NZ", $data["ShippingAddressCheckoutComponent_Country"]);
     $this->assertEquals("NZ", $data["BillingAddressCheckoutComponent_Country"]);
     $validateData = $config->validateData($data);
     $this->assertTrue($validateData, print_r($validateData, true), "Data validation must return true.  Note: should not be testing a country field here as validation of a readonly field is not necessary" . print_r($validateData, true));
     $config->setData($data);
 }