43 protected function setUp()
45 $this->folderDao = M::mock(FolderDao::class);
46 $this->
dbManager = M::mock(DbManager::class);
49 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
52 protected function tearDown()
54 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
58 protected function getFormattedItem($row)
60 return Reflectory::invokeObjectsMethodnameWith($this->folderNav,
'getFormattedItem', array($row,$this->uri));
63 protected function prepareShowFolderTree($parentFolderId=
'parentFolderId')
65 $this->folderDao->shouldReceive(
'getFolderTreeCte')->with($parentFolderId)
66 ->andReturn($parentFolderId.
'Cte');
67 $this->
dbManager->shouldReceive(
'prepare')->withArgs(array(anything(),startsWith($parentFolderId.
'Cte')));
68 $this->
dbManager->shouldReceive(
'execute')->withArgs(array(anything(),array($parentFolderId)))
69 ->andReturn($res=$parentFolderId.
'Res');
70 $this->
dbManager->shouldReceive(
'freeResult')->with($res);
74 public function testShowFolderTreeWithoutContent()
76 $res = $this->prepareShowFolderTree($parentFolderId=
'foo');
77 $this->
dbManager->shouldReceive(
'fetchArray')->with($res)
78 ->andReturn($rowA=array(
'folder_pk'=>1,
'folder_name'=>
'A',
'folder_desc'=>
'',
'depth'=>0),
false);
79 $out = $this->folderNav->showFolderTree($parentFolderId);
80 assertThat($out, equalTo(
'<ul id="tree"><li>'.$this->getFormattedItem($rowA).
'</li></ul>'));
83 public function testShowFolderTreeWithContent()
85 $res = $this->prepareShowFolderTree($parentFolderId=
'foo');
86 $this->
dbManager->shouldReceive(
'fetchArray')->with($res)
87 ->andReturn($rowTop=array(
'folder_pk'=>1,
'folder_name'=>
'Top',
'folder_desc'=>
'',
'depth'=>0),
88 $rowA=array(
'folder_pk'=>2,
'folder_name'=>
'B',
'folder_desc'=>
'/A',
'depth'=>1),
89 $rowB=array(
'folder_pk'=>3,
'folder_name'=>
'B',
'folder_desc'=>
'/A/B',
'depth'=>2),
90 $rowC=array(
'folder_pk'=>4,
'folder_name'=>
'C',
'folder_desc'=>
'/C',
'depth'=>1),
92 $out = $this->folderNav->showFolderTree($parentFolderId);
93 assertThat(str_replace(
"\n",
'',$out), equalTo(
'<ul id="tree"><li>'.$this->getFormattedItem($rowTop).
'<ul><li>' 94 .$this->getFormattedItem($rowA).
'<ul><li>' 95 .$this->getFormattedItem($rowB).
'</li></ul></li><li>' 96 .$this->getFormattedItem($rowC).
'</li></ul></li></ul>'));
Traceback_uri()
Get the URI without query to this location.
fo_dbManager * dbManager
fo_dbManager object