diff options
9 files changed, 64 insertions, 35 deletions
diff --git a/.travis.yml b/.travis.yml index 60e7dd1c..6b279ed6 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -27,6 +27,7 @@ php: | |||
27 | - 5.6 | 27 | - 5.6 |
28 | - 7.0 | 28 | - 7.0 |
29 | - 7.1 | 29 | - 7.1 |
30 | - 7.2 | ||
30 | - nightly | 31 | - nightly |
31 | 32 | ||
32 | node_js: | 33 | node_js: |
@@ -43,6 +44,7 @@ matrix: | |||
43 | - php: 7.0 | 44 | - php: 7.0 |
44 | env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run ASSETS=build DB=sqlite | 45 | env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run ASSETS=build DB=sqlite |
45 | allow_failures: | 46 | allow_failures: |
47 | - php: 7.2 | ||
46 | - php: nightly | 48 | - php: nightly |
47 | 49 | ||
48 | # exclude v1 branches | 50 | # exclude v1 branches |
diff --git a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php index d964439d..b4aa4e47 100644 --- a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php +++ b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php | |||
@@ -111,9 +111,4 @@ class CleanDuplicatesCommand extends ContainerAwareCommand | |||
111 | { | 111 | { |
112 | return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); | 112 | return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); |
113 | } | 113 | } |
114 | |||
115 | private function getDoctrine() | ||
116 | { | ||
117 | return $this->getContainer()->get('doctrine'); | ||
118 | } | ||
119 | } | 114 | } |
diff --git a/src/Wallabag/CoreBundle/Command/ExportCommand.php b/src/Wallabag/CoreBundle/Command/ExportCommand.php index c2e4be05..291926e4 100644 --- a/src/Wallabag/CoreBundle/Command/ExportCommand.php +++ b/src/Wallabag/CoreBundle/Command/ExportCommand.php | |||
@@ -69,9 +69,4 @@ class ExportCommand extends ContainerAwareCommand | |||
69 | 69 | ||
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | |||
73 | private function getDoctrine() | ||
74 | { | ||
75 | return $this->getContainer()->get('doctrine'); | ||
76 | } | ||
77 | } | 72 | } |
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 50551480..c7809053 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -14,7 +14,6 @@ use Symfony\Component\Console\Output\BufferedOutput; | |||
14 | use Symfony\Component\Console\Output\OutputInterface; | 14 | use Symfony\Component\Console\Output\OutputInterface; |
15 | use Symfony\Component\Console\Question\ConfirmationQuestion; | 15 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
16 | use Symfony\Component\Console\Question\Question; | 16 | use Symfony\Component\Console\Question\Question; |
17 | use Wallabag\CoreBundle\Entity\Config; | ||
18 | 17 | ||
19 | class InstallCommand extends ContainerAwareCommand | 18 | class InstallCommand extends ContainerAwareCommand |
20 | { | 19 | { |
diff --git a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php index eef04988..090309d9 100644 --- a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php +++ b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php | |||
@@ -7,12 +7,13 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | |||
7 | use Symfony\Component\Console\Input\InputArgument; | 7 | use Symfony\Component\Console\Input\InputArgument; |
8 | use Symfony\Component\Console\Input\InputInterface; | 8 | use Symfony\Component\Console\Input\InputInterface; |
9 | use Symfony\Component\Console\Output\OutputInterface; | 9 | use Symfony\Component\Console\Output\OutputInterface; |
10 | use Symfony\Component\Console\Style\SymfonyStyle; | ||
10 | use Wallabag\UserBundle\Entity\User; | 11 | use Wallabag\UserBundle\Entity\User; |
11 | 12 | ||
12 | class ShowUserCommand extends ContainerAwareCommand | 13 | class ShowUserCommand extends ContainerAwareCommand |
13 | { | 14 | { |
14 | /** @var OutputInterface */ | 15 | /** @var SymfonyStyle */ |
15 | protected $output; | 16 | protected $io; |
16 | 17 | ||
17 | protected function configure() | 18 | protected function configure() |
18 | { | 19 | { |
@@ -29,7 +30,7 @@ class ShowUserCommand extends ContainerAwareCommand | |||
29 | 30 | ||
30 | protected function execute(InputInterface $input, OutputInterface $output) | 31 | protected function execute(InputInterface $input, OutputInterface $output) |
31 | { | 32 | { |
32 | $this->output = $output; | 33 | $this->io = new SymfonyStyle($input, $output); |
33 | 34 | ||
34 | $username = $input->getArgument('username'); | 35 | $username = $input->getArgument('username'); |
35 | 36 | ||
@@ -37,7 +38,7 @@ class ShowUserCommand extends ContainerAwareCommand | |||
37 | $user = $this->getUser($username); | 38 | $user = $this->getUser($username); |
38 | $this->showUser($user); | 39 | $this->showUser($user); |
39 | } catch (NoResultException $e) { | 40 | } catch (NoResultException $e) { |
40 | $output->writeln(sprintf('<error>User "%s" not found.</error>', $username)); | 41 | $this->io->error(sprintf('User "%s" not found.', $username)); |
41 | 42 | ||
42 | return 1; | 43 | return 1; |
43 | } | 44 | } |
@@ -50,12 +51,14 @@ class ShowUserCommand extends ContainerAwareCommand | |||
50 | */ | 51 | */ |
51 | private function showUser(User $user) | 52 | private function showUser(User $user) |
52 | { | 53 | { |
53 | $this->output->writeln(sprintf('Username : %s', $user->getUsername())); | 54 | $this->io->listing([ |
54 | $this->output->writeln(sprintf('Email : %s', $user->getEmail())); | 55 | sprintf('Username : %s', $user->getUsername()), |
55 | $this->output->writeln(sprintf('Display name : %s', $user->getName())); | 56 | sprintf('Email : %s', $user->getEmail()), |
56 | $this->output->writeln(sprintf('Creation date : %s', $user->getCreatedAt()->format('Y-m-d H:i:s'))); | 57 | sprintf('Display name : %s', $user->getName()), |
57 | $this->output->writeln(sprintf('Last login : %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never')); | 58 | sprintf('Creation date : %s', $user->getCreatedAt()->format('Y-m-d H:i:s')), |
58 | $this->output->writeln(sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no')); | 59 | sprintf('Last login : %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'), |
60 | sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no'), | ||
61 | ]); | ||
59 | } | 62 | } |
60 | 63 | ||
61 | /** | 64 | /** |
@@ -69,9 +72,4 @@ class ShowUserCommand extends ContainerAwareCommand | |||
69 | { | 72 | { |
70 | return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); | 73 | return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); |
71 | } | 74 | } |
72 | |||
73 | private function getDoctrine() | ||
74 | { | ||
75 | return $this->getContainer()->get('doctrine'); | ||
76 | } | ||
77 | } | 75 | } |
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 656ac6ee..1ac7ad83 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php | |||
@@ -126,11 +126,17 @@ class ContentProxy | |||
126 | 126 | ||
127 | // is it a timestamp? | 127 | // is it a timestamp? |
128 | if (filter_var($date, FILTER_VALIDATE_INT) !== false) { | 128 | if (filter_var($date, FILTER_VALIDATE_INT) !== false) { |
129 | $date = '@' . $value; | 129 | $date = '@' . $date; |
130 | } | 130 | } |
131 | 131 | ||
132 | try { | 132 | try { |
133 | $entry->setPublishedAt(new \DateTime($date)); | 133 | // is it already a DateTime? |
134 | // (it's inside the try/catch in case of fail to be parse time string) | ||
135 | if (!$date instanceof \DateTime) { | ||
136 | $date = new \DateTime($date); | ||
137 | } | ||
138 | |||
139 | $entry->setPublishedAt($date); | ||
134 | } catch (\Exception $e) { | 140 | } catch (\Exception $e) { |
135 | $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $entry->getUrl(), 'date' => $value]); | 141 | $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $entry->getUrl(), 'date' => $value]); |
136 | } | 142 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php index 0753e318..77a7a904 100644 --- a/src/Wallabag/ImportBundle/Controller/BrowserController.php +++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php | |||
@@ -80,10 +80,10 @@ abstract class BrowserController extends Controller | |||
80 | */ | 80 | */ |
81 | abstract protected function getImportService(); | 81 | abstract protected function getImportService(); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Return the template used for the form. | 84 | * Return the template used for the form. |
85 | * | 85 | * |
86 | * @return string | 86 | * @return string |
87 | */ | 87 | */ |
88 | abstract protected function getImportTemplate(); | 88 | abstract protected function getImportTemplate(); |
89 | } | 89 | } |
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index c76be13d..2dc08be2 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -421,6 +421,16 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
421 | 421 | ||
422 | public function testPostSameEntry() | 422 | public function testPostSameEntry() |
423 | { | 423 | { |
424 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
425 | $entry = new Entry($em->getReference(User::class, 1)); | ||
426 | $entry->setUrl('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'); | ||
427 | $entry->setArchived(true); | ||
428 | $entry->addTag((new Tag())->setLabel('google')); | ||
429 | $entry->addTag((new Tag())->setLabel('apple')); | ||
430 | $em->persist($entry); | ||
431 | $em->flush(); | ||
432 | $em->clear(); | ||
433 | |||
424 | $this->client->request('POST', '/api/entries.json', [ | 434 | $this->client->request('POST', '/api/entries.json', [ |
425 | 'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', | 435 | 'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', |
426 | 'archive' => '1', | 436 | 'archive' => '1', |
@@ -1046,4 +1056,28 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
1046 | $this->assertSame(400, $this->client->getResponse()->getStatusCode()); | 1056 | $this->assertSame(400, $this->client->getResponse()->getStatusCode()); |
1047 | $this->assertContains('API limit reached', $this->client->getResponse()->getContent()); | 1057 | $this->assertContains('API limit reached', $this->client->getResponse()->getContent()); |
1048 | } | 1058 | } |
1059 | |||
1060 | public function testRePostEntryAndReUsePublishedAt() | ||
1061 | { | ||
1062 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
1063 | $entry = new Entry($em->getReference(User::class, 1)); | ||
1064 | $entry->setTitle('Antoine de Caunes : « Je veux avoir le droit de tâtonner »'); | ||
1065 | $entry->setContent('hihi'); | ||
1066 | $entry->setUrl('http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html'); | ||
1067 | $entry->setPublishedAt(new \DateTime('2017-06-26T07:46:02+0200')); | ||
1068 | $em->persist($entry); | ||
1069 | $em->flush(); | ||
1070 | $em->clear(); | ||
1071 | |||
1072 | $this->client->request('POST', '/api/entries.json', [ | ||
1073 | 'url' => 'http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html', | ||
1074 | ]); | ||
1075 | |||
1076 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
1077 | |||
1078 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
1079 | |||
1080 | $this->assertGreaterThan(0, $content['id']); | ||
1081 | $this->assertSame('http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html', $content['url']); | ||
1082 | } | ||
1049 | } | 1083 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index b1c6d53c..33bfa71e 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -1300,7 +1300,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1300 | null, | 1300 | null, |
1301 | ], | 1301 | ], |
1302 | 'es-ES' => [ | 1302 | 'es-ES' => [ |
1303 | 'http://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google', | 1303 | 'http://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google/', |
1304 | 'es_ES', | 1304 | 'es_ES', |
1305 | ], | 1305 | ], |
1306 | ]; | 1306 | ]; |