Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)
This commit is contained in:
@@ -1,416 +1,419 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
/**
|
||||
* DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
namespace Domframework\Tests;
|
||||
|
||||
use Domframework\Dbjson;
|
||||
|
||||
/** Test the Dbjson database */
|
||||
/**
|
||||
* Test the Dbjson database
|
||||
*/
|
||||
class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_insertOne1()
|
||||
public function testInsertOne1()
|
||||
{
|
||||
// Document #0
|
||||
// Document #0
|
||||
define("dbfile", "/tmp/dbjson-" . time());
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->insertOne(
|
||||
"collection",
|
||||
array ("key1" => "val1", "key2" => "val2")
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
);
|
||||
$this->assertSame($res, 1);
|
||||
}
|
||||
|
||||
public function test_insertOne2()
|
||||
public function testInsertOne2()
|
||||
{
|
||||
// Document #1
|
||||
// Document #1
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->insertOne(
|
||||
"collection",
|
||||
array ("key1" => "val1", "key2" => "val2")
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
);
|
||||
$this->assertSame($res, 1);
|
||||
}
|
||||
|
||||
public function test_insertMany1()
|
||||
public function testInsertMany1()
|
||||
{
|
||||
// Error : Invalid array provided (not array of array)
|
||||
// Error : Invalid array provided (not array of array)
|
||||
$this->setExpectedException("Exception");
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->insertMany(
|
||||
"collection",
|
||||
array ("key1" => "val1", "key2" => "val2")
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_insertMany2()
|
||||
public function testInsertMany2()
|
||||
{
|
||||
// Document #2 and #3
|
||||
// Document #2 and #3
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->insertMany(
|
||||
"collection",
|
||||
array (array ("key1" => "val3", "key2" => "val2"),
|
||||
array ("key1" => "val3", "key2" => "val4"))
|
||||
[["key1" => "val3", "key2" => "val2"],
|
||||
["key1" => "val3", "key2" => "val4"]]
|
||||
);
|
||||
$this->assertSame($res, 2);
|
||||
}
|
||||
|
||||
public function test_filter1()
|
||||
public function testFilter1()
|
||||
{
|
||||
// Return all the keys (filter = array ())
|
||||
// Return all the keys (filter = array ())
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->filter("collection", array ());
|
||||
$this->assertSame(array_keys($res), array (0,1,2,3));
|
||||
$res = $dbjson->filter("collection", []);
|
||||
$this->assertSame(array_keys($res), [0,1,2,3]);
|
||||
}
|
||||
public function test_filter2()
|
||||
public function testFilter2()
|
||||
{
|
||||
// Return the keys where filter = array ("key2"=>"val2"))
|
||||
// Return the keys where filter = array ("key2"=>"val2"))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->filter("collection", array ("key2" => "val2"));
|
||||
$this->assertSame(array_keys($res), array (0,1,2));
|
||||
$res = $dbjson->filter("collection", ["key2" => "val2"]);
|
||||
$this->assertSame(array_keys($res), [0,1,2]);
|
||||
}
|
||||
public function test_filter3()
|
||||
public function testFilter3()
|
||||
{
|
||||
// Return the keys where filter = array ("key1"=>"val3","key2"=>"val2"))
|
||||
// Return the keys where filter = array ("key1"=>"val3","key2"=>"val2"))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->filter("collection", array ("key1" => "val3",
|
||||
"key2" => "val2"));
|
||||
$res = $dbjson->filter("collection", ["key1" => "val3",
|
||||
"key2" => "val2"]);
|
||||
$this->assertSame(count($res), 1);
|
||||
}
|
||||
public function test_filter4()
|
||||
public function testFilter4()
|
||||
{
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "=="),
|
||||
// "key2"=>array ("val2", "=="))
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "=="),
|
||||
// "key2"=>array ("val2", "=="))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->filter("collection", array ("key1" => array ("val3", "=="),
|
||||
"key2" => array ("val2", "==")));
|
||||
$res = $dbjson->filter("collection", ["key1" => ["val3", "=="],
|
||||
"key2" => ["val2", "=="]]);
|
||||
$this->assertSame(count($res), 1);
|
||||
}
|
||||
public function test_filter5()
|
||||
public function testFilter5()
|
||||
{
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
||||
// "key2"=>array ("val2", "=="))
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
||||
// "key2"=>array ("val2", "=="))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->filter("collection", array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", "==")));
|
||||
$this->assertSame(array_keys($res), array (0,1,2));
|
||||
$res = $dbjson->filter("collection", ["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", "=="]]);
|
||||
$this->assertSame(array_keys($res), [0,1,2]);
|
||||
}
|
||||
public function test_filter6()
|
||||
public function testFilter6()
|
||||
{
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
||||
// "key2"=>array ("val2", ">"))
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
||||
// "key2"=>array ("val2", ">"))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->filter("collection", array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", ">")));
|
||||
$res = $dbjson->filter("collection", ["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", ">"]]);
|
||||
$this->assertSame(count($res), 1);
|
||||
}
|
||||
|
||||
public function test_find1()
|
||||
public function testFind1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find("collection", array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", ">")));
|
||||
$res = $dbjson->find("collection", ["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", ">"]]);
|
||||
$res = array_values($res);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key1" => "val3",
|
||||
"key2" => "val4")));
|
||||
$this->assertSame($res, [0 => ["key1" => "val3",
|
||||
"key2" => "val4"]]);
|
||||
}
|
||||
public function test_find2()
|
||||
public function testFind2()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", ">")),
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", ">"]],
|
||||
"*"
|
||||
);
|
||||
$res = array_values($res);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key1" => "val3",
|
||||
"key2" => "val4")));
|
||||
$this->assertSame($res, [0 => ["key1" => "val3",
|
||||
"key2" => "val4"]]);
|
||||
}
|
||||
public function test_find3()
|
||||
public function testFind3()
|
||||
{
|
||||
// Exception : fields not an array
|
||||
// Exception : fields not an array
|
||||
$this->setExpectedException("Exception");
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", ">")),
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", ">"]],
|
||||
"key1"
|
||||
);
|
||||
}
|
||||
public function test_find4()
|
||||
public function testFind4()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", ">")),
|
||||
array ("key1")
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", ">"]],
|
||||
["key1"]
|
||||
);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
$res = array_values($res);
|
||||
unset($res[0]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key1" => "val3")));
|
||||
$this->assertSame($res, [0 => ["key1" => "val3"]]);
|
||||
}
|
||||
public function test_find5()
|
||||
public function testFind5()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", ">")),
|
||||
array ("key1", "key2")
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", ">"]],
|
||||
["key1", "key2"]
|
||||
);
|
||||
$res = array_values($res);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key1" => "val3",
|
||||
"key2" => "val4")));
|
||||
$this->assertSame($res, [0 => ["key1" => "val3",
|
||||
"key2" => "val4"]]);
|
||||
}
|
||||
public function test_find6()
|
||||
public function testFind6()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", "==")),
|
||||
array ("key1", "key2")
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", "=="]],
|
||||
["key1", "key2"]
|
||||
);
|
||||
$res = array_values($res);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
unset($res[1]["_id"]);
|
||||
unset($res[2]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key1" => "val1",
|
||||
"key2" => "val2"),
|
||||
1 => array ("key1" => "val1",
|
||||
"key2" => "val2"),
|
||||
2 => array ("key1" => "val3",
|
||||
"key2" => "val2")));
|
||||
$this->assertSame($res, [0 => ["key1" => "val1",
|
||||
"key2" => "val2"],
|
||||
1 => ["key1" => "val1",
|
||||
"key2" => "val2"],
|
||||
2 => ["key1" => "val3",
|
||||
"key2" => "val2"]]);
|
||||
}
|
||||
public function test_find7()
|
||||
public function testFind7()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", "==")),
|
||||
array ("key2")
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", "=="]],
|
||||
["key2"]
|
||||
);
|
||||
$res = array_values($res);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
unset($res[1]["_id"]);
|
||||
unset($res[2]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key2" => "val2"),
|
||||
1 => array ("key2" => "val2"),
|
||||
2 => array ("key2" => "val2")));
|
||||
$this->assertSame($res, [0 => ["key2" => "val2"],
|
||||
1 => ["key2" => "val2"],
|
||||
2 => ["key2" => "val2"]]);
|
||||
}
|
||||
public function test_find8()
|
||||
public function testFind8()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", "==")),
|
||||
array ("key2"),
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", "=="]],
|
||||
["key2"],
|
||||
1
|
||||
);
|
||||
$res = array_values($res);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key2" => "val2")));
|
||||
$this->assertSame($res, [0 => ["key2" => "val2"]]);
|
||||
}
|
||||
|
||||
public function test_deleteOne1()
|
||||
public function testDeleteOne1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->deleteOne(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2",
|
||||
"=="))
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2",
|
||||
"=="]]
|
||||
);
|
||||
$this->assertSame($res, 1);
|
||||
}
|
||||
public function test_find9()
|
||||
public function testFind9()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", "==")),
|
||||
array ("key2")
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", "=="]],
|
||||
["key2"]
|
||||
);
|
||||
$res = array_values($res);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
unset($res[1]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key2" => "val2"),
|
||||
1 => array ("key2" => "val2")));
|
||||
$this->assertSame($res, [0 => ["key2" => "val2"],
|
||||
1 => ["key2" => "val2"]]);
|
||||
}
|
||||
|
||||
public function test_deleteMany1()
|
||||
public function testDeleteMany1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->deleteMany(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2",
|
||||
"=="))
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2",
|
||||
"=="]]
|
||||
);
|
||||
$this->assertSame($res, 2);
|
||||
}
|
||||
public function test_find10()
|
||||
public function testFind10()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
array ("key1" => array ("val3", "<="),
|
||||
"key2" => array ("val2", "==")),
|
||||
array ("key2")
|
||||
["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", "=="]],
|
||||
["key2"]
|
||||
);
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[1]["_id"]);
|
||||
unset($res[2]["_id"]);
|
||||
$this->assertSame($res, array ());
|
||||
$this->assertSame($res, []);
|
||||
}
|
||||
|
||||
public function test_find11()
|
||||
public function testFind11()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key1" => "val3", "key2" => "val4")));
|
||||
$this->assertSame($res, [0 => ["key1" => "val3", "key2" => "val4"]]);
|
||||
}
|
||||
|
||||
public function test_replace1()
|
||||
public function testReplace1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->replace("collection", array (), array ("key2" => "val5"));
|
||||
$res = $dbjson->replace("collection", [], ["key2" => "val5"]);
|
||||
$this->assertSame($res, 1);
|
||||
}
|
||||
public function test_find12()
|
||||
public function testFind12()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key2" => "val5")));
|
||||
$this->assertSame($res, [0 => ["key2" => "val5"]]);
|
||||
}
|
||||
|
||||
public function test_update1()
|
||||
public function testUpdate1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->update("collection", array (), array ("key2" => "val6",
|
||||
"key5" => "val5"));
|
||||
$res = $dbjson->update("collection", [], ["key2" => "val6",
|
||||
"key5" => "val5"]);
|
||||
$this->assertSame($res, 1);
|
||||
}
|
||||
public function test_find13()
|
||||
public function testFind13()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key2" => "val6",
|
||||
"key5" => "val5")));
|
||||
$this->assertSame($res, [0 => ["key2" => "val6",
|
||||
"key5" => "val5"]]);
|
||||
}
|
||||
public function test_insertOne3()
|
||||
public function testInsertOne3()
|
||||
{
|
||||
// Document #4
|
||||
// Document #4
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->insertOne(
|
||||
"collection",
|
||||
array ("key1" => "val1", "key2" => "val2")
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
);
|
||||
$this->assertSame($res, 1);
|
||||
}
|
||||
public function test_find14()
|
||||
public function testFind14()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
unset($res[1]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key2" => "val6",
|
||||
"key5" => "val5"),
|
||||
1 => array ("key1" => "val1",
|
||||
"key2" => "val2")));
|
||||
$this->assertSame($res, [0 => ["key2" => "val6",
|
||||
"key5" => "val5"],
|
||||
1 => ["key1" => "val1",
|
||||
"key2" => "val2"]]);
|
||||
}
|
||||
|
||||
public function test_update2()
|
||||
public function testUpdate2()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->update("collection", array (), array ("key2" => "val7",
|
||||
"key5" => "val8"));
|
||||
$res = $dbjson->update("collection", [], ["key2" => "val7",
|
||||
"key5" => "val8"]);
|
||||
$this->assertSame($res, 2);
|
||||
}
|
||||
public function test_find15()
|
||||
public function testFind15()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
unset($res[1]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key2" => "val7",
|
||||
"key5" => "val8"),
|
||||
1 => array ("key1" => "val1",
|
||||
$this->assertSame($res, [0 => ["key2" => "val7",
|
||||
"key5" => "val8"],
|
||||
1 => ["key1" => "val1",
|
||||
"key2" => "val7",
|
||||
"key5" => "val8")));
|
||||
"key5" => "val8"]]);
|
||||
}
|
||||
|
||||
public function test_update3()
|
||||
public function testUpdate3()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = $dbjson->update(
|
||||
"collection",
|
||||
array (),
|
||||
array ("key2" => "val9",
|
||||
[],
|
||||
["key2" => "val9",
|
||||
"key5" => "val7",
|
||||
"_unset" => array ("key2"))
|
||||
"_unset" => ["key2"]]
|
||||
);
|
||||
$this->assertSame($res, 2);
|
||||
}
|
||||
public function test_find16()
|
||||
public function testFind16()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
unset($res[1]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key5" => "val7"),
|
||||
1 => array ("key1" => "val1",
|
||||
"key5" => "val7")));
|
||||
$this->assertSame($res, [0 => ["key5" => "val7"],
|
||||
1 => ["key1" => "val1",
|
||||
"key5" => "val7"]]);
|
||||
}
|
||||
|
||||
// Concurrency tests
|
||||
public function test_concurrency1()
|
||||
public function testConcurrency1()
|
||||
{
|
||||
$dbjson1 = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson2 = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson1->insertOne(
|
||||
"collection",
|
||||
array ("key1" => "val1", "key2" => "val2")
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
);
|
||||
$res = array_values($dbjson2->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
unset($res[1]["_id"]);
|
||||
unset($res[2]["_id"]);
|
||||
$this->assertSame($res, array (0 => array ("key5" => "val7"),
|
||||
1 => array ("key1" => "val1",
|
||||
"key5" => "val7"),
|
||||
2 => array ("key1" => "val1",
|
||||
"key2" => "val2")));
|
||||
$this->assertSame($res, [0 => ["key5" => "val7"],
|
||||
1 => ["key1" => "val1",
|
||||
"key5" => "val7"],
|
||||
2 => ["key1" => "val1",
|
||||
"key2" => "val2"]]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user