Completed
Push — 8.7 ( b6d8c1...3ac046 )
by Markus
06:49
created

CredentialStoreTest::_testExists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 31
rs 9.6
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DMK\MKSamlAuth\Tests\Functional\Store;
6
7
use DMK\MKSamlAuth\Store\CredentialStore;
8
use Doctrine\DBAL\DriverManager;
9
use Doctrine\DBAL\Schema\Schema;
10
use Nimut\TestingFramework\TestCase\FunctionalTestCase;
11
use PHPUnit\Framework\TestCase;
12
use TYPO3\CMS\Core\Database\ConnectionPool;
13
14
class CredentialStoreTest extends FunctionalTestCase
15
{
16
    protected $testExtensionsToLoad = [
17
        'typo3conf/ext/mksamlauth'
18
    ];
19
20
    /**
21
     * @var CredentialStore
22
     */
23
    private $store;
24
25
    protected function setUp()
26
    {
27
        $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'] = [
28
            'driver' => 'pdo_sqlite',
29
            'memory' => true
30
        ];
31
32
        parent::setUp();
33
34
        $this->store = new CredentialStore($this->getConnectionPool());
0 ignored issues
show
Deprecated Code introduced by
The function Nimut\TestingFramework\T...se::getConnectionPool() has been deprecated: will be removed once TYPO3 9 LTS is released ( Ignorable by Annotation )

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

34
        $this->store = new CredentialStore(/** @scrutinizer ignore-deprecated */ $this->getConnectionPool());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
35
    }
36
37
    protected function tearDown()
38
    {
39
        $this->getConnectionPool()->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME)
0 ignored issues
show
Deprecated Code introduced by
The function Nimut\TestingFramework\T...se::getConnectionPool() has been deprecated: will be removed once TYPO3 9 LTS is released ( Ignorable by Annotation )

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

39
        /** @scrutinizer ignore-deprecated */ $this->getConnectionPool()->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME)

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
40
            ->exec('TRUNCATE TABLE tx_mksamlauth_domain_model_identityprovider');
41
    }
42
43
44
    public function testNotExists()
45
    {
46
        self::markTestSkipped();
47
        self::assertNull($this->store->getByEntityId('not-exists'));
48
    }
49
50
    public function _testExists()
51
    {
52
        self::markTestSkipped();
53
        $this->getDatabaseConnection()
54
            ->insertArray('tx_mksamlauth_domain_model_identityprovider', [
55
                'name' => 'foo',
56
                'certificate' => file_get_contents(__DIR__.'/../Fixtures/saml.crt'),
57
                'cert_key' => file_get_contents(__DIR__.'/../Fixtures/saml.crt'),
58
                'passphrase' => '123123',
59
            ]);
60
61
        $credential = $this->store->getByEntityId('foo');
62
63
        self::assertSame(
64
            'foo',
65
            $credential->getEntityId()
66
        );
67
68
        self::assertSame(
69
          '',
70
            $credential->getCertificate()->getFingerprint()
71
        );
72
73
        self::assertSame(
74
            '',
75
            $credential->getPrivateKey()->key
76
        );
77
78
        self::assertSame(
79
            '',
80
            $credential->getPrivateKey()->passphrase
81
        );
82
    }
83
}
84