Skip to:

Opened 10 years ago

Closed 10 years ago

#5727 closed defect (bug) (fixed)

Unit Tests: unset globals when using friends_add_friend() in setUp()

Reported by: djpaul's profile DJPaul Owned by: djpaul's profile djpaul
Milestone: 2.1 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:


If you run this unit test, it will produce the following warnings:

vagrant@vvv:~/wp-content/plugins/buddypress$ phpunit --filter PaulsDopeTest
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Installing BuddyPress...
Not running ajax tests... To execute these, use --group ajax.
PHPUnit 4.0.14 by Sebastian Bergmann.

Configuration read from /srv/www/wordpress-develop/src/wp-content/plugins/buddypress/phpunit.xml.dist


Time: 8.16 seconds, Memory: 28.75Mb

There was 1 error:

1) BP_Tests_PaulIsCool::test_PaulsDopeTest
Undefined property: stdClass::$show_avatars

Tests: 1, Assertions: 0, Errors: 1.

$bp->avatar->show_avatars isn't set. I am not sure if we are calling this chain of functions too early, or if our BP_UnitTestCase's clean_up_global_scope() approach to resetting globals between tests is too crappy (it kind of is, and most of that's my fault).

Change History (1)

#1 @djpaul
10 years ago

  • Owner set to djpaul
  • Resolution set to fixed
  • Status changed from new to closed

In 8555:

Tests: stop manually resetting $bp->avatar between tests.

This causes tests to fail if those tests call friends_add_friend() inside setUp()
as the $bp->avatar->show_avatars property is unset. Instead, rather than manually
resetting the variable, we'll let bp_core_set_avatar_globals(), via bp_setup_globals
in assertPreConditions(), reset it correctly.

Fixes #5727

Note: See TracTickets for help on using tickets.