Skip to content

Commit ae3fa45

Browse files
authored
Merge pull request #210 from shlinkio/develop
Release 8.7.0
2 parents 6022141 + 06ddce0 commit ae3fa45

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
66

7+
## [8.7.0] - 2023-12-26
8+
### Added
9+
* Add config option to enable/disable QR codes for disables short URLs.
10+
11+
### Changed
12+
* *Nothing*
13+
14+
### Deprecated
15+
* *Nothing*
16+
17+
### Removed
18+
* *Nothing*
19+
20+
### Fixed
21+
* *Nothing*
22+
23+
724
## [8.6.1] - 2023-12-17
825
### Added
926
* *Nothing*

config/config.php

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
'QR codes > Default format' => Config\Option\QrCode\DefaultFormatConfigOption::class,
9292
'QR codes > Default error correction' => Config\Option\QrCode\DefaultErrorCorrectionConfigOption::class,
9393
'QR codes > Default round block size' => Config\Option\QrCode\DefaultRoundBlockSizeConfigOption::class,
94+
'QR codes > Enabled for disabled short URLs'
95+
=> Config\Option\QrCode\EnabledForDisabledShortUrlsConfigOption::class,
9496
],
9597
'APPLICATION' => [
9698
'Delete short URLs > Visits threshold' => Config\Option\Visit\VisitsThresholdConfigOption::class,
@@ -186,6 +188,7 @@
186188
Config\Option\QrCode\DefaultFormatConfigOption::class => InvokableFactory::class,
187189
Config\Option\QrCode\DefaultErrorCorrectionConfigOption::class => InvokableFactory::class,
188190
Config\Option\QrCode\DefaultRoundBlockSizeConfigOption::class => InvokableFactory::class,
191+
Config\Option\QrCode\EnabledForDisabledShortUrlsConfigOption::class => InvokableFactory::class,
189192
],
190193
],
191194

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Shlinkio\Shlink\Installer\Config\Option\QrCode;
6+
7+
use Shlinkio\Shlink\Installer\Config\Option\BaseConfigOption;
8+
use Symfony\Component\Console\Style\StyleInterface;
9+
10+
class EnabledForDisabledShortUrlsConfigOption extends BaseConfigOption
11+
{
12+
public function getEnvVar(): string
13+
{
14+
return 'QR_CODE_FOR_DISABLED_SHORT_URLS';
15+
}
16+
17+
public function ask(StyleInterface $io, array $currentOptions): bool
18+
{
19+
return $io->confirm(
20+
'Should Shlink be able to generate QR codes for short URLs which are not enabled? (Short URLs are not '
21+
. 'enabled if they have a "valid since" in the future, a "valid until" in the past, or reached the maximum '
22+
. 'amount of allowed visits)',
23+
// Deprecated. Shlink 4.0.0 should change default value to `true`
24+
false,
25+
);
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ShlinkioTest\Shlink\Installer\Config\Option\QrCode;
6+
7+
use PHPUnit\Framework\Attributes\Test;
8+
use PHPUnit\Framework\TestCase;
9+
use Shlinkio\Shlink\Installer\Config\Option\QrCode\EnabledForDisabledShortUrlsConfigOption;
10+
use Symfony\Component\Console\Style\StyleInterface;
11+
12+
class EnabledForDisabledShortUrlsConfigOptionTest extends TestCase
13+
{
14+
private EnabledForDisabledShortUrlsConfigOption $configOption;
15+
16+
public function setUp(): void
17+
{
18+
$this->configOption = new EnabledForDisabledShortUrlsConfigOption();
19+
}
20+
21+
#[Test]
22+
public function returnsExpectedEnvVar(): void
23+
{
24+
self::assertEquals('QR_CODE_FOR_DISABLED_SHORT_URLS', $this->configOption->getEnvVar());
25+
}
26+
27+
#[Test]
28+
public function expectedQuestionIsAsked(): void
29+
{
30+
$io = $this->createMock(StyleInterface::class);
31+
$io->expects($this->once())->method('confirm')->with(
32+
'Should Shlink be able to generate QR codes for short URLs which are not enabled? (Short URLs are not '
33+
. 'enabled if they have a "valid since" in the future, a "valid until" in the past, or reached the maximum '
34+
. 'amount of allowed visits)',
35+
false,
36+
)->willReturn(true);
37+
38+
$answer = $this->configOption->ask($io, []);
39+
40+
self::assertEquals(true, $answer);
41+
}
42+
}

0 commit comments

Comments
 (0)