diff --git a/.gitignore b/.gitignore index 8f244ce8..730fd0d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ +**/.DS_Store /.idea +/.phpunit.result.cache /composer.phar /composer.lock /vendor +/tests/FullStackTest/logs diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1055ffad..00000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: php -php: - - 5.6 - - 5.5 - - 5.4 - - 5.3 - - hhvm - -matrix: - allow_failures: - - php: 5.6 - - php: hhvm - -before_script: - - curl -sS https://getcomposer.org/installer | php - - chmod +x ./composer.phar - - ./composer.phar --version - - ./composer.phar install --dev - -script: - - ./vendor/bin/phpunit - -notifications: - email: - recipients: - - flyingmana@googlemail.com - - vinai@netzarbeiter.com - on_success: never - on_failure: always - irc: - channels: - - "irc.freenode.org#magento-composer" - on_success: change # default: always - on_failure: always # default: always diff --git a/CodeSniffer.conf b/CodeSniffer.conf deleted file mode 100644 index cd0aa8d5..00000000 --- a/CodeSniffer.conf +++ /dev/null @@ -1,10 +0,0 @@ - 'FireGento', - 'report_format' => 'summary', - 'show_warnings' => '0', - 'show_progress' => '1', - 'report_width' => '120', - 'installed_paths' => __DIR__.'/vendor/firegento/', -); - diff --git a/README.md b/README.md index 84525585..be3c4480 100644 --- a/README.md +++ b/README.md @@ -1,372 +1,206 @@ -# Magento Composer Installer [![Build Status](https://travis-ci.org/magento-hackathon/magento-composer-installer.png)](https://travis-ci.org/magento-hackathon/magento-composer-installer) +# Magento Composer Installer -The purpose of this project is to -enable [composer](https://github.com/composer/composer) to install Magento modules, -and automatically integrate them into a Magento installation. +This is a fork of the [Magento Composer Installer](https://github.com/magento-hackathon/magento-composer-installer) repo that provides support for Magento 2 components (modules, themes, language packages, libraries and components). -We strongly recommend you to also read the general composer documentations on [getcomposer.org](http://getcomposer.org) - -Also you should see [Using composer correctly (confoo) by Igor Wiedler](https://speakerdeck.com/igorw/using-composer-correctly-confoo) - - -## Project Details - -This project only covers the custom installer for composer. If you have problems with outdated versions, -need to install magento connect modules or similar, you need to look for [packages.firegento.com](http://packages.firegento.com/) - - -### support contacts - -If you have problems please have patience, as normal support is done during free time. -If you are willing to pay to get your problem fixed, communicate this from the start to get faster responses. - - -If you need consulting, support, training or help regarding Magento and Composer, -you have the chance to hire one of the following people/companies. - -* Daniel Fahlke aka Flyingmana (Maintainer): flyingmana@googlemail.com [@Flyingmana](https://twitter.com/Flyingmana) -* brandung - Magento Team: magento-team@brandung.de (http://brandung.de) -* Your Name here -* Your Name here -* Your Company Name here -* Your Company Name here - -other support contacts - -* irc: freenode the channels #magento-composer #magento-reddit and for german speaking people #magento-de -* twitter: [@firegento](https://twitter.com/firegento) - -## Known issues - -### When upgrading from 1.x to 2.x - -The update from 1.x to 2.x has to be done with no plugins as otherwise a fatal error will be triggered (which does not hurt, just run the update again and it runs through). - -- Error message: `Fatal error: Call to undefined method MagentoHackathon\Composer\Magento\Installer::setDeployManager()` - -To prevent this error, upgrade only *magento-composer-installer* first: - -```composer update --no-plugins --no-dev "magento-hackathon/magento-composer-installer"``` - -Fallback Solutions: - -1. execute `composer install` two times. -2. remove the `vendor` directory and `composer.lock` and do a fresh install. - -### Timeouts and slow downloading. +## Usage -Mostly caused by outtages of Github, Repositories or the Internet. This is a common problem with having all -packges remote. +In the component's `composer.json`, specify: -For all of this Issues you can make use of the commercial [Toran Proxy](https://toranproxy.com/). -It also allows hosting of private packages and speeds up the whole downloading process. +* `type`, type of Magento 2 component. +* `extra/map`, list of files to move and their paths relative to the Magento root directory. +* `extra/chmod`, list of permissions that should be set for files. -Another alternative is to look into [Satis](https://github.com/composer/satis), bare git mirrors and repository aliasing. + **Note**: + * `extra/map` is required only if your component needs to be moved to a location other than `/vendor`. Otherwise, omit this section. + * `extra/chmod` is required only if you need to set specific permissions for files. -## Usage -See below for a [generic instruction on how to install composer](#installation-of-composer) if you aren't familiar with it. +## Supported Components +The following list explains the use of `type` in `composer.json`. -### Install the Magento-Core and initialize your project +### Magento Module +`"type": "magento2-module"` -If you want to setup your project from the scratch, you can require the magento/core package from [the public Magento module repository](http://packages.firegento.com) and have your magento-root-dir set up automatically. It is essential that the Magento core packages type is defined as "magento-core" (as given on magento/core). +Installation location: Default vendor directory or as defined in `extra/map` +Example: ```json { + "name": "magento/module-core", + "description": "N/A", "require": { - "magento/core": "1.9.0.1" + ... }, - "repositories": [ - { - "type": "composer", - "url": "http://packages.firegento.com" - } - ], - "extra":{ - "magento-root-dir": "htdocs/" + "type": "magento2-module", + "extra": { + "map": [ + [ + "*", + "Magento/Core" + ] + ] } } ``` +Final location is `/app/code/Magento/Core` +### Magento Theme +`"type": "magento2-theme"` -### Install a module in your project - -If you want to use [the public Magento module repository](http://packages.firegento.com), -set up your root ```composer.json``` in your project like this: +Installation location: `app/design` +Example: ```json { + "name": "magento/theme-frontend-luma", + "description": "N/A", "require": { - "your-vendor-name/module-name": "*", - "magento-hackathon/magento-composer-installer": "*" + ... }, - "repositories": [ - { - "type": "composer", - "url": "http://packages.firegento.com" - } - ], - "extra":{ - "magento-root-dir": "htdocs/" + "type": "magento2-theme", + "extra": { + "map": [ + [ + "*", + "frontend/Magento/luma" + ] + ] } } ``` -If you want to use a github/git/svn/etc repository, -set up your root ```composer.json``` in your project like this: +Final location is `/app/design/frontend/Magento/luma` -```json -{ - "require": { - "magento-hackathon/magento-composer-installer":"*", - "the-vendor-name/the-module-name": "*" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/magento-hackathon/magento-composer-installer" - }, - { - "type": "vcs", - "url": "the/github/or/git/or/svn/etc/repository/uri-of-the-module" - } - ], - "extra":{ - "magento-root-dir": "htdocs/" - } -} -``` -Notes: - -1. More information about VCS repositories can be found - at [getcomposer.org](http://getcomposer.org/doc/05-repositories.md#vcs) - - - -### Change the Vendor/Name of your Module - -sometimes it will happen, that you change the name or the vendor of a package. -For example you developed a module in your own namespace and later moved it to an organization, or you moved it -from one to another organization. -In this cases you should change your ```composer.json``` a bit to make it for users easier. -Look for the ```replace``` statement +### Magento Language Package +`"type": "magento2-language"` +Installation location: `app/i18n` +Example: ```json { - "name": "your-new-vendor-name/module-name", - "type": "magento-module", - "license":"OSL-3.0", - "description":"A short one line description of your module", - "authors":[ - { - "name":"Author Name", - "email":"author@example.com" - } - ], - "replace": { - "your-vendor-name/module-name":"*" + "name": "magento/language-de_de", + "description": "German (Germany) language", + "require": { + ... + }, + "type": "magento2-language", + "extra": { + "map": [ + [ + "*", + "Magento/de_DE" + ] + ] } } ``` +Final location is `/app/i18n/Magento/de_DE` +### Magento Library +`"type": "magento2-library"` -### Custom Magento module location - -By default all magento-modules packages will be installed in the configured "vendor-dir" (which is "vendor" by default). -The package name will be used as a directory path and if there is a "target-dir" configured this will also be appended. -This results in packaged being installed in a path like this one: vendor/colinmollenhour/cm_diehard. +Support for libraries located in `lib/internal` instead of in the `vendor` directory. -Originally modman packages "live" in a directory called ".modman". This directory can be inside your htdocs directory, -next to it or where ever you want it to be. - -If you want magento-composer-installer to install your Magento extensions in a custom location, this can be configured -as follows: +Example: ```json { - ... - "extra":{ - "magento-root-dir": "htdocs/", - "modman-root-dir": ".modman" + "name": "magento/framework", + "description": "N/A", + "require": { + ... + }, + "type": "magento2-library", + "extra": { + "map": [ + [ + "*", + "Magento/Framework" + ] + ] } - ... } ``` -Make sure the .modman directory exists before updating. There is a fallback in place that will try to find the directory -relative to your vendor dir if it wasn't found in the first place. - -If you want to still use the original modman script, too, and if your modman-root-dir configuration is -not "htdocs/.modman" you'll need a ".basedir" file inside ".modman" that specifies where to find the htdocs folder (see -the [modman](https://github.com/colinmollenhour/modman/blob/master/modman#L268-L279) documentation) +Final location is `/lib/internal/Magento/Framework` -Should you choose to only use the original modman script to deploy packages, you will not want to have the -magento-composer-installer deploy the packages. So this can be disabled: +### Magento Component +`"type": "magento2-component"` -```json -{ - ... - "extra":{ - "magento-root-dir": "htdocs/", - "modman-root-dir": ".modman", - "magento-deploystrategy": "none" - } - ... -} -``` -### Auto add files to .gitignore +Installation location: Magento root directory -If you want to have the deployed files automatically added to your .gitignore file, then you can just set the `auto-append-gitignore` key to true: +Example: ```json { - ... - "extra":{ - "magento-root-dir": "htdocs/", - "auto-append-gitignore": true + "name": "magento/migration-tool", + "description": "N/A", + "require": { + ... + }, + "type": "magento2-component", + "extra": { + "map": [ + [ + "*", + "dev/tools/Magento/Tools/Migration" + ] + ] } - ... } ``` -The `.gitignore` file will be loaded from the current directory, and if it does not exist, it will be created. Every set of module files, will have a comment above them -describing the module name for clarity. - -Multiple deploys will not add additional lines to your .gitignore, they will only ever be added once. - +Final location is `/dev/tools/Magento/Tools/Migration` -### Testing -First clone the magento-composer-installer, then install the dev-stuff: +## Autoload +After handling all Magento components, `/app/etc/vendor_path.php` specifies the path to your `vendor` directory. -``` -./bin/composer.phar install --dev -``` - -then run ```vendor/bin/phpunit``` in project-root directory. +This information allows the Magento application to utilize the Composer autoloader for any libraries installed in the `vendor` directory. The path to `vendor` varies between particular installations and depends on the `magento_root` setting for the Magento Composer installer. That's why it should be generated for each installation. -Note: Windows users please run ```phpunit``` with Administrator permissions. +You must run `composer install` to install dependencies for a new application or `composer update` to update dependencies for an existing application. +## Deployment Strategy +The Magneto Composer Installer uses the `copy` deployment strategy. It copies each file or directory from the `vendor` directory to its designated location based on the `extra/map` section in the component's `composer.json`. -### How to overwrite dependencies +There are [other deployment strategies](https://github.com/magento/magento-composer-installer/blob/master/doc/Deploy.md) that could be used; however, we don't guarantee that any of them will work. -We don't want to use always the official repositories for specific dependencies. -For example for development purpose or use versions with custom patches. +## Usage `extra/chmod` -For this case you have the _repositories_ section inside your project composer.json -Here you can define own package composer.json for specific dependencies by the package name. +The following example shows how you can set specific permissions for files. -This example shows how to use a local git projects local-master branch which even works without a composer.json inside -and a project in VCS with existing composer.json, which is not yet on packagist. +Example: ```json { - ... - "repositories": [ - { - "type": "package", - "package": { - "name": "magento-hackathon/magento-composer-installer", - "version": "dev-master", - "type": "composer-installer", - "source": { - "type": "git", - "url": "/public_projects/magento/magento-composer-installer/", - "reference": "local-master" - }, - "autoload": { - "psr-0": {"MagentoHackathon\\Composer\\Magento": "src/"} - }, - "extra": { - "class": "\\MagentoHackathon\\Composer\\Magento\\Installer" - } - } - } - ] + "name": "magento/module-sample", + "description": "N/A", + "require": { + ... + }, + "type": "magento2-module", + "extra": { + "chmod": [ + { + "mask": "0755", + "path": "bin/magento" + }, + { + "mask": "0644", + "path": "some_dir/file.jpg" + } + ] + } } ``` -## Installation of composer - -### 1. Install PHP-Composer - -#### On Linux/Mac - -Go to your project root directory and run: - -``` -mkdir bin -curl -s https://getcomposer.org/installer | php -- --install-dir=bin -``` - -#### On Windows -Please take a look at http://getcomposer.org/doc/00-intro.md#installation-windows - -Creation of symbolic links requires the SeCreateSymbolicLinkPrivilege (“Create symbolic links”), which is granted only -to administrators by default (but you can change that using security policy). - -To change the policies: -- Launch secpol.msc via Start or Start → Run. -- Open Security Settings → Local Policies → User Rights Assignment. -- In the list, find the "Create symbolic links" item, which represents SeCreateSymbolicLinkPrivilege. - Double-click on the item and add yourself (or the whole Users group) to the list. - -(Seen at http://superuser.com/questions/124679/how-do-i-create-an-mklink-in-windows-7-home-premium-as-a-regular-user#125981) - - -### 2. Download composer.json template - -See [Usage](#usage). - - -### 3. Install Magento modules via composer - -``` -php bin/composer.phar install -``` - - - - - -## Further Information - -* [FAQ](doc/FAQ.md) -* [Make a Magento module installable with composer](doc/MakeAModuleInstallableWithComposer.md) -* [About File Mapping like for example modman](doc/Mapping.md) -* [About Deploying files into your Magento root and possible configs](doc/Deploy.md) - -### External Links - -* [Composer How to Screencast](http://www.youtube.com/watch?v=m_yprtQiFgk) -* [Introducing Composer Blog on Magebase.com](http://magebase.com/magento-tutorials/composer-with-magento/) - -### Core Contributors - -* Daniel Fahlke aka Flyingmana (Maintainer) -* Jörg Weller -* Karl Spies -* Tobias Vogt -* David Fuhr -* Amir Tchavoshinia -* Vinai Kopp (Maintainer) - - -## Thank You - -There are a few companies we want to thank for supporting this project in one way or another. - -#####[digital.manufaktur GmbH](https://www.digitalmanufaktur.com/) - -Teached me(Flyingmana) most I know about Magento and -paid my participation for the hackathon were the installer got created. - -#####[melovely](http://www.melovely.de/) - -Support me(Flyingmana) as my current employer very much in my work on everything composer related. +`mask` is a bit mask for chmod command +`path` is a path to file relative to the Magento root folder +# Notes +- The extra->magento-root-dir option is no longer supported. It displays only to preseve backward compatibility. \ No newline at end of file diff --git a/composer.json b/composer.json index 9d115dcd..134d7279 100644 --- a/composer.json +++ b/composer.json @@ -1,65 +1,62 @@ { - "name":"magento-hackathon/magento-composer-installer", - "description":"Composer installer for Magento modules", - "keywords":[ "composer-installer", "magento"], - "minimum-stability":"stable", - "type":"composer-plugin", - "license":"OSL-3.0", - "homepage":"https://github.com/magento-hackathon/magento-composer-installer", - "repositories": [ - { - "type": "vcs", - "url": "git@github.com:Flyingmana/phpcs.git" - } + "name": "magento/magento-composer-installer", + "description": "Composer installer for Magento modules", + "keywords": [ + "composer-installer", + "magento" ], - "authors":[ + "minimum-stability": "stable", + "type": "composer-plugin", + "license": "OSL-3.0", + "homepage": "https://github.com/magento/magento-composer-installer", + "authors": [ { - "name":"Daniel Fahlke aka Flyingmana", - "email":"flyingmana@googlemail.com" + "name": "Daniel Fahlke aka Flyingmana", + "email": "flyingmana@googlemail.com" }, { - "name":"Jörg Weller", - "email":"weller@flagbit.de" + "name": "Jörg Weller", + "email": "weller@flagbit.de" }, { - "name":"Karl Spies", - "email":"karl.spies@gmx.net" + "name": "Karl Spies", + "email": "karl.spies@gmx.net" }, { - "name":"Tobias Vogt", - "email":"tobi@webguys.de" + "name": "Tobias Vogt", + "email": "tobi@webguys.de" }, { - "name":"David Fuhr", - "email":"fuhr@flagbit.de" + "name": "David Fuhr", + "email": "fuhr@flagbit.de" }, { - "name":"Vinai Kopp", - "email":"vinai@netzarbeiter.com" + "name": "Vinai Kopp", + "email": "vinai@netzarbeiter.com" } ], - "require":{ - "eloquent/composer-config-reader": "2.*", - "composer-plugin-api": "1.0.0" + "require": { + "composer-plugin-api": "^1.1 || ^2.0", + "composer/composer": "^1.9 || ^2.0", + "laminas/laminas-stdlib": "^3.11.0" }, - "require-dev":{ - "phpunit/phpunit":"*", - "phpunit/phpunit-mock-objects": "dev-master", - "squizlabs/php_codesniffer": "1.4.7", - "firegento/phpcs": "dev-patch-1", - "composer/composer":"*@dev", - "symfony/process":"*", - "mikey179/vfsStream":"*" + "require-dev": { + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "~3.6.1", + "symfony/process": "~5.4.0", + "mikey179/vfsstream": "*" }, - "suggest":{ - "theseer/autoload": "~1.14", - "zetacomponents/console-tools": "dev-master", - "colinmollenhour/modman": "*", - "magento-hackathon/composer-command-integrator":"*" + "replace": { + "magento-hackathon/magento-composer-installer": "*" + }, + "autoload": { + "psr-0": { + "MagentoHackathon\\Composer\\Magento": "src/" + } }, - "autoload":{ - "psr-0":{ - "MagentoHackathon\\Composer\\Magento":"src/" + "autoload-dev": { + "psr-4": { + "MagentoHackathon\\": "tests/MagentoHackathon/" } }, "archive": { @@ -68,9 +65,10 @@ "/tests/FullStackTest/" ] }, - "test_version":"999.0.0", - "extra":{ - "composer-command-registry": [ "MagentoHackathon\\Composer\\Magento\\Command\\DeployCommand" ], - "class":"MagentoHackathon\\Composer\\Magento\\Plugin" + "extra": { + "composer-command-registry": [ + "MagentoHackathon\\Composer\\Magento\\Command\\DeployCommand" + ], + "class": "MagentoHackathon\\Composer\\Magento\\Plugin" } -} +} \ No newline at end of file diff --git a/doc/Deploy.md b/doc/Deploy.md index 07bf8737..f2bd0483 100644 --- a/doc/Deploy.md +++ b/doc/Deploy.md @@ -82,6 +82,23 @@ for this you can use `magento-deploy-ignore` which works either global or on mod may not work for symlink, when file/directory is content of a symlinked directory +### How to prevent your custom .gitignore file to be overridden + +In case you want to keep your custom .gitignore file then you need to ignore it in the _magento-deploy-ignore_ section. + +```json +{ + ... + "extra": { + "magento-deploy-ignore": { + "*": [ + "/.gitignore" + ] + } + } + ... +} +``` ### None Deploy If you only want to place packages into the vendor directory with no linking/copying into Magento's folder structure use this deploy strategy. diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 16c5149b..06e71732 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,7 @@ - - + bootstrap="tests/bootstrap.php"> + + + ./src/ + + + ./tests/MagentoHackathon - slow - - - - ./src/ - - - - - \ No newline at end of file + diff --git a/report.full b/report.full deleted file mode 100644 index 37379b75..00000000 --- a/report.full +++ /dev/null @@ -1,617 +0,0 @@ -FILE: ...staller/src/MagentoHackathon/Composer/Magento/Command/DeployCommand.php --------------------------------------------------------------------------------- -FOUND 12 ERROR(S) AND 3 WARNING(S) AFFECTING 9 LINE(S) --------------------------------------------------------------------------------- - 5 | WARNING | PHP version not specified - 5 | ERROR | Missing @category tag in class comment - 5 | ERROR | Missing @package tag in class comment - 5 | ERROR | Missing @author tag in class comment - 5 | ERROR | Missing @license tag in class comment - 18 | ERROR | There must be exactly one blank line before the tags in class - | | comments - 18 | ERROR | @author must be "FireGento Team " - 19 | ERROR | @author must be "FireGento Team " - 20 | ERROR | Missing @category tag in class comment - 20 | ERROR | Missing @package tag in class comment - 23 | ERROR | Missing function doc comment - 30 | WARNING | Line exceeds 120 characters; contains 136 characters - 40 | ERROR | You must use "/**" style comments for a function comment - 58 | WARNING | Line exceeds 120 characters; contains 123 characters - 73 | ERROR | Expected "if (...) {\n"; found "if(...){\n" --------------------------------------------------------------------------------- - - -FILE: ...nstaller/src/MagentoHackathon/Composer/Magento/Deploy/Manager/Entry.php --------------------------------------------------------------------------------- -FOUND 11 ERROR(S) AFFECTING 8 LINE(S) --------------------------------------------------------------------------------- - 2 | ERROR | File doc comment is empty - 12 | ERROR | Missing class doc comment - 12 | ERROR | Opening brace of a class must be on the line after the definition - 14 | ERROR | Protected member variable "packageName" must contain a leading - | | underscore - 19 | ERROR | Protected member variable "deployStrategy" must contain a leading - | | underscore - 22 | ERROR | Missing comment for param "$packageName" at position 1 - 22 | ERROR | There must be exactly one blank line before the tags in function - | | comment - 30 | ERROR | There must be exactly one blank line before the tags in function - | | comment - 38 | ERROR | Missing comment for param "$deployStrategy" at position 1 - 38 | ERROR | There must be exactly one blank line before the tags in function - | | comment - 46 | ERROR | There must be exactly one blank line before the tags in function - | | comment --------------------------------------------------------------------------------- - - -FILE: ...poser-installer/src/MagentoHackathon/Composer/Magento/DeployManager.php --------------------------------------------------------------------------------- -FOUND 22 ERROR(S) AFFECTING 17 LINE(S) --------------------------------------------------------------------------------- - 2 | ERROR | File doc comment is empty - 16 | ERROR | Missing class doc comment - 16 | ERROR | Opening brace of a class must be on the line after the definition - 21 | ERROR | Protected member variable "packages" must contain a leading - | | underscore - 26 | ERROR | Protected member variable "io" must contain a leading underscore - 33 | ERROR | Protected member variable "sortPriority" must contain a leading - | | underscore - 36 | ERROR | Missing function doc comment - 42 | ERROR | Missing function doc comment - 47 | ERROR | Missing function doc comment - 61 | ERROR | Expected 1 space after FUNCTION keyword; 0 found - 61 | ERROR | Expected 1 space before opening brace; found 0 - 63 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 65 | ERROR | Expected "} elseif (...) {\n"; found "}elseif(...){\n" - 70 | ERROR | Whitespace found at end of line - 71 | ERROR | Whitespace found at end of line - 72 | ERROR | Expected 1 space after FUNCTION keyword; 0 found - 72 | ERROR | Expected 1 space after closing parenthesis; found 0 - 72 | ERROR | Expected 1 space after USE keyword; found 0 - 72 | ERROR | Expected 1 space before USE keyword; found 0 - 86 | ERROR | Missing function doc comment - 90 | ERROR | Expected "foreach (...) {\n"; found "foreach(...){\n" - 91 | ERROR | Expected "if (...) {\n"; found "if(...){\n" --------------------------------------------------------------------------------- - - -FILE: ...installer/src/MagentoHackathon/Composer/Magento/Deploystrategy/Copy.php --------------------------------------------------------------------------------- -FOUND 11 ERROR(S) AND 1 WARNING(S) AFFECTING 4 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 10 | ERROR | Missing @category tag in class comment - 10 | ERROR | Missing @package tag in class comment - 10 | ERROR | Missing @author tag in class comment - 16 | ERROR | Expected 2 space(s) before variable type - 16 | ERROR | Missing comment for param "$source" at position 1 - 17 | ERROR | Expected 2 space(s) before variable type - 17 | ERROR | Missing comment for param "$dest" at position 2 --------------------------------------------------------------------------------- - - -FILE: ...ntoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php --------------------------------------------------------------------------------- -FOUND 51 ERROR(S) AND 2 WARNING(S) AFFECTING 35 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 10 | ERROR | Missing @category tag in class comment - 10 | ERROR | Missing @package tag in class comment - 10 | ERROR | Missing @author tag in class comment - 18 | ERROR | Protected member variable "mappings" must contain a leading - | | underscore - 25 | ERROR | Protected member variable "currentMapping" must contain a - | | leading underscore - 32 | ERROR | Protected member variable "ignoredMappings" must contain a - | | leading underscore - 40 | ERROR | Protected member variable "destDir" must contain a leading - | | underscore - 47 | ERROR | Protected member variable "sourceDir" must contain a leading - | | underscore - 54 | ERROR | Protected member variable "isForced" must contain a leading - | | underscore - 59 | ERROR | Missing comment for param "$sourceDir" at position 1 - 60 | ERROR | Missing comment for param "$destDir" at position 2 - 131 | ERROR | Missing comment for param "$forced" at position 1 - 151 | ERROR | Missing comment for param "$mappings" at position 1 - 171 | ERROR | Missing comment for param "$mapping" at position 1 - 182 | ERROR | Doc comment for var [ UNKNOWN ] does not match actual variable - | | name $ignoredMappings at position 1 - 182 | ERROR | Missing parameter name at position 1 - 182 | ERROR | Missing comment for param "[ UNKNOWN ]" at position 1 - 201 | ERROR | Expected 2 space(s) before variable type - 201 | ERROR | Missing comment for param "$destination" at position 1 - 201 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 208 | ERROR | No space found after comma in function call - 209 | ERROR | No space found after comma in function call - 210 | ERROR | Expected "foreach (...) {\n"; found "foreach(...){\n" - 211 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 211 | ERROR | No space found after comma in function call - 218 | ERROR | Doc comment for "$key" missing - 218 | ERROR | Doc comment for "$value" missing - 226 | ERROR | Missing function doc comment - 228 | ERROR | Line indented incorrectly; expected at least 8 spaces, found 7 - 236 | ERROR | Expected 2 space(s) before variable type - 236 | ERROR | Missing comment for param "$source" at position 1 - 237 | ERROR | Expected 2 space(s) before variable type - 237 | ERROR | Missing comment for param "$dest" at position 2 - 243 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 300 | ERROR | Missing comment for param "$source" at position 1 - 301 | ERROR | Missing comment for param "$dest" at position 2 - 327 | WARNING | Line exceeds 120 characters; contains 145 characters - 337 | ERROR | Missing comment for param "$dir" at position 1 - 338 | ERROR | Missing comment for param "$stopDir" at position 2 - 376 | ERROR | Doc comment for var [ UNKNOWN ] does not match actual variable - | | name $dir at position 1 - 376 | ERROR | Missing parameter name at position 1 - 376 | ERROR | Missing comment for param "[ UNKNOWN ]" at position 1 - 381 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 383 | ERROR | Expected "} else {\n"; found "}else{\n" - 396 | ERROR | Expected 2 space(s) before variable type - 396 | ERROR | Missing comment for param "$source" at position 1 - 397 | ERROR | Expected 2 space(s) before variable type - 397 | ERROR | Missing comment for param "$dest" at position 2 --------------------------------------------------------------------------------- - - -FILE: ...installer/src/MagentoHackathon/Composer/Magento/Deploystrategy/Link.php --------------------------------------------------------------------------------- -FOUND 11 ERROR(S) AND 1 WARNING(S) AFFECTING 4 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 10 | ERROR | Missing @category tag in class comment - 10 | ERROR | Missing @package tag in class comment - 10 | ERROR | Missing @author tag in class comment - 16 | ERROR | Expected 2 space(s) before variable type - 16 | ERROR | Missing comment for param "$source" at position 1 - 17 | ERROR | Expected 2 space(s) before variable type - 17 | ERROR | Missing comment for param "$dest" at position 2 --------------------------------------------------------------------------------- - - -FILE: ...installer/src/MagentoHackathon/Composer/Magento/Deploystrategy/None.php --------------------------------------------------------------------------------- -FOUND 15 ERROR(S) AND 1 WARNING(S) AFFECTING 6 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 10 | ERROR | Missing @category tag in class comment - 10 | ERROR | Missing @package tag in class comment - 10 | ERROR | Missing @author tag in class comment - 16 | ERROR | Expected 2 space(s) before variable type - 16 | ERROR | Missing comment for param "$source" at position 1 - 17 | ERROR | Expected 2 space(s) before variable type - 17 | ERROR | Missing comment for param "$dest" at position 2 - 28 | ERROR | Expected 2 space(s) before variable type - 28 | ERROR | Missing comment for param "$source" at position 1 - 29 | ERROR | Expected 2 space(s) before variable type - 29 | ERROR | Missing comment for param "$dest" at position 2 --------------------------------------------------------------------------------- - - -FILE: ...taller/src/MagentoHackathon/Composer/Magento/Deploystrategy/Symlink.php --------------------------------------------------------------------------------- -FOUND 15 ERROR(S) AND 2 WARNING(S) AFFECTING 8 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 10 | ERROR | Missing @category tag in class comment - 10 | ERROR | Missing @package tag in class comment - 10 | ERROR | Missing @author tag in class comment - 16 | ERROR | Expected 2 space(s) before variable type - 16 | ERROR | Missing comment for param "$source" at position 1 - 17 | ERROR | Expected 2 space(s) before variable type - 17 | ERROR | Missing comment for param "$dest" at position 2 - 93 | WARNING | Line exceeds 120 characters; contains 132 characters - 103 | ERROR | Expected "if (...) {\n"; found "if(...) {\n" - 108 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 115 | ERROR | Doc comment for "$from" missing - 115 | ERROR | Doc comment for "$to" missing --------------------------------------------------------------------------------- - - -FILE: ...-composer-installer/src/MagentoHackathon/Composer/Magento/Installer.php --------------------------------------------------------------------------------- -FOUND 110 ERROR(S) AND 12 WARNING(S) AFFECTING 88 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 21 | ERROR | Missing @category tag in class comment - 21 | ERROR | Missing @package tag in class comment - 21 | ERROR | Missing @author tag in class comment - 29 | ERROR | Protected member variable "magentoRootDir" must contain a - | | leading underscore - 36 | ERROR | Protected member variable "defaultMagentoRootDir" must contain - | | a leading underscore - 43 | ERROR | Protected member variable "modmanRootDir" must contain a - | | leading underscore - 50 | ERROR | Protected member variable "isForced" must contain a leading - | | underscore - 57 | ERROR | Variable "_source_dir" is not in valid camel caps format - 71 | ERROR | Protected member variable "noMaintenanceMode" must contain a - | | leading underscore - 72 | ERROR | Protected member variable "originalMagentoRootDir" must - | | contain a leading underscore - 73 | ERROR | Protected member variable "backupMagentoRootDir" must contain - | | a leading underscore - 74 | ERROR | Protected member variable "removeMagentoDev" must contain a - | | leading underscore - 75 | ERROR | Protected member variable "keepMagentoCache" must contain a - | | leading underscore - 90 | ERROR | Protected member variable "deployManager" must contain a - | | leading underscore - 95 | ERROR | Protected member variable "config" must contain a leading - | | underscore - 102 | ERROR | Protected member variable "appendGitIgnore" must contain a - | | leading underscore - 113 | ERROR | Missing comment for param "$io" at position 1 - 114 | ERROR | The variable names for parameters $io (1) and $composer (2) do - | | not align - 114 | ERROR | Missing comment for param "$composer" at position 2 - 115 | ERROR | The variable names for parameters $composer (2) and $type (3) - | | do not align - 115 | ERROR | Missing comment for param "$type" at position 3 - 127 | WARNING | Line exceeds 120 characters; contains 237 characters - 168 | WARNING | Line exceeds 120 characters; contains 129 characters - 169 | WARNING | Line exceeds 120 characters; contains 141 characters - 193 | ERROR | Missing comment for param "$deployManager" at position 1 - 193 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 201 | ERROR | Missing function doc comment - 207 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 217 | ERROR | Opening brace should be on a new line - 236 | ERROR | Extra newline(s) found before function comment short - | | description - 237 | ERROR | Expected 2 space(s) before variable type - 237 | ERROR | Missing comment for param "$extra" at position 1 - 237 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 238 | ERROR | Expected 2 space(s) before variable type - 238 | ERROR | The variable names for parameters $extra (1) and $io (2) do - | | not align - 238 | ERROR | Missing comment for param "$io" at position 2 - 241 | ERROR | Opening brace should be on a new line - 277 | ERROR | Missing function doc comment - 277 | ERROR | Opening brace should be on a new line - 294 | ERROR | Missing comment for param "$strategy" at position 1 - 294 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 304 | ERROR | Expected 2 space(s) before variable type - 304 | ERROR | Missing comment for param "$package" at position 1 - 305 | ERROR | Expected 2 space(s) before variable type - 305 | ERROR | The variable names for parameters $package (1) and $strategy - | | (2) do not align - 305 | ERROR | Missing comment for param "$strategy" at position 2 - 314 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 315 | WARNING | Line exceeds 120 characters; contains 126 characters - 316 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 321 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 323 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 326 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 328 | ERROR | Whitespace found at end of line - 333 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 361 | ERROR | Missing comment for param "$packageType" at position 1 - 372 | ERROR | Expected 2 space(s) before variable type - 372 | ERROR | Missing comment for param "$package" at position 1 - 437 | ERROR | Missing comment for param "$package" at position 1 - 438 | ERROR | The variable names for parameters $package (1) and $ignoreFile - | | (2) do not align - 438 | ERROR | Missing comment for param "$ignoreFile" at position 2 - 443 | ERROR | Expected "if (...) {\n"; found "if(...) {\n" - 448 | ERROR | Expected "foreach (...) {\n"; found "foreach(...) {\n" - 451 | ERROR | No space found after comma in function call - 452 | ERROR | No space found after comma in function call - 453 | ERROR | No space found after comma in function call - 454 | ERROR | Expected "if (...) {\n"; found "if(...) {\n" - 456 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 464 | ERROR | Expected "if (...) {\n"; found "if(...) {\n" - 476 | ERROR | Expected 6 space(s) before asterisk; 5 found - 477 | ERROR | Expected 6 space(s) before asterisk; 5 found - 478 | ERROR | Expected 6 space(s) before asterisk; 5 found - 478 | ERROR | Superfluous doc comment at position 1 - 479 | ERROR | Expected 6 space(s) before asterisk; 5 found - 479 | ERROR | The variable names for parameters $repo (1) and $package (2) - | | do not align - 479 | ERROR | The comments for parameters $repo (1) and $package (2) do not - | | align - 479 | ERROR | Superfluous doc comment at position 2 - 480 | ERROR | Expected 6 space(s) before asterisk; 5 found - 481 | ERROR | Opening brace should be on a new line - 482 | WARNING | Line exceeds 120 characters; contains 220 characters - 490 | ERROR | Missing function doc comment - 490 | ERROR | Opening brace should be on a new line - 495 | ERROR | Missing function doc comment - 495 | ERROR | Opening brace should be on a new line - 503 | ERROR | Opening brace should be on a new line - 516 | ERROR | The variable names for parameters $path (1) and $dirmode (2) - | | do not align - 516 | ERROR | The comments for parameters $path (1) and $dirmode (2) do not - | | align - 517 | ERROR | The comments for parameters $dirmode (2) and $filemode (3) do - | | not align - 519 | ERROR | Opening brace should be on a new line - 543 | ERROR | You must use "/**" style comments for a function comment - 543 | ERROR | Opening brace should be on a new line - 561 | ERROR | Line indented incorrectly; expected at least 16 spaces, found - | | 12 - 573 | ERROR | Line indented incorrectly; expected at least 16 spaces, found - | | 12 - 613 | ERROR | Expected "if (...) {\n"; found "if(...) {\n" - 623 | ERROR | Missing function doc comment - 623 | ERROR | Opening brace should be on a new line - 624 | WARNING | Line exceeds 120 characters; contains 157 characters - 635 | ERROR | Missing function doc comment - 635 | ERROR | Opening brace should be on a new line - 649 | ERROR | Missing function doc comment - 649 | ERROR | Opening brace should be on a new line - 653 | WARNING | Line exceeds 120 characters; contains 139 characters - 656 | WARNING | Line exceeds 120 characters; contains 124 characters - 667 | ERROR | Missing function doc comment - 667 | ERROR | Opening brace should be on a new line - 680 | ERROR | Missing function doc comment - 680 | ERROR | Opening brace should be on a new line - 707 | ERROR | Expected 2 space(s) before variable type - 707 | ERROR | Missing comment for param "$package" at position 1 - 715 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 717 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 729 | WARNING | Line exceeds 120 characters; contains 130 characters - 740 | ERROR | Doc comment for "$package" missing - 764 | ERROR | You must use "/**" style comments for a function comment - 767 | ERROR | Expected "foreach (...) {\n"; found "foreach(...){\n" - 778 | ERROR | Missing comment for param "$io" at position 1 - 788 | WARNING | Line exceeds 120 characters; contains 157 characters - 789 | WARNING | Line exceeds 120 characters; contains 149 characters --------------------------------------------------------------------------------- - - -FILE: ...-composer-installer/src/MagentoHackathon/Composer/Magento/MapParser.php --------------------------------------------------------------------------------- -FOUND 10 ERROR(S) AND 1 WARNING(S) AFFECTING 5 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 8 | ERROR | Missing class doc comment - 8 | ERROR | Opening brace of a class must be on the line after the - | | definition - 12 | ERROR | Missing function doc comment - 12 | ERROR | Visibility must be declared on method "__construct" - 19 | ERROR | Missing function doc comment - 24 | ERROR | Missing function doc comment --------------------------------------------------------------------------------- - - -FILE: ...mposer-installer/src/MagentoHackathon/Composer/Magento/ModmanParser.php --------------------------------------------------------------------------------- -FOUND 19 ERROR(S) AND 2 WARNING(S) AFFECTING 11 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 10 | ERROR | Missing @category tag in class comment - 10 | ERROR | Missing @package tag in class comment - 10 | ERROR | Missing @author tag in class comment - 26 | ERROR | Missing comment for param "$moduleDir" at position 1 - 26 | ERROR | Doc comment for "$translations" missing - 39 | ERROR | Expected 2 space(s) before variable type - 39 | ERROR | Missing comment for param "$moduleDir" at position 1 - 54 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 62 | ERROR | Expected 2 space(s) before variable type - 62 | ERROR | Missing comment for param "$file" at position 1 - 62 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 75 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 83 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 95 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 112 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 128 | WARNING | Line exceeds 120 characters; contains 122 characters --------------------------------------------------------------------------------- - - -FILE: ...er-installer/src/MagentoHackathon/Composer/Magento/PackageXmlParser.php --------------------------------------------------------------------------------- -FOUND 30 ERROR(S) AND 1 WARNING(S) AFFECTING 16 LINE(S) --------------------------------------------------------------------------------- - 4 | WARNING | PHP version not specified - 4 | ERROR | Missing @category tag in class comment - 4 | ERROR | Missing @package tag in class comment - 4 | ERROR | Missing @author tag in class comment - 4 | ERROR | Missing @license tag in class comment - 10 | ERROR | Missing @category tag in class comment - 10 | ERROR | Missing @package tag in class comment - 10 | ERROR | Missing @author tag in class comment - 31 | ERROR | Missing comment for param "$moduleDir" at position 1 - 32 | ERROR | Missing comment for param "$packageXmlFile" at position 2 - 33 | ERROR | Missing comment for param "$translations" at position 3 - 46 | ERROR | Expected 2 space(s) before variable type - 46 | ERROR | Missing comment for param "$moduleDir" at position 1 - 61 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 69 | ERROR | Expected 2 space(s) before variable type - 69 | ERROR | Missing comment for param "$file" at position 1 - 69 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 82 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 90 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 107 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 140 | ERROR | Expected 2 space(s) before variable type - 140 | ERROR | Missing comment for param "$target" at position 1 - 140 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 155 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 171 | ERROR | Expected 2 space(s) before variable type - 171 | ERROR | Missing comment for param "$element" at position 1 - 171 | ERROR | There must be exactly one blank line before the tags in - | | function comment - 175 | ERROR | Opening brace should be on a new line - 205 | ERROR | Expected 2 space(s) before variable type - 205 | ERROR | Missing comment for param "$element" at position 1 - 205 | ERROR | There must be exactly one blank line before the tags in - | | function comment --------------------------------------------------------------------------------- - - -FILE: ...nto-composer-installer/src/MagentoHackathon/Composer/Magento/Parser.php --------------------------------------------------------------------------------- -FOUND 2 ERROR(S) AFFECTING 2 LINE(S) --------------------------------------------------------------------------------- - 2 | ERROR | Missing file doc comment - 5 | ERROR | Missing interface doc comment --------------------------------------------------------------------------------- - - -FILE: ...staller/src/MagentoHackathon/Composer/Magento/PathTranslationParser.php --------------------------------------------------------------------------------- -FOUND 17 ERROR(S) AFFECTING 11 LINE(S) --------------------------------------------------------------------------------- - 2 | ERROR | Missing file doc comment - 8 | ERROR | Missing @category tag in class comment - 8 | ERROR | Missing @package tag in class comment - 8 | ERROR | Missing @author tag in class comment - 15 | ERROR | Protected member variable "pathPrefixVariants" must contain a - | | leading underscore - 21 | ERROR | Protected member variable "pathPrefixTranslations" must contain a - | | leading underscore - 38 | ERROR | Expected 2 space(s) before variable type - 38 | ERROR | Doc comment for var [ UNKNOWN ] does not match actual variable - | | name $translations at position 1 - 38 | ERROR | Missing parameter name at position 1 - 38 | ERROR | Missing comment for param "[ UNKNOWN ]" at position 1 - 44 | ERROR | Expected "foreach (...) {\n"; found "foreach(...) {\n" - 45 | ERROR | Expected "foreach (...) {\n"; found "foreach(...) {\n" - 62 | ERROR | Expected 2 space(s) before variable type - 62 | ERROR | Doc comment for var Array does not match actual variable name - | | $mappings at position 1 - 69 | ERROR | Expected "foreach (...) {\n"; found "foreach(...) {\n" - 70 | ERROR | Expected "foreach (...) {\n"; found "foreach(...) {\n" - 71 | ERROR | Expected "if (...) {\n"; found "if(...) {\n" --------------------------------------------------------------------------------- - - -FILE: ...nto-composer-installer/src/MagentoHackathon/Composer/Magento/Plugin.php --------------------------------------------------------------------------------- -FOUND 32 ERROR(S) AND 3 WARNING(S) AFFECTING 34 LINE(S) --------------------------------------------------------------------------------- - 2 | ERROR | File doc comment is empty - 26 | ERROR | Missing class doc comment - 26 | ERROR | Opening brace of a class must be on the line after the - | | definition - 31 | ERROR | Protected member variable "io" must contain a leading - | | underscore - 37 | ERROR | Protected member variable "config" must contain a leading - | | underscore - 43 | ERROR | Protected member variable "deployManager" must contain a - | | leading underscore - 49 | ERROR | Protected member variable "composer" must contain a leading - | | underscore - 55 | ERROR | Protected member variable "filesystem" must contain a leading - | | underscore - 58 | ERROR | Missing function doc comment - 63 | WARNING | Line exceeds 120 characters; contains 123 characters - 69 | ERROR | Missing function doc comment - 79 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 85 | ERROR | Missing function doc comment - 104 | ERROR | Missing comment for param "$event" at position 1 - 114 | ERROR | Missing comment for param "$event" at position 1 - 118 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 127 | ERROR | Missing function doc comment - 133 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 134 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 147 | ERROR | Expected "foreach (...) {\n"; found "foreach(...){\n" - 150 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 153 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 156 | ERROR | Expected "foreach (...) {\n"; found "foreach(...){\n" - 159 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 169 | ERROR | No space found after comma in function call - 172 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 173 | WARNING | Line exceeds 120 characters; contains 122 characters - 175 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 176 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 179 | ERROR | No space found after comma in function call - 181 | ERROR | Expected "} else {\n"; found "}else{\n" - 182 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 183 | WARNING | Line exceeds 120 characters; contains 132 characters - 202 | ERROR | Missing comment for param "$source" at position 1 - 203 | ERROR | Missing comment for param "$target" at position 2 --------------------------------------------------------------------------------- - - -FILE: ...poser-installer/src/MagentoHackathon/Composer/Magento/ProjectConfig.php --------------------------------------------------------------------------------- -FOUND 14 ERROR(S) AFFECTING 12 LINE(S) --------------------------------------------------------------------------------- - 2 | ERROR | File doc comment is empty - 12 | ERROR | Missing class doc comment - 12 | ERROR | Opening brace of a class must be on the line after the definition - 14 | ERROR | Protected member variable "libraryPath" must contain a leading - | | underscore - 15 | ERROR | Protected member variable "libraryPackages" must contain a - | | leading underscore - 17 | ERROR | Missing function doc comment - 20 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 25 | ERROR | Missing function doc comment - 25 | ERROR | Opening brace should be on a new line - 27 | ERROR | Expected "if (...) {\n"; found "if(...){\n" - 33 | ERROR | Missing function doc comment - 38 | ERROR | Missing function doc comment - 45 | ERROR | Missing function doc comment - 50 | ERROR | Missing function doc comment --------------------------------------------------------------------------------- - - -FILE: ...poser-installer/src/MagentoHackathon/Composer/Magerun/DeployCommand.php --------------------------------------------------------------------------------- -FOUND 12 ERROR(S) AFFECTING 8 LINE(S) --------------------------------------------------------------------------------- - 2 | ERROR | Missing file doc comment - 9 | ERROR | Missing class doc comment - 11 | ERROR | Missing function doc comment - 13 | ERROR | Line indented incorrectly; expected at least 8 spaces, found 6 - 16 | ERROR | Line indented incorrectly; expected at least 8 spaces, found 6 - 19 | ERROR | Line indented incorrectly; expected at least 4 spaces, found 3 - 20 | ERROR | Expected 2 space(s) before variable type - 20 | ERROR | Missing comment for param "$input" at position 1 - 20 | ERROR | There must be exactly one blank line before the tags in function - | | comment - 21 | ERROR | Expected 2 space(s) before variable type - 21 | ERROR | The variable names for parameters $input (1) and $output (2) do - | | not align - 21 | ERROR | Missing comment for param "$output" at position 2 --------------------------------------------------------------------------------- diff --git a/res/target.xml b/res/target.xml index 3e22070b..267e52c2 100644 --- a/res/target.xml +++ b/res/target.xml @@ -1,15 +1,15 @@ - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/run_phpcs.sh b/run_phpcs.sh deleted file mode 100755 index f0f01ed5..00000000 --- a/run_phpcs.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh -#needs to do -#cp /vendor/firegento/phpcs /vendor/firegento/FireGento -#before -./vendor/bin/phpcs --report-full=report.full --standard=./vendor/firegento/FireGento -p ./src diff --git a/run_phpcs_experiment.php b/run_phpcs_experiment.php deleted file mode 100755 index cc51b271..00000000 --- a/run_phpcs_experiment.php +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env php -setTokenListeners( __DIR__.'/vendor/firegento/phpcs'); - -require_once __DIR__ . '/vendor/bin/phpcs'; \ No newline at end of file diff --git a/src/MagentoHackathon/Composer/Magento/Command/DeployCommand.php b/src/MagentoHackathon/Composer/Magento/Command/DeployCommand.php index 8650c677..d586ba74 100644 --- a/src/MagentoHackathon/Composer/Magento/Command/DeployCommand.php +++ b/src/MagentoHackathon/Composer/Magento/Command/DeployCommand.php @@ -18,17 +18,17 @@ * @author Tiago Ribeiro * @author Rui Marinho */ -class DeployCommand extends \Composer\Command\Command +class DeployCommand extends \Composer\Command\BaseCommand { protected function configure() { $this ->setName('magento-module-deploy') ->setDescription('Deploy all Magento modules loaded via composer.json') - ->setDefinition(array( + ->setDefinition([ // we dont need to define verbose, because composer already defined it internal //new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'), - )) + ]) ->setHelp(<<getIO() ); $extra = $composer->getPackage()->getExtra(); - $sortPriority = isset($extra['magento-deploy-sort-priority']) ? $extra['magento-deploy-sort-priority'] : array(); + $sortPriority = $extra['magento-deploy-sort-priority'] ?? []; $deployManager->setSortPriority( $sortPriority ); diff --git a/src/MagentoHackathon/Composer/Magento/Deploy/Manager/Entry.php b/src/MagentoHackathon/Composer/Magento/Deploy/Manager/Entry.php index 175d4567..de3e4180 100644 --- a/src/MagentoHackathon/Composer/Magento/Deploy/Manager/Entry.php +++ b/src/MagentoHackathon/Composer/Magento/Deploy/Manager/Entry.php @@ -49,6 +49,4 @@ public function getDeployStrategy() { return $this->deployStrategy; } - - } diff --git a/src/MagentoHackathon/Composer/Magento/DeployManager.php b/src/MagentoHackathon/Composer/Magento/DeployManager.php index 97c4be95..1376091a 100644 --- a/src/MagentoHackathon/Composer/Magento/DeployManager.php +++ b/src/MagentoHackathon/Composer/Magento/DeployManager.php @@ -1,9 +1,9 @@ 10 + ]; + + public function __construct(IOInterface $io) { $this->io = $io; } - - - public function addPackage( Entry $package ) + + public function addPackage(Entry $package) { $this->packages[] = $package; } - - public function setSortPriority( $priorities ) + + public function setSortPriority($priorities) { $this->sortPriority = $priorities; } - /** - * uses the sortPriority Array to sort the packages. + * Uses the sortPriority Array to sort the packages. + * * Highest priority first. * Copy gets per default higher priority then others + * + * @return array */ protected function sortPackages() { - $sortPriority = $this->sortPriority; - $getPriorityValue = function( Entry $object ) use ( $sortPriority ){ - $result = 100; - if( isset($sortPriority[$object->getPackageName()]) ){ - $result = $sortPriority[$object->getPackageName()]; - }elseif( $object->getDeployStrategy() instanceof Copy ){ - $result = 101; - } - return $result; - }; - usort( - $this->packages, - function($a, $b)use( $getPriorityValue ){ - /** @var Entry $a */ - /** @var Entry $b */ - $aVal = $getPriorityValue($a); - $bVal = $getPriorityValue($b); - if ($aVal == $bVal) { + usort( + $this->packages, + function ($a, $b) { + $aPriority = $this->getPackagePriority($a); + $bPriority = $this->getPackagePriority($b); + if ($aPriority == $bPriority) { return 0; } - return ($aVal > $bVal) ? -1 : 1; + return ($aPriority > $bPriority) ? -1 : 1; } ); + + return $this->packages; } - - + public function doDeploy() { $this->sortPackages(); + /** @var Entry $package */ - foreach( $this->packages as $package ){ - if( $this->io->isDebug() ){ - $this->io->write('start magento deploy for '. $package->getPackageName() ); + foreach ($this->packages as $package) { + if ($this->io->isDebug()) { + $this->io->write('start magento deploy for ' . $package->getPackageName()); + } + try { + $package->getDeployStrategy()->deploy(); + } catch (\ErrorException $e) { + if ($this->io->isDebug()) { + $this->io->write($e->getMessage()); + } } - $package->getDeployStrategy()->deploy(); } } + /** + * Determine the priority in which the package should be deployed + * + * @param Entry $package + * @return int + */ + private function getPackagePriority(Entry $package) + { + $result = 100; + $maxPriority = max(array_merge($this->sortPriority, [100, 101])); + + if (isset($this->highPriority[$package->getPackageName()])) { + $packagePriority = $this->highPriority[$package->getPackageName()]; + $result = intval($maxPriority) + intval($packagePriority); + } elseif (isset($this->sortPriority[$package->getPackageName()])) { + $result = $this->sortPriority[$package->getPackageName()]; + } elseif ($package->getDeployStrategy() instanceof Copy) { + $result = 101; + } + + return $result; + } + } diff --git a/src/MagentoHackathon/Composer/Magento/Deploystrategy/Copy.php b/src/MagentoHackathon/Composer/Magento/Deploystrategy/Copy.php index d998b254..2661065d 100644 --- a/src/MagentoHackathon/Composer/Magento/Deploystrategy/Copy.php +++ b/src/MagentoHackathon/Composer/Magento/Deploystrategy/Copy.php @@ -25,14 +25,16 @@ public function createDelegate($source, $dest) $mapDest = $this->removeTrailingSlash($mapDest); $cleanDest = $this->removeTrailingSlash($dest); - $sourcePath = $this->getSourceDir() . '/' . $this->removeTrailingSlash($source); - $destPath = $this->getDestDir() . '/' . $this->removeTrailingSlash($dest); + $sourcePath = $this->getSourceDir() . DIRECTORY_SEPARATOR + . ltrim($this->removeTrailingSlash($source), DIRECTORY_SEPARATOR); + $destPath = $this->getDestDir() . DIRECTORY_SEPARATOR + . ltrim($this->removeTrailingSlash($dest), DIRECTORY_SEPARATOR); // Create all directories up to one below the target if they don't exist $destDir = dirname($destPath); if (!file_exists($destDir)) { - mkdir($destDir, 0777, true); + mkdir($destDir, 0755, true); } // Handle source to dir copy, @@ -44,27 +46,33 @@ public function createDelegate($source, $dest) // first iteration through, we need to update the mappings to correctly handle mismatch globs if ($mapSource == $this->removeTrailingSlash($source) && $mapDest == $this->removeTrailingSlash($dest)) { if (basename($sourcePath) !== basename($destPath)) { - $this->setCurrentMapping(array($mapSource, $mapDest . '/' . basename($source))); - $cleanDest = $cleanDest . '/' . basename($source); + $this->setCurrentMapping([$mapSource, $mapDest . DIRECTORY_SEPARATOR . basename($source)]); + $cleanDest = $cleanDest . DIRECTORY_SEPARATOR . basename($source); } } if (file_exists($destPath) && is_dir($destPath)) { $mapSource = rtrim($mapSource, '*'); - if (strcmp(substr($cleanDest, strlen($mapDest)+1), substr($source, strlen($mapSource)+1)) === 0) { + $mapSourceLen = empty($mapSource) ? 0 : strlen($mapSource); + if ( + strcmp( + substr(ltrim($cleanDest, DIRECTORY_SEPARATOR), strlen($mapDest)), + substr(ltrim($source, DIRECTORY_SEPARATOR), $mapSourceLen) + ) === 0 + ) { // copy each child of $sourcePath into $destPath foreach (new \DirectoryIterator($sourcePath) as $item) { $item = (string) $item; if (!strcmp($item, '.') || !strcmp($item, '..')) { continue; } - $childSource = $this->removeTrailingSlash($source) . '/' . $item; - $this->create($childSource, substr($destPath, strlen($this->getDestDir())+1)); + $childSource = $this->removeTrailingSlash($source) . DIRECTORY_SEPARATOR . $item; + $this->create($childSource, substr($destPath, strlen($this->getDestDir()) + 1)); } return true; } else { - $destPath = $this->removeTrailingSlash($destPath) . '/' . basename($source); - return $this->create($source, substr($destPath, strlen($this->getDestDir())+1)); + $destPath = $this->removeTrailingSlash($destPath) . DIRECTORY_SEPARATOR . basename($source); + return $this->create($source, substr($destPath, strlen($this->getDestDir()) + 1)); } } @@ -82,7 +90,7 @@ public function createDelegate($source, $dest) // File to file if (!is_dir($sourcePath)) { if (is_dir($destPath)) { - $destPath .= '/' . basename($sourcePath); + $destPath .= DIRECTORY_SEPARATOR . basename($sourcePath); } return copy($sourcePath, $destPath); } @@ -90,18 +98,20 @@ public function createDelegate($source, $dest) // Copy dir to dir // First create destination folder if it doesn't exist if (file_exists($destPath)) { - $destPath .= '/' . basename($sourcePath); + $destPath .= DIRECTORY_SEPARATOR . basename($sourcePath); } - mkdir($destPath, 0777, true); + mkdir($destPath, 0755, true); - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourcePath), - \RecursiveIteratorIterator::SELF_FIRST); + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($sourcePath), + \RecursiveIteratorIterator::SELF_FIRST + ); foreach ($iterator as $item) { - $subDestPath = $destPath . '/' . $iterator->getSubPathName(); + $subDestPath = $destPath . DIRECTORY_SEPARATOR . $iterator->getSubPathName(); if ($item->isDir()) { - if (! file_exists($subDestPath)) { - mkdir($subDestPath, 0777, true); + if (!file_exists($subDestPath)) { + mkdir($subDestPath, 0755, true); } } else { copy($item, $subDestPath); diff --git a/src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php b/src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php index 53723ace..ff52ff4b 100644 --- a/src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php +++ b/src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php @@ -5,6 +5,8 @@ namespace MagentoHackathon\Composer\Magento\Deploystrategy; +use Laminas\Stdlib\Glob; + /** * Abstract deploy strategy */ @@ -15,21 +17,21 @@ abstract class DeploystrategyAbstract * * @var array */ - protected $mappings = array(); + protected $mappings = []; /** * The current mapping of the deployment iteration * * @var array */ - protected $currentMapping = array(); + protected $currentMapping = []; /** * The List of entries which files should not get deployed * * @var array */ - protected $ignoredMappings = array(); + protected $ignoredMappings = []; /** @@ -220,7 +222,7 @@ protected function isDestinationIgnored($destination) */ public function addMapping($key, $value) { - $this->mappings[] = array($key, $value); + $this->mappings[] = [$key, $value]; } protected function removeTrailingSlash($path) @@ -244,8 +246,9 @@ public function create($source, $dest) return; } - $sourcePath = $this->getSourceDir() . '/' . $this->removeTrailingSlash($source); - $destPath = $this->getDestDir() . '/' . $dest; + $sourcePath = $this->getSourceDir() . DIRECTORY_SEPARATOR + . ltrim($this->removeTrailingSlash($source), DIRECTORY_SEPARATOR); + $destPath = $this->getDestDir() . DIRECTORY_SEPARATOR . $dest; /* List of possible cases, keep around for now, might come in handy again @@ -270,20 +273,23 @@ public function create($source, $dest) */ // Create target directory if it ends with a directory separator - if (! file_exists($destPath) && in_array(substr($destPath, -1), array('/', '\\')) && ! is_dir($sourcePath)) { - mkdir($destPath, 0777, true); + if (!file_exists($destPath) + && in_array(substr($destPath, -1), ['/', '\\']) + && !is_dir($sourcePath) + ) { + mkdir($destPath, 0755, true); $destPath = $this->removeTrailingSlash($destPath); } // If source doesn't exist, check if it's a glob expression, otherwise we have nothing we can do if (!file_exists($sourcePath)) { // Handle globing - $matches = glob($sourcePath); + $matches = Glob::glob($sourcePath); if ($matches) { foreach ($matches as $match) { $newDest = substr($destPath . '/' . basename($match), strlen($this->getDestDir())); $newDest = ltrim($newDest, ' \\/'); - $this->create(substr($match, strlen($this->getSourceDir())+1), $newDest); + $this->create(substr($match, strlen($this->getSourceDir()) + 1), $newDest); } return true; } @@ -303,24 +309,21 @@ public function create($source, $dest) */ public function remove($source, $dest) { + if ($this->isDestinationIgnored($dest)){ + return; + } + $sourcePath = $this->getSourceDir() . '/' . $this->removeTrailingSlash($source); $destPath = $this->getDestDir() . '/' . $dest; // If source doesn't exist, check if it's a glob expression, otherwise we have nothing we can do if (!file_exists($sourcePath)) { - // Handle globing - $matches = glob($sourcePath); - if ($matches) { - foreach ($matches as $match) { - $newDest = substr($destPath . '/' . basename($match), strlen($this->getDestDir())); - $newDest = ltrim($newDest, ' \\/'); - $this->remove(substr($match, strlen($this->getSourceDir())+1), $newDest); - } - return; - } - - // Source file isn't a valid file or glob - throw new \ErrorException("Source $sourcePath does not exist"); + $this->removeContentOfCategory($sourcePath, $destPath); + return; + } elseif (file_exists($sourcePath) && is_dir($sourcePath)) { + $this->removeContentOfCategory($sourcePath . '/*', $destPath); + @rmdir($destPath); + return; } // MP Avoid removing whole folders in case the modman file is not 100% well-written @@ -331,6 +334,33 @@ public function remove($source, $dest) self::rmdirRecursive($destPath); } + /** + * Search and remove content of category + * + * @param string $sourcePath + * @param string $destPath + * @throws \ErrorException + */ + protected function removeContentOfCategory($sourcePath, $destPath) + { + $sourcePath = preg_replace('#/\*$#', '/{,.}*', $sourcePath); + $matches = Glob::glob($sourcePath, Glob::GLOB_BRACE); + if ($matches) { + foreach ($matches as $match) { + if (preg_match("#/\.{1,2}$#", $match)) { + continue; + } + $newDest = substr($destPath . '/' . basename($match), strlen($this->getDestDir())); + $newDest = ltrim($newDest, ' \\/'); + $this->remove(substr($match, strlen($this->getSourceDir())+1), $newDest); + } + return; + } + + // Source file isn't a valid file or glob + throw new \ErrorException("Source $sourcePath does not exist"); + } + /** * Remove an empty directory branch up to $stopDir, or stop at the first non-empty parent. * diff --git a/src/MagentoHackathon/Composer/Magento/Deploystrategy/Symlink.php b/src/MagentoHackathon/Composer/Magento/Deploystrategy/Symlink.php index bb925046..9ea40568 100644 --- a/src/MagentoHackathon/Composer/Magento/Deploystrategy/Symlink.php +++ b/src/MagentoHackathon/Composer/Magento/Deploystrategy/Symlink.php @@ -20,8 +20,8 @@ class Symlink extends DeploystrategyAbstract */ public function createDelegate($source, $dest) { - $sourcePath = $this->getSourceDir() . '/' . $this->removeTrailingSlash($source); - $destPath = $this->getDestDir() . '/' . $this->removeTrailingSlash($dest); + $sourcePath = $this->getSourceDir() . DIRECTORY_SEPARATOR . $this->removeTrailingSlash($source); + $destPath = $this->getDestDir() . DIRECTORY_SEPARATOR . $this->removeTrailingSlash($dest); if (!is_file($sourcePath) && !is_dir($sourcePath)) { throw new \ErrorException("Could not find path '$sourcePath'"); @@ -60,7 +60,7 @@ public function createDelegate($source, $dest) // Create all directories up to one below the target if they don't exist $destDir = dirname($destPath); if (!file_exists($destDir)) { - mkdir($destDir, 0777, true); + mkdir($destDir, 0755, true); } // Handle source to dir linking, @@ -114,39 +114,34 @@ public function createDelegate($source, $dest) /** * Returns the relative path from $from to $to - * * This is utility method for symlink creation. - * Orig Source: http://stackoverflow.com/a/2638272/485589 + * + * @param string $from + * @param string $to + * + * @return string */ public function getRelativePath($from, $to) { - // Can't use realpath() here since the destination doesn't exist yet - $from = str_replace(array('/./', '//'), '/', $from); - $from = explode('/', $from); + $from = str_replace(['/./', '//', '\\'], '/', $from); + $to = str_replace(['/./', '//', '\\'], '/', $to); - $to = str_replace(array('/./', '//'), '/', $to); - $to = explode('/', $to); + if (is_file($from)) { + $from = dirname($from); + } else { + $from = rtrim($from, '/'); + } - $relPath = $to; + $dir = explode('/', $from); + $file = explode('/', $to); - foreach ($from as $depth => $dir) { - // find first non-matching dir - if ($dir === $to[$depth]) { - // ignore this directory - array_shift($relPath); - } else { - // get number of remaining dirs to $from - $remaining = count($from) - $depth; - if ($remaining > 1) { - // add traversals up to first matching dir - $padLength = (count($relPath) + $remaining - 1) * -1; - $relPath = array_pad($relPath, $padLength, '..'); - break; - } else { - $relPath[0] = './' . $relPath[0]; - } - } + while ($file && $dir && ($dir[0] == $file[0])) { + array_shift($file); + array_shift($dir); } - return implode('/', $relPath); + + // magento_dir/targetdir/childdir => ../../module_dir/sourcedir/childdir + $relativePath = str_repeat('../', count($dir)) . implode('/', $file); + return $relativePath; } } diff --git a/src/MagentoHackathon/Composer/Magento/Installer.php b/src/MagentoHackathon/Composer/Magento/Installer.php index 215b815d..60cc31f6 100644 --- a/src/MagentoHackathon/Composer/Magento/Installer.php +++ b/src/MagentoHackathon/Composer/Magento/Installer.php @@ -15,6 +15,7 @@ use Composer\Installer\InstallerInterface; use Composer\Package\PackageInterface; use MagentoHackathon\Composer\Magento\Deploy\Manager\Entry; +use React\Promise\PromiseInterface; /** * Composer Magento Installer @@ -33,7 +34,7 @@ class Installer extends LibraryInstaller implements InstallerInterface * * @var \SplFileInfo */ - protected $defaultMagentoRootDir = 'root'; + protected $defaultMagentoRootDir = './'; /** * The base directory of the modman packages @@ -59,8 +60,7 @@ class Installer extends LibraryInstaller implements InstallerInterface /** * @var string */ - protected $_deployStrategy = "symlink"; - + protected $_deployStrategy = "copy"; const MAGENTO_REMOVE_DEV_FLAG = 'magento-remove-dev'; const MAGENTO_MAINTANANCE_FLAG = 'maintenance.flag'; @@ -74,15 +74,15 @@ class Installer extends LibraryInstaller implements InstallerInterface protected $removeMagentoDev = false; protected $keepMagentoCache = false; protected $_magentoLocalXmlPath = 'app/etc/local.xml'; - protected $_defaultEnvFilePaths = array( + protected $_defaultEnvFilePaths = [ 'app/etc/local.xml' - ); + ]; protected $_magentoDevDir = 'dev'; - protected $_magentoWritableDirs = array( + protected $_magentoWritableDirs = [ 'app/etc', 'media', 'var' - ); + ]; /** * @var DeployManager @@ -100,12 +100,12 @@ class Installer extends LibraryInstaller implements InstallerInterface * @var bool */ protected $appendGitIgnore = false; - + /** * @var array Path mapping prefixes that need to be translated (i.e. to * use a public directory as the web server root). */ - protected $_pathMappingTranslations = array(); + protected $_pathMappingTranslations = []; /** * Initializes Magento Module installer @@ -124,11 +124,10 @@ public function __construct(IOInterface $io, Composer $composer, $type = 'magent $extra = $composer->getPackage()->getExtra(); - if (isset($extra['magento-root-dir']) || (($rootDirInput = $io->ask('please define your magento root dir [' . $this->defaultMagentoRootDir . '] ', $this->defaultMagentoRootDir)) || $rootDirInput = $this->defaultMagentoRootDir)) { + if (isset($extra['magento-root-dir']) || $rootDirInput = $this->defaultMagentoRootDir) { if (isset($rootDirInput)) { $extra['magento-root-dir'] = $rootDirInput; - $this->updateJsonExtra($extra, $io); } $dir = rtrim(trim($extra['magento-root-dir']), '/\\'); @@ -158,9 +157,12 @@ public function __construct(IOInterface $io, Composer $composer, $type = 'magent if (isset($extra['magento-deploystrategy'])) { $this->_deployStrategy = (string)$extra['magento-deploystrategy']; + if($this->_deployStrategy !== "copy"){ + $io->write("Warning: Magento 2 is not tested with \"{$this->_deployStrategy}\" deployment strategy. It may not function properly."); + } } - if ((is_null($this->magentoRootDir) || false === $this->magentoRootDir->isDir()) + if (($this->magentoRootDir === null || false === $this->magentoRootDir->isDir()) && $this->_deployStrategy != 'none' ) { $dir = $this->magentoRootDir instanceof \SplFileInfo ? $this->magentoRootDir->getPathname() : ''; @@ -174,6 +176,10 @@ public function __construct(IOInterface $io, Composer $composer, $type = 'magent $this->isForced = (bool)$extra['magento-force']; } + if (false !== getenv('MAGENTO_CLOUD_PROJECT')) { + $this->setDeployStrategy('none'); + } + if (isset($extra['magento-deploystrategy'])) { $this->setDeployStrategy((string)$extra['magento-deploystrategy']); } @@ -185,7 +191,6 @@ public function __construct(IOInterface $io, Composer $composer, $type = 'magent if (!empty($extra['path-mapping-translations'])) { $this->_pathMappingTranslations = (array)$extra['path-mapping-translations']; } - } @@ -197,7 +202,7 @@ public function setDeployManager( DeployManager $deployManager) $this->deployManager = $deployManager; } - + public function setConfig( ProjectConfig $config ) { $this->config = $config; @@ -210,7 +215,7 @@ public function getDeployManager() { return $this->deployManager; } - + /** * Create base requrements for project installation */ @@ -223,7 +228,7 @@ protected function initializeMagentoRootDir() { $pathParts = array_merge($baseDir, $pathParts); $directoryPath = ''; foreach ($pathParts as $pathPart) { - $directoryPath .= DIRECTORY_SEPARATOR . $pathPart; + $directoryPath .= $pathPart . DIRECTORY_SEPARATOR; $this->filesystem->ensureDirectoryExists($directoryPath); } } @@ -262,7 +267,7 @@ private function updateJsonExtra($extra, $io) { $composer = $json->read(); $composerBackup = file_get_contents($json->getPath()); $extraKey = 'extra'; - $baseExtra = array_key_exists($extraKey, $composer) ? $composer[$extraKey] : array(); + $baseExtra = array_key_exists($extraKey, $composer) ? $composer[$extraKey] : []; if (!$this->updateFileCleanly($json, $baseExtra, $extra, $extraKey)) { foreach ($extra as $key => $value) { @@ -317,7 +322,7 @@ public function getDeployStrategy(PackageInterface $package, $strategy = null) $strategy = $moduleSpecificDeployStrategys[$package->getName()]; } } - $moduleSpecificDeployIgnores = array(); + $moduleSpecificDeployIgnores = []; if( isset($extra['magento-deploy-ignore']) ){ $extra['magento-deploy-ignore'] = $this->transformArrayKeysToLowerCase($extra['magento-deploy-ignore']); if( isset($extra['magento-deploy-ignore']["*"]) ){ @@ -325,7 +330,7 @@ public function getDeployStrategy(PackageInterface $package, $strategy = null) } if( isset($extra['magento-deploy-ignore'][$package->getName()]) ){ $moduleSpecificDeployIgnores = array_merge( - $moduleSpecificDeployIgnores, + $moduleSpecificDeployIgnores, $extra['magento-deploy-ignore'][$package->getName()] ); } @@ -336,8 +341,8 @@ public function getDeployStrategy(PackageInterface $package, $strategy = null) $targetDir = $this->getTargetDir(); $sourceDir = $this->getSourceDir($package); switch ($strategy) { - case 'copy': - $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\Copy($sourceDir, $targetDir); + case 'symlink': + $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\Symlink($sourceDir, $targetDir); break; case 'link': $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\Link($sourceDir, $targetDir); @@ -345,9 +350,9 @@ public function getDeployStrategy(PackageInterface $package, $strategy = null) case 'none': $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\None($sourceDir, $targetDir); break; - case 'symlink': + case 'copy': default: - $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\Symlink($sourceDir, $targetDir); + $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\Copy($sourceDir, $targetDir); } // Inject isForced setting from extra config $impl->setIsForced($this->isForced); @@ -363,7 +368,7 @@ public function getDeployStrategy(PackageInterface $package, $strategy = null) */ public function supports($packageType) { - return 'magento-module' === $packageType || 'magento-core' === $packageType; + return array_key_exists($packageType, PackageTypes::$packageTypes); } /** @@ -383,38 +388,46 @@ protected function getSourceDir(PackageInterface $package) * * @return string */ - protected function getTargetDir() + public function getTargetDir() { $targetDir = realpath($this->magentoRootDir->getPathname()); return $targetDir; } /** - * Installs specific package - * - * @param InstalledRepositoryInterface $repo repository in which to check - * @param PackageInterface $package package instance + * @inheritdoc */ public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { - if ($package->getType() === 'magento-core' && !$this->preInstallMagentoCore()) { return; } - parent::install($repo, $package); + $afterInstall = function () use ($package) { + // skip marshal and apply default behavior if extra->map does not exist + if ($this->hasExtraMap($package)) { + $strategy = $this->getDeployStrategy($package); + $strategy->setMappings($this->getParser($package)->getMappings()); + $deployManagerEntry = new Entry(); + $deployManagerEntry->setPackageName($package->getName()); + $deployManagerEntry->setDeployStrategy($strategy); + $this->deployManager->addPackage($deployManagerEntry); + + if ($this->appendGitIgnore) { + $this->appendGitIgnore($package, $this->getGitIgnoreFileLocation()); + } + } + }; - $strategy = $this->getDeployStrategy($package); - $strategy->setMappings($this->getParser($package)->getMappings()); - $deployManagerEntry = new Entry(); - $deployManagerEntry->setPackageName($package->getName()); - $deployManagerEntry->setDeployStrategy($strategy); - $this->deployManager->addPackage($deployManagerEntry); + $promise = parent::install($repo, $package); - if ($this->appendGitIgnore) { - $this->appendGitIgnore($package, $this->getGitIgnoreFileLocation()); + // Composer v2 might return a promise here + if ($promise instanceof PromiseInterface) { + return $promise->then($afterInstall); } + // If not, execute the code right away as parent::install executed synchronously (composer v1, or v2 without async) + $afterInstall(); } /** @@ -439,12 +452,12 @@ public function getGitIgnoreFileLocation() */ public function appendGitIgnore(PackageInterface $package, $ignoreFile) { - $contents = array(); + $contents = []; if(file_exists($ignoreFile)) { $contents = file($ignoreFile, FILE_IGNORE_NEW_LINES); } - $additions = array(); + $additions = []; foreach($this->getParser($package)->getMappings() as $map) { $dest = $map[1]; $ignore = sprintf("/%s", $dest); @@ -456,7 +469,7 @@ public function appendGitIgnore(PackageInterface $package, $ignoreFile) if( in_array($ignore, $ignoredMappings) ){ continue; } - + $additions[] = $ignore; } } @@ -466,7 +479,7 @@ public function appendGitIgnore(PackageInterface $package, $ignoreFile) $contents = array_merge($contents, $additions); file_put_contents($ignoreFile, implode("\n", $contents)); } - + if ($package->getType() === 'magento-core') { $this->prepareMagentoCore(); } @@ -582,41 +595,56 @@ protected function redeployProject() { } /** - * Updates specific package - * - * @param InstalledRepositoryInterface $repo repository in which to check - * @param PackageInterface $initial already installed package version - * @param PackageInterface $target updated version - * - * @throws InvalidArgumentException if $from package is not installed + * @inheritdoc */ public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { - if ($target->getType() === 'magento-core' && !$this->preUpdateMagentoCore()) { return; } - $initialStrategy = $this->getDeployStrategy($initial); - $initialStrategy->setMappings($this->getParser($initial)->getMappings()); - $initialStrategy->clean(); + // cleanup marshaled files if extra->map exist + if ($this->hasExtraMap($initial)) { + $initialStrategy = $this->getDeployStrategy($initial); + $initialStrategy->setMappings($this->getParser($initial)->getMappings()); + try { + $initialStrategy->clean(); + } catch (\ErrorException $e) { + if ($this->io->isDebug()) { + $this->io->write($e->getMessage()); + } + } + } - parent::update($repo, $initial, $target); + $afterUpdate = function () use ($target) { + // marshal files for new package version if extra->map exist + if ($this->hasExtraMap($target)) { + $targetStrategy = $this->getDeployStrategy($target); + $targetStrategy->setMappings($this->getParser($target)->getMappings()); + $deployManagerEntry = new Entry(); + $deployManagerEntry->setPackageName($target->getName()); + $deployManagerEntry->setDeployStrategy($targetStrategy); + $this->deployManager->addPackage($deployManagerEntry); + } - $targetStrategy = $this->getDeployStrategy($target); - $targetStrategy->setMappings($this->getParser($target)->getMappings()); - $deployManagerEntry = new Entry(); - $deployManagerEntry->setPackageName($target->getName()); - $deployManagerEntry->setDeployStrategy($targetStrategy); - $this->deployManager->addPackage($deployManagerEntry); + if($this->appendGitIgnore) { + $this->appendGitIgnore($target, $this->getGitIgnoreFileLocation()); + } - if($this->appendGitIgnore) { - $this->appendGitIgnore($target, $this->getGitIgnoreFileLocation()); - } + if ($target->getType() === 'magento-core') { + $this->postUpdateMagentoCore(); + } + }; + + $promise = parent::update($repo, $initial, $target); - if ($target->getType() === 'magento-core') { - $this->postUpdateMagentoCore(); + // Composer v2 might return a promise here + if ($promise instanceof PromiseInterface) { + return $promise->then($afterUpdate); } + + // If not, execute the code right away as parent::update executed synchronously (composer v1, or v2 without async) + $afterUpdate(); } @@ -641,7 +669,7 @@ protected function postUpdateMagentoCore() { $this->filesystem->rename($origRootDir, $backupDir); $this->filesystem->rename($tmpDir, $origRootDir); $this->magentoRootDir = clone $this->originalMagentoRootDir; - + $this->prepareMagentoCore(); $this->cleanupPostUpdateMagentoCore(); } @@ -649,7 +677,7 @@ protected function postUpdateMagentoCore() { protected function cleanupPostUpdateMagentoCore() { $rootDir = $this->magentoRootDir->getPathname(); $backupDir = $this->backupMagentoRootDir->getPathname(); - $persistentFolders = array('media', 'var'); + $persistentFolders = ['media', 'var']; copy($backupDir . DIRECTORY_SEPARATOR . $this->_magentoLocalXmlPath, $rootDir . DIRECTORY_SEPARATOR . $this->_magentoLocalXmlPath); foreach ($persistentFolders as $folder) { $this->filesystem->removeDirectory($rootDir . DIRECTORY_SEPARATOR . $folder); @@ -687,18 +715,24 @@ public function clearMagentoCache() { } /** - * Uninstalls specific package. - * - * @param InstalledRepositoryInterface $repo repository in which to check - * @param PackageInterface $package package instance + * @inheritdoc */ public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) { - $strategy = $this->getDeployStrategy($package); - $strategy->setMappings($this->getParser($package)->getMappings()); - $strategy->clean(); + // skip marshal and apply default behavior if extra->map does not exist + if ($this->hasExtraMap($package)) { + $strategy = $this->getDeployStrategy($package); + $strategy->setMappings($this->getParser($package)->getMappings()); + try { + $strategy->clean(); + } catch (\ErrorException $e) { + if ($this->io->isDebug()) { + $this->io->write($e->getMessage()); + } + } + } - parent::uninstall($repo, $package); + return parent::uninstall($repo, $package); } /** @@ -718,18 +752,23 @@ public function getParser(PackageInterface $package) $map = $moduleSpecificMap[$package->getName()]; } } - + $suffix = $package->getType() ? PackageTypes::$packageTypes[$package->getType()] : ''; if (isset($map)) { - $parser = new MapParser($map, $this->_pathMappingTranslations); + $parser = new MapParser($map, $this->_pathMappingTranslations, $suffix); return $parser; } elseif (isset($extra['map'])) { - $parser = new MapParser($extra['map'], $this->_pathMappingTranslations); + $parser = new MapParser($extra['map'], $this->_pathMappingTranslations, $suffix); return $parser; } elseif (isset($extra['package-xml'])) { - $parser = new PackageXmlParser($this->getSourceDir($package), $extra['package-xml'], $this->_pathMappingTranslations); + $parser = new PackageXmlParser( + $this->getSourceDir($package), + $extra['package-xml'], + $this->_pathMappingTranslations, + $suffix + ); return $parser; } elseif (file_exists($this->getSourceDir($package) . '/modman')) { - $parser = new ModmanParser($this->getSourceDir($package), $this->_pathMappingTranslations); + $parser = new ModmanParser($this->getSourceDir($package), $this->_pathMappingTranslations, $suffix); return $parser; } else { throw new \ErrorException('Unable to find deploy strategy for module: no known mapping'); @@ -742,8 +781,7 @@ public function getParser(PackageInterface $package) */ public function getInstallPath(PackageInterface $package) { - - if (!is_null($this->modmanRootDir) && true === $this->modmanRootDir->isDir()) { + if ($this->modmanRootDir !== null && true === $this->modmanRootDir->isDir()) { $targetDir = $package->getTargetDir(); if (!$targetDir) { list($vendor, $targetDir) = explode('/', $package->getPrettyName()); @@ -760,10 +798,10 @@ public function getInstallPath(PackageInterface $package) return $installPath; } - + public function transformArrayKeysToLowerCase($array) { - $arrayNew = array(); + $arrayNew = []; foreach($array as $key=>$value){ $arrayNew[strtolower($key)] = $value; } @@ -774,7 +812,7 @@ public function transformArrayKeysToLowerCase($array) * this function is for annoying people with messages. * * First usage: get people to vote about the future release of composer so later I can say "you wanted it this way" - * + * * @param IOInterface $io */ public function annoy(IOInterface $io) @@ -787,7 +825,22 @@ public function annoy(IOInterface $io) $io->write(' time for voting about the future of the #magento #composer installer. ', true); $io->write(' https://github.com/magento-hackathon/magento-composer-installer/blob/discussion-master/Milestone/2/index.md ', true); $io->write(' For the case you don\'t vote, I will ignore your problems till iam finished with the resulting release. ', true); - * + * **/ } + + /** + * Checks if package has extra map value set + * + * @param PackageInterface $package + * @return bool + */ + private function hasExtraMap(PackageInterface $package) { + $packageExtra = $package->getExtra(); + if (isset($packageExtra['map'])) { + return true; + } + + return false; + } } diff --git a/src/MagentoHackathon/Composer/Magento/MapParser.php b/src/MagentoHackathon/Composer/Magento/MapParser.php index 080f00f9..f76e934d 100644 --- a/src/MagentoHackathon/Composer/Magento/MapParser.php +++ b/src/MagentoHackathon/Composer/Magento/MapParser.php @@ -7,11 +7,11 @@ class MapParser extends PathTranslationParser { - protected $_mappings = array(); + protected $_mappings = []; - function __construct( $mappings, $translations = array() ) + function __construct($mappings, $translations = [], $pathSuffix = '') { - parent::__construct($translations); + parent::__construct($translations, $pathSuffix); $this->setMappings($mappings); } diff --git a/src/MagentoHackathon/Composer/Magento/ModmanParser.php b/src/MagentoHackathon/Composer/Magento/ModmanParser.php index b7722b89..af305a65 100644 --- a/src/MagentoHackathon/Composer/Magento/ModmanParser.php +++ b/src/MagentoHackathon/Composer/Magento/ModmanParser.php @@ -25,9 +25,9 @@ class ModmanParser extends PathTranslationParser * * @param string $moduleDir */ - public function __construct($moduleDir = null, $translations = array()) + public function __construct($moduleDir = null, $translations = [], $pathSuffix = '') { - parent::__construct($translations); + parent::__construct($translations, $pathSuffix); $this->setModuleDir($moduleDir); $this->setFile($this->getModmanFile()); @@ -42,7 +42,7 @@ public function __construct($moduleDir = null, $translations = array()) public function setModuleDir($moduleDir) { // Remove trailing slash - if (!is_null($moduleDir)) { + if ($moduleDir !== null) { $moduleDir = rtrim($moduleDir, '\\/'); } @@ -85,7 +85,7 @@ public function getFile() public function getModmanFile() { $file = null; - if (!is_null($this->_moduleDir)) { + if ($this->_moduleDir !== null) { $file = new \SplFileObject($this->_moduleDir . '/modman'); } return $file; @@ -114,13 +114,13 @@ public function getMappings() */ protected function _parseMappings() { - $map = array(); + $map = []; $line = 0; foreach ($this->_file as $row) { $line++; $row = trim($row); - if ('' === $row || in_array($row[0], array('#', '@'))) { + if ('' === $row || in_array($row[0], ['#', '@'])) { continue; } $parts = preg_split('/\s+/', $row, 2, PREG_SPLIT_NO_EMPTY); diff --git a/src/MagentoHackathon/Composer/Magento/PackageTypes.php b/src/MagentoHackathon/Composer/Magento/PackageTypes.php new file mode 100644 index 00000000..45e6df0b --- /dev/null +++ b/src/MagentoHackathon/Composer/Magento/PackageTypes.php @@ -0,0 +1,22 @@ + '/app/code/', + 'magento2-theme' => '/app/design/', + 'magento2-library' => '/lib/internal/', + 'magento2-language' => '/app/i18n/', + 'magento2-component'=> './', + ]; +} diff --git a/src/MagentoHackathon/Composer/Magento/PackageXmlParser.php b/src/MagentoHackathon/Composer/Magento/PackageXmlParser.php index a8db7216..0fbf98a3 100644 --- a/src/MagentoHackathon/Composer/Magento/PackageXmlParser.php +++ b/src/MagentoHackathon/Composer/Magento/PackageXmlParser.php @@ -23,19 +23,19 @@ class PackageXmlParser extends PathTranslationParser /** * @var array Map of package content types to path prefixes */ - protected $_targets = array(); + protected $_targets = []; /** * Constructor * * @param string $moduleDir * @param string $packageXmlFile - * @param array $translations + * @param array $translations + * @param string $pathSuffix */ - public function __construct($moduleDir, $packageXmlFile, $translations = array()) + public function __construct($moduleDir, $packageXmlFile, $translations = [], $pathSuffix = '') { - parent::__construct($translations); - + parent::__construct($translations, $pathSuffix); $this->setModuleDir($moduleDir); $this->setFile($this->getModuleDir() . '/' . $packageXmlFile); } @@ -49,7 +49,7 @@ public function __construct($moduleDir, $packageXmlFile, $translations = array() public function setModuleDir($moduleDir) { // Remove trailing slash - if (!is_null($moduleDir)) { + if ($moduleDir !== null) { $moduleDir = rtrim($moduleDir, '\\/'); } @@ -109,7 +109,7 @@ public function getMappings() */ protected function _parseMappings() { - $map = array(); + $map = []; /** @var $package SimpleXMLElement */ $package = simplexml_load_file($this->getFile()->getPathname()); @@ -121,7 +121,7 @@ protected function _parseMappings() foreach ($target->children() as $child) { foreach ($this->getElementPaths($child) as $elementPath) { $relativePath = $basePath . '/' . $elementPath; - $map[] = array($relativePath, $relativePath); + $map[] = [$relativePath, $relativePath]; } } @@ -175,7 +175,7 @@ protected function getTargetsDefinitions() protected function getElementPaths(\SimpleXMLElement $element) { $type = $element->getName(); $name = $element->attributes()->name; - $elementPaths = array(); + $elementPaths = []; switch ($type) { case 'dir': diff --git a/src/MagentoHackathon/Composer/Magento/PathTranslationParser.php b/src/MagentoHackathon/Composer/Magento/PathTranslationParser.php index cb21f466..8beb0fec 100644 --- a/src/MagentoHackathon/Composer/Magento/PathTranslationParser.php +++ b/src/MagentoHackathon/Composer/Magento/PathTranslationParser.php @@ -12,22 +12,25 @@ abstract class PathTranslationParser implements Parser * @var array Variants on each prefix that path mappings are checked * against. */ - protected $pathPrefixVariants = array('', './'); + protected $pathPrefixVariants = ['', './']; /** * @var array Path mapping prefixes that need to be translated (i.e. to * use a public directory as the web server root). */ - protected $pathPrefixTranslations = array(); + protected $pathPrefixTranslations = []; + + protected $pathSuffix; /** * Constructor. Sets the list of path translations to use. * * @param array $translations Path translations */ - public function __construct($translations) + public function __construct($translations, $pathSuffix) { $this->pathPrefixTranslations = $this->createPrefixVariants($translations); + $this->pathSuffix = $pathSuffix; } /** @@ -40,7 +43,7 @@ public function __construct($translations) */ protected function createPrefixVariants($translations) { - $newTranslations = array(); + $newTranslations = []; foreach($translations as $key => $value) { foreach($this->pathPrefixVariants as $variant) { $newTranslations[$variant.$key] = $value; @@ -76,8 +79,9 @@ public function translatePathMappings($mappings) break; } } + //Adding path Suffix to the mapping info. + $mapping[1] = $this->pathSuffix . $mapping[1]; } - return $mappings; } } diff --git a/src/MagentoHackathon/Composer/Magento/Plugin.php b/src/MagentoHackathon/Composer/Magento/Plugin.php index 7e15a04a..0145596a 100644 --- a/src/MagentoHackathon/Composer/Magento/Plugin.php +++ b/src/MagentoHackathon/Composer/Magento/Plugin.php @@ -1,9 +1,9 @@ deployManager = new DeployManager( $io ); - - $extra = $composer->getPackage()->getExtra(); - $sortPriority = isset($extra['magento-deploy-sort-priority']) ? $extra['magento-deploy-sort-priority'] : array(); - $this->deployManager->setSortPriority( $sortPriority ); - + $this->deployManager = new DeployManager($io); + + $extra = $composer->getPackage()->getExtra(); + $sortPriority = $extra['magento-deploy-sort-priority'] ?? []; + $this->deployManager->setSortPriority($sortPriority); + } - + public function activate(Composer $composer, IOInterface $io) { - $this->io = $io; + $this->io = $io; $this->composer = $composer; - $this->filesystem = new Filesystem(); - $this->config = new ProjectConfig( $composer->getPackage()->getExtra() ); - $installer = new Installer($io, $composer); + $this->filesystem = new Filesystem(); + $this->config = new ProjectConfig($composer->getPackage()->getExtra()); + $this->installer = new Installer($io, $composer); $this->initDeployManager($composer, $io); - $installer->setDeployManager( $this->deployManager ); - $installer->setConfig( $this->config ); - if( $this->io->isDebug() ){ + $this->installer->setDeployManager($this->deployManager); + $this->installer->setConfig($this->config); + if ($this->io->isDebug()) { $this->io->write('activate magento plugin'); } - $composer->getInstallationManager()->addInstaller($installer); + $composer->getInstallationManager()->addInstaller($this->installer); } public static function getSubscribedEvents() { - return array( - PluginEvents::COMMAND => array( - array('onCommandEvent', 0), - ), - ScriptEvents::POST_INSTALL_CMD => array( - array('onNewCodeEvent', 0), - ), - ScriptEvents::POST_UPDATE_CMD => array( - array('onNewCodeEvent', 0), - ), - ); + return [ + PluginEvents::COMMAND => [ + ['onCommandEvent', 1], + ], + ScriptEvents::POST_INSTALL_CMD => [ + ['onNewCodeEvent', 1], + ], + ScriptEvents::POST_UPDATE_CMD => [ + ['onNewCodeEvent', 1], + ], + PackageEvents::POST_PACKAGE_UNINSTALL => [ + ['onPackageUnistall', 0], + ] + ]; } + public function onPackageUnistall(\Composer\Installer\PackageEvent $event) + { + $ds = DIRECTORY_SEPARATOR; + $package = $event->getOperation()->getPackage(); + list($vendor, $packageName) = explode('/', $package->getPrettyName()); + $packageName = trim(str_replace('module-', '', $packageName)); + $packageInstallationPath = $packageInstallationPath = $this->installer->getTargetDir(); + $packagePath = ucfirst($vendor) . $ds . str_replace(' ', '', ucwords(str_replace('-', ' ', $packageName))); + $this->io->write("Removing $packagePath"); + $libPath = 'lib' . $ds . 'internal' . $ds . $packagePath; + $magentoPackagePath = 'app' . $ds . 'code' . $ds . $packagePath; + $deployStrategy = $this->installer->getDeployStrategy($package); + $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $libPath); + $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $magentoPackagePath); + $this->requestRegeneration(); + } /** * actually is triggered before anything got executed - * + * * @param \Composer\Plugin\CommandEvent $event */ - public function onCommandEvent( \Composer\Plugin\CommandEvent $event ) + public function onCommandEvent(\Composer\Plugin\CommandEvent $event) { $command = $event->getCommandName(); } /** * event listener is named this way, as it listens for events leading to changed code files - * - * @param \Composer\Script\CommandEvent $event + * + * @param \Composer\Script\Event $event */ - public function onNewCodeEvent( \Composer\Script\CommandEvent $event ) + public function onNewCodeEvent(\Composer\Script\Event $event) { - if( $this->io->isDebug() ){ + if ($this->io->isDebug()) { $this->io->write('start magento deploy via deployManager'); } - $command = $event->getName(); + $this->deployManager->doDeploy(); $this->deployLibraries(); + $this->saveVendorDirPath($event->getComposer()); + $this->requestRegeneration(); + $this->setFilePermissions(); + } + + /** + * Set permissions for files using extra->chmod from composer.json + * + * @return void + */ + private function setFilePermissions() + { + $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(); + $message = 'Check "chmod" section in composer.json of %s package.'; + + foreach ($packages as $package) { + $extra = $package->getExtra(); + if (!isset($extra['chmod']) || !is_array($extra['chmod'])) { + continue; + } + + $error = false; + foreach ($extra['chmod'] as $chmod) { + if (!isset($chmod['mask']) || !isset($chmod['path']) || strpos($chmod['path'], '..') !== false) { + $error = true; + continue; + } + + $file = $this->installer->getTargetDir() . '/' . $chmod['path']; + if (file_exists($file)) { + chmod($file, octdec($chmod['mask'])); + } else { + $this->io->writeError([ + 'File doesn\'t exist: ' . $chmod['path'], + sprintf($message, $package->getName()) + ]); + } + } + + if ($error) { + $this->io->writeError([ + 'Incorrect mask or file path.', + sprintf($message, $package->getName()) + ]); + } + } } - - + protected function deployLibraries() { $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(); - $autoloadDirectories = array(); - + $autoloadDirectories = []; + $libraryPath = $this->config->getLibraryPath(); - if( $libraryPath === null ){ - if( $this->io->isDebug() ){ + if ($libraryPath === null) { + if ($this->io->isDebug()) { $this->io->write('jump over deployLibraries as no Magento libraryPath is set'); } return; @@ -139,50 +218,50 @@ protected function deployLibraries() $vendorDir = rtrim($this->composer->getConfig()->get('vendor-dir'), '/'); - - $filesystem = $this->filesystem; + + $filesystem = $this->filesystem; $filesystem->removeDirectory($libraryPath); $filesystem->ensureDirectoryExists($libraryPath); - foreach( $packages as $package ){ + foreach ($packages as $package) { /** @var PackageInterface $package */ - $packageConfig = $this->config->getLibraryConfigByPackagename( $package->getName() ); - if( $packageConfig === null ){ + $packageConfig = $this->config->getLibraryConfigByPackagename($package->getName()); + if ($packageConfig === null) { continue; } - if( !isset($packageConfig['autoload']) ){ - $packageConfig['autoload'] = array('/'); + if (!isset($packageConfig['autoload'])) { + $packageConfig['autoload'] = ['/']; } - foreach($packageConfig['autoload'] as $path){ - $autoloadDirectories[] = $libraryPath.'/'.$package->getName()."/".$path; + foreach ($packageConfig['autoload'] as $path) { + $autoloadDirectories[] = $libraryPath . '/' . $package->getName() . "/" . $path; } - if( $this->io->isDebug() ){ - $this->io->write('Magento deployLibraries executed for '.$package->getName()); + if ($this->io->isDebug()) { + $this->io->write('Magento deployLibraries executed for ' . $package->getName()); } - $libraryTargetPath = $libraryPath.'/'.$package->getName(); + $libraryTargetPath = $libraryPath . '/' . $package->getName(); $filesystem->removeDirectory($libraryTargetPath); $filesystem->ensureDirectoryExists($libraryTargetPath); - $this->copyRecursive($vendorDir.'/'.$package->getPrettyName(), $libraryTargetPath); - + $this->copyRecursive($vendorDir . '/' . $package->getPrettyName(), $libraryTargetPath); + } - - $autoloadGenerator = new AutoloadGenerator( new EventDispatcher($this->composer,$this->io) ); - $classmap = ClassMapGenerator::createMap($libraryPath); - $executable = $this->composer->getConfig()->get('bin-dir') .'/phpab'; - if( !file_exists($executable) ){ - $executable = $this->composer->getConfig()->get('vendor-dir') .'/theseer/autoload/composer/bin/phpab'; + + $autoloadGenerator = new AutoloadGenerator(new EventDispatcher($this->composer, $this->io)); + $classmap = ClassMapGenerator::createMap($libraryPath); + $executable = $this->composer->getConfig()->get('bin-dir') . '/phpab'; + if (!file_exists($executable)) { + $executable = $this->composer->getConfig()->get('vendor-dir') . '/theseer/autoload/composer/bin/phpab'; } - if( file_exists($executable) ){ - if( $this->io->isDebug() ){ + if (file_exists($executable)) { + if ($this->io->isDebug()) { $this->io->write('Magento deployLibraries executes autoload generator'); } - $process = new Process( $executable." -o {$libraryPath}/autoload.php ".implode(' ',$autoloadDirectories)); + $process = new Process($executable . " -o {$libraryPath}/autoload.php " . implode(' ', $autoloadDirectories)); $process->run(); - }else{ - if( $this->io->isDebug() ){ + } else { + if ($this->io->isDebug()) { $this->io->write('Magento deployLibraries autoload generator not availabel, you should require "theseer/autoload"'); - var_dump( $executable, getcwd()); - + var_dump($executable, getcwd()); + } } @@ -190,13 +269,12 @@ protected function deployLibraries() } - /** * Copy then delete is a non-atomic version of {@link rename}. * * Some systems can't rename and also don't have proc_open, * which requires this solution. - * + * * copied from \Composer\Util\Filesystem::copyThenRemove and removed the remove part * * @param string $source @@ -219,4 +297,56 @@ protected function copyRecursive($source, $target) } + /** + * Generate file with path to Composer 'vendor' dir to be used by the application + * + * @param \Composer\Composer $composer + * @throws \UnexpectedValueException + */ + private function saveVendorDirPath(Composer $composer) + { + $magentoDir = $this->installer->getTargetDir(); + $vendorDirPath = $this->filesystem->findShortestPath( + $magentoDir, + realpath($composer->getConfig()->get('vendor-dir')), + true + ); + $vendorPathFile = $magentoDir . '/app/etc/vendor_path.php'; + $content = <<installer->getTargetDir() . $this->varFolder)) { + $filename = $this->installer->getTargetDir() . $this->varFolder . $this->regenerate; + touch($filename); + } + } + + /** + * @inheritdoc + */ + public function deactivate(Composer $composer, IOInterface $io) + { + } + + /** + * @inheritdoc + */ + public function uninstall(Composer $composer, IOInterface $io) + { + } } diff --git a/src/MagentoHackathon/Composer/Magento/ProjectConfig.php b/src/MagentoHackathon/Composer/Magento/ProjectConfig.php index 9a4827f5..05878621 100644 --- a/src/MagentoHackathon/Composer/Magento/ProjectConfig.php +++ b/src/MagentoHackathon/Composer/Magento/ProjectConfig.php @@ -22,7 +22,8 @@ public function __construct( $extra ) } } - protected function fetchVarFromConfigArray( $array, $key, $default=null ){ + protected function fetchVarFromConfigArray($array, $key, $default = null) + { $result = $default; if( isset($array[$key]) ){ $result = $array[$key]; diff --git a/tests/FullStackTest/home/composer.json b/tests/FullStackTest/home/composer.json index 7d6be2c7..e7cdfc98 100644 --- a/tests/FullStackTest/home/composer.json +++ b/tests/FullStackTest/home/composer.json @@ -1,18 +1,14 @@ { "repositories": [ - { - "type": "composer", - "url": "http://packages.firegento.com" - }, { "type": "artifact", "url": "../artifact/" } ], "require": { - "magento-hackathon/magento-composer-installer": "*" + "magento/magento-composer-installer": "*" }, "extra": { - + "magento-root-dir": "root" } } diff --git a/tests/FullStackTest/magento-modules/composer_1.json b/tests/FullStackTest/magento-modules/composer_1.json index f7c5d2fe..7ff41180 100644 --- a/tests/FullStackTest/magento-modules/composer_1.json +++ b/tests/FullStackTest/magento-modules/composer_1.json @@ -1,30 +1,19 @@ { "require": { - "fbrnc/aoe_templatehints": "*", - "fbrnc/aoe_profiler": "*", - "magento-hackathon/magento-composer-installer": "*", + "magento/magento2-module-mock": "1.*", + "magento/magento-composer-installer": "100.100.100", "theseer/autoload": "~1.14", "zetacomponents/console-tools": "dev-master", - "firegento/psr0autoloader": "dev-master", - "connect20/aw_blog": "*", - "connect20/aw_onpulse": "*", - "connect20/aw_aheadmetrics": "*", - "connect20/aw_fps": "*", - "magento-hackathon/magento-composer-installer-test-issue-87": "1.*", - "magento-hackathon/magento-composer-installer-test-updateFileRemove": "1.*", - "magento-hackathon/magento-composer-installer-test-wildcard": "1.*", - "magento-hackathon/magento-composer-installer-test-library": "1.*", - "firegento/magesetup": "*" + "magento/magento-composer-installer-test-issue-87": "1.*", + "magento/magento-composer-installer-test-update-file-remove": "1.*", + "magento/magento-composer-installer-test-wildcard": "1.*", + "magento/magento-composer-installer-test-library": "1.*" }, "require-dev": { - "magento-hackathon/composer-command-integrator": "*", - "composer/composer": "dev-master" + + "composer/composer": "dev-main" }, "repositories": [ - { - "type": "composer", - "url": "http://packages.firegento.com" - }, { "type": "artifact", "url": "../artifact/" @@ -36,7 +25,7 @@ "magento-project": { "libraryPath": "../htdocs/composer_lib/", "libraries": { - "magento-hackathon/magento-composer-installer-test-library": {} + "magento/magento-composer-installer-test-library": {} } }, "magento-root-dir": "../htdocs/" diff --git a/tests/FullStackTest/magento-modules/composer_1_copy.json b/tests/FullStackTest/magento-modules/composer_1_copy.json index 70c021cb..b8f607b5 100644 --- a/tests/FullStackTest/magento-modules/composer_1_copy.json +++ b/tests/FullStackTest/magento-modules/composer_1_copy.json @@ -1,32 +1,20 @@ { "require": { - "fbrnc/aoe_templatehints": "*", - "fbrnc/aoe_profiler": "*", - "magento-hackathon/magento-composer-installer": "*", + "magento/magento2-module-mock": "1.*", + "magento/magento-composer-installer": "100.100.100", "theseer/autoload": "~1.14", "zetacomponents/console-tools": "dev-master", - "firegento/psr0autoloader": "dev-master", - "connect20/aw_blog": "*", - "connect20/aw_onpulse": "*", - "connect20/aw_aheadmetrics": "*", - "connect20/aw_fps": "*", - "magento-hackathon/magento-composer-installer-test-issue-87": "1.*", - "magento-hackathon/magento-composer-installer-test-updateFileRemove": "1.*", - "magento-hackathon/magento-composer-installer-test-wildcard": "1.*", - "magento-hackathon/magento-composer-installer-test-wildcard2": "1.*", - "magento-hackathon/magento-composer-installer-test-library": "1.*", - "firegento/magesetup": "*" + "magento/magento-composer-installer-test-issue-87": "1.*", + "magento/magento-composer-installer-test-update-file-remove": "1.*", + "magento/magento-composer-installer-test-wildcard": "1.*", + "magento/magento-composer-installer-test-wildcard2": "1.*", + "magento/magento-composer-installer-test-library": "1.*" }, "require-dev": { - "magento-hackathon/composer-command-integrator": "*", - "composer/composer": "dev-master" + "composer/composer": "dev-main" }, "repositories": [ { - "type": "composer", - "url": "http://packages.firegento.com" - }, - { "type": "artifact", "url": "../artifact/" } @@ -37,7 +25,7 @@ "magento-project": { "libraryPath": "../htdocs/composer_lib/", "libraries": { - "magento-hackathon/magento-composer-installer-test-library": {} + "magento/magento-composer-installer-test-library": {} } }, "magento-root-dir": "../htdocs/" diff --git a/tests/FullStackTest/magento-modules/composer_1_copy_force.json b/tests/FullStackTest/magento-modules/composer_1_copy_force.json index b4e260ec..cc8ee37a 100644 --- a/tests/FullStackTest/magento-modules/composer_1_copy_force.json +++ b/tests/FullStackTest/magento-modules/composer_1_copy_force.json @@ -1,35 +1,23 @@ { "require": { - "fbrnc/aoe_templatehints": "*", - "fbrnc/aoe_profiler": "*", - "magento-hackathon/magento-composer-installer": "*", + "magento/magento2-module-mock": "1.*", + "magento/magento-composer-installer": "100.100.100", "theseer/autoload": "~1.14", "zetacomponents/console-tools": "dev-master", - "firegento/psr0autoloader": "dev-master", - "connect20/aw_blog": "*", - "connect20/aw_onpulse": "*", - "connect20/aw_aheadmetrics": "*", - "connect20/aw_fps": "*", - "magento-hackathon/magento-composer-installer-test-issue-87": "1.*", - "magento-hackathon/magento-composer-installer-test-updateFileRemove": "1.*", - "magento-hackathon/magento-composer-installer-test-wildcard": "1.*", - "magento-hackathon/magento-composer-installer-test-wildcard2": "1.*", - "magento-hackathon/magento-composer-installer-test-library": "1.*", - "magento-hackathon/magento-composer-installer-test-sort1": "1.*", - "magento-hackathon/magento-composer-installer-test-sort2": "1.*", - "magento-hackathon/magento-composer-installer-test-sort3": "1.*", - "firegento/magesetup": "*" + "magento/magento-composer-installer-test-issue-87": "1.*", + "magento/magento-composer-installer-test-update-file-remove": "1.*", + "magento/magento-composer-installer-test-wildcard": "1.*", + "magento/magento-composer-installer-test-wildcard2": "1.*", + "magento/magento-composer-installer-test-library": "1.*", + "magento/magento-composer-installer-test-sort1": "1.*", + "magento/magento-composer-installer-test-sort2": "1.*", + "magento/magento-composer-installer-test-sort3": "1.*" }, "require-dev": { - "magento-hackathon/composer-command-integrator": "*", - "composer/composer": "dev-master" + "composer/composer": "dev-main" }, "repositories": [ { - "type": "composer", - "url": "http://packages.firegento.com" - }, - { "type": "artifact", "url": "../artifact/" } @@ -38,15 +26,15 @@ "magento-deploystrategy": "copy", "magento-force": true, "magento-deploy-sort-priority": { - "magento-hackathon/magento-composer-installer-test-sort1": "200", - "magento-hackathon/magento-composer-installer-test-sort2": "400", - "magento-hackathon/magento-composer-installer-test-sort3": "200" + "magento/magento-composer-installer-test-sort1": "200", + "magento/magento-composer-installer-test-sort2": "400", + "magento/magento-composer-installer-test-sort3": "200" }, "auto-append-gitignore": true, "magento-project": { "libraryPath": "../htdocs/composer_lib/", "libraries": { - "magento-hackathon/magento-composer-installer-test-library": {} + "magento/magento-composer-installer-test-library": {} } }, "magento-root-dir": "../htdocs/" diff --git a/tests/FullStackTest/magento-modules/composer_2.json b/tests/FullStackTest/magento-modules/composer_2.json index 3d3acd42..fbee800a 100644 --- a/tests/FullStackTest/magento-modules/composer_2.json +++ b/tests/FullStackTest/magento-modules/composer_2.json @@ -1,16 +1,12 @@ { "require": { - "magento-hackathon/magento-composer-installer": "*", + "magento/magento-composer-installer": "100.100.100", "theseer/autoload": "~1.14", "zetacomponents/console-tools": "dev-master", - "magento-hackathon/magento-composer-installer-test-updateFileRemove": "2.*" + "magento/magento-composer-installer-test-update-file-remove": "2.*" }, "repositories": [ { - "type": "composer", - "url": "http://packages.firegento.com" - }, - { "type": "artifact", "url": "../artifact/" } @@ -21,7 +17,7 @@ "magento-project": { "libraryPath": "../htdocs/composer_lib/", "libraries": { - "magento-hackathon/magento-composer-installer-test-library": {} + "magento/magento-composer-installer-test-library": {} } }, "magento-root-dir": "../htdocs/" diff --git a/tests/FullStackTest/magento-modules/composer_2_copy.json b/tests/FullStackTest/magento-modules/composer_2_copy.json index 58294f77..857c4a1b 100644 --- a/tests/FullStackTest/magento-modules/composer_2_copy.json +++ b/tests/FullStackTest/magento-modules/composer_2_copy.json @@ -1,15 +1,11 @@ { "require": { - "magento-hackathon/magento-composer-installer": "*", + "magento/magento-composer-installer": "100.100.100", "theseer/autoload": "~1.14", "zetacomponents/console-tools": "dev-master", - "magento-hackathon/magento-composer-installer-test-updateFileRemove": "2.*" + "magento/magento-composer-installer-test-update-file-remove": "2.*" }, "repositories": [ - { - "type": "composer", - "url": "http://packages.firegento.com" - }, { "type": "artifact", "url": "../artifact/" @@ -21,7 +17,7 @@ "magento-project": { "libraryPath": "../htdocs/composer_lib/", "libraries": { - "magento-hackathon/magento-composer-installer-test-library": {} + "magento/magento-composer-installer-test-library": {} } }, "magento-root-dir": "../htdocs/" diff --git a/tests/FullStackTest/magento-modules/composer_2_copy_force.json b/tests/FullStackTest/magento-modules/composer_2_copy_force.json index 6794f539..487df5e2 100644 --- a/tests/FullStackTest/magento-modules/composer_2_copy_force.json +++ b/tests/FullStackTest/magento-modules/composer_2_copy_force.json @@ -1,15 +1,11 @@ { "require": { - "magento-hackathon/magento-composer-installer": "*", + "magento/magento-composer-installer": "100.100.100", "theseer/autoload": "~1.14", "zetacomponents/console-tools": "dev-master", - "magento-hackathon/magento-composer-installer-test-updateFileRemove": "2.*" + "magento/magento-composer-installer-test-update-file-remove": "2.*" }, "repositories": [ - { - "type": "composer", - "url": "http://packages.firegento.com" - }, { "type": "artifact", "url": "../artifact/" @@ -22,7 +18,7 @@ "magento-project": { "libraryPath": "../htdocs/composer_lib/", "libraries": { - "magento-hackathon/magento-composer-installer-test-library": {} + "magento/magento-composer-installer-test-library": {} } }, "magento-root-dir": "../htdocs/" diff --git a/tests/FullStackTest/magento/composer.json b/tests/FullStackTest/magento/composer.json index 9430a251..b0c29f2d 100644 --- a/tests/FullStackTest/magento/composer.json +++ b/tests/FullStackTest/magento/composer.json @@ -1,15 +1,11 @@ { "require": { - "magento-hackathon/magento-composer-installer": "*", - "theseer/autoload": "~1.14", - "zetacomponents/console-tools": "dev-master", - "connect20/mage_all_latest": "*" + "magento/magento2-base-mock": "*", + "magento/magento-composer-installer": "100.100.100", + "theseer/autoload": "~1.14", + "zetacomponents/console-tools": "dev-master" }, "repositories": [ - { - "type": "composer", - "url": "http://packages.firegento.com" - }, { "type": "artifact", "url": "../artifact/" diff --git a/tests/MagentoHackathon/Composer/Magento/Deploystrategy/AbstractTest.php b/tests/MagentoHackathon/Composer/Magento/Deploystrategy/AbstractTest.php index 2d1d21ea..8b5bd276 100644 --- a/tests/MagentoHackathon/Composer/Magento/Deploystrategy/AbstractTest.php +++ b/tests/MagentoHackathon/Composer/Magento/Deploystrategy/AbstractTest.php @@ -1,9 +1,12 @@ filesystem = new \Composer\Util\Filesystem(); - $this->sourceDir = sys_get_temp_dir() . DS . $this->getName() . DS . "module_dir"; - $this->destDir = sys_get_temp_dir() . DS . $this->getName() . DS . "magento_dir"; + $this->testDir = sys_get_temp_dir() . DS . $this->getName(); + $this->sourceDir = $this->testDir . DS . "module_dir"; + $this->destDir = $this->testDir . DS . "magento_dir"; $this->filesystem->ensureDirectoryExists($this->sourceDir); $this->filesystem->ensureDirectoryExists($this->destDir); - $this->strategy = $this->getTestDeployStrategy($this->sourceDir, $this->destDir); } @@ -61,51 +70,51 @@ protected function setUp() * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ - protected function tearDown() + protected function tearDown(): void { - $this->filesystem->remove($this->sourceDir); - $this->filesystem->remove($this->destDir); + $this->filesystem->remove($this->testDir); } /** * @param string $file * @param string $type * @throws \InvalidArgumentException - * @throws \PHPUnit_Framework_AssertionFailedError + * @throws AssertionFailedError */ public function assertFileType($file, $type) { switch ($type) { case self::TEST_FILETYPE_FILE: - $result = is_file($file) && ! is_link($file); + $result = is_file($file) && !is_link($file); break; case self::TEST_FILETYPE_LINK: $file = rtrim($file, '/\\'); $result = is_link($file); break; case self::TEST_FILETYPE_DIR: - $result = is_dir($file) && ! is_link($file); + $result = is_dir($file) && !is_link($file); break; default: throw new \InvalidArgumentException( "Invalid file type argument: " . $type ); } - if (! $result) { - //echo "\n$file\n"; - //passthru("ls -l " . $file); - if (is_dir($file) && ! is_link($file)) { + if (!$result) { + if (is_dir($file) && !is_link($file)) { $realType = 'dir'; } elseif (is_link($file)) { $realType = 'link'; - } elseif (is_file($file) && ! is_link($file)) { + } elseif (is_file($file) && !is_link($file)) { $realType = 'file'; } else { $realType = 'unknown'; } - throw new \PHPUnit_Framework_AssertionFailedError( - "Failed to assert that the $file is of type $type, found type $realType instead." - ); + throw new AssertionFailedError(sprintf( + 'Failed to assert that the "%s" is of type "%s", found type "%s" instead.', + $file, + $type, + $realType + )); } } @@ -118,13 +127,13 @@ protected function mkdir($dir, $recursive = true) throw new \Exception("mkdir('$dir') already exists and is a file"); } } - return mkdir($dir, 0777, $recursive); + return mkdir($dir, 0755, $recursive); } public function testGetMappings() { - $mappingData = array('test', 'test2'); - $this->strategy->setMappings(array($mappingData)); + $mappingData = ['test', 'test2']; + $this->strategy->setMappings([$mappingData]); $this->assertTrue(is_array($this->strategy->getMappings())); $firstValue = $this->strategy->getMappings(); $this->assertEquals(array_pop($firstValue), $mappingData); @@ -132,11 +141,11 @@ public function testGetMappings() public function testAddMapping() { - $this->strategy->setMappings(array()); + $this->strategy->setMappings([]); $this->strategy->addMapping('t1', 't2'); $this->assertTrue(is_array($this->strategy->getMappings())); $firstValue = $this->strategy->getMappings(); - $this->assertEquals(array_pop($firstValue), array("t1", "t2")); + $this->assertEquals(array_pop($firstValue), ["t1", "t2"]); } public function testCreate() @@ -146,7 +155,7 @@ public function testCreate() touch($this->sourceDir . DS . $src); $this->assertTrue(is_readable($this->sourceDir . DS . $src)); $this->assertFalse(is_readable($this->destDir . DS . $dest)); - $this->strategy->setCurrentMapping(array($src, $dest)); + $this->strategy->setCurrentMapping([$src, $dest]); $this->strategy->create($src, $dest); $this->assertTrue(is_readable($this->destDir . DS . $dest)); } @@ -159,7 +168,7 @@ public function testCopyDirToDir() touch($this->sourceDir . DS . $src . DS . "local.xml"); $this->assertTrue(is_readable($this->sourceDir . DS . $src . DS . "local.xml")); $this->assertFalse(is_readable($this->destDir . DS . $dest . DS . "local.xml")); - $this->strategy->setCurrentMapping(array($src, $dest)); + $this->strategy->setCurrentMapping([$src, $dest]); $this->strategy->create($src, $dest); $this->assertTrue(is_readable($this->destDir . DS . $dest . DS . "local.xml")); } @@ -175,7 +184,7 @@ public function testGlobTargetDirExists() $testTarget = $this->destDir . DS . $dest . DS . basename($globSource); - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); $this->assertFileType(dirname($testTarget), self::TEST_FILETYPE_DIR); @@ -195,7 +204,7 @@ public function testTargetDirWithChildDirExists() $testTarget = $this->destDir . DS . $dest . DS . basename($globSource) . DS . basename($sourceContents); - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); //passthru("tree {$this->destDir}/$dest"); @@ -215,7 +224,7 @@ public function testTargetDirWithChildDirNotExists() $testTarget = $this->destDir . DS . $dest . DS . basename($globSource) . DS . basename($sourceContents); - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); //passthru("tree {$this->destDir}/$dest"); @@ -233,7 +242,7 @@ public function testGlobTargetDirDoesNotExists() $testTarget = $this->destDir . DS . $dest; - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); $this->assertFileType(dirname($testTarget), self::TEST_FILETYPE_DIR); @@ -253,7 +262,7 @@ public function testGlobSlashDirectoryExists() $testTarget = $this->destDir . DS . $dest . basename($globSource); // second create has to identify symlink - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); $this->assertFileType(dirname($testTarget), self::TEST_FILETYPE_DIR); @@ -272,7 +281,7 @@ public function testGlobSlashDirectoryDoesNotExists() $testTarget = $this->destDir . DS . $dest . basename($globSource); // second create has to identify symlink - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); $this->assertFileType(dirname($testTarget), self::TEST_FILETYPE_DIR); @@ -284,7 +293,7 @@ public function testGlobWildcardTargetDirDoesNotExist() { $globSource = "sourcedir/*"; $glob_dir = dirname($globSource); - $files = array('test1.xml', 'test2.xml'); + $files = ['test1.xml', 'test2.xml']; $this->mkdir($this->sourceDir . DS . $glob_dir); foreach ($files as $file) { touch($this->sourceDir . DS . $glob_dir . DS . $file); @@ -292,7 +301,7 @@ public function testGlobWildcardTargetDirDoesNotExist() $dest = "targetdir"; - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); $targetDir = $this->destDir . DS . $dest; @@ -312,7 +321,7 @@ public function testGlobWildcardTargetDirDoesExist() { $globSource = "sourcedir/*"; $glob_dir = dirname($globSource); - $files = array('test1.xml', 'test2.xml'); + $files = ['test1.xml', 'test2.xml']; $this->mkdir($this->sourceDir . DS . $glob_dir); foreach ($files as $file) { touch($this->sourceDir . DS . $glob_dir . DS . $file); @@ -321,7 +330,7 @@ public function testGlobWildcardTargetDirDoesExist() $dest = "targetdir"; $this->mkdir($this->destDir . DS . $dest); - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); $targetDir = $this->destDir . DS . $dest; @@ -338,12 +347,12 @@ public function testGlobWildcardTargetDirDoesExist() public function testSourceAndTargetAreDirsDoNotExist() { - $fixtures = array( - array('sourcedir', 'targetdir'), - array('sourcedir', 'targetdir/'), - array('sourcedir/', 'targetdir/'), - array('sourcedir/', 'targetdir'), - ); + $fixtures = [ + ['sourcedir', 'targetdir'], + ['sourcedir', 'targetdir/'], + ['sourcedir/', 'targetdir/'], + ['sourcedir/', 'targetdir'], + ]; foreach ($fixtures as $fixture) { $this->tearDown(); $this->setUp(); @@ -358,7 +367,7 @@ public function testSourceAndTargetAreDirsDoNotExist() $testTarget = $this->destDir . DS . $dest; $testTargetContent = $testTarget . DS . $sourceDirContent; - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); $this->assertFileExists($testTarget); @@ -371,12 +380,12 @@ public function testSourceAndTargetAreDirsDoNotExist() public function testSourceAndTargetAreDirsDoExist() { - $fixtures = array( - array('sourcedir', 'targetdir'), - array('sourcedir', 'targetdir/'), - array('sourcedir/', 'targetdir/'), - array('sourcedir/', 'targetdir'), - ); + $fixtures = [ + ['sourcedir', 'targetdir'], + ['sourcedir', 'targetdir/'], + ['sourcedir/', 'targetdir/'], + ['sourcedir/', 'targetdir'], + ]; foreach ($fixtures as $fixture) { $this->tearDown(); $this->setUp(); @@ -394,7 +403,7 @@ public function testSourceAndTargetAreDirsDoExist() $testTarget = $this->destDir . DS . $dest . DS . basename($globSource); $testTargetContent = $testTarget . DS . $sourceDirContent; - $this->strategy->setCurrentMapping(array($globSource, $dest)); + $this->strategy->setCurrentMapping([$globSource, $dest]); $this->strategy->create($globSource, $dest); $this->assertFileExists($testTarget); diff --git a/tests/MagentoHackathon/Composer/Magento/Deploystrategy/CopyTest.php b/tests/MagentoHackathon/Composer/Magento/Deploystrategy/CopyTest.php index 2c89f1d1..68d653e4 100644 --- a/tests/MagentoHackathon/Composer/Magento/Deploystrategy/CopyTest.php +++ b/tests/MagentoHackathon/Composer/Magento/Deploystrategy/CopyTest.php @@ -19,11 +19,13 @@ public function getTestDeployStrategy($src, $dest) */ public function getTestDeployStrategyFiletype($isDir = false) { - if ($isDir) return self::TEST_FILETYPE_DIR; + if ($isDir) { + return self::TEST_FILETYPE_DIR; + } return self::TEST_FILETYPE_FILE; } - + public function testCopyDirToDirOfSameName() { $sourceRoot = 'root'; @@ -32,12 +34,12 @@ public function testCopyDirToDirOfSameName() $this->mkdir($this->sourceDir . DS . $sourceRoot . DS . dirname($sourceContents)); touch($this->sourceDir . DS . $sourceRoot . DS . $sourceContents); - // intentionally using a differnt name to verify solution doesn't rely on identical src/dest paths + // intentionally using a different name to verify solution doesn't rely on identical src/dest paths $dest = "dest/root"; $this->mkdir($this->destDir . DS . $dest); $testTarget = $this->destDir . DS . $dest . DS . $sourceContents; - $this->strategy->setCurrentMapping(array($sourceRoot, $dest)); + $this->strategy->setCurrentMapping([$sourceRoot, $dest]); $this->strategy->create($sourceRoot, $dest); $this->assertFileExists($testTarget); @@ -45,13 +47,13 @@ public function testCopyDirToDirOfSameName() $this->strategy->setIsForced(true); $this->strategy->create($sourceRoot, $dest); - $this->assertFileNotExists(dirname(dirname($testTarget)) . DS . basename($testTarget)); + $this->assertFileDoesNotExist(dirname(dirname($testTarget)) . DS . basename($testTarget)); } public function testWildcardCopyToExistingDir() { $sourceContents = "app/code/test.php"; - + //create target directory before $this->mkdir($this->destDir . DS . 'app' . DS . 'code'); @@ -62,7 +64,7 @@ public function testWildcardCopyToExistingDir() $this->mkdir($this->destDir . DS . $dest); $testTarget = $this->destDir . DS . $sourceContents; - $this->strategy->setMappings(array(array('*', '/'))); + $this->strategy->setMappings([['*', '/']]); $this->strategy->deploy(); $this->assertFileExists($testTarget); @@ -70,7 +72,7 @@ public function testWildcardCopyToExistingDir() $this->strategy->setIsForced(true); $this->strategy->deploy(); - $this->assertFileNotExists($this->destDir . DS . 'app' . DS . 'app' . DS . 'code' . DS . 'test.php'); - + $this->assertFileDoesNotExist($this->destDir . DS . 'app' . DS . 'app' . DS . 'code' . DS . 'test.php'); + } } diff --git a/tests/MagentoHackathon/Composer/Magento/Deploystrategy/NoneTest.php b/tests/MagentoHackathon/Composer/Magento/Deploystrategy/NoneTest.php index 49bd2a5b..490d9831 100644 --- a/tests/MagentoHackathon/Composer/Magento/Deploystrategy/NoneTest.php +++ b/tests/MagentoHackathon/Composer/Magento/Deploystrategy/NoneTest.php @@ -8,7 +8,7 @@ define('DS', DIRECTORY_SEPARATOR); } -class NoneTest extends \PHPUnit_Framework_TestCase +class NoneTest extends \PHPUnit\Framework\TestCase { const URL_VFS_ROOT = 'vfsroot'; @@ -17,7 +17,7 @@ protected function _getVfsUrl($input) return vfsStream::url(self::URL_VFS_ROOT . DS . $input); } - protected function setUp() + protected function setUp(): void { vfsStream::setup(self::URL_VFS_ROOT); $this->sourceDir = $this->_getVfsUrl('sourceDir'); @@ -31,7 +31,7 @@ public function testCreate() $dest = 'test2'; //create the source directory - mkdir($this->_getVfsUrl('sourceDir' . DS . $src), null, true); + mkdir($this->_getVfsUrl('sourceDir' . DS . $src), 0755, true); $this->assertTrue(is_dir($this->_getVfsUrl('sourceDir' . DS . $src))); $this->assertFalse(is_dir($this->_getVfsUrl('destDir' . DS . $dest))); diff --git a/tests/MagentoHackathon/Composer/Magento/Deploystrategy/SymlinkTest.php b/tests/MagentoHackathon/Composer/Magento/Deploystrategy/SymlinkTest.php index 9b8ba006..74b404c4 100644 --- a/tests/MagentoHackathon/Composer/Magento/Deploystrategy/SymlinkTest.php +++ b/tests/MagentoHackathon/Composer/Magento/Deploystrategy/SymlinkTest.php @@ -32,7 +32,7 @@ public function testClean() $this->strategy->create($src, $dest); $this->assertTrue(is_readable($this->destDir . DIRECTORY_SEPARATOR . $dest)); unlink($this->destDir . DIRECTORY_SEPARATOR . $dest); - $this->strategy->clean($this->destDir . DIRECTORY_SEPARATOR . $dest); + $this->strategy->clean(); $this->assertFalse(is_readable($this->destDir . DIRECTORY_SEPARATOR . $dest)); } @@ -68,7 +68,8 @@ public function testTargetDirWithChildDirExists() $testTarget = $this->destDir . DS . $dest . DS . basename($globSource) . DS . basename($sourceContents); $this->strategy->setIsForced(false); - $this->setExpectedException('ErrorException', "Target targetdir/childdir already exists"); + $this->expectException('ErrorException'); + $this->expectExceptionMessage("Target targetdir/childdir already exists"); $this->strategy->create($globSource, $dest); //passthru("tree {$this->destDir}/$dest"); } diff --git a/tests/MagentoHackathon/Composer/Magento/FullStack/AbstractTest.php b/tests/MagentoHackathon/Composer/Magento/FullStack/AbstractTest.php index 24ff0c4d..849653c7 100644 --- a/tests/MagentoHackathon/Composer/Magento/FullStack/AbstractTest.php +++ b/tests/MagentoHackathon/Composer/Magento/FullStack/AbstractTest.php @@ -11,33 +11,43 @@ use Composer\Util\Filesystem; use Symfony\Component\Process\Process; -abstract class AbstractTest extends \PHPUnit_Framework_TestCase +abstract class AbstractTest extends \PHPUnit\Framework\TestCase { protected static $processLogCounter = 1; - public static function setUpBeforeClass() + /** + * Store current module version for rollback + * + * @var string + */ + protected static $currentModuleVersion = ''; + + /** + * Version to be set in root composer.json for tests + * + * @var string + */ + protected static $testVersion = '100.100.100'; + + public static function setUpBeforeClass(): void { - $process = new Process( - 'perl -pi -e \'s/"test_version"/"version"/g\' ./composer.json', - self::getProjectRoot() + $rootComposer = json_decode(file_get_contents(self::getProjectRoot() . '/composer.json'), true); + self::$currentModuleVersion = $rootComposer['version'] ?? ''; + $rootComposer['version'] = self::$testVersion; + file_put_contents( + self::getProjectRoot() . '/composer.json', + json_encode($rootComposer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ); - $process->run(); - if ($process->getExitCode() !== 0) { - $message = 'process for '.$process->getCommandLine().' exited with '.$process->getExitCode().': '.$process->getExitCodeText(); - $message .= PHP_EOL.'Error Message:'.PHP_EOL.$process->getErrorOutput(); - $message .= PHP_EOL.'Output:'.PHP_EOL.$process->getOutput(); - echo $message; - } - + @unlink(self::getProjectRoot().'/vendor/theseer/directoryscanner/tests/_data/linkdir'); @unlink(self::getBasePath().'/magento/vendor/theseer/directoryscanner/tests/_data/linkdir'); @unlink(self::getBasePath().'/magento-modules/vendor/theseer/directoryscanner/tests/_data/linkdir'); @unlink(self::getProjectRoot().'/vendor/theseer/directoryscanner/tests/_data/nested/empty'); @unlink(self::getBasePath().'/magento/vendor/theseer/directoryscanner/tests/_data/nested/empty'); @unlink(self::getBasePath().'/magento-modules/vendor/theseer/directoryscanner/tests/_data/nested/empty'); - - $process = new Process( + + $process = Process::fromShellCommandline( self::getComposerCommand().' archive --format=zip --dir="tests/FullStackTest/artifact" -vvv', self::getProjectRoot() ); @@ -53,9 +63,20 @@ public static function setUpBeforeClass() } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { - $process = new Process( + $rootComposer = json_decode(file_get_contents(self::getProjectRoot() . '/composer.json'), true); + if (self::$currentModuleVersion === '') { + unset($rootComposer['version']); + } else { + $rootComposer['version'] = self::$currentModuleVersion; + } + file_put_contents( + self::getProjectRoot() . '/composer.json', + json_encode($rootComposer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) + ); + + $process = Process::fromShellCommandline( 'perl -pi -e \'s/"version"/"test_version"/g\' ./composer.json', self::getProjectRoot() ); @@ -77,11 +98,8 @@ protected static function getProjectRoot(){ } protected static function getComposerCommand(){ - $command = 'composer.phar'; - if( getenv('TRAVIS') == "true" ){ - $command = self::getProjectRoot().'/composer.phar'; - } - return $command; + + return 'composer.phar'; } protected static function getComposerArgs(){ @@ -89,11 +107,23 @@ protected static function getComposerArgs(){ } protected static function logProcessOutput(Process $process, $name = null){ - if($name === null){ + if($name === null) { $name = self::$processLogCounter; self::$processLogCounter++; } - file_put_contents( self::getBasePath().'/'.get_called_class().'_'.$name.'Output.log', $process->getCommandLine() ."\n\n". $process->getOutput() ); + $logPath = implode(DIRECTORY_SEPARATOR, [ + self::getBasePath(), + 'logs', + str_replace('\\', '_', static::class), + $name . '_Output.log' + ]); + if (!is_dir(dirname($logPath))) { + mkdir(dirname($logPath)); + } + file_put_contents( + $logPath, + $process->getCommandLine() . "\n\n" . $process->getOutput() + ); } public function assertProcess(Process $process) diff --git a/tests/MagentoHackathon/Composer/Magento/FullStack/GlobalPluginTest.php b/tests/MagentoHackathon/Composer/Magento/FullStack/GlobalPluginTest.php index e03a1440..a269f068 100644 --- a/tests/MagentoHackathon/Composer/Magento/FullStack/GlobalPluginTest.php +++ b/tests/MagentoHackathon/Composer/Magento/FullStack/GlobalPluginTest.php @@ -10,12 +10,12 @@ class GlobalPluginTest extends AbstractTest protected static $processLogCounter = 1; - protected function setUp() + protected function setUp(): void { } - protected function tearDown() + protected function tearDown(): void { } @@ -30,27 +30,25 @@ protected function prepareCleanDirectories() public function testGlobalInstall() { - $process = new Process( - self::getComposerCommand().' global install', - self::getProjectRoot() + $process = Process::fromShellCommandline( + self::getComposerCommand() . ' global install', + self::getProjectRoot(), + ['COMPOSER_HOME' => self::getBasePath() . '/home'] ); - $process->setEnv( array('COMPOSER_HOME'=>self::getBasePath().'/home')); - + $process->setTimeout(180); $process->run(); $this->assertProcess($process); } - + public function testGlobalUpdate() { - - $process = new Process( - self::getComposerCommand().' global update', - self::getProjectRoot() + $process = Process::fromShellCommandline( + self::getComposerCommand() . ' global update', + self::getProjectRoot(), + ['COMPOSER_HOME' => self::getBasePath() . '/home'] ); - $process->setEnv( array('COMPOSER_HOME'=>self::getBasePath().'/home')); - + $process->setTimeout(180); $process->run(); $this->assertProcess($process); } - -} \ No newline at end of file +} diff --git a/tests/MagentoHackathon/Composer/Magento/FullStackTest.php b/tests/MagentoHackathon/Composer/Magento/FullStackTest.php index afe4b78d..066e3a2b 100644 --- a/tests/MagentoHackathon/Composer/Magento/FullStackTest.php +++ b/tests/MagentoHackathon/Composer/Magento/FullStackTest.php @@ -9,17 +9,17 @@ class FullStackTest extends FullStack\AbstractTest { - protected function setUp() + protected function setUp(): void { } - protected function tearDown() + protected function tearDown(): void { } - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); $packagesPath = self::getProjectRoot() .'/tests/res/packages'; @@ -27,8 +27,9 @@ public static function setUpBeforeClass() /** @var \DirectoryIterator $fileinfo */ foreach($directory as $file){ if (!$file->isDot() && $file->isDir()) { - $process = new Process( - self::getComposerCommand().' archive --format=zip --dir="../../../../tests/FullStackTest/artifact" -vvv', + $composerPath = self::getProjectRoot() . DIRECTORY_SEPARATOR . self::getComposerCommand(); + $process = Process::fromShellCommandline( + $composerPath . ' archive --format=zip --dir="../../../../tests/FullStackTest/artifact" -vvv', $file->getPathname() ); $process->run(); @@ -42,7 +43,7 @@ public static function setUpBeforeClass() } } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); } @@ -61,9 +62,10 @@ protected function prepareCleanDirectories() protected function installBaseMagento() { - $process = new Process( - self::getComposerCommand().' install '.self::getComposerArgs().' --working-dir="./"', - self::getBasePath().'/magento' + $process = Process::fromShellCommandline( + self::getProjectRoot() . DIRECTORY_SEPARATOR . self::getComposerCommand() . ' install ' . + self::getComposerArgs() . ' --working-dir="./"', + self::getBasePath() . '/magento' ); $process->setTimeout(300); $process->run(); @@ -73,53 +75,52 @@ protected function installBaseMagento() protected function getMethodRunConfigs() { - $array = array( - 'symlink' => array( - 1 => array( + $array = [ + 'symlink' => [ + 1 => [ 'module_composer_json' => "composer_1.json", - ), - 2 => array( + ], + 2 => [ 'module_composer_json' => "composer_2.json", - ), - 3 => array( + ], + 3 => [ 'module_composer_json' => "composer_1.json", - ), - ), - 'copy' => array( - 1 => array( + ], + ], + 'copy' => [ + 1 => [ 'module_composer_json' => "composer_1_copy.json", - ), - 2 => array( + ], + 2 => [ 'module_composer_json' => "composer_2_copy.json", - ), - 3 => array( + ], + 3 => [ 'module_composer_json' => "composer_1_copy.json", - ), - ), - 'copy_force' => array( - 1 => array( + ], + ], + 'copy_force' => [ + 1 => [ 'module_composer_json' => "composer_1_copy_force.json", - ), - 2 => array( + ], + 2 => [ 'module_composer_json' => "composer_2_copy_force.json", - ), - 3 => array( + ], + 3 => [ 'module_composer_json' => "composer_1_copy_force.json", - ), - ), - - ); + ], + ], + ]; return $array; } public function methodProvider() { - return array( - array('symlink'), - array('copy'), - array('copy_force'), - ); + return [ + ['symlink'], + ['copy'], + ['copy_force'], + ]; } /** @@ -127,78 +128,72 @@ public function methodProvider() */ public function testEverything( $method ) { + $this->assertFileExists( + self::getBasePath() . + '/artifact/magento-magento-composer-installer-' . + self::$testVersion . '.zip' + ); - $this->assertFileExists( self::getBasePath().'/artifact/magento-hackathon-magento-composer-installer-999.0.0.zip' ); + $this->prepareCleanDirectories(); + $this->installBaseMagento(); $methods = $this->getMethodRunConfigs(); - $runs = $methods[$method]; - - $this->prepareCleanDirectories(); - - $this->installBaseMagento(); - - foreach( $runs as $run => $value){ - $this->changeModuleComposerFileAndUpdate( - $value['module_composer_json'], - ($run===1) ? 'install' : 'update' - ); - - switch($run){ - case 1: - case 3: - foreach( - $this->getFirstOnlyFileTestSet() - + $this->getFirstExistTestSet() - as $file){ - $this->assertFileExists( self::getBasePath().'/htdocs/'.$file ); - } - foreach($this->getFirstNotExistTestSet() as $file){ - $this->assertFileNotExists( self::getBasePath().'/htdocs/'.$file ); - } - if($method==="copy_force"){ - $this->assertStringEqualsFile( - self::getBasePath().'/htdocs/'.'app/design/frontend/test/default/installSort/test1.phtml' - ,'testcontent2' - ); - $this->assertStringEqualsFile( - self::getBasePath().'/htdocs/'.'app/design/frontend/test/default/installSort/test2.phtml' - ,'testcontent3' - ); - } - break; - case 2: - if($method==="symlink"){ - foreach($this->getFirstOnlyFileTestSet() as $file){ - $this->assertFileNotExists( self::getBasePath().'/htdocs/'.$file ); - } + foreach( $runs as $run => $value){ + $this->changeModuleComposerFileAndUpdate( + $value['module_composer_json'], + ($run === 1) ? 'install' : 'update' + ); + + switch($run){ + case 1: + case 3: + foreach($this->getFirstOnlyFileTestSet() + $this->getFirstExistTestSet() as $file){ + $this->assertFileExists(self::getBasePath() . '/htdocs/'. $file ); + } + foreach($this->getFirstNotExistTestSet() as $file){ + $this->assertFileDoesNotExist( self::getBasePath() .'/htdocs/'. $file ); + } + if($method==="copy_force"){ + $this->assertStringEqualsFile( + self::getBasePath().'/htdocs/' . 'app/design/frontend/Magento/luma/Magento_SortThemeMock/design/test1.phtml', + 'testcontent1' + ); + $this->assertStringEqualsFile( + self::getBasePath().'/htdocs/' . 'app/design/frontend/Magento/luma/Magento_SortThemeMock/design/test2.phtml', + 'testcontent4' + ); + } + break; + case 2: + if($method==="symlink"){ + foreach($this->getFirstOnlyFileTestSet() as $file){ + $this->assertFileDoesNotExist( self::getBasePath() .'/htdocs/'. $file ); } - foreach($this->getSecondExistTestSet() as $file){ - $this->assertFileExists( self::getBasePath().'/htdocs/'.$file ); - } - break; - } - + } + foreach($this->getSecondExistTestSet() as $file){ + $this->assertFileExists( self::getBasePath() .'/htdocs/'. $file ); + } + break; } - - - + } } - + protected function changeModuleComposerFileAndUpdate($file, $command = "update") { - $magentoModuleComposerFile = self::getBasePath().'/magento-modules/composer.json'; + $magentoModuleComposerFile = self::getBasePath() . '/magento-modules/composer.json'; if(file_exists($magentoModuleComposerFile)){ unlink($magentoModuleComposerFile); } copy( - self::getBasePath().'/magento-modules/'.$file, + self::getBasePath().'/magento-modules/' . $file, $magentoModuleComposerFile ); - $process = new Process( - self::getComposerCommand().' '.$command.' '.self::getComposerArgs().' --optimize-autoloader --working-dir="./"', - self::getBasePath().'/magento-modules' + $composerPath = '../../.././composer.phar'; + $process = Process::fromShellCommandline( + $composerPath . ' ' . $command. ' '. self::getComposerArgs().' --optimize-autoloader --working-dir="./"', + self::getBasePath() . '/magento-modules' ); $process->setTimeout(300); $process->run(); @@ -208,19 +203,19 @@ protected function changeModuleComposerFileAndUpdate($file, $command = "update") protected function getFirstOnlyFileTestSet() { - return array( - 'app/etc/modules/Aoe_Profiler.xml', - 'app/design/frontend/test/default/issue76/Foobar/issue76.phtml', - 'app/design/frontend/wildcard/wildcard.phtml', + return [ + 'app/code/Magento/ModuleMock/etc/module.xml', + 'app/design/frontend/Magento/luma/Magento_ThemeMock/Foobar/issue76.phtml', + 'app/design/adminhtml/Magento/luma/Magento_AdminThemeMock/wildcard/wildcard.phtml', 'composer_lib/autoload.php', - 'composer_lib/magento-hackathon/magento-composer-installer-test-library/composer.json', + 'composer_lib/magento/magento-composer-installer-test-library/composer.json', // 'app/design/frontend/test/default/updateFileRemove/design/test2.phtml', - ); + ]; } protected function getFirstNotExistTestSet() { - return array( + return [ 'app/design/frontend/test/default/issue76/Foobar/Foobar/issue76.phtml', 'app/design/frontend/frontend/wildcard/wildcard.phtml', 'app/app/code/test.php', @@ -228,26 +223,22 @@ protected function getFirstNotExistTestSet() 'shell/compiler.php', // 'app/design/frontend/test/default/updateFileRemove/design/test2.phtml', // 'app/design/frontend/test/default/updateFileRemove/test2.phtml', - ); + ]; } protected function getFirstExistTestSet() { - return array( + return [ // 'app/design/frontend/test/default/updateFileRemove/design/test1.phtml', // 'app/design/frontend/test/default/updateFileRemove/design/test2.phtml', 'shell/log.php', - ); + ]; } protected function getSecondExistTestSet() { - return array( + return [ // 'app/design/frontend/test/default/updateFileRemove/design/test1.phtml', - ); + ]; } - - - - } \ No newline at end of file diff --git a/tests/MagentoHackathon/Composer/Magento/GitIgnoreGeneratorTest.php b/tests/MagentoHackathon/Composer/Magento/GitIgnoreGeneratorTest.php index a8edfe5f..82a6eac8 100644 --- a/tests/MagentoHackathon/Composer/Magento/GitIgnoreGeneratorTest.php +++ b/tests/MagentoHackathon/Composer/Magento/GitIgnoreGeneratorTest.php @@ -23,14 +23,14 @@ protected function getGitIgnoreTestPath() public function testGitIgnoreAppendToExistingFile() { $gitIgnoreFile = $this->getGitIgnoreTestPath(); - $gitIgnoreContent = array("vendor", ".idea"); + $gitIgnoreContent = ["vendor", ".idea"]; file_put_contents($gitIgnoreFile, implode("\n", $gitIgnoreContent)); - $map = array( - array('test1', 'test1'), - array('testfolder1/testfile1', 'testfolder1/testfile1'), - ); - $package = $this->createPackageMock(array('map' => $map, 'auto-append-gitignore' => true)); + $map = [ + ['test1', 'test1'], + ['testfolder1/testfile1', 'testfolder1/testfile1'], + ]; + $package = $this->createPackageMock(['map' => $map, 'auto-append-gitignore' => true]); $this->composer->setPackage($package); $installer = new Installer($this->io, $this->composer); $installer->appendGitIgnore($package, $gitIgnoreFile); @@ -47,11 +47,11 @@ public function testGitIgnoreAppendToExistingFile() public function testGitIgnoreCreateFileIfNotExist() { $gitIgnoreFile = $this->getGitIgnoreTestPath(); - $map = array( - array('test1', 'test1'), - array('testfolder1/testfile1', 'testfolder1/testfile1'), - ); - $package = $this->createPackageMock(array('map' => $map, 'auto-append-gitignore' => true)); + $map = [ + ['test1', 'test1'], + ['testfolder1/testfile1', 'testfolder1/testfile1'], + ]; + $package = $this->createPackageMock(['map' => $map, 'auto-append-gitignore' => true]); $this->composer->setPackage($package); $installer = new Installer($this->io, $this->composer); $installer->appendGitIgnore($package, $gitIgnoreFile); @@ -67,12 +67,12 @@ public function testGitIgnoreCreateFileIfNotExist() */ public function testGitAppendMethodNotCalledIfOptionNotSelected() { - $package = $this->createPackageMock(array('map' => array())); + $package = $this->createPackageMock(['map' => []]); $this->composer->setPackage($package); $mockInstaller = $this->getMockBuilder('MagentoHackathon\Composer\Magento\Installer') - ->setConstructorArgs(array($this->io, $this->composer)) - ->setMethods(array('appendGitIgnore')) + ->setConstructorArgs([$this->io, $this->composer]) + ->setMethods(['appendGitIgnore']) ->getMock(); $mockInstaller->setDeployManager( new DeployManager( $this->io ) ); @@ -90,12 +90,12 @@ public function testGitAppendMethodCalledIfOptionSelected() { $gitIgnoreFile = $this->getGitIgnoreTestPath(); - $package = $this->createPackageMock(array('map' => array(), 'auto-append-gitignore' => true)); + $package = $this->createPackageMock(['map' => [], 'auto-append-gitignore' => true]); $this->composer->setPackage($package); $mockInstaller = $this->getMockBuilder('MagentoHackathon\Composer\Magento\Installer') - ->setConstructorArgs(array($this->io, $this->composer)) - ->setMethods(array('getGitIgnoreFileLocation', 'appendGitIgnore')) + ->setConstructorArgs([$this->io, $this->composer]) + ->setMethods(['getGitIgnoreFileLocation', 'appendGitIgnore']) ->getMock(); $mockInstaller->expects($this->once()) diff --git a/tests/MagentoHackathon/Composer/Magento/InstallerTest.php b/tests/MagentoHackathon/Composer/Magento/InstallerTest.php index 5c42a948..b6bc17b9 100644 --- a/tests/MagentoHackathon/Composer/Magento/InstallerTest.php +++ b/tests/MagentoHackathon/Composer/Magento/InstallerTest.php @@ -1,13 +1,12 @@ fs = new Filesystem; @@ -45,46 +44,47 @@ protected function setUp() $this->composer->setConfig($this->config); $this->composer->setPackage($this->createPackageMock()); - $this->config->merge(array( - 'config' => array( + $this->config->merge([ + 'config' => [ 'vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir, - ), - )); + ] + ]); $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager') ->disableOriginalConstructor() ->getMock(); $this->composer->setDownloadManager($this->dm); - $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); - $this->io = $this->getMock('Composer\IO\IOInterface'); + $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface') + ->getMock(); + $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $this->object = new Installer($this->io, $this->composer); } - protected function tearDown() + protected function tearDown(): void { $this->fs->removeDirectory($this->vendorDir); $this->fs->removeDirectory($this->binDir); $this->fs->removeDirectory($this->magentoDir); } - protected function createPackageMock(array $extra = array(), $name = 'example/test') + protected function createPackageMock(array $extra = [], $name = 'example/test') { //$package= $this->getMockBuilder('Composer\Package\RootPackageInterface') $package = $this->getMockBuilder('Composer\Package\RootPackage') - ->setConstructorArgs(array(md5(rand()), '1.0.0.0', '1.0.0')) - ->getMock(); - $extraData = array_merge(array('magento-root-dir' => $this->magentoDir), $extra); + ->setConstructorArgs([$name, '1.0.0.0', '1.0.0']) + ->onlyMethods(['getExtra', 'getName', 'getType']) + ->getMock(); - $package->expects($this->any()) - ->method('getExtra') - ->will($this->returnValue($extraData)); + $extraData = array_merge(['magento-root-dir' => $this->magentoDir], $extra); + + $package->method('getExtra') + ->willReturn($extraData); - $package->expects($this->any()) - ->method('getName') - ->will($this->returnValue($name)); + $package->method('getName') + ->willReturn($name); return $package; } @@ -92,9 +92,9 @@ protected function createPackageMock(array $extra = array(), $name = 'example/te /** * @dataProvider deployMethodProvider */ - public function testGetDeployStrategy( $strategy, $expectedClass, $composerExtra = array(), $packageName ) + public function testGetDeployStrategy($strategy, $expectedClass, $packageName, $composerExtra = []) { - $extra = array('magento-deploystrategy' => $strategy); + $extra = ['magento-deploystrategy' => $strategy]; $extra = array_merge($composerExtra, $extra); $package = $this->createPackageMock($extra,$packageName); $this->composer->setPackage($package); @@ -107,7 +107,7 @@ public function testGetDeployStrategy( $strategy, $expectedClass, $composerExtra */ public function testSupports() { - $this->assertTrue($this->object->supports('magento-module')); + $this->assertTrue($this->object->supports('magento2-module')); } /** @@ -120,118 +120,140 @@ public function testGetParser( $packageExtra, $expectedClass, $composerExtra, $p $package = $this->createPackageMock( $packageExtra, $packageName ); $prepareCallback($this->vendorDir); + $package->method('getType')->willReturn('magento2-library'); + $this->assertInstanceOf($expectedClass, $this->object->getParser($package)); } public function deployMethodProvider() { - $deployOverwrite = array( + $deployOverwrite = [ 'example/test2' => 'symlink', 'example/test3' => 'none', - ); + ]; - return array( - array( + return [ + [ 'method' => 'copy', 'expectedClass' => 'MagentoHackathon\Composer\Magento\Deploystrategy\Copy', - 'composerExtra' => array( ), 'packageName' => 'example/test1', - ), - array( + ], + [ 'method' => 'symlink', 'expectedClass' => 'MagentoHackathon\Composer\Magento\Deploystrategy\Symlink', - 'composerExtra' => array( ), 'packageName' => 'example/test1', - ), - array( + ], + [ 'method' => 'link', 'expectedClass' => 'MagentoHackathon\Composer\Magento\Deploystrategy\Link', - 'composerExtra' => array( ), 'packageName' => 'example/test1', - ), - array( + ], + [ 'method' => 'none', 'expectedClass' => 'MagentoHackathon\Composer\Magento\Deploystrategy\None', - 'composerExtra' => array( ), 'packageName' => 'example/test1', - ), - array( + ], + [ 'method' => 'symlink', 'expectedClass' => 'MagentoHackathon\Composer\Magento\Deploystrategy\Symlink', - 'composerExtra' => array( 'magento-deploystrategy-overwrite' => $deployOverwrite ), 'packageName' => 'example/test2', - ), - array( + 'composerExtra' => ['magento-deploystrategy-overwrite' => $deployOverwrite], + ], + [ 'method' => 'symlink', 'expectedClass' => 'MagentoHackathon\Composer\Magento\Deploystrategy\None', - 'composerExtra' => array( 'magento-deploystrategy-overwrite' => $deployOverwrite ), 'packageName' => 'example/test3', - ), - ); + 'composerExtra' => ['magento-deploystrategy-overwrite' => $deployOverwrite], + ], + ]; } public function parserTypeProvider() { - $mapOverwrite = array( - 'example/test2' => array('test' => 'test2'), - 'example/test3' => array('test' => 'test3'), - ); - return array( - array( - 'packageExtra' => array('map' => array('test' => 'test')), + $mapOverwrite = [ + 'example/test2' => [['test', 'test2']], + 'example/test3' => [['test', 'test3']], + ]; + return [ + [ + 'packageExtra' => [ + 'map' => [['test', 'test']] + ], 'expectedClass' => 'MagentoHackathon\Composer\Magento\MapParser', - 'composerExtra' => array( 'magento-map-overwrite' => $mapOverwrite ), + 'composerExtra' => ['magento-map-overwrite' => $mapOverwrite], 'packageName' => 'example/test1', 'prepareCallback' => function($vendorDir){ }, - ), - array( - 'packageExtra' => array('map' => null), + ], + [ + 'packageExtra' => ['map' => null], 'expectedClass' => 'MagentoHackathon\Composer\Magento\ModmanParser', - 'composerExtra' => array( 'magento-map-overwrite' => $mapOverwrite ), + 'composerExtra' => ['magento-map-overwrite' => $mapOverwrite], 'packageName' => 'example/test1', - 'prepareCallback' => function($vendorDir){ - touch($vendorDir . DIRECTORY_SEPARATOR . 'modman'); - }, - ), - array( - 'packageExtra' => array('map' => null, 'package-xml' => 'package.xml'), + 'prepareCallback' => function($vendorDir) { + $directory = $this->getPackageDir($vendorDir, 'example/test1'); + mkdir($directory, 0755, true); + touch($directory . 'modman'); + } + ], + [ + 'packageExtra' => ['map' => null, 'package-xml' => 'package.xml'], 'expectedClass' => 'MagentoHackathon\Composer\Magento\PackageXmlParser', - 'composerExtra' => array( 'magento-map-overwrite' => $mapOverwrite ), + 'composerExtra' => ['magento-map-overwrite' => $mapOverwrite], 'packageName' => 'example/test1', - 'prepareCallback' => function($vendorDir){ - touch($vendorDir . DIRECTORY_SEPARATOR . 'package.xml'); - }, - ), - array( - 'packageExtra' => array('map' => array('test' => 'test')), + 'prepareCallback' => function($vendorDir) { + $directory = $this->getPackageDir($vendorDir, 'example/test1'); + mkdir($directory, 0755, true); + touch($directory . 'package.xml'); + } + ], + [ + 'packageExtra' => [ + 'map' => [['test', 'test']] + ], 'expectedClass' => 'MagentoHackathon\Composer\Magento\MapParser', - 'composerExtra' => array( 'magento-map-overwrite' => $mapOverwrite ), + 'composerExtra' => ['magento-map-overwrite' => $mapOverwrite], 'packageName' => 'example/test1', 'prepareCallback' => function($vendorDir){ }, - ), - array( - 'packageExtra' => array('map' => null), + ], + [ + 'packageExtra' => ['map' => null], 'expectedClass' => 'MagentoHackathon\Composer\Magento\ModmanParser', - 'composerExtra' => array( 'magento-map-overwrite' => $mapOverwrite ), + 'composerExtra' => ['magento-map-overwrite' => $mapOverwrite], 'packageName' => 'example/test1', - 'prepareCallback' => function($vendorDir){ - touch($vendorDir . DIRECTORY_SEPARATOR . 'modman'); - }, - ), - array( - 'packageExtra' => array('map' => null), + 'prepareCallback' => function($vendorDir) { + $directory = $this->getPackageDir($vendorDir, 'example/test1'); + mkdir($directory, 0755, true); + touch($directory . 'modman'); + } + ], + [ + 'packageExtra' => ['map' => null], 'expectedClass' => 'MagentoHackathon\Composer\Magento\MapParser', - 'composerExtra' => array( 'magento-map-overwrite' => $mapOverwrite ), + 'composerExtra' => ['magento-map-overwrite' => $mapOverwrite], 'packageName' => 'example/test2', - 'prepareCallback' => function($vendorDir){ - touch($vendorDir . DIRECTORY_SEPARATOR . 'modman'); - }, - ), - ); + 'prepareCallback' => function($vendorDir) { + $directory = $this->getPackageDir($vendorDir, 'example/test2'); + mkdir($directory, 0755, true); + touch($directory . 'modman'); + } + ], + ]; + } + + /** + * Returns package directory path for Data provider. + * + * @param string $vendorDir + * @param string $packageDir + * @return string + */ + private function getPackageDir(string $vendorDir, string $packageDir): string + { + return str_replace('/', DIRECTORY_SEPARATOR, "$vendorDir/$packageDir/"); } /* @@ -242,18 +264,18 @@ public function parserTypeProvider() protected function createPathMappingTranslationMock() { return $this->createPackageMock( - array( - 'map' => array( - array('src/app/etc/modules/Example_Name.xml', 'app/etc/modules/Example_Name.xml'), - array('src/app/code/community/Example/Name', 'app/code/community/Example/Name'), - array('src/skin', 'skin/frontend/default/default/examplename'), - array('src/js', 'js/examplename'), - array('src/media/images', 'media/examplename_images'), - array('src2/skin', './skin/frontend/default/default/examplename'), - array('src2/js', './js/examplename'), - array('src2/media/images', './media/examplename_images'), - ) - ) + [ + 'map' => [ + ['src/app/etc/modules/Example_Name.xml', 'app/etc/modules/Example_Name.xml'], + ['src/app/code/community/Example/Name', 'app/code/community/Example/Name'], + ['src/skin', 'skin/frontend/default/default/examplename'], + ['src/js', 'js/examplename'], + ['src/media/images', 'media/examplename_images'], + ['src2/skin', './skin/frontend/default/default/examplename'], + ['src2/js', './js/examplename'], + ['src2/media/images', './media/examplename_images'], + ] + ] ); } @@ -265,7 +287,7 @@ public function testEtcPathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/app/etc/modules/Example_Name.xml', 'app/etc/modules/Example_Name.xml'), $mappings); + $this->assertContains(['src/app/etc/modules/Example_Name.xml', 'app/etc/modules/Example_Name.xml'], $mappings); } /** @@ -276,7 +298,7 @@ public function testCodePathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/app/code/community/Example/Name', 'app/code/community/Example/Name'), $mappings); + $this->assertContains(['src/app/code/community/Example/Name', 'app/code/community/Example/Name'], $mappings); } /** @@ -287,7 +309,7 @@ public function testJSPathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/js', 'js/examplename'), $mappings); + $this->assertContains(['src/js', 'js/examplename'], $mappings); } /** @@ -298,7 +320,7 @@ public function testSkinPathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/skin', 'skin/frontend/default/default/examplename'), $mappings); + $this->assertContains(['src/skin', 'skin/frontend/default/default/examplename'], $mappings); } /** @@ -309,7 +331,7 @@ public function testMediaPathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/media/images', 'media/examplename_images'), $mappings); + $this->assertContains(['src/media/images', 'media/examplename_images'], $mappings); } /** @@ -320,7 +342,7 @@ public function testJSPathMappingTranslation2() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src2/js', './js/examplename'),$mappings); + $this->assertContains(['src2/js', './js/examplename'],$mappings); } /** @@ -331,7 +353,7 @@ public function testSkinPathMappingTranslation2() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src2/skin', './skin/frontend/default/default/examplename'), $mappings); + $this->assertContains(['src2/skin', './skin/frontend/default/default/examplename'], $mappings); } /** @@ -342,7 +364,7 @@ public function testMediaPathMappingTranslation2() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src2/media/images', './media/examplename_images'), $mappings); + $this->assertContains(['src2/media/images', './media/examplename_images'], $mappings); } } diff --git a/tests/MagentoHackathon/Composer/Magento/ModmanParserTest.php b/tests/MagentoHackathon/Composer/Magento/ModmanParserTest.php index afccdb92..91679a86 100644 --- a/tests/MagentoHackathon/Composer/Magento/ModmanParserTest.php +++ b/tests/MagentoHackathon/Composer/Magento/ModmanParserTest.php @@ -1,7 +1,7 @@ modmanFileDir = __DIR__ . '/data/' . $baseTestClassName . '/'; @@ -28,7 +28,7 @@ protected function setUp() * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ - protected function tearDown() + protected function tearDown(): void { } @@ -61,7 +61,7 @@ public function testSetSetModuleDirWithTrailingBackslash() */ public function testSetGetFile() { - $file = $this->getMockBuilder('\\SplFileObject')->setConstructorArgs(array(__FILE__))->getMock(); + $file = $this->getMockBuilder('\\SplFileObject')->setConstructorArgs([__FILE__])->getMock(); $this->object->setFile($file); $this->assertSame($file, $this->object->getFile()); } @@ -71,11 +71,11 @@ public function testSetGetFile() */ public function testGetMappings() { - $expected = array( - array('line/with/tab', 'record/one'), - array('line/with/space', 'record/two'), - array('line/with/space/and/tab', 'record/three') - ); + $expected = [ + ['line/with/tab', 'record/one'], + ['line/with/space', 'record/two'], + ['line/with/space/and/tab', 'record/three'] + ]; $this->object->setFile($this->modmanFileDir . 'modman'); $this->assertSame($expected, $this->object->getMappings()); } diff --git a/tests/MagentoHackathon/Composer/Magento/PathMappingTranslationTest.php b/tests/MagentoHackathon/Composer/Magento/PathMappingTranslationTest.php index 773cf5cb..48e1b1b5 100644 --- a/tests/MagentoHackathon/Composer/Magento/PathMappingTranslationTest.php +++ b/tests/MagentoHackathon/Composer/Magento/PathMappingTranslationTest.php @@ -13,7 +13,7 @@ */ class PathMappingTranslationTest extends InstallerTest { - protected function setUp() + protected function setUp(): void { $this->fs = new Filesystem; @@ -31,29 +31,31 @@ protected function setUp() $this->config = new Config(); $this->composer->setConfig($this->config); $this->composer->setPackage($this->createPackageMock( - array( - 'path-mapping-translations' => array( + [ + 'path-mapping-translations' => [ 'js/' => 'public/js/', 'media/' => 'public/media/', 'skin/' => 'public/skin/', - ) - ) + ] + ] )); - $this->config->merge(array( - 'config' => array( + $this->config->merge([ + 'config' => [ 'vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir, - ), - )); + ], + ]); $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager') ->disableOriginalConstructor() ->getMock(); $this->composer->setDownloadManager($this->dm); + $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface') + ->getMock(); - $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); - $this->io = $this->getMock('Composer\IO\IOInterface'); + $this->io = $this->getMockBuilder('Composer\IO\IOInterface') + ->getMock(); $this->object = new Installer($this->io, $this->composer); } @@ -66,7 +68,7 @@ public function testEtcPathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/app/etc/modules/Example_Name.xml', 'app/etc/modules/Example_Name.xml'), $mappings); + $this->assertContains(['src/app/etc/modules/Example_Name.xml', 'app/etc/modules/Example_Name.xml'], $mappings); } /** @@ -77,7 +79,7 @@ public function testCodePathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/app/code/community/Example/Name', 'app/code/community/Example/Name'), $mappings); + $this->assertContains(['src/app/code/community/Example/Name', 'app/code/community/Example/Name'], $mappings); } /** @@ -88,7 +90,7 @@ public function testJSPathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/js', 'public/js/examplename'), $mappings); + $this->assertContains(['src/js', 'public/js/examplename'], $mappings); } /** @@ -99,7 +101,7 @@ public function testSkinPathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/skin', 'public/skin/frontend/default/default/examplename'), $mappings); + $this->assertContains(['src/skin', 'public/skin/frontend/default/default/examplename'], $mappings); } /** @@ -110,7 +112,7 @@ public function testMediaPathMappingTranslation() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src/media/images', 'public/media/examplename_images'), $mappings); + $this->assertContains(['src/media/images', 'public/media/examplename_images'], $mappings); } /** @@ -121,7 +123,7 @@ public function testJSPathMappingTranslation2() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src2/js', 'public/js/examplename'),$mappings); + $this->assertContains(['src2/js', 'public/js/examplename'],$mappings); } /** @@ -132,7 +134,7 @@ public function testSkinPathMappingTranslation2() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src2/skin', 'public/skin/frontend/default/default/examplename'), $mappings); + $this->assertContains(['src2/skin', 'public/skin/frontend/default/default/examplename'], $mappings); } /** @@ -143,6 +145,6 @@ public function testMediaPathMappingTranslation2() $package = $this->createPathMappingTranslationMock(); $mappings = $this->object->getParser($package)->getMappings(); - $this->assertContains(array('src2/media/images', 'public/media/examplename_images'), $mappings); + $this->assertContains(['src2/media/images', 'public/media/examplename_images'], $mappings); } } diff --git a/tests/res/packages/issue76/design/Foobar/issue76.phtml b/tests/res/packages/issue76/Foobar/issue76.phtml similarity index 100% rename from tests/res/packages/issue76/design/Foobar/issue76.phtml rename to tests/res/packages/issue76/Foobar/issue76.phtml diff --git a/tests/res/packages/issue76/composer.json b/tests/res/packages/issue76/composer.json index dfa1fbda..b9090448 100644 --- a/tests/res/packages/issue76/composer.json +++ b/tests/res/packages/issue76/composer.json @@ -1,6 +1,14 @@ { - "name":"magento-hackathon/magento-composer-installer-test-issue-87", + "name":"magento/magento-composer-installer-test-issue-87", "minimum-stability":"stable", - "type":"magento-module", - "version":"1.0.0" + "type":"magento2-theme", + "version":"1.0.0", + "extra": { + "map": [ + [ + "Foobar/issue76.phtml", + "frontend/Magento/luma/Magento_ThemeMock/Foobar/issue76.phtml" + ] + ] + } } diff --git a/tests/res/packages/issue76/modman b/tests/res/packages/issue76/modman deleted file mode 100644 index efd3da7a..00000000 --- a/tests/res/packages/issue76/modman +++ /dev/null @@ -1 +0,0 @@ -design/Foobar app/design/frontend/test/default/issue76/Foobar \ No newline at end of file diff --git a/tests/res/packages/library/composer.json b/tests/res/packages/library/composer.json index 32595160..973ed566 100644 --- a/tests/res/packages/library/composer.json +++ b/tests/res/packages/library/composer.json @@ -1,5 +1,5 @@ { - "name":"magento-hackathon/magento-composer-installer-test-library", + "name":"magento/magento-composer-installer-test-library", "minimum-stability":"stable", "autoload":{ "classmap": [ diff --git a/tests/res/packages/magento2-base/composer.json b/tests/res/packages/magento2-base/composer.json new file mode 100644 index 00000000..1abaa342 --- /dev/null +++ b/tests/res/packages/magento2-base/composer.json @@ -0,0 +1,28 @@ +{ + "name":"magento/magento2-base-mock", + "type":"magento2-component", + "version":"1.0.0", + "require" : { + "magento/magento-composer-installer": "*" + }, + "extra": { + "map": [ + [ + "app/code", + "app/code" + ], + [ + "app/design", + "app/design" + ], + [ + "app/etc", + "app/etc" + ], + [ + "app/i18n", + "app/i18n" + ] + ] + } +} diff --git a/tests/res/packages/magento2-module/composer.json b/tests/res/packages/magento2-module/composer.json new file mode 100644 index 00000000..69b900bc --- /dev/null +++ b/tests/res/packages/magento2-module/composer.json @@ -0,0 +1,13 @@ +{ + "name":"magento/magento2-module-mock", + "type":"magento2-module", + "version":"1.0.0", + "extra": { + "map": [ + [ + "*", + "Magento/ModuleMock" + ] + ] + } +} diff --git a/tests/res/packages/magento2-module/etc/module.xml b/tests/res/packages/magento2-module/etc/module.xml new file mode 100644 index 00000000..c6d34d21 --- /dev/null +++ b/tests/res/packages/magento2-module/etc/module.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/tests/res/packages/sort1/composer.json b/tests/res/packages/sort1/composer.json index 31f44999..4b18b194 100644 --- a/tests/res/packages/sort1/composer.json +++ b/tests/res/packages/sort1/composer.json @@ -1,6 +1,14 @@ { - "name":"magento-hackathon/magento-composer-installer-test-sort1", + "name":"magento/magento-composer-installer-test-sort1", "minimum-stability":"stable", - "type":"magento-module", - "version":"1.0.0" + "type":"magento2-theme", + "version":"1.0.0", + "extra": { + "map": [ + [ + "*", + "frontend/Magento/luma/Magento_SortThemeMock" + ] + ] + } } diff --git a/tests/res/packages/sort1/modman b/tests/res/packages/sort1/modman deleted file mode 100644 index 48f2f36a..00000000 --- a/tests/res/packages/sort1/modman +++ /dev/null @@ -1 +0,0 @@ -design app/design/frontend/test/default/installSort/ \ No newline at end of file diff --git a/tests/res/packages/sort2/composer.json b/tests/res/packages/sort2/composer.json index f17c7fea..449b403d 100644 --- a/tests/res/packages/sort2/composer.json +++ b/tests/res/packages/sort2/composer.json @@ -1,6 +1,14 @@ { - "name":"magento-hackathon/magento-composer-installer-test-sort2", + "name":"magento/magento-composer-installer-test-sort2", "minimum-stability":"stable", - "type":"magento-module", - "version":"1.0.0" + "type":"magento2-theme", + "version":"1.0.0", + "extra": { + "map": [ + [ + "*", + "frontend/Magento/luma/Magento_SortThemeMock" + ] + ] + } } diff --git a/tests/res/packages/sort2/modman b/tests/res/packages/sort2/modman deleted file mode 100644 index 48f2f36a..00000000 --- a/tests/res/packages/sort2/modman +++ /dev/null @@ -1 +0,0 @@ -design app/design/frontend/test/default/installSort/ \ No newline at end of file diff --git a/tests/res/packages/sort3/composer.json b/tests/res/packages/sort3/composer.json index f4025ef3..60b5a498 100644 --- a/tests/res/packages/sort3/composer.json +++ b/tests/res/packages/sort3/composer.json @@ -1,6 +1,14 @@ { - "name":"magento-hackathon/magento-composer-installer-test-sort3", + "name":"magento/magento-composer-installer-test-sort3", "minimum-stability":"stable", - "type":"magento-module", - "version":"1.0.0" + "type":"magento2-theme", + "version":"1.0.0", + "extra": { + "map": [ + [ + "*", + "frontend/Magento/luma/Magento_SortThemeMock" + ] + ] + } } diff --git a/tests/res/packages/sort3/modman b/tests/res/packages/sort3/modman deleted file mode 100644 index 48f2f36a..00000000 --- a/tests/res/packages/sort3/modman +++ /dev/null @@ -1 +0,0 @@ -design app/design/frontend/test/default/installSort/ \ No newline at end of file diff --git a/tests/res/packages/updateFileRemove_1/composer.json b/tests/res/packages/updateFileRemove_1/composer.json index b81c7463..5d9d988d 100644 --- a/tests/res/packages/updateFileRemove_1/composer.json +++ b/tests/res/packages/updateFileRemove_1/composer.json @@ -1,5 +1,5 @@ { - "name":"magento-hackathon/magento-composer-installer-test-updateFileRemove", + "name":"magento/magento-composer-installer-test-update-file-remove", "minimum-stability":"stable", "type":"magento-module", "version":"1.0.0" diff --git a/tests/res/packages/updateFileRemove_2/composer.json b/tests/res/packages/updateFileRemove_2/composer.json index 84728265..1e48c785 100644 --- a/tests/res/packages/updateFileRemove_2/composer.json +++ b/tests/res/packages/updateFileRemove_2/composer.json @@ -1,5 +1,5 @@ { - "name":"magento-hackathon/magento-composer-installer-test-updateFileRemove", + "name":"magento/magento-composer-installer-test-update-file-remove", "minimum-stability":"stable", "type":"magento-module", "version":"2.0.0" diff --git a/tests/res/packages/wildcard/composer.json b/tests/res/packages/wildcard/composer.json index c00e59b7..a2c9b8d6 100644 --- a/tests/res/packages/wildcard/composer.json +++ b/tests/res/packages/wildcard/composer.json @@ -1,6 +1,14 @@ { - "name":"magento-hackathon/magento-composer-installer-test-wildcard", + "name":"magento/magento-composer-installer-test-wildcard", "minimum-stability":"stable", - "type":"magento-module", - "version":"1.0.0" + "type":"magento2-theme", + "version":"1.0.0", + "extra": { + "map": [ + [ + "*", + "adminhtml/Magento/luma/Magento_AdminThemeMock" + ] + ] + } } diff --git a/tests/res/packages/wildcard/modman b/tests/res/packages/wildcard/modman deleted file mode 100644 index 6f227f5f..00000000 --- a/tests/res/packages/wildcard/modman +++ /dev/null @@ -1 +0,0 @@ -design/* app/design/frontend/ diff --git a/tests/res/packages/wildcard/design/wildcard/wildcard.phtml b/tests/res/packages/wildcard/wildcard/wildcard.phtml similarity index 100% rename from tests/res/packages/wildcard/design/wildcard/wildcard.phtml rename to tests/res/packages/wildcard/wildcard/wildcard.phtml diff --git a/tests/res/packages/wildcard2/composer.json b/tests/res/packages/wildcard2/composer.json index 74b7e524..c42d1486 100644 --- a/tests/res/packages/wildcard2/composer.json +++ b/tests/res/packages/wildcard2/composer.json @@ -1,5 +1,5 @@ { - "name":"magento-hackathon/magento-composer-installer-test-wildcard2", + "name":"magento/magento-composer-installer-test-wildcard2", "minimum-stability":"stable", "type":"magento-module", "version":"1.0.0" diff --git a/tests/res/packages/wildcard2/modman b/tests/res/packages/wildcard2/modman deleted file mode 100644 index cca591d9..00000000 --- a/tests/res/packages/wildcard2/modman +++ /dev/null @@ -1 +0,0 @@ -* /