Skip to content

Commit

Permalink
Ensured that the tests can be run when the plugin is installed in /ve…
Browse files Browse the repository at this point in the history
…ndor
  • Loading branch information
tom00 committed Dec 16, 2024
1 parent 20b6f99 commit 4da7d49
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/TestBootstrap.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

declare(strict_types=1);

use Shopware\Core\TestBootstrapper;
require_once __DIR__ . '/TestBootstrapper.php';
use Kiwee\KiweeDemo\Test\TestBootstrapper;

$loader = (new TestBootstrapper())
->setForceInstallPlugins(true)
Expand Down
31 changes: 31 additions & 0 deletions tests/TestBootstrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);

namespace Kiwee\KiweeDemo\Test;

use Shopware\Core\TestBootstrapper as BaseTestBootstrapper;

class TestBootstrapper extends BaseTestBootstrapper
{
#[Override]
public function getPluginPath(string $pluginName): ?string
{
$pluginDirectories = \glob($this->getProjectDir() . '/custom/*plugins/*', \GLOB_ONLYDIR) ?: [];
$vendorDirectories = \glob($this->getProjectDir() . '/vendor/kiwee/shopware-demo-plugin', \GLOB_ONLYDIR) ?: [];
$allPluginDirectories = array_merge($pluginDirectories, $vendorDirectories);

foreach ($allPluginDirectories as $pluginDir) {
if (!is_file($pluginDir . '/composer.json')) {
continue;
}

if (!is_file($pluginDir . '/src/' . $pluginName . '.php')) {
continue;
}

return $pluginDir;
}

return null;
}
}

0 comments on commit 4da7d49

Please sign in to comment.