mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-22 17:18:37 +00:00
Add a live test for restricted article
It is not aimed to test if we can get the full article (since we aren't using real login/password)
but mostly to test the full work (with authentication, etc.)
Do not clean fixtured to avoid SQLite to re-use id for entry tag relation 😓
This commit is contained in:
parent
fd7fde9515
commit
9de9f1e5ce
5 changed files with 81 additions and 31 deletions
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace Tests\Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Client;
|
||||
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
|
||||
use Wallabag\CoreBundle\Entity\SiteCredential;
|
||||
|
||||
class SiteCredentialControllerTest extends WallabagCoreTestCase
|
||||
{
|
||||
|
@ -52,18 +54,12 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
|
|||
$this->assertContains('flashes.site_credential.notice.added', $crawler->filter('body')->extract(['_text'])[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNewSiteCredential
|
||||
*/
|
||||
public function testEditSiteCredential()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$credential = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:SiteCredential')
|
||||
->findOneByHost('google.io');
|
||||
$credential = $this->createSiteCredential($client);
|
||||
|
||||
$crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
|
||||
|
||||
|
@ -92,36 +88,26 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
|
|||
$this->assertContains('larry', $crawler->filter('input[id=site_credential_username]')->attr('value'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNewSiteCredential
|
||||
*/
|
||||
public function testEditFromADifferentUserSiteCredential()
|
||||
{
|
||||
$this->logInAs('bob');
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$credential = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:SiteCredential')
|
||||
->findOneByHost('google.io');
|
||||
$credential = $this->createSiteCredential($client);
|
||||
|
||||
$this->logInAs('bob');
|
||||
|
||||
$client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
|
||||
|
||||
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNewSiteCredential
|
||||
*/
|
||||
public function testDeleteSiteCredential()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$credential = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:SiteCredential')
|
||||
->findOneByHost('google.io');
|
||||
$credential = $this->createSiteCredential($client);
|
||||
|
||||
$crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
|
||||
|
||||
|
@ -137,4 +123,18 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$this->assertContains('flashes.site_credential.notice.deleted', $crawler->filter('body')->extract(['_text'])[0]);
|
||||
}
|
||||
|
||||
private function createSiteCredential(Client $client)
|
||||
{
|
||||
$credential = new SiteCredential($this->getLoggedInUser());
|
||||
$credential->setHost('google.io');
|
||||
$credential->setUsername('sergei');
|
||||
$credential->setPassword('microsoft');
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$em->persist($credential);
|
||||
$em->flush();
|
||||
|
||||
return $credential;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue