ProductTabsTest.php in Ubercart 8.4
File
uc_product/tests/src/Functional/ProductTabsTest.php
View source
<?php
namespace Drupal\Tests\uc_product\Functional;
use Drupal\Tests\uc_store\Functional\UbercartBrowserTestBase;
class ProductTabsTest extends UbercartBrowserTestBase {
protected static $modules = [
'uc_product',
'uc_attribute',
'uc_stock',
];
protected static $adminPermissions = [
'bypass node access',
'administer attributes',
'administer product attributes',
'administer product options',
'administer product stock',
];
protected function setUp() {
parent::setUp();
$this
->drupalLogin($this->adminUser);
}
public function testProductTabs() {
$assert = $this
->assertSession();
$product = $this
->createProduct();
$this
->drupalGet('node/' . $product
->id() . '/edit');
$assert
->fieldValueEquals('title[0][value]', $product
->getTitle());
$assert
->linkExists('Product');
$assert
->linkExists('Attributes');
$assert
->linkExists('Options');
$assert
->linkExists('Adjustments');
$assert
->linkExists('Features');
$assert
->linkExists('Stock');
}
public function testNonProductTabs() {
$assert = $this
->assertSession();
$this
->drupalCreateContentType([
'type' => 'page',
]);
$page = $this
->drupalCreateNode([
'type' => 'page',
]);
$this
->drupalGet('node/' . $page
->id() . '/edit');
$assert
->fieldValueEquals('title[0][value]', $page
->getTitle());
$assert
->linkNotExists('Product');
$assert
->linkNotExists('Attributes');
$assert
->linkNotExists('Options');
$assert
->linkNotExists('Adjustments');
$assert
->linkNotExists('Features');
$assert
->linkNotExists('Stock');
}
public function testProductTypeTabs() {
$assert = $this
->assertSession();
$this
->drupalGet('admin/structure/types/manage/product');
$assert
->fieldValueEquals('name', 'Product');
$assert
->linkExists('Product attributes');
$assert
->linkExists('Product options');
}
public function testNonProductTypeTabs() {
$assert = $this
->assertSession();
$type = $this
->drupalCreateContentType([
'type' => 'page',
]);
$this
->drupalGet('admin/structure/types/manage/' . $type
->id());
$assert
->fieldValueEquals('name', $type
->label());
$assert
->linkNotExists('Product attributes');
$assert
->linkNotExists('Product options');
}
}