How to use offsetGet method of calls class

Best Atoum code snippet using calls.offsetGet

DoctrineOrmManagerRegistryTest.php

Source:DoctrineOrmManagerRegistryTest.php Github

copy

Full Screen

...30 public function testGetDefaultConnectionName(): void31 {32 /** @var Container|MockObject $container */33 $container = $this->getMockByCalls(Container::class, [34 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn($this->getMockByCalls(Container::class)),35 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default']),36 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),37 ]);38 $registry = new DoctrineOrmManagerRegistry($container);39 self::assertSame('default', $registry->getDefaultConnectionName());40 }41 public function testGetConnection(): void42 {43 /** @var Connection|MockObject $connection */44 $connection = $this->getMockByCalls(Connection::class);45 /** @var Container|MockObject $container */46 $container = $this->getMockByCalls(Container::class, [47 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(48 $this->getMockByCalls(Container::class, [49 Call::create('offsetExists')->with('default')->willReturn(true),50 Call::create('offsetGet')->with('default')->willReturn($connection),51 ])52 ),53 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default']),54 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),55 ]);56 $registry = new DoctrineOrmManagerRegistry($container);57 self::assertSame($connection, $registry->getConnection());58 }59 public function testGetConnectionByName(): void60 {61 /** @var Connection|MockObject $connection */62 $connection = $this->getMockByCalls(Connection::class);63 /** @var Container|MockObject $container */64 $container = $this->getMockByCalls(Container::class, [65 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(66 $this->getMockByCalls(Container::class, [67 Call::create('offsetExists')->with('somename')->willReturn(true),68 Call::create('offsetGet')->with('somename')->willReturn($connection),69 ])70 ),71 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default', 'somename']),72 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),73 ]);74 $registry = new DoctrineOrmManagerRegistry($container);75 self::assertSame($connection, $registry->getConnection('somename'));76 }77 public function testGetMissingConnection(): void78 {79 $this->expectException(\InvalidArgumentException::class);80 $this->expectExceptionMessage('Missing connection with name "default".');81 /** @var Container|MockObject $container */82 $container = $this->getMockByCalls(Container::class, [83 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(84 $this->getMockByCalls(Container::class, [85 Call::create('offsetExists')->with('default')->willReturn(false),86 ])87 ),88 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn([]),89 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),90 ]);91 $registry = new DoctrineOrmManagerRegistry($container);92 $registry->getConnection();93 }94 public function testGetConnections(): void95 {96 /** @var Connection|MockObject $connection1 */97 $connection1 = $this->getMockByCalls(Connection::class);98 /** @var Connection|MockObject $connection2 */99 $connection2 = $this->getMockByCalls(Connection::class);100 /** @var Container|MockObject $container */101 $container = $this->getMockByCalls(Container::class, [102 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(103 $this->getMockByCalls(Container::class, [104 Call::create('offsetGet')->with('default')->willReturn($connection1),105 Call::create('offsetGet')->with('somename')->willReturn($connection2),106 ])107 ),108 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default', 'somename']),109 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),110 ]);111 $registry = new DoctrineOrmManagerRegistry($container);112 $connections = $registry->getConnections();113 self::assertIsArray($connections);114 self::assertCount(2, $connections);115 self::assertSame($connection1, $connections['default']);116 self::assertSame($connection2, $connections['somename']);117 }118 public function testGetConnectionNames(): void119 {120 /** @var Container|MockObject $container */121 $container = $this->getMockByCalls(Container::class, [122 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(123 $this->getMockByCalls(Container::class)124 ),125 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default']),126 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),127 ]);128 $registry = new DoctrineOrmManagerRegistry($container);129 self::assertSame(['default'], $registry->getConnectionNames());130 }131 public function testGetDefaultManagerName(): void132 {133 /** @var Container|MockObject $container */134 $container = $this->getMockByCalls(Container::class, [135 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn($this->getMockByCalls(Container::class)),136 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),137 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),138 ]);139 $registry = new DoctrineOrmManagerRegistry($container);140 self::assertSame('default', $registry->getDefaultManagerName());141 }142 public function testGetManager(): void143 {144 /** @var EntityManager|MockObject $manager */145 $manager = $this->getMockByCalls(EntityManager::class);146 /** @var Container|MockObject $container */147 $container = $this->getMockByCalls(Container::class, [148 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(149 $this->getMockByCalls(Container::class, [150 Call::create('offsetExists')->with('default')->willReturn(true),151 Call::create('offsetGet')->with('default')->willReturn($manager),152 ])153 ),154 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),155 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),156 ]);157 $registry = new DoctrineOrmManagerRegistry($container);158 self::assertSame($manager, $registry->getManager());159 }160 public function testGetManagerByName(): void161 {162 /** @var EntityManager|MockObject $manager */163 $manager = $this->getMockByCalls(EntityManager::class);164 /** @var Container|MockObject $container */165 $container = $this->getMockByCalls(Container::class, [166 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(167 $this->getMockByCalls(Container::class, [168 Call::create('offsetExists')->with('somename')->willReturn(true),169 Call::create('offsetGet')->with('somename')->willReturn($manager),170 ])171 ),172 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default', 'somename']),173 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),174 ]);175 $registry = new DoctrineOrmManagerRegistry($container);176 self::assertSame($manager, $registry->getManager('somename'));177 }178 public function testGetResetedManager(): void179 {180 /** @var EntityManager|MockObject $manager */181 $manager = $this->getMockByCalls(EntityManager::class);182 /** @var Container|MockObject $container */183 $container = $this->getMockByCalls(Container::class, [184 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(185 $this->getMockByCalls(Container::class, [186 Call::create('offsetExists')->with('default')->willReturn(true),187 ])188 ),189 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),190 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),191 ]);192 $registry = new DoctrineOrmManagerRegistry($container);193 $propertyReflection = new \ReflectionProperty($registry, 'resetedManagers');194 $propertyReflection->setAccessible(true);195 $propertyReflection->setValue($registry, ['default' => $manager]);196 self::assertSame($manager, $registry->getManager());197 }198 public function testGetMissingManager(): void199 {200 $this->expectException(\InvalidArgumentException::class);201 $this->expectExceptionMessage('Missing manager with name "default".');202 /** @var Container|MockObject $container */203 $container = $this->getMockByCalls(Container::class, [204 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(205 $this->getMockByCalls(Container::class, [206 Call::create('offsetExists')->with('default')->willReturn(false),207 ])208 ),209 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn([]),210 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),211 ]);212 $registry = new DoctrineOrmManagerRegistry($container);213 $registry->getManager();214 }215 public function testGetManagers(): void216 {217 /** @var EntityManager|MockObject $manager1 */218 $manager1 = $this->getMockByCalls(EntityManager::class);219 /** @var EntityManager|MockObject $manager2 */220 $manager2 = $this->getMockByCalls(EntityManager::class);221 /** @var Container|MockObject $container */222 $container = $this->getMockByCalls(Container::class, [223 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(224 $this->getMockByCalls(Container::class, [225 Call::create('offsetGet')->with('default')->willReturn($manager1),226 Call::create('offsetGet')->with('somename')->willReturn($manager2),227 ])228 ),229 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default', 'somename']),230 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),231 ]);232 $registry = new DoctrineOrmManagerRegistry($container);233 $managers = $registry->getManagers();234 self::assertIsArray($managers);235 self::assertCount(2, $managers);236 self::assertSame($manager1, $managers['default']);237 self::assertSame($manager2, $managers['somename']);238 }239 public function testGetResetedManagers(): void240 {241 /** @var EntityManager|MockObject $manager */242 $manager = $this->getMockByCalls(EntityManager::class);243 /** @var Container|MockObject $container */244 $container = $this->getMockByCalls(Container::class, [245 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(246 $this->getMockByCalls(Container::class)247 ),248 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),249 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),250 ]);251 $registry = new DoctrineOrmManagerRegistry($container);252 $propertyReflection = new \ReflectionProperty($registry, 'resetedManagers');253 $propertyReflection->setAccessible(true);254 $propertyReflection->setValue($registry, ['default' => $manager]);255 $managers = $registry->getManagers();256 self::assertIsArray($managers);257 self::assertCount(1, $managers);258 self::assertSame($manager, $managers['default']);259 }260 public function testGetManagerNames(): void261 {262 /** @var Container|MockObject $container */263 $container = $this->getMockByCalls(Container::class, [264 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(265 $this->getMockByCalls(Container::class)266 ),267 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),268 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),269 ]);270 $registry = new DoctrineOrmManagerRegistry($container);271 self::assertSame(['default'], $registry->getManagerNames());272 }273 public function testResetManager(): void274 {275 /** @var EventManager|MockObject $eventManager */276 $eventManager = $this->getMockByCalls(EventManager::class);277 /** @var MappingDriver|MockObject $mappingDriver */278 $mappingDriver = $this->getMockByCalls(MappingDriver::class);279 /** @var Connection|MockObject $connection */280 $connection = $this->getMockByCalls(Connection::class, [281 Call::create('getEventManager')->with()->willReturn($eventManager),282 Call::create('getEventManager')->with()->willReturn($eventManager),283 ]);284 /** @var MockObject|RepositoryFactory $repositoryFactory */285 $repositoryFactory = $this->getMockByCalls(RepositoryFactory::class);286 /** @var EntityListenerResolver|MockObject $entityListenerResolver */287 $entityListenerResolver = $this->getMockByCalls(EntityListenerResolver::class);288 /** @var Configuration|MockObject $configuration */289 $configuration = $this->getMockByCalls(Configuration::class, [290 Call::create('getMetadataDriverImpl')->with()->willReturn($mappingDriver),291 Call::create('getClassMetadataFactoryName')->with()->willReturn(ClassMetadataFactory::class),292 Call::create('getMetadataCache')->with()->willReturn(null),293 Call::create('getMetadataCacheImpl')->with()->willReturn(null),294 Call::create('getRepositoryFactory')->with()->willReturn($repositoryFactory),295 Call::create('getEntityListenerResolver')->with()->willReturn($entityListenerResolver),296 Call::create('isSecondLevelCacheEnabled')->with()->willReturn(false),297 Call::create('getProxyDir')->with()->willReturn(sys_get_temp_dir()),298 Call::create('getProxyNamespace')->with()->willReturn('DoctrineProxy'),299 Call::create('getAutoGenerateProxyClasses')->with()->willReturn(AbstractProxyFactory::AUTOGENERATE_ALWAYS),300 Call::create('isSecondLevelCacheEnabled')->with()->willReturn(false),301 ]);302 /** @var EntityManager|MockObject $manager */303 $manager = $this->getMockByCalls(EntityManager::class, [304 Call::create('getConnection')->with()->willReturn($connection),305 Call::create('getConfiguration')->with()->willReturn($configuration),306 Call::create('getEventManager')->with()->willReturn($eventManager),307 ]);308 /** @var Container|MockObject $container */309 $container = $this->getMockByCalls(Container::class, [310 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(311 $this->getMockByCalls(Container::class, [312 Call::create('offsetExists')->with('default')->willReturn(true),313 Call::create('offsetGet')->with('default')->willReturn($manager),314 ])315 ),316 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),317 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),318 Call::create('offsetGet')->with('doctrine.orm.em.factory')->willReturn(319 static fn (Connection $connection, Configuration $config, EventManager $eventManager) => EntityManager::create($connection, $config, $eventManager)320 ),321 ]);322 $registry = new DoctrineOrmManagerRegistry($container);323 $registry->resetManager();324 }325 public function testResetManagerByName(): void326 {327 /** @var EventManager|MockObject $eventManager */328 $eventManager = $this->getMockByCalls(EventManager::class);329 /** @var MappingDriver|MockObject $mappingDriver */330 $mappingDriver = $this->getMockByCalls(MappingDriver::class);331 /** @var Connection|MockObject $connection */332 $connection = $this->getMockByCalls(Connection::class, [333 Call::create('getEventManager')->with()->willReturn($eventManager),334 Call::create('getEventManager')->with()->willReturn($eventManager),335 ]);336 /** @var MockObject|RepositoryFactory $repositoryFactory */337 $repositoryFactory = $this->getMockByCalls(RepositoryFactory::class);338 /** @var EntityListenerResolver|MockObject $entityListenerResolver */339 $entityListenerResolver = $this->getMockByCalls(EntityListenerResolver::class);340 /** @var Configuration|MockObject $configuration */341 $configuration = $this->getMockByCalls(Configuration::class, [342 Call::create('getMetadataDriverImpl')->with()->willReturn($mappingDriver),343 Call::create('getClassMetadataFactoryName')->with()->willReturn(ClassMetadataFactory::class),344 Call::create('getMetadataCache')->with()->willReturn(null),345 Call::create('getMetadataCacheImpl')->with()->willReturn(null),346 Call::create('getRepositoryFactory')->with()->willReturn($repositoryFactory),347 Call::create('getEntityListenerResolver')->with()->willReturn($entityListenerResolver),348 Call::create('isSecondLevelCacheEnabled')->with()->willReturn(false),349 Call::create('getProxyDir')->with()->willReturn(sys_get_temp_dir()),350 Call::create('getProxyNamespace')->with()->willReturn('DoctrineProxy'),351 Call::create('getAutoGenerateProxyClasses')->with()->willReturn(AbstractProxyFactory::AUTOGENERATE_ALWAYS),352 Call::create('isSecondLevelCacheEnabled')->with()->willReturn(false),353 ]);354 /** @var EntityManager|MockObject $manager */355 $manager = $this->getMockByCalls(EntityManager::class, [356 Call::create('getConnection')->with()->willReturn($connection),357 Call::create('getConfiguration')->with()->willReturn($configuration),358 Call::create('getEventManager')->with()->willReturn($eventManager),359 ]);360 /** @var Container|MockObject $container */361 $container = $this->getMockByCalls(Container::class, [362 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(363 $this->getMockByCalls(Container::class, [364 Call::create('offsetExists')->with('somename')->willReturn(true),365 Call::create('offsetGet')->with('somename')->willReturn($manager),366 ])367 ),368 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default', 'somename']),369 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),370 Call::create('offsetGet')->with('doctrine.orm.em.factory')->willReturn(371 static fn (Connection $connection, Configuration $config, EventManager $eventManager) => EntityManager::create($connection, $config, $eventManager)372 ),373 ]);374 $registry = new DoctrineOrmManagerRegistry($container);375 $registry->resetManager('somename');376 }377 public function testResetMissingManager(): void378 {379 $this->expectException(\InvalidArgumentException::class);380 $this->expectExceptionMessage('Missing manager with name "default".');381 /** @var Container|MockObject $container */382 $container = $this->getMockByCalls(Container::class, [383 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(384 $this->getMockByCalls(Container::class, [385 Call::create('offsetExists')->with('default')->willReturn(false),386 ])387 ),388 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn([]),389 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),390 ]);391 $registry = new DoctrineOrmManagerRegistry($container);392 $registry->resetManager();393 }394 public function testGetAliasNamespace(): void395 {396 /** @var Configuration|MockObject $configuration */397 $configuration = $this->getMockByCalls(Configuration::class, [398 Call::create('getEntityNamespace')->with('alias')->willReturn('original'),399 ]);400 /** @var EntityManager|MockObject $manager */401 $manager = $this->getMockByCalls(EntityManager::class, [402 Call::create('getConfiguration')->with()->willReturn($configuration),403 ]);404 /** @var Container|MockObject $container */405 $container = $this->getMockByCalls(Container::class, [406 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(407 $this->getMockByCalls(Container::class, [408 Call::create('offsetExists')->with('default')->willReturn(true),409 Call::create('offsetGet')->with('default')->willReturn($manager),410 ])411 ),412 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),413 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),414 ]);415 $registry = new DoctrineOrmManagerRegistry($container);416 self::assertSame('original', $registry->getAliasNamespace('alias'));417 }418 public function testGetAliasNamespaceWithOrmException(): void419 {420 $this->expectException(ORMException::class);421 $this->expectExceptionMessage('Unknown Entity namespace alias \'alias\'.');422 /** @var EntityManager|MockObject $manager */423 $manager = $this->getMockByCalls(EntityManager::class, [424 Call::create('getConfiguration')->with()->willThrowException(new ORMException('')),425 ]);426 /** @var Container|MockObject $container */427 $container = $this->getMockByCalls(Container::class, [428 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(429 $this->getMockByCalls(Container::class, [430 Call::create('offsetExists')->with('default')->willReturn(true),431 Call::create('offsetGet')->with('default')->willReturn($manager),432 ])433 ),434 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),435 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),436 ]);437 $registry = new DoctrineOrmManagerRegistry($container);438 self::assertSame('original', $registry->getAliasNamespace('alias'));439 }440 public function testGetRepository(): void441 {442 /** @var EntityRepository|MockObject $repository */443 $repository = $this->getMockByCalls(EntityRepository::class);444 /** @var EntityManager|MockObject $manager */445 $manager = $this->getMockByCalls(EntityManager::class, [446 Call::create('getRepository')->with(\stdClass::class)->willReturn($repository),447 ]);448 /** @var Container|MockObject $container */449 $container = $this->getMockByCalls(Container::class, [450 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(451 $this->getMockByCalls(Container::class, [452 Call::create('offsetExists')->with('default')->willReturn(true),453 Call::create('offsetGet')->with('default')->willReturn($manager),454 ])455 ),456 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),457 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),458 ]);459 $registry = new DoctrineOrmManagerRegistry($container);460 self::assertSame($repository, $registry->getRepository(\stdClass::class, 'default'));461 }462 public function testGetManagerForClassFound(): void463 {464 /** @var ClassMetadataFactory|MockObject $classMetadataFactory */465 $classMetadataFactory = $this->getMockByCalls(ClassMetadataFactory::class, [466 Call::create('isTransient')->with(Sample::class)->willReturn(false),467 ]);468 /** @var EntityManager|MockObject $manager */469 $manager = $this->getMockByCalls(EntityManager::class, [470 Call::create('getMetadataFactory')->with()->willReturn($classMetadataFactory),471 ]);472 /** @var Container|MockObject $container */473 $container = $this->getMockByCalls(Container::class, [474 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(475 $this->getMockByCalls(Container::class, [476 Call::create('offsetExists')->with('default')->willReturn(true),477 Call::create('offsetGet')->with('default')->willReturn($manager),478 ])479 ),480 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),481 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),482 ]);483 $registry = new DoctrineOrmManagerRegistry($container);484 self::assertSame($manager, $registry->getManagerForClass(SampleProxy::class));485 }486 public function testGetManagerForClassNotFound(): void487 {488 /** @var ClassMetadataFactory|MockObject $classMetadataFactory */489 $classMetadataFactory = $this->getMockByCalls(ClassMetadataFactory::class, [490 Call::create('isTransient')->with(Sample::class)->willReturn(true),491 ]);492 /** @var EntityManager|MockObject $manager */493 $manager = $this->getMockByCalls(EntityManager::class, [494 Call::create('getMetadataFactory')->with()->willReturn($classMetadataFactory),495 ]);496 /** @var Container|MockObject $container */497 $container = $this->getMockByCalls(Container::class, [498 Call::create('offsetGet')->with('doctrine.orm.ems')->willReturn(499 $this->getMockByCalls(Container::class, [500 Call::create('offsetExists')->with('default')->willReturn(true),501 Call::create('offsetGet')->with('default')->willReturn($manager),502 ])503 ),504 Call::create('offsetGet')->with('doctrine.orm.ems.name')->willReturn(['default']),505 Call::create('offsetGet')->with('doctrine.orm.ems.default')->willReturn('default'),506 ]);507 $registry = new DoctrineOrmManagerRegistry($container);508 self::assertNull($registry->getManagerForClass(SampleProxy::class));509 }510}511class Sample512{513}514final class SampleProxy extends Sample implements Proxy515{516 public function __load(): void517 {518 }519 public function __isInitialized(): bool...

Full Screen

Full Screen

RequestParserStaticRequestTestTrait.php

Source:RequestParserStaticRequestTestTrait.php Github

copy

Full Screen

...106 public function testApplicationPath(): void107 {108 $this->prepare_request_test();109 $this->configuration->expects($this->atLeast(2))110 ->method('offsetGet')111 ->will($this->returnValueMap(array_values($this->mocked_calls)));112 $request = $this->class->parse_request();113 $this->assertIsArray($request);114 $this->assertArrayHasKey('application_path', $request);115 $this->assertEquals('/full/path/to/', $request['application_path']);116 $this->cleanup_request_test();117 }118 /**119 * Test that the base_path is constructed and stored correctly.120 */121 public function testRequestBasePath(): void122 {123 $this->prepare_request_test();124 $this->configuration->expects($this->atLeast(2))125 ->method('offsetGet')126 ->will($this->returnValueMap(array_values($this->mocked_calls)));127 $request = $this->class->parse_request();128 $this->assertIsArray($request);129 $this->assertArrayHasKey('base_path', $request);130 $this->assertEquals('/path/to/', $request['base_path']);131 $this->cleanup_request_test();132 }133 /**134 * Test that the domain is stored correctly.135 */136 public function testRequestDomain(): void137 {138 $this->prepare_request_test();139 $this->configuration->expects($this->atLeast(2))140 ->method('offsetGet')141 ->will($this->returnValueMap(array_values($this->mocked_calls)));142 $request = $this->class->parse_request();143 $this->assertIsArray($request);144 $this->assertArrayHasKey('domain', $request);145 $this->assertEquals('www.domain.com', $request['domain']);146 $this->cleanup_request_test();147 }148 /**149 * Test that the port is stored correctly.150 *151 * @param string $protocol Protocol name152 * @param string $port Expected port value153 *154 * @dataProvider baseurlProvider155 */156 public function testRequestPort($protocol, $port): void157 {158 $this->prepare_request_test($protocol, $port);159 $this->configuration->expects($this->atLeast(2))160 ->method('offsetGet')161 ->will($this->returnValueMap(array_values($this->mocked_calls)));162 $request = $this->class->parse_request();163 $this->assertIsArray($request);164 $this->assertArrayHasKey('port', $request);165 $this->assertEquals($port, $request['port']);166 $this->cleanup_request_test();167 }168 /**169 * Test that the protocol is constructed and stored correctly.170 *171 * @param string $protocol Protocol name172 * @param string $port Expected port value173 * @param string $baseurl The expected base_url value174 *175 * @dataProvider baseurlProvider176 */177 public function testRequestBaseUrl($protocol, $port, $baseurl): void178 {179 $this->prepare_request_test($protocol, $port);180 $this->configuration->expects($this->atLeast(2))181 ->method('offsetGet')182 ->will($this->returnValueMap(array_values($this->mocked_calls)));183 $request = $this->class->parse_request();184 $this->assertIsArray($request);185 $this->assertArrayHasKey('base_url', $request);186 $this->assertEquals($baseurl, $request['base_url']);187 $this->cleanup_request_test();188 }189 /**190 * Test that the useragent is stored correctly, when it is not present.191 */192 public function testRequestNoUserAgent(): void193 {194 $this->prepare_request_test();195 $request = $this->class->parse_request();196 $this->assertIsArray($request);197 $this->assertArrayHasKey('useragent', $request);198 $this->assertNull($request['useragent']);199 $this->cleanup_request_test();200 }201 /**202 * Test that the device useragent is stored correctly, when it is not present.203 */204 public function testRequestNoDeviceUserAgent(): void205 {206 $this->prepare_request_test();207 $request = $this->class->parse_request();208 $this->assertIsArray($request);209 $this->assertArrayHasKey('device_useragent', $request);210 $this->assertNull($request['device_useragent']);211 $this->cleanup_request_test();212 }213 /**214 * Test that the verbosity is stored correctly.215 */216 public function testRequestVerbosity(): void217 {218 $this->prepare_request_test('HTTP', '80', TRUE);219 $this->configuration->expects($this->exactly(8))220 ->method('offsetGet')221 ->will($this->returnValueMap(array_values($this->mocked_calls)));222 $request = $this->class->parse_request();223 $this->assertIsArray($request);224 $this->assertArrayHasKey('verbosity', $request);225 $this->assertEquals(LogLevel::WARNING, $request['verbosity']);226 $this->cleanup_request_test();227 }228 /**229 * Test that the default controller value is stored correctly.230 */231 public function testRequestDefaultController(): void232 {233 $this->prepare_request_test('HTTP', '80');234 $this->prepare_request_data();235 $this->configuration->expects($this->atLeast(2))236 ->method('offsetGet')237 ->will($this->returnValueMap(array_values($this->mocked_calls)));238 $request = $this->class->parse_request();239 $this->assertIsArray($request);240 $this->assertArrayHasKey('controller', $request);241 $this->assertEquals('DefaultController', $request['controller']);242 $this->cleanup_request_test();243 }244 /**245 * Test that the default method value is stored correctly.246 */247 public function testRequestDefaultMethod(): void248 {249 $this->prepare_request_test('HTTP', '80');250 $this->prepare_request_data();251 $this->configuration->expects($this->atLeast(2))252 ->method('offsetGet')253 ->will($this->returnValueMap(array_values($this->mocked_calls)));254 $request = $this->class->parse_request();255 $this->assertIsArray($request);256 $this->assertArrayHasKey('method', $request);257 $this->assertEquals('default_method', $request['method']);258 $this->cleanup_request_test();259 }260 /**261 * Test that the default params value is stored correctly.262 */263 public function testRequestDefaultParams(): void264 {265 $this->prepare_request_test('HTTP', '80');266 $this->prepare_request_data();267 $request = $this->class->parse_request();268 $this->assertIsArray($request);269 $this->assertArrayHasKey('params', $request);270 $this->assertArrayEmpty($request['params']);271 $this->cleanup_request_test();272 }273 /**274 * Test that the default call value is stored correctly.275 */276 public function testRequestDefaultCall(): void277 {278 $this->prepare_request_test('HTTP', '80');279 $this->prepare_request_data();280 $this->configuration->expects($this->atLeast(2))281 ->method('offsetGet')282 ->will($this->returnValueMap(array_values($this->mocked_calls)));283 $request = $this->class->parse_request();284 $this->assertIsArray($request);285 $this->assertArrayHasKey('call', $request);286 $this->assertEquals('DefaultController/default_method', $request['call']);287 $this->cleanup_request_test();288 }289 /**290 * Test that the default call value is stored correctly.291 */292 public function testRequestDefaultCallWithControllerUndefined(): void293 {294 $this->prepare_request_test('HTTP', '80');295 unset($this->mocked_calls['default_controller']);296 $this->configuration->expects($this->atLeast(2))297 ->method('offsetGet')298 ->will($this->returnValueMap(array_values($this->mocked_calls)));299 $request = $this->class->parse_request();300 $this->assertIsArray($request);301 $this->assertArrayHasKey('call', $request);302 $this->assertNull($request['call']);303 $this->cleanup_request_test();304 }305 /**306 * Test that the default call value is stored correctly.307 */308 public function testRequestDefaultCallWithMethodUndefined(): void309 {310 $this->prepare_request_test('HTTP', '80');311 unset($this->mocked_calls['default_method']);312 $this->configuration->expects($this->atLeast(2))313 ->method('offsetGet')314 ->will($this->returnValueMap(array_values($this->mocked_calls)));315 $request = $this->class->parse_request();316 $this->assertIsArray($request);317 $this->assertArrayHasKey('call', $request);318 $this->assertNull($request['call']);319 $this->cleanup_request_test();320 }321 /**322 * Test that a request ID is calculated.323 */324 public function testRequestId(): void325 {326 $this->prepare_request_test('HTTP', '80');327 $this->prepare_request_data(TRUE, FALSE);328 $this->configuration->expects($this->atLeast(2))329 ->method('offsetGet')330 ->will($this->returnValueMap(array_values($this->mocked_calls)));331 $request = $this->class->parse_request();332 $this->assertIsArray($request);333 $this->assertArrayHasKey('id', $request);334 $this->assertEquals('962161b27a0141f384c63834ad001adf', $request['id']);335 $this->cleanup_request_test();336 }337}338?>...

Full Screen

Full Screen

DoctrineDbalConnectionRegistryTest.php

Source:DoctrineDbalConnectionRegistryTest.php Github

copy

Full Screen

...19 public function testGetDefaultConnectionName(): void20 {21 /** @var Container|MockObject $container */22 $container = $this->getMockByCalls(Container::class, [23 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn($this->getMockByCalls(Container::class)),24 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default']),25 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),26 ]);27 $registry = new DoctrineDbalConnectionRegistry($container);28 self::assertSame('default', $registry->getDefaultConnectionName());29 }30 public function testGetConnection(): void31 {32 /** @var Connection|MockObject $connection */33 $connection = $this->getMockByCalls(Connection::class);34 /** @var Container|MockObject $container */35 $container = $this->getMockByCalls(Container::class, [36 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(37 $this->getMockByCalls(Container::class, [38 Call::create('offsetExists')->with('default')->willReturn(true),39 Call::create('offsetGet')->with('default')->willReturn($connection),40 ])41 ),42 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default']),43 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),44 ]);45 $registry = new DoctrineDbalConnectionRegistry($container);46 self::assertSame($connection, $registry->getConnection());47 }48 public function testGetConnectionByName(): void49 {50 /** @var Connection|MockObject $connection */51 $connection = $this->getMockByCalls(Connection::class);52 /** @var Container|MockObject $container */53 $container = $this->getMockByCalls(Container::class, [54 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(55 $this->getMockByCalls(Container::class, [56 Call::create('offsetExists')->with('somename')->willReturn(true),57 Call::create('offsetGet')->with('somename')->willReturn($connection),58 ])59 ),60 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default', 'somename']),61 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),62 ]);63 $registry = new DoctrineDbalConnectionRegistry($container);64 self::assertSame($connection, $registry->getConnection('somename'));65 }66 public function testGetMissingConnection(): void67 {68 $this->expectException(\InvalidArgumentException::class);69 $this->expectExceptionMessage('Missing connection with name "default".');70 /** @var Container|MockObject $container */71 $container = $this->getMockByCalls(Container::class, [72 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(73 $this->getMockByCalls(Container::class, [74 Call::create('offsetExists')->with('default')->willReturn(false),75 ])76 ),77 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn([]),78 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),79 ]);80 $registry = new DoctrineDbalConnectionRegistry($container);81 $registry->getConnection();82 }83 public function testGetConnections(): void84 {85 /** @var Connection|MockObject $connection1 */86 $connection1 = $this->getMockByCalls(Connection::class);87 /** @var Connection|MockObject $connection2 */88 $connection2 = $this->getMockByCalls(Connection::class);89 /** @var Container|MockObject $container */90 $container = $this->getMockByCalls(Container::class, [91 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(92 $this->getMockByCalls(Container::class, [93 Call::create('offsetGet')->with('default')->willReturn($connection1),94 Call::create('offsetGet')->with('somename')->willReturn($connection2),95 ])96 ),97 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default', 'somename']),98 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),99 ]);100 $registry = new DoctrineDbalConnectionRegistry($container);101 $connections = $registry->getConnections();102 self::assertIsArray($connections);103 self::assertCount(2, $connections);104 self::assertSame($connection1, $connections['default']);105 self::assertSame($connection2, $connections['somename']);106 }107 public function testGetConnectionNames(): void108 {109 /** @var Container|MockObject $container */110 $container = $this->getMockByCalls(Container::class, [111 Call::create('offsetGet')->with('doctrine.dbal.dbs')->willReturn(112 $this->getMockByCalls(Container::class)113 ),114 Call::create('offsetGet')->with('doctrine.dbal.dbs.name')->willReturn(['default']),115 Call::create('offsetGet')->with('doctrine.dbal.dbs.default')->willReturn('default'),116 ]);117 $registry = new DoctrineDbalConnectionRegistry($container);118 self::assertSame(['default'], $registry->getConnectionNames());119 }120}...

Full Screen

Full Screen

offsetGet

Using AI Code Generation

copy

Full Screen

1require_once('calls.php');2$call = new calls();3echo $call->offsetGet('name');4require_once('calls.php');5$call = new calls();6echo $call->offsetGet('name');7require_once('calls.php');8$call = new calls();9echo $call->offsetGet('name');10require_once('calls.php');11$call = new calls();12echo $call->offsetGet('name');13require_once('calls.php');14$call = new calls();15echo $call->offsetGet('name');16require_once('calls.php');17$call = new calls();18echo $call->offsetGet('name');19require_once('calls.php');20$call = new calls();21echo $call->offsetGet('name');22require_once('calls.php');23$call = new calls();24echo $call->offsetGet('name');25require_once('calls.php');26$call = new calls();27echo $call->offsetGet('name');28require_once('calls.php');29$call = new calls();30echo $call->offsetGet('name');31require_once('calls.php');32$call = new calls();33echo $call->offsetGet('name');34require_once('calls.php');35$call = new calls();36echo $call->offsetGet('name');37require_once('calls.php');38$call = new calls();39echo $call->offsetGet('name');

Full Screen

Full Screen

offsetGet

Using AI Code Generation

copy

Full Screen

1$call = new calls();2echo $call->offsetGet('a');3$call->offsetSet('a', 10);4echo $call->offsetGet('a');5$call->offsetUnset('a');6echo $call->offsetGet('a');7var_dump($call->offsetExists('a'));8echo count($call);

Full Screen

Full Screen

offsetGet

Using AI Code Generation

copy

Full Screen

1$call = new calls();2$call = new calls();3$call = new calls();4$call = new calls();5$call = new calls();6$call = new calls();7$call = new calls();8$call = new calls();9$call = new calls();10$call = new calls();11$call = new calls();12$call = new calls();

Full Screen

Full Screen

offsetGet

Using AI Code Generation

copy

Full Screen

1$call = new calls();2echo $call->offsetGet('path');3if($call->offsetExists('path'))4{5 echo 'offset exists';6}7$call->offsetSet('path','2.php');8echo $call->offsetGet('path');9$call->offsetUnset('path');10echo $call->offsetGet('path');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful