Browse Source

Fix tests param typehints

Corey Taylor 4 years ago
parent
commit
52d80ab851
30 changed files with 65 additions and 37 deletions
  1. 1 1
      tests/TestCase/BasicsTest.php
  2. 1 0
      tests/TestCase/Cache/CacheTest.php
  3. 1 1
      tests/TestCase/Command/PluginUnloadCommandTest.php
  4. 1 1
      tests/TestCase/Console/CommandCollectionTest.php
  5. 2 2
      tests/TestCase/Console/CommandRunnerTest.php
  6. 4 2
      tests/TestCase/Console/ConsoleIoTest.php
  7. 2 1
      tests/TestCase/Console/ShellTest.php
  8. 1 1
      tests/TestCase/Controller/Component/PaginatorComponentTest.php
  9. 1 1
      tests/TestCase/Controller/Component/SecurityComponentTest.php
  10. 1 1
      tests/TestCase/Controller/ControllerTest.php
  11. 2 0
      tests/TestCase/Core/FunctionsTest.php
  12. 2 0
      tests/TestCase/Database/Driver/SqliteTest.php
  13. 2 1
      tests/TestCase/Database/DriverTest.php
  14. 1 1
      tests/TestCase/Database/Expression/QueryExpressionTest.php
  15. 4 4
      tests/TestCase/Database/Schema/MysqlSchemaTest.php
  16. 3 3
      tests/TestCase/Database/Schema/PostgresSchemaTest.php
  17. 4 4
      tests/TestCase/Database/Schema/SqliteSchemaTest.php
  18. 5 4
      tests/TestCase/Database/Schema/SqlserverSchemaTest.php
  19. 3 3
      tests/TestCase/Database/Schema/TableSchemaTest.php
  20. 4 0
      tests/TestCase/Database/Type/DateTimeFractionalTypeTest.php
  21. 4 0
      tests/TestCase/Database/Type/DateTimeTimezoneTypeTest.php
  22. 2 0
      tests/TestCase/Database/Type/DateTimeTypeTest.php
  23. 2 0
      tests/TestCase/Database/Type/DateTypeTest.php
  24. 2 0
      tests/TestCase/Database/Type/TimeTypeTest.php
  25. 1 1
      tests/TestCase/Database/TypeFactoryTest.php
  26. 2 1
      tests/TestCase/Datasource/ConnectionManagerTest.php
  27. 1 1
      tests/TestCase/Datasource/PaginatorTestTrait.php
  28. 1 1
      tests/TestCase/Error/DebuggerTest.php
  29. 1 1
      tests/TestCase/Error/ErrorHandlerTest.php
  30. 4 1
      tests/TestCase/Mailer/EmailTest.php

+ 1 - 1
tests/TestCase/BasicsTest.php

@@ -465,7 +465,7 @@ EXPECTED;
      * @depends testEventManagerReset1
      * @return void
      */
-    public function testEventManagerReset2($prevEventManager)
+    public function testEventManagerReset2(EventManager $prevEventManager)
     {
         $this->assertInstanceOf(EventManager::class, $prevEventManager);
         $this->assertNotSame($prevEventManager, EventManager::instance());

+ 1 - 0
tests/TestCase/Cache/CacheTest.php

@@ -402,6 +402,7 @@ class CacheTest extends TestCase
      * testConfig method
      *
      * @dataProvider configProvider
+     * @param \Cake\Cache\CacheEngine|array $config
      * @return void
      */
     public function testConfigVariants($config)

+ 1 - 1
tests/TestCase/Command/PluginUnloadCommandTest.php

@@ -167,7 +167,7 @@ class PluginUnloadCommandTest extends TestCase
      * @dataProvider variantProvider
      * @return void
      */
-    public function testRegularExpressionsApplication($content)
+    public function testRegularExpressionsApplication(string $content)
     {
         $this->addPluginToApp($content);
 

+ 1 - 1
tests/TestCase/Console/CommandCollectionTest.php

@@ -160,7 +160,7 @@ class CommandCollectionTest extends TestCase
      * @dataProvider invalidNameProvider
      * @return void
      */
-    public function testAddCommandInvalidName($name)
+    public function testAddCommandInvalidName(string $name)
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionMessage("The command name `$name` is invalid.");

+ 2 - 2
tests/TestCase/Console/CommandRunnerTest.php

@@ -550,7 +550,7 @@ class CommandRunnerTest extends TestCase
         $this->assertGreaterThan(2, count(Router::getRouteCollection()->routes()));
     }
 
-    protected function makeAppWithCommands($commands)
+    protected function makeAppWithCommands(array $commands)
     {
         $app = $this->getMockBuilder(BaseApplication::class)
             ->onlyMethods(['middleware', 'bootstrap', 'console', 'routes'])
@@ -562,7 +562,7 @@ class CommandRunnerTest extends TestCase
         return $app;
     }
 
-    protected function getMockIo($output)
+    protected function getMockIo(ConsoleOutput $output)
     {
         $io = $this->getMockBuilder(ConsoleIo::class)
             ->setConstructorArgs([$output, $output, null, null])

+ 4 - 2
tests/TestCase/Console/ConsoleIoTest.php

@@ -102,6 +102,7 @@ class ConsoleIoTest extends TestCase
      * test ask choices method
      *
      * @dataProvider choiceProvider
+     * @param array|string $choices
      * @return void
      */
     public function testAskChoices($choices)
@@ -118,6 +119,7 @@ class ConsoleIoTest extends TestCase
      * test ask choices method
      *
      * @dataProvider choiceProvider
+     * @param array|string $choices
      * @return void
      */
     public function testAskChoicesInsensitive($choices)
@@ -589,7 +591,7 @@ class ConsoleIoTest extends TestCase
      * @dataProvider outHelperProvider
      * @return void
      */
-    public function testOutHelpers($method)
+    public function testOutHelpers(string $method)
     {
         $this->out->expects($this->exactly(2))
             ->method('write')
@@ -608,7 +610,7 @@ class ConsoleIoTest extends TestCase
      * @dataProvider errHelperProvider
      * @return void
      */
-    public function testErrHelpers($method)
+    public function testErrHelpers(string $method)
     {
         $this->err->expects($this->exactly(2))
             ->method('write')

+ 2 - 1
tests/TestCase/Console/ShellTest.php

@@ -1308,8 +1308,9 @@ TEXT;
      * Test reading params
      *
      * @dataProvider paramReadingDataProvider
+     * @param mixed $expected
      */
-    public function testParamReading($toRead, $expected)
+    public function testParamReading(string $toRead, $expected)
     {
         $this->Shell->params = [
             'key' => 'value',

+ 1 - 1
tests/TestCase/Controller/Component/PaginatorComponentTest.php

@@ -1131,7 +1131,7 @@ class PaginatorComponentTest extends TestCase
      * @dataProvider checkLimitProvider
      * @return void
      */
-    public function testCheckLimit($input, $expected): void
+    public function testCheckLimit(array $input, int $expected): void
     {
         $result = $this->Paginator->checkLimit($input);
         $this->assertSame($expected, $result['limit']);

+ 1 - 1
tests/TestCase/Controller/Component/SecurityComponentTest.php

@@ -97,7 +97,7 @@ class SecurityComponentTest extends TestCase
         unset($this->Controller);
     }
 
-    public function validatePost($expectedException = 'SecurityException', $expectedExceptionMessage = null)
+    public function validatePost(string $expectedException = 'SecurityException', ?string $expectedExceptionMessage = null)
     {
         try {
             return $this->Controller->Security->validatePost($this->Controller);

+ 1 - 1
tests/TestCase/Controller/ControllerTest.php

@@ -354,7 +354,7 @@ class ControllerTest extends TestCase
      * @dataProvider statusCodeProvider
      * @return void
      */
-    public function testRedirectByCode($code, $msg): void
+    public function testRedirectByCode(int $code, string $msg): void
     {
         $Controller = new Controller(null, new Response());
 

+ 2 - 0
tests/TestCase/Core/FunctionsTest.php

@@ -55,6 +55,8 @@ class FunctionsTest extends TestCase
      *
      * @return void
      * @dataProvider hInputProvider
+     * @param mixed $value
+     * @param mixed $expected
      */
     public function testH($value, $expected)
     {

+ 2 - 0
tests/TestCase/Database/Driver/SqliteTest.php

@@ -125,6 +125,8 @@ class SqliteTest extends TestCase
      * Test the schemaValue method on Driver.
      *
      * @dataProvider schemaValueProvider
+     * @param mixed $input
+     * @param mixed $expected
      * @return void
      */
     public function testSchemaValue($input, $expected)

+ 2 - 1
tests/TestCase/Database/DriverTest.php

@@ -124,9 +124,10 @@ class DriverTest extends TestCase
      * Uses a provider for all the different values we can pass to the method.
      *
      * @dataProvider schemaValueProvider
+     * @param mixed $input
      * @return void
      */
-    public function testSchemaValue($input, $expected)
+    public function testSchemaValue($input, string $expected)
     {
         $result = $this->driver->schemaValue($input);
         $this->assertSame($expected, $result);

+ 1 - 1
tests/TestCase/Database/Expression/QueryExpressionTest.php

@@ -172,7 +172,7 @@ class QueryExpressionTest extends TestCase
      * @dataProvider methodsProvider
      * @return void
      */
-    public function testTypeMapUsage($method)
+    public function testTypeMapUsage(string $method)
     {
         $expr = new QueryExpression([], ['created' => 'date']);
         $expr->{$method}('created', 'foo');

+ 4 - 4
tests/TestCase/Database/Schema/MysqlSchemaTest.php

@@ -225,7 +225,7 @@ class MysqlSchemaTest extends TestCase
      * @dataProvider convertColumnProvider
      * @return void
      */
-    public function testConvertColumn($type, $expected)
+    public function testConvertColumn(string $type, array $expected)
     {
         $field = [
             'Field' => 'field',
@@ -826,7 +826,7 @@ SQL;
      * @dataProvider columnSqlProvider
      * @return void
      */
-    public function testColumnSql($name, $data, $expected)
+    public function testColumnSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new MysqlSchemaDialect($driver);
@@ -900,7 +900,7 @@ SQL;
      *
      * @dataProvider constraintSqlProvider
      */
-    public function testConstraintSql($name, $data, $expected)
+    public function testConstraintSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new MysqlSchemaDialect($driver);
@@ -941,7 +941,7 @@ SQL;
      *
      * @dataProvider indexSqlProvider
      */
-    public function testIndexSql($name, $data, $expected)
+    public function testIndexSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new MysqlSchemaDialect($driver);

+ 3 - 3
tests/TestCase/Database/Schema/PostgresSchemaTest.php

@@ -250,7 +250,7 @@ SQL;
      * @dataProvider convertColumnProvider
      * @return void
      */
-    public function testConvertColumn($field, $expected)
+    public function testConvertColumn(array $field, array $expected)
     {
         $field += [
             'name' => 'field',
@@ -966,7 +966,7 @@ SQL;
      * @dataProvider columnSqlProvider
      * @return void
      */
-    public function testColumnSql($name, $data, $expected)
+    public function testColumnSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new PostgresSchemaDialect($driver);
@@ -1055,7 +1055,7 @@ SQL;
      *
      * @dataProvider constraintSqlProvider
      */
-    public function testConstraintSql($name, $data, $expected)
+    public function testConstraintSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new PostgresSchemaDialect($driver);

+ 4 - 4
tests/TestCase/Database/Schema/SqliteSchemaTest.php

@@ -157,7 +157,7 @@ class SqliteSchemaTest extends TestCase
      * @dataProvider convertColumnProvider
      * @return void
      */
-    public function testConvertColumn($type, $expected)
+    public function testConvertColumn(string $type, array $expected)
     {
         $field = [
             'pk' => false,
@@ -719,7 +719,7 @@ SQL;
      * @dataProvider columnSqlProvider
      * @return void
      */
-    public function testColumnSql($name, $data, $expected)
+    public function testColumnSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new SqliteSchemaDialect($driver);
@@ -838,7 +838,7 @@ SQL;
      *
      * @dataProvider constraintSqlProvider
      */
-    public function testConstraintSql($name, $data, $expected)
+    public function testConstraintSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new SqliteSchemaDialect($driver);
@@ -874,7 +874,7 @@ SQL;
      *
      * @dataProvider indexSqlProvider
      */
-    public function testIndexSql($name, $data, $expected)
+    public function testIndexSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new SqliteSchemaDialect($driver);

+ 5 - 4
tests/TestCase/Database/Schema/SqlserverSchemaTest.php

@@ -20,6 +20,7 @@ use Cake\Database\Driver\Sqlserver;
 use Cake\Database\Schema\Collection as SchemaCollection;
 use Cake\Database\Schema\SqlserverSchemaDialect;
 use Cake\Database\Schema\TableSchema;
+use Cake\Datasource\ConnectionInterface;
 use Cake\Datasource\ConnectionManager;
 use Cake\TestSuite\TestCase;
 use PDO;
@@ -45,7 +46,7 @@ class SqlserverSchemaTest extends TestCase
      *
      * @return void
      */
-    protected function _createTables($connection)
+    protected function _createTables(ConnectionInterface $connection)
     {
         $this->_needsConnection();
 
@@ -301,7 +302,7 @@ SQL;
      * @dataProvider convertColumnProvider
      * @return void
      */
-    public function testConvertColumn($type, $length, $precision, $scale, $expected)
+    public function testConvertColumn(string $type, ?int $length, ?int $precision, ?int $scale, array $expected)
     {
         $field = [
             'name' => 'field',
@@ -824,7 +825,7 @@ SQL;
      * @dataProvider columnSqlProvider
      * @return void
      */
-    public function testColumnSql($name, $data, $expected)
+    public function testColumnSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new SqlserverSchemaDialect($driver);
@@ -889,7 +890,7 @@ SQL;
      *
      * @dataProvider constraintSqlProvider
      */
-    public function testConstraintSql($name, $data, $expected)
+    public function testConstraintSql(string $name, array $data, string $expected)
     {
         $driver = $this->_getMockedDriver();
         $schema = new SqlserverSchemaDialect($driver);

+ 3 - 3
tests/TestCase/Database/Schema/TableSchemaTest.php

@@ -394,7 +394,7 @@ class TableSchemaTest extends TestCase
      * @dataProvider addConstraintErrorProvider
      * @return void
      */
-    public function testAddConstraintError($props)
+    public function testAddConstraintError(array $props)
     {
         $this->expectException(\Cake\Database\Exception::class);
         $table = new TableSchema('articles');
@@ -448,7 +448,7 @@ class TableSchemaTest extends TestCase
      * @dataProvider addIndexErrorProvider
      * @return void
      */
-    public function testAddIndexError($props)
+    public function testAddIndexError(array $props)
     {
         $this->expectException(\Cake\Database\Exception::class);
         $table = new TableSchema('articles');
@@ -639,7 +639,7 @@ class TableSchemaTest extends TestCase
      * @dataProvider badForeignKeyProvider
      * @return void
      */
-    public function testAddConstraintForeignKeyBadData($data)
+    public function testAddConstraintForeignKeyBadData(array $data)
     {
         $this->expectException(\Cake\Database\Exception::class);
         $table = new TableSchema('articles');

+ 4 - 0
tests/TestCase/Database/Type/DateTimeFractionalTypeTest.php

@@ -292,6 +292,8 @@ class DateTimeFractionalTypeTest extends TestCase
      * test marshalling data.
      *
      * @dataProvider marshalProvider
+     * @param mixed $value
+     * @param mixed $expected
      * @return void
      */
     public function testMarshal($value, $expected)
@@ -401,6 +403,8 @@ class DateTimeFractionalTypeTest extends TestCase
      * test marshalling data.
      *
      * @dataProvider marshalProviderWithoutMicroseconds
+     * @param mixed $value
+     * @param mixed $expected
      * @return void
      */
     public function testMarshalWithoutMicroseconds($value, $expected)

+ 4 - 0
tests/TestCase/Database/Type/DateTimeTimezoneTypeTest.php

@@ -332,6 +332,8 @@ class DateTimeTimezoneTypeTest extends TestCase
      * test marshalling data.
      *
      * @dataProvider marshalProvider
+     * @param mixed $value
+     * @param mixed $expected
      * @return void
      */
     public function testMarshal($value, $expected)
@@ -441,6 +443,8 @@ class DateTimeTimezoneTypeTest extends TestCase
      * test marshalling data.
      *
      * @dataProvider marshalProviderWithoutMicroseconds
+     * @param mixed $value
+     * @param mixed $expected
      * @return void
      */
     public function testMarshalWithoutMicroseconds($value, $expected)

+ 2 - 0
tests/TestCase/Database/Type/DateTimeTypeTest.php

@@ -296,6 +296,8 @@ class DateTimeTypeTest extends TestCase
      * test marshalling data.
      *
      * @dataProvider marshalProvider
+     * @param mixed $value
+     * @param mixed $expected
      * @return void
      */
     public function testMarshal($value, $expected)

+ 2 - 0
tests/TestCase/Database/Type/DateTypeTest.php

@@ -200,6 +200,8 @@ class DateTypeTest extends TestCase
      * test marshaling data.
      *
      * @dataProvider marshalProvider
+     * @param mixed $value
+     * @param mixed $expected
      * @return void
      */
     public function testMarshal($value, $expected)

+ 2 - 0
tests/TestCase/Database/Type/TimeTypeTest.php

@@ -209,6 +209,8 @@ class TimeTypeTest extends TestCase
      * test marshalling data.
      *
      * @dataProvider marshalProvider
+     * @param mixed $value
+     * @param mixed $expected
      * @return void
      */
     public function testMarshal($value, $expected)

+ 1 - 1
tests/TestCase/Database/TypeFactoryTest.php

@@ -64,7 +64,7 @@ class TypeFactoryTest extends TestCase
      * @dataProvider basicTypesProvider
      * @return void
      */
-    public function testBuildBasicTypes($name)
+    public function testBuildBasicTypes(string $name)
     {
         $type = TypeFactory::build($name);
         $this->assertInstanceOf(TypeInterface::class, $type);

+ 2 - 1
tests/TestCase/Datasource/ConnectionManagerTest.php

@@ -56,6 +56,7 @@ class ConnectionManagerTest extends TestCase
      * Test the various valid config() calls.
      *
      * @dataProvider configProvider
+     * @param \Cake\Datasource\ConnectionInterface|array $settings
      * @return void
      */
     public function testConfigVariants($settings)
@@ -400,7 +401,7 @@ class ConnectionManagerTest extends TestCase
      * @dataProvider dsnProvider
      * @return void
      */
-    public function testParseDsn($dsn, $expected)
+    public function testParseDsn(string $dsn, array $expected)
     {
         $result = ConnectionManager::parseDsn($dsn);
         $this->assertEquals($expected, $result);

+ 1 - 1
tests/TestCase/Datasource/PaginatorTestTrait.php

@@ -1209,7 +1209,7 @@ trait PaginatorTestTrait
      * @dataProvider checkLimitProvider
      * @return void
      */
-    public function testCheckLimit($input, $expected)
+    public function testCheckLimit(array $input, int $expected)
     {
         $result = $this->Paginator->checkLimit($input);
         $this->assertSame($expected, $result['limit']);

+ 1 - 1
tests/TestCase/Error/DebuggerTest.php

@@ -293,7 +293,7 @@ class DebuggerTest extends TestCase
      *
      * @return void
      */
-    public function customFormat($error, $strings)
+    public function customFormat(array $error, array $strings)
     {
         echo $error['error'] . ': I eated an error ' . $error['file'];
     }

+ 1 - 1
tests/TestCase/Error/ErrorHandlerTest.php

@@ -190,7 +190,7 @@ class ErrorHandlerTest extends TestCase
      * @dataProvider errorProvider
      * @return void
      */
-    public function testErrorMapping($error, $expected)
+    public function testErrorMapping(int $error, string $expected)
     {
         $errorHandler = new ErrorHandler();
         $errorHandler->register();

+ 4 - 1
tests/TestCase/Mailer/EmailTest.php

@@ -2274,7 +2274,10 @@ class EmailTest extends TestCase
         $this->assertStringContainsString(mb_convert_encoding('①㈱', 'ISO-2022-JP-MS'), $result['message']);
     }
 
-    protected function _checkContentTransferEncoding($message, $charset)
+    /**
+     * @param array|string $message
+     */
+    protected function _checkContentTransferEncoding($message, string $charset)
     {
         $boundary = '--' . $this->Email->getBoundary();
         $result['text'] = false;