/** * @test */ public function shouldFindModelById() { $expectedModelClass = 'Payum\\Examples\\Model\\TestModel'; $expectedModelId = 123; $expectedFoundModel = new TestModel(); $objectManagerMock = $this->createObjectManagerMock(); $objectManagerMock->expects($this->once())->method('find')->with($expectedModelClass, $expectedModelId)->will($this->returnValue($expectedFoundModel)); $storage = new DoctrineStorage($objectManagerMock, 'Payum\\Examples\\Model\\TestModel'); $actualModel = $storage->findModelById($expectedModelId); $this->assertSame($expectedFoundModel, $actualModel); }
/** * @test */ public function shouldFindModelById() { $storage = new DoctrineStorage($this->dm, 'Payum\\Examples\\Document\\TestModel'); $model = $storage->createModel(); $storage->updateModel($model); $requestId = $model->getId(); $this->dm->clear(); $model = $storage->findModelById($requestId); $this->assertInstanceOf('Payum\\Examples\\Document\\TestModel', $model); $this->assertEquals($requestId, $model->getId()); }