Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2017 07:44:10 PM (4 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/activity/class.BP_Activity_Activity.php

    r11312 r11737  
    1010    public function test_check_exists_by_content() {
    1111        $content  = 'A classy girl who know how to enjoy the freedom of a cup of coffee';
    12         $activity = $this->factory->activity->create( array(
     12        $activity = self::factory()->activity->create( array(
    1313            'content' => $content,
    1414            'type'    => 'activity_update',
     
    2323     */
    2424    public function test_delete_activity_item_comments() {
    25         $parent_activity = $this->factory->activity->create( array(
     25        $parent_activity = self::factory()->activity->create( array(
    2626            'type' => 'activity_update',
    2727        ) );
    2828
    29         $comments = $this->factory->activity->create_many( 3, array(
     29        $comments = self::factory()->activity->create_many( 3, array(
    3030            'item_id' => $parent_activity,
    3131            'type'    => 'activity_comment',
     
    4444     */
    4545    public function test_delete_activity_meta_entries() {
    46         $activity = $this->factory->activity->create( array(
     46        $activity = self::factory()->activity->create( array(
    4747            'type' => 'activity_update',
    4848        ) );
     
    6161     */
    6262    public function test_get_with_fields_parameter_by_id() {
    63         $a = $this->factory->activity->create_many( 3, array(
     63        $a = self::factory()->activity->create_many( 3, array(
    6464            'type' => 'activity_update',
    6565        ) );
     
    7575     */
    7676    public function test_hide_all_for_user() {
    77         $activity = $this->factory->activity->create( array(
     77        $activity = self::factory()->activity->create( array(
    7878            'type' => 'activity_update',
    7979        ) );
     
    9393     */
    9494    public function test_get_with_meta_query() {
    95         $a1 = $this->factory->activity->create();
    96         $a2 = $this->factory->activity->create();
     95        $a1 = self::factory()->activity->create();
     96        $a2 = self::factory()->activity->create();
    9797        bp_activity_update_meta( $a1, 'foo', 'bar' );
    9898
     
    114114    public function test_get_with_meta_query_two_clauses_with_or_relation() {
    115115        $now = time();
    116         $a1 = $this->factory->activity->create( array(
     116        $a1 = self::factory()->activity->create( array(
    117117            'recorded_time' => date( 'Y-m-d H:i:s', $now ),
    118118        ) );
    119         $a2 = $this->factory->activity->create( array(
     119        $a2 = self::factory()->activity->create( array(
    120120            'recorded_time' => date( 'Y-m-d H:i:s', $now - 60 ),
    121121        ) );
    122         $a3 = $this->factory->activity->create( array(
     122        $a3 = self::factory()->activity->create( array(
    123123            'recorded_time' => date( 'Y-m-d H:i:s', $now - 120 ),
    124124        ) );
     
    157157        }
    158158
    159         $a1 = $this->factory->activity->create();
    160         $a2 = $this->factory->activity->create( array(
     159        $a1 = self::factory()->activity->create();
     160        $a2 = self::factory()->activity->create( array(
    161161            'recorded_time' => '2001-01-01 12:00'
    162162        ) );
    163         $a3 = $this->factory->activity->create( array(
     163        $a3 = self::factory()->activity->create( array(
    164164            'recorded_time' => '2005-01-01 12:00'
    165165        ) );
     
    188188        }
    189189
    190         $a1 = $this->factory->activity->create();
    191         $a2 = $this->factory->activity->create( array(
     190        $a1 = self::factory()->activity->create();
     191        $a2 = self::factory()->activity->create( array(
    192192            'recorded_time' => '2001-01-01 12:00'
    193193        ) );
    194         $a3 = $this->factory->activity->create( array(
     194        $a3 = self::factory()->activity->create( array(
    195195            'recorded_time' => '2005-01-01 12:00'
    196196        ) );
     
    221221        }
    222222
    223         $a1 = $this->factory->activity->create();
    224         $a2 = $this->factory->activity->create( array(
     223        $a1 = self::factory()->activity->create();
     224        $a2 = self::factory()->activity->create( array(
    225225            'recorded_time' => '2001-01-01 12:00'
    226226        ) );
    227         $a3 = $this->factory->activity->create( array(
     227        $a3 = self::factory()->activity->create( array(
    228228            'recorded_time' => '2005-01-01 12:00'
    229229        ) );
     
    242242     */
    243243    public function test_get_with_search_terms() {
    244         $a1 = $this->factory->activity->create( array(
     244        $a1 = self::factory()->activity->create( array(
    245245            'content' => 'Boone is a cool guy',
    246246        ) );
    247         $a2 = $this->factory->activity->create( array(
     247        $a2 = self::factory()->activity->create( array(
    248248            'content' => 'No he isn\'t',
    249249        ) );
     
    260260     */
    261261    public function test_get_with_display_comments_threaded() {
    262         $u = $this->factory->user->create();
     262        $u = self::factory()->user->create();
    263263
    264264        $now = time();
    265         $a1 = $this->factory->activity->create( array(
     265        $a1 = self::factory()->activity->create( array(
    266266            'user_id' => $u,
    267267            'content' => 'Life Rules',
    268268            'recorded_time' => date( 'Y-m-d H:i:s', $now ),
    269269        ) );
    270         $a2 = $this->factory->activity->create( array(
     270        $a2 = self::factory()->activity->create( array(
    271271            'user_id' => $u,
    272272            'content' => 'Life Drools',
     
    303303    public function test_get_with_display_comments_stream() {
    304304        $now = time();
    305         $a1 = $this->factory->activity->create( array(
     305        $a1 = self::factory()->activity->create( array(
    306306            'content' => 'Life Rules',
    307307            'recorded_time' => date( 'Y-m-d H:i:s', $now ),
    308308        ) );
    309         $a2 = $this->factory->activity->create( array(
     309        $a2 = self::factory()->activity->create( array(
    310310            'content' => 'Life Drools',
    311311            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
     
    336336    public function test_get_with_display_comments_false() {
    337337        $now = time();
    338         $a1 = $this->factory->activity->create( array(
     338        $a1 = self::factory()->activity->create( array(
    339339            'content' => 'Life Rules',
    340340            'recorded_time' => date( 'Y-m-d H:i:s', $now ),
    341341        ) );
    342         $a2 = $this->factory->activity->create( array(
     342        $a2 = self::factory()->activity->create( array(
    343343            'content' => 'Life Drools',
    344344            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
     
    362362    public function test_get_with_offset() {
    363363        $now = time();
    364         $a1 = $this->factory->activity->create( array(
     364        $a1 = self::factory()->activity->create( array(
    365365            'content' => 'Life Rules',
    366366            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
    367367        ) );
    368         $a2 = $this->factory->activity->create( array(
     368        $a2 = self::factory()->activity->create( array(
    369369            'content' => 'Life Drools',
    370370            'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
    371371        ) );
    372         $a3 = $this->factory->activity->create( array(
     372        $a3 = self::factory()->activity->create( array(
    373373            'content' => 'Life Drools',
    374374            'recorded_time' => date( 'Y-m-d H:i:s', $now - 10 ),
     
    389389    public function test_get_with_since() {
    390390        $now = time();
    391         $a1 = $this->factory->activity->create( array(
     391        $a1 = self::factory()->activity->create( array(
    392392            'content' => 'Life Rules',
    393393            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
    394394        ) );
    395         $a2 = $this->factory->activity->create( array(
     395        $a2 = self::factory()->activity->create( array(
    396396            'content' => 'Life Drools',
    397397            'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
    398398        ) );
    399         $a3 = $this->factory->activity->create( array(
     399        $a3 = self::factory()->activity->create( array(
    400400            'content' => 'Life Drools',
    401401            'recorded_time' => date( 'Y-m-d H:i:s', $now - 10 ),
     
    416416     */
    417417    public function test_get_with_count_total() {
    418         $a1 = $this->factory->activity->create();
    419         $a2 = $this->factory->activity->create();
     418        $a1 = self::factory()->activity->create();
     419        $a2 = self::factory()->activity->create();
    420420
    421421        $activity = BP_Activity_Activity::get( array(
     
    431431     */
    432432    public function test_get_with_count_total_false() {
    433         $a1 = $this->factory->activity->create();
    434         $a2 = $this->factory->activity->create();
     433        $a1 = self::factory()->activity->create();
     434        $a2 = self::factory()->activity->create();
    435435
    436436        $activity = BP_Activity_Activity::get( array(
     
    446446     */
    447447    public function test_get_with_count_total_default_to_false() {
    448         $a1 = $this->factory->activity->create();
    449         $a2 = $this->factory->activity->create();
     448        $a1 = self::factory()->activity->create();
     449        $a2 = self::factory()->activity->create();
    450450
    451451        $activity = BP_Activity_Activity::get();
     
    458458     */
    459459    public function test_get_id_with_item_id() {
    460         $a1 = $this->factory->activity->create( array(
     460        $a1 = self::factory()->activity->create( array(
    461461            'item_id' => 523,
    462462        ) );
    463         $a2 = $this->factory->activity->create( array(
     463        $a2 = self::factory()->activity->create( array(
    464464            'item_id' => 1888,
    465465        ) );
     
    473473     */
    474474    public function test_get_id_with_secondary_item_id() {
    475         $a1 = $this->factory->activity->create( array(
     475        $a1 = self::factory()->activity->create( array(
    476476            'secondary_item_id' => 523,
    477477        ) );
    478         $a2 = $this->factory->activity->create( array(
     478        $a2 = self::factory()->activity->create( array(
    479479            'secondary_content' => 1888,
    480480        ) );
     
    488488     */
    489489    public function test_delete_with_item_id() {
    490         $a1 = $this->factory->activity->create( array(
     490        $a1 = self::factory()->activity->create( array(
    491491            'item_id' => 523,
    492492        ) );
    493         $a2 = $this->factory->activity->create( array(
     493        $a2 = self::factory()->activity->create( array(
    494494            'item_id' => 1888,
    495495        ) );
     
    505505     */
    506506    public function test_delete_with_secondary_item_id() {
    507         $a1 = $this->factory->activity->create( array(
     507        $a1 = self::factory()->activity->create( array(
    508508            'secondary_item_id' => 523,
    509509        ) );
    510         $a2 = $this->factory->activity->create( array(
     510        $a2 = self::factory()->activity->create( array(
    511511            'secondary_item_id' => 1888,
    512512        ) );
     
    527527        $now = time();
    528528
    529         $u1 = $this->factory->user->create();
    530         $u2 = $this->factory->user->create();
    531 
    532         $a1 = $this->factory->activity->create( array(
     529        $u1 = self::factory()->user->create();
     530        $u2 = self::factory()->user->create();
     531
     532        $a1 = self::factory()->activity->create( array(
    533533            'content' => 'Life Rules',
    534534            'recorded_time' => date( 'Y-m-d H:i:s', $now ),
     
    602602    public function test_get_last_updated() {
    603603        $now = time();
    604         $a1 = $this->factory->activity->create( array(
     604        $a1 = self::factory()->activity->create( array(
    605605            'recorded_time' => date( 'Y-m-d H:i:s', $now - 500 ),
    606606        ) );
    607         $a2 = $this->factory->activity->create( array(
     607        $a2 = self::factory()->activity->create( array(
    608608            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
    609609        ) );
    610         $a3 = $this->factory->activity->create( array(
     610        $a3 = self::factory()->activity->create( array(
    611611            'recorded_time' => date( 'Y-m-d H:i:s', $now - 300 ),
    612612        ) );
     
    619619     */
    620620    public function test_get_recorded_components_skip_last_activity_false() {
    621         $a1 = $this->factory->activity->create( array(
     621        $a1 = self::factory()->activity->create( array(
    622622            'component' => 'members',
    623623            'action' => 'last_activity',
    624624        ) );
    625         $a2 = $this->factory->activity->create( array(
     625        $a2 = self::factory()->activity->create( array(
    626626            'component' => 'groups',
    627627            'action' => 'created_group',
    628628        ) );
    629         $a3 = $this->factory->activity->create( array(
     629        $a3 = self::factory()->activity->create( array(
    630630            'component' => 'friends',
    631631            'action' => 'friendship_accepted',
     
    642642     */
    643643    public function test_get_recorded_components_skip_last_activity_true_filter_empty_component() {
    644         $a1 = $this->factory->activity->create( array(
     644        $a1 = self::factory()->activity->create( array(
    645645            'component' => 'members',
    646646            'action' => 'last_activity',
    647647        ) );
    648         $a2 = $this->factory->activity->create( array(
     648        $a2 = self::factory()->activity->create( array(
    649649            'component' => 'groups',
    650650            'action' => 'created_group',
    651651        ) );
    652         $a3 = $this->factory->activity->create( array(
     652        $a3 = self::factory()->activity->create( array(
    653653            'component' => 'friends',
    654654            'action' => 'friendship_accepted',
     
    665665     */
    666666    public function test_get_recorded_components_skip_last_activity_true_members_component_not_empty() {
    667         $a1 = $this->factory->activity->create( array(
     667        $a1 = self::factory()->activity->create( array(
    668668            'component' => 'members',
    669669            'action' => 'last_activity',
    670670        ) );
    671         $a2 = $this->factory->activity->create( array(
     671        $a2 = self::factory()->activity->create( array(
    672672            'component' => 'groups',
    673673            'action' => 'created_group',
    674674        ) );
    675         $a3 = $this->factory->activity->create( array(
     675        $a3 = self::factory()->activity->create( array(
    676676            'component' => 'friends',
    677677            'action' => 'friendship_accepted',
    678678        ) );
    679         $a4 = $this->factory->activity->create( array(
     679        $a4 = self::factory()->activity->create( array(
    680680            'component' => 'members',
    681681            'action' => 'foo',
     
    692692     */
    693693    public function test_get_recorded_components_skip_last_activity_true_la_in_multiple_components() {
    694         $a1 = $this->factory->activity->create( array(
     694        $a1 = self::factory()->activity->create( array(
    695695            'component' => 'members',
    696696            'action' => 'last_activity',
    697697        ) );
    698         $a2 = $this->factory->activity->create( array(
     698        $a2 = self::factory()->activity->create( array(
    699699            'component' => 'groups',
    700700            'action' => 'created_group',
    701701        ) );
    702         $a3 = $this->factory->activity->create( array(
     702        $a3 = self::factory()->activity->create( array(
    703703            'component' => 'friends',
    704704            'action' => 'friendship_accepted',
    705705        ) );
    706         $a4 = $this->factory->activity->create( array(
     706        $a4 = self::factory()->activity->create( array(
    707707            'component' => 'groups',
    708708            'action' => 'last_activity',
     
    726726
    727727        // Create the activity item with a manual activity string
    728         $a = $this->factory->activity->create( array(
     728        $a = self::factory()->activity->create( array(
    729729            'component' => 'foo',
    730730            'type' => 'bar',
     
    744744
    745745        // Create the activity item with a manual activity string
    746         $a = $this->factory->activity->create( array(
     746        $a = self::factory()->activity->create( array(
    747747            'component' => 'foo',
    748748            'type' => 'bar1',
     
    762762
    763763        // Create the activity item with a manual activity string
    764         $a = $this->factory->activity->create( array(
     764        $a = self::factory()->activity->create( array(
    765765            'component' => 'foo',
    766766            'type' => 'bar2',
     
    776776     */
    777777    public function test_nonexistent_activity_should_have_id_0_after_population() {
    778         $a = $this->factory->activity->create();
     778        $a = self::factory()->activity->create();
    779779        bp_activity_delete_by_activity_id( $a );
    780780
Note: See TracChangeset for help on using the changeset viewer.