expectException(RuntimeException::class); $this->expectExceptionMessage('Not enough arguments'); $application = new Application($this->getTestClient()->getKernel()); $command = $application->find('wallabag:import:url'); $tester = new CommandTester($command); $tester->execute([]); } public function testRunUrlCommandWithWrongUsername() { $this->expectException(NoResultException::class); $application = new Application($this->getTestClient()->getKernel()); $command = $application->find('wallabag:import:url'); $tester = new CommandTester($command); $tester->execute([ 'username' => 'random', 'url' => $this->url, ]); } public function testRunUrlCommand() { $application = new Application($this->getTestClient()->getKernel()); $command = $application->find('wallabag:import:url'); $tester = new CommandTester($command); $tester->execute([ 'username' => 'admin', 'url' => $this->url, ]); $this->assertStringContainsString('successfully imported', $tester->getDisplay()); } public function testRunUrlCommandWithTags() { $application = new Application($this->getTestClient()->getKernel()); $command = $application->find('wallabag:import:url'); $tester = new CommandTester($command); $tester->execute([ 'username' => 'admin', 'url' => $this->url, 'tags' => 'sport, football', ]); $this->assertStringContainsString('successfully imported', $tester->getDisplay()); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $entry = $em->getRepository(Entry::class)->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); $this->assertContains('football', $entry->getTagsLabel()); $this->assertNotContains('basketball', $entry->getTagsLabel()); } public function testRunUrlCommandWithUserId() { $this->logInAs('admin'); $application = new Application($this->getTestClient()->getKernel()); $command = $application->find('wallabag:import:url'); $tester = new CommandTester($command); $tester->execute([ 'username' => $this->getLoggedInUserId(), 'url' => $this->url, '--useUserId' => true, ]); $this->assertStringContainsString('successfully imported', $tester->getDisplay()); } }