Make WordPress Core


Ignore:
Timestamp:
10/16/2015 09:04:12 PM (9 years ago)
Author:
wonderboymusic
Message:

Unit Tests: one $factory to rule them all, and it shall be static.

Using more than one instance of WP_UnitTest_Factory causes all kinds of craziness, due to out-of-sync internal generator sequences. Since we want to use setUpBeforeClass, we were creating ad hoc instances. To avoid that, we were injecting one static instance via Dependency Injection in wpSetUpBeforeClass. All tests should really use the static instance, so we will remove the instance prop $factory.

Replace $this->factory with self::$factory over 2000 times.
Rewrite all of the tests that were hard-coding dynamic values.

#YOLOFriday

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/commentForm.php

    r32511 r35225  
    66class Tests_Comment_CommentForm extends WP_UnitTestCase {
    77    public function test_default_markup_for_submit_button_and_wrapper() {
    8         $p = $this->factory->post->create();
     8        $p = self::$factory->post->create();
    99
    1010        $args = array(
     
    2222
    2323    public function test_custom_submit_button() {
    24         $p = $this->factory->post->create();
     24        $p = self::$factory->post->create();
    2525
    2626        $args = array(
     
    3838
    3939    public function test_custom_submit_field() {
    40         $p = $this->factory->post->create();
     40        $p = self::$factory->post->create();
    4141
    4242        $args = array(
     
    5858     */
    5959    public function test_submit_button_and_submit_field_should_fall_back_on_defaults_when_filtered_defaults_do_not_contain_the_keys() {
    60         $p = $this->factory->post->create();
     60        $p = self::$factory->post->create();
    6161
    6262        $args = array(
Note: See TracChangeset for help on using the changeset viewer.