/** * @test */ public function shouldProxyCriteriaToRepositoryFindByMethodOnFindByCall() { $modelClass = 'Payum\\Core\\Tests\\Mocks\\Model\\TestModel'; $model = new TestModel(); $criteria = array('foo' => 'fooVal', 'bar' => 'barVal'); $objectRepositoryMock = $this->createObjectRepositoryMock(); $objectRepositoryMock->expects($this->once())->method('findBy')->with($criteria)->willReturn($model); $objectManagerMock = $this->createObjectManagerMock(); $objectManagerMock->expects($this->once())->method('getRepository')->with($modelClass)->willReturn($objectRepositoryMock); $storage = new DoctrineStorage($objectManagerMock, 'Payum\\Core\\Tests\\Mocks\\Model\\TestModel'); $this->assertSame($model, $storage->findBy($criteria)); }
/** * @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); }