Skip to content

Commit 3dcf84b

Browse files
committed
Fix exception-throwing tests
1 parent 45c245d commit 3dcf84b

File tree

6 files changed

+17
-42
lines changed

6 files changed

+17
-42
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ before_install:
3535
install: composer update --prefer-dist --no-interaction
3636

3737
before_script:
38-
- XDEBUG_MODE=coverage
3938
- composer dump-autoload
4039
- cd tests
4140
- $TRAVIS_BUILD_DIR/tests/run.sh

tests/SphinxQL/ConnectionTest.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ public function testGetConnection()
8080
$this->assertNotNull($this->connection->getConnection());
8181
}
8282

83-
/**
84-
* @expectedException Foolz\SphinxQL\Exception\ConnectionException
85-
*/
8683
public function testGetConnectionThrowsException()
8784
{
85+
$this->expectException(Foolz\SphinxQL\Exception\ConnectionException::class);
8886
$this->connection->getConnection();
8987
}
9088

@@ -96,11 +94,9 @@ public function testConnect()
9694
$this->connection->connect();
9795
}
9896

99-
/**
100-
* @expectedException Foolz\SphinxQL\Exception\ConnectionException
101-
*/
10297
public function testConnectThrowsException()
10398
{
99+
$this->expectException(Foolz\SphinxQL\Exception\ConnectionException::class);
104100
$this->connection->setParam('port', 9308);
105101
$this->connection->connect();
106102
}
@@ -111,11 +107,9 @@ public function testPing()
111107
$this->assertTrue($this->connection->ping());
112108
}
113109

114-
/**
115-
* @expectedException Foolz\SphinxQL\Exception\ConnectionException
116-
*/
117110
public function testClose()
118111
{
112+
$this->expectException(Foolz\SphinxQL\Exception\ConnectionException::class);
119113
$encoding = mb_internal_encoding();
120114
$this->connection->connect();
121115

@@ -150,29 +144,23 @@ public function testMultiQuery()
150144
), $query->getNext()->fetchAllAssoc());
151145
}
152146

153-
/**
154-
* @expectedException Foolz\SphinxQL\Exception\SphinxQLException
155-
* @expectedExceptionMessage The Queue is empty.
156-
*/
157147
public function testEmptyMultiQuery()
158148
{
149+
$this->expectException(Foolz\SphinxQL\Exception\SphinxQLException::class);
150+
$this->expectExceptionMessage('The Queue is empty.');
159151
$this->connection->connect();
160152
$this->connection->multiQuery(array());
161153
}
162154

163-
/**
164-
* @expectedException Foolz\SphinxQL\Exception\DatabaseException
165-
*/
166155
public function testMultiQueryThrowsException()
167156
{
157+
$this->expectException(Foolz\SphinxQL\Exception\DatabaseException::class);
168158
$this->connection->multiQuery(array('SHOW METAL'));
169159
}
170160

171-
/**
172-
* @expectedException Foolz\SphinxQL\Exception\DatabaseException
173-
*/
174161
public function testQueryThrowsException()
175162
{
163+
$this->expectException(Foolz\SphinxQL\Exception\DatabaseException::class);
176164
$this->connection->query('SHOW METAL');
177165
}
178166

@@ -182,11 +170,9 @@ public function testEscape()
182170
$this->assertEquals('\'\\\' \\"\\" \\\'\\\' \'', $result);
183171
}
184172

185-
/**
186-
* @expectedException Foolz\SphinxQL\Exception\ConnectionException
187-
*/
188173
public function testEscapeThrowsException()
189174
{
175+
$this->expectException(Foolz\SphinxQL\Exception\ConnectionException::class);
190176
// or we get the wrong error popping up
191177
$this->connection->setParam('port', 9308);
192178
$this->connection->connect();

tests/SphinxQL/HelperTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,10 @@ public function testCallKeywords()
163163
);
164164
}
165165

166-
/**
167-
* @expectedException Foolz\SphinxQL\Exception\DatabaseException
168-
* @expectedExceptionMessage Sphinx expr: syntax error
169-
*/
170166
public function testUdfNotInstalled()
171167
{
168+
$this->expectException(Foolz\SphinxQL\Exception\DatabaseException::class);
169+
$this->expectExceptionMessage('Sphinx expr: syntax error');
172170
$this->conn->query('SELECT MY_UDF()');
173171
}
174172

tests/SphinxQL/MultiResultSetTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ public function testStore()
119119
$this->assertEquals(8, $all[0]['count(*)']);
120120
}
121121

122-
/**
123-
* @expectedException Foolz\SphinxQL\Exception\DatabaseException
124-
*/
125122
public function testInvalidStore()
126123
{
124+
$this->expectException(Foolz\SphinxQL\Exception\DatabaseException::class);
127125
$this->refill();
128126

129127
$res = self::$conn->multiQuery(array('SELECT COUNT(*) FROM rt', 'SHOW META'));

tests/SphinxQL/ResultSetTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,10 @@ public function testToRow()
102102
$res->freeResult();
103103
}
104104

105-
/**
106-
* @expectedException Foolz\SphinxQL\Exception\ResultSetException
107-
* @expectedExceptionMessage The row does not exist.
108-
*/
109105
public function testToRowThrows()
110106
{
107+
$this->expectException(Foolz\SphinxQL\Exception\ResultSetException::class);
108+
$this->expectExceptionMessage("The row does not exist.");
111109
$this->refill();
112110
$res = self::$conn->query('SELECT * FROM rt');
113111
$res->toRow(8);
@@ -134,12 +132,10 @@ public function testToNextRow()
134132
$res->freeResult();
135133
}
136134

137-
/**
138-
* @expectedException Foolz\SphinxQL\Exception\ResultSetException
139-
* @expectedExceptionMessage The row does not exist.
140-
*/
141135
public function testToNextRowThrows()
142136
{
137+
$this->expectException(Foolz\SphinxQL\Exception\ResultSetException::class);
138+
$this->expectExceptionMessage("The row does not exist.");
143139
$this->refill();
144140
$res = self::$conn->query('SELECT * FROM rt WHERE id = 10');
145141
$res->toNextRow()->toNextRow();

tests/SphinxQL/SphinxQLTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -899,12 +899,10 @@ public function testQueue()
899899
$this->assertEquals('11', $result[2][0]['id']);
900900
}
901901

902-
/**
903-
* @expectedException Foolz\SphinxQL\Exception\SphinxQLException
904-
* @expectedExceptionMessage There is no Queue present to execute.
905-
*/
906902
public function testEmptyQueue()
907903
{
904+
$this->expectException(Foolz\SphinxQL\Exception\SphinxQLException::class);
905+
$this->expectExceptionMessage("There is no Queue present to execute.");
908906
$this->createSphinxQL()
909907
->executeBatch()
910908
->getStored();

0 commit comments

Comments
 (0)