[tests] Start improving test suite.

- Make use of more typehints for function parameters
- Make use of typehints for function return values
- Use @var where needed to give proper hints to IDEs and avoid warnings
- Replace MockObject::setMethods() with addMethods() and onlyMethods()
- Rewording of some phpdocs
This commit is contained in:
Daniele Alessandri
2020-08-28 18:59:10 +02:00
parent c2ede30394
commit 36c9bb047e
236 changed files with 2887 additions and 2454 deletions
+13 -13
View File
@@ -11,8 +11,8 @@
namespace Predis\PubSub;
use Predis\Client;
use PredisTestCase;
use Predis\Client;
/**
* @group realm-pubsub
@@ -27,12 +27,12 @@ class DispatcherLoopTest extends PredisTestCase
* @group connected
* @requiresRedisVersion >= 2.0.0
*/
public function testDispatcherLoopAgainstRedisServer()
public function testDispatcherLoopAgainstRedisServer(): void
{
$parameters = array(
'host' => REDIS_SERVER_HOST,
'port' => REDIS_SERVER_PORT,
'database' => REDIS_SERVER_DBNUM,
'host' => constant('REDIS_SERVER_HOST'),
'port' => constant('REDIS_SERVER_PORT'),
'database' => constant('REDIS_SERVER_DBNUM'),
// Prevents suite from hanging on broken test
'read_write_timeout' => 2,
);
@@ -47,7 +47,7 @@ class DispatcherLoopTest extends PredisTestCase
$dispatcher = new DispatcherLoop($pubsub);
$function01 = $this->getMockBuilder('stdClass')
->setMethods(array('__invoke'))
->addMethods(array('__invoke'))
->getMock();
$function01
->expects($this->exactly(2))
@@ -63,7 +63,7 @@ class DispatcherLoopTest extends PredisTestCase
}));
$function02 = $this->getMockBuilder('stdClass')
->setMethods(array('__invoke'))
->addMethods(array('__invoke'))
->getMock();
$function02
->expects($this->once())
@@ -71,7 +71,7 @@ class DispatcherLoopTest extends PredisTestCase
->with('02:argument');
$function03 = $this->getMockBuilder('stdClass')
->setMethods(array('__invoke'))
->addMethods(array('__invoke'))
->getMock();
$function03
->expects($this->never())
@@ -94,12 +94,12 @@ class DispatcherLoopTest extends PredisTestCase
* @group connected
* @requiresRedisVersion >= 2.0.0
*/
public function testDispatcherLoopAgainstRedisServerWithPrefix()
public function testDispatcherLoopAgainstRedisServerWithPrefix(): void
{
$parameters = array(
'host' => REDIS_SERVER_HOST,
'port' => REDIS_SERVER_PORT,
'database' => REDIS_SERVER_DBNUM,
'host' => constant('REDIS_SERVER_HOST'),
'port' => constant('REDIS_SERVER_PORT'),
'database' => constant('REDIS_SERVER_DBNUM'),
// Prevents suite from handing on broken test
'read_write_timeout' => 2,
);
@@ -116,7 +116,7 @@ class DispatcherLoopTest extends PredisTestCase
$dispatcher = new DispatcherLoop($pubsub);
$callback = $this->getMockBuilder('stdClass')
->setMethods(array('__invoke'))
->addMethods(array('__invoke'))
->getMock();
$callback
->expects($this->exactly(1))