-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Make extension compatible to cart version v6.x
Resolves: #13
- Loading branch information
Showing
48 changed files
with
477 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,98 @@ | ||
cache: | ||
key: "$CI_COMMIT_REF_NAME/$CI_JOB_STAGE" | ||
key: "$CI_JOB_STAGE-$CI_COMMIT_REF_NAME" | ||
paths: | ||
- .composer/ | ||
- .php_cs.cache | ||
|
||
variables: | ||
COMPOSER_CACHE_DIR: ".composer" | ||
TYPO3_PATH_WEB: "$CI_PROJECT_DIR/.Build/Web" | ||
MYSQL_DATABASE: "typo3" | ||
MYSQL_ROOT_PASSWORD: "joh316" | ||
typo3DatabaseName: "typo3" | ||
typo3DatabaseHost: "mysql" | ||
typo3DatabaseUsername: "root" | ||
typo3DatabasePassword: "joh316" | ||
|
||
before_script: | ||
- apk add git --update | ||
|
||
stages: | ||
- lint | ||
- test | ||
|
||
test:cgl: | ||
image: composer:1.3 | ||
stage: test | ||
lint:cgl: | ||
image: composer:1.6 | ||
stage: lint | ||
before_script: | ||
- composer remove typo3/cms-core --no-update | ||
- composer install | ||
- composer remove typo3/cms-core --no-update | ||
- composer install --no-progress --no-ansi --no-interaction | ||
script: | ||
- .Build/bin/php-cs-fixer fix --config=Build/.php_cs.dist -v --dry-run --using-cache=no --path-mode=intersection ./ | ||
|
||
lint:typoscriptcgl: | ||
stage: lint | ||
image: composer:1.6 | ||
script: | ||
- pwd | ||
- ls .Build/bin/ | ||
- .Build/bin/php-cs-fixer fix --config=Build/.php_cs -v --dry-run --using-cache=no --path-mode=intersection ./ | ||
- composer remove typo3/cms-core --no-update | ||
- composer install --no-progress --no-ansi --no-interaction | ||
- .Build/bin/typoscript-lint -c tslint.yaml | ||
|
||
lint:yaml: | ||
stage: lint | ||
image: python:alpine3.7 | ||
before_script: | ||
- pip install yamllint==1.10.0 | ||
script: | ||
- yamllint -c Build/yamllint.yaml Configuration/ Resources/ .travis.yml | ||
|
||
lint:php72: | ||
stage: lint | ||
image: php:7.2-alpine | ||
script: | ||
- find . -name \*.php -exec php -l "{}" \; | ||
|
||
.test: &test_php | ||
stage: test | ||
services: | ||
- mysql:5 | ||
image: php:$DOCKER_TAG | ||
only: | ||
- branches | ||
before_script: | ||
- apk --no-cache add bash curl git mercurial openssh openssl parallel subversion tini | ||
- apk add --no-cache bash curl git mercurial openssh openssl parallel subversion tini | ||
- > | ||
if [[ "$COVERAGE" == "1" ]]; then | ||
apk add --no-cache $PHPIZE_DEPS | ||
pecl install xdebug && docker-php-ext-enable xdebug | ||
fi | ||
- docker-php-ext-install mysqli | ||
- export TYPO3_PATH_WEB="$PWD/.Build/Web" | ||
- export COMPOSER_CACHE_DIR=.composer | ||
- curl -OLs https://composer.github.io/installer.sig | ||
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig | ||
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
- php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | ||
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer | ||
- php -r "unlink('composer-setup.php'); unlink('installer.sig');" | ||
- composer require typo3/cms="${TYPO3_VERSION}" --update-with-dependencies | ||
- composer require nimut/testing-framework | ||
- composer require typo3/cms-core="${TYPO3_VERSION}" | ||
script: | ||
- .Build/bin/phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit | ||
- find . -name \*.php ! -path "./.Build/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null | ||
|
||
# Build in PHP 5.6 and TYPO3 7.6 | ||
test:php56:typo3_7: | ||
<<: *test_php | ||
variables: | ||
DOCKER_TAG: 5.6-alpine | ||
TYPO3_VERSION: ^7.6 | ||
|
||
# Build in PHP 7.0 and TYPO3 7.6 | ||
test:php70:typo3_7: | ||
<<: *test_php | ||
variables: | ||
DOCKER_TAG: 7.0-alpine | ||
TYPO3_VERSION: ^7.6 | ||
|
||
# Build in PHP 7.1 and TYPO3 7.6 | ||
test:php71:typo3_7: | ||
<<: *test_php | ||
variables: | ||
DOCKER_TAG: 7.1-alpine | ||
TYPO3_VERSION: ^7.6 | ||
|
||
# Build in PHP 7.0 and TYPO3 8.7 | ||
test:php70:typo3_8: | ||
<<: *test_php | ||
variables: | ||
DOCKER_TAG: 7.0-alpine | ||
TYPO3_VERSION: ^8.7 | ||
- > | ||
if [[ "$COVERAGE" == "0" ]]; then | ||
.Build/bin/phpunit -c Build/UnitTests.xml Tests/Unit | ||
fi | ||
- > | ||
if [[ "$COVERAGE" == "1" ]]; then | ||
.Build/bin/phpunit --coverage-clover=phpunit.coverage.xml --log-junit=phpunit.report.xml -c Build/UnitTests.xml Tests/Unit | ||
fi | ||
artifacts: | ||
paths: | ||
- phpunit.coverage.xml | ||
- phpunit.report.xml | ||
expire_in: 1 day | ||
when: always | ||
|
||
# Build in PHP 7.1 and TYPO3 8.7 | ||
test:php71:typo3_8: | ||
# Build in PHP 7.2 and TYPO3 9.3 | ||
test:php72:typo3_9: | ||
<<: *test_php | ||
variables: | ||
DOCKER_TAG: 7.1-alpine | ||
TYPO3_VERSION: ^8.7 | ||
DOCKER_TAG: 7.2-alpine | ||
TYPO3_VERSION: ^9.5 | ||
COVERAGE: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<phpunit | ||
backupGlobals="true" | ||
backupStaticAttributes="false" | ||
bootstrap="../.Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
forceCoversAnnotation="false" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
stopOnIncomplete="false" | ||
stopOnSkipped="false" | ||
verbose="false" | ||
> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">../Classes/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
extends: default | ||
|
||
rules: | ||
line-length: disable | ||
document-start: disable | ||
braces: | ||
min-spaces-inside-empty: 1 | ||
max-spaces-inside-empty: 1 | ||
brackets: | ||
min-spaces-inside-empty: 1 | ||
max-spaces-inside-empty: 1 | ||
comments: | ||
level: error | ||
min-spaces-from-content: 1 | ||
comments-indentation: | ||
level: error | ||
empty-lines: | ||
max: 1 | ||
empty-values: | ||
forbid-in-block-mappings: true | ||
forbid-in-flow-mappings: true | ||
indentation: | ||
spaces: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Extcode\CartPdf\Domain\Finisher\Order; | ||
|
||
class DocumentFinisher extends \Extcode\Cart\Domain\Finisher\AbstractFinisher | ||
{ | ||
/** | ||
* @var \Extcode\Cart\Domain\Repository\Order\ItemRepository | ||
*/ | ||
protected $orderItemRepository; | ||
|
||
/** | ||
* @var \Extcode\Cart\Utility\OrderUtility | ||
*/ | ||
protected $orderUtility; | ||
|
||
/** | ||
* @param \Extcode\Cart\Domain\Repository\Order\ItemRepository $orderItemRepository | ||
*/ | ||
public function injectOrderItemRepository( | ||
\Extcode\Cart\Domain\Repository\Order\ItemRepository $orderItemRepository | ||
) { | ||
$this->orderItemRepository = $orderItemRepository; | ||
} | ||
|
||
/** | ||
* @param \Extcode\Cart\Utility\OrderUtility $orderUtility | ||
*/ | ||
public function injectOrderUtility( | ||
\Extcode\Cart\Utility\OrderUtility $orderUtility | ||
) { | ||
$this->orderUtility = $orderUtility; | ||
} | ||
|
||
public function executeInternal() | ||
{ | ||
$orderItem = $this->finisherContext->getOrderItem(); | ||
|
||
if ($this->settings['autoGenerateDocuments']) { | ||
foreach ($this->settings['autoGenerateDocuments'] as $documentType => $documentData) { | ||
$getterForNumber = 'get' . ucfirst($documentType) . 'Number'; | ||
$setterForNumber = 'set' . ucfirst($documentType) . 'Number'; | ||
$setterForDate = 'set' . ucfirst($documentType) . 'Date'; | ||
|
||
if (!$orderItem->$getterForNumber()) { | ||
$documentNumber = $this->orderUtility->getNumber($this->settings, $documentType); | ||
|
||
$orderItem->$setterForNumber($documentNumber); | ||
$orderItem->$setterForDate(new \DateTime()); | ||
} | ||
|
||
$this->generatePdfDocument($orderItem, $documentType); | ||
} | ||
|
||
$this->orderItemRepository->update($orderItem); | ||
$this->persistenceManager->persistAll(); | ||
|
||
$this->finisherContext->setOrderItem($orderItem); | ||
} | ||
} | ||
|
||
/** | ||
* @param \Extcode\Cart\Domain\Model\Order\Item $orderItem | ||
* @param string $pdfType | ||
*/ | ||
protected function generatePdfDocument(\Extcode\Cart\Domain\Model\Order\Item $orderItem, $pdfType) | ||
{ | ||
$pdfService = $this->objectManager->get( | ||
\Extcode\CartPdf\Service\PdfService::class | ||
); | ||
|
||
$pdfService->createPdf($orderItem, $pdfType); | ||
} | ||
} |
Oops, something went wrong.