Exemplo n.º 1
0
 /**
  * @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 shouldFindModelByIdentificator()
 {
     $storage = new DoctrineStorage($this->dm, 'Payum\\Examples\\Document\\TestModel');
     $model = $storage->createModel();
     $storage->updateModel($model);
     $requestId = $model->getId();
     $this->dm->clear();
     $identificator = $storage->getIdentificator($model);
     $foundModel = $storage->findModelByIdentificator($identificator);
     $this->assertInstanceOf('Payum\\Examples\\Document\\TestModel', $foundModel);
     $this->assertEquals($requestId, $foundModel->getId());
 }