Skip to content

Commit dfafa15

Browse files
committed
Use Application::addCommand if available
1 parent ff65f40 commit dfafa15

6 files changed

Lines changed: 24 additions & 12 deletions

tests/Unit/Command/BaseInvalidateCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public function testContainerAccess(): void
3535
;
3636

3737
$application = new Application();
38+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
3839
$command = new InvalidatePathCommand($invalidator);
39-
$application->add($command);
40+
$application->$addMethod($command);
4041

4142
$command = $application->find('fos:httpcache:invalidate:path');
4243
$commandTester = new CommandTester($command);

tests/Unit/Command/ClearCommandTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public function testExecuteClear(): void
3232
;
3333

3434
$application = new Application();
35-
$application->add(new ClearCommand($invalidator));
35+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
36+
$application->$addMethod(new ClearCommand($invalidator));
3637

3738
$command = $application->find('fos:httpcache:clear');
3839
$commandTester = new CommandTester($command);
@@ -54,7 +55,8 @@ public function testExecuteInvalidate(): void
5455
;
5556

5657
$application = new Application();
57-
$application->add(new ClearCommand($invalidator));
58+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
59+
$application->$addMethod(new ClearCommand($invalidator));
5860

5961
$command = $application->find('fos:httpcache:clear');
6062
$commandTester = new CommandTester($command);
@@ -75,7 +77,8 @@ public function testExecuteNotSupported(): void
7577
;
7678

7779
$application = new Application();
78-
$application->add(new ClearCommand($invalidator));
80+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
81+
$application->$addMethod(new ClearCommand($invalidator));
7982

8083
$command = $application->find('fos:httpcache:clear');
8184
$commandTester = new CommandTester($command);

tests/Unit/Command/InvalidatePathCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void
2929
$invalidator = \Mockery::mock(CacheManager::class);
3030

3131
$application = new Application();
32-
$application->add(new InvalidatePathCommand($invalidator));
32+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
33+
$application->$addMethod(new InvalidatePathCommand($invalidator));
3334

3435
$command = $application->find('fos:httpcache:invalidate:path');
3536
$commandTester = new CommandTester($command);
@@ -45,7 +46,8 @@ public function testExecuteParameter(): void
4546
;
4647

4748
$application = new Application();
48-
$application->add(new InvalidatePathCommand($invalidator));
49+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
50+
$application->$addMethod(new InvalidatePathCommand($invalidator));
4951

5052
$command = $application->find('fos:httpcache:invalidate:path');
5153
$commandTester = new CommandTester($command);

tests/Unit/Command/InvalidateRegexCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function testExecuteNoParameters(): void
2929
$invalidator = \Mockery::mock(CacheManager::class);
3030

3131
$application = new Application();
32-
$application->add(new InvalidateRegexCommand($invalidator));
32+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
33+
$application->$addMethod(new InvalidateRegexCommand($invalidator));
3334

3435
$command = $application->find('fos:httpcache:invalidate:regex');
3536
$commandTester = new CommandTester($command);
@@ -44,7 +45,8 @@ public function testExecuteParameter(): void
4445
;
4546

4647
$application = new Application();
47-
$application->add(new InvalidateRegexCommand($invalidator));
48+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
49+
$application->$addMethod(new InvalidateRegexCommand($invalidator));
4850

4951
$command = $application->find('fos:httpcache:invalidate:regex');
5052
$commandTester = new CommandTester($command);

tests/Unit/Command/InvalidateTagCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void
2929
$invalidator = \Mockery::mock(CacheManager::class);
3030

3131
$application = new Application();
32-
$application->add(new InvalidateTagCommand($invalidator));
32+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
33+
$application->$addMethod(new InvalidateTagCommand($invalidator));
3334

3435
$command = $application->find('fos:httpcache:invalidate:tag');
3536
$commandTester = new CommandTester($command);
@@ -44,7 +45,8 @@ public function testExecuteParameter(): void
4445
;
4546

4647
$application = new Application();
47-
$application->add(new InvalidateTagCommand($invalidator));
48+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
49+
$application->$addMethod(new InvalidateTagCommand($invalidator));
4850

4951
$command = $application->find('fos:httpcache:invalidate:tag');
5052
$commandTester = new CommandTester($command);

tests/Unit/Command/RefreshPathCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void
2929
$invalidator = \Mockery::mock(CacheManager::class);
3030

3131
$application = new Application();
32-
$application->add(new RefreshPathCommand($invalidator));
32+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
33+
$application->$addMethod(new RefreshPathCommand($invalidator));
3334

3435
$command = $application->find('fos:httpcache:refresh:path');
3536
$commandTester = new CommandTester($command);
@@ -45,7 +46,8 @@ public function testExecuteParameter(): void
4546
;
4647

4748
$application = new Application();
48-
$application->add(new RefreshPathCommand($invalidator));
49+
$addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add';
50+
$application->$addMethod(new RefreshPathCommand($invalidator));
4951

5052
$command = $application->find('fos:httpcache:refresh:path');
5153
$commandTester = new CommandTester($command);

0 commit comments

Comments
 (0)