-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathNoTableSubQueryTest.php
More file actions
33 lines (23 loc) · 891 Bytes
/
NoTableSubQueryTest.php
File metadata and controls
33 lines (23 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php namespace Pixie;
use PDO;
use Mockery as m;
use Pixie\QueryBuilder\QueryBuilderHandler;
class NoTableSubQueryTest extends TestCase
{
/**
* @var QueryBuilderHandler
*/
protected $builder;
public function setUp()
{
parent::setUp();
$this->builder = new QueryBuilderHandler($this->mockConnection);
}
public function testRawQuery()
{
$subQuery1 = $this->builder->table('mail')->select($this->builder->raw('COUNT(*)'));
$subQuery2 = $this->builder->table('event_message')->select($this->builder->raw('COUNT(*)'));
$count = $this->builder->select($this->builder->subQuery($subQuery1, 'row1'), $this->builder->subQuery($subQuery2, 'row2'))->first();
$this->assertEquals('SELECT (SELECT COUNT(*) FROM `cb_mail`) as row1, (SELECT COUNT(*) FROM `cb_event_message`) as row2 LIMIT 1', $count);
}
}