Skip to content

Commit

Permalink
PHP 8 and PHPUnit 9
Browse files Browse the repository at this point in the history
  • Loading branch information
amostajo committed Jan 7, 2023
1 parent 3b54198 commit 2962ef7
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

# Generated files
.tmp
composer.lock
composer.lock
.phpunit.result.cache
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"10quality/wpmvc-addon": "1.0.*"
},
"require-dev": {
"phpunit/phpunit": "4.4.*"
"phpunit/phpunit": "9.*",
"10quality/wpmvc-addon-testsuite": "dev-main"
},
"autoload": {
"files": [
Expand All @@ -19,5 +20,10 @@
"WPMVC\\Addons\\Customizer\\": "addon/"
}
},
"autoload-dev": {
"classmap": [
"tests/framework/"
]
},
"minimum-stability": "dev"
}
}
15 changes: 15 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="true">
<testsuites>
<testsuite name="WPMVC Addon Customizer">
<directory>./tests/cases/</directory>
</testsuite>
</testsuites>
</phpunit>
59 changes: 59 additions & 0 deletions tests/cases/CustomizerAddonTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

use WPMVC\Addons\PHPUnit\TestCase;
use WPMVC\Addons\Customizer\CustomizerAddon;

/**
* Test addon class.
*
* @author 10 Quality <info@10quality.com>
* @package wpmvc-addon-customizer
* @license MIT
* @version 1.0.8
*/
class CustomizerAddonTest extends TestCase
{
/**
* Tear down.
* @since 1.0.8
*/
public function tearDown(): void
{
wpmvc_addon_phpunit_reset();
}
/**
* Test init.
* @since 1.0.8
* @group addon
*/
public function testInit()
{
// Prepare
$bridge = $this->getBridgeMock();
$addon = new CustomizerAddon($bridge);
// Run
$addon->init();
// Assert
$this->assertAddedAction( 'admin_enqueue_scripts' );
$this->assertAddedAction( 'customize_register' );
$this->assertAddedAction( 'wp_head' );
$this->assertAddedFilter( 'wpmvc_addon_customizer_controls' );
$this->assertAddedFilter( 'init' );
}
/**
* Test init.
* @since 1.0.8
* @group addon
*/
public function testCustomizerControls()
{
// Prepare
$bridge = $this->getBridgeMock();
$addon = new CustomizerAddon($bridge);
// Run
$controls = $addon->customizer_controls( [] );
// Assert
$this->assertNotEmpty( $controls );
$this->assertCount( 6, $controls );
}
}
16 changes: 16 additions & 0 deletions tests/framework/WP_Customize_Control.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/**
* Mocked WordPress core class.
*
* @author 10 Quality <info@10quality.com>
* @package wpmvc-addon-customizer
* @license MIT
* @version 1.0.8
*/
class WP_Customize_Control
{
/**
* @todo just mock
*/
}

0 comments on commit 2962ef7

Please sign in to comment.