Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,7 @@ yarn-json-output.json

# Storybook
storybook-static

# PHPUnit cache
.phpunit.result.cache
.phpunit.cache
1 change: 1 addition & 0 deletions apps/editing-toolkit/.wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"themes": [ "../../../themes/varia", "../../../themes/maywood" ],
"port": 4013,
"testsPort": 4005,
"phpVersion": "8.2",
"mappings": {
"wp-content/plugins/editing-toolkit-plugin/vendor": "../../vendor"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function register_patterns() {
foreach ( (array) $block_patterns as $pattern ) {
foreach ( (array) $pattern['categories'] as $slug => $category ) {
// Register categories from first pattern in each category.
if ( ! $pattern_categories[ $slug ] ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP 8 does not allow you to access arrays directly if the index doesn't exist.

if ( ! isset( $pattern_categories[ $slug ] ) ) {
$pattern_categories[ $slug ] = array(
'label' => $category['title'],
'description' => $category['description'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Block_Patterns_From_Api_Test extends TestCase {
/**
* Pre-test setup.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->pattern_mock_object = array(
'ID' => '1',
Expand All @@ -41,8 +41,9 @@ public function setUp() {
'source_url' => 'http;//test',
'modified_date' => 'dd:mm:YY',
'categories' => array(
array(
'title' => 'test-category',
'test_slug' => array(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP 8 noticed these fields were undefined when going through other tests, which probably means the mock data wasn't fully created in the first place.

'title' => 'category title',
'description' => 'category description',
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Block_Patterns_Utils_Test extends TestCase {
/**
* Pre-test setup.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->utils = new Block_Patterns_Utils();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function load_blog_posts_block() {
$disable_block = (
( defined( 'WP_CLI' ) && WP_CLI ) ||
/* phpcs:ignore WordPress.Security.NonceVerification */
( isset( $_GET['action'], $_GET['plugin'] ) && 'activate' === $_GET['action'] && preg_match( $slug_regex, sanitize_text_field( wp_unslash( $_GET['plugin'] ) ) ) ) ||
( isset( $_GET['action'] ) && isset( $_GET['plugin'] ) && 'activate' === $_GET['action'] && preg_match( $slug_regex, sanitize_text_field( wp_unslash( $_GET['plugin'] ) ) ) ) ||
preg_grep( $slug_regex, (array) get_option( 'active_plugins' ) ) ||
preg_grep( $slug_regex, (array) get_site_option( 'active_sitewide_plugins' ) )
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Global_Styles {
* @return \Automattic\Jetpack\Global_Styles\Global_Styles
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct() {
* @return \A8C\FSE\Help_Center
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WPCOM_Help_Center_Test extends WP_UnitTestCase {
/**
* Pre-test setup.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();

$this->help_center = $this->createPartialMock(
Expand Down
12 changes: 6 additions & 6 deletions apps/editing-toolkit/editing-toolkit-plugin/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="phpunit/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<php>
<const name="WP_TESTS_MULTISITE" value="1" />
</php>
<php>
<env name="WORDPRESS_TABLE_PREFIX" value="wptests_"/>
<const name="WP_TESTS_MULTISITE" value="1"/>
</php>
<testsuites>
<testsuite name="default">
<directory suffix="-test.php">./phpunit/</directory>
Expand All @@ -19,9 +22,6 @@
<testsuite name="help-center">
<directory suffix="-test.php">./help-center/test/</directory>
</testsuite>
<testsuite name="tutorials">
<directory suffix="-test.php">./tutorials/test/</directory>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this directory doesn't exist any more

</testsuite>
<testsuite name="wpcom-global-styles">
<directory suffix="-test.php">./wpcom-global-styles/test/</directory>
</testsuite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
* PHPUnit bootstrap file
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/phpunit/bootstrap.php
*
* @package FullSiteEditing
*/

// Require composer dependencies.
require_once dirname( __DIR__ ) . '/vendor/autoload.php';

$_tests_dir = getenv( 'WP_PHPUNIT__DIR' );
$_tests_dir = getenv( 'WP_TESTS_DIR' );

if ( ! $_tests_dir ) {
throw new Exception( 'Could not find the WordPress test lib.' );
Expand Down Expand Up @@ -59,9 +57,6 @@ function fail_if_died( $message ) {
// Use existing behavior for wp_die during actual test execution.
remove_filter( 'wp_die_handler', 'fail_if_died' );

// Don't let deprecation notices cause tests to fail.
PHPUnit\Framework\Error\Deprecated::$enabled = false;

// Global function stubs that might be needed by all tests.

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public function test_carousel_assets_enqueued() {
ob_start();
newspack_blocks_render_block_carousel(
array(
'postsToShow' => 3,
'postsToShow' => 3,
'slidesPerView' => 2,
)
);
ob_end_flush();
Expand All @@ -44,6 +45,8 @@ public function test_blog_posts_assets_enqueued() {
'showImage' => false,
'specificMode' => 0,
'textColor' => '',
'slidesPerView' => false,
'textAlign' => false,
)
);
ob_end_flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct() {
* @return \A8C\FSE\Tags_Education
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct() {
* @return \A8C\FSE\Whats_New
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct() {
* @return \A8C\FSE\WPCOM_Block_Description_Links
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct() {
* @return \A8C\FSE\WPCOM_Block_Editor_Nav_Sidebar
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct() {
* @return \A8C\FSE\WPCOM_Block_Editor_NUX
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct() {
* @return \A8C\FSE\WPCOM_Documentation_Links
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct() {
* @return \A8C\FSE\WPCOM_Domain_Upsell_Callout
*/
public static function init() {
if ( is_null( self::$instance ) ) {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function test_wpcom_block_global_styles_frontend() {
// Check that the custom color is blocked when Global Styles are limited.
add_filter( 'wpcom_force_limit_global_styles', '__return_true' );
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $user_data, 'custom' ) );
$this->assertEmpty( $theme_json->get_data()['styles']['color']['background'] );
$this->assertFalse( isset( $theme_json->get_data()['styles'] ) );
remove_filter( 'wpcom_force_limit_global_styles', '__return_true' );
}
}
4 changes: 2 additions & 2 deletions apps/editing-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"sync:newspack-blocks": "./bin/sync-newspack-blocks.sh",
"test:js": "yarn run -T test-apps apps/editing-toolkit",
"test:js:watch": "yarn test:js --watch",
"test:php": "npx wp-env run phpunit 'phpunit -c /var/www/html/wp-content/plugins/editing-toolkit-plugin/phpunit.xml.dist'",
"test:php": "wp-env run --env-cwd='wp-content/plugins/editing-toolkit-plugin' tests-wordpress vendor/bin/phpunit -c phpunit.xml.dist",
"wpcom-sync": "./bin/wpcom-watch-and-sync.sh"
},
"dependencies": {
Expand Down Expand Up @@ -82,7 +82,7 @@
"@wordpress/dom-ready": "^3.23.0",
"@wordpress/edit-post": "^7.0.0",
"@wordpress/element": "^5.0.0",
"@wordpress/env": "^4.7.0",
"@wordpress/env": "^8.3.0",
"@wordpress/escape-html": "^2.23.0",
"@wordpress/hooks": "^3.23.0",
"@wordpress/html-entities": "^3.23.0",
Expand Down
14 changes: 14 additions & 0 deletions apps/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
<ini name="error_reporting" value="E_ALL &#38; ~E_DEPRECATED" />

<rule ref="Jetpack"/>

<rule ref="Jetpack.Functions.I18n">
<properties>
<property name="text_domain" value="full-site-editing" />
</properties>
</rule>

<rule ref="WordPress.Utils.I18nTextDomainFixer">
<properties>
<property name="old_text_domain" type="array">
Expand Down Expand Up @@ -40,6 +47,13 @@
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable" >
<exclude-pattern>editing-toolkit/editing-toolkit-plugin/newspack-blocks/synced-newspack-blocks</exclude-pattern>
</rule>
<rule ref="MediaWiki.Usage.ForbiddenFunctions.isset">
<exclude-pattern>editing-toolkit/editing-toolkit-plugin/newspack-blocks/synced-newspack-blocks</exclude-pattern>
</rule>

<rule ref="Squiz.Commenting.FileComment.MissingPackageTag">
<severity>0</severity>
</rule>

<!-- Ignore assset files and undeployed files. -->
<exclude-pattern>*.asset.php</exclude-pattern>
Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{
"name": "automattic/wp-calypso",
"require": {
"wp-phpunit/wp-phpunit": "^5.4",
"automattic/jetpack-codesniffer": "^2.1"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
},
"platform": {
"php": "8.2"
}
},
"require-dev": {
"automattic/jetpack-codesniffer": "^2.1",
"phpunit/phpunit": "^9",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wp-env update basically meant that you should manage your own phpunit version instead of bundling it, so we do that here.

"yoast/phpunit-polyfills": "^1.0",
"phpcsstandards/phpcsextra": "^1.0"
}
}
Loading