mirror of
https://github.com/predis/predis.git
synced 2026-10-07 20:38:06 +00:00
[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:
@@ -21,7 +21,7 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testConstructorWithoutArguments()
|
||||
public function testConstructorWithoutArguments(): void
|
||||
{
|
||||
$options = new Options();
|
||||
|
||||
@@ -37,12 +37,12 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testConstructorWithArrayArgument()
|
||||
public function testConstructorWithArrayArgument(): void
|
||||
{
|
||||
$connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock();
|
||||
|
||||
$callable = $this->getMockBuilder('stdClass')
|
||||
->setMethods(array('__invoke'))
|
||||
->addMethods(array('__invoke'))
|
||||
->getMock();
|
||||
$callable
|
||||
->expects($this->any())
|
||||
@@ -78,7 +78,7 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testSupportsCustomOptions()
|
||||
public function testSupportsCustomOptions(): void
|
||||
{
|
||||
$options = new Options(array(
|
||||
'custom' => 'foobar',
|
||||
@@ -90,7 +90,7 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testUndefinedOptionsReturnNull()
|
||||
public function testUndefinedOptionsReturnNull(): void
|
||||
{
|
||||
$options = new Options();
|
||||
|
||||
@@ -102,7 +102,7 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testCanCheckOptionsIfDefinedByUser()
|
||||
public function testCanCheckOptionsIfDefinedByUser(): void
|
||||
{
|
||||
$options = new Options(array(
|
||||
'prefix' => 'prefix:',
|
||||
@@ -119,7 +119,7 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testIsSetReplicatesPHPBehavior()
|
||||
public function testIsSetReplicatesPHPBehavior(): void
|
||||
{
|
||||
$options = new Options(array(
|
||||
'prefix' => 'prefix:',
|
||||
@@ -136,7 +136,7 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testReturnsDefaultValueOfSpecifiedOption()
|
||||
public function testReturnsDefaultValueOfSpecifiedOption(): void
|
||||
{
|
||||
$options = new Options();
|
||||
|
||||
@@ -146,7 +146,7 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testReturnsNullAsDefaultValueForUndefinedOption()
|
||||
public function testReturnsNullAsDefaultValueForUndefinedOption(): void
|
||||
{
|
||||
$options = new Options();
|
||||
|
||||
@@ -156,13 +156,13 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testLazilyInitializesOptionValueUsingObjectWithInvokeMagicMethod()
|
||||
public function testLazilyInitializesOptionValueUsingObjectWithInvokeMagicMethod(): void
|
||||
{
|
||||
$commands = $this->getMockBuilder('Predis\Command\FactoryInterface')->getMock();
|
||||
|
||||
// NOTE: closure values are covered by this test since they define __invoke().
|
||||
$callable = $this->getMockBuilder('stdClass')
|
||||
->setMethods(array('__invoke'))
|
||||
->addMethods(array('__invoke'))
|
||||
->getMock();
|
||||
$callable
|
||||
->expects($this->once())
|
||||
@@ -181,13 +181,13 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testLazilyInitializesCustomOptionValueUsingObjectWithInvokeMagicMethod()
|
||||
public function testLazilyInitializesCustomOptionValueUsingObjectWithInvokeMagicMethod(): void
|
||||
{
|
||||
$custom = new \stdClass();
|
||||
|
||||
// NOTE: closure values are covered by this test since they define __invoke().
|
||||
$callable = $this->getMockBuilder('stdClass')
|
||||
->setMethods(array('__invoke'))
|
||||
->addMethods(array('__invoke'))
|
||||
->getMock();
|
||||
$callable
|
||||
->expects($this->once())
|
||||
@@ -206,10 +206,10 @@ class OptionsTest extends PredisTestCase
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testChecksForInvokeMagicMethodDoesNotTriggerAutoloader()
|
||||
public function testChecksForInvokeMagicMethodDoesNotTriggerAutoloader(): void
|
||||
{
|
||||
$trigger = $this->getMockBuilder('stdClass')
|
||||
->setMethods(array('autoload'))
|
||||
->addMethods(array('autoload'))
|
||||
->getMock();
|
||||
$trigger
|
||||
->expects($this->never())
|
||||
|
||||
Reference in New Issue
Block a user