Guest User

Untitled

a guest
Jan 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Tests\Browser;
  4.  
  5. use Tests\DuskTestCase;
  6. use Laravel\Dusk\Browser;
  7. use Illuminate\Foundation\Testing\WithFaker;
  8.  
  9. class SubscriptionsTest extends DuskTestCase
  10. {
  11. use WithFaker;
  12. /**
  13. * A basic browser test example.
  14. *
  15. * @return void
  16. */
  17. public function testSubscribe()
  18. {
  19. $this->browse(function (Browser $browser) {
  20. $browser->loginAs($this->customer_user)
  21. ->visit('/settings')
  22. ->click('a[href="#subscription"]')
  23. ->click('#subscription .radio-select:nth-child(1)')
  24. ->assertSee('Billing Information')
  25. ->type('@subscribeNameInput', $this->faker->name)
  26. ->type('@addressInput', $this->faker->streetAddress)
  27. ->type('@address2Input', $this->faker->secondaryAddress)
  28. ->type('@cityInput', $this->faker->city)
  29. ->type('@stateInput', $this->faker->stateAbbr)
  30. ->type('@zipInput', $this->faker->postcode)
  31. ->select('@countryInput', 'US')
  32. ->waitFor('#subscription iframe[allowpaymentrequest="true"]', 15);
  33. $browser->driver->switchTo()->frame($browser->script('return $(\'#subscription iframe[allowpaymentrequest="true"]\').attr("name");')[0]);
  34.  
  35. foreach (str_split('4242424242424242') as $char) {
  36. $browser->append('cardnumber', $char)->pause(100);
  37. }
  38.  
  39. $browser->type('exp-date', '1222')
  40. ->type('cvc', '123');
  41.  
  42. $browser->driver->switchTo()->defaultContent();
  43.  
  44. $browser->press('Subscribe')
  45. ->waitForText('You are currently subscribed', 60)
  46. ->assertSee('You are currently subscribed');
  47. });
  48. }
  49. }
Add Comment
Please, Sign In to add comment