[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
@@ -12,6 +12,11 @@
namespace Predis\Protocol\Text;
use PredisTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use Predis\Command\CommandInterface;
use Predis\Connection\CompositeConnectionInterface;
use Predis\Protocol\RequestSerializerInterface;
use Predis\Protocol\ResponseReaderInterface;
/**
*
@@ -21,7 +26,7 @@ class CompositeProtocolProcessorTest extends PredisTestCase
/**
* @group disconnected
*/
public function testConstructor()
public function testConstructor(): void
{
$protocol = new CompositeProtocolProcessor();
@@ -32,9 +37,11 @@ class CompositeProtocolProcessorTest extends PredisTestCase
/**
* @group disconnected
*/
public function testConstructorWithArguments()
public function testConstructorWithArguments(): void
{
/** @var RequestSerializerInterface */
$serializer = $this->getMockBuilder('Predis\Protocol\RequestSerializerInterface')->getMock();
/** @var ResponseReaderInterface */
$reader = $this->getMockBuilder('Predis\Protocol\ResponseReaderInterface')->getMock();
$protocol = new CompositeProtocolProcessor($serializer, $reader);
@@ -46,8 +53,9 @@ class CompositeProtocolProcessorTest extends PredisTestCase
/**
* @group disconnected
*/
public function testCustomRequestSerializer()
public function testCustomRequestSerializer(): void
{
/** @var RequestSerializerInterface */
$serializer = $this->getMockBuilder('Predis\Protocol\RequestSerializerInterface')->getMock();
$protocol = new CompositeProtocolProcessor();
@@ -59,8 +67,9 @@ class CompositeProtocolProcessorTest extends PredisTestCase
/**
* @group disconnected
*/
public function testCustomResponseReader()
public function testCustomResponseReader(): void
{
/** @var ResponseReaderInterface */
$reader = $this->getMockBuilder('Predis\Protocol\ResponseReaderInterface')->getMock();
$protocol = new CompositeProtocolProcessor();
@@ -72,12 +81,15 @@ class CompositeProtocolProcessorTest extends PredisTestCase
/**
* @group disconnected
*/
public function testConnectionWrite()
public function testConnectionWrite(): void
{
$serialized = "*1\r\n$4\r\nPING\r\n";
/** @var CommandInterface */
$command = $this->getMockBuilder('Predis\Command\CommandInterface')->getMock();
/** @var CompositeConnectionInterface|MockObject */
$connection = $this->getMockBuilder('Predis\Connection\CompositeConnectionInterface')->getMock();
/** @var RequestSerializerInterface|MockObject */
$serializer = $this->getMockBuilder('Predis\Protocol\RequestSerializerInterface')->getMock();
$protocol = new CompositeProtocolProcessor($serializer);
@@ -99,9 +111,11 @@ class CompositeProtocolProcessorTest extends PredisTestCase
/**
* @group disconnected
*/
public function testConnectionRead()
public function testConnectionRead(): void
{
/** @var CompositeConnectionInterface */
$connection = $this->getMockBuilder('Predis\Connection\CompositeConnectionInterface')->getMock();
/** @var ResponseReaderInterface|MockObject */
$reader = $this->getMockBuilder('Predis\Protocol\ResponseReaderInterface')->getMock();
$protocol = new CompositeProtocolProcessor(null, $reader);