Skip to content

Commit 341a0bd

Browse files
authored
Merge pull request #45 from visto9259/master
Fixed Test suite to remove PHP 8.2 deprecation notices
2 parents e05b6fd + 9337968 commit 341a0bd

5 files changed

Lines changed: 66 additions & 43 deletions

File tree

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ matrix:
3737
- php: 8.0
3838
env:
3939
- DEPS=latest
40+
- php: 8.1
41+
env:
42+
- DEPS=lowest
43+
- php: 8.1
44+
env:
45+
- DEPS=latest
46+
- php: 8.2
47+
env:
48+
- DEPS=lowest
49+
- php: 8.2
50+
env:
51+
- DEPS=latest
4052
- php: nightly
4153
env:
4254
- DEPS=lowest

phpunit.xml.dist

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
colors="true"
4-
convertErrorsToExceptions="true"
5-
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
verbose="true"
8-
stopOnFailure="false"
9-
processIsolation="false"
10-
backupGlobals="false"
11-
>
12-
<testsuite name="LmcUser Test Suite">
13-
<directory>./tests</directory>
14-
</testsuite>
15-
16-
<php>
17-
<const name="DB_MYSQL_DSN" value="mysql:host=localhost;dbname=lmc_user" />
18-
<const name="DB_MYSQL_USERNAME" value="root" />
19-
<const name="DB_MYSQL_PASSWORD" value="" />
20-
<const name="DB_MYSQL_SCHEMA" value="./data/schema.mysql.sql" />
21-
22-
<const name="DB_SQLITE_DSN" value="sqlite::memory:" />
23-
<const name="DB_SQLITE_USERNAME" value="" />
24-
<const name="DB_SQLITE_PASSWORD" value="" />
25-
<const name="DB_SQLITE_SCHEMA" value="./data/schema.sqlite.sql" />
26-
</php>
27-
28-
<filter>
29-
<whitelist>
30-
<directory suffix=".php">./src</directory>
31-
<file>Module.php</file>
32-
</whitelist>
33-
</filter>
34-
35-
<logging>
36-
<log type="coverage-text" target="php://stdout"/>
37-
<log type="coverage-clover" target="./build/logs/clover.xml"/>
38-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" verbose="true" stopOnFailure="false" processIsolation="false" backupGlobals="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">./src</directory>
6+
<file>Module.php</file>
7+
</include>
8+
<report>
9+
<clover outputFile="./build/logs/clover.xml"/>
10+
<text outputFile="php://stdout"/>
11+
</report>
12+
</coverage>
13+
<testsuite name="LmcUser Test Suite">
14+
<directory>./tests</directory>
15+
</testsuite>
16+
<php>
17+
<const name="DB_MYSQL_DSN" value="mysql:host=localhost;dbname=lmc_user"/>
18+
<const name="DB_MYSQL_USERNAME" value="root"/>
19+
<const name="DB_MYSQL_PASSWORD" value=""/>
20+
<const name="DB_MYSQL_SCHEMA" value="./data/schema.mysql.sql"/>
21+
<const name="DB_SQLITE_DSN" value="sqlite::memory:"/>
22+
<const name="DB_SQLITE_USERNAME" value=""/>
23+
<const name="DB_SQLITE_PASSWORD" value=""/>
24+
<const name="DB_SQLITE_SCHEMA" value="./data/schema.sqlite.sql"/>
25+
</php>
26+
<logging/>
3927
</phpunit>

tests/Authentication/Adapter/DbTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace LmcUserTest\Authentication\Adapter;
44

5+
use Laminas\Crypt\Password\Bcrypt;
56
use Laminas\EventManager\Event;
67
use LmcUser\Authentication\Adapter\Db;
78
use PHPUnit\Framework\TestCase;
@@ -199,6 +200,15 @@ public function testAuthenticateWithWrongPassword()
199200
->method('getPasswordCost')
200201
->willReturn(4);
201202

203+
$bcrypt = new Bcrypt([
204+
'cost' => 4,
205+
]);
206+
207+
$hash = $bcrypt->create('123456');
208+
$this->user->expects($this->once())
209+
->method('getPassword')
210+
->willReturn($hash);
211+
202212
$this->authEvent->expects($this->once())
203213
->method('setCode')
204214
->with(\Laminas\Authentication\Result::FAILURE_CREDENTIAL_INVALID)

tests/Mapper/UserTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ class UserTest extends TestCase
6868
*/
6969
protected $mockedDbAdapterPlatform;
7070

71+
/**
72+
* @var \Laminas\Db\Adapter\Driver\StatementInterface
73+
*/
74+
protected $mockedDbAdapterStatement;
75+
76+
/**
77+
* @var \Laminas\Db\Sql\Platform\Platform
78+
*/
79+
protected $mockedDbSqlPlatform;
80+
7181
public function setUp():void
7282
{
7383
$mapper = new Mapper;

tests/Service/UserTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,14 @@ public function testRegisterWithInvalidForm()
8888
*/
8989
public function testRegisterWithUsernameAndDisplayNameUserStateDisabled()
9090
{
91-
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User');
91+
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User', 'password' => '123456');
9292

9393
$user = $this->createMock('LmcUser\Entity\User');
9494
$user->expects($this->once())
9595
->method('setPassword');
9696
$user->expects($this->once())
97-
->method('getPassword');
97+
->method('getPassword')
98+
->willReturn('123456');
9899
$user->expects($this->once())
99100
->method('setUsername')
100101
->with('LmcUser');
@@ -159,13 +160,14 @@ public function testRegisterWithUsernameAndDisplayNameUserStateDisabled()
159160
*/
160161
public function testRegisterWithDefaultUserStateOfZero()
161162
{
162-
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User');
163+
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User', 'password' => '123456');
163164

164165
$user = $this->createMock('LmcUser\Entity\User');
165166
$user->expects($this->once())
166167
->method('setPassword');
167168
$user->expects($this->once())
168-
->method('getPassword');
169+
->method('getPassword')
170+
->willReturn('123456');
169171
$user->expects($this->once())
170172
->method('setUsername')
171173
->with('LmcUser');
@@ -231,13 +233,14 @@ public function testRegisterWithDefaultUserStateOfZero()
231233
*/
232234
public function testRegisterWithUserStateDisabled()
233235
{
234-
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User');
236+
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User', 'password' => '123456');
235237

236238
$user = $this->createMock('LmcUser\Entity\User');
237239
$user->expects($this->once())
238240
->method('setPassword');
239241
$user->expects($this->once())
240-
->method('getPassword');
242+
->method('getPassword')
243+
->willReturn('123456');
241244
$user->expects($this->once())
242245
->method('setUsername')
243246
->with('LmcUser');

0 commit comments

Comments
 (0)