|
| 1 | +<?php |
| 2 | + |
| 3 | +class LocationRatingTest extends TestCase |
| 4 | +{ |
| 5 | + protected function setUp() |
| 6 | + { |
| 7 | + parent::setUp(); |
| 8 | + $this->flushSession(); |
| 9 | + $data = ['email' => 'josh.greig2@gmail.com', 'password' => 'password']; |
| 10 | + $response = $this->post('/signin', $data); |
| 11 | + } |
| 12 | + |
| 13 | + private function checkLocationRatingContent($content) |
| 14 | + { |
| 15 | + $this->assertTrue(strpos($content, 'Tim Hortons') !== false); |
| 16 | + $this->assertTrue(strpos($content, 'Rate') !== false); |
| 17 | + $this->assertTrue(strpos($content, 'View') !== false); |
| 18 | + $this->assertTrue(strpos($content, 'Are there picture-based symbols for information and signage?') !== false); |
| 19 | + $this->assertTrue(strpos($content, 'question-explanation-link') !== false); |
| 20 | + } |
| 21 | + |
| 22 | + public function testGetAmenityReporting() |
| 23 | + { |
| 24 | + $response = $this->get('/location-reporting/00000000-0000-0000-0000-000000000001/6'); |
| 25 | + $this->assertEquals(200, $response->getStatusCode()); |
| 26 | + $content = $response->getContent(); |
| 27 | + $this->checkLocationRatingContent($content); |
| 28 | + } |
| 29 | + |
| 30 | + public function testGetAmenityRating() |
| 31 | + { |
| 32 | + $response = $this->get('/location/rating/00000000-0000-0000-0000-000000000001/6'); |
| 33 | + $this->assertEquals(200, $response->getStatusCode()); |
| 34 | + $content = $response->getContent(); |
| 35 | + $this->checkLocationRatingContent($content); |
| 36 | + } |
| 37 | + |
| 38 | + public function testSetComment() |
| 39 | + { |
| 40 | + srand(time()); |
| 41 | + $data = [ |
| 42 | + 'question_category_id' => 6, |
| 43 | + 'location_id' => '00000000-0000-0000-0000-000000000001', |
| 44 | + 'comment' => 'Hello World'.rand() |
| 45 | + ]; |
| 46 | + $response = $this->put('location/rating/comment', $data); |
| 47 | + $this->assertEquals(200, $response->getStatusCode()); |
| 48 | + $response = $this->get('/location/rating/00000000-0000-0000-0000-000000000001/6'); |
| 49 | + $content = $response->getContent(); |
| 50 | + // The recently set comment should appear in the HTML content. |
| 51 | + $this->assertTrue(strpos($content, $data['comment']) !== false); |
| 52 | + |
| 53 | + // There should be no problem setting the comment to an empty string. |
| 54 | + // This is how the user clears his comment. |
| 55 | + $data['comment'] = ''; |
| 56 | + $response = $this->put('location/rating/comment', $data); |
| 57 | + $this->assertEquals(200, $response->getStatusCode()); |
| 58 | + } |
| 59 | +} |
0 commit comments