public function testRequiredLocales() { $locale = $this->createLocaleMock(); $locale->expects($this->once())->method('getCode')->will($this->returnValue($code = 'fr')); $this->localeProvider->expects($this->once())->method('getRequiredLocales')->will($this->returnValue([$locale])); $this->assertSame([$code], $this->a2lixLocaleProvider->getRequiredLocales()); }
public function testValidateNotDefaultLocale() { $this->localeProvider->expects($this->once())->method('getDefaultLocale')->will($this->returnValue($this->createLocaleMock())); $domainEvent = $this->createDomainEventMock(); $domainEvent->expects($this->once())->method('getData')->will($this->returnValue($this->createLocaleMock())); $domainEvent->expects($this->never())->method('setStopped'); $domainEvent->expects($this->never())->method('setStatusCode'); $domainEvent->expects($this->never())->method('setMessageType'); $domainEvent->expects($this->never())->method('setMessage'); $this->localeDomainSubscriber->validateDefaultLocale($domainEvent); }
public function testValidateWithLastLocaleNotRequired() { $locale = $this->createLocaleMock(); $locale->expects($this->exactly(2))->method('isEnabled')->will($this->returnValue(true)); $locale->expects($this->exactly(2))->method('isRequired')->will($this->returnValue(false)); $this->localeProvider->expects($this->once())->method('getDefaultLocale')->will($this->returnValue($this->createLocaleMock())); $this->localeProvider->expects($this->once())->method('getRequiredLocales')->will($this->returnValue([$locale])); $errors = $this->validator->validate($locale); $this->assertCount(1, $errors); $this->assertArrayHasKey(0, $errors); $this->assertSame('required', $errors[0]->getPropertyPath()); $this->assertSame('The locale is the last required. You can\'t make it optional.', $errors[0]->getMessage()); }
public function testSubmitDefaultLocale() { $this->localeProvider->expects($this->once())->method('getDefaultLocale')->will($this->returnValue($defaultLocale = $this->createLocaleMock())); $defaultLocale->expects($this->exactly(2))->method('getCode')->will($this->returnValue($defaultLocaleCode = 'fr')); $defaultLocale->expects($this->never())->method('setCode'); $defaultLocale->expects($this->never())->method('setEnabled'); $defaultLocale->expects($this->never())->method('setRequired'); $this->resource->expects($this->once())->method('getModel')->will($this->returnValue(get_class($defaultLocale))); $this->repository->expects($this->once())->method('findAll')->will($this->returnValue([$defaultLocale])); $form = $this->formFactory->create(LocaleType::class, $defaultLocale)->submit(['code' => 'USD', 'enabled' => false, 'required' => false]); $view = $form->createView(); $this->assertCount(4, $view->children); $this->assertArrayHasKey('code', $view->children); $this->assertArrayHasKey('enabled', $view->children); $this->assertArrayHasKey('required', $view->children); $this->assertArrayHasKey('submit', $view->children); $this->assertArrayHasKey('disabled', $view->children['code']->vars); $this->assertTrue($view->children['code']->vars['disabled']); $this->assertArrayHasKey('disabled', $view->children['enabled']->vars); $this->assertTrue($view->children['enabled']->vars['disabled']); $this->assertArrayHasKey('disabled', $view->children['required']->vars); $this->assertTrue($view->children['required']->vars['disabled']); }
public function testLocalesWithoutRequest() { $this->localeProvider->expects($this->once())->method('getDefaultLocale')->will($this->returnValue($locale = $this->createLocaleMock())); $locale->expects($this->once())->method('getCode')->will($this->returnValue($code = 'en')); $this->assertSame([$code], $this->localeContext->getLocales()); }