Skip to content

Commit

Permalink
[#14080] - Fixed array to string conversion for delete
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Jul 6, 2019
1 parent 35163a4 commit 467ec6b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
2 changes: 1 addition & 1 deletion phalcon/Db/Adapter/AbstractAdapter.zep
Expand Up @@ -263,7 +263,7 @@ abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface
* DELETE FROM `robots` WHERE `id` = 101 * DELETE FROM `robots` WHERE `id` = 101
* ``` * ```
*/ */
public function delete(string table, var whereCondition = null, var placeholders = null, var dataTypes = null) -> bool public function delete(var table, var whereCondition = null, var placeholders = null, var dataTypes = null) -> bool
{ {
var sql, escapedTable; var sql, escapedTable;


Expand Down
2 changes: 1 addition & 1 deletion phalcon/Db/Adapter/AdapterInterface.zep
Expand Up @@ -86,7 +86,7 @@ interface AdapterInterface
/** /**
* Deletes data from a table using custom RDBMS SQL syntax * Deletes data from a table using custom RDBMS SQL syntax
*/ */
public function delete(string table, whereCondition = null, placeholders = null, dataTypes = null) -> bool; public function delete(var table, whereCondition = null, placeholders = null, dataTypes = null) -> bool;


/** /**
* Returns an array of Phalcon\Db\Column objects describing a table * Returns an array of Phalcon\Db\Column objects describing a table
Expand Down
36 changes: 35 additions & 1 deletion tests/integration/Mvc/Model/CreateCest.php
Expand Up @@ -13,12 +13,17 @@
namespace Phalcon\Test\Integration\Mvc\Model; namespace Phalcon\Test\Integration\Mvc\Model;


use IntegrationTester; use IntegrationTester;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Models\AlbumORama\Artists;
use function uniqid;


/** /**
* Class CreateCest * Class CreateCest
*/ */
class CreateCest class CreateCest
{ {
use DiTrait;

/** /**
* Tests Phalcon\Mvc\Model :: create() * Tests Phalcon\Mvc\Model :: create()
* *
Expand All @@ -28,6 +33,35 @@ class CreateCest
public function mvcModelCreate(IntegrationTester $I) public function mvcModelCreate(IntegrationTester $I)
{ {
$I->wantToTest('Mvc\Model - create()'); $I->wantToTest('Mvc\Model - create()');
$I->skipTest('Need implementation');
$this->setNewFactoryDefault();

$name = uniqid();

// MySql
$this->setDiMysql();

$artist = new Artists();
$artist->name = $name;
$result = $artist->save();

$I->assertNotFalse($result);

$result = $artist->delete();

$I->assertNotFalse($result);

// Postgresql
$this->setDiPostgresql();

$artist = new Artists();
$artist->name = $name;
$result = $artist->save();

$I->assertNotFalse($result);

$result = $artist->delete();

$I->assertNotFalse($result);
} }
} }
36 changes: 35 additions & 1 deletion tests/integration/Mvc/Model/DeleteCest.php
Expand Up @@ -13,12 +13,17 @@
namespace Phalcon\Test\Integration\Mvc\Model; namespace Phalcon\Test\Integration\Mvc\Model;


use IntegrationTester; use IntegrationTester;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Models\AlbumORama\Artists;
use function uniqid;


/** /**
* Class DeleteCest * Class DeleteCest
*/ */
class DeleteCest class DeleteCest
{ {
use DiTrait;

/** /**
* Tests Phalcon\Mvc\Model :: delete() * Tests Phalcon\Mvc\Model :: delete()
* *
Expand All @@ -28,6 +33,35 @@ class DeleteCest
public function mvcModelDelete(IntegrationTester $I) public function mvcModelDelete(IntegrationTester $I)
{ {
$I->wantToTest('Mvc\Model - delete()'); $I->wantToTest('Mvc\Model - delete()');
$I->skipTest('Need implementation');
$this->setNewFactoryDefault();

$name = uniqid();

// MySql
$this->setDiMysql();

$artist = new Artists();
$artist->name = $name;
$result = $artist->save();

$I->assertNotFalse($result);

$result = $artist->delete();

$I->assertNotFalse($result);

// Postgresql
$this->setDiPostgresql();

$artist = new Artists();
$artist->name = $name;
$result = $artist->save();

$I->assertNotFalse($result);

$result = $artist->delete();

$I->assertNotFalse($result);
} }
} }

0 comments on commit 467ec6b

Please sign in to comment.