diff --git tests/phpunit/testcases/core/class-bp-attachment.php tests/phpunit/testcases/core/class-bp-attachment.php
index 80f933f5d..fae4e150d 100644
|
|
|
class BP_Tests_BP_Attachment_TestCases extends BP_UnitTestCase { |
| 377 | 377 | * @group avatars |
| 378 | 378 | */ |
| 379 | 379 | public function test_bp_attachment_avatar_shrink() { |
| 380 | | if ( false === _wp_image_editor_choose() ) { |
| 381 | | $this->markTestSkipped( 'This test requires PHP to have a valid image editor that is compatible with WordPress.' ); |
| | 380 | if ( false === _wp_image_editor_choose() || version_compare( phpversion(), '7.0' , '<' ) ) { |
| | 381 | $this->markTestSkipped( 'This test requires PHP >= 7.0 and to have a valid image editor that is compatible with WordPress.' ); |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | $image = BP_TESTS_DIR . 'assets/upside-down.jpg'; |
| … |
… |
class BP_Tests_BP_Attachment_TestCases extends BP_UnitTestCase { |
| 429 | 429 | $this->markTestSkipped( 'This test requires PHP to have a valid image editor that is compatible with WordPress.' ); |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | | $image = BP_TESTS_DIR . 'assets/upside-down.jpg'; |
| | 432 | $image = BP_TESTS_DIR . 'assets/test-image-large.jpg'; |
| 433 | 433 | |
| 434 | 434 | $cover_image_class = new BP_Attachment_Cover_Image(); |
| 435 | 435 | |
| 436 | | $abs_path_copy = $cover_image_class->upload_path . '/upside-down.jpg'; |
| | 436 | $abs_path_copy = $cover_image_class->upload_path . '/test-image-large.jpg'; |
| 437 | 437 | |
| 438 | 438 | copy( $image, $abs_path_copy ); |
| 439 | 439 | |
| … |
… |
class BP_Tests_BP_Attachment_TestCases extends BP_UnitTestCase { |
| 464 | 464 | * @group cover_images |
| 465 | 465 | */ |
| 466 | 466 | public function test_bp_attachment_get_image_data() { |
| 467 | | if ( ! is_callable( 'exif_read_data' ) ) { |
| 468 | | $this->markTestSkipped( 'This test requires PHP to be compiled with EXIF support.' ); |
| | 467 | if ( ! is_callable( 'exif_read_data' ) || version_compare( phpversion(), '7.0' , '<' ) ) { |
| | 468 | $this->markTestSkipped( 'This test requires PHP >= 7.0 and to be compiled with EXIF support.' ); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | $image_data = BP_Attachment::get_image_data( BP_TESTS_DIR . 'assets/upside-down.jpg' ); |
diff --git tests/phpunit/testcases/core/class-bp-media-extractor.php tests/phpunit/testcases/core/class-bp-media-extractor.php
index 7587d7e69..328dcf572 100644
|
|
|
class BP_Tests_Media_Extractor extends BP_UnitTestCase { |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | public function test_extract_images_from_content_with_galleries_variant_ids() { |
| 324 | | $attachment_ids = array(); |
| 325 | | $attachment_ids[] = $this->fake_attachment_upload( DIR_TESTDATA . '/images/test-image-large.png' ); |
| 326 | | $attachment_ids[] = $this->fake_attachment_upload( DIR_TESTDATA . '/images/canola.jpg' ); |
| 327 | | $attachment_ids = join( ',', $attachment_ids ); |
| 328 | | $post_id = self::factory()->post->create( array( 'post_content' => "[gallery ids='{$attachment_ids}']" ) ); |
| | 324 | $attachment_ids = array( |
| | 325 | 'large' => 0, |
| | 326 | 'canola' => 0, |
| | 327 | ); |
| | 328 | |
| | 329 | $attachment_ids['large'] = self::factory()->attachment->create_upload_object( BP_TESTS_DIR . 'assets/test-image-large.jpg' ); |
| | 330 | $attachment_ids['canola'] = self::factory()->attachment->create_upload_object( BP_TESTS_DIR . 'assets/canola.jpg' ); |
| | 331 | |
| | 332 | $attachments = join( ',', $attachment_ids ); |
| | 333 | $post_id = self::factory()->post->create( array( 'post_content' => "[gallery ids='{$attachments}']" ) ); |
| 329 | 334 | |
| 330 | 335 | // Extract the gallery images. |
| 331 | 336 | $media = self::$media_extractor->extract( '', BP_Media_Extractor::IMAGES, array( |
| … |
… |
class BP_Tests_Media_Extractor extends BP_UnitTestCase { |
| 336 | 341 | $media = array_values( wp_list_filter( $media['images'], array( 'source' => 'galleries' ) ) ); |
| 337 | 342 | $this->assertCount( 2, $media ); |
| 338 | 343 | |
| 339 | | $this->assertSame( WP_CONTENT_URL . '/uploads/test-image-large.png', $media[0]['url'] ); |
| 340 | | $this->assertSame( WP_CONTENT_URL . '/uploads/canola.jpg', $media[1]['url'] ); |
| | 344 | $expected_urls = array( |
| | 345 | 'large' => wp_get_attachment_url( $attachment_ids['large'] ), |
| | 346 | 'canola' => wp_get_attachment_url( $attachment_ids['canola'] ), |
| | 347 | ); |
| | 348 | |
| | 349 | $this->assertSame( $expected_urls['large'], $media[0]['url'] ); |
| | 350 | $this->assertSame( $expected_urls['canola'], $media[1]['url'] ); |
| 341 | 351 | } |
| 342 | 352 | |
| 343 | 353 | public function test_extract_no_images_from_content_with_invalid_galleries_variant_no_ids() { |