This repository was archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
faryar
committed
Feb 24, 2019
1 parent
66b17e8
commit d7630c4
Showing
2 changed files
with
54 additions
and
16 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 |
---|---|---|
|
@@ -308,4 +308,34 @@ public function test_must_return_exception_on_non_exist_method() | |
$this->expectException(\BadMethodCallException::class); | ||
$results = $db->none('name','=','John')->andWhere('email','==','[email protected]')->resultDocuments(); | ||
} | ||
/** | ||
* based on issue #41 | ||
* results() returns document instead of array #41 | ||
*/ | ||
public function test_must_return_array_on_select_an_culomn_from_cache() | ||
{ | ||
$db = new \Filebase\Database([ | ||
'dir' => __DIR__.'/databases/saved', | ||
'cache' => true | ||
]); | ||
|
||
$db->flush(true); | ||
|
||
for ($x = 1; $x <= 10; $x++) | ||
{ | ||
$user = $db->get(uniqid()); | ||
$user->name = 'John'; | ||
$user->email = '[email protected]'; | ||
$user->save(); | ||
} | ||
|
||
$db->where('name','=','John')->andWhere('email','==','[email protected]')->select('email')->results(); | ||
$result_from_cache = $db->where('name','=','John')->andWhere('email','==','[email protected]')->select('email')->results(); | ||
|
||
$this->assertCount(10,$result_from_cache); | ||
$this->assertEquals(['email'=>'[email protected]'],$result_from_cache[0]); | ||
$this->assertInternalType('array', $result_from_cache[0]); | ||
$this->assertInternalType('string', $result_from_cache[0]['email']); | ||
$db->flush(true); | ||
} | ||
} |