diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..0dbfc87 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: [ develop ] + pull_request: + branches: [ develop ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: + - "7.4" + - "8.1" + - "8.2" + - "8.3" + - "8.4" + dependencies: + - "lowest" + - "highest" + + name: Tests with PHP ${{ matrix.php-version }} and ${{ matrix.dependencies }} dependencies + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Validate composer + run: composer validate + + - name: Composer install + uses: "ramsey/composer-install@v1" + with: + dependency-versions: "${{ matrix.dependencies }}" + composer-options: "${{ matrix.composer-options }}" + + - name: Run unit tests suite + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 17e77d9..b1a0ca5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ atlassian* /.idea /.gitattributes +/composer.lock diff --git a/composer.json b/composer.json index 84df861..c6d41cf 100644 --- a/composer.json +++ b/composer.json @@ -2,22 +2,25 @@ "name": "magento/composer", "description": "Magento composer library helps to instantiate Composer application and run composer commands.", "type": "library", - "version": "1.6.0", + "version": "1.10.1", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "php": "~7.3.0||~7.4.0", - "composer/composer": "^1.9", - "symfony/console": "~4.4.0" + "php": "~7.4.0||~8.1.0||~8.2.0||~8.3.0||~8.4.0", + "composer/composer": "^2.1.13", + "symfony/console": "~4.4.0||~5.4.0||~6.4.0" }, "require-dev": { - "phpunit/phpunit": "^9" + "phpunit/phpunit": "^9.5.10 || ^10" }, "autoload": { "psr-4": { "Magento\\Composer\\": "src" } + }, + "archive": { + "exclude": [".github", ".gitignore"] } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 545fc14..dc7c76e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,23 @@ - + bootstrap="vendor/autoload.php"> - + - ./tests/ - - - + + ./ - - ./tests - - - + + + ./tests + + diff --git a/src/MagentoComposerApplication.php b/src/MagentoComposerApplication.php index ef9ce98..4e6defc 100644 --- a/src/MagentoComposerApplication.php +++ b/src/MagentoComposerApplication.php @@ -65,9 +65,9 @@ class MagentoComposerApplication public function __construct( $pathToComposerHome, $pathToComposerJson, - Application $consoleApplication = null, - ConsoleArrayInputFactory $consoleArrayInputFactory = null, - BufferedOutput $consoleOutput = null + ?Application $consoleApplication = null, + ?ConsoleArrayInputFactory $consoleArrayInputFactory = null, + ?BufferedOutput $consoleOutput = null ) { $this->consoleApplication = $consoleApplication ? $consoleApplication : new Application(); $this->consoleArrayInputFactory = $consoleArrayInputFactory ? $consoleArrayInputFactory diff --git a/src/RequireUpdateDryRunCommand.php b/src/RequireUpdateDryRunCommand.php index 53df1e6..f24a15a 100644 --- a/src/RequireUpdateDryRunCommand.php +++ b/src/RequireUpdateDryRunCommand.php @@ -72,7 +72,7 @@ public function run($packages, $workingDir = null) /** * Generates additional explanation for error message * - * @param array $message + * @param string $message * @param array $inputPackages * @return string */ diff --git a/tests/Composer/InfoCommandTest.php b/tests/Composer/InfoCommandTest.php index 63dbb92..3cf7999 100644 --- a/tests/Composer/InfoCommandTest.php +++ b/tests/Composer/InfoCommandTest.php @@ -6,6 +6,7 @@ use Magento\Composer\MagentoComposerApplication; use Magento\Composer\InfoCommand; +use PHPUnit\Framework\MockObject\MockObject; class InfoCommandTest extends \PHPUnit\Framework\TestCase { @@ -22,7 +23,7 @@ class InfoCommandTest extends \PHPUnit\Framework\TestCase 3rdp/c 1.1.0'; /** - * @var MagentoComposerApplication|\PHPUnit_Framework_MockObject_MockObject + * @var MagentoComposerApplication|MockObject */ protected $application; @@ -73,7 +74,7 @@ public function testRunInstalled() * * @return array */ - public function getCommandOutputDataProvider() + public static function getCommandOutputDataProvider() { return [ 'Package not installed' => [ diff --git a/tests/Composer/MagentoComposerApplicationTest.php b/tests/Composer/MagentoComposerApplicationTest.php index 75619c5..742856c 100644 --- a/tests/Composer/MagentoComposerApplicationTest.php +++ b/tests/Composer/MagentoComposerApplicationTest.php @@ -7,6 +7,7 @@ use Composer\Console\Application; use Magento\Composer\MagentoComposerApplication; use Magento\Composer\ConsoleArrayInputFactory; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Console\Output\BufferedOutput; class MagentoComposerApplicationTest extends \PHPUnit\Framework\TestCase @@ -17,23 +18,24 @@ class MagentoComposerApplicationTest extends \PHPUnit\Framework\TestCase protected $application; /** - * @var Application|\PHPUnit_Framework_MockObject_MockObject + * @var Application|MockObject */ protected $composerApplication; /** - * @var ConsoleArrayInputFactory|\PHPUnit_Framework_MockObject_MockObject + * @var ConsoleArrayInputFactory|MockObject */ protected $inputFactory; /** - * @var BufferedOutput|\PHPUnit_Framework_MockObject_MockObject + * @var BufferedOutput|MockObject */ protected $consoleOutput; protected function setUp(): void { - $this->composerApplication = $this->createMock(\Composer\Console\Application::class); + $this->composerApplication = $this->getMockBuilder('Composer\Console\Application') + ->getMock(); $this->inputFactory = $this->createMock(\Magento\Composer\ConsoleArrayInputFactory::class); $this->consoleOutput = $this->createMock(\Symfony\Component\Console\Output\BufferedOutput::class); diff --git a/tests/Composer/RequireUpdateDryRunCommandTest.php b/tests/Composer/RequireUpdateDryRunCommandTest.php index 1c97213..44a5164 100644 --- a/tests/Composer/RequireUpdateDryRunCommandTest.php +++ b/tests/Composer/RequireUpdateDryRunCommandTest.php @@ -7,16 +7,17 @@ use Magento\Composer\MagentoComposerApplication; use Magento\Composer\InfoCommand; use Magento\Composer\RequireUpdateDryRunCommand; +use PHPUnit\Framework\MockObject\MockObject; class RequireUpdateDryRunCommandTest extends \PHPUnit\Framework\TestCase { /** - * @var MagentoComposerApplication|\PHPUnit_Framework_MockObject_MockObject + * @var MagentoComposerApplication|MockObject */ protected $application; /** - * @var InfoCommand|\PHPUnit_Framework_MockObject_MockObject + * @var InfoCommand|MockObject */ protected $infoCommand; @@ -81,7 +82,7 @@ public function testRun() public function testRunException() { - $this->application->expects($this->at(1)) + $this->application->expects($this->once()) ->method('runComposerCommand') ->willThrowException(new \RuntimeException($this->errorMessage)); $this->expectException(\RuntimeException::class);