Skip to content

Commit

Permalink
Added: ActionsTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan0sz committed Mar 26, 2024
1 parent 13d9573 commit d0c9202
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 26 deletions.
26 changes: 26 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,30 @@ public function __construct() {

parent::__construct();
}

/**
* Enable the proxy.
*
* @param $settings
*
* @return mixed
*/
public function enableProxy( $settings ) {
$settings[ 'proxy_enabled' ] = 'on';

return $settings;
}

/**
* Set domain_name option.
*
* @param $settings
*
* @return mixed
*/
public function setDomain( $settings ) {
$settings[ 'domain_name' ] = 'test.dev';

return $settings;
}
}
32 changes: 32 additions & 0 deletions tests/integration/ActionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* @package Plausible Analytics Integration Tests - Helpers
*/

namespace Plausible\Analytics\Tests\Integration;

use Plausible\Analytics\Tests\TestCase;
use Plausible\Analytics\WP\Actions;
use Plausible\Analytics\WP\Helpers;

class ActionsTest extends TestCase {
/**
* @see Actions::maybe_register_assets()
* @return void
* @throws \Exception
*/
public function testRegisterAssets() {
$class = new Actions();

add_filter( 'plausible_analytics_settings', [ $this, 'enableProxy' ] );
add_filter( 'plausible_analytics_settings', [ $this, 'setDomain' ] );

$class->maybe_register_assets();

$this->expectOutputContains( Helpers::get_filename( true ) );
$this->expectOutputContains( 'test.dev' );
$this->expectOutputContains( Helpers::get_rest_endpoint() );

wp_print_head_scripts();
}
}
26 changes: 0 additions & 26 deletions tests/integration/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ public function testGetJsUrl() {
$this->assertEquals( 'https://self-hosted-test.org/js/plausible.js', $url );
}

/**
* Enable the proxy.
*
* @param $settings
*
* @return mixed
*/
public function enableProxy( $settings ) {
$settings[ 'proxy_enabled' ] = 'on';

return $settings;
}

/**
* Enable Self Hosted domain.
*
Expand Down Expand Up @@ -205,19 +192,6 @@ public function testGetDomain() {
$this->assertEquals( 'test.dev', $domain );
}

/**
* Set domain_name option.
*
* @param $settings
*
* @return mixed
*/
public function setDomain( $settings ) {
$settings[ 'domain_name' ] = 'test.dev';

return $settings;
}

/**
* @see Helpers::get_data_api_url()
* @return void
Expand Down

0 comments on commit d0c9202

Please sign in to comment.