Completed
Push — master ( 4b4e40...af8835 )
by Craig
10:40 queued 04:02
created

PasswordApiTest::testGetHashedPasswordOnUndefined()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula Foundation - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\ZAuthModule\Tests\Api;
15
16
use PHPUnit\Framework\Error\Notice;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\Error\Notice was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Zikula\ZAuthModule\Api\ApiInterface\PasswordApiInterface;
19
use Zikula\ZAuthModule\Api\PasswordApi;
20
21
class PasswordApiTest extends TestCase
22
{
23
    /**
24
     * @var PasswordApiInterface
25
     */
26
    private $api;
27
28
    protected function setUp(): void
29
    {
30
        $this->api = new PasswordApi();
0 ignored issues
show
Deprecated Code introduced by
The class Zikula\ZAuthModule\Api\PasswordApi has been deprecated: at Core-3.0.0 to be removed in Core-4.0.0 Use \Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface Use `bin2hex(random_bytes(8))` for random string generation suitable for passwords ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

30
        $this->api = /** @scrutinizer ignore-deprecated */ new PasswordApi();
Loading history...
31
    }
32
33
    /**
34
     * @covers PasswordApi::passwordsMatch()
35
     */
36
    public function testPasswordsMatch(): void
37
    {
38
        $hashedPass = $this->api->getHashedPassword('12345678');
39
        $this->assertTrue($this->api->passwordsMatch('12345678', $hashedPass));
40
    }
41
42
    /**
43
     * @covers PasswordApi::passwordsMatch()
44
     */
45
    public function testPasswordsMatchExceptionOnEmpty(): void
46
    {
47
        $hashedPass = $this->api->getHashedPassword('12345678');
48
        $this->assertFalse($this->api->passwordsMatch('', $hashedPass));
49
    }
50
51
    /**
52
     * @covers PasswordApi::passwordsMatch()
53
     */
54
    public function testPasswordsMatchExceptionOnNull(): void
55
    {
56
        $this->expectException(\TypeError::class);
57
        $hashedPass = $this->api->getHashedPassword('12345678');
58
        $this->api->passwordsMatch(null, $hashedPass);
0 ignored issues
show
Bug introduced by
null of type null is incompatible with the type string expected by parameter $unhashedPassword of Zikula\ZAuthModule\Api\A...rface::passwordsMatch(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
        $this->api->passwordsMatch(/** @scrutinizer ignore-type */ null, $hashedPass);
Loading history...
59
    }
60
}
61