Passed
Push — master ( e4ea65...5bc50c )
by Christian
15:36 queued 10s
created

StoreClientBehaviour::createAdminStoreContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 21
rs 9.8333
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Framework\Test\Store;
4
5
use GuzzleHttp\Handler\MockHandler;
6
use Shopware\Core\Framework\Api\Context\AdminApiSource;
7
use Shopware\Core\Framework\Context;
8
use Shopware\Core\Framework\Uuid\Uuid;
9
10
trait StoreClientBehaviour
11
{
12
    public function getRequestHandler(): MockHandler
13
    {
14
        return $this->getContainer()->get('shopware.store.mock_handler');
0 ignored issues
show
Bug introduced by
It seems like getContainer() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

14
        return $this->/** @scrutinizer ignore-call */ getContainer()->get('shopware.store.mock_handler');
Loading history...
15
    }
16
17
    private function createAdminStoreContext(): Context
18
    {
19
        $userId = Uuid::randomHex();
20
        $storeToken = Uuid::randomHex();
21
22
        $data = [
23
            [
24
                'id' => $userId,
25
                'localeId' => $this->getLocaleIdOfSystemLanguage(),
0 ignored issues
show
Bug introduced by
It seems like getLocaleIdOfSystemLanguage() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

25
                'localeId' => $this->/** @scrutinizer ignore-call */ getLocaleIdOfSystemLanguage(),
Loading history...
26
                'username' => 'foobar',
27
                'password' => 'asdasdasdasd',
28
                'firstName' => 'Foo',
29
                'lastName' => 'Bar',
30
                'email' => Uuid::randomHex() . '@bar.com',
31
                'storeToken' => $storeToken,
32
            ],
33
        ];
34
35
        $this->getContainer()->get('user.repository')->create($data, Context::createDefaultContext());
36
37
        return Context::createDefaultContext(new AdminApiSource($userId));
38
    }
39
}
40