GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 3.x ( 56b2ee...e477bf )
by Jindřich
01:49
created

SkautisTest::testGettingService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Test\Skautis;
4
5
use PHPUnit_Framework_TestCase;
6
use Skautis\Config;
7
use Skautis\DynamicPropertiesDisabledException;
8
use Skautis\Skautis;
9
use Skautis\Wsdl\WebService;
10
use Skautis\Wsdl\WebServiceInterface;
11
use Skautis\Wsdl\WebServiceName;
12
13
class SkautisTest extends PHPUnit_Framework_TestCase
14
{
15
16
    public function testSingletonSameId(): void
17
    {
18
        $skautis = Skautis::getInstance('asd');
19
        $skautisA = Skautis::getInstance('asd');
20
        $this->assertSame($skautis, $skautisA);
21
    }
22
23
    public function testSingletonDifferentId(): void
24
    {
25
        $skautis = Skautis::getInstance('asd');
26
        $skautisA = Skautis::getInstance('qwe');
27
        $this->assertNotSame($skautis, $skautisA);
28
    }
29
30
    public function testSingletonTestMode(): void
31
    {
32
        $appId = 'some-app-id';
33
34
        $skautisWithTestMode = Skautis::getInstance($appId, Config::TEST_MODE_ENABLED);
35
        $skautisWithoutTestMode = Skautis::getInstance($appId, Config::TEST_MODE_DISABLED);
36
37
        $this->assertNotSame($skautisWithTestMode, $skautisWithoutTestMode);
38
    }
39
40
    public function testGettingService(): void {
41
      $skautis = Skautis::getInstance('asd');
42
43
      $serviceA = $skautis->UserManagement;
44
      $serviceB = $skautis->getWebService(WebServiceName::USER_MANAGEMENT);
45
46
      $this->assertSame($serviceA, $serviceB);
47
    }
48
49
    public function testGettingServiceUsingAlias(): void {
50
      $skautis = Skautis::getInstance('asd');
51
52
      $serviceA = $skautis->UserManagement;
53
      $serviceB = $skautis->user;
0 ignored issues
show
Documentation introduced by
The property $user is declared private in Skautis\Skautis. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
54
      $serviceC = $skautis->usr;
0 ignored issues
show
Documentation introduced by
The property usr does not exist on object<Skautis\Skautis>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
55
56
      $this->assertSame($serviceA, $serviceB);
57
      $this->assertSame($serviceB, $serviceC);
58
    }
59
60
    public function testSettingWebService(): void {
61
      $skautis = Skautis::getInstance('asd');
62
63
      $this->expectException(DynamicPropertiesDisabledException::class);
64
      $skautis->UserManagement = 'asd';
65
    }
66
67
    public function testEventSetter(): void
68
    {
69
        //@TODO
70
    }
71
}
72