@@ 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, |
@@ 100-118 (lines=19) @@ | ||
97 | $this->prePersist($event); |
|
98 | } |
|
99 | ||
100 | public function it_throws_exception_when_no_organization_on_pre_persist_doctrine_event( |
|
101 | TenantContextInterface $tenantContext, |
|
102 | LifecycleEventArgs $event, |
|
103 | OrganizationAwareInterface $organizationAware, |
|
104 | ContainerInterface $container |
|
105 | ) { |
|
106 | $tenant = new Tenant(); |
|
107 | $tenant->setDomainName('example.com'); |
|
108 | $tenant->setName('Example'); |
|
109 | $tenant->setCode('avc2334'); |
|
110 | ||
111 | $organizationAware->getOrganization()->shouldBeCalled()->willReturn(null); |
|
112 | $event->getEntity()->willReturn($organizationAware); |
|
113 | $tenantContext->getTenant()->shouldBeCalled()->willReturn($tenant); |
|
114 | $container->get('swp_multi_tenancy.tenant_context')->willReturn($tenantContext); |
|
115 | ||
116 | $this->shouldThrow(UnexpectedTypeException::class) |
|
117 | ->duringAddOrganization($event); |
|
118 | } |
|
119 | ||
120 | public function it_sets_only_organization_aware_interface_implementation_on_pre_presist( |
|
121 | OrganizationAwareInterface $organizationAware, |