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
2 changes: 1 addition & 1 deletion Tests/Integration/init-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
define( 'WPMEDIA_PHPUNIT_ROOT_DIR', dirname( dirname( __DIR__ ) ) );
define( 'WPMEDIA_PHPUNIT_ROOT_TEST_DIR', __DIR__ );

require_once WPMEDIA_PHPUNIT_ROOT_DIR . '/Integration/bootstrap.php';
require_once WPMEDIA_PHPUNIT_ROOT_DIR . '/src/Integration/bootstrap.php';
2 changes: 1 addition & 1 deletion Tests/Unit/init-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
define( 'WPMEDIA_PHPUNIT_ROOT_DIR', dirname( dirname( __DIR__ ) ) );
define( 'WPMEDIA_PHPUNIT_ROOT_TEST_DIR', __DIR__ );

require_once WPMEDIA_PHPUNIT_ROOT_DIR . '/Unit/bootstrap.php';
require_once WPMEDIA_PHPUNIT_ROOT_DIR . '/src/Unit/bootstrap.php';
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
"yoast/wp-test-utils": "^1.0.0"
},
"autoload": {
"psr-4": { "WPMedia\\PHPUnit\\": "." }
"psr-4": { "WPMedia\\PHPUnit\\": "src/" }
},
"autoload-dev": {
"psr-4": { "WPMedia\\PHPUnit\\Tests\\": "Tests/" },
"files": [
"vendor/antecedent/patchwork/Patchwork.php"
]
Expand Down
6 changes: 3 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
(see issue #39). A job that only `uses:` a reusable workflow cannot carry
`continue-on-error`, so the ruleset is scoped instead of failing CI on the ~20 pre-existing
files that have not been touched yet. Add files here as they are brought up to standard
opportunistically, and widen this to the full source tree (the six root files plus
Integration/, Unit/, Fixtures/, Tests/) once the codebase is fully compliant.
opportunistically, and widen this to the full source tree (src/ plus Tests/) once the
codebase is fully compliant.
-->
<file>Integration/HttpRequestTrait.php</file>
<file>src/Integration/HttpRequestTrait.php</file>
<exclude-pattern>vendor/*</exclude-pattern>
<arg value="sp"/>
<arg name="colors"/>
Expand Down
64 changes: 32 additions & 32 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,103 @@ parameters:
rawMessage: Offset 'WPMEDIA_PHPUNIT_ROOT_DIR' does not exist on string.
identifier: offsetAccess.notFound
count: 1
path: BootstrapManager.php
path: src/BootstrapManager.php

-
rawMessage: 'Parameter #1 $root of static method WPMedia\PHPUnit\BootstrapManager::getRootDir() expects string, array|bool given.'
identifier: argument.type
count: 1
path: BootstrapManager.php
path: src/BootstrapManager.php

-
rawMessage: 'Strict comparison using === between false and string will always evaluate to false.'
identifier: identical.alwaysFalse
count: 1
path: BootstrapManager.php
path: src/BootstrapManager.php

-
rawMessage: 'Call to WPMedia\PHPUnit\Integration\AdminTestCase::initBeforeClass() on a separate line has no effect.'
identifier: staticMethod.resultUnused
count: 1
path: Integration/AdminTestCase.php
path: src/Integration/AdminTestCase.php

-
rawMessage: Constant AUTH_COOKIE not found.
identifier: constant.notFound
count: 1
path: Integration/AdminTestCase.php
path: src/Integration/AdminTestCase.php

-
rawMessage: Constant LOGGED_IN_COOKIE not found.
identifier: constant.notFound
count: 1
path: Integration/AdminTestCase.php
path: src/Integration/AdminTestCase.php

-
rawMessage: Constant PASS_COOKIE not found.
identifier: constant.notFound
count: 1
path: Integration/AdminTestCase.php
path: src/Integration/AdminTestCase.php

-
rawMessage: Constant SECURE_AUTH_COOKIE not found.
identifier: constant.notFound
count: 1
path: Integration/AdminTestCase.php
path: src/Integration/AdminTestCase.php

-
rawMessage: Constant USER_COOKIE not found.
identifier: constant.notFound
count: 1
path: Integration/AdminTestCase.php
path: src/Integration/AdminTestCase.php

-
rawMessage: 'Method WPMedia\PHPUnit\Integration\AjaxTestCase::getApiCredential() should return string but returns bool.'
identifier: return.type
count: 1
path: Integration/AjaxTestCase.php
path: src/Integration/AjaxTestCase.php

-
rawMessage: 'Class WP_REST_Request referenced with incorrect case: WP_Rest_Request.'
identifier: class.nameCase
count: 1
path: Integration/RESTTrait.php
path: src/Integration/RESTTrait.php

-
rawMessage: 'Class WP_REST_Request referenced with incorrect case: WP_Rest_Request.'
identifier: class.nameCase
count: 1
path: Integration/RESTVfsTestCase.php
path: src/Integration/RESTVfsTestCase.php

-
rawMessage: Variable $wp_rest_server in PHPDoc tag @var does not exist.
identifier: varTag.variableNotFound
count: 1
path: Integration/RESTVfsTestCase.php
path: src/Integration/RESTVfsTestCase.php

-
rawMessage: 'Class WP_REST_Request referenced with incorrect case: WP_Rest_Request.'
identifier: class.nameCase
count: 1
path: Integration/RESTfulTestCase.php
path: src/Integration/RESTfulTestCase.php

-
rawMessage: 'Method WPMedia\PHPUnit\Integration\RESTfulTestCase::getApiCredential() should return string but returns bool.'
identifier: return.type
count: 1
path: Integration/RESTfulTestCase.php
path: src/Integration/RESTfulTestCase.php

-
rawMessage: Variable $wp_rest_server in PHPDoc tag @var does not exist.
identifier: varTag.variableNotFound
count: 1
path: Integration/RESTfulTestCase.php
path: src/Integration/RESTfulTestCase.php

-
rawMessage: Constant WPMEDIA_PHPUNIT_ROOT_DIR not found.
identifier: constant.notFound
count: 1
path: Integration/bootstrap.php
path: src/Integration/bootstrap.php

-
rawMessage: Constant WPMEDIA_PHPUNIT_ROOT_DIR not found.
Expand Down Expand Up @@ -178,88 +178,88 @@ parameters:
rawMessage: 'Call to function is_array() with array will always evaluate to true.'
identifier: function.alreadyNarrowedType
count: 1
path: Unit/VirtualFilesystemTestCase.php
path: src/Unit/VirtualFilesystemTestCase.php

-
rawMessage: 'Call to function is_null() with string will always evaluate to false.'
identifier: function.impossibleType
count: 2
path: Unit/VirtualFilesystemTestCase.php
path: src/Unit/VirtualFilesystemTestCase.php

-
rawMessage: Constant WPMEDIA_PHPUNIT_ROOT_DIR not found.
identifier: constant.notFound
count: 1
path: Unit/bootstrap.php
path: src/Unit/bootstrap.php

-
rawMessage: Binary operation "+" between non-empty-string and non-empty-string results in an error.
identifier: binaryOp.invalid
count: 3
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'Call to function is_null() with bool|org\bovigo\vfs\vfsStreamFile will always evaluate to false.'
identifier: function.impossibleType
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'Call to function is_string() with string will always evaluate to true.'
identifier: function.alreadyNarrowedType
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: Instanceof between org\bovigo\vfs\vfsStreamDirectory and org\bovigo\vfs\vfsStreamDirectory will always evaluate to true.
identifier: instanceof.alwaysTrue
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'Method WPMedia\PHPUnit\VirtualFilesystemDirect::getDir() should return org\bovigo\vfs\vfsStreamDirectory|null but returns org\bovigo\vfs\vfsStreamContent.'
identifier: return.type
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'Method WPMedia\PHPUnit\VirtualFilesystemDirect::getFile() should return org\bovigo\vfs\vfsStreamFile|null but returns org\bovigo\vfs\vfsStreamContent.'
identifier: return.type
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'Method WPMedia\PHPUnit\VirtualFilesystemDirect::getnumchmodfromh() should return int but returns string.'
identifier: return.type
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'Method WPMedia\PHPUnit\VirtualFilesystemDirect::setFilemtime() should return int but returns null.'
identifier: return.type
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'PHPDoc tag @param references unknown parameter: $filectime'
identifier: parameter.notFound
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'Property WPMedia\PHPUnit\VirtualFilesystemDirect::$filesystem (org\bovigo\vfs\vfsStreamDirectory) does not accept null.'
identifier: assign.propertyType
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: 'Property WPMedia\PHPUnit\VirtualFilesystemDirect::$root (string) does not accept null.'
identifier: assign.propertyType
count: 1
path: VirtualFilesystemDirect.php
path: src/VirtualFilesystemDirect.php

-
rawMessage: Constant WPMEDIA_PHPUNIT_ROOT_DIR not found.
identifier: constant.notFound
count: 3
path: bootstrap-functions.php
path: src/bootstrap-functions.php
18 changes: 9 additions & 9 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ parameters:
level: 5
inferPrivatePropertyTypeFromConstructor: true
paths:
- ArrayTrait.php
- BootstrapManager.php
- TestCaseTrait.php
- VirtualFilesystemDirect.php
- VirtualFilesystemTestTrait.php
- bootstrap-functions.php
- Integration/
- Unit/
- Fixtures/
- src/ArrayTrait.php
- src/BootstrapManager.php
- src/TestCaseTrait.php
- src/VirtualFilesystemDirect.php
- src/VirtualFilesystemTestTrait.php
- src/bootstrap-functions.php
- src/Integration/
- src/Unit/
- src/Fixtures/
- Tests/
scanFiles:
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions BootstrapManager.php → src/BootstrapManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function runTestSuite( $which_testsuite ) {
$_SERVER['argc'] = $GLOBALS['argc'] = count( $GLOBALS['argv'] );

// Find and load PHPUnit.
foreach ( [ dirname( dirname( __DIR__ ) ), __DIR__ . '/vendor' ] as $root ) {
foreach ( [ dirname( dirname( dirname( __DIR__ ) ) ), dirname( __DIR__ ) . '/vendor' ] as $root ) {
if ( is_readable( "{$root}/bin/phpunit" ) ) {
require_once "{$root}/bin/phpunit";
return;
Expand Down Expand Up @@ -179,11 +179,11 @@ protected static function getArg( $key ) {
*/
protected static function getRootDir( $root ) {
if ( false === $root ) {
return dirname( dirname( dirname( __DIR__ ) ) );
return dirname( dirname( dirname( dirname( __DIR__ ) ) ) );
}

if ( '.' === $root['WPMEDIA_PHPUNIT_ROOT_DIR'] ) {
return __DIR__;
return dirname( __DIR__ );
}

return ltrim( $root['WPMEDIA_PHPUNIT_ROOT_DIR'], '/\\' );
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

<testsuites>
<testsuite name="integration">
<directory suffix=".php">../../../../Tests/Integration/</directory>
<exclude>../../../../Tests/Integration/bootstrap.php</exclude>
<directory suffix=".php">../../../../../Tests/Integration/</directory>
<exclude>../../../../../Tests/Integration/bootstrap.php</exclude>
</testsuite>
</testsuites>
<groups>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions Unit/phpunit.xml.dist → src/Unit/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

<testsuites>
<testsuite name="unit">
<directory suffix=".php">../../../../Tests/Unit/</directory>
<exclude>../../../../Tests/Unit/bootstrap.php</exclude>
<directory suffix=".php">../../../../../Tests/Unit/</directory>
<exclude>../../../../../Tests/Unit/bootstrap.php</exclude>
</testsuite>
</testsuites>
<groups>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion wpmedia-phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace WPMedia\PHPUnit;

$_SERVER['argv'][1] = strtolower( $_SERVER['argv'][1] );
if ( ! class_exists( __NAMESPACE__ . '\BootstrapManager' ) ) {
require 'BootstrapManager.php';
require __DIR__ . '/src/BootstrapManager.php';
}
BootstrapManager::setupConstants( $_SERVER['argv'][1] );
BootstrapManager::runTestSuite( $_SERVER['argv'][1] );
Loading