-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI-1276: no-scripts doesn't disable composer hooks
- Loading branch information
1 parent
6bc2749
commit 88d5d3a
Showing
3 changed files
with
98 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
tests/phpunit/src/Application/ComposerScriptsListenerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Acquia\Cli\Tests\Application; | ||
|
||
use Acquia\Cli\Tests\ApplicationTestBase; | ||
use Symfony\Component\Filesystem\Path; | ||
|
||
/** | ||
* Tests Composer hooks handled by the Symfony Event Dispatcher. | ||
* | ||
* These must be tested using the ApplicationTestBase, since the Symfony | ||
* CommandTester does not fire Event Dispatchers. | ||
*/ | ||
class ComposerScriptsListenerTest extends ApplicationTestBase { | ||
|
||
/** | ||
* @group serial | ||
* @covers \Acquia\Cli\EventListener\ComposerScriptsListener::onConsoleCommand | ||
*/ | ||
public function testPreScripts(): void { | ||
$json = [ | ||
'scripts' => [ | ||
'pre-acli-hello-world' => [ | ||
'echo "good morning world"', | ||
], | ||
], | ||
]; | ||
file_put_contents( | ||
Path::join($this->projectDir, 'composer.json'), | ||
json_encode($json, JSON_THROW_ON_ERROR) | ||
); | ||
$this->mockRequest('getAccount'); | ||
$this->setInput([ | ||
'command' => 'hello-world', | ||
]); | ||
$buffer = $this->runApp(); | ||
self::assertStringContainsString('pre-acli-hello-world', $buffer); | ||
} | ||
|
||
/** | ||
* @group serial | ||
* @covers \Acquia\Cli\EventListener\ComposerScriptsListener::onConsoleTerminate | ||
*/ | ||
public function testPostScripts(): void { | ||
$json = [ | ||
'scripts' => [ | ||
'post-acli-hello-world' => [ | ||
'echo "goodbye world"', | ||
], | ||
], | ||
]; | ||
file_put_contents( | ||
Path::join($this->projectDir, 'composer.json'), | ||
json_encode($json, JSON_THROW_ON_ERROR) | ||
); | ||
$this->mockRequest('getAccount'); | ||
$this->setInput([ | ||
'command' => 'hello-world', | ||
]); | ||
$buffer = $this->runApp(); | ||
self::assertStringContainsString('post-acli-hello-world', $buffer); | ||
} | ||
|
||
public function testNoScripts(): void { | ||
$json = [ | ||
'scripts' => [ | ||
'pre-acli-pull-code' => [ | ||
'echo "goodbye world"', | ||
], | ||
], | ||
]; | ||
file_put_contents( | ||
Path::join($this->projectDir, 'composer.json'), | ||
json_encode($json, JSON_THROW_ON_ERROR) | ||
); | ||
$this->setInput([ | ||
'--no-scripts' => TRUE, | ||
'command' => 'pull:code', | ||
]); | ||
$buffer = $this->runApp(); | ||
self::assertStringNotContainsString('pre-acli-pull-code', $buffer); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters