-
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 #172 from shlinkio/develop
Release 8.2.0
- Loading branch information
Showing
8 changed files
with
115 additions
and
10 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
25 changes: 25 additions & 0 deletions
25
src/Config/Option/UrlShortener/EnableTrailingSlashConfigOption.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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Installer\Config\Option\UrlShortener; | ||
|
||
use Shlinkio\Shlink\Installer\Config\Option\BaseConfigOption; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class EnableTrailingSlashConfigOption extends BaseConfigOption | ||
{ | ||
public function getEnvVar(): string | ||
{ | ||
return 'SHORT_URL_TRAILING_SLASH'; | ||
} | ||
|
||
public function ask(StyleInterface $io, array $currentOptions): bool | ||
{ | ||
return $io->confirm( | ||
'Do you want to support trailing slashes in short URLs? (https://doma.in/foo and https://doma.in/foo/ ' | ||
. 'will be considered the same)', | ||
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
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
44 changes: 44 additions & 0 deletions
44
test/Config/Option/UrlShortener/EnableTrailingSlashConfigOptionTest.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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioTest\Shlink\Installer\Config\Option\UrlShortener; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\PhpUnit\ProphecyTrait; | ||
use Shlinkio\Shlink\Installer\Config\Option\UrlShortener\EnableTrailingSlashConfigOption; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class EnableTrailingSlashConfigOptionTest extends TestCase | ||
{ | ||
use ProphecyTrait; | ||
|
||
private EnableTrailingSlashConfigOption $configOption; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->configOption = new EnableTrailingSlashConfigOption(); | ||
} | ||
|
||
/** @test */ | ||
public function returnsExpectedEnvVar(): void | ||
{ | ||
self::assertEquals('SHORT_URL_TRAILING_SLASH', $this->configOption->getEnvVar()); | ||
} | ||
|
||
/** @test */ | ||
public function expectedQuestionIsAsked(): void | ||
{ | ||
$io = $this->prophesize(StyleInterface::class); | ||
$confirm = $io->confirm( | ||
'Do you want to support trailing slashes in short URLs? (https://doma.in/foo and https://doma.in/foo/ ' | ||
. 'will be considered the same)', | ||
false, | ||
)->willReturn(true); | ||
|
||
$answer = $this->configOption->ask($io->reveal(), []); | ||
|
||
self::assertTrue($answer); | ||
$confirm->shouldHaveBeenCalledOnce(); | ||
} | ||
} |
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