Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2017 07:44:10 PM (9 years ago)
Author:
boonebgorges
Message:

Use static factory method throughout PHPUnit tests.

See #7620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/class-bp-media-extractor.php

    r10223 r11737  
    144144
    145145        public function test_extract_multiple_media_types_from_content() {
    146                 $this->factory->user->create( array( 'user_login' => 'paulgibbs' ) );
     146                self::factory()->user->create( array( 'user_login' => 'paulgibbs' ) );
    147147                $media = self::$media_extractor->extract( self::$richtext, BP_Media_Extractor::LINKS | BP_Media_Extractor::MENTIONS );
    148148
     
    153153
    154154        public function test_extract_media_from_a_wp_post() {
    155                 $post_id = $this->factory->post->create( array( 'post_content' => self::$richtext ) );
     155                $post_id = self::factory()->post->create( array( 'post_content' => self::$richtext ) );
    156156                $media   = self::$media_extractor->extract( get_post( $post_id ), BP_Media_Extractor::LINKS );
    157157
     
    190190
    191191        public function test_extract_mentions_from_content_with_activity_enabled() {
    192                 $this->factory->user->create( array( 'user_login' => 'paulgibbs' ) );
     192                self::factory()->user->create( array( 'user_login' => 'paulgibbs' ) );
    193193                $media = self::$media_extractor->extract( self::$richtext, BP_Media_Extractor::MENTIONS );
    194194
     
    198198
    199199        public function test_extract_mentions_from_content_with_activity_disabled() {
    200                 $this->factory->user->create( array( 'user_login' => 'paulgibbs' ) );
     200                self::factory()->user->create( array( 'user_login' => 'paulgibbs' ) );
    201201                $was_activity_enabled = false;
    202202
     
    304304        public function test_extract_images_from_content_with_galleries_variant_no_ids() {
    305305                // To test the [gallery] shortcode, we need to create a post and an attachment.
    306                 $post_id       = $this->factory->post->create( array( 'post_content' => self::$richtext ) );
    307                 $attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
     306                $post_id       = self::factory()->post->create( array( 'post_content' => self::$richtext ) );
     307                $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array(
    308308                        'post_mime_type' => 'image/jpeg',
    309309                        'post_type'      => 'attachment'
     
    329329                $attachment_ids[] = $this->fake_attachment_upload( DIR_TESTDATA . '/images/canola.jpg' );
    330330                $attachment_ids   = join( ',', $attachment_ids );
    331                 $post_id          = $this->factory->post->create( array( 'post_content' => "[gallery ids='{$attachment_ids}']" ) );
     331                $post_id          = self::factory()->post->create( array( 'post_content' => "[gallery ids='{$attachment_ids}']" ) );
    332332
    333333                // Extract the gallery images.
     
    345345
    346346        public function test_extract_no_images_from_content_with_invalid_galleries_variant_no_ids() {
    347                 $post_id = $this->factory->post->create( array( 'post_content' => self::$richtext ) );
     347                $post_id = self::factory()->post->create( array( 'post_content' => self::$richtext ) );
    348348                $media   = self::$media_extractor->extract( self::$richtext, BP_Media_Extractor::IMAGES, array(
    349349                        'post' => get_post( $post_id ),
     
    356356
    357357        public function test_extract_no_images_from_content_with_invalid_galleries_variant_ids() {
    358                 $post_id = $this->factory->post->create( array( 'post_content' => '[gallery ids="117,4529"]' ) );
     358                $post_id = self::factory()->post->create( array( 'post_content' => '[gallery ids="117,4529"]' ) );
    359359                $media   = self::$media_extractor->extract( '', BP_Media_Extractor::IMAGES, array(
    360360                        'post' => get_post( $post_id ),
     
    372372
    373373        public function test_extract_no_images_from_content_with_featured_image() {
    374                 $post_id      = $this->factory->post->create( array( 'post_content' => self::$richtext ) );
    375                 $thumbnail_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array(
     374                $post_id      = self::factory()->post->create( array( 'post_content' => self::$richtext ) );
     375                $thumbnail_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array(
    376376                        'post_mime_type' => 'image/jpeg',
    377377                        'post_type'      => 'attachment'
     
    393393
    394394        public function test_extract_images_from_content_without_featured_image() {
    395                 $post_id = $this->factory->post->create( array( 'post_content' => self::$richtext ) );
     395                $post_id = self::factory()->post->create( array( 'post_content' => self::$richtext ) );
    396396                $media   = self::$media_extractor->extract( '', BP_Media_Extractor::IMAGES, array(
    397397                        'post' => get_post( $post_id ),
Note: See TracChangeset for help on using the changeset viewer.