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 — master ( 87d66a...5c300c )
by Navarr
02:35
created

SocketTest::testSocketCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Navarr\Socket\Test;
4
5
use Navarr\Socket\Socket;
6
7
class SocketTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testSocketCreate()
10
    {
11
        // Create the Socket
12
        $socket = Socket::create(AF_INET, SOCK_STREAM, SOL_TCP);
13
14
        // Create function should obviously return an instance of the class
15
        $this->assertTrue($socket instanceof Socket);
16
17
        // Lets make sure that the resource is created properly
18
        $reflectionProperty = new \ReflectionProperty($socket, 'resource');
19
        $this->assertTrue($reflectionProperty->isProtected());
20
        $reflectionProperty->setAccessible(true);
21
        $this->assertEquals('resource', gettype($reflectionProperty->getValue($socket)));
22
    }
23
24
    /**
25
     * @expectedException \Navarr\Socket\Exception\SocketException
26
     */
27
    public function testSocketCreateWithBadValuesThrowsSocketException()
28
    {
29
        Socket::create(9001, 9001, 9001);
30
    }
31
32
    /**
33
     * @expectedException \Navarr\Socket\Exception\SocketException
34
     */
35
    public function testSocketWithResourceThrowsSocketException()
36
    {
37
        $socket = Socket::create(AF_INET, SOCK_STREAM, SOL_TCP);
38
        $socket->write('test', 4);
39
    }
40
41
    /**
42
     * Verifies that {@see Socket::constructFromResources} works as expected
43
     */
44
    public function testSocketCanBeConstructedFromResources()
45
    {
46
        $resourceA = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
47
        $resourceB = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
48
49
        $reflectionMethod = new \ReflectionMethod(Socket::class, 'constructFromResources');
50
        $reflectionMethod->setAccessible(true);
51
        $func = $reflectionMethod->getClosure();
52
53
        /** @var Socket[] $result */
54
        $result = $func([$resourceA, $resourceB]);
55
56
        $this->assertTrue(is_array($result));
57
        $this->assertEquals(2, count($result));
58
        foreach($result as $singleResult) {
59
            $this->assertInstanceOf(Socket::class, $singleResult);
60
        }
61
62
        $resultA = $result[0];
63
        $resultB = $result[1];
64
65
        $reflectionProperty = new \ReflectionProperty($resultA, 'resource');
66
        $reflectionProperty->setAccessible(true);
67
68
        $this->assertEquals($resourceA, $reflectionProperty->getValue($resultA));
69
        $this->assertEquals($resourceB, $reflectionProperty->getValue($resultB));
70
    }
71
}
72