1
|
|
|
<?php |
2
|
|
|
namespace StefanoTreeTest\Unit\NestedSet\Adapter; |
3
|
|
|
|
4
|
|
|
use StefanoTree\NestedSet\Adapter\Zend1; |
5
|
|
|
use StefanoTree\NestedSet\Options; |
6
|
|
|
|
7
|
|
|
class Zend1Test extends \PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
protected function tearDown() |
10
|
|
|
{ |
11
|
|
|
\Mockery::close(); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public function testGetBlankDbSelect() |
15
|
|
|
{ |
16
|
|
|
$options = new Options(array( |
17
|
|
|
'tableName' => 'tableName', |
18
|
|
|
'idColumnName' => 'id', |
19
|
|
|
)); |
20
|
|
|
|
21
|
|
|
$dbAdapter = $this->getDbAdapterMock(); |
22
|
|
|
$adapter = new Zend1($options, $dbAdapter); |
23
|
|
|
|
24
|
|
|
$expectedQuery = 'SELECT "tableName".* FROM "tableName"'; |
25
|
|
|
$actualQuery = (string) $adapter->getBlankDbSelect(); |
26
|
|
|
$this->assertEquals($expectedQuery, |
27
|
|
|
$actualQuery); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testGetDefaultDbSelectMustAlwaysReturnNewInstance() |
31
|
|
|
{ |
32
|
|
|
$options = new Options(array( |
33
|
|
|
'tableName' => 'tableName', |
34
|
|
|
'idColumnName' => 'id', |
35
|
|
|
)); |
36
|
|
|
|
37
|
|
|
$dbAdapter = $this->getDbAdapterMock(); |
38
|
|
|
$adapter = new Zend1($options, $dbAdapter); |
39
|
|
|
|
40
|
|
|
$this->assertNotSame($adapter->getDefaultDbSelect(), $adapter->getDefaultDbSelect()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testSetDefaultDbSelect() |
44
|
|
|
{ |
45
|
|
|
$options = new Options(array( |
46
|
|
|
'tableName' => 'tableName', |
47
|
|
|
'idColumnName' => 'id', |
48
|
|
|
)); |
49
|
|
|
|
50
|
|
|
$dbAdapter = $this->getDbAdapterMock(); |
51
|
|
|
$adapter = new Zend1($options, $dbAdapter); |
52
|
|
|
|
53
|
|
|
$select = $dbAdapter->select()->from('tableName'); |
|
|
|
|
54
|
|
|
|
55
|
|
|
$adapter->setDefaultDbSelect($select); |
56
|
|
|
|
57
|
|
|
$this->assertEquals($select->__toString(), $adapter->getDefaultDbSelect()->__toString()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return \Zend_Db_Adapter_Pdo_Sqlite |
62
|
|
|
*/ |
63
|
|
|
protected function getDbAdapterMock() |
64
|
|
|
{ |
65
|
|
|
$dbA = \Zend_Db::factory('Pdo_Sqlite', array( |
66
|
|
|
'database' => ':memory:', |
67
|
|
|
'dbname' => TEST_STEFANO_DB_DB_NAME, |
68
|
|
|
)); |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
$dbAdapterMock = \Mockery::mock($dbA); |
72
|
|
|
$dbAdapterMock->makePartial(); |
73
|
|
|
|
74
|
|
|
return $dbAdapterMock; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.