mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-18 00:52:07 +03:00
Added searchTerm param to shortcode:list command
This commit is contained in:
parent
0a6030b35d
commit
8610a158d4
2 changed files with 23 additions and 10 deletions
|
@ -56,6 +56,14 @@ class ListShortcodesCommand extends Command
|
||||||
),
|
),
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
|
->addOption(
|
||||||
|
'searchTerm',
|
||||||
|
's',
|
||||||
|
InputOption::VALUE_OPTIONAL,
|
||||||
|
$this->translator->translate(
|
||||||
|
'A query used to filter results by searching for it on the longUrl and shortCode fields'
|
||||||
|
)
|
||||||
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'tags',
|
'tags',
|
||||||
't',
|
't',
|
||||||
|
@ -67,13 +75,14 @@ class ListShortcodesCommand extends Command
|
||||||
public function execute(InputInterface $input, OutputInterface $output)
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$page = intval($input->getOption('page'));
|
$page = intval($input->getOption('page'));
|
||||||
|
$searchTerm = $input->getOption('searchTerm');
|
||||||
$showTags = $input->getOption('tags');
|
$showTags = $input->getOption('tags');
|
||||||
|
|
||||||
/** @var QuestionHelper $helper */
|
/** @var QuestionHelper $helper */
|
||||||
$helper = $this->getHelper('question');
|
$helper = $this->getHelper('question');
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$result = $this->shortUrlService->listShortUrls($page);
|
$result = $this->shortUrlService->listShortUrls($page, $searchTerm);
|
||||||
$page++;
|
$page++;
|
||||||
$table = new Table($output);
|
$table = new Table($output);
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ class ListShortcodesCommandTest extends TestCase
|
||||||
public function noInputCallsListJustOnce()
|
public function noInputCallsListJustOnce()
|
||||||
{
|
{
|
||||||
$this->questionHelper->setInputStream($this->getInputStream('\n'));
|
$this->questionHelper->setInputStream($this->getInputStream('\n'));
|
||||||
$this->shortUrlService->listShortUrls(1)->willReturn(new Paginator(new ArrayAdapter()))
|
$this->shortUrlService->listShortUrls(1, null)->willReturn(new Paginator(new ArrayAdapter()))
|
||||||
->shouldBeCalledTimes(1);
|
->shouldBeCalledTimes(1);
|
||||||
|
|
||||||
$this->commandTester->execute(['command' => 'shortcode:list']);
|
$this->commandTester->execute(['command' => 'shortcode:list']);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,11 @@ class ListShortcodesCommandTest extends TestCase
|
||||||
|
|
||||||
$questionHelper = $this->questionHelper;
|
$questionHelper = $this->questionHelper;
|
||||||
$that = $this;
|
$that = $this;
|
||||||
$this->shortUrlService->listShortUrls(Argument::any())->will(function () use (&$data, $questionHelper, $that) {
|
$this->shortUrlService->listShortUrls(Argument::cetera())->will(function () use (
|
||||||
|
&$data,
|
||||||
|
$questionHelper,
|
||||||
|
$that
|
||||||
|
) {
|
||||||
$questionHelper->setInputStream($that->getInputStream('y'));
|
$questionHelper->setInputStream($that->getInputStream('y'));
|
||||||
return new Paginator(new ArrayAdapter(array_shift($data)));
|
return new Paginator(new ArrayAdapter(array_shift($data)));
|
||||||
})->shouldBeCalledTimes(3);
|
})->shouldBeCalledTimes(3);
|
||||||
|
@ -86,8 +90,8 @@ class ListShortcodesCommandTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->questionHelper->setInputStream($this->getInputStream('n'));
|
$this->questionHelper->setInputStream($this->getInputStream('n'));
|
||||||
$this->shortUrlService->listShortUrls(Argument::any())->willReturn(new Paginator(new ArrayAdapter($data)))
|
$this->shortUrlService->listShortUrls(Argument::cetera())->willReturn(new Paginator(new ArrayAdapter($data)))
|
||||||
->shouldBeCalledTimes(1);
|
->shouldBeCalledTimes(1);
|
||||||
|
|
||||||
$this->commandTester->execute(['command' => 'shortcode:list']);
|
$this->commandTester->execute(['command' => 'shortcode:list']);
|
||||||
}
|
}
|
||||||
|
@ -99,8 +103,8 @@ class ListShortcodesCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
$page = 5;
|
$page = 5;
|
||||||
$this->questionHelper->setInputStream($this->getInputStream('\n'));
|
$this->questionHelper->setInputStream($this->getInputStream('\n'));
|
||||||
$this->shortUrlService->listShortUrls($page)->willReturn(new Paginator(new ArrayAdapter()))
|
$this->shortUrlService->listShortUrls($page, null)->willReturn(new Paginator(new ArrayAdapter()))
|
||||||
->shouldBeCalledTimes(1);
|
->shouldBeCalledTimes(1);
|
||||||
|
|
||||||
$this->commandTester->execute([
|
$this->commandTester->execute([
|
||||||
'command' => 'shortcode:list',
|
'command' => 'shortcode:list',
|
||||||
|
@ -114,8 +118,8 @@ class ListShortcodesCommandTest extends TestCase
|
||||||
public function ifTagsFlagIsProvidedTagsColumnIsIncluded()
|
public function ifTagsFlagIsProvidedTagsColumnIsIncluded()
|
||||||
{
|
{
|
||||||
$this->questionHelper->setInputStream($this->getInputStream('\n'));
|
$this->questionHelper->setInputStream($this->getInputStream('\n'));
|
||||||
$this->shortUrlService->listShortUrls(1)->willReturn(new Paginator(new ArrayAdapter()))
|
$this->shortUrlService->listShortUrls(1, null)->willReturn(new Paginator(new ArrayAdapter()))
|
||||||
->shouldBeCalledTimes(1);
|
->shouldBeCalledTimes(1);
|
||||||
|
|
||||||
$this->commandTester->execute([
|
$this->commandTester->execute([
|
||||||
'command' => 'shortcode:list',
|
'command' => 'shortcode:list',
|
||||||
|
|
Loading…
Reference in a new issue