| 200 | |
| 201 | /** |
| 202 | * @test 33591 |
| 203 | */ |
| 204 | function test_atom_enclosure_with_extended_url_length_type_parsing() |
| 205 | { |
| 206 | $enclosures = array( |
| 207 | array( |
| 208 | 'actual' => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\n318465\nvideo/mp4", // url length type |
| 209 | 'expected' => array( |
| 210 | 'href' => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4", |
| 211 | 'length' => 318465, |
| 212 | 'type' => "video/mp4" |
| 213 | ) |
| 214 | ), |
| 215 | array( |
| 216 | 'actual' => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\nvideo/mp4\n318465", // url type length |
| 217 | 'expected' => array( |
| 218 | 'href' => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4", |
| 219 | 'length' => 318465, |
| 220 | 'type' => "video/mp4" |
| 221 | ) |
| 222 | ), |
| 223 | array( |
| 224 | 'actual' => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4\n318465", // url length |
| 225 | 'expected' => array( |
| 226 | 'href' => "https://wordpress.dev/wp-content/uploads/2017/09/movie.mp4", |
| 227 | 'length' => 318465, |
| 228 | 'type' => "" |
| 229 | ) |
| 230 | ), |
| 231 | array( |
| 232 | 'actual' => "https://wordpress.dev/wp-content/uploads/2017/01/audio.mp3\n\naudio/mpeg", // url type |
| 233 | 'expected' => array( |
| 234 | 'href' => "https://wordpress.dev/wp-content/uploads/2017/01/audio.mp3", |
| 235 | 'length' => 0, |
| 236 | 'type' => "audio/mpeg" |
| 237 | ) |
| 238 | ), |
| 239 | array( |
| 240 | 'actual' => "https://wordpress.dev/wp-content/uploads/2016/01/test.mp4", // url |
| 241 | 'expected' => array( |
| 242 | 'href' => "https://wordpress.dev/wp-content/uploads/2016/01/test.mp4", |
| 243 | 'length' => 0, |
| 244 | 'type' => "" |
| 245 | ) |
| 246 | ), |
| 247 | ); |
| 248 | |
| 249 | $post_id = end( self::$posts ); |
| 250 | foreach( $enclosures as $enclosure ) { |
| 251 | add_post_meta( $post_id, 'enclosure', $enclosure['actual'] ); |
| 252 | } |
| 253 | $this->go_to( '/?feed=atom' ); |
| 254 | $feed = $this->do_atom(); |
| 255 | $xml = xml_to_array( $feed ); |
| 256 | $entries = xml_find( $xml, 'feed', 'entry' ); |
| 257 | $entries = array_slice( $entries, 0, 1 ); |
| 258 | |
| 259 | foreach ( $entries as $key => $entry ) { |
| 260 | $links = xml_find( $entries[$key]['child'], 'link' ); |
| 261 | $i = 0; |
| 262 | foreach ( (array) $links as $link ) { |
| 263 | if ( 'enclosure' == $link['attributes']['rel'] ) { |
| 264 | $this->assertEquals( $enclosures[$i]['expected']['href'] , $link['attributes']['href'] ); |
| 265 | $this->assertEquals( $enclosures[$i]['expected']['length'] , $link['attributes']['length'] ); |
| 266 | $this->assertEquals( $enclosures[$i]['expected']['type'] , $link['attributes']['type'] ); |
| 267 | $i++; |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | |