| @@ 68-88 (lines=21) @@ | ||
| 65 | $this->prePersist($event)->shouldReturn(null); |
|
| 66 | } |
|
| 67 | ||
| 68 | public function it_sets_the_tenant_code_on_pre_persist_doctrine_event( |
|
| 69 | TenantContextInterface $tenantContext, |
|
| 70 | LifecycleEventArgs $event, |
|
| 71 | TenantAwareInterface $tenantAware, |
|
| 72 | ContainerInterface $container |
|
| 73 | ) { |
|
| 74 | $tenant = new Tenant(); |
|
| 75 | $tenant->setSubdomain('example.com'); |
|
| 76 | $tenant->setName('Example'); |
|
| 77 | $tenant->setCode('123456'); |
|
| 78 | ||
| 79 | $tenantAware->getTenantCode()->shouldBeCalled()->willReturn(null); |
|
| 80 | $event->getEntity()->willReturn($tenantAware); |
|
| 81 | $tenantContext->getTenant()->shouldBeCalled()->willReturn($tenant); |
|
| 82 | ||
| 83 | $tenantAware->setTenantCode('123456')->shouldBeCalled(); |
|
| 84 | ||
| 85 | $container->get('swp_multi_tenancy.tenant_context')->willReturn($tenantContext); |
|
| 86 | ||
| 87 | $this->prePersist($event)->shouldBeNull(); |
|
| 88 | } |
|
| 89 | ||
| 90 | public function it_sets_only_tenant_aware_interface_implementation_on_pre_presist( |
|
| 91 | TenantAwareInterface $tenantAware, |
|
| @@ 118-136 (lines=19) @@ | ||
| 115 | $this->preUpdate($event); |
|
| 116 | } |
|
| 117 | ||
| 118 | public function it_throws_exception_when_no_organization_on_pre_persist_doctrine_event( |
|
| 119 | TenantContextInterface $tenantContext, |
|
| 120 | LifecycleEventArgs $event, |
|
| 121 | OrganizationAwareInterface $organizationAware, |
|
| 122 | ContainerInterface $container |
|
| 123 | ) { |
|
| 124 | $tenant = new Tenant(); |
|
| 125 | $tenant->setDomainName('example.com'); |
|
| 126 | $tenant->setName('Example'); |
|
| 127 | $tenant->setCode('avc2334'); |
|
| 128 | ||
| 129 | $organizationAware->getOrganization()->shouldBeCalled()->willReturn(null); |
|
| 130 | $event->getEntity()->willReturn($organizationAware); |
|
| 131 | $tenantContext->getTenant()->shouldBeCalled()->willReturn($tenant); |
|
| 132 | $container->get('swp_multi_tenancy.tenant_context')->willReturn($tenantContext); |
|
| 133 | ||
| 134 | $this->shouldThrow(UnexpectedTypeException::class) |
|
| 135 | ->duringAddOrganization($event); |
|
| 136 | } |
|
| 137 | ||
| 138 | public function it_sets_only_organization_aware_interface_implementation_on_pre_presist( |
|
| 139 | OrganizationAwareInterface $organizationAware, |
|