Completed
Pull Request — master (#51)
by
unknown
20s
created
tests/Swagger/Type/Custom/Ipv6TypeTest.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -3,154 +3,154 @@
 block discarded – undo
3 3
 class Ipv6TypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
20
-     */
21
-    public function testConstructNotAnIpv6()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not an IPv6: 'wrong'");
24
-
25
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
30
-     */
31
-    public function testConstruct()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'string',
39
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
45
-     */
46
-    public function testConstructEmptyDefault()
47
-    {
48
-        $this->expectException('\SwaggerGen\Exception', "Unparseable IPv6 definition: 'ipv6='");
49
-
50
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= ');
51
-    }
52
-
53
-    /**
54
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
55
-     */
56
-    public function testConstructDefaultTooManyDigits()
57
-    {
58
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '12001:0db8:85a3:0000:1319:8a2e:0370:7344'");
59
-
60
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=12001:0db8:85a3:0000:1319:8a2e:0370:7344');
61
-    }
62
-
63
-    /**
64
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
65
-     */
66
-    public function testConstructDefaultTooFewParts()
67
-    {
68
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '0db8:85a3:0000:1319:8a2e:0370:7344'");
69
-
70
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=0db8:85a3:0000:1319:8a2e:0370:7344');
71
-    }
72
-
73
-    /**
74
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
75
-     */
76
-    public function testConstructDefaultTooManyParts()
77
-    {
78
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344'");
79
-
80
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344');
81
-    }
82
-
83
-    /**
84
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
85
-     */
86
-    public function testConstructDefaultUntrimmed()
87
-    {
88
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: ' 2001:0db8:85a3:0000:1319:8a2e:0370:7344'");
89
-
90
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= 2001:0db8:85a3:0000:1319:8a2e:0370:7344');
91
-    }
92
-
93
-    /**
94
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
95
-     */
96
-    public function testConstructDefault()
97
-    {
98
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3:0000:1319:8a2e:0370:7344');
99
-
100
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
101
-
102
-        $this->assertSame(array(
103
-            'type' => 'string',
104
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
105
-            'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344',
106
-        ), $object->toArray());
107
-    }
108
-
109
-    /**
110
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
111
-     */
112
-    public function testConstructDefaultNoZeroes()
113
-    {
114
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3::1319:8a2e:0370:7344');
115
-
116
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
117
-
118
-        $this->assertSame(array(
119
-            'type' => 'string',
120
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
121
-            'default' => '2001:0db8:85a3::1319:8a2e:0370:7344',
122
-        ), $object->toArray());
123
-    }
124
-
125
-    /**
126
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand
127
-     */
128
-    public function testCommandDefaultNoValue()
129
-    {
130
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
131
-
132
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
133
-
134
-        $this->expectException('\SwaggerGen\Exception', "Empty IPv6 default");
135
-        $object->handleCommand('default', '');
136
-    }
137
-
138
-    /**
139
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand
140
-     */
141
-    public function testCommandDefault()
142
-    {
143
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
144
-
145
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
146
-
147
-        $object->handleCommand('default', '2001:0db8:85a3:0000:1319:8a2e:0370:7344');
148
-
149
-        $this->assertSame(array(
150
-            'type' => 'string',
151
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
152
-            'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344',
153
-        ), $object->toArray());
154
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
20
+	 */
21
+	public function testConstructNotAnIpv6()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not an IPv6: 'wrong'");
24
+
25
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
30
+	 */
31
+	public function testConstruct()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'string',
39
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
45
+	 */
46
+	public function testConstructEmptyDefault()
47
+	{
48
+		$this->expectException('\SwaggerGen\Exception', "Unparseable IPv6 definition: 'ipv6='");
49
+
50
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= ');
51
+	}
52
+
53
+	/**
54
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
55
+	 */
56
+	public function testConstructDefaultTooManyDigits()
57
+	{
58
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '12001:0db8:85a3:0000:1319:8a2e:0370:7344'");
59
+
60
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=12001:0db8:85a3:0000:1319:8a2e:0370:7344');
61
+	}
62
+
63
+	/**
64
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
65
+	 */
66
+	public function testConstructDefaultTooFewParts()
67
+	{
68
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '0db8:85a3:0000:1319:8a2e:0370:7344'");
69
+
70
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=0db8:85a3:0000:1319:8a2e:0370:7344');
71
+	}
72
+
73
+	/**
74
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
75
+	 */
76
+	public function testConstructDefaultTooManyParts()
77
+	{
78
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344'");
79
+
80
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344');
81
+	}
82
+
83
+	/**
84
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
85
+	 */
86
+	public function testConstructDefaultUntrimmed()
87
+	{
88
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: ' 2001:0db8:85a3:0000:1319:8a2e:0370:7344'");
89
+
90
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= 2001:0db8:85a3:0000:1319:8a2e:0370:7344');
91
+	}
92
+
93
+	/**
94
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
95
+	 */
96
+	public function testConstructDefault()
97
+	{
98
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3:0000:1319:8a2e:0370:7344');
99
+
100
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
101
+
102
+		$this->assertSame(array(
103
+			'type' => 'string',
104
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
105
+			'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344',
106
+		), $object->toArray());
107
+	}
108
+
109
+	/**
110
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
111
+	 */
112
+	public function testConstructDefaultNoZeroes()
113
+	{
114
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3::1319:8a2e:0370:7344');
115
+
116
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
117
+
118
+		$this->assertSame(array(
119
+			'type' => 'string',
120
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
121
+			'default' => '2001:0db8:85a3::1319:8a2e:0370:7344',
122
+		), $object->toArray());
123
+	}
124
+
125
+	/**
126
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand
127
+	 */
128
+	public function testCommandDefaultNoValue()
129
+	{
130
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
131
+
132
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
133
+
134
+		$this->expectException('\SwaggerGen\Exception', "Empty IPv6 default");
135
+		$object->handleCommand('default', '');
136
+	}
137
+
138
+	/**
139
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand
140
+	 */
141
+	public function testCommandDefault()
142
+	{
143
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
144
+
145
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
146
+
147
+		$object->handleCommand('default', '2001:0db8:85a3:0000:1319:8a2e:0370:7344');
148
+
149
+		$this->assertSame(array(
150
+			'type' => 'string',
151
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
152
+			'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344',
153
+		), $object->toArray());
154
+	}
155 155
 
156 156
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/Custom/Ipv4TypeTest.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -3,138 +3,138 @@
 block discarded – undo
3 3
 class Ipv4TypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
20
-     */
21
-    public function testConstructNotAnIpv4()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not an IPv4: 'wrong'");
24
-
25
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
30
-     */
31
-    public function testConstruct()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'string',
39
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
45
-     */
46
-    public function testConstructEmptyDefault()
47
-    {
48
-        $this->expectException('\SwaggerGen\Exception', "Unparseable IPv4 definition: 'ipv4='");
49
-
50
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= ');
51
-    }
52
-
53
-    /**
54
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
55
-     */
56
-    public function testConstructDefaultRange()
57
-    {
58
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '127.0.256.0'");
59
-
60
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=127.0.256.0');
61
-    }
62
-
63
-    /**
64
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
65
-     */
66
-    public function testConstructDefault3Numbers()
67
-    {
68
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0'");
69
-
70
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0');
71
-    }
72
-
73
-    /**
74
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
75
-     */
76
-    public function testConstructDefault5Numbers()
77
-    {
78
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0.0.0'");
79
-
80
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0.0.0');
81
-    }
82
-
83
-    /**
84
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
85
-     */
86
-    public function testConstructDefaultUntrimmed()
87
-    {
88
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: ' 0.0.0.0.0'");
89
-
90
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= 0.0.0.0.0');
91
-    }
92
-
93
-    /**
94
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
95
-     */
96
-    public function testConstructDefault()
97
-    {
98
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=123.45.67.89');
99
-
100
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
101
-
102
-        $this->assertSame(array(
103
-            'type' => 'string',
104
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
105
-            'default' => '123.45.67.89',
106
-        ), $object->toArray());
107
-    }
108
-
109
-    /**
110
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand
111
-     */
112
-    public function testCommandDefaultNoValue()
113
-    {
114
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
115
-
116
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
117
-
118
-        $this->expectException('\SwaggerGen\Exception', "Empty IPv4 default");
119
-        $object->handleCommand('default', '');
120
-    }
121
-
122
-    /**
123
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand
124
-     */
125
-    public function testCommandDefault()
126
-    {
127
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
128
-
129
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
130
-
131
-        $object->handleCommand('default', '123.45.67.89');
132
-
133
-        $this->assertSame(array(
134
-            'type' => 'string',
135
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
136
-            'default' => '123.45.67.89',
137
-        ), $object->toArray());
138
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
20
+	 */
21
+	public function testConstructNotAnIpv4()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not an IPv4: 'wrong'");
24
+
25
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
30
+	 */
31
+	public function testConstruct()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'string',
39
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
45
+	 */
46
+	public function testConstructEmptyDefault()
47
+	{
48
+		$this->expectException('\SwaggerGen\Exception', "Unparseable IPv4 definition: 'ipv4='");
49
+
50
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= ');
51
+	}
52
+
53
+	/**
54
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
55
+	 */
56
+	public function testConstructDefaultRange()
57
+	{
58
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '127.0.256.0'");
59
+
60
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=127.0.256.0');
61
+	}
62
+
63
+	/**
64
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
65
+	 */
66
+	public function testConstructDefault3Numbers()
67
+	{
68
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0'");
69
+
70
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0');
71
+	}
72
+
73
+	/**
74
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
75
+	 */
76
+	public function testConstructDefault5Numbers()
77
+	{
78
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0.0.0'");
79
+
80
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0.0.0');
81
+	}
82
+
83
+	/**
84
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
85
+	 */
86
+	public function testConstructDefaultUntrimmed()
87
+	{
88
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: ' 0.0.0.0.0'");
89
+
90
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= 0.0.0.0.0');
91
+	}
92
+
93
+	/**
94
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
95
+	 */
96
+	public function testConstructDefault()
97
+	{
98
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=123.45.67.89');
99
+
100
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
101
+
102
+		$this->assertSame(array(
103
+			'type' => 'string',
104
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
105
+			'default' => '123.45.67.89',
106
+		), $object->toArray());
107
+	}
108
+
109
+	/**
110
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand
111
+	 */
112
+	public function testCommandDefaultNoValue()
113
+	{
114
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
115
+
116
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
117
+
118
+		$this->expectException('\SwaggerGen\Exception', "Empty IPv4 default");
119
+		$object->handleCommand('default', '');
120
+	}
121
+
122
+	/**
123
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand
124
+	 */
125
+	public function testCommandDefault()
126
+	{
127
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
128
+
129
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
130
+
131
+		$object->handleCommand('default', '123.45.67.89');
132
+
133
+		$this->assertSame(array(
134
+			'type' => 'string',
135
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
136
+			'default' => '123.45.67.89',
137
+		), $object->toArray());
138
+	}
139 139
 
140 140
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/Custom/EmailTypeTest.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -3,118 +3,118 @@
 block discarded – undo
3 3
 class EmailTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
20
-     */
21
-    public function testConstructNotAnEmail()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not an email: 'wrong'");
24
-
25
-        new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
30
-     */
31
-    public function testConstruct()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'string',
39
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
45
-     */
46
-    public function testConstructEmptyDefault()
47
-    {
48
-        $this->expectException('\SwaggerGen\Exception', "Unparseable email definition: 'email='");
49
-
50
-        new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= ');
51
-    }
52
-
53
-    /**
54
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
55
-     */
56
-    public function testConstructDefaultDoubleAt()
57
-    {
58
-        $this->expectException('\SwaggerGen\Exception', "Invalid email default value: 'test@[email protected]'");
59
-
60
-        new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email=test@[email protected]');
61
-    }
62
-
63
-    /**
64
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
65
-     */
66
-    public function testConstructDefaultUntrimmed()
67
-    {
68
-        $this->expectException('\SwaggerGen\Exception', "Invalid email default value: ' [email protected]'");
69
-
70
-        new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= [email protected]');
71
-    }
72
-
73
-    /**
74
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
75
-     */
76
-    public function testConstructDefault()
77
-    {
78
-        $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, '[email protected]');
79
-
80
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
81
-
82
-        $this->assertSame(array(
83
-            'type' => 'string',
84
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
85
-            'default' => '[email protected]',
86
-        ), $object->toArray());
87
-    }
88
-
89
-    /**
90
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand
91
-     */
92
-    public function testCommandDefaultNoValue()
93
-    {
94
-        $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
95
-
96
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
97
-
98
-        $this->expectException('\SwaggerGen\Exception', "Empty email default");
99
-        $object->handleCommand('default', '');
100
-    }
101
-
102
-    /**
103
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand
104
-     */
105
-    public function testCommandDefault()
106
-    {
107
-        $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
108
-
109
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
110
-
111
-        $object->handleCommand('default', '[email protected]');
112
-
113
-        $this->assertSame(array(
114
-            'type' => 'string',
115
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
116
-            'default' => '[email protected]',
117
-        ), $object->toArray());
118
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
20
+	 */
21
+	public function testConstructNotAnEmail()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not an email: 'wrong'");
24
+
25
+		new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
30
+	 */
31
+	public function testConstruct()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'string',
39
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
45
+	 */
46
+	public function testConstructEmptyDefault()
47
+	{
48
+		$this->expectException('\SwaggerGen\Exception', "Unparseable email definition: 'email='");
49
+
50
+		new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= ');
51
+	}
52
+
53
+	/**
54
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
55
+	 */
56
+	public function testConstructDefaultDoubleAt()
57
+	{
58
+		$this->expectException('\SwaggerGen\Exception', "Invalid email default value: 'test@[email protected]'");
59
+
60
+		new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email=test@[email protected]');
61
+	}
62
+
63
+	/**
64
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
65
+	 */
66
+	public function testConstructDefaultUntrimmed()
67
+	{
68
+		$this->expectException('\SwaggerGen\Exception', "Invalid email default value: ' [email protected]'");
69
+
70
+		new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= [email protected]');
71
+	}
72
+
73
+	/**
74
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
75
+	 */
76
+	public function testConstructDefault()
77
+	{
78
+		$object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, '[email protected]');
79
+
80
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
81
+
82
+		$this->assertSame(array(
83
+			'type' => 'string',
84
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
85
+			'default' => '[email protected]',
86
+		), $object->toArray());
87
+	}
88
+
89
+	/**
90
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand
91
+	 */
92
+	public function testCommandDefaultNoValue()
93
+	{
94
+		$object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
95
+
96
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
97
+
98
+		$this->expectException('\SwaggerGen\Exception', "Empty email default");
99
+		$object->handleCommand('default', '');
100
+	}
101
+
102
+	/**
103
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand
104
+	 */
105
+	public function testCommandDefault()
106
+	{
107
+		$object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
108
+
109
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
110
+
111
+		$object->handleCommand('default', '[email protected]');
112
+
113
+		$this->assertSame(array(
114
+			'type' => 'string',
115
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
116
+			'default' => '[email protected]',
117
+		), $object->toArray());
118
+	}
119 119
 
120 120
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/Custom/MacTypeTest.php 1 patch
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -3,148 +3,148 @@
 block discarded – undo
3 3
 class MacTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
20
-     */
21
-    public function testConstructNotAnMac()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not a MAC: 'wrong'");
24
-
25
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
30
-     */
31
-    public function testConstruct()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'string',
39
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
45
-     */
46
-    public function testConstructEmptyDefault()
47
-    {
48
-        $this->expectException('\SwaggerGen\Exception', "Unparseable MAC definition: 'mac='");
49
-
50
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= ');
51
-    }
52
-
53
-    /**
54
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
55
-     */
56
-    public function testConstructDefaultTooFewBytes()
57
-    {
58
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF'");
59
-
60
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF');
61
-    }
62
-
63
-    /**
64
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
65
-     */
66
-    public function testConstructDefaultTooManyBytes()
67
-    {
68
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF:FF:FF'");
69
-
70
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF:FF');
71
-    }
72
-
73
-    /**
74
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
75
-     */
76
-    public function testConstructDefaultTooFewDigits()
77
-    {
78
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'F:FF:FF:FF:FF:FF'");
79
-
80
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=F:FF:FF:FF:FF:FF');
81
-    }
82
-
83
-    /**
84
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
85
-     */
86
-    public function testConstructDefaultTooManyDigits()
87
-    {
88
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FFF:FF:FF:FF:FF:FF'");
89
-
90
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FFF:FF:FF:FF:FF:FF');
91
-    }
92
-
93
-    /**
94
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
95
-     */
96
-    public function testConstructDefaultUntrimmed()
97
-    {
98
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: ' FF:FF:FF:FF:FF:FF'");
99
-
100
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= FF:FF:FF:FF:FF:FF');
101
-    }
102
-
103
-    /**
104
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
105
-     */
106
-    public function testConstructDefault()
107
-    {
108
-        $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF');
109
-
110
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
111
-
112
-        $this->assertSame(array(
113
-            'type' => 'string',
114
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
115
-            'default' => 'FF:FF:FF:FF:FF:FF',
116
-        ), $object->toArray());
117
-    }
118
-
119
-    /**
120
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand
121
-     */
122
-    public function testCommandDefaultNoValue()
123
-    {
124
-        $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
125
-
126
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
127
-
128
-        $this->expectException('\SwaggerGen\Exception', "Empty MAC default");
129
-        $object->handleCommand('default', '');
130
-    }
131
-
132
-    /**
133
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand
134
-     */
135
-    public function testCommandDefault()
136
-    {
137
-        $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
138
-
139
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
140
-
141
-        $object->handleCommand('default', 'FF:FF:FF:FF:FF:FF');
142
-
143
-        $this->assertSame(array(
144
-            'type' => 'string',
145
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
146
-            'default' => 'FF:FF:FF:FF:FF:FF',
147
-        ), $object->toArray());
148
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
20
+	 */
21
+	public function testConstructNotAnMac()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not a MAC: 'wrong'");
24
+
25
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
30
+	 */
31
+	public function testConstruct()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'string',
39
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
45
+	 */
46
+	public function testConstructEmptyDefault()
47
+	{
48
+		$this->expectException('\SwaggerGen\Exception', "Unparseable MAC definition: 'mac='");
49
+
50
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= ');
51
+	}
52
+
53
+	/**
54
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
55
+	 */
56
+	public function testConstructDefaultTooFewBytes()
57
+	{
58
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF'");
59
+
60
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF');
61
+	}
62
+
63
+	/**
64
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
65
+	 */
66
+	public function testConstructDefaultTooManyBytes()
67
+	{
68
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF:FF:FF'");
69
+
70
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF:FF');
71
+	}
72
+
73
+	/**
74
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
75
+	 */
76
+	public function testConstructDefaultTooFewDigits()
77
+	{
78
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'F:FF:FF:FF:FF:FF'");
79
+
80
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=F:FF:FF:FF:FF:FF');
81
+	}
82
+
83
+	/**
84
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
85
+	 */
86
+	public function testConstructDefaultTooManyDigits()
87
+	{
88
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FFF:FF:FF:FF:FF:FF'");
89
+
90
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FFF:FF:FF:FF:FF:FF');
91
+	}
92
+
93
+	/**
94
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
95
+	 */
96
+	public function testConstructDefaultUntrimmed()
97
+	{
98
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: ' FF:FF:FF:FF:FF:FF'");
99
+
100
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= FF:FF:FF:FF:FF:FF');
101
+	}
102
+
103
+	/**
104
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
105
+	 */
106
+	public function testConstructDefault()
107
+	{
108
+		$object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF');
109
+
110
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
111
+
112
+		$this->assertSame(array(
113
+			'type' => 'string',
114
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
115
+			'default' => 'FF:FF:FF:FF:FF:FF',
116
+		), $object->toArray());
117
+	}
118
+
119
+	/**
120
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand
121
+	 */
122
+	public function testCommandDefaultNoValue()
123
+	{
124
+		$object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
125
+
126
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
127
+
128
+		$this->expectException('\SwaggerGen\Exception', "Empty MAC default");
129
+		$object->handleCommand('default', '');
130
+	}
131
+
132
+	/**
133
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand
134
+	 */
135
+	public function testCommandDefault()
136
+	{
137
+		$object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
138
+
139
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
140
+
141
+		$object->handleCommand('default', 'FF:FF:FF:FF:FF:FF');
142
+
143
+		$this->assertSame(array(
144
+			'type' => 'string',
145
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
146
+			'default' => 'FF:FF:FF:FF:FF:FF',
147
+		), $object->toArray());
148
+	}
149 149
 
150 150
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/FileTypeTest.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -3,112 +3,112 @@
 block discarded – undo
3 3
 class FileTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = new \SwaggerGen\Swagger\Swagger;
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
20
-     */
21
-    public function testConstructNotAFile()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not a file: 'wrong'");
24
-
25
-        $object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
30
-     */
31
-    public function testConstructNotParameter()
32
-    {
33
-        $this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter");
34
-
35
-        $object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'file');
36
-    }
37
-
38
-    /**
39
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
40
-     */
41
-    public function testConstructNotFormParameter()
42
-    {
43
-        $this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter");
44
-
45
-        $parameter = new SwaggerGen\Swagger\Parameter($this->parent, 'query', 'long whatever');
46
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
47
-    }
48
-
49
-    /**
50
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
51
-     */
52
-    public function testConstructNoFormConsumes()
53
-    {
54
-        $this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume");
55
-
56
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
57
-        $operation->handleCommand('consumes', 'text');
58
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
59
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
60
-    }
61
-
62
-    /**
63
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
64
-     */
65
-    public function testConstructNotExclusiveFormConsumes()
66
-    {
67
-        $this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume");
68
-
69
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
70
-        $operation->handleCommand('consumes', 'text file');
71
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
72
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
73
-    }
74
-
75
-    /**
76
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
77
-     */
78
-    public function testConstructFormConsumes()
79
-    {
80
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
81
-        $operation->handleCommand('consumes', 'form');
82
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
83
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
84
-    }
85
-
86
-    /**
87
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
88
-     */
89
-    public function testConstructFileformConsumes()
90
-    {
91
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
92
-        $operation->handleCommand('consumes', 'fileform');
93
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
94
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
95
-    }
96
-
97
-    /**
98
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
99
-     */
100
-    public function testConstructBothConsumes()
101
-    {
102
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
103
-        $operation->handleCommand('consumes', 'fileform form');
104
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
105
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
106
-
107
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\FileType', $object);
108
-
109
-        $this->assertSame(array(
110
-            'type' => 'file',
111
-        ), $object->toArray());
112
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = new \SwaggerGen\Swagger\Swagger;
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
20
+	 */
21
+	public function testConstructNotAFile()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not a file: 'wrong'");
24
+
25
+		$object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
30
+	 */
31
+	public function testConstructNotParameter()
32
+	{
33
+		$this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter");
34
+
35
+		$object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'file');
36
+	}
37
+
38
+	/**
39
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
40
+	 */
41
+	public function testConstructNotFormParameter()
42
+	{
43
+		$this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter");
44
+
45
+		$parameter = new SwaggerGen\Swagger\Parameter($this->parent, 'query', 'long whatever');
46
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
47
+	}
48
+
49
+	/**
50
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
51
+	 */
52
+	public function testConstructNoFormConsumes()
53
+	{
54
+		$this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume");
55
+
56
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
57
+		$operation->handleCommand('consumes', 'text');
58
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
59
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
60
+	}
61
+
62
+	/**
63
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
64
+	 */
65
+	public function testConstructNotExclusiveFormConsumes()
66
+	{
67
+		$this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume");
68
+
69
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
70
+		$operation->handleCommand('consumes', 'text file');
71
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
72
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
73
+	}
74
+
75
+	/**
76
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
77
+	 */
78
+	public function testConstructFormConsumes()
79
+	{
80
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
81
+		$operation->handleCommand('consumes', 'form');
82
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
83
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
84
+	}
85
+
86
+	/**
87
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
88
+	 */
89
+	public function testConstructFileformConsumes()
90
+	{
91
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
92
+		$operation->handleCommand('consumes', 'fileform');
93
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
94
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
95
+	}
96
+
97
+	/**
98
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
99
+	 */
100
+	public function testConstructBothConsumes()
101
+	{
102
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
103
+		$operation->handleCommand('consumes', 'fileform form');
104
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
105
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
106
+
107
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\FileType', $object);
108
+
109
+		$this->assertSame(array(
110
+			'type' => 'file',
111
+		), $object->toArray());
112
+	}
113 113
 
114 114
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/ArrayTypeTest.php 1 patch
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -3,372 +3,372 @@
 block discarded – undo
3 3
 class ArrayTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
20
-     */
21
-    public function testConstructNotAArray()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not an array: 'wrong'");
24
-
25
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
30
-     */
31
-    public function testConstructInvalidDefault()
32
-    {
33
-        $this->expectException('\SwaggerGen\Exception', "Unparseable array definition: 'array=null'");
34
-
35
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array=null');
36
-    }
37
-
38
-    /**
39
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
40
-     */
41
-    public function testConstructMultiLimit()
42
-    {
43
-        $this->expectException('\SwaggerGen\Exception', "Multi array only allowed on query or form parameter: 'multi'");
44
-
45
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'multi');
46
-    }
47
-
48
-    /**
49
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
50
-     */
51
-    public function testConstructMultiOnFormParam()
52
-    {
53
-        $param = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'multi foo');
54
-
55
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $param);
56
-    }
57
-
58
-    /**
59
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
60
-     */
61
-    public function testConstructEmptyRange()
62
-    {
63
-        $this->expectException('\SwaggerGen\Exception', "Empty array range: 'array[,]'");
64
-
65
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[,]');
66
-    }
67
-
68
-    /**
69
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
70
-     */
71
-    public function testConstructRangeStart()
72
-    {
73
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[0,]');
74
-
75
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
76
-
77
-        $this->assertSame(array(
78
-            'type' => 'array',
79
-            'minItems' => 0,
80
-        ), $object->toArray());
81
-    }
82
-
83
-    /**
84
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
85
-     */
86
-    public function testConstructRangeBoth()
87
-    {
88
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array<2,4]');
89
-
90
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
91
-
92
-        $this->assertSame(array(
93
-            'type' => 'array',
94
-            'minItems' => 3,
95
-            'maxItems' => 4,
96
-        ), $object->toArray());
97
-    }
98
-
99
-    /**
100
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
101
-     */
102
-    public function testConstructEmptyItems()
103
-    {
104
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array()');
105
-
106
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
107
-
108
-        $this->assertSame(array(
109
-            'type' => 'array',
110
-        ), $object->toArray());
111
-    }
112
-
113
-    /**
114
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
115
-     */
116
-    public function testConstructBadItems()
117
-    {
118
-        $this->expectException('\SwaggerGen\Exception', "Unparseable items definition: '1'");
119
-
120
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(1)');
121
-    }
122
-
123
-    /**
124
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
125
-     */
126
-    public function testConstructTypeItems()
127
-    {
128
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(string)');
129
-
130
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
131
-
132
-        $this->assertSame(array(
133
-            'type' => 'array',
134
-            'items' => array(
135
-                'type' => 'string',
136
-            ),
137
-        ), $object->toArray());
138
-    }
139
-
140
-    /**
141
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
142
-     */
143
-    public function testConstructBracketsTypeItems()
144
-    {
145
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, '[string]');
146
-
147
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
148
-
149
-        $this->assertSame(array(
150
-            'type' => 'array',
151
-            'items' => array(
152
-                'type' => 'string',
153
-            ),
154
-        ), $object->toArray());
155
-    }
156
-
157
-    /**
158
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
159
-     */
160
-    public function testConstructTypeItemsPipes()
161
-    {
162
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'pipes(string)');
163
-
164
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
165
-
166
-        $this->assertSame(array(
167
-            'type' => 'array',
168
-            'items' => array(
169
-                'type' => 'string',
170
-            ),
171
-            'collectionFormat' => 'pipes',
172
-        ), $object->toArray());
173
-    }
174
-
175
-    /**
176
-     * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
177
-     */
178
-    public function testConstructReferenceItems()
179
-    {
180
-        $this->parent->handleCommand('model', 'Item');
181
-
182
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(Item)');
183
-
184
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
185
-
186
-        $this->assertSame(array(
187
-            'type' => 'array',
188
-            'items' => array(
189
-                '$ref' => '#/definitions/Item',
190
-            ),
191
-        ), $object->toArray());
192
-    }
193
-
194
-    /**
195
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
196
-     */
197
-    public function testCommandMinUpperBound()
198
-    {
199
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
200
-
201
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
202
-
203
-        $this->expectException('\SwaggerGen\Exception', "Minimum greater than maximum: '6'");
204
-
205
-        $object->handleCommand('min', '6');
206
-    }
207
-
208
-    /**
209
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
210
-     */
211
-    public function testCommandMinLowerBound()
212
-    {
213
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
214
-
215
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
216
-
217
-        $this->expectException('\SwaggerGen\Exception', "Minimum less than zero: '-1'");
218
-
219
-        $object->handleCommand('min', '-1');
220
-    }
221
-
222
-    /**
223
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
224
-     */
225
-    public function testCommandMin()
226
-    {
227
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
228
-
229
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
230
-
231
-        $object->handleCommand('min', '4');
232
-
233
-        $this->assertSame(array(
234
-            'type' => 'array',
235
-            'minItems' => 4,
236
-            'maxItems' => 5,
237
-        ), $object->toArray());
238
-    }
239
-
240
-    /**
241
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
242
-     */
243
-    public function testCommandMaxLowerBound()
244
-    {
245
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
20
+	 */
21
+	public function testConstructNotAArray()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not an array: 'wrong'");
24
+
25
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
30
+	 */
31
+	public function testConstructInvalidDefault()
32
+	{
33
+		$this->expectException('\SwaggerGen\Exception', "Unparseable array definition: 'array=null'");
34
+
35
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array=null');
36
+	}
37
+
38
+	/**
39
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
40
+	 */
41
+	public function testConstructMultiLimit()
42
+	{
43
+		$this->expectException('\SwaggerGen\Exception', "Multi array only allowed on query or form parameter: 'multi'");
44
+
45
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'multi');
46
+	}
47
+
48
+	/**
49
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
50
+	 */
51
+	public function testConstructMultiOnFormParam()
52
+	{
53
+		$param = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'multi foo');
54
+
55
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $param);
56
+	}
57
+
58
+	/**
59
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
60
+	 */
61
+	public function testConstructEmptyRange()
62
+	{
63
+		$this->expectException('\SwaggerGen\Exception', "Empty array range: 'array[,]'");
64
+
65
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[,]');
66
+	}
67
+
68
+	/**
69
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
70
+	 */
71
+	public function testConstructRangeStart()
72
+	{
73
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[0,]');
74
+
75
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
76
+
77
+		$this->assertSame(array(
78
+			'type' => 'array',
79
+			'minItems' => 0,
80
+		), $object->toArray());
81
+	}
82
+
83
+	/**
84
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
85
+	 */
86
+	public function testConstructRangeBoth()
87
+	{
88
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array<2,4]');
89
+
90
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
91
+
92
+		$this->assertSame(array(
93
+			'type' => 'array',
94
+			'minItems' => 3,
95
+			'maxItems' => 4,
96
+		), $object->toArray());
97
+	}
98
+
99
+	/**
100
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
101
+	 */
102
+	public function testConstructEmptyItems()
103
+	{
104
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array()');
105
+
106
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
107
+
108
+		$this->assertSame(array(
109
+			'type' => 'array',
110
+		), $object->toArray());
111
+	}
112
+
113
+	/**
114
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
115
+	 */
116
+	public function testConstructBadItems()
117
+	{
118
+		$this->expectException('\SwaggerGen\Exception', "Unparseable items definition: '1'");
119
+
120
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(1)');
121
+	}
122
+
123
+	/**
124
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
125
+	 */
126
+	public function testConstructTypeItems()
127
+	{
128
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(string)');
129
+
130
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
131
+
132
+		$this->assertSame(array(
133
+			'type' => 'array',
134
+			'items' => array(
135
+				'type' => 'string',
136
+			),
137
+		), $object->toArray());
138
+	}
139
+
140
+	/**
141
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
142
+	 */
143
+	public function testConstructBracketsTypeItems()
144
+	{
145
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, '[string]');
146
+
147
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
148
+
149
+		$this->assertSame(array(
150
+			'type' => 'array',
151
+			'items' => array(
152
+				'type' => 'string',
153
+			),
154
+		), $object->toArray());
155
+	}
156
+
157
+	/**
158
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
159
+	 */
160
+	public function testConstructTypeItemsPipes()
161
+	{
162
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'pipes(string)');
163
+
164
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
165
+
166
+		$this->assertSame(array(
167
+			'type' => 'array',
168
+			'items' => array(
169
+				'type' => 'string',
170
+			),
171
+			'collectionFormat' => 'pipes',
172
+		), $object->toArray());
173
+	}
174
+
175
+	/**
176
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct
177
+	 */
178
+	public function testConstructReferenceItems()
179
+	{
180
+		$this->parent->handleCommand('model', 'Item');
181
+
182
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(Item)');
183
+
184
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
185
+
186
+		$this->assertSame(array(
187
+			'type' => 'array',
188
+			'items' => array(
189
+				'$ref' => '#/definitions/Item',
190
+			),
191
+		), $object->toArray());
192
+	}
193
+
194
+	/**
195
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
196
+	 */
197
+	public function testCommandMinUpperBound()
198
+	{
199
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
200
+
201
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
202
+
203
+		$this->expectException('\SwaggerGen\Exception', "Minimum greater than maximum: '6'");
204
+
205
+		$object->handleCommand('min', '6');
206
+	}
207
+
208
+	/**
209
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
210
+	 */
211
+	public function testCommandMinLowerBound()
212
+	{
213
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
214
+
215
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
216
+
217
+		$this->expectException('\SwaggerGen\Exception', "Minimum less than zero: '-1'");
218
+
219
+		$object->handleCommand('min', '-1');
220
+	}
221
+
222
+	/**
223
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
224
+	 */
225
+	public function testCommandMin()
226
+	{
227
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
228
+
229
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
230
+
231
+		$object->handleCommand('min', '4');
232
+
233
+		$this->assertSame(array(
234
+			'type' => 'array',
235
+			'minItems' => 4,
236
+			'maxItems' => 5,
237
+		), $object->toArray());
238
+	}
239
+
240
+	/**
241
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
242
+	 */
243
+	public function testCommandMaxLowerBound()
244
+	{
245
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
246 246
 
247
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
248
-
249
-        $this->expectException('\SwaggerGen\Exception', "Maximum less than minimum: '2'");
250
-
251
-        $object->handleCommand('max', '2');
252
-    }
253
-
254
-    /**
255
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
256
-     */
257
-    public function testCommandMaxUpperBound()
258
-    {
259
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array');
260
-
261
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
247
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
248
+
249
+		$this->expectException('\SwaggerGen\Exception', "Maximum less than minimum: '2'");
250
+
251
+		$object->handleCommand('max', '2');
252
+	}
253
+
254
+	/**
255
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
256
+	 */
257
+	public function testCommandMaxUpperBound()
258
+	{
259
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array');
260
+
261
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
262 262
 
263
-        $this->expectException('\SwaggerGen\Exception', "Maximum less than zero: '-1'");
263
+		$this->expectException('\SwaggerGen\Exception', "Maximum less than zero: '-1'");
264 264
 
265
-        $object->handleCommand('max', '-1');
266
-    }
267
-
268
-    /**
269
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
270
-     */
271
-    public function testCommandMax()
272
-    {
273
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
265
+		$object->handleCommand('max', '-1');
266
+	}
267
+
268
+	/**
269
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
270
+	 */
271
+	public function testCommandMax()
272
+	{
273
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
274 274
 
275
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
276
-
277
-        $object->handleCommand('max', '4');
275
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
276
+
277
+		$object->handleCommand('max', '4');
278 278
 
279
-        $this->assertSame(array(
280
-            'type' => 'array',
281
-            'minItems' => 3,
282
-            'maxItems' => 4,
283
-        ), $object->toArray());
284
-    }
285
-
286
-    /**
287
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
288
-     */
289
-    public function testCommandEmptyItems()
290
-    {
291
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
279
+		$this->assertSame(array(
280
+			'type' => 'array',
281
+			'minItems' => 3,
282
+			'maxItems' => 4,
283
+		), $object->toArray());
284
+	}
285
+
286
+	/**
287
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
288
+	 */
289
+	public function testCommandEmptyItems()
290
+	{
291
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
292 292
 
293
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
293
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
294 294
 
295
-        $this->expectException('\SwaggerGen\Exception', "Empty items definition: ''");
295
+		$this->expectException('\SwaggerGen\Exception', "Empty items definition: ''");
296 296
 
297
-        $object->handleCommand('items', '');
298
-    }
297
+		$object->handleCommand('items', '');
298
+	}
299 299
 
300
-    /**
301
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
302
-     */
303
-    public function testCommandBadItems()
304
-    {
305
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
300
+	/**
301
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
302
+	 */
303
+	public function testCommandBadItems()
304
+	{
305
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]');
306 306
 
307
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
308
-
309
-        $this->expectException('\SwaggerGen\Exception', "Unparseable items definition: '1'");
307
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
308
+
309
+		$this->expectException('\SwaggerGen\Exception', "Unparseable items definition: '1'");
310 310
 
311
-        $object->handleCommand('items', '1');
312
-    }
311
+		$object->handleCommand('items', '1');
312
+	}
313 313
 
314
-    /**
315
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
316
-     */
317
-    public function testCommandTypeItems()
318
-    {
319
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array');
320
-
321
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
322
-
323
-        $object->handleCommand('items', 'string');
324
-
325
-        $this->assertSame(array(
326
-            'type' => 'array',
327
-            'items' => array(
328
-                'type' => 'string',
329
-            ),
330
-        ), $object->toArray());
331
-    }
332
-
333
-    /**
334
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
335
-     */
336
-    public function testCommandReferenceItems()
337
-    {
338
-        $this->parent->handleCommand('model', 'Item');
314
+	/**
315
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
316
+	 */
317
+	public function testCommandTypeItems()
318
+	{
319
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array');
320
+
321
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
322
+
323
+		$object->handleCommand('items', 'string');
324
+
325
+		$this->assertSame(array(
326
+			'type' => 'array',
327
+			'items' => array(
328
+				'type' => 'string',
329
+			),
330
+		), $object->toArray());
331
+	}
332
+
333
+	/**
334
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
335
+	 */
336
+	public function testCommandReferenceItems()
337
+	{
338
+		$this->parent->handleCommand('model', 'Item');
339 339
 
340
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array');
341
-
342
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
340
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array');
341
+
342
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
343 343
 
344
-        $object->handleCommand('items', 'Item');
344
+		$object->handleCommand('items', 'Item');
345 345
 
346
-        $this->assertSame(array(
347
-            'type' => 'array',
348
-            'items' => array(
349
-                '$ref' => '#/definitions/Item',
350
-            ),
351
-        ), $object->toArray());
352
-    }
353
-
354
-    /**
355
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
356
-     */
357
-    public function testCommandPassing()
358
-    {
359
-        $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(string)');
346
+		$this->assertSame(array(
347
+			'type' => 'array',
348
+			'items' => array(
349
+				'$ref' => '#/definitions/Item',
350
+			),
351
+		), $object->toArray());
352
+	}
353
+
354
+	/**
355
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
356
+	 */
357
+	public function testCommandPassing()
358
+	{
359
+		$object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(string)');
360 360
 
361
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
361
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object);
362 362
 
363
-        $object->handleCommand('default', 'good');
364
-
365
-        $this->assertSame(array(
366
-            'type' => 'array',
367
-            'items' => array(
368
-                'type' => 'string',
369
-                'default' => 'good',
370
-            ),
371
-        ), $object->toArray());
372
-    }
363
+		$object->handleCommand('default', 'good');
364
+
365
+		$this->assertSame(array(
366
+			'type' => 'array',
367
+			'items' => array(
368
+				'type' => 'string',
369
+				'default' => 'good',
370
+			),
371
+		), $object->toArray());
372
+	}
373 373
 
374 374
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/IntegerTypeTest.php 1 patch
Indentation   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -3,358 +3,358 @@
 block discarded – undo
3 3
 class IntegerTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
20
-     */
21
-    public function testConstructNotAInteger()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not an integer: 'wrong'");
24
-
25
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
30
-     */
31
-    public function testConstructInvalidDefault()
32
-    {
33
-        $this->expectException('\SwaggerGen\Exception', "Unparseable integer definition: 'integer=null'");
34
-
35
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=null');
36
-    }
37
-
38
-    /**
39
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
40
-     */
41
-    public function testConstructNoSpecificationAllowed()
42
-    {
43
-        $this->expectException('\SwaggerGen\Exception', "Unparseable integer definition: 'integer()=1'");
44
-
45
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer()=1');
46
-    }
47
-
48
-    /**
49
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
50
-     */
51
-    public function testConstructEmptyRange()
52
-    {
53
-        $this->expectException('\SwaggerGen\Exception', "Empty integer range: 'integer[,]=1'");
54
-
55
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[,]=1');
56
-    }
57
-
58
-    /**
59
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
60
-     */
61
-    public function testConstructNotEmptyRange()
62
-    {
63
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'int[0,]');
64
-
65
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
66
-
67
-        $this->assertSame(array(
68
-            'type' => 'integer',
69
-            'format' => 'int32',
70
-            'minimum' => 0,
71
-        ), $object->toArray());
72
-    }
73
-
74
-    /**
75
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
76
-     */
77
-    public function testConstructInteger()
78
-    {
79
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
80
-
81
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
82
-
83
-        $this->assertSame(array(
84
-            'type' => 'integer',
85
-            'format' => 'int32',
86
-        ), $object->toArray());
87
-    }
88
-
89
-    /**
90
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
91
-     */
92
-    public function testConstructLong()
93
-    {
94
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'long');
95
-
96
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
97
-
98
-        $this->assertSame(array(
99
-            'type' => 'integer',
100
-            'format' => 'int64',
101
-        ), $object->toArray());
102
-    }
103
-
104
-    /**
105
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
106
-     */
107
-    public function testConstructZero()
108
-    {
109
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=0');
110
-
111
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
112
-
113
-        $this->assertSame(array(
114
-            'type' => 'integer',
115
-            'format' => 'int32',
116
-            'default' => 0,
117
-        ), $object->toArray());
118
-    }
119
-
120
-    /**
121
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
122
-     */
123
-    public function testConstructPositive()
124
-    {
125
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=1');
126
-
127
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
128
-
129
-        $this->assertSame(array(
130
-            'type' => 'integer',
131
-            'format' => 'int32',
132
-            'default' => 1,
133
-        ), $object->toArray());
134
-    }
135
-
136
-    /**
137
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
138
-     */
139
-    public function testConstructNegative()
140
-    {
141
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=-1');
142
-
143
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
144
-
145
-        $this->assertSame(array(
146
-            'type' => 'integer',
147
-            'format' => 'int32',
148
-            'default' => -1,
149
-        ), $object->toArray());
150
-    }
151
-
152
-    /**
153
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
154
-     */
155
-    public function testConstructRangeInclusive()
156
-    {
157
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=3');
158
-
159
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
160
-
161
-        $this->assertSame(array(
162
-            'type' => 'integer',
163
-            'format' => 'int32',
164
-            'default' => 3,
165
-            'minimum' => 2,
166
-            'maximum' => 5,
167
-        ), $object->toArray());
168
-    }
169
-
170
-    /**
171
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
172
-     */
173
-    public function testConstructRangeExclusive()
174
-    {
175
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=3');
176
-
177
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
178
-
179
-        $this->assertSame(array(
180
-            'type' => 'integer',
181
-            'format' => 'int32',
182
-            'default' => 3,
183
-            'minimum' => 2,
184
-            'exclusiveMinimum' => true,
185
-            'maximum' => 5,
186
-            'exclusiveMaximum' => true,
187
-        ), $object->toArray());
188
-    }
189
-
190
-    /**
191
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
192
-     */
193
-    public function testConstructDefaultBeyondMaximumExclusive()
194
-    {
195
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=4');
196
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
197
-
198
-        $this->expectException('\SwaggerGen\Exception', "Default integer beyond maximum: '5'");
199
-
200
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=5');
201
-    }
202
-
203
-    /**
204
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
205
-     */
206
-    public function testConstructDefaultBeyondMaximum()
207
-    {
208
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=5');
209
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
210
-
211
-        $this->expectException('\SwaggerGen\Exception', "Default integer beyond maximum: '6'");
212
-
213
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=6');
214
-    }
215
-
216
-    /**
217
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
218
-     */
219
-    public function testConstructDefaultBeyondMinimumExclusive()
220
-    {
221
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=3');
222
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
223
-
224
-        $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '2'");
225
-
226
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=2');
227
-    }
228
-
229
-    /**
230
-     * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
231
-     */
232
-    public function testConstructDefaultBeyondMinimum()
233
-    {
234
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=2');
235
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
236
-
237
-        $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '1'");
238
-
239
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=1');
240
-    }
241
-
242
-    /**
243
-     * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
244
-     */
245
-    public function testCommandDefaultNoValue()
246
-    {
247
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
248
-
249
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
250
-
251
-        $this->expectException('\SwaggerGen\Exception', "Invalid integer default: ''");
252
-        $object->handleCommand('default', '');
253
-    }
254
-
255
-    /**
256
-     * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
257
-     */
258
-    public function testCommandDefaultInvalidValue()
259
-    {
260
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
261
-
262
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
263
-
264
-        $this->expectException('\SwaggerGen\Exception', "Invalid integer default: 'foo'");
265
-        $object->handleCommand('default', 'foo');
266
-    }
267
-
268
-    /**
269
-     * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
270
-     */
271
-    public function testCommandDefaultPositive()
272
-    {
273
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
274
-
275
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
276
-
277
-        $object->handleCommand('default', '123');
278
-
279
-        $this->assertSame(array(
280
-            'type' => 'integer',
281
-            'format' => 'int32',
282
-            'default' => 123,
283
-        ), $object->toArray());
284
-    }
285
-
286
-    /**
287
-     * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
288
-     */
289
-    public function testCommandDefaultNegative()
290
-    {
291
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
292
-
293
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
294
-
295
-        $object->handleCommand('default', '-123');
296
-
297
-        $this->assertSame(array(
298
-            'type' => 'integer',
299
-            'format' => 'int32',
300
-            'default' => -123,
301
-        ), $object->toArray());
302
-    }
303
-
304
-    /**
305
-     * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
306
-     */
307
-    public function testCommandDefaultBeyondRange()
308
-    {
309
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[-100,100]');
310
-
311
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
312
-
313
-        $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '-123'");
314
-        $object->handleCommand('default', '-123');
315
-    }
316
-
317
-    /**
318
-     * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
319
-     */
320
-    public function testCommandEnum()
321
-    {
322
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
323
-
324
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
325
-
326
-        $object->handleCommand('enum', '-1 2 123');
327
-        $object->handleCommand('enum', '-123 0');
328
-
329
-        $this->assertEquals(array(
330
-            'type' => 'integer',
331
-            'format' => 'int32',
332
-            'enum' => array(
333
-                -1,
334
-                2,
335
-                123,
336
-                -123,
337
-                0,
338
-            ),
339
-        ), $object->toArray());
340
-    }
341
-
342
-    /**
343
-     * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
344
-     */
345
-    public function testCommandStep()
346
-    {
347
-        $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
348
-
349
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
350
-
351
-        $object->handleCommand('step', '3');
352
-
353
-        $this->assertEquals(array(
354
-            'type' => 'integer',
355
-            'format' => 'int32',
356
-            'multipleOf' => 3,
357
-        ), $object->toArray());
358
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
20
+	 */
21
+	public function testConstructNotAInteger()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not an integer: 'wrong'");
24
+
25
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
30
+	 */
31
+	public function testConstructInvalidDefault()
32
+	{
33
+		$this->expectException('\SwaggerGen\Exception', "Unparseable integer definition: 'integer=null'");
34
+
35
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=null');
36
+	}
37
+
38
+	/**
39
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
40
+	 */
41
+	public function testConstructNoSpecificationAllowed()
42
+	{
43
+		$this->expectException('\SwaggerGen\Exception', "Unparseable integer definition: 'integer()=1'");
44
+
45
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer()=1');
46
+	}
47
+
48
+	/**
49
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
50
+	 */
51
+	public function testConstructEmptyRange()
52
+	{
53
+		$this->expectException('\SwaggerGen\Exception', "Empty integer range: 'integer[,]=1'");
54
+
55
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[,]=1');
56
+	}
57
+
58
+	/**
59
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
60
+	 */
61
+	public function testConstructNotEmptyRange()
62
+	{
63
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'int[0,]');
64
+
65
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
66
+
67
+		$this->assertSame(array(
68
+			'type' => 'integer',
69
+			'format' => 'int32',
70
+			'minimum' => 0,
71
+		), $object->toArray());
72
+	}
73
+
74
+	/**
75
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
76
+	 */
77
+	public function testConstructInteger()
78
+	{
79
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
80
+
81
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
82
+
83
+		$this->assertSame(array(
84
+			'type' => 'integer',
85
+			'format' => 'int32',
86
+		), $object->toArray());
87
+	}
88
+
89
+	/**
90
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
91
+	 */
92
+	public function testConstructLong()
93
+	{
94
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'long');
95
+
96
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
97
+
98
+		$this->assertSame(array(
99
+			'type' => 'integer',
100
+			'format' => 'int64',
101
+		), $object->toArray());
102
+	}
103
+
104
+	/**
105
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
106
+	 */
107
+	public function testConstructZero()
108
+	{
109
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=0');
110
+
111
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
112
+
113
+		$this->assertSame(array(
114
+			'type' => 'integer',
115
+			'format' => 'int32',
116
+			'default' => 0,
117
+		), $object->toArray());
118
+	}
119
+
120
+	/**
121
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
122
+	 */
123
+	public function testConstructPositive()
124
+	{
125
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=1');
126
+
127
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
128
+
129
+		$this->assertSame(array(
130
+			'type' => 'integer',
131
+			'format' => 'int32',
132
+			'default' => 1,
133
+		), $object->toArray());
134
+	}
135
+
136
+	/**
137
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
138
+	 */
139
+	public function testConstructNegative()
140
+	{
141
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=-1');
142
+
143
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
144
+
145
+		$this->assertSame(array(
146
+			'type' => 'integer',
147
+			'format' => 'int32',
148
+			'default' => -1,
149
+		), $object->toArray());
150
+	}
151
+
152
+	/**
153
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
154
+	 */
155
+	public function testConstructRangeInclusive()
156
+	{
157
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=3');
158
+
159
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
160
+
161
+		$this->assertSame(array(
162
+			'type' => 'integer',
163
+			'format' => 'int32',
164
+			'default' => 3,
165
+			'minimum' => 2,
166
+			'maximum' => 5,
167
+		), $object->toArray());
168
+	}
169
+
170
+	/**
171
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
172
+	 */
173
+	public function testConstructRangeExclusive()
174
+	{
175
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=3');
176
+
177
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
178
+
179
+		$this->assertSame(array(
180
+			'type' => 'integer',
181
+			'format' => 'int32',
182
+			'default' => 3,
183
+			'minimum' => 2,
184
+			'exclusiveMinimum' => true,
185
+			'maximum' => 5,
186
+			'exclusiveMaximum' => true,
187
+		), $object->toArray());
188
+	}
189
+
190
+	/**
191
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
192
+	 */
193
+	public function testConstructDefaultBeyondMaximumExclusive()
194
+	{
195
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=4');
196
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
197
+
198
+		$this->expectException('\SwaggerGen\Exception', "Default integer beyond maximum: '5'");
199
+
200
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=5');
201
+	}
202
+
203
+	/**
204
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
205
+	 */
206
+	public function testConstructDefaultBeyondMaximum()
207
+	{
208
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=5');
209
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
210
+
211
+		$this->expectException('\SwaggerGen\Exception', "Default integer beyond maximum: '6'");
212
+
213
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=6');
214
+	}
215
+
216
+	/**
217
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
218
+	 */
219
+	public function testConstructDefaultBeyondMinimumExclusive()
220
+	{
221
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=3');
222
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
223
+
224
+		$this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '2'");
225
+
226
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=2');
227
+	}
228
+
229
+	/**
230
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct
231
+	 */
232
+	public function testConstructDefaultBeyondMinimum()
233
+	{
234
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=2');
235
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
236
+
237
+		$this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '1'");
238
+
239
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=1');
240
+	}
241
+
242
+	/**
243
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
244
+	 */
245
+	public function testCommandDefaultNoValue()
246
+	{
247
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
248
+
249
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
250
+
251
+		$this->expectException('\SwaggerGen\Exception', "Invalid integer default: ''");
252
+		$object->handleCommand('default', '');
253
+	}
254
+
255
+	/**
256
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
257
+	 */
258
+	public function testCommandDefaultInvalidValue()
259
+	{
260
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
261
+
262
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
263
+
264
+		$this->expectException('\SwaggerGen\Exception', "Invalid integer default: 'foo'");
265
+		$object->handleCommand('default', 'foo');
266
+	}
267
+
268
+	/**
269
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
270
+	 */
271
+	public function testCommandDefaultPositive()
272
+	{
273
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
274
+
275
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
276
+
277
+		$object->handleCommand('default', '123');
278
+
279
+		$this->assertSame(array(
280
+			'type' => 'integer',
281
+			'format' => 'int32',
282
+			'default' => 123,
283
+		), $object->toArray());
284
+	}
285
+
286
+	/**
287
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
288
+	 */
289
+	public function testCommandDefaultNegative()
290
+	{
291
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
292
+
293
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
294
+
295
+		$object->handleCommand('default', '-123');
296
+
297
+		$this->assertSame(array(
298
+			'type' => 'integer',
299
+			'format' => 'int32',
300
+			'default' => -123,
301
+		), $object->toArray());
302
+	}
303
+
304
+	/**
305
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
306
+	 */
307
+	public function testCommandDefaultBeyondRange()
308
+	{
309
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[-100,100]');
310
+
311
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
312
+
313
+		$this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '-123'");
314
+		$object->handleCommand('default', '-123');
315
+	}
316
+
317
+	/**
318
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
319
+	 */
320
+	public function testCommandEnum()
321
+	{
322
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
323
+
324
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
325
+
326
+		$object->handleCommand('enum', '-1 2 123');
327
+		$object->handleCommand('enum', '-123 0');
328
+
329
+		$this->assertEquals(array(
330
+			'type' => 'integer',
331
+			'format' => 'int32',
332
+			'enum' => array(
333
+				-1,
334
+				2,
335
+				123,
336
+				-123,
337
+				0,
338
+			),
339
+		), $object->toArray());
340
+	}
341
+
342
+	/**
343
+	 * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand
344
+	 */
345
+	public function testCommandStep()
346
+	{
347
+		$object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer');
348
+
349
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object);
350
+
351
+		$object->handleCommand('step', '3');
352
+
353
+		$this->assertEquals(array(
354
+			'type' => 'integer',
355
+			'format' => 'int32',
356
+			'multipleOf' => 3,
357
+		), $object->toArray());
358
+	}
359 359
 
360 360
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/BooleanTypeTest.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -3,160 +3,160 @@
 block discarded – undo
3 3
 class BooleanTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
20
-     */
21
-    public function testConstructNotABoolean()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not a boolean: 'wrong'");
24
-
25
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
30
-     */
31
-    public function testConstructInvalidDefault()
32
-    {
33
-        $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean=null'");
34
-
35
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=null');
36
-    }
37
-
38
-    /**
39
-     * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
40
-     */
41
-    public function testConstructNoSpecificationAllowed()
42
-    {
43
-        $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean()=true'");
44
-
45
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean()=true');
46
-    }
47
-
48
-    /**
49
-     * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
50
-     */
51
-    public function testConstructNoRangeAllowed()
52
-    {
53
-        $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean[0,1]=true'");
54
-
55
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean[0,1]=true');
56
-    }
57
-
58
-    /**
59
-     * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
60
-     */
61
-    public function testConstructWithoutDefault()
62
-    {
63
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
64
-
65
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
66
-
67
-        $this->assertSame(array(
68
-            'type' => 'boolean',
69
-        ), $object->toArray());
70
-    }
71
-
72
-    /**
73
-     * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
74
-     */
75
-    public function testConstructTrue()
76
-    {
77
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=true');
78
-
79
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
80
-
81
-        $this->assertSame(array(
82
-            'type' => 'boolean',
83
-            'default' => true,
84
-        ), $object->toArray());
85
-    }
86
-
87
-    /**
88
-     * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
89
-     */
90
-    public function testConstruct0()
91
-    {
92
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=0');
93
-
94
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
95
-
96
-        $this->assertSame(array(
97
-            'type' => 'boolean',
98
-            'default' => false,
99
-        ), $object->toArray());
100
-    }
101
-
102
-    /**
103
-     * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand
104
-     */
105
-    public function testCommandDefaultNoValue()
106
-    {
107
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
108
-
109
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
110
-
111
-        $this->expectException('\SwaggerGen\Exception', "Invalid boolean default: ''");
112
-        $object->handleCommand('default', '');
113
-    }
114
-
115
-    /**
116
-     * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand
117
-     */
118
-    public function testCommandDefaultInvalidValue()
119
-    {
120
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
121
-
122
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
123
-
124
-        $this->expectException('\SwaggerGen\Exception', "Invalid boolean default: 'null'");
125
-        $object->handleCommand('default', 'null');
126
-    }
127
-
128
-    /**
129
-     * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand
130
-     */
131
-    public function testCommandDefaultFalse()
132
-    {
133
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
134
-
135
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
136
-
137
-        $object->handleCommand('default', 'false');
138
-
139
-        $this->assertSame(array(
140
-            'type' => 'boolean',
141
-            'default' => false,
142
-        ), $object->toArray());
143
-    }
144
-
145
-    /**
146
-     * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand
147
-     */
148
-    public function testCommandDefault1()
149
-    {
150
-        $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
151
-
152
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
153
-
154
-        $object->handleCommand('default', '1');
155
-
156
-        $this->assertSame(array(
157
-            'type' => 'boolean',
158
-            'default' => true,
159
-        ), $object->toArray());
160
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
20
+	 */
21
+	public function testConstructNotABoolean()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not a boolean: 'wrong'");
24
+
25
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
30
+	 */
31
+	public function testConstructInvalidDefault()
32
+	{
33
+		$this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean=null'");
34
+
35
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=null');
36
+	}
37
+
38
+	/**
39
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
40
+	 */
41
+	public function testConstructNoSpecificationAllowed()
42
+	{
43
+		$this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean()=true'");
44
+
45
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean()=true');
46
+	}
47
+
48
+	/**
49
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
50
+	 */
51
+	public function testConstructNoRangeAllowed()
52
+	{
53
+		$this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean[0,1]=true'");
54
+
55
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean[0,1]=true');
56
+	}
57
+
58
+	/**
59
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
60
+	 */
61
+	public function testConstructWithoutDefault()
62
+	{
63
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
64
+
65
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
66
+
67
+		$this->assertSame(array(
68
+			'type' => 'boolean',
69
+		), $object->toArray());
70
+	}
71
+
72
+	/**
73
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
74
+	 */
75
+	public function testConstructTrue()
76
+	{
77
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=true');
78
+
79
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
80
+
81
+		$this->assertSame(array(
82
+			'type' => 'boolean',
83
+			'default' => true,
84
+		), $object->toArray());
85
+	}
86
+
87
+	/**
88
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct
89
+	 */
90
+	public function testConstruct0()
91
+	{
92
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=0');
93
+
94
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
95
+
96
+		$this->assertSame(array(
97
+			'type' => 'boolean',
98
+			'default' => false,
99
+		), $object->toArray());
100
+	}
101
+
102
+	/**
103
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand
104
+	 */
105
+	public function testCommandDefaultNoValue()
106
+	{
107
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
108
+
109
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
110
+
111
+		$this->expectException('\SwaggerGen\Exception', "Invalid boolean default: ''");
112
+		$object->handleCommand('default', '');
113
+	}
114
+
115
+	/**
116
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand
117
+	 */
118
+	public function testCommandDefaultInvalidValue()
119
+	{
120
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
121
+
122
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
123
+
124
+		$this->expectException('\SwaggerGen\Exception', "Invalid boolean default: 'null'");
125
+		$object->handleCommand('default', 'null');
126
+	}
127
+
128
+	/**
129
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand
130
+	 */
131
+	public function testCommandDefaultFalse()
132
+	{
133
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
134
+
135
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
136
+
137
+		$object->handleCommand('default', 'false');
138
+
139
+		$this->assertSame(array(
140
+			'type' => 'boolean',
141
+			'default' => false,
142
+		), $object->toArray());
143
+	}
144
+
145
+	/**
146
+	 * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand
147
+	 */
148
+	public function testCommandDefault1()
149
+	{
150
+		$object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean');
151
+
152
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object);
153
+
154
+		$object->handleCommand('default', '1');
155
+
156
+		$this->assertSame(array(
157
+			'type' => 'boolean',
158
+			'default' => true,
159
+		), $object->toArray());
160
+	}
161 161
 
162 162
 }
Please login to merge, or discard this patch.
tests/Swagger/SecuritySchemeTest.php 1 patch
Indentation   +490 added lines, -490 removed lines patch added patch discarded remove patch
@@ -3,495 +3,495 @@
 block discarded – undo
3 3
 class SecuritySchemeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
20
-     */
21
-    public function testConstructor_UnknownType()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'");
24
-
25
-        new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
30
-     */
31
-    public function testConstructor_Basic()
32
-    {
33
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'basic',
39
-        ), $object->toArray());
40
-    }
41
-
42
-    /**
43
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
44
-     */
45
-    public function testConstructor_BasicDescription()
46
-    {
47
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text');
48
-
49
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
50
-
51
-        $this->assertSame(array(
52
-            'type' => 'basic',
53
-            'description' => 'Some text',
54
-        ), $object->toArray());
55
-    }
56
-
57
-    /**
58
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
59
-     */
60
-    public function testConstructor_ApiKeyNoName()
61
-    {
62
-        $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"
63
-        );
64
-
65
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey');
66
-    }
67
-
68
-    /**
69
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
70
-     */
71
-    public function testConstructor_ApiKeyNoIn()
72
-    {
73
-        $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''");
74
-
75
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name');
76
-    }
77
-
78
-    /**
79
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
80
-     */
81
-    public function testConstructor_ApiKeyWrongIn()
82
-    {
83
-        $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'");
84
-
85
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad');
86
-    }
87
-
88
-    /**
89
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
90
-     */
91
-    public function testConstructor_ApiKey()
92
-    {
93
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query');
94
-
95
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
96
-
97
-        $this->assertSame(array(
98
-            'type' => 'apiKey',
99
-            'name' => 'Name',
100
-            'in' => 'query',
101
-        ), $object->toArray());
102
-    }
103
-
104
-    /**
105
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
106
-     */
107
-    public function testConstructor_ApiKeyDescription()
108
-    {
109
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words');
110
-
111
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
112
-
113
-        $this->assertSame(array(
114
-            'type' => 'apiKey',
115
-            'description' => 'Some words',
116
-            'name' => 'Name',
117
-            'in' => 'query',
118
-        ), $object->toArray());
119
-    }
120
-
121
-    /**
122
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
123
-     */
124
-    public function testConstructor_Oauth2NoFlow()
125
-    {
126
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''");
127
-
128
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2');
129
-    }
130
-
131
-    /**
132
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
133
-     */
134
-    public function testConstructor_Oauth2WrongFlow()
135
-    {
136
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'");
137
-
138
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow');
139
-    }
140
-
141
-    /**
142
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
143
-     */
144
-    public function testConstructor_Oauth2ImplicitNoUrl()
145
-    {
146
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''");
147
-
148
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit');
149
-    }
150
-
151
-    /**
152
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
153
-     */
154
-    public function testConstructor_Oauth2ImplicitBadUrl()
155
-    {
156
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'");
157
-
158
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad');
159
-    }
160
-
161
-    /**
162
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
163
-     */
164
-    public function testConstructor_Oauth2ImplicitUrl()
165
-    {
166
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test');
167
-
168
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
169
-
170
-        $this->assertSame(array(
171
-            'type' => 'oauth2',
172
-            'flow' => 'implicit',
173
-            'authorizationUrl' => 'http://www.test',
174
-        ), $object->toArray());
175
-    }
176
-
177
-    /**
178
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
179
-     */
180
-    public function testConstructor_Oauth2ImplicitUrlDescription()
181
-    {
182
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words');
183
-
184
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
185
-
186
-        $this->assertSame(array(
187
-            'type' => 'oauth2',
188
-            'description' => 'Some words',
189
-            'flow' => 'implicit',
190
-            'authorizationUrl' => 'http://www.test',
191
-        ), $object->toArray());
192
-    }
193
-
194
-    /**
195
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
196
-     */
197
-    public function testConstructor_Oauth2PasswordNoUrl()
198
-    {
199
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
200
-
201
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password');
202
-    }
203
-
204
-    /**
205
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
206
-     */
207
-    public function testConstructor_Oauth2PasswordBadUrl()
208
-    {
209
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
210
-
211
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad');
212
-    }
213
-
214
-    /**
215
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
216
-     */
217
-    public function testConstructor_Oauth2Password()
218
-    {
219
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test');
220
-
221
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
222
-
223
-        $this->assertSame(array(
224
-            'type' => 'oauth2',
225
-            'flow' => 'password',
226
-            'tokenUrl' => 'http://token.test',
227
-        ), $object->toArray());
228
-    }
229
-
230
-    /**
231
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
232
-     */
233
-    public function testConstructor_Oauth2PasswordDescription()
234
-    {
235
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words');
236
-
237
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
238
-
239
-        $this->assertSame(array(
240
-            'type' => 'oauth2',
241
-            'description' => 'Some words',
242
-            'flow' => 'password',
243
-            'tokenUrl' => 'http://token.test',
244
-        ), $object->toArray());
245
-    }
246
-
247
-    /**
248
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
249
-     */
250
-    public function testConstructor_Oauth2ApplicationNoUrl()
251
-    {
252
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
253
-
254
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application');
255
-    }
256
-
257
-    /**
258
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
259
-     */
260
-    public function testConstructor_Oauth2ApplicationBadUrl()
261
-    {
262
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
263
-
264
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad');
265
-    }
266
-
267
-    /**
268
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
269
-     */
270
-    public function testConstructor_Oauth2Application()
271
-    {
272
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test');
273
-
274
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
275
-
276
-        $this->assertSame(array(
277
-            'type' => 'oauth2',
278
-            'flow' => 'application',
279
-            'tokenUrl' => 'http://token.test',
280
-        ), $object->toArray());
281
-    }
282
-
283
-    /**
284
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
285
-     */
286
-    public function testConstructor_Oauth2ApplicationDescription()
287
-    {
288
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words');
289
-
290
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
291
-
292
-        $this->assertSame(array(
293
-            'type' => 'oauth2',
294
-            'description' => 'Some words',
295
-            'flow' => 'application',
296
-            'tokenUrl' => 'http://token.test',
297
-        ), $object->toArray());
298
-    }
299
-
300
-
301
-    /**
302
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
303
-     */
304
-    public function testConstructor_Oauth2AccesscodeNoUrl1()
305
-    {
306
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''");
307
-
308
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode');
309
-    }
310
-
311
-    /**
312
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
313
-     */
314
-    public function testConstructor_Oauth2AccesscodeBadUrl1()
315
-    {
316
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'");
317
-
318
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad');
319
-    }
320
-
321
-    /**
322
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
323
-     */
324
-    public function testConstructor_Oauth2AccesscodeNoUrl2()
325
-    {
326
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
327
-
328
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test');
329
-    }
330
-
331
-    /**
332
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
333
-     */
334
-    public function testConstructor_Oauth2AccesscodeBadUrl2()
335
-    {
336
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
337
-
338
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad');
339
-    }
340
-
341
-    /**
342
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
343
-     */
344
-    public function testConstructor_Oauth2Accesscode()
345
-    {
346
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
347
-
348
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
349
-
350
-        $this->assertSame(array(
351
-            'type' => 'oauth2',
352
-            'flow' => 'accessCode',
353
-            'authorizationUrl' => 'http://auth.test',
354
-            'tokenUrl' => 'http://token.test',
355
-        ), $object->toArray());
356
-    }
357
-
358
-    /**
359
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
360
-     */
361
-    public function testConstructor_Oauth2AccesscodeDescription()
362
-    {
363
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode  http://auth.test http://token.test Some words');
364
-
365
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
366
-
367
-        $this->assertSame(array(
368
-            'type' => 'oauth2',
369
-            'description' => 'Some words',
370
-            'flow' => 'accessCode',
371
-            'authorizationUrl' => 'http://auth.test',
372
-            'tokenUrl' => 'http://token.test',
373
-        ), $object->toArray());
374
-    }
375
-
376
-    /**
377
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
378
-     */
379
-    public function testCommandDescription()
380
-    {
381
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
382
-
383
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
384
-
385
-        $object->handleCommand('description', 'Some words');
386
-
387
-        $this->assertSame(array(
388
-            'type' => 'oauth2',
389
-            'description' => 'Some words',
390
-            'flow' => 'accessCode',
391
-            'authorizationUrl' => 'http://auth.test',
392
-            'tokenUrl' => 'http://token.test',
393
-        ), $object->toArray());
394
-    }
395
-
396
-    /**
397
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
398
-     */
399
-    public function testCommandDescriptionEmpty()
400
-    {
401
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words');
402
-
403
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
404
-
405
-        $object->handleCommand('description', '');
406
-
407
-        $this->assertSame(array(
408
-            'type' => 'oauth2',
409
-            'flow' => 'accessCode',
410
-            'authorizationUrl' => 'http://auth.test',
411
-            'tokenUrl' => 'http://token.test',
412
-        ), $object->toArray());
413
-    }
414
-
415
-    /**
416
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
417
-     */
418
-    public function testCommandScopeNotOauth()
419
-    {
420
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic');
421
-
422
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
423
-
424
-        $this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'");
425
-
426
-        $object->handleCommand('scope', 'scope1');
427
-    }
428
-
429
-    /**
430
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
431
-     */
432
-    public function testCommandScope()
433
-    {
434
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
435
-
436
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
437
-
438
-        $object->handleCommand('scope', 'scope1');
439
-
440
-        $this->assertSame(array(
441
-            'type' => 'oauth2',
442
-            'flow' => 'accessCode',
443
-            'authorizationUrl' => 'http://auth.test',
444
-            'tokenUrl' => 'http://token.test',
445
-            'scopes' => array(
446
-                'scope1' => '',
447
-            )
448
-        ), $object->toArray());
449
-    }
450
-
451
-    /**
452
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
453
-     */
454
-    public function testCommandScopeDescription()
455
-    {
456
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
457
-
458
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
459
-
460
-        $object->handleCommand('scope', 'scope1 Some text');
461
-
462
-        $this->assertSame(array(
463
-            'type' => 'oauth2',
464
-            'flow' => 'accessCode',
465
-            'authorizationUrl' => 'http://auth.test',
466
-            'tokenUrl' => 'http://token.test',
467
-            'scopes' => array(
468
-                'scope1' => 'Some text',
469
-            )
470
-        ), $object->toArray());
471
-    }
472
-
473
-    /**
474
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
475
-     */
476
-    public function testCommandScopes()
477
-    {
478
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
479
-
480
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
481
-
482
-        $object->handleCommand('scope', 'scope2 Some text');
483
-        $object->handleCommand('scope', 'scope1 Some text');
484
-
485
-        $this->assertSame(array(
486
-            'type' => 'oauth2',
487
-            'flow' => 'accessCode',
488
-            'authorizationUrl' => 'http://auth.test',
489
-            'tokenUrl' => 'http://token.test',
490
-            'scopes' => array(
491
-                'scope2' => 'Some text',
492
-                'scope1' => 'Some text',
493
-            )
494
-        ), $object->toArray());
495
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
20
+	 */
21
+	public function testConstructor_UnknownType()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'");
24
+
25
+		new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
30
+	 */
31
+	public function testConstructor_Basic()
32
+	{
33
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'basic',
39
+		), $object->toArray());
40
+	}
41
+
42
+	/**
43
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
44
+	 */
45
+	public function testConstructor_BasicDescription()
46
+	{
47
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text');
48
+
49
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
50
+
51
+		$this->assertSame(array(
52
+			'type' => 'basic',
53
+			'description' => 'Some text',
54
+		), $object->toArray());
55
+	}
56
+
57
+	/**
58
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
59
+	 */
60
+	public function testConstructor_ApiKeyNoName()
61
+	{
62
+		$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"
63
+		);
64
+
65
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey');
66
+	}
67
+
68
+	/**
69
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
70
+	 */
71
+	public function testConstructor_ApiKeyNoIn()
72
+	{
73
+		$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''");
74
+
75
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name');
76
+	}
77
+
78
+	/**
79
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
80
+	 */
81
+	public function testConstructor_ApiKeyWrongIn()
82
+	{
83
+		$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'");
84
+
85
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad');
86
+	}
87
+
88
+	/**
89
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
90
+	 */
91
+	public function testConstructor_ApiKey()
92
+	{
93
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query');
94
+
95
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
96
+
97
+		$this->assertSame(array(
98
+			'type' => 'apiKey',
99
+			'name' => 'Name',
100
+			'in' => 'query',
101
+		), $object->toArray());
102
+	}
103
+
104
+	/**
105
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
106
+	 */
107
+	public function testConstructor_ApiKeyDescription()
108
+	{
109
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words');
110
+
111
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
112
+
113
+		$this->assertSame(array(
114
+			'type' => 'apiKey',
115
+			'description' => 'Some words',
116
+			'name' => 'Name',
117
+			'in' => 'query',
118
+		), $object->toArray());
119
+	}
120
+
121
+	/**
122
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
123
+	 */
124
+	public function testConstructor_Oauth2NoFlow()
125
+	{
126
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''");
127
+
128
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2');
129
+	}
130
+
131
+	/**
132
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
133
+	 */
134
+	public function testConstructor_Oauth2WrongFlow()
135
+	{
136
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'");
137
+
138
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow');
139
+	}
140
+
141
+	/**
142
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
143
+	 */
144
+	public function testConstructor_Oauth2ImplicitNoUrl()
145
+	{
146
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''");
147
+
148
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit');
149
+	}
150
+
151
+	/**
152
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
153
+	 */
154
+	public function testConstructor_Oauth2ImplicitBadUrl()
155
+	{
156
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'");
157
+
158
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad');
159
+	}
160
+
161
+	/**
162
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
163
+	 */
164
+	public function testConstructor_Oauth2ImplicitUrl()
165
+	{
166
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test');
167
+
168
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
169
+
170
+		$this->assertSame(array(
171
+			'type' => 'oauth2',
172
+			'flow' => 'implicit',
173
+			'authorizationUrl' => 'http://www.test',
174
+		), $object->toArray());
175
+	}
176
+
177
+	/**
178
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
179
+	 */
180
+	public function testConstructor_Oauth2ImplicitUrlDescription()
181
+	{
182
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words');
183
+
184
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
185
+
186
+		$this->assertSame(array(
187
+			'type' => 'oauth2',
188
+			'description' => 'Some words',
189
+			'flow' => 'implicit',
190
+			'authorizationUrl' => 'http://www.test',
191
+		), $object->toArray());
192
+	}
193
+
194
+	/**
195
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
196
+	 */
197
+	public function testConstructor_Oauth2PasswordNoUrl()
198
+	{
199
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
200
+
201
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password');
202
+	}
203
+
204
+	/**
205
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
206
+	 */
207
+	public function testConstructor_Oauth2PasswordBadUrl()
208
+	{
209
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
210
+
211
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad');
212
+	}
213
+
214
+	/**
215
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
216
+	 */
217
+	public function testConstructor_Oauth2Password()
218
+	{
219
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test');
220
+
221
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
222
+
223
+		$this->assertSame(array(
224
+			'type' => 'oauth2',
225
+			'flow' => 'password',
226
+			'tokenUrl' => 'http://token.test',
227
+		), $object->toArray());
228
+	}
229
+
230
+	/**
231
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
232
+	 */
233
+	public function testConstructor_Oauth2PasswordDescription()
234
+	{
235
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words');
236
+
237
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
238
+
239
+		$this->assertSame(array(
240
+			'type' => 'oauth2',
241
+			'description' => 'Some words',
242
+			'flow' => 'password',
243
+			'tokenUrl' => 'http://token.test',
244
+		), $object->toArray());
245
+	}
246
+
247
+	/**
248
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
249
+	 */
250
+	public function testConstructor_Oauth2ApplicationNoUrl()
251
+	{
252
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
253
+
254
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application');
255
+	}
256
+
257
+	/**
258
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
259
+	 */
260
+	public function testConstructor_Oauth2ApplicationBadUrl()
261
+	{
262
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
263
+
264
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad');
265
+	}
266
+
267
+	/**
268
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
269
+	 */
270
+	public function testConstructor_Oauth2Application()
271
+	{
272
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test');
273
+
274
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
275
+
276
+		$this->assertSame(array(
277
+			'type' => 'oauth2',
278
+			'flow' => 'application',
279
+			'tokenUrl' => 'http://token.test',
280
+		), $object->toArray());
281
+	}
282
+
283
+	/**
284
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
285
+	 */
286
+	public function testConstructor_Oauth2ApplicationDescription()
287
+	{
288
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words');
289
+
290
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
291
+
292
+		$this->assertSame(array(
293
+			'type' => 'oauth2',
294
+			'description' => 'Some words',
295
+			'flow' => 'application',
296
+			'tokenUrl' => 'http://token.test',
297
+		), $object->toArray());
298
+	}
299
+
300
+
301
+	/**
302
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
303
+	 */
304
+	public function testConstructor_Oauth2AccesscodeNoUrl1()
305
+	{
306
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''");
307
+
308
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode');
309
+	}
310
+
311
+	/**
312
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
313
+	 */
314
+	public function testConstructor_Oauth2AccesscodeBadUrl1()
315
+	{
316
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'");
317
+
318
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad');
319
+	}
320
+
321
+	/**
322
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
323
+	 */
324
+	public function testConstructor_Oauth2AccesscodeNoUrl2()
325
+	{
326
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
327
+
328
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test');
329
+	}
330
+
331
+	/**
332
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
333
+	 */
334
+	public function testConstructor_Oauth2AccesscodeBadUrl2()
335
+	{
336
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
337
+
338
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad');
339
+	}
340
+
341
+	/**
342
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
343
+	 */
344
+	public function testConstructor_Oauth2Accesscode()
345
+	{
346
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
347
+
348
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
349
+
350
+		$this->assertSame(array(
351
+			'type' => 'oauth2',
352
+			'flow' => 'accessCode',
353
+			'authorizationUrl' => 'http://auth.test',
354
+			'tokenUrl' => 'http://token.test',
355
+		), $object->toArray());
356
+	}
357
+
358
+	/**
359
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
360
+	 */
361
+	public function testConstructor_Oauth2AccesscodeDescription()
362
+	{
363
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode  http://auth.test http://token.test Some words');
364
+
365
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
366
+
367
+		$this->assertSame(array(
368
+			'type' => 'oauth2',
369
+			'description' => 'Some words',
370
+			'flow' => 'accessCode',
371
+			'authorizationUrl' => 'http://auth.test',
372
+			'tokenUrl' => 'http://token.test',
373
+		), $object->toArray());
374
+	}
375
+
376
+	/**
377
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
378
+	 */
379
+	public function testCommandDescription()
380
+	{
381
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
382
+
383
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
384
+
385
+		$object->handleCommand('description', 'Some words');
386
+
387
+		$this->assertSame(array(
388
+			'type' => 'oauth2',
389
+			'description' => 'Some words',
390
+			'flow' => 'accessCode',
391
+			'authorizationUrl' => 'http://auth.test',
392
+			'tokenUrl' => 'http://token.test',
393
+		), $object->toArray());
394
+	}
395
+
396
+	/**
397
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
398
+	 */
399
+	public function testCommandDescriptionEmpty()
400
+	{
401
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words');
402
+
403
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
404
+
405
+		$object->handleCommand('description', '');
406
+
407
+		$this->assertSame(array(
408
+			'type' => 'oauth2',
409
+			'flow' => 'accessCode',
410
+			'authorizationUrl' => 'http://auth.test',
411
+			'tokenUrl' => 'http://token.test',
412
+		), $object->toArray());
413
+	}
414
+
415
+	/**
416
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
417
+	 */
418
+	public function testCommandScopeNotOauth()
419
+	{
420
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic');
421
+
422
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
423
+
424
+		$this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'");
425
+
426
+		$object->handleCommand('scope', 'scope1');
427
+	}
428
+
429
+	/**
430
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
431
+	 */
432
+	public function testCommandScope()
433
+	{
434
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
435
+
436
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
437
+
438
+		$object->handleCommand('scope', 'scope1');
439
+
440
+		$this->assertSame(array(
441
+			'type' => 'oauth2',
442
+			'flow' => 'accessCode',
443
+			'authorizationUrl' => 'http://auth.test',
444
+			'tokenUrl' => 'http://token.test',
445
+			'scopes' => array(
446
+				'scope1' => '',
447
+			)
448
+		), $object->toArray());
449
+	}
450
+
451
+	/**
452
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
453
+	 */
454
+	public function testCommandScopeDescription()
455
+	{
456
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
457
+
458
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
459
+
460
+		$object->handleCommand('scope', 'scope1 Some text');
461
+
462
+		$this->assertSame(array(
463
+			'type' => 'oauth2',
464
+			'flow' => 'accessCode',
465
+			'authorizationUrl' => 'http://auth.test',
466
+			'tokenUrl' => 'http://token.test',
467
+			'scopes' => array(
468
+				'scope1' => 'Some text',
469
+			)
470
+		), $object->toArray());
471
+	}
472
+
473
+	/**
474
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
475
+	 */
476
+	public function testCommandScopes()
477
+	{
478
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
479
+
480
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
481
+
482
+		$object->handleCommand('scope', 'scope2 Some text');
483
+		$object->handleCommand('scope', 'scope1 Some text');
484
+
485
+		$this->assertSame(array(
486
+			'type' => 'oauth2',
487
+			'flow' => 'accessCode',
488
+			'authorizationUrl' => 'http://auth.test',
489
+			'tokenUrl' => 'http://token.test',
490
+			'scopes' => array(
491
+				'scope2' => 'Some text',
492
+				'scope1' => 'Some text',
493
+			)
494
+		), $object->toArray());
495
+	}
496 496
 
497 497
 }
Please login to merge, or discard this patch.