Skip to content

Commit

Permalink
Merge pull request #192 from plausible/automated_testing
Browse files Browse the repository at this point in the history
Automated testing
  • Loading branch information
Dan0sz authored Mar 20, 2024
2 parents ed826db + ae43f0b commit aa011b6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unit tests
/tmp
/tests/bin/tmp
.phpunit.cache

# Numerous always-ignore extensions
.diff
Expand Down
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 aa011b6

Please sign in to comment.