]>
Commit | Line | Data |
---|---|---|
8a4690b6 | 1 | <?php |
5bf8f3f1 | 2 | |
23634d5d | 3 | namespace Tests\Wallabag\CoreBundle\Controller; |
8a4690b6 | 4 | |
23634d5d | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
8a4690b6 NL |
6 | |
7 | class DeveloperControllerTest extends WallabagCoreTestCase | |
8 | { | |
9bf15f02 | 9 | public function testCreateClient() |
8a4690b6 NL |
10 | { |
11 | $this->logInAs('admin'); | |
12 | $client = $this->getClient(); | |
9bf15f02 JB |
13 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); |
14 | $nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); | |
8a4690b6 NL |
15 | |
16 | $crawler = $client->request('GET', '/developer/client/create'); | |
17 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
18 | ||
19 | $form = $crawler->filter('button[type=submit]')->form(); | |
20 | ||
9c545fe0 TC |
21 | $data = [ |
22 | 'client[name]' => 'My app', | |
23 | ]; | |
24 | ||
25 | $crawler = $client->submit($form, $data); | |
8a4690b6 NL |
26 | |
27 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
9bf15f02 JB |
28 | |
29 | $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); | |
30 | $this->assertGreaterThan(count($nbClients), count($newNbClients)); | |
9c545fe0 TC |
31 | |
32 | $this->assertGreaterThan(1, $alert = $crawler->filter('.settings ul li strong')->extract(['_text'])); | |
33 | $this->assertContains('My app', $alert[0]); | |
9bf15f02 JB |
34 | } |
35 | ||
36 | public function testListingClient() | |
37 | { | |
38 | $this->logInAs('admin'); | |
39 | $client = $this->getClient(); | |
40 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | |
41 | $nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); | |
42 | ||
43 | $crawler = $client->request('GET', '/developer'); | |
44 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
45 | $this->assertEquals(count($nbClients), $crawler->filter('ul[class=collapsible] li')->count()); | |
46 | } | |
47 | ||
48 | public function testDeveloperHowto() | |
49 | { | |
50 | $this->logInAs('admin'); | |
51 | $client = $this->getClient(); | |
52 | ||
53 | $crawler = $client->request('GET', '/developer/howto/first-app'); | |
54 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
55 | } | |
56 | ||
57 | public function testRemoveClient() | |
58 | { | |
59 | $this->logInAs('admin'); | |
60 | $client = $this->getClient(); | |
61 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | |
62 | $nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); | |
63 | ||
64 | $crawler = $client->request('GET', '/developer'); | |
65 | ||
66 | $link = $crawler | |
67 | ->filter('div[class=collapsible-body] p a') | |
68 | ->eq(0) | |
69 | ->link() | |
70 | ; | |
71 | ||
72 | $client->click($link); | |
73 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
74 | ||
75 | $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); | |
76 | $this->assertGreaterThan(count($newNbClients), count($nbClients)); | |
8a4690b6 NL |
77 | } |
78 | } |