Skip to content
Snippets Groups Projects
Commit 11b2efcc authored by Vadim Justus's avatar Vadim Justus
Browse files

Merge branch 'TDMET-5-automated-testing' into 'develop'

TDMET-5 Introduce automated testing with TD internal CI system

See merge request !42
parents b99f81ed eebdf968
Branches
Tags
1 merge request!42TDMET-5 Introduce automated testing with TD internal CI system
Pipeline #28139 passed
Showing
with 146 additions and 97 deletions
include:
- remote: 'https://gitlab.met.tdintern.de/met-public/gitlab-ci-templates/-/raw/master/module/stages.yml'
- remote: 'https://gitlab.met.tdintern.de/met-public/gitlab-ci-templates/-/raw/master/module/merge-request/2.4.4/static-tests.yml'
#- remote: 'https://gitlab.met.tdintern.de/met-public/gitlab-ci-templates/-/raw/master/module/merge-request/2.4.4/unit-tests.yml'
- remote: 'https://gitlab.met.tdintern.de/met-public/gitlab-ci-templates/-/raw/master/module/merge-request/2.4.4/integration-tests.yml'
- remote: 'https://gitlab.met.tdintern.de/met-public/gitlab-ci-templates/-/raw/master/module/merge-request/2.4.4/semver-tests.yml'
#- remote: 'https://gitlab.met.tdintern.de/met-public/gitlab-ci-templates/-/raw/master/module/nightly-build/2.4/unit-tests.yml'
- remote: 'https://gitlab.met.tdintern.de/met-public/gitlab-ci-templates/-/raw/master/module/nightly-build/2.4/static-tests.yml'
- remote: 'https://gitlab.met.tdintern.de/met-public/gitlab-ci-templates/-/raw/master/module/nightly-build/2.4/integration-tests.yml'
#variables:
# SEMVER_ALLOWED_CHANGE_LEVEL: 3
addons:
apt:
sources:
- mysql-8.0-trusty
packages:
- mysql-server
- mysql-client
- rabbitmq-server
services:
- mysql
- rabbitmq
- elasticsearch
language: php
php:
- 7.4
- 8.1
env:
matrix:
- MAGENTO_VERSION=2.4
before_install:
- composer self-update --1
- git clone --depth=50 --branch=$MAGENTO_VERSION https://github.com/magento/magento2.git /tmp/magento
- mysql -uroot -e 'SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; CREATE DATABASE magento_integration_tests;'
- mv $(pwd)/install-config-mysql.travis.$MAGENTO_VERSION.php /tmp/magento/dev/tests/integration/etc/install-config-mysql.php
- mkdir -p /tmp/magento/app/code/Firegento
- cp -R $(pwd) /tmp/magento/app/code/Firegento/ContentProvisioning
install:
- cd /tmp/magento
- composer install --no-interaction
- composer require --dev mikey179/vfsstream
script:
- php /tmp/magento/vendor/bin/phpunit -c /tmp/magento/app/code/Firegento/ContentProvisioning/Test/Integration/phpunit.travis.xml
...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api; ...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api;
use DOMElement; use DOMElement;
/**
* @api
*/
interface ConfigParserInterface interface ConfigParserInterface
{ {
/** /**
......
...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api; ...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api;
use Magento\Framework\Config\DataInterface; use Magento\Framework\Config\DataInterface;
/**
* @api
*/
interface ConfigurationInterface extends DataInterface interface ConfigurationInterface extends DataInterface
{ {
/** /**
......
...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api; ...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api;
use DOMElement; use DOMElement;
/**
* @api
*/
interface ContentResolverInterface interface ContentResolverInterface
{ {
/** /**
......
...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api\Data; ...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api\Data;
use Magento\Cms\Api\Data\BlockInterface; use Magento\Cms\Api\Data\BlockInterface;
/**
* @api
*/
interface BlockEntryInterface extends BlockInterface, EntryInterface interface BlockEntryInterface extends BlockInterface, EntryInterface
{ {
} }
...@@ -3,13 +3,16 @@ declare(strict_types=1); ...@@ -3,13 +3,16 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api\Data; namespace Firegento\ContentProvisioning\Api\Data;
/**
* @api
*/
interface EntryInterface interface EntryInterface
{ {
const KEY = 'key'; public const KEY = 'key';
const IS_MAINTAINED = 'is_maintained'; public const IS_MAINTAINED = 'is_maintained';
const STORES = 'stores'; public const STORES = 'stores';
const MEDIA_DIRECTORY = 'media_directory'; public const MEDIA_DIRECTORY = 'media_directory';
const MEDIA_FILES = 'media_files'; public const MEDIA_FILES = 'media_files';
/** /**
* @return string * @return string
......
...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api\Data; ...@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api\Data;
use Magento\Cms\Api\Data\PageInterface; use Magento\Cms\Api\Data\PageInterface;
/**
* @api
*/
interface PageEntryInterface extends PageInterface, EntryInterface interface PageEntryInterface extends PageInterface, EntryInterface
{ {
} }
...@@ -3,6 +3,9 @@ declare(strict_types=1); ...@@ -3,6 +3,9 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api; namespace Firegento\ContentProvisioning\Api;
/**
* @api
*/
interface MediaFilesParserInterface interface MediaFilesParserInterface
{ {
/** /**
......
...@@ -3,6 +3,9 @@ declare(strict_types=1); ...@@ -3,6 +3,9 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api; namespace Firegento\ContentProvisioning\Api;
/**
* @api
*/
interface StoreCodeResolverInterface interface StoreCodeResolverInterface
{ {
/** /**
......
...@@ -3,6 +3,9 @@ declare(strict_types=1); ...@@ -3,6 +3,9 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api; namespace Firegento\ContentProvisioning\Api;
/**
* @api
*/
interface TargetMediaDirectoryPathProviderInterface interface TargetMediaDirectoryPathProviderInterface
{ {
/** /**
......
...@@ -122,8 +122,11 @@ class SaveButton extends GenericButton implements ButtonProviderInterface ...@@ -122,8 +122,11 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
], ],
]; ];
if ($this->hasDefaultConfiguration->get((int)$this->getBlockId())) { if ($this->hasDefaultConfiguration->execute((int)$this->getBlockId())) {
$options = array_merge($options, [[ $options = array_merge(
$options,
[
[
'is_hard' => 'apply_default', 'is_hard' => 'apply_default',
'label' => __('Reset to Default & Save'), 'label' => __('Reset to Default & Save'),
'data_attribute' => [ 'data_attribute' => [
...@@ -143,7 +146,10 @@ class SaveButton extends GenericButton implements ButtonProviderInterface ...@@ -143,7 +146,10 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
], ],
], ],
], ],
]]]); ]
]
]
);
} }
return $options; return $options;
......
...@@ -122,8 +122,11 @@ class SaveButton extends GenericButton implements ButtonProviderInterface ...@@ -122,8 +122,11 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
], ],
]; ];
if ($this->hasDefaultConfiguration->get((int)$this->getPageId())) { if ($this->hasDefaultConfiguration->execute((int)$this->getPageId())) {
$options = array_merge($options, [[ $options = array_merge(
$options,
[
[
'is_hard' => 'apply_default', 'is_hard' => 'apply_default',
'label' => __('Reset to Default & Save'), 'label' => __('Reset to Default & Save'),
'data_attribute' => [ 'data_attribute' => [
...@@ -143,7 +146,10 @@ class SaveButton extends GenericButton implements ButtonProviderInterface ...@@ -143,7 +146,10 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
], ],
], ],
], ],
]]]); ]
]
]
);
} }
return $options; return $options;
......
...@@ -56,6 +56,8 @@ class Save extends \Magento\Cms\Controller\Adminhtml\Block implements HttpPostAc ...@@ -56,6 +56,8 @@ class Save extends \Magento\Cms\Controller\Adminhtml\Block implements HttpPostAc
* @param Context $context * @param Context $context
* @param Registry $coreRegistry * @param Registry $coreRegistry
* @param DataPersistorInterface $dataPersistor * @param DataPersistorInterface $dataPersistor
* @param GetBlockEntryByBlock $getBlockEntryByBlock
* @param ApplyBlockEntry $applyBlockEntry
* @param BlockFactory|null $blockFactory * @param BlockFactory|null $blockFactory
* @param BlockRepositoryInterface|null $blockRepository * @param BlockRepositoryInterface|null $blockRepository
*/ */
......
...@@ -25,6 +25,7 @@ use Magento\Framework\Exception\LocalizedException; ...@@ -25,6 +25,7 @@ use Magento\Framework\Exception\LocalizedException;
/** /**
* Save CMS page action. * Save CMS page action.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/ */
class Save extends Action implements HttpPostActionInterface class Save extends Action implements HttpPostActionInterface
{ {
...@@ -33,7 +34,7 @@ class Save extends Action implements HttpPostActionInterface ...@@ -33,7 +34,7 @@ class Save extends Action implements HttpPostActionInterface
* *
* @see _isAllowed() * @see _isAllowed()
*/ */
const ADMIN_RESOURCE = 'Magento_Cms::save'; public const ADMIN_RESOURCE = 'Magento_Cms::save';
/** /**
* @var PostDataProcessor * @var PostDataProcessor
...@@ -69,6 +70,8 @@ class Save extends Action implements HttpPostActionInterface ...@@ -69,6 +70,8 @@ class Save extends Action implements HttpPostActionInterface
* @param Action\Context $context * @param Action\Context $context
* @param PostDataProcessor $dataProcessor * @param PostDataProcessor $dataProcessor
* @param DataPersistorInterface $dataPersistor * @param DataPersistorInterface $dataPersistor
* @param GetPageEntryByPage $getPageEntryByPage
* @param ApplyPageEntry $applyPageEntry
* @param PageFactory|null $pageFactory * @param PageFactory|null $pageFactory
* @param PageRepositoryInterface|null $pageRepository * @param PageRepositoryInterface|null $pageRepository
*/ */
......
<?php
declare(strict_types=1);
namespace Firegento\ContentProvisioning\Exception;
use Exception;
class CommandInputException extends Exception
{
}
...@@ -72,13 +72,16 @@ class BlockInstaller ...@@ -72,13 +72,16 @@ class BlockInstaller
$this->applyMediaFiles->execute($blockEntry); $this->applyMediaFiles->execute($blockEntry);
} }
} catch (Exception $exception) { } catch (Exception $exception) {
$this->logger->error(sprintf( $this->logger->error(
sprintf(
'An error appeared while applying cms block content: %s', 'An error appeared while applying cms block content: %s',
$exception->getMessage() $exception->getMessage()
), [ ),
[
'block-data' => $blockEntry->getData(), 'block-data' => $blockEntry->getData(),
'trace' => $exception->getTrace(), 'trace' => $exception->getTrace(),
]); ]
);
} }
} }
} }
......
...@@ -5,7 +5,8 @@ namespace Firegento\ContentProvisioning\Model\Command; ...@@ -5,7 +5,8 @@ namespace Firegento\ContentProvisioning\Model\Command;
use Firegento\ContentProvisioning\Api\Data\EntryInterface; use Firegento\ContentProvisioning\Api\Data\EntryInterface;
use Firegento\ContentProvisioning\Api\TargetMediaDirectoryPathProviderInterface; use Firegento\ContentProvisioning\Api\TargetMediaDirectoryPathProviderInterface;
use SplFileInfo; use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem\DriverInterface;
class ApplyMediaFiles class ApplyMediaFiles
{ {
...@@ -14,17 +15,26 @@ class ApplyMediaFiles ...@@ -14,17 +15,26 @@ class ApplyMediaFiles
*/ */
private $targetMediaDirectoryPathProvider; private $targetMediaDirectoryPathProvider;
/**
* @var DriverInterface
*/
private $fileSystemDriver;
/** /**
* @param TargetMediaDirectoryPathProviderInterface $targetMediaDirectoryPathProvider * @param TargetMediaDirectoryPathProviderInterface $targetMediaDirectoryPathProvider
* @param DriverInterface $fileSystemDriver
*/ */
public function __construct( public function __construct(
TargetMediaDirectoryPathProviderInterface $targetMediaDirectoryPathProvider TargetMediaDirectoryPathProviderInterface $targetMediaDirectoryPathProvider,
DriverInterface $fileSystemDriver
) { ) {
$this->targetMediaDirectoryPathProvider = $targetMediaDirectoryPathProvider; $this->targetMediaDirectoryPathProvider = $targetMediaDirectoryPathProvider;
$this->fileSystemDriver = $fileSystemDriver;
} }
/** /**
* @param EntryInterface $entry * @param EntryInterface $entry
* @throws FileSystemException
*/ */
public function execute(EntryInterface $entry): void public function execute(EntryInterface $entry): void
{ {
...@@ -41,6 +51,7 @@ class ApplyMediaFiles ...@@ -41,6 +51,7 @@ class ApplyMediaFiles
/** /**
* @param string $sourceDirPath * @param string $sourceDirPath
* @param string $fileName * @param string $fileName
* @throws FileSystemException
*/ */
private function copyFile(string $sourceDirPath, string $fileName): void private function copyFile(string $sourceDirPath, string $fileName): void
{ {
...@@ -48,24 +59,30 @@ class ApplyMediaFiles ...@@ -48,24 +59,30 @@ class ApplyMediaFiles
$sourcePathname = $sourceDirPath . DIRECTORY_SEPARATOR . $fileName; $sourcePathname = $sourceDirPath . DIRECTORY_SEPARATOR . $fileName;
$targetPathname = $targetDirPath . DIRECTORY_SEPARATOR . $fileName; $targetPathname = $targetDirPath . DIRECTORY_SEPARATOR . $fileName;
$sourceInfo = new SplFileInfo($sourcePathname); if ($this->fileSystemDriver->isFile($sourcePathname)
if ($sourceInfo->isFile() && $sourceInfo->isReadable()) { && $this->fileSystemDriver->isReadable($sourcePathname)
$this->createDirectory($targetDirPath, $sourceDirPath, $sourceInfo); ) {
copy($sourceInfo->getPathname(), $targetPathname); $this->createDirectory($targetDirPath, $sourceDirPath, $sourcePathname);
$this->fileSystemDriver->copy($sourcePathname, $targetPathname);
} }
} }
/** /**
* @param string $targetDirPath * @param string $targetDirPath
* @param string $sourceDirPath * @param string $sourceDirPath
* @param SplFileInfo $sourceInfo * @param string $sourcePathname
* @throws FileSystemException
*/ */
private function createDirectory(string $targetDirPath, string $sourceDirPath, SplFileInfo $sourceInfo): void private function createDirectory(string $targetDirPath, string $sourceDirPath, string $sourcePathname): void
{ {
$subPath = str_replace($sourceDirPath, '', $sourceInfo->getPath()); $subPath = str_replace(
$sourceDirPath,
'',
$this->fileSystemDriver->getParentDirectory($sourcePathname)
);
$pathname = $targetDirPath . DIRECTORY_SEPARATOR . $subPath; $pathname = $targetDirPath . DIRECTORY_SEPARATOR . $subPath;
if (!is_dir($pathname)) { if (!$this->fileSystemDriver->isDirectory($pathname)) {
mkdir($pathname, 0775, true); $this->fileSystemDriver->createDirectory($pathname);
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment