function MerciTest::setUp in MERCI (Manage Equipment Reservations, Checkout and Inventory) 8.2
Modules to enable.
Overrides MerciTestBase::setUp
File
- src/
Tests/ MerciTest.php, line 32 - Contains \Drupal\merci\Tests\MerciTest.
Class
- MerciTest
- Tests pager functionality.
Namespace
Drupal\merci\TestsCode
function setUp() {
// Enable the module.
parent::setUp();
// Create merci user.
$this->merci_user = $this
->createUser(array(
'view all revisions',
'revert all revisions',
'edit own merci_resource content',
'delete own merci_resource content',
'access merci line item overview',
'add merci line item entities',
'edit merci line item entities',
'delete merci line item entities',
'view all merci line item revisions',
));
$roles = $this->merci_user
->getRoles();
$this->merci_role = reset($roles);
$vocabulary = Vocabulary::load('resource_tree');
$values = array(
'field_merci_allow_overnight' => array(
'value' => TRUE,
),
'field_merci_allow_weekends' => array(
'value' => TRUE,
),
'field_required_roles' => array(
'target_id' => $this->merci_role,
),
);
$this->term = $this
->createTerm($vocabulary, $values);
$settings = array(
'type' => 'office_hours',
'field_office_hours' => array(
array(
'day' => 0,
'starthours' => '400',
'endhours' => '1000',
),
array(
'day' => 0,
'starthours' => '1400',
'endhours' => '1800',
),
array(
'day' => 1,
'starthours' => '400',
'endhours' => '1800',
),
),
);
$this->office_hours = $this
->createNode($settings);
$id = $this->office_hours
->id();
$this
->drupalGet("/node/{$id}/edit");
$settings = array(
'type' => 'merci_resource',
'field_merci_grouping' => array(
'target_id' => $this->term
->id(),
),
'field_merci_location' => array(
'target_id' => $this->office_hours
->id(),
),
);
$this->resource1 = $this
->createNode($settings);
}