diff --git a/app/code/Magento/Backup/Model/Backup.php b/app/code/Magento/Backup/Model/Backup.php index 6688c369019392c0f841f1c5f35a3bf7d73a5312..71eec41eadb101c2520b6cfe84db6504fc2d45a1 100644 --- a/app/code/Magento/Backup/Model/Backup.php +++ b/app/code/Magento/Backup/Model/Backup.php @@ -6,6 +6,7 @@ namespace Magento\Backup\Model; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem\DriverPool; /** * Backup file item model @@ -293,11 +294,10 @@ class Backup extends \Magento\Framework\Object implements \Magento\Framework\Bac try { /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $varDirectory */ - $varDirectory = $this->_filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); + $varDirectory = $this->_filesystem->getDirectoryWrite(DirectoryList::VAR_DIR, DriverPool::ZLIB); $this->_stream = $varDirectory->openFile( $this->_getFilePath(), - $mode, - \Magento\Framework\Filesystem\DriverPool::ZLIB + $mode ); } catch (\Magento\Framework\Filesystem\FilesystemException $e) { throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions( diff --git a/app/code/Magento/Customer/Model/Resource/Address.php b/app/code/Magento/Customer/Model/Resource/Address.php index bec7eec4634435e086829198f20f6284aea49c25..c047a54d3eeb81ef3976e7041ff68b8e382d1ae2 100644 --- a/app/code/Magento/Customer/Model/Resource/Address.php +++ b/app/code/Magento/Customer/Model/Resource/Address.php @@ -12,7 +12,7 @@ use Magento\Framework\Exception\InputException; class Address extends \Magento\Eav\Model\Entity\AbstractEntity { /** - * @var \Magento\Core\Model\Validator\Factory + * @var \Magento\Framework\Validator\Factory */ protected $_validatorFactory; @@ -28,7 +28,7 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Core\Model\Validator\Factory $validatorFactory + * @param \Magento\Framework\Validator\Factory $validatorFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param array $data */ @@ -39,7 +39,7 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Core\Model\Validator\Factory $validatorFactory, + \Magento\Framework\Validator\Factory $validatorFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, $data = [] ) { diff --git a/app/code/Magento/Customer/Model/Resource/Customer.php b/app/code/Magento/Customer/Model/Resource/Customer.php index 07527e8100ad5aa0d1f914936526421c37683463..4577a1a113bd39fa1c78c09f597b640e99e12f8f 100644 --- a/app/code/Magento/Customer/Model/Resource/Customer.php +++ b/app/code/Magento/Customer/Model/Resource/Customer.php @@ -14,7 +14,7 @@ use Magento\Framework\Exception\InputException; class Customer extends \Magento\Eav\Model\Entity\AbstractEntity { /** - * @var \Magento\Core\Model\Validator\Factory + * @var \Magento\Framework\Validator\Factory */ protected $_validatorFactory; @@ -38,7 +38,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Core\Model\Validator\Factory $validatorFactory + * @param \Magento\Framework\Validator\Factory $validatorFactory * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -51,7 +51,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Core\Model\Validator\Factory $validatorFactory, + \Magento\Framework\Validator\Factory $validatorFactory, \Magento\Framework\Stdlib\DateTime $dateTime, $data = [] ) { diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php index ca38c73e7c6243ea8e1610b4b5aba0425f9876d9..dbc58086db9bc348c5b92496c4c489e4b68cdc7f 100644 --- a/app/code/Magento/Email/Model/AbstractTemplate.php +++ b/app/code/Magento/Email/Model/AbstractTemplate.php @@ -56,7 +56,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn protected $_design = null; /** - * @var \Magento\Core\Model\App\Emulation + * @var \Magento\Store\Model\App\Emulation */ protected $_appEmulation; @@ -69,7 +69,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry - * @param \Magento\Core\Model\App\Emulation $appEmulation + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param array $data */ @@ -77,7 +77,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, - \Magento\Core\Model\App\Emulation $appEmulation, + \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, array $data = [] ) { diff --git a/app/code/Magento/Email/Model/BackendTemplate.php b/app/code/Magento/Email/Model/BackendTemplate.php index abc963099c9b558588bf5580684ba0700116a2f4..27c6084b4382fb0ac0aad564a7d5edf92742ebad 100644 --- a/app/code/Magento/Email/Model/BackendTemplate.php +++ b/app/code/Magento/Email/Model/BackendTemplate.php @@ -21,7 +21,7 @@ class BackendTemplate extends Template * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry - * @param \Magento\Core\Model\App\Emulation $appEmulation + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo @@ -38,7 +38,7 @@ class BackendTemplate extends Template \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, - \Magento\Core\Model\App\Emulation $appEmulation, + \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\View\Asset\Repository $assetRepo, diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index a397317ff4cd9474192f26d83d8a35f0a30fe07f..e3b52978ca6541b3004af2ed20b1d42fe9ab9575 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -157,7 +157,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry - * @param \Magento\Core\Model\App\Emulation $appEmulation + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo @@ -173,7 +173,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, - \Magento\Core\Model\App\Emulation $appEmulation, + \Magento\Store\Model\App\Emulation $appEmulation, StoreManagerInterface $storeManager, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\View\Asset\Repository $assetRepo, diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 8c58ed17a58db7daa90139c2b0d80b54a63b3a2b..72239c7dcfabd57bc466a3773e292e719169dfbf 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -115,7 +115,7 @@ class Queue extends \Magento\Email\Model\AbstractTemplate * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry - * @param \Magento\Core\Model\App\Emulation $appEmulation + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Newsletter\Model\Template\Filter $templateFilter * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -131,7 +131,7 @@ class Queue extends \Magento\Email\Model\AbstractTemplate \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, - \Magento\Core\Model\App\Emulation $appEmulation, + \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Newsletter\Model\Template\Filter $templateFilter, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index 6733903b3a65303ef74d6d33c1770ca6989157b2..4ff5e4d526c661f2cad580ffdf468e27c121da3a 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -94,7 +94,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry - * @param \Magento\Core\Model\App\Emulation $appEmulation + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Newsletter\Model\Template\Filter $filter @@ -108,7 +108,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, - \Magento\Core\Model\App\Emulation $appEmulation, + \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Newsletter\Model\Template\Filter $filter, diff --git a/app/code/Magento/Payment/Helper/Data.php b/app/code/Magento/Payment/Helper/Data.php index 4b7de3300964aefdea3322972c310c0a5ddc41a7..6f77f919472e893a745e1ae516f3c7dc88e90cac 100644 --- a/app/code/Magento/Payment/Helper/Data.php +++ b/app/code/Magento/Payment/Helper/Data.php @@ -53,7 +53,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * App emulation model * - * @var \Magento\Core\Model\App\Emulation + * @var \Magento\Store\Model\App\Emulation */ protected $_appEmulation; @@ -69,7 +69,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param LayoutFactory $layoutFactory * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory - * @param \Magento\Core\Model\App\Emulation $appEmulation + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Payment\Model\Config $paymentConfig * @param \Magento\Framework\App\Config\Initial $initialConfig */ @@ -78,7 +78,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, LayoutFactory $layoutFactory, \Magento\Payment\Model\Method\Factory $paymentMethodFactory, - \Magento\Core\Model\App\Emulation $appEmulation, + \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Payment\Model\Config $paymentConfig, \Magento\Framework\App\Config\Initial $initialConfig ) { diff --git a/app/code/Magento/ProductAlert/Model/Email.php b/app/code/Magento/ProductAlert/Model/Email.php index 94d37b405395dc157885bef651e8aac37ee49d27..395d2d9bef1416d60602e56d3dce9b3d8fdf1ea9 100644 --- a/app/code/Magento/ProductAlert/Model/Email.php +++ b/app/code/Magento/ProductAlert/Model/Email.php @@ -93,7 +93,7 @@ class Email extends \Magento\Framework\Model\AbstractModel protected $customerRepository; /** - * @var \Magento\Core\Model\App\Emulation + * @var \Magento\Store\Model\App\Emulation */ protected $_appEmulation; @@ -115,7 +115,7 @@ class Email extends \Magento\Framework\Model\AbstractModel * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository * @param \Magento\Customer\Helper\View $customerHelper - * @param \Magento\Core\Model\App\Emulation $appEmulation + * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -130,7 +130,7 @@ class Email extends \Magento\Framework\Model\AbstractModel \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, \Magento\Customer\Helper\View $customerHelper, - \Magento\Core\Model\App\Emulation $appEmulation, + \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Core/Model/App/Emulation.php b/app/code/Magento/Store/Model/App/Emulation.php similarity index 98% rename from app/code/Magento/Core/Model/App/Emulation.php rename to app/code/Magento/Store/Model/App/Emulation.php index 85f57ad61706303c0d05926efde1d96c1126a7a5..5b64511218ac279cc0bc1bb8c56a4e73436d9f8a 100644 --- a/app/code/Magento/Core/Model/App/Emulation.php +++ b/app/code/Magento/Store/Model/App/Emulation.php @@ -9,8 +9,9 @@ * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Core\Model\App; +namespace Magento\Store\Model\App; +use Magento\Framework\Object; use Magento\Framework\Translate\Inline\ConfigInterface; class Emulation extends \Magento\Framework\Object @@ -145,7 +146,7 @@ class Emulation extends \Magento\Framework\Object * * Function restores initial store environment * - * @return \Magento\Core\Model\App\Emulation + * @return \Magento\Store\Model\App\Emulation */ public function stopEnvironmentEmulation() { diff --git a/composer.json b/composer.json index 675ca726dafc5f9ac4f57b9d8ac122d5b1e03644..64f4d82c9d865f6e72914ece47865acfa5d54131 100644 --- a/composer.json +++ b/composer.json @@ -143,7 +143,6 @@ "magento/language-pt_br": "self.version", "magento/language-zh_cn": "self.version", "magento/framework": "self.version", - "magento/project-setup": "0.1.0", "oyejorge/less.php": "1.7.0", "trentrichardson/jquery-timepicker-addon": "1.4.3", "components/handlebars.js": "1.3.0", diff --git a/composer.lock b/composer.lock index d9dde5fab26f383959bee5f375672ca6dc80df7d..7b97eaf296a318fe02d104c15f032bca9537ba42 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "26d01745182292ebe1704daed40c6d4a", + "hash": "b2434120b753fdef32c2584eade97c9d", "packages": [ { "name": "composer/composer", @@ -1821,16 +1821,16 @@ }, { "name": "fabpot/php-cs-fixer", - "version": "v1.3", + "version": "v1.4", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "653cefbf33241185b58f7323157f1829552e370d" + "reference": "72a8c34210c0fbd8caa007fccea87a59f6f0a4d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/653cefbf33241185b58f7323157f1829552e370d", - "reference": "653cefbf33241185b58f7323157f1829552e370d", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/72a8c34210c0fbd8caa007fccea87a59f6f0a4d3", + "reference": "72a8c34210c0fbd8caa007fccea87a59f6f0a4d3", "shasum": "" }, "require": { @@ -1843,15 +1843,13 @@ "symfony/process": "~2.3", "symfony/stopwatch": "~2.5" }, + "require-dev": { + "satooshi/php-coveralls": "0.7.*@dev" + }, "bin": [ "php-cs-fixer" ], "type": "application", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Symfony\\CS\\": "Symfony/CS/" @@ -1872,20 +1870,20 @@ } ], "description": "A script to automatically fix Symfony Coding Standard", - "time": "2014-12-12 06:09:01" + "time": "2015-01-12 21:28:53" }, { "name": "league/climate", - "version": "2.6.0", + "version": "2.6.1", "source": { "type": "git", "url": "https://github.com/thephpleague/climate.git", - "reference": "776b6c3b32837832a9f6d94f134b55cb7910ece6" + "reference": "28851c909017424f61cc6a62089316313c645d1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/climate/zipball/776b6c3b32837832a9f6d94f134b55cb7910ece6", - "reference": "776b6c3b32837832a9f6d94f134b55cb7910ece6", + "url": "https://api.github.com/repos/thephpleague/climate/zipball/28851c909017424f61cc6a62089316313c645d1c", + "reference": "28851c909017424f61cc6a62089316313c645d1c", "shasum": "" }, "require": { @@ -1921,7 +1919,7 @@ "php", "terminal" ], - "time": "2015-01-08 02:28:23" + "time": "2015-01-18 14:31:58" }, { "name": "lusitanian/oauth", @@ -2261,16 +2259,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "f8d5d08c56de5cfd592b3340424a81733259a876" + "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876", - "reference": "f8d5d08c56de5cfd592b3340424a81733259a876", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/db32c18eba00b121c145575fcbcd4d4d24e6db74", + "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74", "shasum": "" }, "require": { @@ -2283,7 +2281,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -2306,7 +2304,7 @@ "keywords": [ "tokenizer" ], - "time": "2014-08-31 06:12:13" + "time": "2015-01-17 09:51:32" }, { "name": "phpunit/phpunit", diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php index 3344852fa45c5412ff7245095c2a19395a99048e..a1f054261ad1d8963c4614e426c90e3874ceefe0 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php @@ -34,7 +34,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase $objectManager->get('Magento\Framework\Model\Context'), $objectManager->get('Magento\Framework\View\DesignInterface'), $objectManager->get('Magento\Framework\Registry'), - $objectManager->get('Magento\Core\Model\App\Emulation'), + $objectManager->get('Magento\Store\Model\App\Emulation'), $objectManager->get('Magento\Store\Model\StoreManager'), $objectManager->create('Magento\Framework\Filesystem'), $objectManager->create('Magento\Framework\View\Asset\Repository'), diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Validator/FactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php similarity index 81% rename from dev/tests/integration/testsuite/Magento/Core/Model/Validator/FactoryTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php index eeaaba1172a8bf836b52d8e4dd4bead5f5645de3..2a25d44f2b656b0d6a08d07b1404b11b1557c224 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Validator/FactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php @@ -1,11 +1,11 @@ <?php /** - * Integration test for \Magento\Core\Model\Validator\Factory + * Integration test for \Magento\Framework\Validator\Factory * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Model\Validator; +namespace Magento\Framework\Validator; class FactoryTest extends \PHPUnit_Framework_TestCase { @@ -17,8 +17,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase public function testGetValidatorConfig() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var \Magento\Core\Model\Validator\Factory $factory */ - $factory = $objectManager->get('Magento\Core\Model\Validator\Factory'); + /** @var \Magento\Framework\Validator\Factory $factory */ + $factory = $objectManager->get('Magento\Framework\Validator\Factory'); $this->assertInstanceOf('Magento\Framework\Validator\Config', $factory->getValidatorConfig()); // Check that default translator was set $translator = \Magento\Framework\Validator\AbstractValidator::getDefaultTranslator(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/App/EmulationTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/App/EmulationTest.php similarity index 75% rename from dev/tests/integration/testsuite/Magento/Core/Model/App/EmulationTest.php rename to dev/tests/integration/testsuite/Magento/Store/Model/App/EmulationTest.php index 6bd0071e9409f9d301de908f5137e8f1e084a735..d374b8cea90345fe3f13f7765fb2d1bf42133327 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/App/EmulationTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/App/EmulationTest.php @@ -3,23 +3,23 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Model\App; +namespace Magento\Store\Model\App; class EmulationTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\App\Emulation + * @var \Magento\Store\Model\App\Emulation */ protected $_model; /** - * @covers \Magento\Core\Model\App\Emulation::startEnvironmentEmulation - * @covers \Magento\Core\Model\App\Emulation::stopEnvironmentEmulation + * @covers \Magento\Store\Model\App\Emulation::startEnvironmentEmulation + * @covers \Magento\Store\Model\App\Emulation::stopEnvironmentEmulation */ public function testEnvironmentEmulation() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\App\Emulation'); + ->create('Magento\Store\Model\App\Emulation'); \Magento\TestFramework\Helper\Bootstrap::getInstance() ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..97039e891351231f60d6c028e57585596dfd78aa --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php @@ -0,0 +1,439 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Test\Integrity; + +use Magento\Framework\Composer\MagentoComponent; +use Magento\Framework\Test\Utility\Files; +use Magento\Framework\Shell; +use Magento\Framework\Exception; + +/** + * A test that enforces validity of composer.json files and any other conventions in Magento components + */ +class ComposerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Shell + */ + private static $shell; + + /** + * @var bool + */ + private static $isComposerAvailable; + + /** + * @var string + */ + private static $root; + + /** + * @var \stdClass + */ + private static $rootJson; + + /** + * @var array + */ + private static $dependencies; + + /** + * @var string + */ + private static $composerPath = 'composer'; + + public static function setUpBeforeClass() + { + if (defined('TESTS_COMPOSER_PATH')) { + self::$composerPath = TESTS_COMPOSER_PATH; + } + self::$shell = self::createShell(); + self::$isComposerAvailable = self::isComposerAvailable(); + self::$root = Files::init()->getPathToSource(); + self::$rootJson = json_decode(file_get_contents(self::$root . '/composer.json'), true); + self::$dependencies = []; + } + + public function testValidComposerJson() + { + $invoker = new \Magento\Framework\Test\Utility\AggregateInvoker($this); + $invoker( + /** + * @param string $dir + * @param string $packageType + */ + function ($dir, $packageType) { + $this->assertComposerAvailable(); + $file = $dir . '/composer.json'; + $this->assertFileExists($file); + self::$shell->execute(self::$composerPath . ' validate --working-dir=%s', [$dir]); + $contents = file_get_contents($file); + $json = json_decode($contents); + $this->assertCodingStyle($contents); + $this->assertMagentoConventions($dir, $packageType, $json); + }, + $this->validateComposerJsonDataProvider() + ); + } + + /** + * @return array + */ + public function validateComposerJsonDataProvider() + { + $root = \Magento\Framework\Test\Utility\Files::init()->getPathToSource(); + $result = []; + foreach (glob("{$root}/app/code/Magento/*", GLOB_ONLYDIR) as $dir) { + $result[$dir] = [$dir, 'magento2-module']; + } + foreach (glob("{$root}/app/i18n/magento/*", GLOB_ONLYDIR) as $dir) { + $result[$dir] = [$dir, 'magento2-language']; + } + foreach (glob("{$root}/app/design/adminhtml/Magento/*", GLOB_ONLYDIR) as $dir) { + $result[$dir] = [$dir, 'magento2-theme']; + } + foreach (glob("{$root}/app/design/frontend/Magento/*", GLOB_ONLYDIR) as $dir) { + $result[$dir] = [$dir, 'magento2-theme']; + } + foreach (glob("{$root}/lib/internal/Magento/*", GLOB_ONLYDIR) as $dir) { + $result[$dir] = [$dir, 'magento2-library']; + } + $result[$root] = [$root, 'project']; + + return $result; + } + + /** + * Some of coding style conventions + * + * @param string $contents + */ + private function assertCodingStyle($contents) + { + $this->assertNotRegExp('/" :\s*["{]/', $contents, 'Coding style: no space before colon.'); + $this->assertNotRegExp('/":["{]/', $contents, 'Coding style: a space is necessary after colon.'); + } + + /** + * Enforce Magento-specific conventions to a composer.json file + * + * @param string $dir + * @param string $packageType + * @param \StdClass $json + * @throws \InvalidArgumentException + */ + private function assertMagentoConventions($dir, $packageType, \StdClass $json) + { + $this->assertObjectHasAttribute('name', $json); + $this->assertObjectHasAttribute('license', $json); + $this->assertObjectHasAttribute('type', $json); + $this->assertObjectHasAttribute('version', $json); + $this->assertVersionInSync($json->name, $json->version); + $this->assertObjectHasAttribute('require', $json); + $this->assertEquals($packageType, $json->type); + if ($packageType !== 'project') { + self::$dependencies[] = $json->name; + $this->assertHasMap($json); + $this->assertMapConsistent($dir, $json); + } + switch ($packageType) { + case 'magento2-module': + $xml = simplexml_load_file("$dir/etc/module.xml"); + $this->assertConsistentModuleName($xml, $json->name); + $this->assertDependsOnPhp($json->require); + $this->assertDependsOnFramework($json->require); + $this->assertDependsOnInstaller($json->require); + $this->assertRequireInSync($json); + break; + case 'magento2-language': + $this->assertRegExp('/^magento\/language\-[a-z]{2}_[a-z]{2}$/', $json->name); + $this->assertDependsOnFramework($json->require); + $this->assertDependsOnInstaller($json->require); + $this->assertRequireInSync($json); + break; + case 'magento2-theme': + $this->assertRegExp('/^magento\/theme-(?:adminhtml|frontend)(\-[a-z0-9_]+)+$/', $json->name); + $this->assertDependsOnPhp($json->require); + $this->assertDependsOnFramework($json->require); + $this->assertDependsOnInstaller($json->require); + $this->assertRequireInSync($json); + break; + case 'magento2-library': + $this->assertDependsOnPhp($json->require); + $this->assertRegExp('/^magento\/framework$/', $json->name); + $this->assertDependsOnInstaller($json->require); + $this->assertRequireInSync($json); + break; + case 'project': + sort(self::$dependencies); + $dependenciesListed = []; + foreach (array_keys((array)self::$rootJson['replace']) as $key) { + if (MagentoComponent::matchMagentoComponent($key)) { + $dependenciesListed[] = $key; + } + } + sort($dependenciesListed); + $nonDeclaredDependencies = array_diff(self::$dependencies, $dependenciesListed); + $nonexistentDependencies = array_diff($dependenciesListed, self::$dependencies); + $this->assertEmpty( + $nonDeclaredDependencies, + 'Following dependencies are not declared in the root composer.json: ' + . join(', ', $nonDeclaredDependencies) + ); + $this->assertEmpty( + $nonexistentDependencies, + 'Following dependencies declared in the root composer.json do not exist: ' + . join(', ', $nonexistentDependencies) + ); + break; + default: + throw new \InvalidArgumentException("Unknown package type {$packageType}"); + } + } + + /** + * Assert that there is map in specified composer json + * + * @param \StdClass $json + */ + private function assertHasMap(\StdClass $json) + { + $error = 'There must be an "extra->map" node in composer.json of each Magento component.'; + $this->assertObjectHasAttribute('extra', $json, $error); + $this->assertObjectHasAttribute('map', $json->extra, $error); + $this->assertInternalType('array', $json->extra->map, $error); + } + + /** + * Assert that component directory name and mapping information are consistent + * + * @param string $dir + * @param \StdClass $json + */ + private function assertMapConsistent($dir, $json) + { + preg_match('/^.+\/(.+)\/(.+)$/', $dir, $matches); + list(, $vendor, $name) = $matches; + $map = $json->extra->map; + $this->assertArrayHasKey(0, $map); + $this->assertArrayHasKey(1, $map[0]); + $this->assertRegExp( + "/{$vendor}\\/{$name}$/", + $map[0][1], + 'Mapping info is inconsistent with the directory structure' + ); + } + + /** + * Enforce package naming conventions for modules + * + * @param \SimpleXMLElement $xml + * @param string $packageName + */ + private function assertConsistentModuleName(\SimpleXMLElement $xml, $packageName) + { + $moduleName = (string)$xml->module->attributes()->name; + $this->assertEquals( + $packageName, + $this->convertModuleToPackageName($moduleName), + "For the module '{$moduleName}', the expected package name is '{$packageName}'" + ); + } + + /** + * Make sure a component depends on php version + * + * @param \StdClass $json + */ + private function assertDependsOnPhp(\StdClass $json) + { + $this->assertObjectHasAttribute('php', $json, 'This component is expected to depend on certain PHP version(s)'); + } + + /** + * Make sure a component depends on magento/framework component + * + * @param \StdClass $json + */ + private function assertDependsOnFramework(\StdClass $json) + { + $this->assertObjectHasAttribute( + 'magento/framework', + $json, + 'This component is expected to depend on magento/framework' + ); + } + + /** + * Make sure a component depends on Magento Composer Installer component + * + * @param \StdClass $json + */ + private function assertDependsOnInstaller(\StdClass $json) + { + $this->assertObjectHasAttribute( + 'magento/magento-composer-installer', + $json, + 'This component is expected to depend on magento/magento-composer-installer' + ); + } + + /** + * Assert that versions in root composer.json and Magento component's composer.json are not out of sync + * + * @param string $name + * @param string $version + */ + private function assertVersionInSync($name, $version) + { + $this->assertEquals( + self::$rootJson['version'], + $version, + "Version {$version} in component {$name} is inconsistent with version " + . self::$rootJson['version'] . ' in root composer.json' + ); + } + + /** + * Make sure requirements of components are reflected in root composer.json + * + * @param \StdClass $json + */ + private function assertRequireInSync(\StdClass $json) + { + $name = $json->name; + if (isset($json->require)) { + $errors = []; + foreach (array_keys((array)$json->require) as $depName) { + if ($depName == 'magento/magento-composer-installer') { + // Magento Composer Installer is not needed for already existing components + continue; + } + if (!isset(self::$rootJson['require-dev'][$depName]) && !isset(self::$rootJson['require'][$depName]) + && !isset(self::$rootJson['replace'][$depName])) { + $errors[] = "'$name' depends on '$depName'"; + } + } + if (!empty($errors)) { + $this->fail( + "The following dependencies are missing in root 'composer.json'," + . " while declared in child components.\n" + . "Consider adding them to 'require-dev' section (if needed for child components only)," + . " to 'replace' section (if they are present in the project)," + . " to 'require' section (if needed for the skeleton).\n" + . join("\n", $errors) + ); + } + } + } + + /** + * Convert a fully qualified module name to a composer package name according to conventions + * + * @param string $moduleName + * @return string + */ + private function convertModuleToPackageName($moduleName) + { + list($vendor, $name) = explode('_', $moduleName, 2); + $package = 'module'; + foreach (preg_split('/([A-Z][a-z\d]+)/', $name, -1, PREG_SPLIT_DELIM_CAPTURE) as $chunk) { + $package .= $chunk ? "-{$chunk}" : ''; + } + return strtolower("{$vendor}/{$package}"); + } + + /** + * Create shell wrapper + * + * @return \Magento\Framework\Shell + */ + private static function createShell() + { + return new Shell(new Shell\CommandRenderer, null); + } + + /** + * Check if composer command is available in the environment + * + * @return bool + */ + private static function isComposerAvailable() + { + try { + self::$shell->execute(self::$composerPath . ' --version'); + } catch (Exception $e) { + return false; + } + return true; + } + + /** + * Skip the test if composer is unavailable + */ + private function assertComposerAvailable() + { + if (!self::$isComposerAvailable) { + $this->markTestSkipped(); + } + } + + public function testComponentPathsInRoot() + { + if (!isset(self::$rootJson['extra']) || !isset(self::$rootJson['extra']['component_paths'])) { + $this->markTestSkipped("The root composer.json file doesn't mention any extra component paths information"); + } + $this->assertArrayHasKey( + 'replace', + self::$rootJson, + "If there are any component paths specified, then they must be reflected in 'replace' section" + ); + $flat = $this->getFlatPathsInfo(self::$rootJson['extra']['component_paths']); + while (list(, list($component, $path)) = each($flat)) { + $this->assertFileExists( + self::$root . '/' . $path, + "Missing or invalid component path: {$component} -> {$path}" + ); + $this->assertArrayHasKey( + $component, + self::$rootJson['replace'], + "The {$component} is specified in 'extra->component_paths', but missing in 'replace' section" + ); + } + foreach (array_keys(self::$rootJson['replace']) as $replace) { + if (!MagentoComponent::matchMagentoComponent($replace)) { + $this->assertArrayHasKey( + $replace, + self::$rootJson['extra']['component_paths'], + "The {$replace} is specified in 'replace', but missing in 'extra->component_paths' section" + ); + } + } + } + + /** + * @param array $info + * @return array + * @throws \Exception + */ + private function getFlatPathsInfo(array $info) + { + $flat = []; + foreach ($info as $key => $element) { + if (is_string($element)) { + $flat[] = [$key, $element]; + } elseif (is_array($element)) { + foreach ($element as $path) { + $flat[] = [$key, $path]; + } + } else { + throw new \Exception("Unexpected element 'in extra->component_paths' section"); + } + } + + return $flat; + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 50c4be7bfcaccea0ba7e01ab0070c4c669a2ab84..f12e7d360fea297c329082f978afe83b0d77d3db 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -1302,6 +1302,7 @@ return [ ['Magento\Core\Controller\Varien\DispatchableInterface'], ['Magento\Core\Controller\Varien\Front', 'Magento\Framework\App\FrontController'], ['Magento\Core\Controller\FrontInterface', 'Magento\Framework\App\FrontControllerInterface'], + ['Magento\Core\Model\App\Emulation', 'Magento\Store\Model\App\Emulation'], ['Magento\Core\Model\App\Handler'], ['Magento\Core\Model\App\Proxy'], ['Magento\Core\Model\Event\Config\SchemaLocator', 'Magento\Framework\Event\Config\SchemaLocator'], @@ -2853,4 +2854,5 @@ return [ ['Magento\Sales\Model\Quote\Address\Total\Nominal\Collector'], ['Magento\Sales\Model\Quote\Address\Total\Nominal\Shipping'], ['Magento\Sales\Model\Quote\Address\Total\Nominal\Subtotal'], + ['Magento\Core\Model\Validator\Factory', 'Magento\Framework\Validator\Factory'], ]; diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Resource/AddressTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Resource/AddressTest.php index da1843a4172dcce7ff823ac017aabb31a6819b8a..ec8a8a50763b4690bc405c8403869b560111cb87 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Resource/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Resource/AddressTest.php @@ -232,7 +232,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase /** * Prepare validator mock object * - * @return \Magento\Core\Model\Validator\Factory|\PHPUnit_Framework_MockObject_MockObject + * @return \Magento\Framework\Validator\Factory|\PHPUnit_Framework_MockObject_MockObject */ protected function prepareValidatorFactory() { @@ -242,7 +242,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase ->willReturn(true); $validatorFactory = $this->getMock( - 'Magento\Core\Model\Validator\Factory', + 'Magento\Framework\Validator\Factory', ['createValidator'], [], '', diff --git a/dev/tests/unit/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/unit/testsuite/Magento/Email/Model/TemplateTest.php index 7ff2358c4f2418b84133c905af8d97a756a2532c..f63b91e5ea668c01c7e135ebc1affea073fc133f 100644 --- a/dev/tests/unit/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/unit/testsuite/Magento/Email/Model/TemplateTest.php @@ -30,7 +30,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Framework\Model\Context', [], [], '', false), $this->getMock('Magento\Core\Model\View\Design', [], [], '', false), $this->getMock('Magento\Framework\Registry', [], [], '', false), - $this->getMock('Magento\Core\Model\App\Emulation', [], [], '', false), + $this->getMock('Magento\Store\Model\App\Emulation', [], [], '', false), $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false), $this->getMock('Magento\Framework\Filesystem', [], [], '', false), $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false), diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/View/Asset/PublisherTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/View/Asset/PublisherTest.php index 4b3658be21981a6966f106cddeb526eee19a55ea..6d5c40ea63d013761e9fe36364cee1db4d29c641 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/View/Asset/PublisherTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/View/Asset/PublisherTest.php @@ -7,6 +7,7 @@ namespace Magento\Framework\App\View\Asset; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem\DriverPool; class PublisherTest extends \PHPUnit_Framework_TestCase { @@ -56,8 +57,8 @@ class PublisherTest extends \PHPUnit_Framework_TestCase $this->filesystem->expects($this->any()) ->method('getDirectoryWrite') ->will($this->returnValueMap([ - [DirectoryList::ROOT, $this->rootDirWrite], - [DirectoryList::STATIC_VIEW, $this->staticDirWrite], + [DirectoryList::ROOT, DriverPool::FILE, $this->rootDirWrite], + [DirectoryList::STATIC_VIEW, DriverPool::FILE, $this->staticDirWrite], ])); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Filesystem/Directory/ReadTest.php b/dev/tests/unit/testsuite/Magento/Framework/Filesystem/Directory/ReadTest.php index b84c08e9a72c529606b33a3d4fdf4a857700222c..640724c6bb59081771f676b8a4bc27cf35985b90 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Filesystem/Directory/ReadTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Filesystem/Directory/ReadTest.php @@ -77,7 +77,7 @@ class ReadTest extends \PHPUnit_Framework_TestCase $this->assertEquals(['some-stat-data'], $this->read->stat('correct-path')); } - public function testReadFileNoProtocol() + public function testReadFile() { $path = 'filepath'; $flag = 'flag'; @@ -95,32 +95,4 @@ class ReadTest extends \PHPUnit_Framework_TestCase $this->assertEquals($contents, $this->read->readFile($path, $flag, $context)); } - - public function testReadFileCustomProtocol() - { - $path = 'filepath'; - $flag = 'flag'; - $context = 'context'; - $protocol = 'ftp'; - $contents = 'contents'; - - $fileMock = $this->getMock('Magento\Framework\Filesystem\File\Read', [], [], '', false); - $fileMock->expects($this->once()) - ->method('readAll') - ->with($flag, $context) - ->will($this->returnValue($contents)); - - $this->driver->expects($this->once()) - ->method('getAbsolutePath') - ->with($this->path, $path, $protocol) - ->will($this->returnValue($path)); - $this->driver->expects($this->never()) - ->method('fileGetContents'); - $this->fileFactory->expects($this->once()) - ->method('create') - ->with($path, $protocol, $this->driver) - ->will($this->returnValue($fileMock)); - - $this->assertEquals($contents, $this->read->readFile($path, $flag, $context, $protocol)); - } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Filesystem/File/ReadFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Filesystem/File/ReadFactoryTest.php index f41817b6cf3c459859461727f6362df7ece8599c..41f52ea79834c3be4f8369397fb79afebf2e50c5 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Filesystem/File/ReadFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Filesystem/File/ReadFactoryTest.php @@ -12,45 +12,25 @@ use Magento\Framework\Filesystem\DriverPool; */ class ReadFactoryTest extends \PHPUnit_Framework_TestCase { - /** - * @param string|null $protocol - * @param \PHPUnit_Framework_MockObject_MockObject|null $driver - * @dataProvider createProvider - */ - public function testCreate($protocol, $driver) + public function testCreate() { $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); - if ($protocol) { - $driverMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); - $driverMock->expects($this->any())->method('isExists')->willReturn(true); - $driverPool->expects($this->once())->method('getDriver')->willReturn($driverMock); - } else { - $driverPool->expects($this->never())->method('getDriver'); - } - $factory = new ReadFactory($driverPool); - $result = $factory->create('path', $protocol, $driver); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Read', $result); - } - - /** - * @return array - */ - public function createProvider() - { + $driverPool->expects($this->never())->method('getDriver'); $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); $driver->expects($this->any())->method('isExists')->willReturn(true); - return [ - [null, $driver], - ['custom_protocol', null] - ]; + $factory = new ReadFactory($driverPool); + $result = $factory->create('path', $driver); + $this->assertInstanceOf('Magento\Framework\Filesystem\File\Read', $result); } - /** - * @expectedException \InvalidArgumentException - */ - public function testCreateException() + public function testCreateWithDriverCode() { - $factory = new ReadFactory(new DriverPool()); - $factory->create('path'); + $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); + $driverMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driverMock->expects($this->any())->method('isExists')->willReturn(true); + $driverPool->expects($this->once())->method('getDriver')->willReturn($driverMock); + $factory = new ReadFactory($driverPool); + $result = $factory->create('path', 'driverCode'); + $this->assertInstanceOf('Magento\Framework\Filesystem\File\Read', $result); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Filesystem/File/WriteFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Filesystem/File/WriteFactoryTest.php index 256dbf1a7c36cafa19e4e23d17d24bc0c32cf341..bd9c483346ecffd4cc09b1a63e7dd55f2c6d9a03 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Filesystem/File/WriteFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Filesystem/File/WriteFactoryTest.php @@ -5,63 +5,41 @@ */ namespace Magento\Framework\Filesystem\File; -use Magento\Framework\Filesystem\DriverPool; - /** * Class WriteFactoryTest */ class WriteFactoryTest extends \PHPUnit_Framework_TestCase { - /** - * @param string|null $protocol - * @param \PHPUnit_Framework_MockObject_MockObject|null $driver - * @dataProvider createProvider - */ - public function testCreate($protocol, $driver) + public function testCreate() { $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); - if ($protocol) { - $driverMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); - $driverMock->expects($this->any())->method('isExists')->willReturn(true); - $driverPool->expects($this->once())->method('getDriver')->willReturn($driverMock); - } else { - $driverPool->expects($this->never())->method('getDriver'); - } + $driverPool->expects($this->never())->method('getDriver'); $factory = new WriteFactory($driverPool); - $result = $factory->create('path', $protocol, $driver); - $this->assertInstanceOf('Magento\Framework\Filesystem\File\Write', $result); - } - - /** - * @return array - */ - public function createProvider() - { $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); $driver->expects($this->any())->method('isExists')->willReturn(true); - return [ - [null, $driver], - ['custom_protocol', null] - ]; + $result = $factory->create('path', $driver); + $this->assertInstanceOf('Magento\Framework\Filesystem\File\Write', $result); } - /** - * @expectedException \InvalidArgumentException - */ - public function testCreateException() + public function testCreateWithDriverCode() { - $factory = new WriteFactory(new DriverPool()); - $factory->create('path'); + $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); + $driverMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driverMock->expects($this->any())->method('isExists')->willReturn(true); + $driverPool->expects($this->once())->method('getDriver')->willReturn($driverMock); + $factory = new WriteFactory($driverPool); + $result = $factory->create('path', 'driverCode'); + $this->assertInstanceOf('Magento\Framework\Filesystem\File\Write', $result); } public function testCreateWithMode() { - $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); - $driver->expects($this->any())->method('isExists')->willReturn(false); $driverPool = $this->getMock('Magento\Framework\Filesystem\DriverPool', ['getDriver']); - $driverPool->expects($this->once())->method('getDriver')->with('protocol')->willReturn($driver); + $driverPool->expects($this->never())->method('getDriver'); + $driver = $this->getMockForAbstractClass('Magento\Framework\Filesystem\DriverInterface'); + $driver->expects($this->any())->method('isExists')->willReturn(true); $factory = new WriteFactory($driverPool); - $result = $factory->create('path', 'protocol', null, 'a+'); + $result = $factory->create('path', $driver, 'a+'); $this->assertInstanceOf('Magento\Framework\Filesystem\File\Write', $result); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Less/File/Collector/LibraryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Less/File/Collector/LibraryTest.php index f5d9ef63f16d5055d26f70e4a269a641e4f348be..396fad99d70d6ff501dfe7d3b6d6af1718c5de64 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Less/File/Collector/LibraryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Less/File/Collector/LibraryTest.php @@ -72,8 +72,8 @@ class LibraryTest extends \PHPUnit_Framework_TestCase ->will( $this->returnValueMap( [ - [DirectoryList::LIB_WEB, $this->libraryDirectoryMock], - [DirectoryList::THEMES, $this->themesDirectoryMock], + [DirectoryList::LIB_WEB, Filesystem\DriverPool::FILE, $this->libraryDirectoryMock], + [DirectoryList::THEMES, Filesystem\DriverPool::FILE, $this->themesDirectoryMock], ] ) ); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Validator/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Validator/FactoryTest.php similarity index 94% rename from dev/tests/unit/testsuite/Magento/Core/Model/Validator/FactoryTest.php rename to dev/tests/unit/testsuite/Magento/Framework/Validator/FactoryTest.php index 2ad8b19d563dcc38632187c3c99975f500d3c70e..649ad967473afc3a7d961029f56eb907e229d66b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Validator/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Validator/FactoryTest.php @@ -1,11 +1,11 @@ <?php /** - * Unit test for \Magento\Core\Model\Validator\Factory + * Unit test for \Magento\Framework\Validator\Factory * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Model\Validator; +namespace Magento\Framework\Validator; class FactoryTest extends \PHPUnit_Framework_TestCase { @@ -104,7 +104,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase */ public function testGetValidatorConfig() { - $factory = new \Magento\Core\Model\Validator\Factory( + $factory = new \Magento\Framework\Validator\Factory( $this->_objectManager, $this->_config, $this->_translateAdapter @@ -144,7 +144,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase $objectManager->getObject('Magento\Framework\Validator\Builder', ['constraints' => []]) ) ); - $factory = new \Magento\Core\Model\Validator\Factory( + $factory = new \Magento\Framework\Validator\Factory( $this->_objectManager, $this->_config, $this->_translateAdapter @@ -171,7 +171,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase )->will( $this->returnValue(new \Magento\Framework\Validator()) ); - $factory = new \Magento\Core\Model\Validator\Factory( + $factory = new \Magento\Framework\Validator\Factory( $this->_objectManager, $this->_config, $this->_translateAdapter diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/MinifiedTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/MinifiedTest.php index 7b501992bca1fcbb3efed587558e9008a53a836b..50e39edc08a4a7a48ac4e7c314ae60a36ff9c492 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/MinifiedTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/MinifiedTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\View\Asset; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem\DriverPool; class MinifiedTest extends \PHPUnit_Framework_TestCase { @@ -62,8 +63,8 @@ class MinifiedTest extends \PHPUnit_Framework_TestCase $this->_filesystem->expects($this->any()) ->method('getDirectoryRead') ->will($this->returnValueMap([ - [DirectoryList::STATIC_VIEW, $this->_staticViewDir], - [DirectoryList::ROOT, $this->_rootDir], + [DirectoryList::STATIC_VIEW, DriverPool::FILE, $this->_staticViewDir], + [DirectoryList::ROOT, DriverPool::FILE, $this->_rootDir], ])); $this->_filesystem->expects($this->any()) ->method('getDirectoryWrite') diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php index 910f6e90781c7f825654b4cb673501572c67aada..8afbb1a372982dff4b35450415aa29aae4c30580 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php @@ -9,6 +9,7 @@ namespace Magento\Framework\View\Asset; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem\DriverPool; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -247,9 +248,9 @@ class SourceTest extends \PHPUnit_Framework_TestCase $this->varDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); $readDirMap = [ - [DirectoryList::ROOT, $this->rootDirRead], - [DirectoryList::STATIC_VIEW, $this->staticDirRead], - [DirectoryList::VAR_DIR, $this->varDir], + [DirectoryList::ROOT, DriverPool::FILE, $this->rootDirRead], + [DirectoryList::STATIC_VIEW, DriverPool::FILE, $this->staticDirRead], + [DirectoryList::VAR_DIR, DriverPool::FILE, $this->varDir], ]; $this->filesystem->expects($this->any()) diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Element/TemplateTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Element/TemplateTest.php index 3a3fd0e8709e7d36305e35aecd68ec313b05a143..59f6568e91e8cb8668b08e1836833d4d6a74758e 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Element/TemplateTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Element/TemplateTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\View\Element; +use Magento\Framework\Filesystem\DriverPool; + class TemplateTest extends \PHPUnit_Framework_TestCase { /** @@ -50,9 +52,9 @@ class TemplateTest extends \PHPUnit_Framework_TestCase $this->_filesystem->expects($this->any()) ->method('getDirectoryRead') ->will($this->returnValueMap([ - [\Magento\Framework\App\Filesystem\DirectoryList::THEMES, $themesDirMock], - [\Magento\Framework\App\Filesystem\DirectoryList::APP, $appDirMock], - [\Magento\Framework\App\Filesystem\DirectoryList::ROOT, $this->rootDirMock], + [\Magento\Framework\App\Filesystem\DirectoryList::THEMES, DriverPool::FILE, $themesDirMock], + [\Magento\Framework\App\Filesystem\DirectoryList::APP, DriverPool::FILE, $appDirMock], + [\Magento\Framework\App\Filesystem\DirectoryList::ROOT, DriverPool::FILE, $this->rootDirMock], ])); $this->_templateEngine = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Newsletter/Model/TemplateTest.php b/dev/tests/unit/testsuite/Magento/Newsletter/Model/TemplateTest.php index ca617c4f218d65db0ae07bc944463333e1724a90..617131882a610b46a53c729557a28741fae9b448 100644 --- a/dev/tests/unit/testsuite/Magento/Newsletter/Model/TemplateTest.php +++ b/dev/tests/unit/testsuite/Magento/Newsletter/Model/TemplateTest.php @@ -40,7 +40,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase } $filter = $this->getMock('Magento\Newsletter\Model\Template\Filter', [], [], '', false); - $appEmulation = $this->getMock('Magento\Core\Model\App\Emulation', [], [], '', false); + $appEmulation = $this->getMock('Magento\Store\Model\App\Emulation', [], [], '', false); $filter->expects($this->once())->method('setStoreId')->with('test_id'); $filter->expects($this->once())->method('setIncludeProcessor')->will($this->returnSelf()); $filter->expects( diff --git a/dev/tests/unit/testsuite/Magento/Payment/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Payment/Helper/DataTest.php index f2ae8359ac89d28e21520d34c8c128bd08db6da0..0c3371787ecc978d2c0ff5b782d136227c27317c 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Helper/DataTest.php @@ -42,7 +42,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $layoutFactoryMock->expects($this->once())->method('create')->willReturn($this->layoutMock); $this->methodFactory = $this->getMock('Magento\Payment\Model\Method\Factory', [], [], '', false); - $this->appEmulation = $this->getMock('Magento\Core\Model\App\Emulation', [], [], '', false); + $this->appEmulation = $this->getMock('Magento\Store\Model\App\Emulation', [], [], '', false); $paymentConfig = $this->getMock('Magento\Payment\Model\Config', [], [], '', false); $this->initialConfig = $this->getMock('Magento\Framework\App\Config\Initial', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/App/EmulationTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/App/EmulationTest.php similarity index 98% rename from dev/tests/unit/testsuite/Magento/Core/Model/App/EmulationTest.php rename to dev/tests/unit/testsuite/Magento/Store/Model/App/EmulationTest.php index 4db287af03615d06da7f10ff8cf4cb9ec78e41db..725f6fa510286f295d4d2574aef1e66b6440267b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/App/EmulationTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/App/EmulationTest.php @@ -1,6 +1,6 @@ <?php /** - * Tests Magento\Core\Model\App\Emulation + * Tests Magento\Store\Model\App\Emulation * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. @@ -8,7 +8,7 @@ // @codingStandardsIgnoreFile -namespace Magento\Core\Model\App; +namespace Magento\Store\Model\App; class EmulationTest extends \PHPUnit_Framework_TestCase { @@ -68,7 +68,7 @@ class EmulationTest extends \PHPUnit_Framework_TestCase const NEW_STORE_ID = 9; /** - * @var \Magento\Core\Model\App\Emulation + * @var \Magento\Store\Model\App\Emulation */ private $model; @@ -108,7 +108,7 @@ class EmulationTest extends \PHPUnit_Framework_TestCase $this->designMock->expects($this->any())->method('getData')->willReturn(false); // Prepare SUT - $this->model = $this->objectManager->getObject('Magento\Core\Model\App\Emulation', + $this->model = $this->objectManager->getObject('Magento\Store\Model\App\Emulation', [ 'storeManager' => $this->storeManagerMock, 'viewDesign' => $this->viewDesignMock, diff --git a/lib/internal/Magento/Framework/Composer/MagentoComponent.php b/lib/internal/Magento/Framework/Composer/MagentoComponent.php new file mode 100644 index 0000000000000000000000000000000000000000..5e2da7bfa557e166d6f45e04efd1a584dac92a30 --- /dev/null +++ b/lib/internal/Magento/Framework/Composer/MagentoComponent.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Composer; + +class MagentoComponent +{ + /** + * Get matched Magento component or empty array, if it's not a Magento component + * + * @param string $key + * @return string[] ['type' => '<type>', 'area' => '<area>', 'name' => '<name>'] + * Ex.: ['type' => 'module', 'name' => 'catalog'] + * ['type' => 'theme', 'area' => 'frontend', 'name' => 'blank'] + */ + public static function matchMagentoComponent($key) + { + $typePattern = 'module|theme|language|framework'; + $areaPattern = 'frontend|adminhtml'; + $namePattern = '[a-z_-]+'; + $regex = '/^magento\/(?P<type>' . $typePattern . ')(?:-(?P<area>' . $areaPattern . '))?(?:-(?P<name>' + . $namePattern . '))?$/'; + if (preg_match($regex, $key, $matches)) { + return $matches; + } + return []; + } +} diff --git a/lib/internal/Magento/Framework/Composer/README.md b/lib/internal/Magento/Framework/Composer/README.md new file mode 100644 index 0000000000000000000000000000000000000000..fc92f73c2db20310df2d28e92c12972b78c8f80d --- /dev/null +++ b/lib/internal/Magento/Framework/Composer/README.md @@ -0,0 +1,2 @@ +**Magento\Framework\Composer** provides Magento-specific features for working with packages. + For example, ability to distinguish Magento package and any other package. diff --git a/lib/internal/Magento/Framework/Filesystem.php b/lib/internal/Magento/Framework/Filesystem.php index e55ea9d8b2dfadc626b6145a5b98423f1daa150e..6c4e7de35c2833b927ae99aecc83801bdff82ec3 100644 --- a/lib/internal/Magento/Framework/Filesystem.php +++ b/lib/internal/Magento/Framework/Filesystem.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework; -use Magento\Framework\Filesystem\File\ReadInterface; +use Magento\Framework\Filesystem\DriverPool; class Filesystem { @@ -52,30 +52,34 @@ class Filesystem } /** - * Create an instance of directory with write permissions + * Create an instance of directory with read permissions * - * @param string $code + * @param string $directoryCode + * @param string $driverCode * @return \Magento\Framework\Filesystem\Directory\ReadInterface */ - public function getDirectoryRead($code) + public function getDirectoryRead($directoryCode, $driverCode = DriverPool::FILE) { + $code = $directoryCode . '_' . $driverCode; if (!array_key_exists($code, $this->readInstances)) { - $this->readInstances[$code] = $this->readFactory->create($this->getDirPath($code)); + $this->readInstances[$code] = $this->readFactory->create($this->getDirPath($directoryCode), $driverCode); } return $this->readInstances[$code]; } /** - * Create an instance of directory with read permissions + * Create an instance of directory with write permissions * - * @param string $code + * @param string $directoryCode + * @param string $driverCode * @return \Magento\Framework\Filesystem\Directory\WriteInterface * @throws \Magento\Framework\Filesystem\FilesystemException */ - public function getDirectoryWrite($code) + public function getDirectoryWrite($directoryCode, $driverCode = DriverPool::FILE) { + $code = $directoryCode . '_' . $driverCode; if (!array_key_exists($code, $this->writeInstances)) { - $this->writeInstances[$code] = $this->writeFactory->create($this->getDirPath($code)); + $this->writeInstances[$code] = $this->writeFactory->create($this->getDirPath($directoryCode), $driverCode); } return $this->writeInstances[$code]; } diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/Read.php b/lib/internal/Magento/Framework/Filesystem/Directory/Read.php index 3d10c9741cd2760926d7bbcf1075a69ac6ef4000..33f09a43d326f99fc3fbce2df3f04b573f922db6 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/Read.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/Read.php @@ -181,15 +181,13 @@ class Read implements ReadInterface * Open file in read mode * * @param string $path - * @param string|null $protocol * * @return \Magento\Framework\Filesystem\File\ReadInterface */ - public function openFile($path, $protocol = null) + public function openFile($path) { return $this->fileFactory->create( $this->driver->getAbsolutePath($this->path, $path), - $protocol, $this->driver ); } @@ -200,21 +198,14 @@ class Read implements ReadInterface * @param string $path * @param string|null $flag * @param resource|null $context - * @param string|null $protocol * @return string * @throws FilesystemException */ - public function readFile($path, $flag = null, $context = null, $protocol = null) + public function readFile($path, $flag = null, $context = null) { - $absolutePath = $this->driver->getAbsolutePath($this->path, $path, $protocol); + $absolutePath = $this->driver->getAbsolutePath($this->path, $path); + return $this->driver->fileGetContents($absolutePath, $flag, $context); - if (is_null($protocol)) { - return $this->driver->fileGetContents($absolutePath, $flag, $context); - } - - /** @var \Magento\Framework\Filesystem\File\Read $fileReader */ - $fileReader = $this->fileFactory->create($absolutePath, $protocol, $this->driver); - return $fileReader->readAll($flag, $context); } /** diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/ReadFactory.php b/lib/internal/Magento/Framework/Filesystem/Directory/ReadFactory.php index 423ed6166a3c33f8b5f092343713ad3e3276c11b..e1a9b33ab7a97db6d71aa51a31bc479f4875d215 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/ReadFactory.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/ReadFactory.php @@ -30,12 +30,12 @@ class ReadFactory * Create a readable directory * * @param string $path - * @param string $protocol + * @param string $driverCode * @return ReadInterface */ - public function create($path, $protocol = DriverPool::FILE) + public function create($path, $driverCode = DriverPool::FILE) { - $driver = $this->driverPool->getDriver($protocol); + $driver = $this->driverPool->getDriver($driverCode); $factory = new \Magento\Framework\Filesystem\File\ReadFactory($this->driverPool); return new Read($factory, $driver, $path); } diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/Write.php b/lib/internal/Magento/Framework/Filesystem/Directory/Write.php index 6657360dc2a50b2e5f1bbec558b36c6a50b96ce2..18ff07a750e53fdcfad8d4af7cee94cf6d59507e 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/Write.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/Write.php @@ -197,16 +197,15 @@ class Write extends Read implements WriteInterface * * @param string $path * @param string $mode - * @param string|null $protocol * @return \Magento\Framework\Filesystem\File\WriteInterface */ - public function openFile($path, $mode = 'w', $protocol = null) + public function openFile($path, $mode = 'w') { $folder = dirname($path); $this->create($folder); $this->assertWritable($folder); $absolutePath = $this->driver->getAbsolutePath($this->path, $path); - return $this->fileFactory->create($absolutePath, $protocol, $this->driver, $mode); + return $this->fileFactory->create($absolutePath, $this->driver, $mode); } /** @@ -215,13 +214,12 @@ class Write extends Read implements WriteInterface * @param string $path * @param string $content * @param string|null $mode - * @param string|null $protocol * @return int The number of bytes that were written. * @throws FilesystemException */ - public function writeFile($path, $content, $mode = 'w+', $protocol = null) + public function writeFile($path, $content, $mode = 'w+') { - return $this->openFile($path, $mode, $protocol)->write($content); + return $this->openFile($path, $mode)->write($content); } /** diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/WriteFactory.php b/lib/internal/Magento/Framework/Filesystem/Directory/WriteFactory.php index 4585629cd98a382b1d9af12e186b27248ca26ee8..809d86bb20bc0fb59cf7ae911acced7c045c9553 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/WriteFactory.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/WriteFactory.php @@ -30,13 +30,13 @@ class WriteFactory * Create a readable directory * * @param string $path - * @param string $protocol + * @param string $driverCode * @param int $createPermissions * @return \Magento\Framework\Filesystem\Directory\Write */ - public function create($path, $protocol = DriverPool::FILE, $createPermissions = null) + public function create($path, $driverCode = DriverPool::FILE, $createPermissions = null) { - $driver = $this->driverPool->getDriver($protocol); + $driver = $this->driverPool->getDriver($driverCode); $factory = new \Magento\Framework\Filesystem\File\WriteFactory($this->driverPool); return new Write($factory, $driver, $path, $createPermissions); } diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/WriteInterface.php b/lib/internal/Magento/Framework/Filesystem/Directory/WriteInterface.php index df05fb18b13dce1c958b185009ad8635074dceac..ba46d247d4870a596a7c5affaf0bda21d97bca1e 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/WriteInterface.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/WriteInterface.php @@ -80,10 +80,9 @@ interface WriteInterface extends ReadInterface * * @param string $path * @param string $mode - * @param string|null $protocol * @return \Magento\Framework\Filesystem\File\WriteInterface */ - public function openFile($path, $mode = 'w', $protocol = null); + public function openFile($path, $mode = 'w'); /** * Open file in given path diff --git a/lib/internal/Magento/Framework/Filesystem/File/ReadFactory.php b/lib/internal/Magento/Framework/Filesystem/File/ReadFactory.php index d142ee2a284100dfbf2b12ade18c99a82fc63475..0c758ce471dfbe4d75d6cb0e065f7b14d65c394d 100644 --- a/lib/internal/Magento/Framework/Filesystem/File/ReadFactory.php +++ b/lib/internal/Magento/Framework/Filesystem/File/ReadFactory.php @@ -31,17 +31,13 @@ class ReadFactory * Create a readable file * * @param string $path - * @param string|null $protocol [optional] - * @param DriverInterface $driver [optional] + * @param DriverInterface|string $driver Driver or driver code * @return \Magento\Framework\Filesystem\File\ReadInterface - * @throws \InvalidArgumentException */ - public function create($path, $protocol = null, DriverInterface $driver = null) + public function create($path, $driver) { - if ($protocol) { - $driver = $this->driverPool->getDriver($protocol); - } elseif (!$driver) { - throw new \InvalidArgumentException('Either driver or protocol must be specified.'); + if (is_string($driver)) { + return new Read($path, $this->driverPool->getDriver($driver)); } return new Read($path, $driver); } diff --git a/lib/internal/Magento/Framework/Filesystem/File/WriteFactory.php b/lib/internal/Magento/Framework/Filesystem/File/WriteFactory.php index 95a764a0e41966a124fec248077373891bebedae..1f0fe8066c55709b0c97287232c3ccd9e8cd56d1 100644 --- a/lib/internal/Magento/Framework/Filesystem/File/WriteFactory.php +++ b/lib/internal/Magento/Framework/Filesystem/File/WriteFactory.php @@ -31,18 +31,14 @@ class WriteFactory * Create a readable file. * * @param string $path - * @param string|null $protocol [optional] - * @param DriverInterface $driver [optional] + * @param DriverInterface|string $driver Driver or driver code * @param string $mode [optional] * @return Write - * @throws \InvalidArgumentException */ - public function create($path, $protocol = null, DriverInterface $driver = null, $mode = 'r') + public function create($path, $driver, $mode = 'r') { - if ($protocol) { - $driver = $this->driverPool->getDriver($protocol); - } elseif (!$driver) { - throw new \InvalidArgumentException('Either driver or protocol must be specified.'); + if (is_string($driver)) { + return new Write($path, $this->driverPool->getDriver($driver), $mode); } return new Write($path, $driver, $mode); } diff --git a/app/code/Magento/Core/Model/Validator/Factory.php b/lib/internal/Magento/Framework/Validator/Factory.php similarity index 98% rename from app/code/Magento/Core/Model/Validator/Factory.php rename to lib/internal/Magento/Framework/Validator/Factory.php index 5fc949b3e7a6f05cf96fab89e73e600d8c05fe74..a663b91cc745f01f164e1d30a1f6e9f04682087b 100644 --- a/app/code/Magento/Core/Model/Validator/Factory.php +++ b/lib/internal/Magento/Framework/Validator/Factory.php @@ -8,7 +8,7 @@ // @codingStandardsIgnoreFile -namespace Magento\Core\Model\Validator; +namespace Magento\Framework\Validator; class Factory {