Exemplo n.º 1
0
 /**
  * @test
  */
 public function shouldFindModelById()
 {
     $expectedModelClass = 'Payum\\Core\\Tests\\Mocks\\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\\Core\\Tests\\Mocks\\Model\\TestModel');
     $actualModel = $storage->findModelById($expectedModelId);
     $this->assertSame($expectedFoundModel, $actualModel);
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function shouldFindModelById()
 {
     $storage = new DoctrineStorage($this->em, 'Payum\\Core\\Tests\\Mocks\\Entity\\TestModel');
     $model = $storage->createModel();
     $storage->updateModel($model);
     $requestId = $model->getId();
     $this->em->clear();
     $model = $storage->findModelById($requestId);
     $this->assertInstanceOf('Payum\\Core\\Tests\\Mocks\\Entity\\TestModel', $model);
     $this->assertEquals($requestId, $model->getId());
 }