Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Oct 12, 2022
2 parents 323dee6 + 8255215 commit ce7de2d
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 1,364 deletions.
2 changes: 1 addition & 1 deletion system/Validation/StrictRules/CreditCardRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct()
* 'cc_num' => 'valid_cc_number[visa]'
* ];
*
* @param mixed $ccNumber
* @param array|bool|float|int|object|string|null $ccNumber
*/
public function valid_cc_number($ccNumber, string $type): bool
{
Expand Down
50 changes: 25 additions & 25 deletions system/Validation/StrictRules/FormatRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()
/**
* Alpha
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function alpha($str = null): bool
{
Expand All @@ -44,7 +44,7 @@ public function alpha($str = null): bool
/**
* Alpha with spaces.
*
* @param mixed $value Value.
* @param array|bool|float|int|object|string|null $value Value.
*
* @return bool True if alpha with spaces, else false.
*/
Expand All @@ -60,7 +60,7 @@ public function alpha_space($value = null): bool
/**
* Alphanumeric with underscores and dashes
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function alpha_dash($str = null): bool
{
Expand All @@ -82,7 +82,7 @@ public function alpha_dash($str = null): bool
* _ underscore, + plus, = equals, | vertical bar, : colon, . period
* ~ ! # $ % & * - _ + = | : .
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*
* @return bool
*/
Expand All @@ -102,7 +102,7 @@ public function alpha_numeric_punct($str)
/**
* Alphanumeric
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function alpha_numeric($str = null): bool
{
Expand All @@ -120,7 +120,7 @@ public function alpha_numeric($str = null): bool
/**
* Alphanumeric w/ spaces
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function alpha_numeric_space($str = null): bool
{
Expand All @@ -138,7 +138,7 @@ public function alpha_numeric_space($str = null): bool
/**
* Any type of string
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function string($str = null): bool
{
Expand All @@ -148,7 +148,7 @@ public function string($str = null): bool
/**
* Decimal number
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function decimal($str = null): bool
{
Expand All @@ -166,7 +166,7 @@ public function decimal($str = null): bool
/**
* String of hexidecimal characters
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function hex($str = null): bool
{
Expand All @@ -184,7 +184,7 @@ public function hex($str = null): bool
/**
* Integer
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function integer($str = null): bool
{
Expand All @@ -202,7 +202,7 @@ public function integer($str = null): bool
/**
* Is a Natural number (0,1,2,3, etc.)
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function is_natural($str = null): bool
{
Expand All @@ -220,7 +220,7 @@ public function is_natural($str = null): bool
/**
* Is a Natural number, but not a zero (1,2,3, etc.)
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function is_natural_no_zero($str = null): bool
{
Expand All @@ -238,7 +238,7 @@ public function is_natural_no_zero($str = null): bool
/**
* Numeric
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function numeric($str = null): bool
{
Expand All @@ -256,7 +256,7 @@ public function numeric($str = null): bool
/**
* Compares value against a regular expression pattern.
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function regex_match($str, string $pattern): bool
{
Expand All @@ -273,7 +273,7 @@ public function regex_match($str, string $pattern): bool
*
* @see http://php.net/manual/en/datetimezone.listidentifiers.php
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function timezone($str = null): bool
{
Expand All @@ -290,7 +290,7 @@ public function timezone($str = null): bool
* Tests a string for characters outside of the Base64 alphabet
* as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function valid_base64($str = null): bool
{
Expand All @@ -304,7 +304,7 @@ public function valid_base64($str = null): bool
/**
* Valid JSON
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function valid_json($str = null): bool
{
Expand All @@ -318,7 +318,7 @@ public function valid_json($str = null): bool
/**
* Checks for a correctly formatted email address
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function valid_email($str = null): bool
{
Expand All @@ -335,7 +335,7 @@ public function valid_email($str = null): bool
* Example:
* valid_emails[[email protected],[email protected]]
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function valid_emails($str = null): bool
{
Expand All @@ -349,8 +349,8 @@ public function valid_emails($str = null): bool
/**
* Validate an IP address (human readable format or binary string - inet_pton)
*
* @param mixed $ip
* @param string|null $which IP protocol: 'ipv4' or 'ipv6'
* @param array|bool|float|int|object|string|null $ip
* @param string|null $which IP protocol: 'ipv4' or 'ipv6'
*/
public function valid_ip($ip = null, ?string $which = null): bool
{
Expand All @@ -367,7 +367,7 @@ public function valid_ip($ip = null, ?string $which = null): bool
* Warning: this rule will pass basic strings like
* "banana"; use valid_url_strict for a stricter rule.
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function valid_url($str = null): bool
{
Expand All @@ -381,8 +381,8 @@ public function valid_url($str = null): bool
/**
* Checks a URL to ensure it's formed correctly.
*
* @param mixed $str
* @param string|null $validSchemes comma separated list of allowed schemes
* @param array|bool|float|int|object|string|null $str
* @param string|null $validSchemes comma separated list of allowed schemes
*/
public function valid_url_strict($str = null, ?string $validSchemes = null): bool
{
Expand All @@ -396,7 +396,7 @@ public function valid_url_strict($str = null, ?string $validSchemes = null): boo
/**
* Checks for a valid date and matches a given date format
*
* @param mixed $str
* @param array|bool|float|int|object|string|null $str
*/
public function valid_date($str = null, ?string $format = null): bool
{
Expand Down
2 changes: 2 additions & 0 deletions tests/_support/View/SampleClassWithInitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
class SampleClassWithInitController
{
private ResponseInterface $response;

public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->response = $response;
Expand Down
10 changes: 4 additions & 6 deletions tests/system/Database/Migrations/MigrationRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,16 @@ public function testSetNamespaceStoresValue()

public function testFindMigrationsReturnsEmptyArrayWithNoneFound()
{
$config = $this->config;
$config->type = 'timestamp';

$config = $this->config;
$runner = new MigrationRunner($config);

$this->assertSame([], $runner->findMigrations());
}

public function testFindMigrationsSuccessTimestamp()
{
$config = $this->config;
$config->type = 'timestamp';
$runner = new MigrationRunner($config);
$config = $this->config;
$runner = new MigrationRunner($config);

$runner = $runner->setNamespace('Tests\Support\MigrationTestMigrations');

Expand Down
10 changes: 5 additions & 5 deletions tests/system/Filters/FiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public function testRunDoesBefore()
$uri = 'admin/foo/bar';
$request = $filters->run($uri, 'before');

$this->assertSame('http://google.com', $request->url);
$this->assertSame('http://google.com', $request->getBody());
}

public function testRunDoesAfter()
Expand All @@ -519,7 +519,7 @@ public function testRunDoesAfter()
$uri = 'admin/foo/bar';
$response = $filters->run($uri, 'after');

$this->assertSame('http://google.com', $response->csp);
$this->assertSame('http://google.com', $response->getBody());
}

public function testShortCircuit()
Expand All @@ -540,7 +540,7 @@ public function testShortCircuit()
$response = $filters->run($uri, 'before');

$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertSame('http://google.com', $response->csp);
$this->assertSame('http://google.com', $response->getBody());
}

public function testOtherResult()
Expand Down Expand Up @@ -1103,8 +1103,8 @@ public function testFilterAliasMultiple()
$uri = 'admin/foo/bar';
$request = $filters->run($uri, 'before');

$this->assertSame('http://exampleMultipleURL.com', $request->url);
$this->assertSame('http://exampleMultipleCSP.com', $request->csp);
$this->assertSame('http://exampleMultipleURL.com', $request->header('x-url')->getValue());
$this->assertSame('http://exampleMultipleCSP.com', $request->header('x-csp')->getValue());
}

public function testFilterClass()
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Filters/fixtures/GoogleMe.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class GoogleMe implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
$request->url = 'http://google.com';
$request->setBody('http://google.com');

return $request;
}

public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
$response->csp = 'http://google.com';
$response->setBody('http://google.com');

return $response;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Filters/fixtures/GoogleYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class GoogleYou implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
$response = Services::response();
$response->csp = 'http://google.com';
$response = Services::response();
$response->setBody('http://google.com');

return $response;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Filters/fixtures/Multiple1.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Multiple1 implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
$request->csp = 'http://exampleMultipleCSP.com';
$request->setHeader('x-csp', 'http://exampleMultipleCSP.com');

return $request;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Filters/fixtures/Multiple2.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Multiple2 implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
$request->url = 'http://exampleMultipleURL.com';
$request->setHeader('x-url', 'http://exampleMultipleURL.com');

return $request;
}
Expand Down
4 changes: 0 additions & 4 deletions tests/system/Models/GeneralModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ public function testMagicGetters(): void
$this->assertFalse(isset($this->model->foobar));
$this->assertNull($this->model->foobar);

$this->model->flavor = 'chocolate';
$this->assertTrue(isset($this->model->flavor));
$this->assertSame('chocolate', $this->model->flavor);

// from DB
$this->assertTrue(isset($this->model->DBPrefix));
$this->assertSame('utf8', $this->model->charset);
Expand Down
25 changes: 12 additions & 13 deletions tests/system/Models/ValidationModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,26 +238,25 @@ public function testValidationPassesWithMissingFields(): void

public function testValidationWithGroupName(): void
{
$config = new Validation();
$config = new class () extends Validation {
public $grouptest = [
'name' => [
'required',
'min_length[3]',
],
'token' => 'in_list[{id}]',
];
};
Factories::injectMock('config', 'Validation', $config);

$config->grouptest = [
'name' => [
'required',
'min_length[3]',
],
'token' => 'in_list[{id}]',
];
$this->createModel(ValidModel::class);
$this->setPrivateProperty($this->model, 'validationRules', 'grouptest');

$data = [
'name' => 'abc',
'id' => 13,
'token' => 13,
];

Factories::injectMock('config', 'Validation', $config);

$this->createModel(ValidModel::class);
$this->setPrivateProperty($this->model, 'validationRules', 'grouptest');
$this->assertTrue($this->model->validate($data));
}

Expand Down
Loading

0 comments on commit ce7de2d

Please sign in to comment.