CryptKeysTraitTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 3
Bugs 2 Features 1
Metric Value
wmc 1
eloc 13
c 3
b 2
f 1
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCanUseCryptoKeysFromConfig() 0 20 1
1
<?php
2
3
namespace ByTIC\Hello\Tests\Oauth\ServiceProvider\Traits;
4
5
use ByTIC\Hello\HelloServiceProvider;
6
use ByTIC\Hello\Tests\AbstractTest;
7
use ByTIC\Hello\Utility\ConfigHelper;
8
use Mockery as m;
9
use Nip\Container\Container;
10
11
/**
12
 * Class CryptKeysTraitTest
13
 * @package ByTIC\Hello\Tests\Oauth\ServiceProvider\Traits
14
 */
15
class CryptKeysTraitTest extends AbstractTest
16
{
17
    public function testCanUseCryptoKeysFromConfig()
18
    {
19
        $config = m::mock(ConfigHelper::class)->makePartial();
20
        $config->shouldReceive('get')
21
//            ->with('private_key', null)
22
            ->andReturn('-----BEGIN RSA PRIVATE KEY-----\nconfig\n-----END RSA PRIVATE KEY-----');
23
24
        $provider = new HelloServiceProvider();
25
        $provider->setContainer(new Container());
26
27
        ConfigHelper::setConfig($config);
0 ignored issues
show
Bug introduced by
$config of type Mockery\Mock is incompatible with the type Nip\Config\Config expected by parameter $object of ByTIC\Hello\Utility\ConfigHelper::setConfig(). ( Ignorable by Annotation )

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

27
        ConfigHelper::setConfig(/** @scrutinizer ignore-type */ $config);
Loading history...
28
29
        // Call protected makeCryptKey method
30
        $cryptKey = (function () {
31
            return $this->makeCryptKey('private');
0 ignored issues
show
Bug introduced by
The method makeCryptKey() does not exist on ByTIC\Hello\Tests\Oauth\...aits\CryptKeysTraitTest. ( Ignorable by Annotation )

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

31
            return $this->/** @scrutinizer ignore-call */ makeCryptKey('private');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
        })->call($provider);
33
34
        static::assertSame(
35
            "-----BEGIN RSA PRIVATE KEY-----\nconfig\n-----END RSA PRIVATE KEY-----",
36
            file_get_contents($cryptKey->getKeyPath())
37
        );
38
    }
39
}
40