From 35de14be911c2a4882cf9becaf77853357e464c5 Mon Sep 17 00:00:00 2001 From: wagnert Date: Fri, 9 Dec 2016 15:50:21 +0100 Subject: [PATCH] Refactoring + Documentation to prepare for Github release --- .gitignore | 1 + .travis.yml | 24 +++++++ CHANGELOG.md | 9 +++ README.md | 9 +++ composer.json | 36 ++++++----- phpcs.xml | 27 ++++++++ phpmd.xml | 22 +++++++ phpunit.xml | 24 +++++++ .../SequenceProductPersistBatchProcessor.php | 12 ++-- .../SequenceProductPersistProcessor.php | 6 +- src/Observers/EeProductObserver.php | 10 ++- .../PostImport/EeCleanUpObserver.php | 8 ++- src/Utils/SqlStatements.php | 2 +- tests/Actions/SequenceProductActionTest.php | 63 +++++++++++++++++++ 14 files changed, 224 insertions(+), 29 deletions(-) create mode 100644 .travis.yml create mode 100644 CHANGELOG.md create mode 100644 README.md create mode 100644 phpcs.xml create mode 100644 phpmd.xml create mode 100644 phpunit.xml create mode 100644 tests/Actions/SequenceProductActionTest.php diff --git a/.gitignore b/.gitignore index 5dae439..8bc520a 100755 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .settings composer.lock /vendor +/target diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e842c62 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: php + +php: + - 7.0 + - 5.6 + +before_install: + - pecl install xdebug + - phpenv rehash + - wget https://scrutinizer-ci.com/ocular.phar + +before_script: + - composer selfupdate + +script: + - composer install + - vendor/bin/phpunit -c phpunit.xml + - vendor/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml src + - vendor/bin/phpcpd src + - vendor/bin/phpmd src text phpmd.xml --ignore-violations-on-exit + - php ocular.phar code-coverage:upload --format=php-clover $TRAVIS_BUILD_DIR/target/reports/unit/clover.xml + +notifications: + email: t.wagner@techdivision.com diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3ea16c9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Version 1.0.0-alpha1 + +## Bugfixes + +* None + +## Features + +* Refactoring + Documentation to prepare for Github release \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c648d2a --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# M2IF - EE Product Import + +[![Latest Stable Version](https://img.shields.io/packagist/v/techdivision/import-product-ee.svg?style=flat-square)](https://packagist.org/packages/techdivision/import-product-ee) + [![Total Downloads](https://img.shields.io/packagist/dt/techdivision/import-product-ee.svg?style=flat-square)](https://packagist.org/packages/techdivision/import-product-ee) + [![License](https://img.shields.io/packagist/l/techdivision/import-product-ee.svg?style=flat-square)](https://packagist.org/packages/techdivision/import-product-ee) + [![Build Status](https://img.shields.io/travis/techdivision/import-product-ee/master.svg?style=flat-square)](http://travis-ci.org/techdivision/import-product-ee) + [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/techdivision/import-product-ee/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/techdivision/import-product-ee/?branch=master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/techdivision/import-product-ee/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/techdivision/import-product-ee/?branch=master) + + \ No newline at end of file diff --git a/composer.json b/composer.json index 9496227..d1377e0 100755 --- a/composer.json +++ b/composer.json @@ -1,29 +1,31 @@ { "name" : "techdivision/import-product-ee", - "description" : "A library supporting generic Magento 2 import functionality", + "description" : "M2IF library providing basic Magento 2 EE product import functionality", + "minimum-stability" : "alpha", + "license" : "OSL-3", "require" : { - "techdivision/import" : "0.6.*", - "techdivision/import-product" : "0.1.*" + "techdivision/import-product" : "~1.0" + }, + "require-dev" : { + "phpmd/phpmd" : "2.5.*", + "phploc/phploc" : "2.0.*", + "pdepend/pdepend" : "2.0.*", + "phpunit/phpunit" : "4.4.*", + "sebastian/phpcpd" : "2.0.*", + "squizlabs/php_codesniffer" : "2.2.*", + "phpdocumentor/phpdocumentor" : "2.8.*" }, "authors" : [{ "name" : "Tim Wagner", - "email" : "tw@appserver.io" + "email" : "t.wagner@techdivision.com" } ], "autoload" : { "psr-4" : { - "TechDivision\\Import\\Product\\Ee\\" : [ "src/", "tests/" ] + "TechDivision\\Import\\Product\\Ee\\" : [ + "src/", + "tests/" + ] } - }, - "repositories" : [{ - "type" : "git", - "url" : "https://gitlab.tdintern.de/wagnert/techdivision-import.git", - "name" : "techdivision/import" - }, - { - "type" : "git", - "url" : "https://gitlab.tdintern.de/wagnert/techdivision-import-product.git", - "name" : "techdivision/import-product" - } - ] + } } \ No newline at end of file diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..d101425 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,27 @@ + + + + + TechDivision GmbH coding standard + + + */doc/* + */tests/* + */target/* + */vendor/* + + + + + + + + + + + + + \ No newline at end of file diff --git a/phpmd.xml b/phpmd.xml new file mode 100644 index 0000000..43e3d8d --- /dev/null +++ b/phpmd.xml @@ -0,0 +1,22 @@ + + + + TechDivision GmbH default PHPMD rule set + + + + + + + */doc/* + */tests/* + */target/* + */vendor/* + + \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..d7e3e20 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,24 @@ + + + + tests + + + + + src + + src + src + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Actions/Processors/Batch/SequenceProductPersistBatchProcessor.php b/src/Actions/Processors/Batch/SequenceProductPersistBatchProcessor.php index f685c26..e4f9f5b 100644 --- a/src/Actions/Processors/Batch/SequenceProductPersistBatchProcessor.php +++ b/src/Actions/Processors/Batch/SequenceProductPersistBatchProcessor.php @@ -35,8 +35,10 @@ class SequenceProductPersistBatchProcessor extends AbstractPersistBatchProcessor { /** - * {@inheritDoc} - * @see \TechDivision\Import\Product\Actions\Processors\Batch\AbstractPersistBatchProcessor::getNumberOfPlaceholders() + * The number of placeholders of the prepared statement. + * + * @return integer The number of placeholers + * @see \TechDivision\Import\Actions\Processors\Batch\AbstractBatchBaseProcessor::getNumberOfPlaceholders() */ protected function getNumberOfPlaceholders() { @@ -44,8 +46,10 @@ protected function getNumberOfPlaceholders() } /** - * {@inheritDoc} - * @see \TechDivision\Import\Product\Actions\Processors\Batch\AbstractPersistBatchProcessor::getStatement() + * Return's the SQL statement that has to be prepared. + * + * @return string The SQL statement + * @see \TechDivision\Import\Actions\Processors\Batch\AbstractBatchBaseProcessor::getStatement() */ protected function getStatement() { diff --git a/src/Actions/Processors/SequenceProductPersistProcessor.php b/src/Actions/Processors/SequenceProductPersistProcessor.php index 6d70e58..c7a2da9 100644 --- a/src/Actions/Processors/SequenceProductPersistProcessor.php +++ b/src/Actions/Processors/SequenceProductPersistProcessor.php @@ -35,8 +35,10 @@ class SequenceProductPersistProcessor extends AbstractPersistProcessor { /** - * {@inheritDoc} - * @see \TechDivision\Import\Product\Actions\Processors\AbstractPersistProcessor::getStatement() + * Return's the SQL statement that has to be prepared. + * + * @return string The SQL statement + * @see \TechDivision\Import\Actions\Processors\AbstractBaseProcessor::getStatement() */ protected function getStatement() { diff --git a/src/Observers/EeProductObserver.php b/src/Observers/EeProductObserver.php index 8c8fd71..902237e 100644 --- a/src/Observers/EeProductObserver.php +++ b/src/Observers/EeProductObserver.php @@ -37,8 +37,12 @@ class EeProductObserver extends ProductObserver { /** - * {@inheritDoc} - * @see \Importer\Csv\Actions\Listeners\Row\ListenerInterface::handle() + * Will be invoked by the action on the events the listener has been registered for. + * + * @param array $row The row to handle + * + * @return array The modified row + * @see \TechDivision\Import\Product\Observers\ImportObserverInterface::handle() */ public function handle(array $row) { @@ -93,7 +97,7 @@ public function handle(array $row) /** * Set's the row ID of the product that has been created recently. * - * @param string $lastRowId The row ID + * @param string $rowId The row ID * * @return void */ diff --git a/src/Observers/PostImport/EeCleanUpObserver.php b/src/Observers/PostImport/EeCleanUpObserver.php index 3ba48a5..d7fe223 100644 --- a/src/Observers/PostImport/EeCleanUpObserver.php +++ b/src/Observers/PostImport/EeCleanUpObserver.php @@ -36,8 +36,12 @@ class EeCleanUpObserver extends CleanUpObserver { /** - * {@inheritDoc} - * @see \Importer\Csv\Actions\Listeners\Row\ListenerInterface::handle() + * Will be invoked by the action on the events the listener has been registered for. + * + * @param array $row The row to handle + * + * @return array The modified row + * @see \TechDivision\Import\Product\Observers\ImportObserverInterface::handle() */ public function handle(array $row) { diff --git a/src/Utils/SqlStatements.php b/src/Utils/SqlStatements.php index aba7859..c335ac3 100644 --- a/src/Utils/SqlStatements.php +++ b/src/Utils/SqlStatements.php @@ -147,4 +147,4 @@ private function __clone() value ) VALUES (?, ?, ?, ?)'; -} \ No newline at end of file +} diff --git a/tests/Actions/SequenceProductActionTest.php b/tests/Actions/SequenceProductActionTest.php new file mode 100644 index 0000000..bb12f89 --- /dev/null +++ b/tests/Actions/SequenceProductActionTest.php @@ -0,0 +1,63 @@ + + * @copyright 2016 TechDivision GmbH + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link https://github.com/techdivision/import-product-media + * @link http://www.techdivision.com + */ + +namespace TechDivision\Import\Product\Ee\Actions; + +/** + * Test class for the sequence product action implementation. + * + * @author Tim Wagner + * @copyright 2016 TechDivision GmbH + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link https://github.com/techdivision/import-product-media + * @link http://www.techdivision.com + */ +class SequenceProductActionTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Test's the persist() method successfull. + * + * @return void + */ + public function testPersistWithSuccess() + { + + // create a persist processor mock instance + $mockPersistProcessor = $this->getMockBuilder($processorInterface = 'TechDivision\Import\Actions\Processors\ProcessorInterface') + ->setMethods(get_class_methods($processorInterface)) + ->getMock(); + $mockPersistProcessor->expects($this->once()) + ->method('execute') + ->with($row = array()) + ->willReturn(null); + + // create a mock for the sequence product action + $mockAction = $this->getMockBuilder('TechDivision\Import\Product\Ee\Actions\SequenceProductAction') + ->setMethods(array('getPersistProcessor')) + ->getMock(); + $mockAction->expects($this->once()) + ->method('getPersistProcessor') + ->willReturn($mockPersistProcessor); + + // test the persist() method + $this->assertNull($mockAction->persist($row)); + } +}