Skip to content

Commit

Permalink
Refactoring + Documentation to prepare for Github release
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnert committed Dec 9, 2016
1 parent be6803f commit 35de14b
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.settings
composer.lock
/vendor
/target
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Version 1.0.0-alpha1

## Bugfixes

* None

## Features

* Refactoring + Documentation to prepare for Github release
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)


36 changes: 19 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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" : "[email protected]"
"email" : "[email protected]"
}
],
"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"
}
]
}
}
27 changes: 27 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<ruleset name="techdivision/import-product-ee">

<!--
The TechDivision GmbH coding standard is using a mix of PSR-2
coding conventions and PEAR doc-block commenting rules.
-->
<description>TechDivision GmbH coding standard</description>

<!-- Define global exclude patterns -->
<exclude-pattern>*/doc/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/target/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

<!-- Mainly use PSR2 coding standard -->
<rule ref="PSR2"/>

<!-- Include commenting sniffs from PEAR standard -->
<rule ref="PEAR.Commenting.FunctionComment"/>
<rule ref="PEAR.Commenting.InlineComment"/>

<!-- Include generic commenting sniffs -->
<rule ref="Generic.Commenting.Fixme"/>
<rule ref="Generic.Commenting.Todo"/>

</ruleset>
22 changes: 22 additions & 0 deletions phpmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="techdivision/import-product-ee PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
TechDivision GmbH default PHPMD rule set
</description>

<rule ref="rulesets/unusedcode.xml" />
<rule ref="rulesets/codesize.xml" />

<!-- Define global exclude patterns -->
<exclude-pattern>*/doc/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/target/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

</ruleset>
24 changes: 24 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<phpunit>
<testsuites>
<testsuite name="techdivision/import-product-ee PHPUnit testsuite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory prefix="Mock">src</directory>
<directory suffix="Test.php">src</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="target/reports/unit/coverage" />
<log type="coverage-clover" target="target/reports/unit/clover.xml" />
<log type="junit" target="target/reports/unit/junit.xml" logIncompleteSkipped="false" />
</logging>
<php>
<ini name="date.timezone" value="Europe/Berlin" />
</php>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,21 @@ 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()
{
return 0;
}

/**
* {@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()
{
Expand Down
6 changes: 4 additions & 2 deletions src/Actions/Processors/SequenceProductPersistProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
10 changes: 7 additions & 3 deletions src/Observers/EeProductObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
*/
Expand Down
8 changes: 6 additions & 2 deletions src/Observers/PostImport/EeCleanUpObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/SqlStatements.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ private function __clone()
value
)
VALUES (?, ?, ?, ?)';
}
}
63 changes: 63 additions & 0 deletions tests/Actions/SequenceProductActionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* TechDivision\Import\Product\Ee\Actions\SequenceProductActionTest
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* PHP version 5
*
* @author Tim Wagner <[email protected]>
* @copyright 2016 TechDivision GmbH <[email protected]>
* @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 <[email protected]>
* @copyright 2016 TechDivision GmbH <[email protected]>
* @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));
}
}

0 comments on commit 35de14b

Please sign in to comment.