RoleTest.php in Ubercart 8.4
File
uc_role/tests/src/Functional/RoleTest.php
View source
<?php
namespace Drupal\Tests\uc_role\Functional;
use Drupal\Tests\Traits\Core\CronRunTrait;
use Drupal\Tests\uc_store\Functional\UbercartBrowserTestBase;
use Drupal\user\Entity\Role;
class RoleTest extends UbercartBrowserTestBase {
use CronRunTrait;
protected static $modules = [
'uc_payment',
'uc_payment_pack',
'uc_role',
'editor',
];
public function testRolePurchaseCheckout() {
$product = $this
->createProduct([
'price' => 0,
'shippable' => 0,
]);
$rid = $this
->drupalCreateRole([
'access content',
]);
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('node/' . $product
->id() . '/edit/features');
$this
->submitForm([
'feature' => 'role',
], 'Add');
$edit = [
'role' => $rid,
'end_override' => TRUE,
'expire_relative_duration' => 1,
'expire_relative_granularity' => 'day',
];
$this
->submitForm($edit, 'Save feature');
$this
->addToCart($product);
$order = $this
->checkout();
$role = Role::load($rid);
user_delete($order
->getOwnerId());
$this
->cronRun();
}
protected function populateCheckoutForm(array $edit = []) {
$edit = parent::populateCheckoutForm($edit);
foreach (array_keys($edit) as $key) {
if (substr($key, 0, 15) == 'panes[delivery]') {
unset($edit[$key]);
}
}
return $edit;
}
}
Classes
Name |
Description |
RoleTest |
Tests the role purchase functionality. |