Skip to content

Commit

Permalink
Added: PluginTest to generate first code coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan0sz committed Mar 20, 2024
1 parent 4308615 commit ae43f0b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Plausible\Analytics\Tests;

use Yoast\WPTestUtils\BrainMonkey\TestCase as YoastTestCase;

class TestCase extends YoastTestCase {
public function __construct() {
/**
* During local unit testing this constant is required.
*/
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', true );
}

/**
* Required for loading assets.
*/
if ( ! defined( 'PLAUSIBLE_TESTS_ROOT' ) ) {
define( 'PLAUSIBLE_TESTS_ROOT', __DIR__ . '/' );
}

parent::__construct();
}
}
31 changes: 31 additions & 0 deletions tests/integration/PluginTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* @package Plausible Analytics Integration Tests - Plugin
*/

namespace Plausible\Analytics\Tests\Integration;

use Plausible\Analytics\Tests\TestCase;
use Plausible\Analytics\WP\Plugin;

class PluginTest extends TestCase {
/**
*
*/
public function testRegister() {
$class = new Plugin();
$class->register();

do_action( 'plugins_loaded' );

$this->assertTrue( class_exists( '\Plausible\Analytics\WP\Setup' ) );

define( 'WP_ADMIN', true );

$class->register();

do_action( 'plugins_loaded' );

$this->assertTrue( class_exists( '\Plausible\Analytics\WP\Admin\SelfHosted' ) );
}
}

0 comments on commit ae43f0b

Please sign in to comment.