continue;
}
+ // last element in the csv is the folder where the content belong
+ // BUT it can also be the status (since status = folder in Instapaper)
+ // and we don't want archive, unread & starred to become a tag
+ $tags = null;
+ if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'])) {
+ $tags = [$data[3]];
+ }
+
$entries[] = [
'url' => $data[0],
'title' => $data[1],
'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred',
'is_starred' => $data[3] === 'Starred',
'html' => false,
+ 'tags' => $tags,
];
}
fclose($handle);
// update entry with content (in case fetching failed, the given entry will be return)
$entry = $this->fetchContent($entry, $importedEntry['url'], $importedEntry);
+ if (!empty($importedEntry['tags'])) {
+ $this->tagsAssigner->assignTagsToEntry(
+ $entry,
+ $importedEntry['tags'],
+ $this->em->getUnitOfWork()->getScheduledEntityInsertions()
+ );
+ }
+
$entry->setArchived($importedEntry['is_archived']);
$entry->setStarred($importedEntry['is_starred']);
class ExportCommandTest extends WallabagCoreTestCase
{
/**
- * @expectedException Symfony\Component\Console\Exception\RuntimeException
+ * @expectedException \Symfony\Component\Console\Exception\RuntimeException
* @expectedExceptionMessage Not enough arguments (missing: "username")
*/
public function testExportCommandWithoutUsername()
class TagAllCommandTest extends WallabagCoreTestCase
{
/**
- * @expectedException Symfony\Component\Console\Exception\RuntimeException
+ * @expectedException \Symfony\Component\Console\Exception\RuntimeException
* @expectedExceptionMessage Not enough arguments (missing: "username")
*/
public function testRunTagAllCommandWithoutUsername()
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Repository\TagRepository;
use Wallabag\CoreBundle\Helper\RuleBasedTagger;
class ContentProxyTest extends \PHPUnit_Framework_TestCase
}
/**
- * @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @expectedExceptionMessage User not found
*/
public function testApplyUserNotFound()
class RedisWorkerCommandTest extends WallabagCoreTestCase
{
/**
- * @expectedException Symfony\Component\Console\Exception\RuntimeException
+ * @expectedException \Symfony\Component\Console\Exception\RuntimeException
* @expectedExceptionMessage Not enough arguments (missing: "serviceName")
*/
public function testRunRedisWorkerCommandWithoutArguments()
}
/**
- * @expectedException Symfony\Component\Config\Definition\Exception\Exception
+ * @expectedException \Symfony\Component\Config\Definition\Exception\Exception
* @expectedExceptionMessage No queue or consumer found for service name
*/
public function testRunRedisWorkerCommandWithBadService()
$crawler = $client->followRedirect();
+ $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
+ $this->assertContains('flashes.import.notice.summary', $body[0]);
+
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
$this->getLoggedInUserId()
);
- $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
- $this->assertContains('flashes.import.notice.summary', $body[0]);
-
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok');
+ $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag');
$this->assertEquals(1, count($content->getTags()));
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
+
+ $content = $client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findByUrlAndUserId(
+ 'http://www.20minutes.fr/high-tech/2077615-20170531-dis-donc-donald-trump-quoi-exactement-covfefe',
+ $this->getLoggedInUserId()
+ );
+
+ $this->assertContains('foot', $content->getTags());
+ $this->assertContains('test_tag', $content->getTags());
+
+ $this->assertEquals(2, count($content->getTags()));
}
public function testImportInstapaperWithFileAndMarkAllAsRead()
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://ma.ttias.be is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok');
- $this->assertEquals(3, count($content->getTags()));
+
+ $tags = $content->getTags();
+ $this->assertContains('foot', $tags, 'It includes the "foot" tag');
+ $this->assertContains('varnish', $tags, 'It includes the "varnish" tag');
+ $this->assertContains('PHP', $tags, 'It includes the "PHP" tag');
+ $this->assertEquals(3, count($tags));
+
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
$this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d'));
}
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok');
- $this->assertEquals(1, count($content->getTags()));
+
+ $tags = $content->getTags();
+ $this->assertContains('foot', $tags, 'It includes the "foot" tag');
+ $this->assertEquals(1, count($tags));
+
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
$this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
}
$this->getLoggedInUserId()
);
- $tag = $client->getContainer()
- ->get('doctrine.orm.entity_manager')
- ->getRepository('WallabagCoreBundle:Tag')
- ->findOneByLabel('Framabag');
-
- $this->assertTrue($content->getTags()->contains($tag));
-
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok');
- $this->assertEquals(2, count($content->getTags()));
+
+ $tags = $content->getTags();
+ $this->assertContains('foot', $tags, 'It includes the "foot" tag');
+ $this->assertContains('Framabag', $tags, 'It includes the "Framabag" tag');
+ $this->assertEquals(2, count($tags));
+
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
}
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok');
- $this->assertEquals(1, count($content->getTags()));
+
+ $tags = $content->getTags();
+ $this->assertContains('foot', $tags, 'It includes the "foot" tag');
+ $this->assertEquals(1, count($tags));
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok');
- $this->assertEquals(3, count($content->getTags()));
+
+ $tags = $content->getTags();
+ $this->assertContains('foot', $tags, 'It includes the "foot" tag');
+ $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag');
+ $this->assertContains('blog', $tags, 'It includes the "blog" tag');
+ $this->assertEquals(3, count($tags));
+
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
$this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
$this->assertTrue($content->isStarred(), 'Entry is starred');
protected $logHandler;
protected $contentProxy;
protected $tagsAssigner;
+ protected $uow;
private function getInstapaperImport($unsetUser = false, $dispatched = 0)
{
->disableOriginalConstructor()
->getMock();
+ $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->em
+ ->expects($this->any())
+ ->method('getUnitOfWork')
+ ->willReturn($this->uow);
+
+ $this->uow
+ ->expects($this->any())
+ ->method('getScheduledEntityInsertions')
+ ->willReturn([]);
+
$this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
->disableOriginalConstructor()
->getMock();
public function testImport()
{
- $instapaperImport = $this->getInstapaperImport(false, 3);
+ $instapaperImport = $this->getInstapaperImport(false, 4);
$instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
->getMock();
- $entryRepo->expects($this->exactly(3))
+ $entryRepo->expects($this->exactly(4))
->method('findByUrlAndUserId')
->willReturn(false);
->getMock();
$this->contentProxy
- ->expects($this->exactly(3))
+ ->expects($this->exactly(4))
->method('updateEntry')
->willReturn($entry);
$res = $instapaperImport->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $instapaperImport->getSummary());
+ $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $instapaperImport->getSummary());
}
public function testImportAndMarkAllAsRead()
->disableOriginalConstructor()
->getMock();
- $entryRepo->expects($this->exactly(3))
+ $entryRepo->expects($this->exactly(4))
->method('findByUrlAndUserId')
- ->will($this->onConsecutiveCalls(false, true, true));
+ ->will($this->onConsecutiveCalls(false, true, true, true));
$this->em
->expects($this->any())
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 2, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary());
+ $this->assertEquals(['skipped' => 3, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary());
}
public function testImportWithRabbit()
->getMock();
$producer
- ->expects($this->exactly(3))
+ ->expects($this->exactly(4))
->method('publish');
$instapaperImport->setProducer($producer);
$res = $instapaperImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $instapaperImport->getSummary());
+ $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
}
public function testImportWithRedis()
$res = $instapaperImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $instapaperImport->getSummary());
+ $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
$this->assertNotEmpty($redisMock->lpop('instapaper'));
}
http://www.liberation.fr/societe/2012/12/06/baumettes-un-tour-en-cellule_865551,Baumettes : un tour en cellule,,Unread
https://redditblog.com/2016/09/20/amp-and-reactredux/,AMP and React+Redux: Why Not?,,Archive
https://medium.com/@the_minh/why-foursquare-swarm-is-still-my-favourite-social-network-e38228493e6c,Why Foursquare / Swarm is still my favourite social network,,Starred
+http://www.20minutes.fr/high-tech/2077615-20170531-dis-donc-donald-trump-quoi-exactement-covfefe,"Dis donc Donald Trump, c'est quoi exactement «covfefe»?",,test_tag