Chris@0: createContentType(['type' => 'page']); Chris@0: Chris@0: $titles = [ Chris@0: 'Page One', Chris@0: 'Page Two', Chris@0: 'Another page', Chris@0: ]; Chris@0: foreach ($titles as $title) { Chris@0: $this->createNode([ Chris@0: 'title' => $title, Chris@0: 'language' => 'en', Chris@0: ]); Chris@0: $this->createNode([ Chris@0: 'title' => $title, Chris@0: 'language' => 'nl', Chris@0: ]); Chris@0: } Chris@0: Chris@0: // Create a user privileged enough to use exposed filters and view content. Chris@0: $user = $this->drupalCreateUser([ Chris@0: 'administer site configuration', Chris@0: 'access content', Chris@0: 'access content overview', Chris@0: ]); Chris@0: $this->drupalLogin($user); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests the AJAX callbacks for the glossary view. Chris@0: */ Chris@0: public function testGlossaryDefault() { Chris@0: // Visit the default Glossary page. Chris@0: $url = Url::fromRoute('view.test_glossary.page_1'); Chris@0: $this->drupalGet($url); Chris@0: Chris@0: $session = $this->getSession(); Chris@0: $web_assert = $this->assertSession(); Chris@0: Chris@0: $page = $session->getPage(); Chris@0: $rows = $page->findAll('css', '.view-test-glossary tr'); Chris@0: // We expect 2 rows plus the header row. Chris@0: $this->assertCount(3, $rows); Chris@0: // Click on the P link, this should show 4 rows plus the header row. Chris@0: $page->clickLink('P'); Chris@0: $web_assert->assertWaitOnAjaxRequest(); Chris@0: $rows = $page->findAll('css', '.view-test-glossary tr'); Chris@0: $this->assertCount(5, $rows); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Test that the glossary also works on a language prefixed URL. Chris@0: */ Chris@0: public function testGlossaryLanguagePrefix() { Chris@14: ConfigurableLanguage::createFromLangcode('nl')->save(); Chris@0: Chris@0: $config = $this->config('language.negotiation'); Chris@0: $config->set('url.prefixes', ['en' => 'en', 'nl' => 'nl']) Chris@0: ->save(); Chris@0: Chris@0: \Drupal::service('kernel')->rebuildContainer(); Chris@0: Chris@0: $url = Url::fromRoute('view.test_glossary.page_1'); Chris@0: $this->drupalGet($url); Chris@0: Chris@0: $session = $this->getSession(); Chris@0: $web_assert = $this->assertSession(); Chris@0: Chris@0: $page = $session->getPage(); Chris@0: Chris@0: $rows = $page->findAll('css', '.view-test-glossary tr'); Chris@0: // We expect 2 rows plus the header row. Chris@0: $this->assertCount(3, $rows); Chris@0: // Click on the P link, this should show 4 rows plus the header row. Chris@0: $page->clickLink('P'); Chris@0: $web_assert->assertWaitOnAjaxRequest(); Chris@0: Chris@0: $rows = $page->findAll('css', '.view-test-glossary tr'); Chris@0: $this->assertCount(5, $rows); Chris@0: } Chris@0: Chris@0: }