[wp-hackers] Running the WordPress test suite with PHPUnit
David Morris
dvmorris at gmail.com
Wed Jun 23 15:06:06 UTC 2010
Dion, I tried the $GLOBALS suggestion in my bootstrap and my wp-config file,
and neither seemed to work. I still get the same error.
Peter, I will look into switching out the result printer in the wp-test.php
file to the junit one.
Thanks for your help,
Dave
On Wed, Jun 23, 2010 at 2:43 AM, Dion Hulse (dd32) <wordpress at dd32.id.au>wrote:
> I have a feeling that running the test suite like this, is resulting in
> WordPress being included within a function..
>
> The WordPress files expect that they're being included into global scope,
> As a result, you'll get errors like that if you run it in a local scope..
>
> I've seen some people recomend adding somethign such this to your
> wp-config.php file to simulate it being included in global scope:
>
> foreach ( $GLOBALS as $key => $var ) $$key = &$var;
>
>
>
>
> On Wed, 23 Jun 2010 16:15:43 +1000, David Morris <dvmorris at gmail.com>
> wrote:
>
> Has anyone ever gotten the wordpress test suite (
>> svn.automattic.com/wordpress-tests/) to run using PHPUnit from the
>> command
>> line, instead of running "php wp-test.php"?
>>
>> I would like to integrate testing into a continuous integration
>> environment,
>> and I am having trouble translating wp-test.php into a PHPUnit bootstrap
>> file. I would like to run the Wordpress test suite like this:
>>
>> phpunit --bootstrap bootstrap.php --log-junit phpunit.xml
>> wp-testcase/test_actions.php
>>
>> I created a bootstrap.php file that is heavily based on wp-test.php, and I
>> when I run it, I get this error:
>>
>> Fatal error: Call to undefined method stdClass::set_prefix() in
>> C:\wamp\www\wordpress\trunk\src\wp-settings.php on line 286
>>
>> Line 286 of wp-settings.php is this:
>>
>> $prefix = $wpdb->set_prefix($table_prefix); // set up global tables
>>
>> It appears that $wpdb is not being defined properly by this point in the
>> execution of the bootstrap.php file, but when I run "php wp-test.php",
>> which
>> is almost the same execution steps, it works. It leads me to believe that
>> there is some issue with the way PHPUnit bootstrap files handle all of
>> WordPress' global variables, like $wpdb.
>>
>> Another alternative for me would be to get the "php wp-test.php" to spit
>> out
>> junit style xml files, which would probably be sufficient for me right
>> now.
>> I have been unable to get it to work so far.
>>
>> Anyways, someone on the IRC channel suggested I ask the wp-hackers list.
>> Any
>> help would be greatly appreciated.
>>
>> Thanks,
>>
>> Dave Morris
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>>
>
> -- Dion Hulse / dd32
> Contact:
> e: contact at dd32.id.au
> Web: http://dd32.id.au/
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
--
Dave Morris
http://dave.showviz.net/
http://3dcamphouston.com/
More information about the wp-hackers
mailing list