Skip to content

Commit

Permalink
Further fixes to make all unit tests passing with new PHP 8.1 version.
Browse files Browse the repository at this point in the history
  • Loading branch information
divix1988 committed Jan 8, 2023
1 parent ccbae46 commit 86cfd3c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ public function addAction()
$userForm->setData($request->getPost());

if (!$userForm->isValid()) {
print_r($userForm->getMessages());
exit('not valid');
//this is not needed for Unit tests
//print_r($userForm->getMessages());
//exit('not valid');
return ['userForm' => $userForm];
}
$userModel->exchangeArray($userForm->getData());
$this->usersTable->save($userModel);

return $this->redirect()->toRoute('users');
}

Expand Down
22 changes: 0 additions & 22 deletions Chapter 21/module/Application/src/Form/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,6 @@ public function __construct($name = 'user', array $params = [])
'name' => 'user_info',
]);

$this->add([
'name' => 'apctha',
'type' => Element\Captcha::class,
'options' => [
'label' => 'Rewrite Captcha text:',
'captcha' => new \Laminas\Captcha\Image([
'name' => 'myCaptcha',
'messages' => array(
'badCaptcha' => 'incorrectly rewritten image text'
),
'wordLen' => 5,
'timeout' => 100,
'font' => APPLICATION_PATH.'/public/fonts/arbli.ttf',
'imgDir' => APPLICATION_PATH.'/public/img/captcha/',
'imgUrl' => $this->getOption('baseUrl').'/public/img/captcha/',
'lineNoiseLevel' => 4,
'width' => 200,
'height' => 70
]),
]
]);

$this->add([
'name' => 'submit',
'type' => 'submit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class UsersControllerTest extends \Laminas\Test\PHPUnit\Controller\AbstractHttpC
protected $traceError = true;
protected $usersTable;
protected $userHobbiesTable;

use \Prophecy\PhpUnit\ProphecyTrait;

protected function setup():void
{
Expand Down Expand Up @@ -100,7 +102,7 @@ public function testUpdateActionValidate()
$this->usersTable->getById($id)->willReturn($rowset);
$this->dispatch('/users/edit/'.$id, 'GET');
$this->assertResponseStatusCode(200);
$dom = new \Laminas\Dom\Query($this->getResponse());
$dom = new \Laminas\Dom\Query($this->getResponse()->getBody());
$results = $dom->execute('input[name="username"]');
$this->assertEquals($editData['username'], $results[0]->getAttribute('value'));
$this->assertQueryContentContains('.jumbotron .zf-green', 'Edit User id: '.$editData['id']);
Expand Down
2 changes: 2 additions & 0 deletions Chapter 21/module/Application/test/Model/ComicsTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class ComicsTableTest extends \Laminas\Test\PHPUnit\Controller\AbstractHttpContr
protected $traceError = true;
protected $usersTable;
protected $baseUrl;

use \Prophecy\PhpUnit\ProphecyTrait;

protected function setup():void
{
Expand Down
2 changes: 1 addition & 1 deletion Chapter 21/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</whitelist>
</filter>
<php>
<const name="APPLICATION_PATH" value="E:\RZECZY_ADAMA\_XAMPP\xampp-7.4\htdocs\laminas_app\" />
<const name="APPLICATION_PATH" value="E:\RZECZY_ADAMA\_XAMPP\xampp-8.1\htdocs\laminas_app\" />
<server name="APPLICATION_ENV" value="tests" />
</php>
</phpunit>

0 comments on commit 86cfd3c

Please sign in to comment.