-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from luislard/composer_plugin_api_v2_compat
Add support for composer plugin api 2 , Drop support PHP 7 and composer version 1
- Loading branch information
Showing
9 changed files
with
252 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: PHP Unit Tests | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**workflows/php-unit-tests.yml' | ||
- '**.php' | ||
- '**phpunit.xml.dist' | ||
- '**composer.json' | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
if: ${{ !contains(github.event.head_commit.message, 'skip unit') }} | ||
|
||
env: | ||
USE_COVERAGE: 'no' | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-versions: [ '8.0', '8.1', '8.2' ] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
ini-values: zend.assertions=1, error_reporting=E_ALL, display_errors=On | ||
coverage: ${{ env.USE_COVERAGE == 'yes' && 'xdebug' || 'none' }} | ||
|
||
- name: Install Composer dependencies | ||
uses: ramsey/composer-install@v2 | ||
|
||
- name: Run unit tests | ||
run: composer tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
composer.phar | ||
/vendor/ | ||
composer.lock | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,39 @@ | ||
{ | ||
"name": "wecodemore/wp-downloader", | ||
"description": "A Composer plugin that downloads WordPress releases zip from official repo.", | ||
"type": "composer-plugin", | ||
"license": "MIT", | ||
"authors": [ | ||
"name": "wecodemore/wp-downloader", | ||
"description": "A Composer plugin that downloads WordPress releases zip from official repo.", | ||
"type": "composer-plugin", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Giuseppe Mazzapica", | ||
"name": "Giuseppe Mazzapica", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "stable", | ||
"require": { | ||
"php": ">=5.4", | ||
"composer-plugin-api": "^1.1" | ||
"require": { | ||
"php": ">=8.0", | ||
"composer-plugin-api": "^2.0" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"src/" | ||
] | ||
"autoload": { | ||
"psr-4": { | ||
"WCM\\WpDownloader\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"WCM\\WpDownloader\\Tests\\Unit\\": "tests/Unit/" | ||
} | ||
}, | ||
"extra": { | ||
"extra": { | ||
"class": "WCM\\WpDownloader\\WpDownloader" | ||
}, | ||
"require-dev": { | ||
"brain/monkey": "^2.6", | ||
"phpunit/phpunit": "^9.6", | ||
"composer/composer": "^2.0" | ||
}, | ||
"scripts": { | ||
"tests": "@php ./vendor/phpunit/phpunit/phpunit --coverage-text", | ||
"tests:no-cov": "@php ./vendor/phpunit/phpunit/phpunit --no-coverage" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
bootstrap="tests/bootstrap.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false" | ||
stopOnError="false" | ||
verbose="true"> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory suffix="Test.php">tests/Unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of @package Mercury\Blocks. | ||
* | ||
* (c) Inpsyde GmbH | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WCM\WpDownloader\Tests\Unit; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; | ||
use Brain\Monkey; | ||
abstract class AbstractTestCase extends TestCase | ||
{ | ||
use MockeryPHPUnitIntegration; | ||
|
||
/** | ||
* Sets up the environment. | ||
* | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
// Monkey\setUp(); | ||
} | ||
|
||
/** | ||
* Tears down the environment. | ||
* | ||
* @return void | ||
*/ | ||
protected function tearDown(): void | ||
{ | ||
// Monkey\tearDown(); | ||
parent::tearDown(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WCM\WpDownloader\Tests\Unit; | ||
|
||
use Composer\Composer; | ||
use Composer\IO\IOInterface; | ||
use Composer\Util\Filesystem; | ||
use Composer\Util\RemoteFilesystem; | ||
use WCM\WpDownloader\WpDownloader; | ||
|
||
class WpDownloaderTest extends AbstractTestCase | ||
{ | ||
public function testCanInstantiateClass() | ||
{ | ||
$instance = new WpDownloader(); | ||
$this->assertInstanceOf(WpDownloader::class, $instance); | ||
} | ||
|
||
public function testActivate() | ||
{ | ||
$mock = \Mockery::mock(WpDownloader::class)->shouldAllowMockingProtectedMethods()->makePartial(); | ||
$composerMock = \Mockery::mock(Composer::class); | ||
$ioMock = \Mockery::mock(IOInterface::class); | ||
$filesystemMock = \Mockery::mock(Filesystem::class); | ||
$remoteFsMock = \Mockery::mock(RemoteFilesystem::class); | ||
$mock->shouldReceive('prepareFilesystem')->once()->andReturn($filesystemMock); | ||
$mock->shouldReceive('prepareRemoteSystem')->withArgs([ | ||
$composerMock, | ||
$ioMock | ||
])->once()->andReturn($remoteFsMock); | ||
$mock->shouldReceive('prepareConfig')->withArgs([ | ||
$composerMock, | ||
])->once(); | ||
$mock->activate($composerMock, $ioMock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
|
||
declare(strict_types=1); | ||
|
||
//phpcs:disable PSR1.Files.SideEffects | ||
|
||
$libraryPath = dirname(__DIR__, 1); | ||
$vendorPath = "{$libraryPath}/vendor"; | ||
if (!realpath($vendorPath)) { | ||
die('Please install via Composer before running tests.'); | ||
} | ||
|
||
putenv('LIBRARY_PATH=' . $libraryPath); | ||
|
||
if (!defined('PHPUNIT_COMPOSER_INSTALL')) { | ||
define('PHPUNIT_COMPOSER_INSTALL', "{$vendorPath}/autoload.php"); | ||
} | ||
|
||
|
||
require_once "{$vendorPath}/antecedent/patchwork/Patchwork.php"; | ||
require_once "{$vendorPath}/autoload.php"; | ||
|
||
unset($libraryPath, $vendorPath); | ||
|
||
//phpcs:enable |