for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Lampager\Cake\Test\TestCase\Database;
use Cake\Datasource\ConnectionManager;
use Cake\ORM\TableRegistry;
use Lampager\Cake\Test\TestCase\TestCase;
class SqliteCompilerTest extends TestCase
{
public $fixtures = [
'plugin.Lampager\\Cake.Posts',
];
public function setUp()
$config = ConnectionManager::getConfig('test');
$this->skipIf(strpos($config['driver'], 'Sqlite') === false, 'Not using Sqlite');
}
public function testSelect()
$posts = TableRegistry::getTableLocator()->get('Posts');
$expected = '
SELECT
Posts.* AS "Posts__*"
FROM
posts Posts
ORDER BY
modified ASC
';
$actual = $posts->find()
->select(['*'])
->orderAsc('modified')
->sql();
$this->assertSqlEquals($expected, $actual);
public function testUnion()
*
(
Posts.id AS "Posts__id",
Posts.modified AS "Posts__modified"
WHERE
id > :c0
)
UNION ALL
$subQuery = $posts->find()
->select(['id', 'modified'])
->orderAsc('modified');
$mainQuery = $posts->find()
->where(['id >' => 1])
->unionAll($subQuery);
$actual = $mainQuery->sql();