$value) { $this->buildTestee()[0]->shouldReceive('has') ->with(Matchers::identicalTo($key)) ->andReturn(true); $this->buildTestee()[0]->shouldReceive('get') ->with(Matchers::identicalTo($key)) ->andReturn($value); } expect('get_user_locale') ->andReturn($userLocale); /* @var ApplicationContextRepository $testee */ $testee = $this->buildTestee()[1]; $context = $testee->currentContext(); self::assertInstanceOf( ApplicationContext::class, $context ); foreach ($expected as $method => $value) { self::assertSame( $value, $context->{$method}(), "Test failed for method {$method}" ); } } /** * @see testCurrentContext */ public function currentContextData(): array { return [ 'default test' => [ 'container' => [ 'brand_name' => 'Acme corp.', 'landing_page' => ApplicationContext::LANDING_PAGE_BILLING, ], 'user_locale' => 'de_DE', 'expected' => [ 'locale' => 'de-DE', 'brandName' => 'Acme corp.', 'landingPage' => ApplicationContext::LANDING_PAGE_BILLING, ], ], ]; } public function tearDown(): void { self::$mocks = []; parent::tearDown(); } /** * @return MockInterface[] */ private function buildTestee(): array { if (! self::$mocks) { $config = \Mockery::mock(ContainerInterface::class); $testee = new ApplicationContextRepository($config); self::$mocks = [ $config, $testee, ]; } return self::$mocks; } }