Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : Component_Tests.php
<?php
/**
 * WP_Rig\WP_Rig\Tests\Unit\Base_Support\Component_Tests class
 *
 * @package wp_rig
 */

namespace WP_Rig\WP_Rig\Tests\Unit\Base_Support;

use WP_Rig\WP_Rig\Tests\Framework\Unit_Test_Case;
use Brain\Monkey\Functions;
use Mockery;
use WP_Rig\WP_Rig\Base_Support\Component;

/**
 * Class unit-testing the accessibility component.
 *
 * @group hooks
 */
class Component_Tests extends Unit_Test_Case {

	/**
	 * The accessibility component instance.
	 *
	 * @var Component
	 */
	private $component;

	/**
	 * Sets up the environment before each test.
	 */
	protected function setUp() {
		parent::setUp();

		$this->component = new Component();
	}

	/**
	 * Tests that the slug of the component is correct.
	 *
	 * @covers Component::get_slug()
	 */
	public function test_get_slug() {
		$this->assertSame( 'base_support', $this->component->get_slug() );
	}

	/**
	 * Tests that the component adds hooks correctly.
	 *
	 * @covers Component::initialize()
	 */
	public function test_initialize() {
		$this->component->initialize();

		$this->assertNotEquals( false, has_action( 'after_setup_theme', array( $this->component, 'action_essential_theme_support' ) ) );
		$this->assertNotEquals( false, has_action( 'wp_head', array( $this->component, 'action_add_pingback_header' ) ) );
		$this->assertNotEquals( false, has_filter( 'body_class', array( $this->component, 'filter_body_classes_add_hfeed' ) ) );
		$this->assertNotEquals( false, has_filter( 'embed_defaults', array( $this->component, 'filter_embed_dimensions' ) ) );
		$this->assertNotEquals( false, has_filter( 'theme_scandir_exclusions', array( $this->component, 'filter_scandir_exclusions_for_optional_templates' ) ) );
		$this->assertNotEquals( false, has_filter( 'script_loader_tag', array( $this->component, 'filter_script_loader_tag' ) ) );
	}

	/**
	 * Tests that the correct template tags are exposed.
	 *
	 * @covers Component::template_tags()
	 */
	public function test_template_tags() {
		$tags = $this->component->template_tags();

		$this->assertEqualSetsWithIndex(
			array(
				'get_version'       => array( $this->component, 'get_version' ),
				'get_asset_version' => array( $this->component, 'get_asset_version' ),
			),
			$tags
		);
	}

	/**
	 * Tests that essential theme support is added.
	 *
	 * @covers Component::action_essential_theme_support()
	 */
	public function test_action_essential_theme_support() {
		$features = array();

		Functions\when( 'add_theme_support' )->alias(
			function( $feature, ...$args ) use ( &$features ) {
				$features[ $feature ] = $args;
			}
		);

		$this->component->action_essential_theme_support();

		$this->assertEqualSets(
			array(
				'automatic-feed-links',
				'title-tag',
				'html5',
				'customize-selective-refresh-widgets',
				'responsive-embeds',
			),
			array_keys( $features )
		);
	}
}
© 2026 GrazzMean-Shell