# disco/1.3.48/vendor/micropackage/requirements/tests/Checker/test-theme.php

Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO, version 1.3.48. 93 lines.

- Page: https://pluginprobe.com/plugins/disco/1.3.48/code/vendor/micropackage/requirements/tests/Checker/test-theme.php
- Raw: https://pluginprobe.com/plugins/disco/1.3.48/raw/vendor/micropackage/requirements/tests/Checker/test-theme.php
- Modified: 2024-09-18T11:17:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/disco/1.3.48/code/vendor/micropackage/requirements/tests/Checker/test-theme.php#L10-L20`.

```php
<?php
/**
 * Class TestTheme
 *
 * @package micropackage/requirements
 */

namespace Micropackage\Requirements\Test\Checker;

use phpmock\Mock;
use phpmock\MockBuilder;
use Micropackage\Requirements\Requirements;
use Micropackage\Requirements\Checker\Theme as TestedChecker;

/**
 * Theme checker test case.
 */
class TestTheme extends \WP_UnitTestCase {

	use \phpmock\phpunit\PHPMock;

	public function setUp() {
		parent::setUp();
		$this->checker = new TestedChecker();
	}

	public function tearDown() {
		parent::tearDown();
		Mock::disableAll();
	}

	public function bad_params() {
		return [
			[ '5.3' ],
			[ 1 ],
			[ true ],
			[ [ 'slug', 'name' ] ],
			[ [ 'slug' => 'slug', 'name' ] ],
			[ [ 'slug', 'name' => 'name' ] ],
		];
	}

	public function test_get_name_should_return_valid_name() {
		$this->assertSame( 'theme', $this->checker->get_name() );
	}

	/**
	 * @dataProvider bad_params
	 * @expectedException Exception
	 */
	public function test_check_should_throw_exception_if_passed_not_array_with_slug_and_name_keys( $param ) {
		$this->checker->check( $param );
	}

	/**
	 * @doesNotPerformAssertions
	 */
	public function test_check_should_accept_array_with_slug_and_name_requirement() {

		$this->checker->check( [
			'slug' => 'test',
			'name' => 'Test',
		] );

	}

	public function test_check_should_pass_if_current_theme_slug_matches_requirement() {

		$this->checker->check( [
			'slug' => 'default',
			'name' => 'Default',
		] );

		$this->assertEmpty( $this->checker->get_errors() );
	}

	public function test_check_should_fail_if_current_theme_slug_doesnt_match_requirement() {

		$this->checker->check( [
			'slug' => 'not-existing',
			'name' => 'Ups',
		] );

		$errors = $this->checker->get_errors();

		$this->assertNotEmpty( $errors );
		$this->assertCount( 1, $errors );
		$this->assertContains( 'Ups', $errors[0] );

	}

}

```
