Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions tests/system/Cache/Handlers/BaseTestFileHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

declare(strict_types=1);

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace CodeIgniter\Cache\Handlers;

use Config\Cache;

/**
* @internal
*/
final class BaseTestFileHandler extends FileHandler
{
private static string $directory = 'FileHandler';
private readonly Cache $config;

public function __construct()
{
$this->config = new Cache();
$this->config->file['storePath'] .= self::$directory;

parent::__construct($this->config);

helper('filesystem');
}

/**
* @return array{
* name: string,
* server_path: string,
* size: int,
* date: int,
* readable: bool,
* writable: bool,
* executable: bool,
* fileperms: int,
* }|null
*/
public function getFileInfoTest(): ?array
{
$tmpHandle = tmpfile();
stream_get_meta_data($tmpHandle);

return get_file_info(stream_get_meta_data($tmpHandle)['uri'], [
'name',
'server_path',
'size',
'date',
'readable',
'writable',
'executable',
'fileperms',
]);
}
}
48 changes: 0 additions & 48 deletions tests/system/Cache/Handlers/FileHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,51 +399,3 @@ public function testReconnect(): void
$this->assertTrue($this->handler->reconnect());
}
}

/**
* @internal
*/
final class BaseTestFileHandler extends FileHandler
{
private static string $directory = 'FileHandler';
private readonly Cache $config;

public function __construct()
{
$this->config = new Cache();
$this->config->file['storePath'] .= self::$directory;

parent::__construct($this->config);

helper('filesystem');
}

/**
* @return array{
* name: string,
* server_path: string,
* size: int,
* date: int,
* readable: bool,
* writable: bool,
* executable: bool,
* fileperms: int,
* }|null
*/
public function getFileInfoTest(): ?array
{
$tmpHandle = tmpfile();
stream_get_meta_data($tmpHandle);

return get_file_info(stream_get_meta_data($tmpHandle)['uri'], [
'name',
'server_path',
'size',
'date',
'readable',
'writable',
'executable',
'fileperms',
]);
}
}
45 changes: 45 additions & 0 deletions tests/system/View/DBResultDummy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace CodeIgniter\View;

use CodeIgniter\Database\MySQLi\Result;

// We need this for the _set_from_db_result() test
class DBResultDummy extends Result
{
public function getFieldNames(): array
{
return [
'name',
'email',
];
}

/**
* @return array<int, array<string, string>>
*/
public function getResultArray(): array
{
return [
[
'name' => 'John Doe',
'email' => 'john@doe.com',
],
[
'name' => 'Foo Bar',
'email' => 'foo@bar.com',
],
];
}
}
27 changes: 0 additions & 27 deletions tests/system/View/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace CodeIgniter\View;

use CodeIgniter\Database\MySQLi\Result;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\Mock\MockTable;
use PHPUnit\Framework\Attributes\DataProvider;
Expand Down Expand Up @@ -888,29 +887,3 @@ public function testGenerateTableWithHeadingContainFieldNamedData(): void
$this->assertStringContainsString('<td>codigo3</td><td>2023-10-16 21:53:25</td><td>PERCENTUAL</td><td>10</td>', $generated);
}
}

// We need this for the _set_from_db_result() test
class DBResultDummy extends Result
{
public function getFieldNames(): array
{
return [
'name',
'email',
];
}

public function getResultArray(): array
{
return [
[
'name' => 'John Doe',
'email' => 'john@doe.com',
],
[
'name' => 'Foo Bar',
'email' => 'foo@bar.com',
],
];
}
}
2 changes: 1 addition & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 2055 errors
# total 2054 errors

includes:
- argument.type.neon
Expand Down
13 changes: 4 additions & 9 deletions utils/phpstan-baseline/missingType.iterableValue.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 1258 errors
# total 1257 errors

parameters:
ignoreErrors:
Expand Down Expand Up @@ -6217,20 +6217,15 @@ parameters:
count: 1
path: ../../tests/system/Validation/ValidationTest.php

-
message: '#^Method CodeIgniter\\View\\ParserTest\:\:provideEscHandling\(\) return type has no value type specified in iterable type iterable\.$#'
count: 1
path: ../../tests/system/View/ParserTest.php

-
message: '#^Method CodeIgniter\\View\\DBResultDummy\:\:getFieldNames\(\) return type has no value type specified in iterable type array\.$#'
count: 1
path: ../../tests/system/View/TableTest.php
path: ../../tests/system/View/DBResultDummy.php

-
message: '#^Method CodeIgniter\\View\\DBResultDummy\:\:getResultArray\(\) return type has no value type specified in iterable type array\.$#'
message: '#^Method CodeIgniter\\View\\ParserTest\:\:provideEscHandling\(\) return type has no value type specified in iterable type iterable\.$#'
count: 1
path: ../../tests/system/View/TableTest.php
path: ../../tests/system/View/ParserTest.php

-
message: '#^Method CodeIgniter\\View\\TableTest\:\:orderedColumnUsecases\(\) return type has no value type specified in iterable type iterable\.$#'
Expand Down
Loading