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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ permissions:

jobs:
testsuite:
uses: ADmad/.github/.github/workflows/testsuite-with-db.yml@master
uses: ADmad/.github/.github/workflows/testsuite-with-db.yml@cake6
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

cs-stan:
uses: ADmad/.github/.github/workflows/cs-stan.yml@master
uses: ADmad/.github/.github/workflows/cs-stan.yml@cake6
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ Copyright (c) 2015-Present, [Use Muffin][muffin] and licensed under [The MIT Lic
[composer]:http://getcomposer.org
[mit]:http://www.opensource.org/licenses/mit-license.php
[muffin]:http://usemuffin.com
[standards]:http://book.cakephp.org/5/en/contributing/cakephp-coding-conventions.html
[standards]:http://book.cakephp.org/6/en/contributing/cakephp-coding-conventions.html
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
"source": "https://github.com/usemuffin/orderly"
},
"require": {
"cakephp/orm": "^5.0"
"php": ">=8.5",
"cakephp/orm": "^6.0"
},
"require-dev": {
"cakephp/cakephp": "^5.0",
"phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4"
"cakephp/cakephp": "^6.0",
"phpunit/phpunit": "^13.2"
},
"autoload": {
"psr-4": {
Expand All @@ -52,5 +53,7 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
5 changes: 1 addition & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
parameters:
level: 7
treatPhpDocTypesAsCertain: false
level: 8
bootstrapFiles:
- tests/bootstrap.php
paths:
- src
ignoreErrors:
- identifier: missingType.generics
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.3/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Orderly Test Cases">
<directory>./tests/</directory>
Expand Down
18 changes: 9 additions & 9 deletions src/Model/Behavior/OrderlyBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public function initialize(array $config): void
{
parent::initialize($config);

$this->_normalizeConfig($config);
$this->normalizeConfig($config);
}

/**
* Add the default order clause to the query as necessary.
*
* @param \Cake\Event\EventInterface $event Event
* @param \Cake\ORM\Query\SelectQuery $query Query
* @param \ArrayObject $options Options
* @param \Cake\Event\EventInterface<\Cake\ORM\Table> $event Event
* @param \Cake\ORM\Query\SelectQuery<\Cake\Datasource\EntityInterface|array<mixed>> $query Query
* @param \ArrayObject<string, mixed> $options Options
* @param bool $primary Boolean indicating whether it's primary query.
* @return void
*/
Expand All @@ -38,7 +38,7 @@ public function beforeFind(EventInterface $event, SelectQuery $query, ArrayObjec
return;
}

$orders = $this->_config['orders'];
$orders = $this->config['orders'];
foreach ($orders as $config) {
if (
empty($config['callback'])
Expand All @@ -55,7 +55,7 @@ public function beforeFind(EventInterface $event, SelectQuery $query, ArrayObjec
* @param array<string, mixed> $orders Orders config
* @return void
*/
protected function _normalizeConfig(array $orders): void
protected function normalizeConfig(array $orders): void
{
unset($orders['className']);

Expand All @@ -67,8 +67,8 @@ protected function _normalizeConfig(array $orders): void

$default = [
'order' => array_map(
$this->_table->aliasField(...),
(array)$this->_table->getDisplayField(),
$this->table->aliasField(...),
(array)$this->table->getDisplayField(),
),
'callback' => null,
];
Expand All @@ -77,7 +77,7 @@ protected function _normalizeConfig(array $orders): void
$orders[$key] = $orders[$key] + $default;
}

$this->_config = [
$this->config = [
'orders' => $orders,
];
}
Expand Down
22 changes: 11 additions & 11 deletions tests/TestCase/Model/Behavior/OrderlyBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,37 +67,37 @@ public function testInitialize()
$this->Table->removeBehavior('Orderly');
$this->Table->addBehavior('Muffin/Orderly.Orderly', ['callback' => $callback]);

$orders = $this->Table->behaviors()->Orderly->getConfig()['orders'];
$this->assertSame($callback, $orders[0]['callback']);
unset($orders[0]['callback']);

$expected = [
[
'order' => ['Posts.title'],
'callback' => $callback,
],
];
$this->assertEquals(
$expected,
$this->Table->behaviors()->Orderly->getConfig()['orders'],
);
$this->assertEquals($expected, $orders);

$this->Table->removeBehavior('Orderly');
$this->Table->addBehavior('Muffin/Orderly.Orderly', [
[],
['order' => 'published', 'callback' => $callback],
]);

$orders = $this->Table->behaviors()->Orderly->getConfig()['orders'];
$this->assertNull($orders[0]['callback']);
$this->assertSame($callback, $orders[1]['callback']);
unset($orders[0]['callback'], $orders[1]['callback']);

$expected = [
[
'order' => ['Posts.title'],
'callback' => null,
],
[
'order' => 'published',
'callback' => $callback,
],
];
$this->assertEquals(
$expected,
$this->Table->behaviors()->Orderly->getConfig()['orders'],
);
$this->assertEquals($expected, $orders);
}

public function testBeforeFind()
Expand Down
Loading