You are here

function AttributeCrudTest::testAddConfigurable in Linkit 8.4

Test adding a configurable attribute to a profile.

File

src/Tests/AttributeCrudTest.php, line 84
Contains \Drupal\linkit\Tests\AttributeCrudTest.

Class

AttributeCrudTest
Tests adding, listing and deleting attributes on a profile.

Namespace

Drupal\linkit\Tests

Code

function testAddConfigurable() {
  $this
    ->drupalGet(Url::fromRoute('linkit.attribute.add', [
    'linkit_profile' => $this->linkitProfile
      ->id(),
  ]));
  $this
    ->assertEqual(count($this->manager
    ->getDefinitions()), count($this
    ->xpath('//input[@type="radio"]')), 'All attributes are available.');
  $edit = array();
  $edit['plugin'] = 'configurable_dummy_attribute';
  $this
    ->drupalPostForm(NULL, $edit, t('Save and continue'));
  $this
    ->assertUrl(Url::fromRoute('linkit.attribute.edit', [
    'linkit_profile' => $this->linkitProfile
      ->id(),
    'plugin_instance_id' => 'configurable_dummy_attribute',
  ]));
  $this
    ->drupalGet(Url::fromRoute('linkit.attributes', [
    'linkit_profile' => $this->linkitProfile
      ->id(),
  ]));
  $this
    ->assertEqual(1, count($this
    ->xpath('//table/tbody/tr')), 'Attribute added.');
  $this
    ->assertNoText(t('No attributes added.'));
  $plugin_url = Url::fromRoute('linkit.attribute.edit', [
    'linkit_profile' => $this->linkitProfile
      ->id(),
    'plugin_instance_id' => 'configurable_dummy_attribute',
  ]);
  $this
    ->assertLinkByHref($plugin_url
    ->toString());
}