1+ <?php
2+
3+ namespace Gcd \Cyclops \Tests \unit \UseCases ;
4+
5+ use Codeception \Stub ;
6+ use Gcd \Cyclops \Entities \CustomerEntity ;
7+ use Gcd \Cyclops \Entities \CyclopsIdentityEntity ;
8+ use Gcd \Cyclops \Services \CyclopsService ;
9+ use Gcd \Cyclops \Tests \unit \CyclopsTestCase ;
10+ use Gcd \Cyclops \UseCases \DeleteCustomerUseCase ;
11+ use Gcd \Cyclops \UseCases \GetBrandOptInUseCase ;
12+
13+ class DeleteCustomerUseCaseTest extends CyclopsTestCase
14+ {
15+ public function testCustomerDeleted ()
16+ {
17+ $ count = 0 ;
18+ $ service = Stub::make (CyclopsService::class, [
19+ 'createCustomer ' => function (CyclopsIdentityEntity $ identityEntity ) use (&$ count ): CustomerEntity {
20+ $ identityEntity ->id = $ count ++;
21+ $ customer = new CustomerEntity ();
22+ $ customer ->identity = $ identityEntity ;
23+ return $ customer ;
24+ },
25+ 'loadCustomer ' => function (CyclopsIdentityEntity $ identityEntity ) use (&$ count ): CustomerEntity {
26+ $ customer = new CustomerEntity ();
27+ $ customer ->identity = $ identityEntity ;
28+ return $ customer ;
29+ },
30+ 'getBrandOptInStatus ' => function (CustomerEntity $ customerEntity ): bool {
31+ return false ;
32+ },
33+ 'deleteCustomer ' => function (CyclopsIdentityEntity $ identityEntity ): bool {
34+ return true ;
35+ },
36+ ]);
37+
38+ $ id = new CyclopsIdentityEntity ();
39+ $ id ->email = "test@test.com " ;
40+
41+ $ useCase = new GetBrandOptInUseCase ($ service );
42+ $ response = $ useCase ->execute ($ id );
43+ verify ($ response ->identity ->id )->notNull ();
44+
45+ $ deleteUseCase = new DeleteCustomerUseCase ($ service );
46+ $ deleteUseCase ->execute ($ response ->identity );
47+
48+ $ response2 = $ useCase ->execute ($ id );
49+ verify ($ response2 ->identity ->id )->notNull ();
50+ verify ($ response2 ->identity ->id )->notSame ($ response ->identity ->id );
51+ }
52+ }
0 commit comments