Skip to content

Commit

Permalink
[#14734] - Corrected some Crypt tests (why not); Adjusted "cat" methods
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Feb 19, 2020
1 parent cfb33db commit e4a6843
Show file tree
Hide file tree
Showing 28 changed files with 249 additions and 378 deletions.
2 changes: 0 additions & 2 deletions phalcon/DataMapper/Query/AbstractQuery.zep
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
namespace Phalcon\DataMapper\Query;

use Phalcon\DataMapper\Pdo\Connection;
use Phalcon\DataMapper\Pdo\Exception\CannotBindValue;

/**
* Class AbstractQuery
Expand Down Expand Up @@ -124,7 +123,6 @@ abstract class AbstractQuery
* Performs a statement in the connection
*
* @return PDOStatement
* @throws CannotBindValue
*/
public function perform()
{
Expand Down
6 changes: 3 additions & 3 deletions phalcon/DataMapper/Query/Delete.zep
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ class Delete extends AbstractConditions
/**
* Adds the `RETURNING` clause
*
* @param string ...$columns
* @param array $columns
*
* @return Delete
*/
public function returning() -> <Delete>
public function returning(array columns) -> <Delete>
{
let this->store["RETURNING"] = array_merge(
this->store["RETURNING"],
func_get_args()
columns
);

return this;
Expand Down
7 changes: 3 additions & 4 deletions phalcon/DataMapper/Query/Insert.zep
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace Phalcon\DataMapper\Query;

use BadMethodCallException;
use Phalcon\DataMapper\Pdo\Connection;

/**
Expand Down Expand Up @@ -118,15 +117,15 @@ class Insert extends AbstractQuery
/**
* Adds the `RETURNING` clause
*
* @param string ...$columns
* @param array $columns
*
* @return Insert
*/
public function returning() -> <Insert>
public function returning(array columns) -> <Insert>
{
let this->store["RETURNING"] = array_merge(
this->store["RETURNING"],
func_get_args()
columns
);

return this;
Expand Down
4 changes: 2 additions & 2 deletions phalcon/DataMapper/Query/Select.zep
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Select extends AbstractConditions
*
* @return Select
*/
public function catHaving(
public function appendHaving(
string condition,
var value = null,
int type = -1
Expand All @@ -159,7 +159,7 @@ class Select extends AbstractConditions
*
* @return Select
*/
public function catJoin(
public function appendJoin(
string condition,
var value = null,
int type = -1
Expand Down
7 changes: 3 additions & 4 deletions phalcon/DataMapper/Query/Update.zep
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace Phalcon\DataMapper\Query;

use BadMethodCallException;
use Phalcon\DataMapper\Pdo\Connection;

/**
Expand Down Expand Up @@ -117,15 +116,15 @@ class Update extends AbstractConditions
/**
* Adds the `RETURNING` clause
*
* @param string ...$columns
* @param array $columns
*
* @return Update
*/
public function returning() -> <Update>
public function returning(array columns) -> <Update>
{
let this->store["RETURNING"] = array_merge(
this->store["RETURNING"],
func_get_args()
columns
);

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function dMQueryDeleteGetStatement(DatabaseTester $I)
->where('inv_total > :total')
->where('inv_cst_id = :cstId')
->orWhere('inv_status_flag = :flag')
->returning('inv_total', 'inv_cst_id', 'inv_status_flag')
->returning(['inv_total', 'inv_cst_id', 'inv_status_flag'])
->bindValues(
[
'total' => 100,
Expand Down
4 changes: 2 additions & 2 deletions tests/database/DataMapper/Query/Insert/GetStatementCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function dMQueryInsertGetStatement(DatabaseTester $I)
->set('inv_status_flag', 1)
->set('inv_created_date', 'NOW()')
->columns(['inv_cst_id' => 1])
->returning('inv_id', 'inv_cst_id')
->returning('inv_total')
->returning(['inv_id', 'inv_cst_id'])
->returning(['inv_total'])
;

$expected = sprintf(
Expand Down
2 changes: 1 addition & 1 deletion tests/database/DataMapper/Query/Select/HavingCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function dMQuerySelectHavingComplex(DatabaseTester $I)
->having('inv_total = :total')
->andHaving('inv_cst_id = 1')
->orHaving('(inv_status_flag = 0 ')
->catHaving('OR inv_status_flag = 1)')
->appendHaving('OR inv_status_flag = 1)')
->bindValue('total', 100)
;

Expand Down
2 changes: 1 addition & 1 deletion tests/database/DataMapper/Query/Select/JoinCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function dMQuerySelectJoinWithBind(DatabaseTester $I)
'inv_cst_id = cst_id AND cst_status_flag = ',
1
)
->catJoin(' AND cst_name LIKE ', '%john%')
->appendJoin(' AND cst_name LIKE ', '%john%')
;

$expected = "SELECT * FROM co_invoices "
Expand Down
4 changes: 2 additions & 2 deletions tests/database/DataMapper/Query/Update/GetStatementCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public function dMQueryUpdateGetStatement(DatabaseTester $I)
$I->assertEquals($expected, $actual);

$update
->returning('inv_id', 'inv_cst_id')
->returning('inv_total')
->returning(['inv_id', 'inv_cst_id'])
->returning(['inv_total'])
;

$expected = sprintf(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Crypt/DecryptBase64Cest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Phalcon\Test\Unit\Crypt;

use Phalcon\Crypt;
use Phalcon\Crypt\Mismatch;
use Phalcon\Crypt\MismatchException;
use UnitTester;

class DecryptBase64Cest
Expand Down Expand Up @@ -52,7 +52,7 @@ public function shouldNotThrowExceptionIfKeyMismatch(UnitTester $I)
public function shouldThrowExceptionIfHashMismatch(UnitTester $I)
{
$I->expectThrowable(
new Mismatch('Hash does not match.'),
new MismatchException('Hash does not match.'),
function () {
$crypt = new Crypt();

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Crypt/DecryptCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Phalcon\Test\Unit\Crypt;

use Phalcon\Crypt;
use Phalcon\Crypt\Mismatch;
use Phalcon\Crypt\MismatchException;
use UnitTester;

class DecryptCest
Expand Down Expand Up @@ -52,7 +52,7 @@ public function shouldNotThrowExceptionIfKeyMismatch(UnitTester $I)
public function shouldThrowExceptionIfHashMismatch(UnitTester $I)
{
$I->expectThrowable(
new Mismatch('Hash does not match.'),
new MismatchException('Hash does not match.'),
function () {
$crypt = new Crypt();

Expand Down
32 changes: 0 additions & 32 deletions tests/unit/Crypt/GetAuthDataCest.php

This file was deleted.

32 changes: 0 additions & 32 deletions tests/unit/Crypt/GetAuthTagCest.php

This file was deleted.

32 changes: 0 additions & 32 deletions tests/unit/Crypt/GetAuthTagLengthCest.php

This file was deleted.

32 changes: 0 additions & 32 deletions tests/unit/Crypt/GetHashAlgoCest.php

This file was deleted.

32 changes: 0 additions & 32 deletions tests/unit/Crypt/GetKeyCest.php

This file was deleted.

40 changes: 40 additions & 0 deletions tests/unit/Crypt/GetSetAuthDataCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
*
* 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\Unit\Crypt;

use Phalcon\Crypt;
use UnitTester;

class GetSetAuthDataCest
{
/**
* Unit Tests Phalcon\Crypt :: getAuthData()/setAuthData()
*
* @author Phalcon Team <[email protected]>
* @since 2020-02-16
*/
public function cryptGetSetAuthData(UnitTester $I)
{
$I->wantToTest('Crypt - getAuthData()/setAuthData()');

$crypt = new Crypt();

$crypt->setAuthData('test-data');

$I->assertEquals(
'test-data',
$crypt->getAuthData()
);
}
}
Loading

0 comments on commit e4a6843

Please sign in to comment.