Skip to content

Commit 0f07496

Browse files
committed
PHP 8 and PHPUnit 9
1 parent cd58faa commit 0f07496

File tree

4 files changed

+126
-3
lines changed

4 files changed

+126
-3
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
# Generated files
77
.tmp
8-
composer.lock
8+
composer.lock
9+
.phpunit.result.cache

Diff for: composer.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@
1313
"WPMVC\\Addons\\Status\\": "addon/"
1414
}
1515
},
16-
"minimum-stability": "dev"
17-
}
16+
"minimum-stability": "dev",
17+
"require-dev": {
18+
"10quality/wpmvc-addon-testsuite": "dev-main",
19+
"phpunit/phpunit": "9.*"
20+
}
21+
}

Diff for: phpunit.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
stopOnFailure="true">
10+
<testsuites>
11+
<testsuite name="WPMVC Addon Status">
12+
<directory>./tests/cases/</directory>
13+
</testsuite>
14+
</testsuites>
15+
</phpunit>

Diff for: tests/cases/StatusAddonTest.php

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
use WPMVC\Addons\PHPUnit\TestCase;
4+
use WPMVC\Addons\Status\StatusAddon;
5+
6+
/**
7+
* Test addon class.
8+
*
9+
* @author 10 Quality <[email protected]>
10+
* @package wpmvc-addon-customizer
11+
* @license MIT
12+
* @version 1.0.2
13+
*/
14+
class StatusAddonTest extends TestCase
15+
{
16+
/**
17+
* Tear down.
18+
* @since 1.0.2
19+
*/
20+
public function tearDown(): void
21+
{
22+
wpmvc_addon_phpunit_reset();
23+
}
24+
/**
25+
* Test init.
26+
* @since 1.0.2
27+
* @group addon
28+
*/
29+
public function testInit()
30+
{
31+
// Prepare
32+
$bridge = $this->getBridgeMock();
33+
$addon = new StatusAddon( $bridge );
34+
// Run
35+
$addon->on_admin();
36+
// Assertc
37+
$this->assertAddedAction( 'admin_menu' );
38+
}
39+
/**
40+
* Test init.
41+
* @since 1.0.2
42+
* @group addon
43+
*/
44+
public function testRenderPlugins()
45+
{
46+
// Prepare
47+
$bridge = $this->getBridgeMock();
48+
$addon = new StatusAddon( $bridge );
49+
// Run
50+
ob_start();
51+
$addon->render_plugins();
52+
$render = ob_get_clean();
53+
// Assertc
54+
$this->assertNotEmpty( $render );
55+
$this->assertMatchesRegularExpression( '/class="box-wrapper"/i', $render );
56+
$this->assertDidAction( 'wpmvc_addon_status_header' );
57+
$this->assertDidAction( 'wpmvc_addon_status_footer' );
58+
$this->assertAppliedFilters( 'wpmvc_addon_status_tab' );
59+
}
60+
/**
61+
* Test init.
62+
* @since 1.0.2
63+
* @group addon
64+
*/
65+
public function testRenderThemes()
66+
{
67+
// Prepare
68+
$bridge = $this->getBridgeMock();
69+
$addon = new StatusAddon( $bridge );
70+
// Run
71+
ob_start();
72+
$addon->render_themes();
73+
$render = ob_get_clean();
74+
// Assertc
75+
$this->assertNotEmpty( $render );
76+
$this->assertMatchesRegularExpression( '/class="box-wrapper"/i', $render );
77+
$this->assertDidAction( 'wpmvc_addon_status_header' );
78+
$this->assertDidAction( 'wpmvc_addon_status_footer' );
79+
$this->assertAppliedFilters( 'wpmvc_addon_status_tab' );
80+
}
81+
/**
82+
* Test init.
83+
* @since 1.0.2
84+
* @group addon
85+
*/
86+
public function testRenderCache()
87+
{
88+
// Prepare
89+
$bridge = $this->getBridgeMock();
90+
$addon = new StatusAddon( $bridge );
91+
$_GET['tab'] = 'cache';
92+
// Run
93+
ob_start();
94+
$addon->render_plugins();
95+
$render = ob_get_clean();
96+
// Assertc
97+
$this->assertNotEmpty( $render );
98+
$this->assertMatchesRegularExpression( '/class="box-wrapper"/i', $render );
99+
$this->assertMatchesRegularExpression( '/Flush/i', $render );
100+
$this->assertDidAction( 'wpmvc_addon_status_header' );
101+
$this->assertDidAction( 'wpmvc_addon_status_footer' );
102+
}
103+
}

0 commit comments

Comments
 (0)