Skip to content

[CS] Refactor #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace Dachcom\Codeception\Support;

class AcceptanceTester extends \Codeception\Actor
Expand Down
17 changes: 13 additions & 4 deletions src/Support/App/TestKernel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<?php

use Pimcore\Kernel;
/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

use Pimcore\HttpKernel\BundleCollection\BundleCollection;
use Pimcore\Kernel;
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderInterface;
Expand Down Expand Up @@ -57,7 +68,7 @@ public function registerBundlesToCollection(BundleCollection $collection): void

if (is_array($testBundles)) {
foreach ($testBundles as $testBundle) {
$collection->addBundle(new $testBundle['namespace'], array_key_exists('priority', $testBundle) ? $testBundle['priority'] : -1000);
$collection->addBundle(new $testBundle['namespace'](), array_key_exists('priority', $testBundle) ? $testBundle['priority'] : -1000);
}
}
}
Expand All @@ -71,13 +82,11 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
}

$loader->load(function (ContainerBuilder $container) {

$runtimeConfigDir = sprintf('%s/_etc', $_SERVER['TEST_BUNDLE_TEST_DIR']);
$runtimeConfigDir = sprintf('%s/config/bundle/', $runtimeConfigDir);

$loader = new YamlFileLoader($container, new FileLocator([$runtimeConfigDir]));
$loader->load($this->runtimeConfigFile);

});
}

Expand Down
19 changes: 17 additions & 2 deletions src/Support/Constraint/ArrayContainsComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

declare(strict_types=1);

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace Dachcom\Codeception\Support\Constraint;

use function array_intersect;
Expand Down Expand Up @@ -40,6 +51,7 @@ private function arrayIntersectRecursive(mixed $arr1, mixed $arr2): bool|array|n
if ($this->arrayIsSequential($arr1) && $this->arrayIsSequential($arr2)) {
return $this->sequentialArrayIntersect($arr1, $arr2);
}

return $this->associativeArrayIntersect($arr1, $arr2);
}

Expand All @@ -64,12 +76,14 @@ private function sequentialArrayIntersect(array $arr1, array $arr2): array
if ($return !== false && $return == $value1) {
$ret[$key1] = $return;
$matchedKeys[$key2] = true;

break;
}

if ($this->isEqualValue($value1, $value2)) {
$ret[$key1] = $value1;
$matchedKeys[$key2] = true;

break;
}
}
Expand All @@ -87,6 +101,7 @@ private function associativeArrayIntersect(array $arr1, array $arr2): bool|array
$return = $this->arrayIntersectRecursive($arr1[$key], $arr2[$key]);
if ($return !== false) {
$ret[$key] = $return;

continue;
}
if ($this->isEqualValue($arr1[$key], $arr2[$key])) {
Expand All @@ -113,11 +128,11 @@ private function associativeArrayIntersect(array $arr1, array $arr2): bool|array
private function isEqualValue($val1, $val2): bool
{
if (is_numeric($val1)) {
$val1 = (string)$val1;
$val1 = (string) $val1;
}

if (is_numeric($val2)) {
$val2 = (string)$val2;
$val2 = (string) $val2;
}

return $val1 === $val2;
Expand Down
28 changes: 20 additions & 8 deletions src/Support/Constraint/JsonContains.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace Dachcom\Codeception\Support\Constraint;

use InvalidArgumentException;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\ArrayComparator;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\Factory;
use InvalidArgumentException;

class JsonContains extends Constraint
{
Expand All @@ -24,9 +35,9 @@ public function __construct(array $expected)
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*/
protected function matches(mixed $other) : bool
protected function matches(mixed $other): bool
{
if (!is_string($other)) {
if (!is_string($other)) {
throw new InvalidArgumentException('$jsonString param must be a string.');
}

Expand All @@ -41,7 +52,7 @@ protected function matches(mixed $other) : bool
if (JSON_ERROR_NONE !== json_last_error()) {
throw new InvalidArgumentException(
sprintf(
"Invalid json: %s. System message: %s.",
'Invalid json: %s. System message: %s.',
$other,
json_last_error_msg()
),
Expand All @@ -58,7 +69,8 @@ protected function matches(mixed $other) : bool
}

$comparator = new ArrayComparator();
$comparator->setFactory(new Factory);
$comparator->setFactory(new Factory());

try {
$comparator->assertEquals($this->expected, $this->jsonArray);
} catch (ComparisonFailure $failure) {
Expand All @@ -76,12 +88,12 @@ public function containsArray(array $needle): bool
return (new ArrayContainsComparator($this->jsonArray))->containsArray($needle);
}

public function toString() : string
public function toString(): string
{
return '';
}

protected function failureDescription($other) : string
protected function failureDescription($other): string
{
return '';
}
Expand Down
11 changes: 11 additions & 0 deletions src/Support/DependencyInjection/DisablePimcoreCsrfProtection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace Dachcom\Codeception\Support\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down
12 changes: 11 additions & 1 deletion src/Support/DependencyInjection/MakeServicesPublicPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace Dachcom\Codeception\Support\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand All @@ -16,7 +27,6 @@ public function process(ContainerBuilder $container): void
});

foreach ($serviceIds as $serviceId) {

if ($container->hasAlias($serviceId)) {
$container->getAlias($serviceId)->setPublic(true);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Support/DependencyInjection/MonologChannelLoggerPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace Dachcom\Codeception\Support\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down
11 changes: 11 additions & 0 deletions src/Support/FunctionalTester.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace Dachcom\Codeception\Support;

class FunctionalTester extends \Codeception\Actor
Expand Down
Loading
Loading