Skip to content

Commit

Permalink
Merge pull request wallabag#7577 from wallabag/fix/tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
j0k3r authored Jul 15, 2024
2 parents 85585e1 + d5d6b68 commit 89252f3
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 66 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions tests/Controller/Api/EntryRestControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public function testDeleteEntryExpectBadRequest()
public function testPostEntry()
{
$this->client->request('POST', '/api/entries.json', [
'url' => 'https://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',
'url' => 'https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment',
'tags' => 'google',
'title' => 'New title for my article',
'content' => 'my content',
Expand All @@ -574,7 +574,7 @@ public function testPostEntry()
$content = json_decode($this->client->getResponse()->getContent(), true);

$this->assertGreaterThan(0, $content['id']);
$this->assertSame('https://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', $content['url']);
$this->assertSame('https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment', $content['url']);
$this->assertSame(0, $content['is_archived']);
$this->assertSame(0, $content['is_starred']);
$this->assertNull($content['starred_at']);
Expand All @@ -596,7 +596,7 @@ public function testPostSameEntry()
{
$em = $this->client->getContainer()->get(EntityManagerInterface::class);
$entry = new Entry($em->getReference(User::class, $this->getUserId()));
$entry->setUrl('https://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');
$entry->setUrl('https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment');
$entry->setArchived(true);
$entry->addTag((new Tag())->setLabel('google'));
$entry->addTag((new Tag())->setLabel('apple'));
Expand All @@ -605,7 +605,7 @@ public function testPostSameEntry()
$em->clear();

$this->client->request('POST', '/api/entries.json', [
'url' => 'https://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',
'url' => 'https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment',
'archive' => '1',
'tags' => 'google, apple',
]);
Expand All @@ -615,7 +615,7 @@ public function testPostSameEntry()
$content = json_decode($this->client->getResponse()->getContent(), true);

$this->assertGreaterThan(0, $content['id']);
$this->assertSame('https://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', $content['url']);
$this->assertSame('https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment', $content['url']);
$this->assertSame(1, $content['is_archived']);
$this->assertSame(0, $content['is_starred']);
$this->assertCount(3, $content['tags']);
Expand Down Expand Up @@ -699,7 +699,7 @@ public function testPostArchivedAndStarredEntryWithoutQuotes()
public function testPostEntryWithOriginUrl()
{
$this->client->request('POST', '/api/entries.json', [
'url' => 'https://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',
'url' => 'https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment',
'tags' => 'google',
'title' => 'New title for my article',
'content' => 'my content',
Expand All @@ -715,7 +715,7 @@ public function testPostEntryWithOriginUrl()
$content = json_decode($this->client->getResponse()->getContent(), true);

$this->assertGreaterThan(0, $content['id']);
$this->assertSame('https://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', $content['url']);
$this->assertSame('https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment', $content['url']);
$this->assertSame('http://mysource.tld', $content['origin_url']);
}

Expand Down Expand Up @@ -1223,7 +1223,7 @@ public function testReloadEntryErrorWhileFetching()
public function testReloadEntry()
{
$this->client->request('POST', '/api/entries.json', [
'url' => 'https://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',
'url' => 'https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment',
'archive' => '1',
'tags' => 'google, apple',
]);
Expand Down
10 changes: 5 additions & 5 deletions tests/Controller/EntryControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

class EntryControllerTest extends WallabagTestCase
{
public const AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'https://www.lemonde.fr/judo/article/2017/11/11/judo-la-decima-de-teddy-riner_5213605_1556020.html';
public const AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment';
public $downloadImagesEnabled = false;
public $url = 'https://www.lemonde.fr/pixels/article/2019/06/18/ce-qu-il-faut-savoir-sur-le-libra-la-cryptomonnaie-de-facebook_5477887_4408996.html';
public $url = 'https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment';
private $entryDataTestAttribute = '[data-test="entry"]';

/**
Expand Down Expand Up @@ -175,9 +175,9 @@ public function testPostNewOk()

$this->assertInstanceOf(Entry::class, $content);
$this->assertSame($this->url, $content->getUrl());
$this->assertStringContainsString('la cryptomonnaie de Facebook', $content->getTitle());
$this->assertStringContainsString('Comment Hidalgo', $content->getTitle());
$this->assertSame('fr', $content->getLanguage());
$this->assertArrayHasKey('x-frame-options', $content->getHeaders());
$this->assertArrayHasKey('cache-control', $content->getHeaders());
$client->getContainer()->get(Config::class)->set('store_article_headers', 0);
}

Expand Down Expand Up @@ -1246,7 +1246,7 @@ public function testNewEntryWithDownloadImagesEnabled()

$this->assertInstanceOf(Entry::class, $entry);
$this->assertSame($url, $entry->getUrl());
$this->assertStringContainsString('Judo', $entry->getTitle());
$this->assertStringContainsString('Comment Hidalgo', $entry->getTitle());
// instead of checking for the filename (which might change) check that the image is now local
$this->assertStringContainsString(rtrim($client->getContainer()->getParameter('domain_name'), '/') . '/assets/images/', $entry->getContent());

Expand Down
17 changes: 0 additions & 17 deletions tests/Controller/Import/FirefoxControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,6 @@ public function testImportWallabagWithFirefoxFile()
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for 20minutes.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for 20minutes.fr is ok');
$this->assertCount(3, $content->getTags());

$content = $client->getContainer()
->get(EntityManagerInterface::class)
->getRepository(Entry::class)
->findByUrlAndUserId(
'https://www.lemonde.fr/disparitions/article/2018/07/05/le-journaliste-et-cineaste-claude-lanzmann-est-mort_5326313_3382.html',
$this->getLoggedInUserId()
);

$this->assertInstanceOf(Entry::class, $content);
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.lemonde.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.lemonde.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://www.lemonde.fr is ok');

$createdAt = $content->getCreatedAt();
$this->assertSame('2013', $createdAt->format('Y'));
$this->assertSame('12', $createdAt->format('m'));
}

public function testImportWallabagWithEmptyFile()
Expand Down
13 changes: 0 additions & 13 deletions tests/Controller/Import/PocketHtmlControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,6 @@ public function testImportWallabagWithPocketHtmlFile()
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for 20minutes.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for 20minutes.fr is ok');
$this->assertCount(3, $content->getTags());

$content = $client->getContainer()
->get(EntityManagerInterface::class)
->getRepository(Entry::class)
->findByUrlAndUserId(
'https://www.lemonde.fr/disparitions/article/2018/07/05/le-journaliste-et-cineaste-claude-lanzmann-est-mort_5326313_3382.html',
$this->getLoggedInUserId()
);

$this->assertInstanceOf(Entry::class, $content);
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.lemonde.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.lemonde.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://www.lemonde.fr is ok');
}

public function testImportWallabagWithEmptyFile()
Expand Down
13 changes: 0 additions & 13 deletions tests/Controller/Import/ShaarliControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,6 @@ public function testImportWallabagWithShaarliFile()
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for 20minutes.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for 20minutes.fr is ok');
$this->assertCount(2, $content->getTags());

$content = $client->getContainer()
->get(EntityManagerInterface::class)
->getRepository(Entry::class)
->findByUrlAndUserId(
'https://www.lemonde.fr/disparitions/article/2018/07/05/le-journaliste-et-cineaste-claude-lanzmann-est-mort_5326313_3382.html',
$this->getLoggedInUserId()
);

$this->assertInstanceOf(Entry::class, $content);
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.lemonde.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.lemonde.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for https://www.lemonde.fr is ok');
}

public function testImportWallabagWithEmptyFile()
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/Import/firefox-bookmarks.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
},
{
"guid": "E385l9vZ_LVn",
"title": "Le journaliste et cinéaste Claude Lanzmann est mort",
"title": "JO Paris 2024 : Où courir dans la capitale maintenant que les quais sont fermés ?",
"index": 1,
"dateAdded": 1388166091544000,
"lastModified": 1388166091545000,
"id": 5,
"type": "text/x-moz-place",
"uri": "https://www.lemonde.fr/disparitions/article/2018/07/05/le-journaliste-et-cineaste-claude-lanzmann-est-mort_5326313_3382.html"
"uri": "https://www.20minutes.fr/paris/4100740-20240715-jo-paris-2024-courir-capitale-maintenant-quais-fermes"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/Import/ril_export.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<h1>Unread</h1>
<ul>
<li><a href="https://www.20minutes.fr/sport/4002755-20220928-tarn-lapins-ravagent-terrain-match-rugby-doit-etre-annule" time_added="1688628695" tags="ifttt,new_entry_simple">Tarn : Des lapins ravagent le terrain, le match de rugby doit être annulé</a></li>
<li><a href="https://www.lemonde.fr/disparitions/article/2018/07/05/le-journaliste-et-cineaste-claude-lanzmann-est-mort_5326313_3382.html" time_added="1688627412" tags="ifttt,new_entry_simple">Le journaliste et cinéaste Claude Lanzmann est mort</a></li>
<li><a href="https://www.20minutes.fr/paris/4100740-20240715-jo-paris-2024-courir-capitale-maintenant-quais-fermes" time_added="1688627412" tags="ifttt,new_entry_simple">JO Paris 2024 : Où courir dans la capitale maintenant que les quais sont fermés ?</a></li>

</ul>

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/Import/shaarli-bookmarks.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 89252f3

Please sign in to comment.