-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phalcon\Test\Fixtures\DM\Pdo; | ||
|
||
use Phalcon\DM\Pdo\Connection; | ||
use Phalcon\DM\Pdo\Profiler\ProfilerInterface; | ||
|
||
class ConnectionFixture extends Connection | ||
{ | ||
public function __construct( | ||
string $dsn, | ||
string $username = null, | ||
string $password = null, | ||
array $options = [], | ||
array $queries = [], | ||
ProfilerInterface $profiler = null | ||
) { | ||
$this->pdo = new PdoFixture(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phalcon\Test\Fixtures\DM\Pdo; | ||
|
||
class PdoFixture | ||
{ | ||
public function callMe(string $name): string | ||
{ | ||
return $name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?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\Fixtures\Migrations; | ||
|
||
use Phalcon\DM\Pdo\Connection; | ||
|
||
use function date; | ||
use function uniqid; | ||
|
||
class Invoices | ||
{ | ||
/** | ||
* Invoices constructor. | ||
* | ||
* @param Connection $connection | ||
*/ | ||
public function __construct(Connection $connection) | ||
{ | ||
$this->truncate($connection); | ||
} | ||
|
||
/** | ||
* @param Connection $connection | ||
* @param int $id | ||
* @param string|null $title | ||
* | ||
* @return int | ||
*/ | ||
public function insert( | ||
Connection $connection, | ||
int $id, | ||
string $title = null | ||
): int { | ||
$title = $title ?: uniqid(); | ||
$now = date('Y-m-d H:i:s'); | ||
$total = 100 + $id; | ||
$flag = (int) ($id % 2); | ||
$sql = <<<SQL | ||
insert into co_invoices ( | ||
inv_id, | ||
inv_cst_id, | ||
inv_status_flag, | ||
inv_title, | ||
inv_total, | ||
inv_created_at | ||
) values ( | ||
{$id}, | ||
1, | ||
{$flag}, | ||
"{$title}", | ||
{$total}, | ||
"{$now}" | ||
) | ||
SQL; | ||
|
||
return $connection->exec($sql); | ||
} | ||
|
||
/** | ||
* @param Connection $connection | ||
*/ | ||
public function truncate(Connection $connection): void | ||
{ | ||
$sql = "delete from co_invoices"; | ||
|
||
$connection->exec($sql); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phalcon\Test\Fixtures; | ||
|
||
class Resultset | ||
{ | ||
public $calculated = ''; | ||
|
||
public function __construct(string $calculated) | ||
{ | ||
$this->calculated = $calculated; | ||
} | ||
} |