PHP code example of rosio / wordpress-testing-harness

1. Go to this page and download the library: Download rosio/wordpress-testing-harness library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rosio / wordpress-testing-harness example snippets


	

	trapper = new Rosio\WordPressTestingHarness\Bootstrapper(array(
	    'bootstrap-path' => __FILE__,

	    'db-name' => 'wp_test',
	    'db-user' => 'root',
	    'db-pass' => 'root',
	    'db-host' => 'localhost',
	    'db-prefix' => 'wptests_',
	    'db-charset' => '',
	    'db-collate' => '',
	    'wplang' => '',

	    'wordpress-path' => __DIR__ . '/../wordpress',
	    'domain' => 'wp.localhost',
	    'admin-email' => '[email protected]',
	    'blog-title' => 'Tests',
	    'admin-password' => 'admin',

	    'always-reinstall' => true,

	    'php-binary' => 'php',
	    'testdata-path' => __DIR__ . '/../data',
	));

	// Require in plugin
	

	
	namespace Plugin\SomePlugin;

	use WP_UnitTestCase;
	use \Mockery as m;

	class MainPluginTest extends WP_UnitTestCase
	{
		public function setUp()
		{

		}

		public function tearDown()
		{
			m::close();
		}

		public function testPluginIsCreated()
		{
			$this->assertInstanceOf('Plugin\SomePlugin\MainPlugin', getSomePlugin());
		}
	}