PowerKiKi /
mqueue
| 1 | <?php |
||
| 2 | |||
| 3 | namespace mQueueTest\Controller; |
||
| 4 | |||
| 5 | abstract class AbstractControllerTestCase extends \Zend_Test_PHPUnit_ControllerTestCase |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var \mQueue\Model\User |
||
| 9 | */ |
||
| 10 | protected $testUser; |
||
| 11 | protected $userData = [ |
||
| 12 | 'nickname' => 'test user', |
||
| 13 | 'email' => '[email protected]', |
||
| 14 | 'password' => 'superpassword', |
||
| 15 | ]; |
||
| 16 | protected $movieData = [ |
||
| 17 | 'id' => '0096446', |
||
| 18 | 'title' => 'Willow (1988)', |
||
| 19 | ]; |
||
| 20 | |||
| 21 | public function setUp(): void |
||
| 22 | { |
||
| 23 | $this->bootstrap = new \Zend_Application( |
||
| 24 | APPLICATION_ENV, [ |
||
| 25 | 'config' => [ |
||
| 26 | APPLICATION_PATH . '/configs/application.ini', |
||
| 27 | ], |
||
| 28 | ] |
||
| 29 | ); |
||
| 30 | |||
| 31 | $this->testUser = \mQueue\Model\UserMapper::findEmailPassword($this->userData['email'], $this->userData['password']); |
||
| 32 | if (!$this->testUser) { |
||
| 33 | $this->testUser = \mQueue\Model\UserMapper::insertUser($this->userData); |
||
| 34 | } |
||
| 35 | |||
| 36 | $movie = \mQueue\Model\MovieMapper::find($this->movieData['id']); |
||
| 37 | if (!$movie) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 38 | \mQueue\Model\MovieMapper::getDbTable()->createRow($this->movieData)->save(); |
||
| 39 | } |
||
| 40 | |||
| 41 | parent::setUp(); |
||
| 42 | } |
||
| 43 | |||
| 44 | public function loginUser($login, $password): void |
||
| 45 | { |
||
| 46 | $this->request->setMethod('POST') |
||
|
0 ignored issues
–
show
The property
request does not exist on mQueueTest\Controller\AbstractControllerTestCase. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 47 | ->setPost([ |
||
| 48 | 'login' => $login, |
||
| 49 | 'password' => $password, |
||
| 50 | ]); |
||
| 51 | $this->dispatch('/user/login'); |
||
| 52 | |||
| 53 | $this->resetRequest() |
||
| 54 | ->resetResponse(); |
||
| 55 | |||
| 56 | $this->request->setPost([]); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Assert against plain text search; content should contain needle |
||
| 61 | * |
||
| 62 | * @param string $needle needle that should be contained in content |
||
| 63 | * @param string $message |
||
| 64 | */ |
||
| 65 | public function assertContentContains($needle, $message = ''): void |
||
| 66 | { |
||
| 67 | $this->_incrementAssertionCount(); |
||
| 68 | $content = $this->response->outputBody(); |
||
|
0 ignored issues
–
show
The property
response does not exist on mQueueTest\Controller\AbstractControllerTestCase. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 69 | if (mb_strpos($content, $needle) === false) { |
||
| 70 | $failure = sprintf('Failed asserting needle DENOTED BY %s DOES NOT EXIST', $needle); |
||
| 71 | if (!empty($message)) { |
||
| 72 | $failure = $message . "\n" . $failure; |
||
| 73 | } |
||
| 74 | |||
| 75 | throw new \Zend_Test_PHPUnit_Constraint_Exception($failure); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 |