8 namespace Fossology\Lib\Db;
14 function setUp() :
void
18 $this->
dbManager->setDriver($this->driver);
21 function tearDown() :
void
26 function testInsertTableRow()
29 $assocParams = array(
'cola'=>1,
'colb'=>2);
31 $preSql =
"INSERT INTO $tableName (cola,colb) VALUES ($1,$2)";
32 $this->driver->shouldReceive(
'prepare')->with($sqlLog,$preSql)->once();
33 $this->driver->shouldReceive(
'execute')->with($sqlLog,array_values($assocParams))->once();
34 $this->driver->shouldReceive(
'freeResult');
35 $this->
dbManager->insertTableRow($tableName,$assocParams,$sqlLog);
38 function testCreateMap()
44 $preSql =
"/ $keyColumn, *$valueColumn /";
45 $this->driver->shouldReceive(
'prepare')->with($sqlLog,\Mockery::pattern($preSql))->once();
46 $this->driver->shouldReceive(
'execute')->andReturn(
'fakeRes');
47 $this->driver->shouldReceive(
'fetchArray')->andReturn(
48 array($keyColumn=>
'k0',$valueColumn=>
'v0'),
49 array($keyColumn=>
'k1',$valueColumn=>
'v1'),
52 $this->driver->shouldReceive(
'freeResult');
53 $map = $this->
dbManager->createMap($tableName,$keyColumn,$valueColumn,$sqlLog);
54 assertThat($map,hasKey(
'k0'));
55 assertThat($map,EqualTo(array(
'k0'=>
'v0',
'k1'=>
'v1')));
fo_dbManager * dbManager
fo_dbManager object