-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from shlinkio/develop
Release 7.1.0
- Loading branch information
Showing
12 changed files
with
165 additions
and
34 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
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
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
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
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Installer\Config\Option; | ||
|
||
use Shlinkio\Shlink\Config\Collection\PathCollection; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class TimezoneConfigOption implements ConfigOptionInterface | ||
{ | ||
public function getEnvVar(): string | ||
{ | ||
return 'TIMEZONE'; | ||
} | ||
|
||
public function shouldBeAsked(PathCollection $currentOptions): bool | ||
{ | ||
return ! $currentOptions->pathExists([$this->getEnvVar()]); | ||
} | ||
|
||
public function ask(StyleInterface $io, PathCollection $currentOptions): ?string | ||
{ | ||
return $io->ask( | ||
'Set the timezone in which your Shlink instance is running (leave empty to use the one set in PHP config)', | ||
); | ||
} | ||
} |
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
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
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
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
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,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioTest\Shlink\Installer\Config\Option; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\PhpUnit\ProphecyTrait; | ||
use Shlinkio\Shlink\Config\Collection\PathCollection; | ||
use Shlinkio\Shlink\Installer\Config\Option\TimezoneConfigOption; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class TimezoneConfigOptionTest extends TestCase | ||
{ | ||
use ProphecyTrait; | ||
|
||
private TimezoneConfigOption $configOption; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->configOption = new TimezoneConfigOption(); | ||
} | ||
|
||
/** @test */ | ||
public function returnsExpectedEnvVar(): void | ||
{ | ||
self::assertEquals('TIMEZONE', $this->configOption->getEnvVar()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @dataProvider provideValidAnswers | ||
*/ | ||
public function expectedQuestionIsAsked(?string $answer, string $expectedAnswer): void | ||
{ | ||
$io = $this->prophesize(StyleInterface::class); | ||
$ask = $io->ask( | ||
'Set the timezone in which your Shlink instance is running (leave empty to use the one set in PHP config)', | ||
)->willReturn($answer); | ||
|
||
$answer = $this->configOption->ask($io->reveal(), new PathCollection()); | ||
|
||
self::assertEquals($expectedAnswer, $answer); | ||
$ask->shouldHaveBeenCalledOnce(); | ||
} | ||
|
||
public function provideValidAnswers(): iterable | ||
{ | ||
yield ['the_answer', 'the_answer']; | ||
yield [null, '']; | ||
} | ||
|
||
/** | ||
* @test | ||
* @dataProvider provideCurrentOptions | ||
*/ | ||
public function shouldBeCalledOnlyIfItDoesNotYetExist(PathCollection $currentOptions, bool $expected): void | ||
{ | ||
self::assertEquals($expected, $this->configOption->shouldBeAsked($currentOptions)); | ||
} | ||
|
||
public function provideCurrentOptions(): iterable | ||
{ | ||
yield 'not exists in config' => [new PathCollection(), true]; | ||
yield 'exists in config' => [new PathCollection(['TIMEZONE' => 'America/Los_Angeles']), false]; | ||
} | ||
} |
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
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