bobbingwide / wordpress-develop-tests

WordPress develop tests
https://develop.wp-a2z.org/oik-plugins/wordpress-develop-tests/
GNU General Public License v2.0
9 stars 4 forks source link
phpunit-tests wordpress-tests

wordpress-develop-tests

banner

Description

Automated testing of WordPress involves running test cases where manual intervention is not required to run each one.

The purpose of this plugin is twofold:

  1. To allow the WP-a2z dynamic API reference parser to be run against the PHPUnit tests for WordPress. Developers can then view the tests and navigate through them as if they were a real plugin.
  2. To provide the framework functionality for in situ PHPUnit testing of plugins and themes using oik-batch.

Installation

Frequently Asked Questions

What does this plugin do?

Nothing as a plugin. You have to invoke the tests using PHPUnit.

From v4.9.1 we provide a modified version of the phpunit.xml file so that you can attempt to run the WordPress core tests in situ.

Testsuites The primary directory is different. You run the tests from the plugin directory, Instead of being called tests/phpunit/tests the directory is phpunit/tests

We expect PHP 7.2 - 7.4 so there's no need for the exclude sections

<testsuites>
    <!-- Default test suite to run all tests -->
    <testsuite>
        <directory suffix=".php">tests/phpunit/tests</directory>
        <exclude>tests/phpunit/tests/actions/closures.php</exclude>
        <exclude>tests/phpunit/tests/image/editor.php</exclude>
        <exclude>tests/phpunit/tests/image/editorGd.php</exclude>
        <exclude>tests/phpunit/tests/image/editorImagick.php</exclude>
        <exclude>tests/phpunit/tests/oembed/headers.php</exclude>
        <file phpVersion="5.3.0">tests/phpunit/tests/actions/closures.php</file>
        <file phpVersion="5.3.0">tests/phpunit/tests/image/editor.php</file>
        <file phpVersion="5.3.0">tests/phpunit/tests/image/editorGd.php</file>
        <file phpVersion="5.3.0">tests/phpunit/tests/image/editorImagick.php</file>
        <file phpVersion="5.3.0">tests/phpunit/tests/oembed/headers.php</file>
    </testsuite>

Groups - the exclusion list is the same.

<groups>
    <exclude>
        <group>ajax</group>
        <group>ms-files</group>
        <group>ms-required</group>
        <group>external-http</group>
    </exclude>
</groups>

Logging - There's no logging section.

<logging>
    <log type="junit" target="tests/phpunit/build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>

We control it from the command line.

Listeners - There's no listener section

<listeners>
    <listener class="SpeedTrapListener" file="tests/phpunit/includes/speed-trap-listener.php">
        <arguments>
            <array>
                <element key="slowThreshold">
                    <integer>150</integer>
                </element>
            </array>
        </arguments>
    </listener>
</listeners>

Filter - There's no filter section - since we don't do code coverage

<filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">src</directory>
    </whitelist>
</filter>

PHP const - same as for core

What would happen if I did actually run this?

If you activate the plugin then nothing is expected to happen since it doesn't contain any code.

If you run PHPUnit then quite a lot might happen.

And if you had happened to configure your database the same as your live site then you could destroy your live site. But probably not completely!

Can I run the tests from my WordPress site?

I'm sure you could try to do this but I can't see why you'd want to.

How do I run in situ tests for my plugin or theme

Use this plugin in combination with oik-batch

What versions of PHPUnit does this support?

From WordPress 5.9 and above the only version supported is PHPUnit 9.

How does this help me to develop WordPress tests?

In the same way that WP-a2z.org helps you to develop WordPress code this provides you with a dynamic reference of current tests. See develop.wp-a2z.org

Have you actually tried using this?

Yes. oik-plugins are PHPUnit tested using in situ testing. See How to run PHPUnit tests for WordPress plugins in situ

What's the process for managing this repo?

cd \github\wordpress
git clone https://github.com/WordPress/wordpress-develop
cd \svn\wordpress-develop
svn co https://develop.svn.wordpress.org/tags/5.3
cd \svn\wordpress-develop
svn co https://develop.svn.wordpress.org/tags/5.2.3
cd \svn\wordpress-develop
svn co https://develop.svn.wordpress.org/tags/5.0
cd \svn\wordpress-develop
svn co http://develop.svn.wordpress.org/tags/4.9.6
cd \svn\wordpress-develop
svn co http://develop.svn.wordpress.org/tags/4.9

This is the latest process used to build the API reference.

To get WP-A2z to work locally I simply created a symbolic link from the latest SVN version to a plugin directory.

cd wp-content/plugins mklink /J wordpress-develop-tests svn\wordpress-develop\tests

Screenshots

  1. None

Upgrade Notice

5.9.3

Built from https://github.com/WordPress/wordpress-develop ( on 2022/03/20 ) Now requires PHPUnit 9.

5.5

Built from https://github.com/WordPress/wordpress-develop ( on 2020/08/30 )

5.3

Built from https://develop.svn.wordpress.org/tags/5.3 ( on 2019/11/26 )

5.2.3

Now requires PHPUnit 8. Built from https://develop.svn.wordpress.org/tags/5.2.3 ( on 2019/10/09 )

5.0

Built from https://develop.svn.wordpress.org/tags/5.0 ( on 2018/12/07 )

4.9.6

Built from http://develop.svn.wordpress.org/tags/4.9.6 ( on 2018/05/27 )

4.9

Built from http://develop.svn.wordpress.org/tags/4.9 ( on 2017/11/16 )

4.8.1

Built from http://develop.svn.wordpress.org/tags/4.8.3 ( on 2017/08/04 )

4.8

Built from http://develop.svn.wordpress.org/trunk ( on 2017/06/02 )

4.7.3

Built from http://develop.svn.wordpress.org/tags/4.7.3 (on 2017/03/12 )

4.7

Built from http://develop.svn.wordpress.org/branch/4.7 (on 2016/12/07 )

4.6

Built from an SVN extract of trunk taken 2016/08/19

4.5.3

Built from an SVN extract of trunk taken 2016/07/07

4.1-beta1

Built from an update performed on 20 Nov 2014

4.0

Changelog

5.5

5.3

5.2.3

5.0

4.9.6

4.9.1

4.9

4.8.1

4.8

4.7.3

4.7

4.6

4.5.3

4.1-beta1

4.0

Further reading

Extract the latest version of WordPress developer from

https://develop.svn.wordpress.org/trunk/

This will also extract the latest version of the source.

Read about: