You are here

public function InvoiceAdminTest::testOrderInvoicesAccess in Commerce Invoice 8.2

Tests access to the order invoices tab.

File

tests/src/Functional/InvoiceAdminTest.php, line 111

Class

InvoiceAdminTest
Tests the invoice admin UI.

Namespace

Drupal\Tests\commerce_invoice\Functional

Code

public function testOrderInvoicesAccess() {
  $user = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet($this->orderInvoicesUrl);
  $this
    ->assertSession()
    ->pageTextContains('Access denied');
  $this->order
    ->set('state', 'completed');
  $this->order
    ->save();
  $this
    ->getSession()
    ->reload();
  $this
    ->assertSession()
    ->pageTextContains('Access denied');
  $user2 = $this
    ->drupalCreateUser([
    'administer commerce_invoice',
  ]);
  $this
    ->drupalLogin($user2);
  $this
    ->drupalGet($this->orderInvoicesUrl);
  $this
    ->assertSession()
    ->pageTextContains('There are no invoices yet.');
  $this
    ->assertSession()
    ->linkByHrefExists($this->orderInvoiceAddUrl);
}