@@ 37-51 (lines=15) @@ | ||
34 | $this->assertNull($provider->getObject('foo', ['some_column_not_id'=>42])); |
|
35 | } |
|
36 | ||
37 | public function testGetObjectExistingPk() |
|
38 | { |
|
39 | $tdbmService = $this->createMock(TDBMService::class); |
|
40 | $tdbmService->method('_getPrimaryKeysFromObjectData') |
|
41 | ->willReturn(['id'=>42]); |
|
42 | ||
43 | $tdbmService->method('findObjectByPk') |
|
44 | ->willReturn('some_foo'); |
|
45 | ||
46 | $provider = new TdbmDbProvider($tdbmService); |
|
47 | ||
48 | ||
49 | ||
50 | $this->assertSame('some_foo', $provider->getObject('foo', ['id'=>42])); |
|
51 | } |
|
52 | ||
53 | public function testGetObjectNonExistingPk() |
|
54 | { |
|
@@ 53-68 (lines=16) @@ | ||
50 | $this->assertSame('some_foo', $provider->getObject('foo', ['id'=>42])); |
|
51 | } |
|
52 | ||
53 | public function testGetObjectNonExistingPk() |
|
54 | { |
|
55 | $tdbmService = $this->createMock(TDBMService::class); |
|
56 | $tdbmService->method('_getPrimaryKeysFromObjectData') |
|
57 | ->willReturn(['id'=>'not_exist']); |
|
58 | ||
59 | $tdbmService->method('findObjectByPk') |
|
60 | ->willThrowException(new NoBeanFoundException('No bean found')); |
|
61 | ||
62 | $provider = new TdbmDbProvider($tdbmService); |
|
63 | ||
64 | $this->expectException(DBException::class); |
|
65 | $this->expectExceptionMessage('No bean found'); |
|
66 | ||
67 | $provider->getObject('foo', ['id'=>'not_exist']); |
|
68 | } |
|
69 | } |
|
70 |