Completed
Push — master ( d991f2...2b3b24 )
by Julián
04:04
created

OptionRegexTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 32
rs 10
1
<?php
2
3
/*
4
 * A PSR7 aware cURL client (https://github.com/juliangut/spiral).
5
 *
6
 * @license BSD-3-Clause
7
 * @link https://github.com/juliangut/spiral
8
 * @author Julián Gutiérrez <[email protected]>
9
 */
10
11
namespace Jgut\Spiral\Tests\Option;
12
13
use Jgut\Spiral\Option\OptionRegex;
14
15
/**
16
 * Regex option tests.
17
 */
18
class OptionRegexTest extends \PHPUnit_Framework_TestCase
19
{
20
    /**
21
     * @expectedException \Jgut\Spiral\Exception\OptionException
22
     */
23
    public function testBadFormatted()
24
    {
25
        $option = new OptionRegex(CURLOPT_USERPWD);
26
27
        static::assertEquals(CURLOPT_USERPWD, $option->getOption());
28
        static::assertEquals('', $option->getValue());
29
30
        $option->setValue('/^a$/');
31
        static::assertEquals('a', $option->getValue());
32
33
        $option->setValue('value');
34
    }
35
36
    /**
37
     * @expectedException \Jgut\Spiral\Exception\OptionException
38
     * @expectedExceptionMessage Invalid!
39
     */
40
    public function testAccessors()
41
    {
42
        $option = new OptionRegex(CURLOPT_USERPWD);
43
44
        $option->setRegex('/^a$/');
45
        $option->setMessage('Invalid!');
46
47
        $option->setValue('b');
48
    }
49
}
50