| @@ 39-47 (lines=9) @@ | ||
| 36 | $this->assertContains('1', $crawler->filter('.widget .tag-list a .badge')->eq(1)->text()); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function testShowArticle() |
|
| 40 | { |
|
| 41 | $client = static::createClient(); |
|
| 42 | ||
| 43 | $crawler = $client->request('GET', '/article/test_title'); |
|
| 44 | ||
| 45 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 46 | $this->assertContains('Test title', $crawler->filter('h2 a')->text()); |
|
| 47 | } |
|
| 48 | ||
| 49 | public function testSortAuthor() |
|
| 50 | { |
|
| @@ 49-57 (lines=9) @@ | ||
| 46 | $this->assertContains('Test title', $crawler->filter('h2 a')->text()); |
|
| 47 | } |
|
| 48 | ||
| 49 | public function testSortAuthor() |
|
| 50 | { |
|
| 51 | $client = static::createClient(); |
|
| 52 | ||
| 53 | $crawler = $client->request('GET', '/author/user_name'); |
|
| 54 | ||
| 55 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 56 | $this->assertContains('Test title', $crawler->filter('h2 a')->text()); |
|
| 57 | } |
|
| 58 | ||
| 59 | public function testSortCategory() |
|
| 60 | { |
|
| @@ 59-67 (lines=9) @@ | ||
| 56 | $this->assertContains('Test title', $crawler->filter('h2 a')->text()); |
|
| 57 | } |
|
| 58 | ||
| 59 | public function testSortCategory() |
|
| 60 | { |
|
| 61 | $client = static::createClient(); |
|
| 62 | ||
| 63 | $crawler = $client->request('GET', '/category/test_category'); |
|
| 64 | ||
| 65 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 66 | $this->assertContains('Test title', $crawler->filter('h2 a')->text()); |
|
| 67 | } |
|
| 68 | ||
| 69 | public function testSortTags() |
|
| 70 | { |
|
| @@ 69-77 (lines=9) @@ | ||
| 66 | $this->assertContains('Test title', $crawler->filter('h2 a')->text()); |
|
| 67 | } |
|
| 68 | ||
| 69 | public function testSortTags() |
|
| 70 | { |
|
| 71 | $client = static::createClient(); |
|
| 72 | ||
| 73 | $crawler = $client->request('GET', '/tag/news'); |
|
| 74 | ||
| 75 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 76 | $this->assertContains('Test title', $crawler->filter('h2 a')->text()); |
|
| 77 | } |
|
| 78 | ||
| 79 | public function testFormComment() |
|
| 80 | { |
|
| @@ 105-113 (lines=9) @@ | ||
| 102 | $this->assertContains('Text comment', $crawler->filter('.media-body p')->text()); |
|
| 103 | } |
|
| 104 | ||
| 105 | public function testSuccess() |
|
| 106 | { |
|
| 107 | $client = static::createClient(); |
|
| 108 | ||
| 109 | $crawler = $client->request('GET', '/success'); |
|
| 110 | ||
| 111 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 112 | $this->assertContains('Your data successfully saved.', $crawler->filter('.alert')->text()); |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||
| @@ 9-17 (lines=9) @@ | ||
| 6 | ||
| 7 | class DefaultControllerTest extends WebTestCase |
|
| 8 | { |
|
| 9 | public function testIndex() |
|
| 10 | { |
|
| 11 | $client = static::createClient(); |
|
| 12 | ||
| 13 | $crawler = $client->request('GET', '/helloSymfony'); |
|
| 14 | ||
| 15 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 16 | $this->assertContains('Welcome to Symfony', $crawler->filter('#container h1')->text()); |
|
| 17 | } |
|
| 18 | } |
|
| 19 | ||
| @@ 15-22 (lines=8) @@ | ||
| 12 | ||
| 13 | class AdminControllerTest extends WebTestCase |
|
| 14 | { |
|
| 15 | public function testIndex(){ |
|
| 16 | $client = static::createClient(); |
|
| 17 | ||
| 18 | $crawler = $client->request('GET', '/admin/'); |
|
| 19 | ||
| 20 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 21 | $this->assertContains('Statistic', $crawler->filter('h2')->text()); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function testArticles(){ |
|
| 25 | $client = static::createClient(); |
|
| @@ 64-72 (lines=9) @@ | ||
| 61 | $this->assertEquals(2, $crawler->filter('tr')->count()); |
|
| 62 | } |
|
| 63 | ||
| 64 | public function testUsersDelete(){ |
|
| 65 | $client = static::createClient(); |
|
| 66 | ||
| 67 | $crawler = $client->request('GET', '/admin/user/delete/1'); |
|
| 68 | ||
| 69 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 70 | $this->assertContains('You want to delete user "User name" (id: 1). Related records: articles (count: 1), comments (count: 1). You must to delete related records before.', |
|
| 71 | $crawler->filter('.alert')->text()); |
|
| 72 | } |
|
| 73 | ||
| 74 | public function testRoles(){ |
|
| 75 | $client = static::createClient(); |
|
| @@ 84-92 (lines=9) @@ | ||
| 81 | $this->assertEquals(2, $crawler->filter('tr')->count()); |
|
| 82 | } |
|
| 83 | ||
| 84 | public function testRolesDelete(){ |
|
| 85 | $client = static::createClient(); |
|
| 86 | ||
| 87 | $crawler = $client->request('GET', '/admin/role/delete/1'); |
|
| 88 | ||
| 89 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
| 90 | $this->assertContains('You want to delete role "admin" (id: 1). Related records: users (count: 1). You must to delete related records before.', |
|
| 91 | $crawler->filter('.alert')->text()); |
|
| 92 | } |
|
| 93 | } |
|