Skip to content

Commit d8d1732

Browse files
committed
test: make event listeners testable (bypass guards)
1 parent 68bd546 commit d8d1732

11 files changed

Lines changed: 10 additions & 15 deletions

src/EventListener/ContentListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(
2929
string $projectDir,
3030
) {
3131
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
32-
$this->isCli = PHP_SAPI === 'cli';
32+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
3333
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
3434
$this->mode = Helper::determineMode();
3535
$this->destination = Helper::determineDestination($this->projectDir);

src/EventListener/ContentTypeGroupListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
private readonly ContainerInterface $container
3737
) {
3838
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
39-
$this->isCli = PHP_SAPI === 'cli';
39+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
4040
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
4141
$this->mode = Helper::determineMode();
4242
$this->destination = Helper::determineDestination($this->projectDir);

src/EventListener/ContentTypeListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131
) {
3232
$this->container = $container;
3333
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
34-
$this->isCli = PHP_SAPI === 'cli';
34+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
3535
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
3636
$this->mode = Helper::determineMode();
3737
$this->destination = Helper::determineDestination($this->projectDir);

src/EventListener/LanguageListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131
) {
3232
$this->container = $container;
3333
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
34-
$this->isCli = PHP_SAPI === 'cli';
34+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
3535
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
3636
$this->mode = Helper::determineMode();
3737
$this->destination = Helper::determineDestination($this->projectDir);

src/EventListener/ObjectStateGroupListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
) {
3737
$this->logger->info('ObjectStateGroupListener constructor called');
3838
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
39-
$this->isCli = PHP_SAPI === 'cli';
39+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
4040
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
4141
$this->mode = Helper::determineMode();
4242
$this->logger->info('ObjectStateGroupListener detected migration mode', ['mode' => $this->mode]);

src/EventListener/ObjectStateListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(
3333
) {
3434
$this->container = $container;
3535
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
36-
$this->isCli = PHP_SAPI === 'cli';
36+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
3737
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
3838
$this->mode = Helper::determineMode();
3939
$this->destination = Helper::determineDestination($this->projectDir);

src/EventListener/RoleListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
) {
3333
$this->container = $container;
3434
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
35-
$this->isCli = PHP_SAPI === 'cli';
35+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
3636
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
3737
$this->mode = Helper::determineMode();
3838
$this->destination = Helper::determineDestination($this->projectDir);

src/EventListener/SectionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
) {
3737
$this->container = $container;
3838
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
39-
$this->isCli = PHP_SAPI === 'cli';
39+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
4040
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
4141
$this->mode = Helper::determineMode();
4242
$this->destination = Helper::determineDestination($this->projectDir);

src/EventListener/UrlListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
) {
3333
$this->container = $container;
3434
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
35-
$this->isCli = PHP_SAPI === 'cli';
35+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
3636
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
3737
$this->mode = Helper::determineMode();
3838
$this->destination = Helper::determineDestination($this->projectDir);

src/EventListener/UserListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131
) {
3232
$this->container = $container;
3333
$this->projectDir = rtrim($projectDir, DIRECTORY_SEPARATOR);
34-
$this->isCli = PHP_SAPI === 'cli';
34+
$this->isCli = PHP_SAPI === 'cli' && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) !== 'testing';
3535
$this->consoleCommand = ['php', '-d', 'memory_limit=512M', $this->projectDir . '/bin/console'];
3636
$this->mode = Helper::determineMode();
3737
$this->destination = Helper::determineDestination($this->projectDir);

0 commit comments

Comments
 (0)