-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d5af4e
commit 5d12513
Showing
2 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,4 +149,41 @@ public function testDoesntSupportMetadata() | |
{ | ||
$this->assertFalse($this->adapter->supportsMetadata()); | ||
} | ||
} | ||
|
||
public function testCanListEmptyDirectory() | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{ | ||
$test_dir = ''; | ||
$dirname = 'child_dir'; | ||
$filename = 'test_file.xml'; | ||
$foo_tree_mock = M::mock('Gittern\Entity\GitObject\Node\TreeNode'); | ||
$foo_tree_mock->shouldReceive('getName')->atLeast()->once()->andReturn($dirname); | ||
$foo_blob_mock = M::mock('Gittern\Entity\GitObject\Node\BlobNode'); | ||
$foo_blob_mock->shouldReceive('getName')->atLeast()->once()->andReturn($filename); | ||
$this->tree_mock->shouldReceive('getNodeNamed')->with('')->andReturn($this->tree_mock); | ||
$this->tree_mock->shouldReceive('getRelatedObject')->andReturn($this->tree_mock); | ||
$this->tree_mock->shouldReceive('getNodes')->atLeast()->once()->andReturn(array($foo_tree_mock, $foo_blob_mock)); | ||
|
||
$list = $this->adapter->listDirectory($test_dir); | ||
$this->assertEquals(array($filename), $list['keys']); | ||
$this->assertEquals(array($dirname), $list['dirs']); | ||
} | ||
|
||
public function testCanListGivenDirectory() | ||
{ | ||
$test_dir = 'translations'; | ||
$filename = 'test_file.xml'; | ||
|
||
$tree_node_mock = M::mock('Gittern\Entity\GitObject\Node\TreeNode'); | ||
$tree_mock = M::mock('Gittern\Entity\GitObject\Tree'); | ||
$blob_mock = M::mock('Gittern\Entity\GitObject\Node\BlobNode'); | ||
$blob_mock->shouldReceive('getName')->atLeast()->once()->andReturn($filename); | ||
This comment has been minimized.
Sorry, something went wrong.
vatson
|
||
$this->tree_mock->shouldReceive('getNodeNamed')->with($test_dir)->andReturn($tree_node_mock); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
$tree_node_mock->shouldReceive('getRelatedObject')->andReturn($tree_mock); | ||
$tree_mock->shouldReceive('getNodes')->atLeast()->once()->andReturn(array($blob_mock)); | ||
|
||
$list = $this->adapter->listDirectory($test_dir); | ||
$this->assertEquals(array($filename), $list['key']); | ||
This comment has been minimized.
Sorry, something went wrong.
vatson
|
||
$this->assertEmpty($list['dirs']); | ||
} | ||
|
||
} |
This name does not reflect the essence of the test. It's not an empty directory. It's the directory with undefined name. I suggest to rename this name to
'testListDirectoryWithUndefinedName'
or something similar.