Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Convert questions to a string, fixes #243 #244

Merged
merged 2 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@
"expressive": "expressive --ansi",
"check": [
"@cs-check",
"@test"
"@test",
"@analyze"
],
"analyze": "phpstan analyze -l max -c ./phpstan.installer.neon ./src ./config",
"clear-config-cache": "php bin/clear-config-cache.php",
"cs-check": "phpcs",
"cs-fix": "phpcbf",
Expand Down
4 changes: 2 additions & 2 deletions src/ExpressiveInstaller/OptionalPackages.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function requestInstallType() : string
];

while (true) {
$answer = $this->io->ask($query, '2');
$answer = $this->io->ask(implode($query), '2');

switch (true) {
case ($answer === '1'):
Expand Down Expand Up @@ -621,7 +621,7 @@ private function askQuestion(array $question, $defaultOption)

while (true) {
// Ask for user input
$answer = $this->io->ask($ask, (string) $defaultOption);
$answer = $this->io->ask(implode($ask), (string) $defaultOption);

// Handle none of the options
if ($answer === 'n' && $question['required'] !== true) {
Expand Down
14 changes: 11 additions & 3 deletions test/ExpressiveInstallerTest/PromptForOptionalPackagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@ public function testPromptForOptionalPackage(

public static function assertPromptText($expected, $argument)
{
$argument = is_array($argument) ? array_shift($argument) : $argument;
$message = sprintf('Expected prompt not received: "%s"', $expected);
self::assertThat(false !== strpos($argument, $expected), self::isTrue(), $message);
self::assertInternalType(
'string',
$argument,
'Questions must be a string since symfony/console:4.0'
);

self::assertThat(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not assertTrue?

Copy link
Member Author

@geerteltink geerteltink Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question.

@weierophinney any reason you wrote it like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to ask @weierophinney ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, because it's how custom assertions are demonstrated in the manual: https://phpunit.de/manual/current/en/extending-phpunit.html

I'm fine with either approach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... in the docs is just example, maybe a bit unfortunate, because assertTrue is one of the available assertions.

false !== strpos($argument, $expected),
self::isTrue(),
sprintf('Expected prompt not received: "%s"', $expected)
);
}
}
6 changes: 5 additions & 1 deletion test/ExpressiveInstallerTest/RequestInstallTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public function testWillContinueToPromptUntilValidAnswerPresented()

public static function assertQueryPrompt($value)
{
$value = is_array($value) ? array_shift($value) : $value;
self::assertInternalType(
'string',
$value,
'Questions must be a string since symfony/console:4.0'
);

self::assertThat(
false !== strpos($value, 'What type of installation would you like?'),
Expand Down