public function it_throws_an_exception(FactoryInterface $factory, GeneratorInterface $generator, TenantInterface $tenant, OrganizationInterface $organization, OrganizationRepositoryInterface $organizationRepository)
 {
     $organizationRepository->findOneByCode('123456')->willReturn(null);
     $factory->create()->shouldNotBeCalled();
     $generator->generate(6)->shouldNotBeCalled();
     $tenant->setCode('123456')->shouldNotBeCalled();
     $tenant->setOrganization($organization)->shouldNotBeCalled();
     $this->shouldThrow(\InvalidArgumentException::class)->during('createForOrganization', ['123456']);
 }
 private function assignDefaultOrganization(TenantInterface $tenant)
 {
     if (null === $tenant->getOrganization()) {
         $organization = $this->get('swp.repository.organization')->findOneByName(OrganizationInterface::DEFAULT_NAME);
         if (null === $organization) {
             throw $this->createNotFoundException('Default organization was not found.');
         }
         $tenant->setOrganization($organization);
     }
     return $tenant;
 }