Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
85.71% |
6 / 7 |
CRAP | |
91.67% |
44 / 48 |
DigitalV2Faker | |
0.00% |
0 / 1 |
|
85.71% |
6 / 7 |
16.15 | |
91.67% |
44 / 48 |
createSite | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
updateSite | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
createSponsorWebservice | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
createOfferPlanning | |
100.00% |
1 / 1 |
1 | |
100.00% |
4 / 4 |
|||
getSiteResponse | |
100.00% |
1 / 1 |
9 | |
100.00% |
35 / 35 |
|||
getExternalUsers | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
getBlackListProfils | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
1 | <?php |
2 | |
3 | namespace Qmp\Laravel\ApiDigitalV2\Api; |
4 | |
5 | |
6 | use Illuminate\Support\Facades\Log; |
7 | use Qmp\Laravel\ApiDigitalV2\Api\DigitalV2AbstractProvider; |
8 | use Qmp\Laravel\SiteGeneratorDetail\Models\Site; |
9 | |
10 | /** |
11 | * Class DigitalV2Faker |
12 | * @package Qmp\Laravel\ApiDigitalV2\Api |
13 | */ |
14 | class DigitalV2Faker extends DigitalV2AbstractProvider |
15 | { |
16 | /** |
17 | * fake site digitalv2 |
18 | * |
19 | * @param Site $site |
20 | * @return array |
21 | */ |
22 | public function createSite(Site $site) |
23 | { |
24 | return $this->getSiteResponse($site); |
25 | } |
26 | |
27 | /** |
28 | * fake site digitalv2 |
29 | * |
30 | * @param Site $site |
31 | * @return array |
32 | */ |
33 | public function updateSite(Site $site) |
34 | { |
35 | return $this->getSiteResponse($site); |
36 | } |
37 | |
38 | /** |
39 | * Fake webservice |
40 | * @param $id |
41 | * @param $id_offer |
42 | * @return array |
43 | */ |
44 | public function createSponsorWebservice($id, $id_offer) |
45 | { |
46 | return [ |
47 | 'id' => $id_offer, |
48 | 'ws' => 'https://datas.coreg-feed.com/pxv/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?lastname=[LASTNAME]&firstname=[FIRSTNAME]&zipcode=[ZIPCODE]&email=[EMAIL]&city=[CITY]&phone=[PHONE]&address=[ADDRESS]&title=[TITLE]&birthdate=[BIRTHDATE]' |
49 | ]; |
50 | } |
51 | |
52 | /** |
53 | * Fake planning |
54 | * @param $id |
55 | * @param $blockId |
56 | * @return array |
57 | */ |
58 | public function createOfferPlanning($id, $blockId) |
59 | { |
60 | return [ |
61 | 'id' => $id, |
62 | 'id_planning' => strval(rand(57600, 57650)), |
63 | 'url' => 'https://www.google.fr?email=[EMAIL]&lastname=[LASTNAME]&firstname=[FIRSTNAME]&zipcode=[ZIPCODE]&city=[CITY]&phone=[PHONE]&address=[ADDRESS]&title=[TITLE]&birthdate=[BIRTHDATE]', |
64 | 'img' => 'https://via.placeholder.com/300x250', |
65 | ]; |
66 | } |
67 | |
68 | /** |
69 | * fake site digitalv2 |
70 | * |
71 | * @param Site $site |
72 | * @return array |
73 | */ |
74 | private function getSiteResponse(Site $site) |
75 | { |
76 | $response = []; |
77 | |
78 | $response['id'] = 3190; |
79 | $response['name'] = $site->text; |
80 | $response['containers'] = []; |
81 | |
82 | $id = 4000; |
83 | foreach ($site->blocks as $block) { |
84 | |
85 | if ($block['value'] === 2 || ($block['value'] === 0 && $block['source'] === 0)) { |
86 | $type = $block['value'] === 2 ? 3 : 0; |
87 | $params = $type === 0 ? '?civilite=[TITLE]&nom=[LASTNAME]&prenom=[FIRSTNAME]&email=[EMAIL]&date_naissance=[BIRTHDATE]&adresse=[ADDRESS]&ville=[CITY]&codepostal=[ZIPCODE]&telephone=[PHONE]' : ''; |
88 | $response['containers'][] = [ |
89 | 'id' => $id++, |
90 | 'routeId' => $block['routeId'], |
91 | 'pageId' => $block['pageId'], |
92 | 'blockId' => $block['id'], |
93 | 'name' => $block['name'], |
94 | 'type' => $type, |
95 | 'tag' => 'https://stats.coreg-feed.com/frmvw/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' . $params |
96 | ]; |
97 | } |
98 | } |
99 | |
100 | $response['webservices'] = []; |
101 | |
102 | $offers = array_column($site->dotGet('config.sponsorsList'), 'id'); |
103 | |
104 | foreach ($offers as $offer) { |
105 | $response['webservices'][] = [ |
106 | 'id_offer' => $offer, |
107 | 'ws' => 'https://datas.coreg-feed.com/pxv/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?lastname=[LASTNAME]&firstname=[FIRSTNAME]&zipcode=[ZIPCODE]&email=[EMAIL]&city=[CITY]&phone=[PHONE]&address=[ADDRESS]&title=[TITLE]&birthdate=[BIRTHDATE]' |
108 | ]; |
109 | } |
110 | |
111 | $response['visuals'] = []; |
112 | $planning = 57600; |
113 | foreach ($site->offers as $visual) { |
114 | $response['visuals'][] = [ |
115 | 'routeId' => $visual['routeId'], |
116 | 'pageId' => $visual['pageId'], |
117 | 'blockId' => $visual['blockId'], |
118 | 'id' => $visual['id'], |
119 | 'url' => 'https://www.google.fr?email=[EMAIL]&lastname=[LASTNAME]&firstname=[FIRSTNAME]&zipcode=[ZIPCODE]&city=[CITY]&phone=[PHONE]&address=[ADDRESS]&title=[TITLE]&birthdate=[BIRTHDATE]', |
120 | 'img' => 'https://via.placeholder.com/300x250', |
121 | 'id_planning' => strval($planning++) |
122 | ]; |
123 | } |
124 | |
125 | return $response; |
126 | } |
127 | |
128 | public function getExternalUsers() |
129 | { |
130 | return [ |
131 | [ |
132 | 'id' => 14, |
133 | 'name' => 'Sarabia', |
134 | 'firstname' => 'David', |
135 | 'email' => 'specqueur@advertise-me.net ', |
136 | 'id_company' => 76, |
137 | 'company_name' => '2-30 Media Sarl', |
138 | 'sites' => [ |
139 | ['id' => 39, 'name' => 'Tous-Testeurs', 'url' => 'www.tous-testeurs.com'], |
140 | ['id' => 49, 'name' => 'Testclub.com', 'url' => 'http://www.testclub.com'], |
141 | ['id' => 569, 'name' => 'GreenConso', 'url' => 'http://www.greenconso.com/'], |
142 | ['id' => 570, 'name' => 'Test Club IT', 'url' => 'http://www.testclub.com/it/'], |
143 | ['id' => 1900, 'name' => 'je-teste.fr', 'url' => 'http://www.je-teste.fr'], |
144 | ['id' => 2312, 'name' => 'Crazy tests', 'url' => 'crazy-tests.com'], |
145 | ['id' => 2864, 'name' => 'Le Club des jeux', 'url' => 'testclub.fr'], |
146 | ['id' => 2867, 'name' => 'je-teste.be', 'url' => 'je-teste.be'] |
147 | ] |
148 | ], |
149 | [ |
150 | 'id' => 15, |
151 | 'name' => 'Beaunier', |
152 | 'firstname' => 'Florian', |
153 | 'email' => 'specqueur@advertise-me.net ', |
154 | 'id_company' => 73, |
155 | 'company_name' => 'RIVERLINE SAS', |
156 | 'sites' => [ |
157 | ['id' => 33, 'name' => 'Optin Collect', 'url' => 'optin-collect.fr'] |
158 | ] |
159 | ] |
160 | ]; |
161 | } |
162 | |
163 | /** |
164 | * fake blacklist profil digitalv2 |
165 | * |
166 | * @return array |
167 | */ |
168 | public function getBlackListProfils() |
169 | { |
170 | $emails = []; |
171 | |
172 | for($i=1; $i <= 10; $i++) { |
173 | $emails[] = 'blacklist'.$i.'@advertise-me.net'; |
174 | } |
175 | |
176 | return $emails; |
177 | } |
178 | } |