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
No related branches found
No related tags found
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;
use DOMElement;
/**
* @api
*/
interface ConfigParserInterface
{
/**
......
......@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api;
use Magento\Framework\Config\DataInterface;
/**
* @api
*/
interface ConfigurationInterface extends DataInterface
{
/**
......
......@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api;
use DOMElement;
/**
* @api
*/
interface ContentResolverInterface
{
/**
......
......@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api\Data;
use Magento\Cms\Api\Data\BlockInterface;
/**
* @api
*/
interface BlockEntryInterface extends BlockInterface, EntryInterface
{
}
......@@ -3,13 +3,16 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api\Data;
/**
* @api
*/
interface EntryInterface
{
const KEY = 'key';
const IS_MAINTAINED = 'is_maintained';
const STORES = 'stores';
const MEDIA_DIRECTORY = 'media_directory';
const MEDIA_FILES = 'media_files';
public const KEY = 'key';
public const IS_MAINTAINED = 'is_maintained';
public const STORES = 'stores';
public const MEDIA_DIRECTORY = 'media_directory';
public const MEDIA_FILES = 'media_files';
/**
* @return string
......
......@@ -5,6 +5,9 @@ namespace Firegento\ContentProvisioning\Api\Data;
use Magento\Cms\Api\Data\PageInterface;
/**
* @api
*/
interface PageEntryInterface extends PageInterface, EntryInterface
{
}
......@@ -3,6 +3,9 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api;
/**
* @api
*/
interface MediaFilesParserInterface
{
/**
......
......@@ -3,6 +3,9 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api;
/**
* @api
*/
interface StoreCodeResolverInterface
{
/**
......
......@@ -3,6 +3,9 @@ declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api;
/**
* @api
*/
interface TargetMediaDirectoryPathProviderInterface
{
/**
......
......@@ -122,8 +122,11 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
],
];
if ($this->hasDefaultConfiguration->get((int)$this->getBlockId())) {
$options = array_merge($options, [[
if ($this->hasDefaultConfiguration->execute((int)$this->getBlockId())) {
$options = array_merge(
$options,
[
[
'is_hard' => 'apply_default',
'label' => __('Reset to Default & Save'),
'data_attribute' => [
......@@ -143,7 +146,10 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
],
],
],
]]]);
]
]
]
);
}
return $options;
......
......@@ -122,8 +122,11 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
],
];
if ($this->hasDefaultConfiguration->get((int)$this->getPageId())) {
$options = array_merge($options, [[
if ($this->hasDefaultConfiguration->execute((int)$this->getPageId())) {
$options = array_merge(
$options,
[
[
'is_hard' => 'apply_default',
'label' => __('Reset to Default & Save'),
'data_attribute' => [
......@@ -143,7 +146,10 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
],
],
],
]]]);
]
]
]
);
}
return $options;
......
......@@ -56,6 +56,8 @@ class Save extends \Magento\Cms\Controller\Adminhtml\Block implements HttpPostAc
* @param Context $context
* @param Registry $coreRegistry
* @param DataPersistorInterface $dataPersistor
* @param GetBlockEntryByBlock $getBlockEntryByBlock
* @param ApplyBlockEntry $applyBlockEntry
* @param BlockFactory|null $blockFactory
* @param BlockRepositoryInterface|null $blockRepository
*/
......
......@@ -25,6 +25,7 @@ use Magento\Framework\Exception\LocalizedException;
/**
* Save CMS page action.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Save extends Action implements HttpPostActionInterface
{
......@@ -33,7 +34,7 @@ class Save extends Action implements HttpPostActionInterface
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'Magento_Cms::save';
public const ADMIN_RESOURCE = 'Magento_Cms::save';
/**
* @var PostDataProcessor
......@@ -69,6 +70,8 @@ class Save extends Action implements HttpPostActionInterface
* @param Action\Context $context
* @param PostDataProcessor $dataProcessor
* @param DataPersistorInterface $dataPersistor
* @param GetPageEntryByPage $getPageEntryByPage
* @param ApplyPageEntry $applyPageEntry
* @param PageFactory|null $pageFactory
* @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
$this->applyMediaFiles->execute($blockEntry);
}
} catch (Exception $exception) {
$this->logger->error(sprintf(
$this->logger->error(
sprintf(
'An error appeared while applying cms block content: %s',
$exception->getMessage()
), [
),
[
'block-data' => $blockEntry->getData(),
'trace' => $exception->getTrace(),
]);
]
);
}
}
}
......
......@@ -5,7 +5,8 @@ namespace Firegento\ContentProvisioning\Model\Command;
use Firegento\ContentProvisioning\Api\Data\EntryInterface;
use Firegento\ContentProvisioning\Api\TargetMediaDirectoryPathProviderInterface;
use SplFileInfo;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem\DriverInterface;
class ApplyMediaFiles
{
......@@ -14,17 +15,26 @@ class ApplyMediaFiles
*/
private $targetMediaDirectoryPathProvider;
/**
* @var DriverInterface
*/
private $fileSystemDriver;
/**
* @param TargetMediaDirectoryPathProviderInterface $targetMediaDirectoryPathProvider
* @param DriverInterface $fileSystemDriver
*/
public function __construct(
TargetMediaDirectoryPathProviderInterface $targetMediaDirectoryPathProvider
TargetMediaDirectoryPathProviderInterface $targetMediaDirectoryPathProvider,
DriverInterface $fileSystemDriver
) {
$this->targetMediaDirectoryPathProvider = $targetMediaDirectoryPathProvider;
$this->fileSystemDriver = $fileSystemDriver;
}
/**
* @param EntryInterface $entry
* @throws FileSystemException
*/
public function execute(EntryInterface $entry): void
{
......@@ -41,6 +51,7 @@ class ApplyMediaFiles
/**
* @param string $sourceDirPath
* @param string $fileName
* @throws FileSystemException
*/
private function copyFile(string $sourceDirPath, string $fileName): void
{
......@@ -48,24 +59,30 @@ class ApplyMediaFiles
$sourcePathname = $sourceDirPath . DIRECTORY_SEPARATOR . $fileName;
$targetPathname = $targetDirPath . DIRECTORY_SEPARATOR . $fileName;
$sourceInfo = new SplFileInfo($sourcePathname);
if ($sourceInfo->isFile() && $sourceInfo->isReadable()) {
$this->createDirectory($targetDirPath, $sourceDirPath, $sourceInfo);
copy($sourceInfo->getPathname(), $targetPathname);
if ($this->fileSystemDriver->isFile($sourcePathname)
&& $this->fileSystemDriver->isReadable($sourcePathname)
) {
$this->createDirectory($targetDirPath, $sourceDirPath, $sourcePathname);
$this->fileSystemDriver->copy($sourcePathname, $targetPathname);
}
}
/**
* @param string $targetDirPath
* @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;
if (!is_dir($pathname)) {
mkdir($pathname, 0775, true);
if (!$this->fileSystemDriver->isDirectory($pathname)) {
$this->fileSystemDriver->createDirectory($pathname);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment