Changeset 40447
- Timestamp:
- 04/15/2017 08:07:52 PM (8 years ago)
- Location:
- branches/4.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0
-
branches/4.0/tests/phpunit/tests/general/paginateLinks.php
r28785 r40447 125 125 ) ); 126 126 127 // It's supposed to link to page 1: 128 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => 'http://' . WP_TESTS_DOMAIN . '/' ) ), $links[0] ); 129 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => 'http://' . WP_TESTS_DOMAIN . '/' ) ), $links[1] ); 127 $expected_attributes = array( 128 array( 129 'href' => 'http://' . WP_TESTS_DOMAIN . '/', 130 'class' => 'prev page-numbers' 131 ), 132 array( 133 'href' => 'http://' . WP_TESTS_DOMAIN . '/', 134 'class' => 'page-numbers' 135 ) 136 ); 130 137 131 // It's not supposed to have an empty href. 132 $this->assertNotTag( array( 'tag' => 'a', 'attributes' => array( 'class' => 'prev page-numbers', 'href' => '' ) ), $links[0] ); 133 $this->assertNotTag( array( 'tag' => 'a', 'attributes' => array( 'class' => 'page-numbers', 'href' => '' ) ), $links[1] ); 138 $document = new DOMDocument(); 139 $document->preserveWhiteSpace = false; 140 141 // The first two links should link to page 1 142 foreach ( $expected_attributes as $link_idx => $attributes ) { 143 144 $document->loadHTML( $links[$link_idx] ); 145 $tag = $document->getElementsByTagName( 'a' )->item( 0 ); 146 147 $this->assertNotNull( $tag ); 148 149 $href = $tag->attributes->getNamedItem( 'href' )->value; 150 $class = $tag->attributes->getNamedItem( 'class' )->value; 151 152 $this->assertEquals( $attributes['href'], $href ); 153 $this->assertEquals( $attributes['class'], $class ); 154 } 134 155 135 156 // Current page: 1 … … 142 163 ) ); 143 164 144 $this->assertTag( array( 'tag' => 'span', 'attributes' => array( 'class' => 'current' ) ), $links[0] ); 145 $this->assertTag( array( 'tag' => 'a', 'attributes' => array( 'href' => get_pagenum_link( 2 ) ) ), $links[1] ); 165 $document->loadHTML( $links[0] ); 166 $tag = $document->getElementsByTagName( 'span' )->item( 0 ); 167 $this->assertNotNull( $tag ); 168 169 $class = $tag->attributes->getNamedItem( 'class' )->value; 170 $this->assertEquals( 'page-numbers current', $class ); 171 172 $document->loadHTML( $links[1] ); 173 $tag = $document->getElementsByTagName( 'a' )->item( 0 ); 174 $this->assertNotNull( $tag ); 175 176 $href = $tag->attributes->getNamedItem( 'href' )->value; 177 $this->assertEquals( get_pagenum_link( 2 ), $href ); 146 178 } 147 179
Note: See TracChangeset
for help on using the changeset viewer.