/** * @test */ public function shouldCallObjectManagerPersistAndFlushOnUpdateModel() { $objectManagerMock = $this->createObjectManagerMock(); $objectManagerMock->expects($this->once())->method('persist')->with($this->isInstanceOf('Payum\\Core\\Tests\\Mocks\\Model\\TestModel')); $objectManagerMock->expects($this->once())->method('flush'); $storage = new DoctrineStorage($objectManagerMock, 'Payum\\Core\\Tests\\Mocks\\Model\\TestModel'); $model = $storage->createModel(); $storage->updateModel($model); }
/** * @test */ public function shouldFindModelByIdentificator() { $storage = new DoctrineStorage($this->em, 'Payum\\Core\\Tests\\Mocks\\Entity\\TestModel'); $model = $storage->createModel(); $storage->updateModel($model); $requestId = $model->getId(); $this->em->clear(); $identificator = $storage->getIdentificator($model); $foundModel = $storage->findModelByIdentificator($identificator); $this->assertInstanceOf('Payum\\Core\\Tests\\Mocks\\Entity\\TestModel', $foundModel); $this->assertEquals($requestId, $foundModel->getId()); }