Skip to content

Commit

Permalink
Move "Pimcore\BootstrapPimcore" to the namespace root
Browse files Browse the repository at this point in the history
  • Loading branch information
jdreesen committed Aug 30, 2024
1 parent 8283a78 commit 474aba6
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v0.13.0
### Changes:
- Deprecated `Neusta\Pimcore\TestingFramework\Kernel\TestKernel` in favor of `Neusta\Pimcore\TestingFramework\TestKernel`
- Deprecated `Neusta\Pimcore\TestingFramework\Pimcore\BootstrapPimcore` in favor of `Neusta\Pimcore\TestingFramework\BootstrapPimcore`

## v0.12.4
### Bugfixes:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Just call `BootstrapPimcore::bootstrap()` in your `tests/bootstrap.php` as seen
include dirname(__DIR__).'/vendor/autoload.php';
Neusta\Pimcore\TestingFramework\Pimcore\BootstrapPimcore::bootstrap();
\Neusta\Pimcore\TestingFramework\BootstrapPimcore::bootstrap();
```
You can also pass any environment variable via named arguments to this method:
```php
# tests/bootstrap.php
Neusta\Pimcore\TestingFramework\Pimcore\BootstrapPimcore::bootstrap(
\Neusta\Pimcore\TestingFramework\BootstrapPimcore::bootstrap(
APP_ENV: 'custom',
SOMETHING: 'else',
);
Expand All @@ -52,7 +52,7 @@ For a basic setup, you can use the `TestKernel` directly:
# tests/bootstrap.php
<?php
use Neusta\Pimcore\TestingFramework\Pimcore\BootstrapPimcore;
use Neusta\Pimcore\TestingFramework\BootstrapPimcore;
use Neusta\Pimcore\TestingFramework\TestKernel;
include dirname(__DIR__).'/vendor/autoload.php';
Expand Down
31 changes: 31 additions & 0 deletions src/BootstrapPimcore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Neusta\Pimcore\TestingFramework;

use Neusta\Pimcore\TestingFramework\Pimcore\AdminMode;
use Pimcore\Bootstrap;

final class BootstrapPimcore
{
private const DEFAULT_ENV_VARS = [
'APP_ENV' => 'test',
];

public static function bootstrap(string ...$envVars): void
{
foreach ($envVars + self::DEFAULT_ENV_VARS as $name => $value) {
self::setEnv($name, $value);
}

Bootstrap::setProjectRoot();
Bootstrap::bootstrap();
AdminMode::disable();
}

public static function setEnv(string $name, string $value): void
{
putenv("{$name}=" . $_ENV[$name] = $_SERVER[$name] = $value);
}
}
38 changes: 20 additions & 18 deletions src/Pimcore/BootstrapPimcore.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
<?php

declare(strict_types=1);

namespace Neusta\Pimcore\TestingFramework\Pimcore;

use Pimcore\Bootstrap;
use \Neusta\Pimcore\TestingFramework\BootstrapPimcore as RootBootstrapPimcore;

trigger_deprecation(
'teamneusta/pimcore-testing-framework',
'0.13',
'The "%s" class is deprecated, use "%s" instead.',
BootstrapPimcore::class,
RootBootstrapPimcore::class,
);

final class BootstrapPimcore
{
private const DEFAULT_ENV_VARS = [
'APP_ENV' => 'test',
];
class_alias(RootBootstrapPimcore::class, BootstrapPimcore::class);

public static function bootstrap(string ...$envVars): void
if (false) {
/**
* @deprecated since 0.13, use Neusta\Pimcore\TestingFramework\BootstrapPimcore instead
*/
final class BootstrapPimcore
{
foreach ($envVars + self::DEFAULT_ENV_VARS as $name => $value) {
self::setEnv($name, $value);
public static function bootstrap(string ...$envVars): void
{
}

Bootstrap::setProjectRoot();
Bootstrap::bootstrap();
AdminMode::disable();
}

public static function setEnv(string $name, string $value): void
{
putenv("{$name}=" . $_ENV[$name] = $_SERVER[$name] = $value);
public static function setEnv(string $name, string $value): void
{
}
}
}
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Neusta\Pimcore\TestingFramework\Pimcore\BootstrapPimcore;
use Neusta\Pimcore\TestingFramework\BootstrapPimcore;
use Neusta\Pimcore\TestingFramework\TestKernel;

include dirname(__DIR__) . '/vendor/autoload.php';
Expand Down

0 comments on commit 474aba6

Please sign in to comment.