-
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 #223 from acelaya-forks/feature/robots-user-agents
Feature/robots user agents
- Loading branch information
Showing
7 changed files
with
76 additions
and
11 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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Installer\Config\Option\Robots; | ||
|
||
use Shlinkio\Shlink\Installer\Config\Option\BaseConfigOption; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class RobotsUserAgentsConfigOption extends BaseConfigOption | ||
{ | ||
public function getEnvVar(): string | ||
{ | ||
return 'ROBOTS_USER_AGENTS'; | ||
} | ||
|
||
public function ask(StyleInterface $io, array $currentOptions): ?string | ||
{ | ||
return $io->ask( | ||
'Provide a comma-separated list of user agents for your robots.txt file. Defaults to all user agents (*)', | ||
); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
test/Config/Option/Robots/RobotsUserAgentsConfigOptionTest.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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioTest\Shlink\Installer\Config\Option\Robots; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
use Shlinkio\Shlink\Installer\Config\Option\Robots\RobotsUserAgentsConfigOption; | ||
use Symfony\Component\Console\Style\StyleInterface; | ||
|
||
class RobotsUserAgentsConfigOptionTest extends TestCase | ||
{ | ||
private RobotsUserAgentsConfigOption $configOption; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->configOption = new RobotsUserAgentsConfigOption(); | ||
} | ||
|
||
#[Test] | ||
public function returnsExpectedEnvVar(): void | ||
{ | ||
self::assertEquals('ROBOTS_USER_AGENTS', $this->configOption->getEnvVar()); | ||
} | ||
|
||
#[Test] | ||
public function expectedQuestionIsAsked(): void | ||
{ | ||
$io = $this->createMock(StyleInterface::class); | ||
$io->expects($this->once())->method('ask')->with( | ||
'Provide a comma-separated list of user agents for your robots.txt file. Defaults to all user agents (*)', | ||
)->willReturn('foo,bar'); | ||
|
||
$answer = $this->configOption->ask($io, []); | ||
|
||
self::assertEquals('foo,bar', $answer); | ||
} | ||
} |