Completed
Pull Request — master (#38)
by Daniel
14:53
created

HybridSessionTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 13
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace SilverStripe\HybridSessions\Tests;
4
5
use SilverStripe\ORM\DB;
6
use SilverStripe\ORM\Connect\MySQLDatabase;
7
use SilverStripe\Core\Injector\Injector;
8
use SilverStripe\Core\Config\Config;
9
use SilverStripe\Core\TempFolder;
10
use SilverStripe\HybridSessions\HybridSession;
11
12
class HybridSessionTest extends AbstractTest
13
{
14
15
    protected function setUp()
16
    {
17
        parent::setUp();
18
19
        if (!DB::get_conn() instanceof MySQLDatabase) {
20
            // we can't always use the DB driver, so remove it if we aren't running a MySQL DB
21
            Config::modify()->set(HybridSession::class, 'dependencies', [
22
                'handlers' => [
23
                    '%$\SilverStripe\HybridSessions\Store\CookieStore',
24
                ],
25
            ]);
26
        }
27
    }
28
29
    /**
30
     * @return HybridSessionStore_Cookie
31
     */
32 View Code Duplication
    protected function getStore()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        $store = Injector::inst()->create(HybridSession::class);
35
        $store->setKey(uniqid());
36
        $store->open(TempFolder::getTempFolder(BASE_PATH).'/'.__CLASS__, 'SESSIONCOOKIE');
37
38
        return $store;
39
    }
40
}
41