Skip to content

Commit

Permalink
Merge pull request #45 from visto9259/master
Browse files Browse the repository at this point in the history
Fixed Test suite to remove PHP 8.2 deprecation notices
  • Loading branch information
visto9259 authored Aug 22, 2023
2 parents e05b6fd + 9337968 commit 341a0bd
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 43 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ matrix:
- php: 8.0
env:
- DEPS=latest
- php: 8.1
env:
- DEPS=lowest
- php: 8.1
env:
- DEPS=latest
- php: 8.2
env:
- DEPS=lowest
- php: 8.2
env:
- DEPS=latest
- php: nightly
env:
- DEPS=lowest
Expand Down
62 changes: 25 additions & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
stopOnFailure="false"
processIsolation="false"
backupGlobals="false"
>
<testsuite name="LmcUser Test Suite">
<directory>./tests</directory>
</testsuite>

<php>
<const name="DB_MYSQL_DSN" value="mysql:host=localhost;dbname=lmc_user" />
<const name="DB_MYSQL_USERNAME" value="root" />
<const name="DB_MYSQL_PASSWORD" value="" />
<const name="DB_MYSQL_SCHEMA" value="./data/schema.mysql.sql" />

<const name="DB_SQLITE_DSN" value="sqlite::memory:" />
<const name="DB_SQLITE_USERNAME" value="" />
<const name="DB_SQLITE_PASSWORD" value="" />
<const name="DB_SQLITE_SCHEMA" value="./data/schema.sqlite.sql" />
</php>

<filter>
<whitelist>
<directory suffix=".php">./src</directory>
<file>Module.php</file>
</whitelist>
</filter>

<logging>
<log type="coverage-text" target="php://stdout"/>
<log type="coverage-clover" target="./build/logs/clover.xml"/>
</logging>
<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">
<coverage>
<include>
<directory suffix=".php">./src</directory>
<file>Module.php</file>
</include>
<report>
<clover outputFile="./build/logs/clover.xml"/>
<text outputFile="php://stdout"/>
</report>
</coverage>
<testsuite name="LmcUser Test Suite">
<directory>./tests</directory>
</testsuite>
<php>
<const name="DB_MYSQL_DSN" value="mysql:host=localhost;dbname=lmc_user"/>
<const name="DB_MYSQL_USERNAME" value="root"/>
<const name="DB_MYSQL_PASSWORD" value=""/>
<const name="DB_MYSQL_SCHEMA" value="./data/schema.mysql.sql"/>
<const name="DB_SQLITE_DSN" value="sqlite::memory:"/>
<const name="DB_SQLITE_USERNAME" value=""/>
<const name="DB_SQLITE_PASSWORD" value=""/>
<const name="DB_SQLITE_SCHEMA" value="./data/schema.sqlite.sql"/>
</php>
<logging/>
</phpunit>
10 changes: 10 additions & 0 deletions tests/Authentication/Adapter/DbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LmcUserTest\Authentication\Adapter;

use Laminas\Crypt\Password\Bcrypt;
use Laminas\EventManager\Event;
use LmcUser\Authentication\Adapter\Db;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -199,6 +200,15 @@ public function testAuthenticateWithWrongPassword()
->method('getPasswordCost')
->willReturn(4);

$bcrypt = new Bcrypt([
'cost' => 4,
]);

$hash = $bcrypt->create('123456');
$this->user->expects($this->once())
->method('getPassword')
->willReturn($hash);

$this->authEvent->expects($this->once())
->method('setCode')
->with(\Laminas\Authentication\Result::FAILURE_CREDENTIAL_INVALID)
Expand Down
10 changes: 10 additions & 0 deletions tests/Mapper/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ class UserTest extends TestCase
*/
protected $mockedDbAdapterPlatform;

/**
* @var \Laminas\Db\Adapter\Driver\StatementInterface
*/
protected $mockedDbAdapterStatement;

/**
* @var \Laminas\Db\Sql\Platform\Platform
*/
protected $mockedDbSqlPlatform;

public function setUp():void
{
$mapper = new Mapper;
Expand Down
15 changes: 9 additions & 6 deletions tests/Service/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ public function testRegisterWithInvalidForm()
*/
public function testRegisterWithUsernameAndDisplayNameUserStateDisabled()
{
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User');
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User', 'password' => '123456');

$user = $this->createMock('LmcUser\Entity\User');
$user->expects($this->once())
->method('setPassword');
$user->expects($this->once())
->method('getPassword');
->method('getPassword')
->willReturn('123456');
$user->expects($this->once())
->method('setUsername')
->with('LmcUser');
Expand Down Expand Up @@ -159,13 +160,14 @@ public function testRegisterWithUsernameAndDisplayNameUserStateDisabled()
*/
public function testRegisterWithDefaultUserStateOfZero()
{
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User');
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User', 'password' => '123456');

$user = $this->createMock('LmcUser\Entity\User');
$user->expects($this->once())
->method('setPassword');
$user->expects($this->once())
->method('getPassword');
->method('getPassword')
->willReturn('123456');
$user->expects($this->once())
->method('setUsername')
->with('LmcUser');
Expand Down Expand Up @@ -231,13 +233,14 @@ public function testRegisterWithDefaultUserStateOfZero()
*/
public function testRegisterWithUserStateDisabled()
{
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User');
$expectArray = array('username' => 'LmcUser', 'display_name' => 'Zfc User', 'password' => '123456');

$user = $this->createMock('LmcUser\Entity\User');
$user->expects($this->once())
->method('setPassword');
$user->expects($this->once())
->method('getPassword');
->method('getPassword')
->willReturn('123456');
$user->expects($this->once())
->method('setUsername')
->with('LmcUser');
Expand Down

0 comments on commit 341a0bd

Please sign in to comment.