| @@ 114-129 (lines=16) @@ | ||
| 111 | $this->assertSame($queryBuilder, $this->repository->createQueryBuilderForCollection()); |
|
| 112 | } |
|
| 113 | ||
| 114 | public function testFindOneByWithNullValue() |
|
| 115 | { |
|
| 116 | $queryBuilder = $this->setUpQueryBuilder($value = null); |
|
| 117 | ||
| 118 | $queryBuilder |
|
| 119 | ->expects($this->once()) |
|
| 120 | ->method('getQuery') |
|
| 121 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 122 | ||
| 123 | $query |
|
| 124 | ->expects($this->once()) |
|
| 125 | ->method('getSingleResult') |
|
| 126 | ->will($this->returnValue($result = 'result')); |
|
| 127 | ||
| 128 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 129 | } |
|
| 130 | ||
| 131 | public function testFindOneByWithScalarValue() |
|
| 132 | { |
|
| @@ 131-146 (lines=16) @@ | ||
| 128 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 129 | } |
|
| 130 | ||
| 131 | public function testFindOneByWithScalarValue() |
|
| 132 | { |
|
| 133 | $queryBuilder = $this->setUpQueryBuilder($value = 'bar'); |
|
| 134 | ||
| 135 | $queryBuilder |
|
| 136 | ->expects($this->once()) |
|
| 137 | ->method('getQuery') |
|
| 138 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 139 | ||
| 140 | $query |
|
| 141 | ->expects($this->once()) |
|
| 142 | ->method('getSingleResult') |
|
| 143 | ->will($this->returnValue($result = 'result')); |
|
| 144 | ||
| 145 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 146 | } |
|
| 147 | ||
| 148 | public function testFindOneByWithArrayValue() |
|
| 149 | { |
|
| @@ 148-163 (lines=16) @@ | ||
| 145 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 146 | } |
|
| 147 | ||
| 148 | public function testFindOneByWithArrayValue() |
|
| 149 | { |
|
| 150 | $queryBuilder = $this->setUpQueryBuilder($value = ['bar']); |
|
| 151 | ||
| 152 | $queryBuilder |
|
| 153 | ->expects($this->once()) |
|
| 154 | ->method('getQuery') |
|
| 155 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 156 | ||
| 157 | $query |
|
| 158 | ->expects($this->once()) |
|
| 159 | ->method('getSingleResult') |
|
| 160 | ->will($this->returnValue($result = 'result')); |
|
| 161 | ||
| 162 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 163 | } |
|
| 164 | ||
| 165 | public function testFindBy() |
|
| 166 | { |
|
| @@ 209-224 (lines=16) @@ | ||
| 206 | $this->assertInstanceOf(DoctrineODMMongoDBAdapter::class, $pager->getAdapter()); |
|
| 207 | } |
|
| 208 | ||
| 209 | public function testFindForShow() |
|
| 210 | { |
|
| 211 | $queryBuilder = $this->setUpQueryBuilder($value = 'bar'); |
|
| 212 | ||
| 213 | $queryBuilder |
|
| 214 | ->expects($this->once()) |
|
| 215 | ->method('getQuery') |
|
| 216 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 217 | ||
| 218 | $query |
|
| 219 | ->expects($this->once()) |
|
| 220 | ->method('getSingleResult') |
|
| 221 | ->will($this->returnValue($result = 'result')); |
|
| 222 | ||
| 223 | $this->assertSame($result, $this->repository->findForShow(['foo' => $value], ['baz' => 'ASC'])); |
|
| 224 | } |
|
| 225 | ||
| 226 | public function testFindForUpdate() |
|
| 227 | { |
|
| @@ 226-241 (lines=16) @@ | ||
| 223 | $this->assertSame($result, $this->repository->findForShow(['foo' => $value], ['baz' => 'ASC'])); |
|
| 224 | } |
|
| 225 | ||
| 226 | public function testFindForUpdate() |
|
| 227 | { |
|
| 228 | $queryBuilder = $this->setUpQueryBuilder($value = 'bar'); |
|
| 229 | ||
| 230 | $queryBuilder |
|
| 231 | ->expects($this->once()) |
|
| 232 | ->method('getQuery') |
|
| 233 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 234 | ||
| 235 | $query |
|
| 236 | ->expects($this->once()) |
|
| 237 | ->method('getSingleResult') |
|
| 238 | ->will($this->returnValue($result = 'result')); |
|
| 239 | ||
| 240 | $this->assertSame($result, $this->repository->findForUpdate(['foo' => $value], ['baz' => 'ASC'])); |
|
| 241 | } |
|
| 242 | ||
| 243 | public function testFindForDelete() |
|
| 244 | { |
|
| @@ 243-258 (lines=16) @@ | ||
| 240 | $this->assertSame($result, $this->repository->findForUpdate(['foo' => $value], ['baz' => 'ASC'])); |
|
| 241 | } |
|
| 242 | ||
| 243 | public function testFindForDelete() |
|
| 244 | { |
|
| 245 | $queryBuilder = $this->setUpQueryBuilder($value = 'bar'); |
|
| 246 | ||
| 247 | $queryBuilder |
|
| 248 | ->expects($this->once()) |
|
| 249 | ->method('getQuery') |
|
| 250 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 251 | ||
| 252 | $query |
|
| 253 | ->expects($this->once()) |
|
| 254 | ->method('getSingleResult') |
|
| 255 | ->will($this->returnValue($result = 'result')); |
|
| 256 | ||
| 257 | $this->assertSame($result, $this->repository->findForDelete(['foo' => $value], ['baz' => 'ASC'])); |
|
| 258 | } |
|
| 259 | ||
| 260 | /** |
|
| 261 | * @param mixed $value |
|
| @@ 126-141 (lines=16) @@ | ||
| 123 | $this->assertSame($queryBuilder, $this->repository->createQueryBuilderForCollection(null, $indexBy)); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function testFindOneByWithNullValue() |
|
| 127 | { |
|
| 128 | $queryBuilder = $this->setUpQueryBuilder($value = null); |
|
| 129 | ||
| 130 | $queryBuilder |
|
| 131 | ->expects($this->once()) |
|
| 132 | ->method('getQuery') |
|
| 133 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 134 | ||
| 135 | $query |
|
| 136 | ->expects($this->once()) |
|
| 137 | ->method('getOneOrNullResult') |
|
| 138 | ->will($this->returnValue($result = 'result')); |
|
| 139 | ||
| 140 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 141 | } |
|
| 142 | ||
| 143 | public function testFindOneByWithScalarValue() |
|
| 144 | { |
|
| @@ 143-158 (lines=16) @@ | ||
| 140 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 141 | } |
|
| 142 | ||
| 143 | public function testFindOneByWithScalarValue() |
|
| 144 | { |
|
| 145 | $queryBuilder = $this->setUpQueryBuilder($value = 'bar'); |
|
| 146 | ||
| 147 | $queryBuilder |
|
| 148 | ->expects($this->once()) |
|
| 149 | ->method('getQuery') |
|
| 150 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 151 | ||
| 152 | $query |
|
| 153 | ->expects($this->once()) |
|
| 154 | ->method('getOneOrNullResult') |
|
| 155 | ->will($this->returnValue($result = 'result')); |
|
| 156 | ||
| 157 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 158 | } |
|
| 159 | ||
| 160 | public function testFindOneByWithArrayValue() |
|
| 161 | { |
|
| @@ 160-175 (lines=16) @@ | ||
| 157 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 158 | } |
|
| 159 | ||
| 160 | public function testFindOneByWithArrayValue() |
|
| 161 | { |
|
| 162 | $queryBuilder = $this->setUpQueryBuilder($value = ['bar']); |
|
| 163 | ||
| 164 | $queryBuilder |
|
| 165 | ->expects($this->once()) |
|
| 166 | ->method('getQuery') |
|
| 167 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 168 | ||
| 169 | $query |
|
| 170 | ->expects($this->once()) |
|
| 171 | ->method('getOneOrNullResult') |
|
| 172 | ->will($this->returnValue($result = 'result')); |
|
| 173 | ||
| 174 | $this->assertSame($result, $this->repository->findOneBy(['foo' => $value], ['baz' => 'ASC'])); |
|
| 175 | } |
|
| 176 | ||
| 177 | public function testFindBy() |
|
| 178 | { |
|
| @@ 216-231 (lines=16) @@ | ||
| 213 | $this->assertInstanceOf(DoctrineORMAdapter::class, $pager->getAdapter()); |
|
| 214 | } |
|
| 215 | ||
| 216 | public function testFindForShow() |
|
| 217 | { |
|
| 218 | $queryBuilder = $this->setUpQueryBuilder($value = 'bar'); |
|
| 219 | ||
| 220 | $queryBuilder |
|
| 221 | ->expects($this->once()) |
|
| 222 | ->method('getQuery') |
|
| 223 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 224 | ||
| 225 | $query |
|
| 226 | ->expects($this->once()) |
|
| 227 | ->method('getOneOrNullResult') |
|
| 228 | ->will($this->returnValue($result = 'result')); |
|
| 229 | ||
| 230 | $this->assertSame($result, $this->repository->findForShow(['foo' => $value], ['baz' => 'ASC'])); |
|
| 231 | } |
|
| 232 | ||
| 233 | public function testFindForUpdate() |
|
| 234 | { |
|
| @@ 233-248 (lines=16) @@ | ||
| 230 | $this->assertSame($result, $this->repository->findForShow(['foo' => $value], ['baz' => 'ASC'])); |
|
| 231 | } |
|
| 232 | ||
| 233 | public function testFindForUpdate() |
|
| 234 | { |
|
| 235 | $queryBuilder = $this->setUpQueryBuilder($value = 'bar'); |
|
| 236 | ||
| 237 | $queryBuilder |
|
| 238 | ->expects($this->once()) |
|
| 239 | ->method('getQuery') |
|
| 240 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 241 | ||
| 242 | $query |
|
| 243 | ->expects($this->once()) |
|
| 244 | ->method('getOneOrNullResult') |
|
| 245 | ->will($this->returnValue($result = 'result')); |
|
| 246 | ||
| 247 | $this->assertSame($result, $this->repository->findForUpdate(['foo' => $value], ['baz' => 'ASC'])); |
|
| 248 | } |
|
| 249 | ||
| 250 | public function testFindForDelete() |
|
| 251 | { |
|
| @@ 250-265 (lines=16) @@ | ||
| 247 | $this->assertSame($result, $this->repository->findForUpdate(['foo' => $value], ['baz' => 'ASC'])); |
|
| 248 | } |
|
| 249 | ||
| 250 | public function testFindForDelete() |
|
| 251 | { |
|
| 252 | $queryBuilder = $this->setUpQueryBuilder($value = 'bar'); |
|
| 253 | ||
| 254 | $queryBuilder |
|
| 255 | ->expects($this->once()) |
|
| 256 | ->method('getQuery') |
|
| 257 | ->will($this->returnValue($query = $this->createQueryMock())); |
|
| 258 | ||
| 259 | $query |
|
| 260 | ->expects($this->once()) |
|
| 261 | ->method('getOneOrNullResult') |
|
| 262 | ->will($this->returnValue($result = 'result')); |
|
| 263 | ||
| 264 | $this->assertSame($result, $this->repository->findForDelete(['foo' => $value], ['baz' => 'ASC'])); |
|
| 265 | } |
|
| 266 | ||
| 267 | /** |
|
| 268 | * @param mixed $value |
|