CurlOptsTest::testArrayAccess()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 11
rs 10
1
<?php
2
3
namespace Palmtree\Curl\Tests;
4
5
use Palmtree\Curl\CurlOpts;
6
use PHPUnit\Framework\TestCase;
7
8
class CurlOptsTest extends TestCase
9
{
10
    public function testOffsetExists()
11
    {
12
        $opts = new CurlOpts([
13
            CURLOPT_BINARYTRANSFER => true,
14
        ]);
15
16
        $this->assertTrue(isset($opts[CURLOPT_BINARYTRANSFER]));
17
    }
18
19
    public function testArrayAccess()
20
    {
21
        $opts = new CurlOpts([]);
22
23
        $opts[CURLOPT_BINARYTRANSFER] = true;
24
25
        $this->assertTrue($opts->get(CURLOPT_BINARYTRANSFER));
26
27
        unset($opts[CURLOPT_BINARYTRANSFER]);
28
29
        $this->assertNull($opts->get(CURLOPT_BINARYTRANSFER));
30
    }
31
32
    public function testArrayIterator()
33
    {
34
        $opts = new CurlOpts([
35
            CURLOPT_BINARYTRANSFER => true,
36
        ]);
37
38
        foreach ($opts as $key => $value) {
39
            if ($key === CURLOPT_BINARYTRANSFER) {
40
                $this->assertTrue($value);
41
            }
42
        }
43
    }
44
}
45