/**
  * @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->create();
     $storage->update($model);
 }
    /**
     * @test
     */
    public function shouldFindModelByIdentity()
    {
        $storage = new DoctrineStorage(
            $this->em,
            'Payum\Core\Tests\Mocks\Entity\TestModel'
        );

        $model = $storage->create();

        $storage->update($model);

        $requestId = $model->getId();

        $this->em->clear();

        $identity = $storage->identify($model);

        $foundModel = $storage->find($identity);

        $this->assertInstanceOf('Payum\Core\Tests\Mocks\Entity\TestModel', $foundModel);
        $this->assertEquals($requestId, $foundModel->getId());
    }
 /**
  * @test
  */
 public function shouldFindByAllIfCriteriaIsEmpty()
 {
     $storage = new DoctrineStorage($this->em, 'Payum\\Core\\Tests\\Mocks\\Entity\\TestModel');
     /** @var TestModel $model */
     $model = $storage->create();
     $model->setCurrency('USD');
     $storage->update($model);
     /** @var TestModel $model */
     $model = $storage->create();
     $model->setCurrency('USD');
     $storage->update($model);
     /** @var TestModel $model */
     $model = $storage->create();
     $model->setCurrency('EUR');
     $storage->update($model);
     $result = $storage->findBy(array());
     $this->assertCount(3, $result);
     $this->assertContainsOnly('Payum\\Core\\Tests\\Mocks\\Entity\\TestModel', $result);
 }