function test_blank_attr_does_not_match_zero()
 {
     $expectation = new ContainsTagWithAttributes('span', array('class' => ''));
     $this->assertFalse($expectation->test('<span class="0">message</span>'));
 }
Example #2
0
 function test($html)
 {
     return !parent::test($html);
 }
Example #3
0
 public function test_paging_bar()
 {
     global $CFG, $OUTPUT;
     $totalcount = 5;
     $perpage = 4;
     $page = 1;
     $baseurl = new moodle_url($CFG->wwwroot . '/index.php');
     $pagevar = 'mypage';
     $pagingbar = new moodle_paging_bar();
     $pagingbar->totalcount = $totalcount;
     $pagingbar->page = $page;
     $pagingbar->perpage = $perpage;
     $pagingbar->baseurl = $baseurl;
     $pagingbar->pagevar = $pagevar;
     $pagingbar->nocurr = true;
     $originalbar = clone $pagingbar;
     $html = $OUTPUT->paging_bar($pagingbar);
     $this->assert(new ContainsTagWithAttribute('div', 'class', 'paging'), $html);
     $this->assert(new ContainsTagWithAttributes('a', array('class' => 'previous', 'href' => $baseurl->out() . '?mypage=0')), $html);
     // One of the links to the previous page must not have the 'previous' class
     $this->assert(new ContainsTagWithAttributes('a', array('href' => $baseurl->out() . '?mypage=0'), array('class' => 'previous')), $html);
     // The link to the current page must not have the 'next' class: it's the last page
     $this->assert(new ContainsTagWithAttributes('a', array('href' => $baseurl->out() . '?mypage=1'), array('class' => 'next')), $html);
     $pagingbar = clone $originalbar;
     // clone the original bar before each output and set of assertions
     $pagingbar->nocurr = false;
     $html = $OUTPUT->paging_bar($pagingbar);
     $this->assert(new ContainsTagWithAttribute('div', 'class', 'paging'), $html);
     $this->assert(new ContainsTagWithAttributes('a', array('href' => $baseurl->out() . '?mypage=0'), array('class' => 'previous')), $html);
     $this->assert(new ContainsTagWithAttributes('a', array('class' => 'previous', 'href' => $baseurl->out() . '?mypage=0')), $html);
     $expectation = new ContainsTagWithAttributes('a', array('href' => $baseurl->out() . '?mypage=1'), array('class' => 'next'));
     $this->assertFalse($expectation->test($html));
     // TODO test with more different parameters
 }