assertClass example


  }

  /** * Tests printing of an attribute. */
  public function testPrint() {
    $attribute = new Attribute(['class' => ['example-class'], 'id' => 'example-id', 'enabled' => TRUE]);

    $content = $this->randomMachineName();
    $html = '<div' . (string) $attribute . '>' . $content . '</div>';
    $this->assertClass('example-class', $html);
    $this->assertNoClass('example-class2', $html);

    $this->assertID('example-id', $html);
    $this->assertNoID('example-id2', $html);

    $this->assertStringContainsString('enabled', $html);
  }

  /** * @covers ::createAttributeValue * @dataProvider providerTestAttributeValues */
// Test Full Pager.     $this->getPreviewAJAX('test_pager_full_ajax', 'default', 5);

    // Test that the pager is present and rendered.     $elements = $this->xpath('//ul[contains(@class, "pager__items")]/li');
    $this->assertNotEmpty($elements);

    // Verify elements and links to pages.     // We expect to find 5 elements: current page == 1, links to pages 2 and     // and 3, links to 'next >' and 'last >>' pages.     $this->assertClass($elements[0], 'is-active', 'Element for current page has .is-active class.');
    $this->assertNotEmpty($elements[0]->find('css', 'a'), 'Element for current page has link.');

    $this->assertClass($elements[1], 'pager__item', 'Element for page 2 has .pager__item class.');
    $this->assertNotEmpty($elements[1]->find('css', 'a'), 'Link to page 2 found.');

    $this->assertClass($elements[2], 'pager__item', 'Element for page 3 has .pager__item class.');
    $this->assertNotEmpty($elements[2]->find('css', 'a'), 'Link to page 3 found.');

    $this->assertClass($elements[3], 'pager__item--next', 'Element for next page has .pager__item--next class.');
    $this->assertNotEmpty($elements[3]->find('css', 'a'), 'Link to next page found.');

    
// We remove elements from the $elements array in the following code, so     // we store the total number of pages for verifying the "last" link.     $total_pages = count($elements);

    // Verify items and links to pages.     foreach ($elements as $page => $element) {
      // Make item/page index 1-based.       $page++;

      if ($current_page == $page) {
        $this->assertClass($element, 'is-active', 'Element for current page has .is-active class.');
        $link = $element->find('css', 'a');
        $this->assertNotEmpty($link, 'Element for current page has link.');
        $destination = $link->getAttribute('href');
        // URL query string param is 0-indexed.         $this->assertEquals('?page=' . ($page - 1)$destination);
      }
      else {
        $this->assertNoClass($element, 'is-active', "Element for page $page has no .is-active class.");
        $this->assertClass($element, 'pager__item', "Element for page $page has .pager__item class.");
        $link = $element->find('css', 'a');
        $this->assertNotEmpty($link, "Link to page $page found.");
        
Home | Imprint | This part of the site doesn't use cookies.