Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 863f49c

Browse files
committed
Updated tests to work with PHPUnit 7
1 parent 2176f98 commit 863f49c

File tree

5 files changed

+38
-46
lines changed

5 files changed

+38
-46
lines changed

test/Cloud/CloudTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public function testSetInvalidCloudDecorator()
6161
{
6262
$cloud = $this->getCloud();
6363

64-
$this->setExpectedException('Zend\Tag\Exception\InvalidArgumentException', 'DecoratorInterface');
64+
$this->expectException('Zend\Tag\Exception\InvalidArgumentException');
65+
$this->expectExceptionMessage('DecoratorInterface');
6566
$cloud->setCloudDecorator(new stdClass());
6667
}
6768

@@ -90,7 +91,8 @@ public function testSetInvalidTagDecorator()
9091
{
9192
$cloud = $this->getCloud();
9293

93-
$this->setExpectedException('Zend\Tag\Exception\InvalidArgumentException', 'DecoratorInterface');
94+
$this->expectException('Zend\Tag\Exception\InvalidArgumentException');
95+
$this->expectExceptionMessage('DecoratorInterface');
9496
$cloud->setTagDecorator(new stdClass());
9597
}
9698

@@ -142,7 +144,8 @@ public function testAppendInvalidTag()
142144
{
143145
$cloud = $this->getCloud();
144146

145-
$this->setExpectedException('Zend\Tag\Exception\InvalidArgumentException', 'TaggableInterface');
147+
$this->expectException('Zend\Tag\Exception\InvalidArgumentException');
148+
$this->expectExceptionMessage('TaggableInterface');
146149
$cloud->appendTag('foo');
147150
}
148151

@@ -210,7 +213,8 @@ public function testSetInvalidTags()
210213
{
211214
$cloud = $this->getCloud();
212215

213-
$this->setExpectedException('Zend\Tag\Exception\InvalidArgumentException', 'TaggableInterface');
216+
$this->expectException('Zend\Tag\Exception\InvalidArgumentException');
217+
$this->expectExceptionMessage('TaggableInterface');
214218
$cloud->setTags(['foo']);
215219
}
216220

test/Cloud/Decorator/HtmlCloudTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ public function testInvalidHtmlTagsRaiseAnException($tags)
151151
{
152152
$decorator = new Decorator\HtmlCloud();
153153
$decorator->setHTMLTags($tags);
154-
$this->setExpectedException(
155-
'Zend\Tag\Exception\InvalidElementNameException'
156-
);
154+
$this->expectException('Zend\Tag\Exception\InvalidElementNameException');
157155
$decorator->render([]);
158156
}
159157

@@ -191,9 +189,7 @@ public function testInvalidAttributeNamesRaiseAnException($tags)
191189
{
192190
$decorator = new Decorator\HtmlCloud();
193191
$decorator->setHTMLTags($tags);
194-
$this->setExpectedException(
195-
'Zend\Tag\Exception\InvalidAttributeNameException'
196-
);
192+
$this->expectException('Zend\Tag\Exception\InvalidAttributeNameException');
197193
$decorator->render([]);
198194
}
199195
}

test/Cloud/Decorator/HtmlTagTest.php

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,54 +69,44 @@ public function testEmptyClassList()
6969
{
7070
$decorator = new Decorator\HtmlTag();
7171

72-
$this->setExpectedException(
73-
'Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException',
74-
'Classlist is empty'
75-
);
72+
$this->expectException('Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException');
73+
$this->expectExceptionMessage('Classlist is empty');
7674
$decorator->setClassList([]);
7775
}
7876

7977
public function testInvalidClassList()
8078
{
8179
$decorator = new Decorator\HtmlTag();
8280

83-
$this->setExpectedException(
84-
'Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException',
85-
'Classlist contains an invalid classname'
86-
);
81+
$this->expectException('Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException');
82+
$this->expectExceptionMessage('Classlist contains an invalid classname');
8783
$decorator->setClassList([[]]);
8884
}
8985

9086
public function testInvalidFontSizeUnit()
9187
{
9288
$decorator = new Decorator\HtmlTag();
9389

94-
$this->setExpectedException(
95-
'Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException',
96-
'Invalid fontsize unit specified'
97-
);
90+
$this->expectException('Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException');
91+
$this->expectExceptionMessage('Invalid fontsize unit specified');
9892
$decorator->setFontSizeUnit('foo');
9993
}
10094

10195
public function testInvalidMinFontSize()
10296
{
10397
$decorator = new Decorator\HtmlTag();
10498

105-
$this->setExpectedException(
106-
'Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException',
107-
'Fontsize must be numeric'
108-
);
99+
$this->expectException('Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException');
100+
$this->expectExceptionMessage('Fontsize must be numeric');
109101
$decorator->setMinFontSize('foo');
110102
}
111103

112104
public function testInvalidMaxFontSize()
113105
{
114106
$decorator = new Decorator\HtmlTag();
115107

116-
$this->setExpectedException(
117-
'Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException',
118-
'Fontsize must be numeric'
119-
);
108+
$this->expectException('Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException');
109+
$this->expectExceptionMessage('Fontsize must be numeric');
120110
$decorator->setMaxFontSize('foo');
121111
}
122112

@@ -208,7 +198,7 @@ public function testInvalidElementNamesRaiseAnException($tags)
208198
{
209199
$decorator = new Decorator\HtmlTag();
210200
$decorator->setHTMLTags($tags);
211-
$this->setExpectedException('Zend\Tag\Exception\InvalidElementNameException');
201+
$this->expectException('Zend\Tag\Exception\InvalidElementNameException');
212202
$decorator->render($this->getTags());
213203
}
214204

@@ -240,7 +230,7 @@ public function testInvalidAttributesRaiseAnException($tags)
240230
{
241231
$decorator = new Decorator\HtmlTag();
242232
$decorator->setHTMLTags($tags);
243-
$this->setExpectedException('Zend\Tag\Exception\InvalidAttributeNameException');
233+
$this->expectException('Zend\Tag\Exception\InvalidAttributeNameException');
244234
$decorator->render($this->getTags());
245235
}
246236
}

test/ItemListTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,17 @@ public function testSeektableIteratorThrowsBoundsException()
6060
}
6161
$list->seek(2);
6262

63-
$this->setExpectedException('Zend\Tag\Exception\OutOfBoundsException', 'Invalid seek position');
63+
$this->expectException('Zend\Tag\Exception\OutOfBoundsException');
64+
$this->expectExceptionMessage('Invalid seek position');
6465
$list->seek(3);
6566
}
6667

6768
public function testInvalidItem()
6869
{
6970
$list = new Tag\ItemList();
7071

71-
$this->setExpectedException(
72-
'\Zend\Tag\Exception\OutOfBoundsException',
73-
'Item must implement Zend\Tag\TaggableInterface'
74-
);
72+
$this->expectException('\Zend\Tag\Exception\OutOfBoundsException');
73+
$this->expectExceptionMessage('Item must implement Zend\Tag\TaggableInterface');
7574
$list[] = 'test';
7675
}
7776

@@ -119,7 +118,8 @@ public function testSpreadWeightValuesWithEmptyValuesArray()
119118
{
120119
$list = new Tag\ItemList();
121120

122-
$this->setExpectedException('Zend\Tag\Exception\InvalidArgumentException', 'Value list may not be empty');
121+
$this->expectException('Zend\Tag\Exception\InvalidArgumentException');
122+
$this->expectExceptionMessage('Value list may not be empty');
123123
$list->spreadWeightValues([]);
124124
}
125125

test/ItemTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public function testSetTitle()
6565

6666
public function testInvalidTitle()
6767
{
68-
$this->setExpectedException('\Zend\Tag\Exception\InvalidArgumentException', 'Title must be a string');
68+
$this->expectException('\Zend\Tag\Exception\InvalidArgumentException');
69+
$this->expectExceptionMessage('Title must be a string');
6970
$tag = new Tag\Item(['title' => 10, 'weight' => 1]);
7071
}
7172

@@ -80,7 +81,8 @@ public function testSetWeight()
8081

8182
public function testInvalidWeight()
8283
{
83-
$this->setExpectedException('\Zend\Tag\Exception\InvalidArgumentException', 'Weight must be numeric');
84+
$this->expectException('\Zend\Tag\Exception\InvalidArgumentException');
85+
$this->expectExceptionMessage('Weight must be numeric');
8486
$tag = new Tag\Item(['title' => 'foo', 'weight' => 'foobar']);
8587
}
8688

@@ -92,22 +94,22 @@ public function testSkipOptions()
9294

9395
public function testInvalidOptions()
9496
{
95-
$this->setExpectedException(
96-
'\Zend\Tag\Exception\InvalidArgumentException',
97-
'Invalid options provided to constructor'
98-
);
97+
$this->expectException('\Zend\Tag\Exception\InvalidArgumentException');
98+
$this->expectExceptionMessage('Invalid options provided to constructor');
9999
$tag = new Tag\Item('test');
100100
}
101101

102102
public function testMissingTitle()
103103
{
104-
$this->setExpectedException('\Zend\Tag\Exception\InvalidArgumentException', 'Title was not set');
104+
$this->expectException('\Zend\Tag\Exception\InvalidArgumentException');
105+
$this->expectExceptionMessage('Title was not set');
105106
$tag = new Tag\Item(['weight' => 1]);
106107
}
107108

108109
public function testMissingWeight()
109110
{
110-
$this->setExpectedException('\Zend\Tag\Exception\InvalidArgumentException', 'Weight was not set');
111+
$this->expectException('\Zend\Tag\Exception\InvalidArgumentException');
112+
$this->expectExceptionMessage('Weight was not set');
111113
$tag = new Tag\Item(['title' => 'foo']);
112114
}
113115

0 commit comments

Comments
 (0)