PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.3.53
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.3.53
1.4.17 1.4.16 1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 All 180 releases
disco / vendor / micropackage / requirements / tests / Checker / test-theme.php

test-theme.php in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.3.53, at vendor/micropackage/requirements/tests/Checker/test-theme.php

93 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class TestTheme
4 *
5 * @package micropackage/requirements
6 */
7
8 namespace Micropackage\Requirements\Test\Checker;
9
10 use phpmock\Mock;
11 use phpmock\MockBuilder;
12 use Micropackage\Requirements\Requirements;
13 use Micropackage\Requirements\Checker\Theme as TestedChecker;
14
15 /**
16 * Theme checker test case.
17 */
18 class TestTheme extends \WP_UnitTestCase {
19
20 use \phpmock\phpunit\PHPMock;
21
22 public function setUp() {
23 parent::setUp();
24 $this->checker = new TestedChecker();
25 }
26
27 public function tearDown() {
28 parent::tearDown();
29 Mock::disableAll();
30 }
31
32 public function bad_params() {
33 return [
34 [ '5.3' ],
35 [ 1 ],
36 [ true ],
37 [ [ 'slug', 'name' ] ],
38 [ [ 'slug' => 'slug', 'name' ] ],
39 [ [ 'slug', 'name' => 'name' ] ],
40 ];
41 }
42
43 public function test_get_name_should_return_valid_name() {
44 $this->assertSame( 'theme', $this->checker->get_name() );
45 }
46
47 /**
48 * @dataProvider bad_params
49 * @expectedException Exception
50 */
51 public function test_check_should_throw_exception_if_passed_not_array_with_slug_and_name_keys( $param ) {
52 $this->checker->check( $param );
53 }
54
55 /**
56 * @doesNotPerformAssertions
57 */
58 public function test_check_should_accept_array_with_slug_and_name_requirement() {
59
60 $this->checker->check( [
61 'slug' => 'test',
62 'name' => 'Test',
63 ] );
64
65 }
66
67 public function test_check_should_pass_if_current_theme_slug_matches_requirement() {
68
69 $this->checker->check( [
70 'slug' => 'default',
71 'name' => 'Default',
72 ] );
73
74 $this->assertEmpty( $this->checker->get_errors() );
75 }
76
77 public function test_check_should_fail_if_current_theme_slug_doesnt_match_requirement() {
78
79 $this->checker->check( [
80 'slug' => 'not-existing',
81 'name' => 'Ups',
82 ] );
83
84 $errors = $this->checker->get_errors();
85
86 $this->assertNotEmpty( $errors );
87 $this->assertCount( 1, $errors );
88 $this->assertContains( 'Ups', $errors[0] );
89
90 }
91
92 }
93