Files
wp-plugin-starter-template-…/tests/phpunit/test-core.php
marcusquinn bb6de9a3cb Fix test conflicts between WP_Mock and WordPress unit tests
- Add guards to WP_Mock tests to skip when WP_UnitTestCase is available
- Add guards to WordPress unit tests to skip when WP_UnitTestCase is not available
- Add @group annotations for test separation
2025-11-24 19:41:45 +00:00

69 lines
1.3 KiB
PHP

<?php
/**
* Class CoreTest
*
* @package WPALLSTARS\PluginStarterTemplate
* @group wpmock
*/
// Skip this test file if WP_Mock is not available or WordPress test framework is loaded.
if ( ! class_exists( 'WP_Mock' ) || class_exists( 'WP_UnitTestCase' ) ) {
return;
}
use WPALLSTARS\PluginStarterTemplate\Core;
/**
* Core test case.
*/
class CoreTest extends \WP_Mock\Tools\TestCase {
/**
* Test instance
*
* @var Core
*/
private $core;
/**
* Set up the test environment.
*/
public function setUp(): void
{
parent::setUp();
// Set up mocks
WP_Mock::setUp();
// Create instance of Core class
$this->core = new Core();
}
/**
* Tear down the test environment.
*/
public function tearDown(): void
{
WP_Mock::tearDown();
parent::tearDown();
}
/**
* Test constructor
*/
public function test_constructor() {
// Verify that the constructor initializes hooks
$this->assertInstanceOf(Core::class, $this->core);
}
/**
* Test example method
*/
public function test_filter_content() {
$content = 'Test content';
// Test that filter_content returns the content
$this->assertEquals($content, $this->core->filter_content($content));
}
}