mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Added tests
This commit is contained in:
parent
f052f1fd57
commit
65cd8a4a9a
3 changed files with 78 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
|
||||
class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
@ -896,4 +897,68 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
|
||||
}
|
||||
|
||||
public function testRedirectToHomepage()
|
||||
{
|
||||
$this->logInAs('empty');
|
||||
$client = $this->getClient();
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->find($this->getLoggedInUserId());
|
||||
|
||||
if (!$user) {
|
||||
$this->markTestSkipped('No user found in db.');
|
||||
}
|
||||
|
||||
// Redirect to homepage
|
||||
$config = $user->getConfig();
|
||||
$config->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
|
||||
$em->persist($config);
|
||||
$em->flush();
|
||||
|
||||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
|
||||
|
||||
$client->request('GET', '/view/'.$content->getId());
|
||||
$client->request('GET', '/archive/'.$content->getId());
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
$this->assertEquals('/', $client->getResponse()->headers->get('location'));
|
||||
}
|
||||
|
||||
public function testRedirectToCurrentPage()
|
||||
{
|
||||
$this->logInAs('empty');
|
||||
$client = $this->getClient();
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $em
|
||||
->getRepository('WallabagUserBundle:User')
|
||||
->find($this->getLoggedInUserId());
|
||||
|
||||
if (!$user) {
|
||||
$this->markTestSkipped('No user found in db.');
|
||||
}
|
||||
|
||||
// Redirect to current page
|
||||
$config = $user->getConfig();
|
||||
$config->setActionMarkAsRead(Config::REDIRECT_TO_CURRENT_PAGE);
|
||||
$em->persist($config);
|
||||
$em->flush();
|
||||
|
||||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
|
||||
|
||||
$client->request('GET', '/view/'.$content->getId());
|
||||
$client->request('GET', '/archive/'.$content->getId());
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
$this->assertContains('/view/'.$content->getId(), $client->getResponse()->headers->get('location'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue