/**
  * {@inheritdoc}
  */
 public function create()
 {
     /** @var TenantInterface $tenant */
     $tenant = $this->decoratedFactory->create();
     $tenant->setCode($this->generator->generate(6));
     return $tenant;
 }
 public function it_creates_a_new_organization_with_code(FactoryInterface $factory, GeneratorInterface $generator, OrganizationInterface $organization)
 {
     $factory->create()->willReturn($organization);
     $generator->generate(6)->willReturn('123456');
     $organization->setCode('123456')->shouldBeCalled();
     $this->createWithCode()->shouldReturn($organization);
 }
 /**
  * {@inheritdoc}
  */
 public function createWithCode()
 {
     /** @var OrganizationInterface $organization */
     $organization = $this->create();
     $organization->setCode($this->generator->generate(6));
     return $organization;
 }
 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']);
 }