Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T15415 orderby interface 2 #15416

Merged
merged 4 commits into from
Apr 20, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Fixed
- Corrected the `Phalcon\Db\Profiler\Item` calculation for seconds [#15249](https://github.com/phalcon/cphalcon/issues/15249)
- Corrected `Phalcon\Http\Message\ServerRequestFactory` to populate with superglobals [#15286](https://github.com/phalcon/cphalcon/issues/15286)
- Corrected `Phalcon\Mvc\Model\Query\BuilderInterface::orderBy` to use `var` instead of `string` [#15415](https://github.com/phalcon/cphalcon/issues/15415)

# [5.0.0-alpha.1](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0-alpha.1) (2020-03-31)

Expand Down
2 changes: 1 addition & 1 deletion phalcon/Mvc/Model/Query/BuilderInterface.zep
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ interface BuilderInterface
/**
* Sets an ORDER BY condition clause
*/
public function orderBy(string orderBy) -> <BuilderInterface>;
public function orderBy(var orderBy) -> <BuilderInterface>;

/**
* Appends a condition to the current conditions using an OR operator
Expand Down
2 changes: 0 additions & 2 deletions tests/_data/fixtures/Traits/RecordsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ private function insertDataInvoices(
sprintf("Failed to insert row #%d into table '%s' using '%s' driver", $counter, $table, $driver)
);
}


}
}
}
3 changes: 0 additions & 3 deletions tests/database/Db/Adapter/Pdo/DescribeColumnsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@

use DatabaseTester;
use Phalcon\Db\Column;
use Phalcon\Storage\Exception;
use Phalcon\Test\Fixtures\Migrations\AbstractMigration;
use Phalcon\Test\Fixtures\Migrations\ComplexDefaultMigration;
use Phalcon\Test\Fixtures\Migrations\DialectMigration;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use function var_dump;

class DescribeColumnsCest
{
Expand Down
1 change: 1 addition & 0 deletions tests/database/Db/Adapter/Pdo/ExecInsertCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Phalcon\Test\Fixtures\Migrations\DialectMigration;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use PHPUnit\Framework\Assert;

use function array_keys;
use function array_values;
use function pack;
Expand Down
88 changes: 88 additions & 0 deletions tests/database/Mvc/Model/Query/Builder/OrderByCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalcon.io>
*
* For the full copyright and license information, please view the
* LICENSE.txt file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\Test\Database\Mvc\Model\Query\Builder;

use DatabaseTester;
use Phalcon\Mvc\Model\Query\Builder;
use Phalcon\Storage\Exception;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Fixtures\Traits\RecordsTrait;
use Phalcon\Test\Models\Invoices;

class OrderByCest
{
use DiTrait;
use RecordsTrait;

/**
* Executed before each test
*
* @param DatabaseTester $I
*
* @return void
*/
public function _before(DatabaseTester $I): void
{
try {
$this->setNewFactoryDefault();
} catch (Exception $e) {
$I->fail($e->getMessage());
}

$this->setDatabase($I);
}

/**
* Tests Phalcon\Mvc\Model\Query :: getSql() - Issue 14657
*
* @param DatabaseTester $I
*
* @author Phalcon Team <team@phalcon.io>
* @since 2021-04-20
* @issue 15411
*
* @group mysql
* @group pgsql
* @group sqlite
*/
public function mvcModelQueryBuilderOrderBy(DatabaseTester $I)
{
$I->wantToTest('Mvc\Model\Query\Builder :: orderBy()');

$builder = new Builder();
$phql = $builder
->columns('inv_id, inv_title')
->addFrom(Invoices::class)
->orderBy('inv_title')
->getPhql()
;

$expected = 'SELECT inv_id, inv_title '
. 'FROM [Phalcon\Test\Models\Invoices] '
. 'ORDER BY inv_title';
$actual = $phql;
$I->assertEquals($expected, $actual);

$phql = $builder
->orderBy('inv_title DESC')
->getPhql()
;

$expected = 'SELECT inv_id, inv_title '
. 'FROM [Phalcon\Test\Models\Invoices] '
. 'ORDER BY inv_title DESC';
$actual = $phql;
$I->assertEquals($expected, $actual);
}
}
9 changes: 5 additions & 4 deletions tests/database/Mvc/Model/Query/GetSqlCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class GetSqlCest
/**
* Executed before each test
*
* @param DatabaseTester $I
* @param DatabaseTester $I
*
* @return void
*/
public function _before(DatabaseTester $I): void
Expand All @@ -53,7 +54,7 @@ public function _before(DatabaseTester $I): void
/**
* Tests Phalcon\Mvc\Model\Query :: getSql() - Issue 14657
*
* @param DatabaseTester $I
* @param DatabaseTester $I
*
* @author Phalcon Team <team@phalcon.io>
* @since 2020-05-06
Expand Down Expand Up @@ -85,8 +86,8 @@ public function mvcModelQueryGetSql(DatabaseTester $I)

$I->assertEquals(
[
'sql' => $sql,
'bind' => [],
'sql' => $sql,
'bind' => [],
'bindTypes' => [],
],
$query->getSql()
Expand Down
1 change: 0 additions & 1 deletion tests/unit/Logger/Logger/LogCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function loggerLog(UnitTester $I)
];

foreach ($levels as $level => $levelName) {

$fileName = $I->getNewFileName('log', 'log');
$adapter = new Stream($logPath . $fileName);

Expand Down