IntegrationTest.php 2.7 KB
Newer Older
1 2 3 4
<?php

namespace Drupal\facets_summary\Tests;

5
use Drupal\Tests\facets\Functional\FacetsTestBase;
6 7 8 9 10 11 12
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Tests the overall functionality of the Facets summary admin UI.
 *
 * @group facets
 */
13
class IntegrationTest extends FacetsTestBase {
14 15 16 17 18 19 20 21 22 23 24 25

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'facets_summary',
  ];

  /**
   * No config checking.
   *
   * @var bool
26 27
   *
   * @todo Enable config checking again.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
   */
  protected $strictConfigSchema = FALSE;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->drupalLogin($this->adminUser);

    $this->setUpExampleStructure();
    $this->insertExampleContent();
    $this->assertEqual($this->indexItems($this->indexId), 5, '5 items were indexed.');

    // Make absolutely sure the ::$blocks variable doesn't pass information
    // along between tests.
    $this->blocks = NULL;
  }

  /**
   * {@inheritdoc}
   */
  protected function installModulesFromClassProperty(ContainerInterface $container) {
    // This will just set the Drupal state to include the necessary bundles for
    // our test entity type. Otherwise, fields from those bundles won't be found
    // and thus removed from the test index. (We can't do it in setUp(), before
    // calling the parent method, since the container isn't set up at that
    // point.)
    $bundles = array(
      'entity_test_mulrev_changed' => array('label' => 'Entity Test Bundle'),
      'item' => array('label' => 'item'),
      'article' => array('label' => 'article'),
    );
    \Drupal::state()->set('entity_test_mulrev_changed.bundles', $bundles);

    parent::installModulesFromClassProperty($container);
  }

  /**
   * Tests the overall functionality of the Facets summary admin UI.
   */
  public function testFramework() {
    $this->drupalGet('admin/config/search/facets');
    $this->assertNoText('Facets Summary');

    $values = [
      'name' => 'Owl',
      'id' => 'owl',
77
      'facet_source_id' => 'search_api:views_page__search_api_test_view__page_1',
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
    ];
    $this->drupalPostForm('admin/config/search/facets/add-facet-summary', $values, 'Save');
    $this->drupalPostForm(NULL, [], 'Save');

    $this->drupalGet('admin/config/search/facets');
    $this->assertText('Facets Summary');
    $this->assertText('Owl');

    $this->drupalGet('admin/config/search/facets/facet-summary/owl/edit');
    $this->assertText('No facets found.');

    $this->createFacet('Llama', 'llama');
    $this->drupalGet('admin/config/search/facets');
    $this->assertText('Llama');

    $this->drupalGet('admin/config/search/facets/facet-summary/owl/edit');
    $this->assertNoText('No facets found.');
    $this->assertText('Llama');
  }

}