Skip to content
Permalink
Browse files

Confirmed valid traits; Paginator db tests; New models

  • Loading branch information
niden committed Jan 30, 2020
1 parent 076b477 commit 74aa882ad2178234d1317a074dabbfb19c7c0561
Showing with 1,127 additions and 978 deletions.
  1. +1 −0 .gitignore
  2. +16 −8 tests/_data/fixtures/Migrations/InvoicesMigration.php
  3. +1 −0 tests/_data/fixtures/Traits/ApcuTrait.php
  4. +1 −0 tests/_data/fixtures/Traits/ConfigTrait.php
  5. +1 −0 tests/_data/fixtures/Traits/CookieTrait.php
  6. +1 −0 tests/_data/fixtures/Traits/DiTrait.php
  7. +1 −0 tests/_data/fixtures/Traits/FactoryTrait.php
  8. +1 −0 tests/_data/fixtures/Traits/GdTrait.php
  9. +1 −0 tests/_data/fixtures/Traits/ImagickTrait.php
  10. +1 −0 tests/_data/fixtures/Traits/LibmemcachedTrait.php
  11. +2 −2 tests/_data/fixtures/Traits/LoaderTrait.php
  12. +2 −2 tests/_data/fixtures/Traits/LoggerTrait.php
  13. +77 −0 tests/_data/fixtures/Traits/RecordsTrait.php
  14. +1 −0 tests/_data/fixtures/Traits/RedisTrait.php
  15. +1 −0 tests/_data/fixtures/Traits/RouterTrait.php
  16. +1 −0 tests/_data/fixtures/Traits/SessionBagTrait.php
  17. +1 −0 tests/_data/fixtures/Traits/SessionTrait.php
  18. +1 −0 tests/_data/fixtures/Traits/TranslateArrayTrait.php
  19. +1 −0 tests/_data/fixtures/Traits/TranslateCsvTrait.php
  20. +1 −0 tests/_data/fixtures/Traits/TranslateGettextTrait.php
  21. +1 −0 tests/_data/fixtures/Traits/ValidationTrait.php
  22. +1 −0 tests/_data/fixtures/Traits/VersionTrait.php
  23. +1 −0 tests/_data/fixtures/Traits/ViewTrait.php
  24. 0 tests/_data/fixtures/Traits/{ → _tocheck}/CollectionTrait.php
  25. 0 tests/_data/fixtures/Traits/{ → _tocheck}/CryptTrait.php
  26. 0 tests/_data/fixtures/Traits/{ → _tocheck}/Db/MysqlTrait.php
  27. 0 tests/_data/fixtures/Traits/{ → _tocheck}/Db/PostgresqlTrait.php
  28. 0 tests/_data/fixtures/Traits/{ → _tocheck}/DialectTrait.php
  29. 0 tests/_data/fixtures/Traits/{ → _tocheck}/TagHelperTrait.php
  30. 0 tests/_data/fixtures/Traits/{ → _tocheck}/TagSetupTrait.php
  31. +53 −0 tests/_data/fixtures/models/InvoicesMap.php
  32. +56 −0 tests/database/Mvc/Model/ConstructCest.php
  33. +182 −0 tests/database/Mvc/Model/CountCest.php
  34. +72 −0 tests/database/Mvc/Model/GetSetEventsManagerCest.php
  35. +71 −0 tests/database/Mvc/Model/RefreshCest.php
  36. +52 −0 tests/database/Mvc/Model/Row/JsonSerializeCest.php
  37. +12 −7 tests/{tocheck-database → database}/Mvc/Model/Row/OffsetExistsCest.php
  38. +6 −6 tests/{tocheck-database → database}/Mvc/Model/Row/OffsetGetCest.php
  39. +4 −4 tests/{tocheck-database → database}/Mvc/Model/Row/OffsetSetCest.php
  40. +5 −5 tests/{tocheck-database → database}/Mvc/Model/Row/OffsetUnsetCest.php
  41. +6 −6 tests/{tocheck-database → database}/Mvc/Model/Row/ReadWriteAttributeCest.php
  42. +9 −4 tests/{tocheck-database → database}/Mvc/Model/Row/SetDirtyStateCest.php
  43. +52 −0 tests/database/Mvc/Model/Row/ToArrayCest.php
  44. +82 −0 tests/database/Mvc/Model/SerializeCest.php
  45. +68 −0 tests/database/Paginator/Model/ConstructCest.php
  46. +202 −0 tests/database/Paginator/Model/PaginateCest.php
  47. +74 −0 tests/database/Paginator/Model/SetGetLimitCest.php
  48. +3 −3 tests/{tocheck-database/Paginator/Adapter → database/Paginator}/Model/SetRepositoryCest.php
  49. +2 −2 tests/integration/Mvc/Model/FindFirstCest.php
  50. +0 −34 tests/tocheck-database/Mvc/Model/ConstructCest.php
  51. +0 −236 tests/tocheck-database/Mvc/Model/CountCest.php
  52. +0 −34 tests/tocheck-database/Mvc/Model/GetEventsManagerCest.php
  53. +0 −64 tests/tocheck-database/Mvc/Model/RefreshCest.php
  54. +0 −46 tests/tocheck-database/Mvc/Model/Row/JsonSerializeCest.php
  55. +0 −46 tests/tocheck-database/Mvc/Model/Row/ToArrayCest.php
  56. +0 −34 tests/tocheck-database/Mvc/Model/SerializeCest.php
  57. +0 −34 tests/tocheck-database/Mvc/Model/SetEventsManagerCest.php
  58. +0 −45 tests/tocheck-database/Paginator/Adapter/Model/ConstructCest.php
  59. +0 −273 tests/tocheck-database/Paginator/Adapter/Model/PaginateCest.php
  60. +0 −34 tests/tocheck-database/Paginator/Adapter/Model/SetCurrentPageCest.php
  61. +0 −49 tests/tocheck-database/Paginator/Adapter/Model/SetGetLimitCest.php
@@ -60,6 +60,7 @@ composer.lock
php_test_results_*.txt
docker-compose.yml
build/gccarch
tests/_data/phalcon_test*
tests/_output/*

.php_cs.cache
@@ -22,23 +22,31 @@ class InvoicesMigration extends AbstractMigration

/**
* @param int $id
* @param int|null $custId
* @param int $status
* @param string|null $title
* @param float $total
* @param string|null $createdAt
*
* @return int
*/
public function insert(
int $id,
string $title = null
$id,
int $custId = null,
int $status = 0,
string $title = null,
float $total = 0,
string $createdAt = null
): int {
$title = $title ?: uniqid();
$now = date('Y-m-d H:i:s');
$total = 100 + $id;
$flag = (int) ($id % 2);
$sql = <<<SQL
$id = $id ?: 'null';
$title = $title ?: uniqid();
$custId = $custId ?: 1;
$now = $createdAt ?: date('Y-m-d H:i:s');
$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}"
{$id}, {$custId}, {$status}, "{$title}", {$total}, "{$now}"
)
SQL;

@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,14 +1,14 @@
<?php

declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
*
* 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\Traits;

use UnitTester;
@@ -1,14 +1,14 @@
<?php

declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
*
* 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\Traits;

use DateTime;
@@ -0,0 +1,77 @@
<?php

declare(strict_types=1);

/**
* 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.
*/

namespace Phalcon\Test\Fixtures\Traits;

use DatabaseTester;
use PDO;
use Phalcon\Annotations\Adapter\Memory as AnnotationsMemory;
use Phalcon\Cache\Adapter\Libmemcached as StorageLibmemcached;
use Phalcon\Cache\Adapter\Stream as StorageStream;
use Phalcon\Cli\Console as CliConsole;
use Phalcon\Crypt;
use Phalcon\Db\Adapter\PdoFactory;
use Phalcon\Di;
use Phalcon\Di\DiInterface;
use Phalcon\Di\FactoryDefault;
use Phalcon\Di\FactoryDefault\Cli as CliFactoryDefault;
use Phalcon\Escaper;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Filter;
use Phalcon\Http\Request;
use Phalcon\Http\Response;
use Phalcon\Mvc\Model\Manager as ModelsManager;
use Phalcon\Mvc\Model\Metadata\Memory as MetadataMemory;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Simple;
use Phalcon\Session\Adapter\Libmemcached as SessionLibmemcached;
use Phalcon\Session\Adapter\Noop as SessionNoop;
use Phalcon\Session\Adapter\Redis as SessionRedis;
use Phalcon\Session\Adapter\Stream as SessionFiles;
use Phalcon\Session\Manager as SessionManager;
use Phalcon\Storage\SerializerFactory;
use Phalcon\Test\Fixtures\Migrations\InvoicesMigration;
use Phalcon\Url;
use function dataDir;
use function getOptionsLibmemcached;
use function getOptionsMysql;
use function getOptionsPostgresql;
use function getOptionsRedis;
use function getOptionsSqlite;
use function uniqid;

trait RecordsTrait
{
/**
* @param InvoicesMigration $migration
* @param int $count
* @param int $custId
* @param string $prefix
*/
private function insertDataInvoices(
InvoicesMigration $migration,
int $count,
int $custId,
string $prefix
) {
$title = uniqid($prefix . '-');
for ($counter = 1; $counter <= $count; $counter++) {
$migration->insert(
null,
$custId,
1,
$title
);
}
}
}
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
File renamed without changes.
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

/**
* 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.
*/

namespace Phalcon\Test\Models;

use Phalcon\Mvc\Model;

/**
* Class InvoicesMap
*
* @property int $inv_id
* @property int $inv_cst_id
* @property int $inv_status_flag
* @property string $inv_title
* @property float $inv_total
* @property string $inv_created_at
*/
class InvoicesMap extends Model
{
public $inv_id;
public $inv_cst_id;
public $inv_status_flag;
public $inv_title;
public $inv_total;
public $inv_created_at;

public function initialize()
{
$this->setSource('co_invoices');
}

public function columnMap()
{
return [
'inv_id' => 'id',
'inv_cst_id' => 'cst_id',
'inv_status_flag' => 'status_flag',
'inv_title' => 'title',
'inv_total' => 'total',
'inv_created_at' => 'created_at',
];
}
}
@@ -0,0 +1,56 @@
<?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;

use DatabaseTester;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\ModelInterface;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Models\Invoices;

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

public function _before(DatabaseTester $I)
{
$this->setNewFactoryDefault();
$this->setDatabase($I);
}

/**
* Tests Phalcon\Mvc\Model :: __construct()
*
* @author Phalcon Team <team@phalcon.io>
* @since 2018-11-13
*/
public function mvcModelConstruct(DatabaseTester $I)
{
$I->wantToTest('Mvc\Model - __construct()');

$invoice = new Invoices();

$I->assertInstanceOf(
Model::class,
$invoice
);
$I->assertInstanceOf(
ModelInterface::class,
$invoice
);
}
}

0 comments on commit 74aa882

Please sign in to comment.
You can’t perform that action at this time.