mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Merge remote-tracking branch 'origin/master' into 2.2
This commit is contained in:
commit
e4cf672ccf
74 changed files with 1595 additions and 1519 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Wallabag\CoreBundle\Controller;
|
||||
namespace Tests\Wallabag\ApiBundle\Controller;
|
||||
|
||||
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
|
||||
|
||||
|
@ -33,6 +33,32 @@ class DeveloperControllerTest extends WallabagCoreTestCase
|
|||
$this->assertContains('My app', $alert[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreateClient
|
||||
*/
|
||||
public function testCreateToken()
|
||||
{
|
||||
$client = $this->getClient();
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$apiClient = $em->getRepository('WallabagApiBundle:Client')->findOneByName('My app');
|
||||
|
||||
$client->request('POST', '/oauth/v2/token', [
|
||||
'grant_type' => 'password',
|
||||
'client_id' => $apiClient->getPublicId(),
|
||||
'client_secret' => $apiClient->getSecret(),
|
||||
'username' => 'admin',
|
||||
'password' => 'mypassword',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
|
||||
$data = json_decode($client->getResponse()->getContent(), true);
|
||||
$this->assertArrayHasKey('access_token', $data);
|
||||
$this->assertArrayHasKey('expires_in', $data);
|
||||
$this->assertArrayHasKey('token_type', $data);
|
||||
$this->assertArrayHasKey('refresh_token', $data);
|
||||
}
|
||||
|
||||
public function testListingClient()
|
||||
{
|
||||
$this->logInAs('admin');
|
|
@ -561,6 +561,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
|||
*/
|
||||
public function testDeleteUserTag($tag)
|
||||
{
|
||||
$tagName = $tag['label'];
|
||||
|
||||
$this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json');
|
||||
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||
|
@ -577,6 +579,13 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
|||
->findAllByTagId($this->user->getId(), $tag['id']);
|
||||
|
||||
$this->assertCount(0, $entries);
|
||||
|
||||
$tag = $this->client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Tag')
|
||||
->findOneByLabel($tagName);
|
||||
|
||||
$this->assertNull($tag, $tagName.' was removed because it begun an orphan tag');
|
||||
}
|
||||
|
||||
public function testDeleteTagByLabel()
|
||||
|
@ -794,6 +803,22 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
|||
$this->assertEquals(true, $content['exists']);
|
||||
}
|
||||
|
||||
public function testGetEntriesExistsWithManyUrls()
|
||||
{
|
||||
$url1 = 'http://0.0.0.0/entry2';
|
||||
$url2 = 'http://0.0.0.0/entry10';
|
||||
$this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2);
|
||||
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertArrayHasKey($url1, $content);
|
||||
$this->assertArrayHasKey($url2, $content);
|
||||
$this->assertEquals(true, $content[$url1]);
|
||||
$this->assertEquals(false, $content[$url2]);
|
||||
}
|
||||
|
||||
public function testGetEntriesExistsWhichDoesNotExists()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2');
|
||||
|
|
|
@ -341,22 +341,23 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
$em = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
$content = $em
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
|
||||
|
||||
// empty content
|
||||
$content->setContent('');
|
||||
$client->getContainer()->get('doctrine.orm.entity_manager')->persist($content);
|
||||
$client->getContainer()->get('doctrine.orm.entity_manager')->flush();
|
||||
$em->persist($content);
|
||||
$em->flush();
|
||||
|
||||
$client->request('GET', '/reload/'.$content->getId());
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
|
||||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
$content = $em
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
|
||||
|
||||
|
@ -486,9 +487,11 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$em = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
// add a new content to be removed later
|
||||
$user = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->findOneByUserName('admin');
|
||||
|
||||
|
@ -502,12 +505,8 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$content->setArchived(true);
|
||||
$content->setLanguage('fr');
|
||||
|
||||
$client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->persist($content);
|
||||
$client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->flush();
|
||||
$em->persist($content);
|
||||
$em->flush();
|
||||
|
||||
$client->request('GET', '/view/'.$content->getId());
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
|
||||
class TagControllerTest extends WallabagCoreTestCase
|
||||
{
|
||||
|
@ -134,36 +135,48 @@ class TagControllerTest extends WallabagCoreTestCase
|
|||
$client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
|
||||
|
||||
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
||||
|
||||
$tag = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Tag')
|
||||
->findOneByLabel($this->tagName);
|
||||
|
||||
$this->assertNull($tag, $this->tagName.' was removed because it begun an orphan tag');
|
||||
}
|
||||
|
||||
public function testShowEntriesForTagAction()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
$em = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
$tag = new Tag();
|
||||
$tag->setLabel($this->tagName);
|
||||
|
||||
$entry = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getLoggedInUserId());
|
||||
|
||||
$tag = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Tag')
|
||||
->findOneByEntryAndTagLabel($entry, 'foo');
|
||||
$tag->addEntry($entry);
|
||||
|
||||
$crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
$this->assertCount(2, $crawler->filter('div[class=entry]'));
|
||||
$em->persist($entry);
|
||||
$em->persist($tag);
|
||||
$em->flush();
|
||||
|
||||
$tag = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Tag')
|
||||
->findOneByLabel('baz');
|
||||
->findOneByEntryAndTagLabel($entry, $this->tagName);
|
||||
|
||||
$crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(1, $crawler->filter('[id*="entry-"]'));
|
||||
|
||||
$entry->removeTag($tag);
|
||||
$em->remove($tag);
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,9 +90,7 @@ abstract class WallabagCoreTestCase extends WebTestCase
|
|||
try {
|
||||
$this->client->getContainer()->get('wallabag_core.redis.client')->connect();
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped(
|
||||
'Redis is not installed/activated'
|
||||
);
|
||||
$this->markTestSkipped('Redis is not installed/activated');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
|
|||
|
||||
public function testImportChromeWithRedisEnabled()
|
||||
{
|
||||
$this->checkRedis();
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
$client->getContainer()->get('craue_config')->set('import_with_redis', 1);
|
||||
|
|
|
@ -54,6 +54,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
|
|||
|
||||
public function testImportFirefoxWithRedisEnabled()
|
||||
{
|
||||
$this->checkRedis();
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
$client->getContainer()->get('craue_config')->set('import_with_redis', 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue