Skip to content

Commit bd2d786

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
2 parents f875417 + 8cedb51 commit bd2d786

File tree

16 files changed

+83
-53
lines changed

16 files changed

+83
-53
lines changed

system/Helpers/date_helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ function timezone_select(string $class = '', string $default = '', int $what = D
5454
{
5555
$timezones = DateTimeZone::listIdentifiers($what, $country);
5656

57-
$buffer = "<select name='timezone' class='{$class}'>" . PHP_EOL;
57+
$buffer = "<select name='timezone' class='{$class}'>\n";
5858

5959
foreach ($timezones as $timezone) {
6060
$selected = ($timezone === $default) ? 'selected' : '';
61-
$buffer .= "<option value='{$timezone}' {$selected}>{$timezone}</option>" . PHP_EOL;
61+
$buffer .= "<option value='{$timezone}' {$selected}>{$timezone}</option>\n";
6262
}
6363

64-
return $buffer . ('</select>' . PHP_EOL);
64+
return $buffer . ("</select>\n");
6565
}
6666
}

system/Validation/Rules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function not_in_list(?string $value, string $list): bool
209209
}
210210

211211
/**
212-
* @param mixed $str
212+
* @param array|bool|float|int|object|string|null $str
213213
*/
214214
public function required($str = null): bool
215215
{

system/Validation/Validation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ public function run(?array $data = null, ?string $group = null, ?string $dbGroup
177177
* Runs the validation process, returning true or false
178178
* determining whether validation was successful or not.
179179
*
180-
* @param mixed $value
181-
* @param string[] $errors
180+
* @param array|bool|float|int|object|string|null $value
181+
* @param string[] $errors
182182
*/
183183
public function check($value, string $rule, array $errors = []): bool
184184
{

system/Validation/ValidationInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ public function run(?array $data = null, ?string $group = null, ?string $dbGroup
3232
* Check; runs the validation process, returning true or false
3333
* determining whether or not validation was successful.
3434
*
35-
* @param mixed $value Value to validation.
36-
* @param string $rule Rule.
37-
* @param string[] $errors Errors.
35+
* @param array|bool|float|int|object|string|null $value Value to validate.
36+
* @param string[] $errors
3837
*
3938
* @return bool True if valid, else false.
4039
*/

tests/_support/Config/TestRegistrar.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ public static function RegistrarConfig()
2525
'first',
2626
'second',
2727
],
28-
'format' => 'nice',
29-
'fruit' => [
30-
'apple',
31-
'banana',
32-
],
3328
];
3429
}
3530
}

tests/_support/Log/Handlers/TestHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ class TestHandler extends \CodeIgniter\Log\Handlers\FileHandler
2626
*/
2727
protected static $logs = [];
2828

29+
protected string $destination;
30+
2931
/**
3032
* Where would the log be written?
3133
*/
3234
public function __construct(array $config)
3335
{
3436
parent::__construct($config);
37+
3538
$this->handles = $config['handles'] ?? [];
3639
$this->destination = $this->path . 'log-' . date('Y-m-d') . '.' . $this->fileExtension;
3740

tests/system/Config/BaseConfigTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@ public function testRegistrars()
252252
$this->assertSame('bar', $config->foo);
253253
// add to an existing array property
254254
$this->assertSame(['baz', 'first', 'second'], $config->bar);
255-
// add a new property
256-
$this->assertSame('nice', $config->format);
257-
// add a new array property
258-
$this->assertSame(['apple', 'banana'], $config->fruit);
259255
}
260256

261257
public function testBadRegistrar()

tests/system/Config/FactoriesTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ public function testSetsOptions()
7575
public function testUsesConfigOptions()
7676
{
7777
// Simulate having a $widgets property in App\Config\Factory
78-
$config = new Factory();
79-
$config->widgets = ['bar' => 'bam'];
78+
$config = new class () extends Factory {
79+
public $widgets = ['bar' => 'bam'];
80+
};
8081
Factories::injectMock('config', Factory::class, $config);
8182

8283
$result = Factories::getOptions('widgets');

tests/system/ControllerTest.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace CodeIgniter;
1313

14+
use CodeIgniter\Config\Factories;
1415
use CodeIgniter\HTTP\IncomingRequest;
1516
use CodeIgniter\HTTP\Request;
1617
use CodeIgniter\HTTP\Response;
@@ -20,7 +21,9 @@
2021
use CodeIgniter\Validation\Exceptions\ValidationException;
2122
use Config\App;
2223
use Config\Services;
24+
use Config\Validation as ValidationConfig;
2325
use Psr\Log\LoggerInterface;
26+
use Tests\Support\Config\Validation;
2427

2528
/**
2629
* Exercise our core Controller class.
@@ -118,15 +121,17 @@ public function testValidateWithStringRulesNotFound()
118121

119122
public function testValidateWithStringRulesFoundReadMessagesFromValidationConfig()
120123
{
121-
$validation = config('Validation');
122-
$validation->signup = [
123-
'username' => 'required',
124-
];
125-
$validation->signup_errors = [
126-
'username' => [
127-
'required' => 'You must choose a username.',
128-
],
129-
];
124+
$validation = new class () extends ValidationConfig {
125+
public $signup = [
126+
'username' => 'required',
127+
];
128+
public $signup_errors = [
129+
'username' => [
130+
'required' => 'You must choose a username.',
131+
],
132+
];
133+
};
134+
Factories::injectMock('config', 'Validation', $validation);
130135

131136
// make sure we can instantiate one
132137
$this->controller = new Controller();
@@ -139,10 +144,12 @@ public function testValidateWithStringRulesFoundReadMessagesFromValidationConfig
139144

140145
public function testValidateWithStringRulesFoundUseMessagesParameter()
141146
{
142-
$validation = config('Validation');
143-
$validation->signup = [
144-
'username' => 'required',
145-
];
147+
$validation = new class () extends ValidationConfig {
148+
public $signup = [
149+
'username' => 'required',
150+
];
151+
};
152+
Factories::injectMock('config', 'Validation', $validation);
146153

147154
// make sure we can instantiate one
148155
$this->controller = new Controller();

tests/system/Helpers/DateHelperTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public function testTimezoneSelectDefault()
4040
{
4141
$timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL, null);
4242

43-
$expected = "<select name='timezone' class='custom-select'>" . PHP_EOL;
43+
$expected = "<select name='timezone' class='custom-select'>\n";
4444

4545
foreach ($timezones as $timezone) {
4646
$selected = ($timezone === 'Asia/Jakarta') ? 'selected' : '';
47-
$expected .= "<option value='{$timezone}' {$selected}>{$timezone}</option>" . PHP_EOL;
47+
$expected .= "<option value='{$timezone}' {$selected}>{$timezone}</option>\n";
4848
}
4949

50-
$expected .= ('</select>' . PHP_EOL);
50+
$expected .= ("</select>\n");
5151

5252
$this->assertSame($expected, timezone_select('custom-select', 'Asia/Jakarta'));
5353
}
@@ -57,14 +57,14 @@ public function testTimezoneSelectSpecific()
5757
$spesificRegion = DateTimeZone::ASIA;
5858
$timezones = DateTimeZone::listIdentifiers($spesificRegion, null);
5959

60-
$expected = "<select name='timezone' class='custom-select'>" . PHP_EOL;
60+
$expected = "<select name='timezone' class='custom-select'>\n";
6161

6262
foreach ($timezones as $timezone) {
6363
$selected = ($timezone === 'Asia/Jakarta') ? 'selected' : '';
64-
$expected .= "<option value='{$timezone}' {$selected}>{$timezone}</option>" . PHP_EOL;
64+
$expected .= "<option value='{$timezone}' {$selected}>{$timezone}</option>\n";
6565
}
6666

67-
$expected .= ('</select>' . PHP_EOL);
67+
$expected .= ("</select>\n");
6868

6969
$this->assertSame($expected, timezone_select('custom-select', 'Asia/Jakarta', $spesificRegion));
7070
}
@@ -75,14 +75,14 @@ public function testTimezoneSelectSingle()
7575
$country = 'ID';
7676
$timezones = DateTimeZone::listIdentifiers($spesificRegion, $country);
7777

78-
$expected = "<select name='timezone' class='custom-select'>" . PHP_EOL;
78+
$expected = "<select name='timezone' class='custom-select'>\n";
7979

8080
foreach ($timezones as $timezone) {
8181
$selected = ($timezone === 'Asia/Jakarta') ? 'selected' : '';
82-
$expected .= "<option value='{$timezone}' {$selected}>{$timezone}</option>" . PHP_EOL;
82+
$expected .= "<option value='{$timezone}' {$selected}>{$timezone}</option>\n";
8383
}
8484

85-
$expected .= ('</select>' . PHP_EOL);
85+
$expected .= ("</select>\n");
8686

8787
$this->assertSame($expected, timezone_select('custom-select', 'Asia/Jakarta', $spesificRegion, $country));
8888
}

0 commit comments

Comments
 (0)