diff --git a/modules/order/tests/src/FunctionalJavascript/ProfileSelectTest.php b/modules/order/tests/src/FunctionalJavascript/ProfileSelectTest.php index 1cae168..22e4a7c 100644 --- a/modules/order/tests/src/FunctionalJavascript/ProfileSelectTest.php +++ b/modules/order/tests/src/FunctionalJavascript/ProfileSelectTest.php @@ -160,7 +160,7 @@ public function testAuthenticated() { /** * Tests creating the initial profile as an authenticated user. */ - public function testAuthenticatedEmpty() { + public function testAuthenticatedCreate() { $this->drupalGet(Url::fromRoute('commerce_order_test.profile_select_form')); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->fieldNotExists('Select a profile'); @@ -174,10 +174,11 @@ public function testAuthenticatedEmpty() { } $edit['profile[form][address][0][address][' . $key . ']'] = $value; } - $this->submitForm($edit, 'Submit'); + $this->submitForm($edit, 'Save'); /** @var \Drupal\profile\Entity\ProfileInterface $profile */ $profile = $this->profileStorage->load(1); + $this->submitForm($edit, 'Submit'); $this->assertSession()->responseContains(new FormattableMarkup('Profile selected: :label', [':label' => $profile->label()])); /** @var \Drupal\address\Plugin\Field\FieldType\AddressItem $address */ @@ -194,54 +195,6 @@ public function testAuthenticatedEmpty() { } /** - * Tests creating a profile as an authenticated user. - */ - public function testAuthenticatedCreate() { - /** @var \Drupal\profile\Entity\ProfileInterface $profile1 */ - $profile1 = $this->createEntity('profile', [ - 'type' => 'customer', - 'uid' => $this->adminUser->id(), - 'address' => $this->address1, - ]);; - - $this->drupalGet(Url::fromRoute('commerce_order_test.profile_select_form')); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->fieldExists('Select a profile'); - // The last created profile should be selected by default. - $this->assertSession()->pageTextContains($this->address1['locality']); - - $this->getSession()->getPage()->fillField('Select a profile', '_new'); - $this->waitForAjaxToFinish(); - $this->getSession()->getPage()->fillField('Country', $this->address2['country_code']); - $this->waitForAjaxToFinish(); - $edit = []; - foreach ($this->address2 as $key => $value) { - if ($key == 'country_code') { - continue; - } - $edit['profile[form][address][0][address][' . $key . ']'] = $value; - } - - $this->submitForm($edit, 'Submit'); - - $new_profile = $this->profileStorage->load(2); - /** @var \Drupal\address\Plugin\Field\FieldType\AddressItem $address */ - $address = $new_profile->get('address')->first(); - - $this->assertSession()->responseContains(new FormattableMarkup('Profile selected: :label', [':label' => $new_profile->label()])); - // Assert that field values have not changed. - $this->assertEquals($this->address2['country_code'], $address->getCountryCode()); - $this->assertEquals($this->address2['given_name'], $address->getGivenName()); - $this->assertEquals($this->address2['family_name'], $address->getFamilyName()); - $this->assertEquals($this->address2['address_line1'], $address->getAddressLine1()); - $this->assertEquals($this->address2['locality'], $address->getLocality()); - $this->assertEquals($this->address2['postal_code'], $address->getPostalCode()); - - $profiles = $this->profileStorage->loadMultipleByUser($this->adminUser, 'customer', TRUE); - $this->assertCount(2, $profiles); - } - - /** * Tests editing a profile as an authenticated user. * * @group debug @@ -253,6 +206,7 @@ public function testAuthenticatedEdit() { 'uid' => $this->adminUser->id(), 'address' => $this->address1, ]); + $profile1->save(); /** @var \Drupal\profile\Entity\ProfileInterface $profile2 */ $profile2 = $this->createEntity('profile', [ 'type' => 'customer', @@ -260,6 +214,7 @@ public function testAuthenticatedEdit() { 'address' => $this->address2, 'is_default' => TRUE, ]); + $profile2->save(); $this->drupalGet(Url::fromRoute('commerce_order_test.profile_select_form')); $this->assertSession()->statusCodeEquals(200); @@ -273,13 +228,14 @@ public function testAuthenticatedEdit() { $this->assertSession()->fieldValueEquals('profile[form][address][0][address][' . $key . ']', $value); } $this->getSession()->getPage()->fillField('Street address', 'Andrássy út 22'); - $this->submitForm([], 'Submit'); + $this->submitForm([], 'Save'); $this->profileStorage->resetCache([$profile2->id()]); $profile2 = $this->profileStorage->load($profile2->id()); /** @var \Drupal\address\Plugin\Field\FieldType\AddressItem $address */ $address = $profile2->get('address')->first(); + $this->submitForm([], 'Submit'); $this->assertSession()->responseContains(new FormattableMarkup('Profile selected: :label', [':label' => $profile2->label()])); // Assert that field values have not changed.