1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the SectionServiceTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\API\Repository\Tests; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Exceptions\NotFoundException; |
12
|
|
|
use eZ\Publish\API\Repository\Values\Content\Section; |
13
|
|
|
use Exception; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Test case for operations in the SectionService using in memory storage. |
17
|
|
|
* |
18
|
|
|
* @see eZ\Publish\API\Repository\SectionService |
19
|
|
|
* @group integration |
20
|
|
|
* @group section |
21
|
|
|
*/ |
22
|
|
|
class SectionServiceTest extends BaseTest |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Tests that the required <b>ContentService::loadContentInfoByRemoteId()</b> |
26
|
|
|
* at least returns an object, because this method is utilized in several |
27
|
|
|
* tests,. |
28
|
|
|
*/ |
29
|
|
|
protected function setUp() |
30
|
|
|
{ |
31
|
|
|
parent::setUp(); |
32
|
|
|
|
33
|
|
|
try { |
34
|
|
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
35
|
|
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
36
|
|
|
|
37
|
|
|
// Load the ContentService |
38
|
|
|
$contentService = $this->getRepository()->getContentService(); |
39
|
|
|
|
40
|
|
|
// Load a content info instance |
41
|
|
|
$contentInfo = $contentService->loadContentInfoByRemoteId( |
42
|
|
|
$mediaRemoteId |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
if (false === is_object($contentInfo)) { |
46
|
|
|
$this->markTestSkipped( |
47
|
|
|
'This test cannot be executed, because the utilized ' . |
48
|
|
|
'ContentService::loadContentInfoByRemoteId() does not ' . |
49
|
|
|
'return an object.' |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
} catch (Exception $e) { |
53
|
|
|
$this->markTestSkipped( |
54
|
|
|
'This test cannot be executed, because the utilized ' . |
55
|
|
|
'ContentService::loadContentInfoByRemoteId() failed with ' . |
56
|
|
|
PHP_EOL . PHP_EOL . |
57
|
|
|
$e |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Test for the newSectionCreateStruct() method. |
64
|
|
|
* |
65
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::newSectionCreateStruct() |
66
|
|
|
*/ |
67
|
|
|
public function testNewSectionCreateStruct() |
68
|
|
|
{ |
69
|
|
|
$repository = $this->getRepository(); |
70
|
|
|
|
71
|
|
|
/* BEGIN: Use Case */ |
72
|
|
|
$sectionService = $repository->getSectionService(); |
73
|
|
|
|
74
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
75
|
|
|
/* END: Use Case */ |
76
|
|
|
|
77
|
|
|
$this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\SectionCreateStruct', $sectionCreate); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Test for the createSection() method. |
82
|
|
|
* |
83
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::createSection() |
84
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testNewSectionCreateStruct |
85
|
|
|
*/ |
86
|
|
|
public function testCreateSection() |
87
|
|
|
{ |
88
|
|
|
$repository = $this->getRepository(); |
89
|
|
|
|
90
|
|
|
/* BEGIN: Use Case */ |
91
|
|
|
$sectionService = $repository->getSectionService(); |
92
|
|
|
|
93
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
94
|
|
|
$sectionCreate->name = 'Test Section'; |
95
|
|
|
$sectionCreate->identifier = 'uniqueKey'; |
96
|
|
|
|
97
|
|
|
$section = $sectionService->createSection($sectionCreate); |
98
|
|
|
/* END: Use Case */ |
99
|
|
|
|
100
|
|
|
$this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\Section', $section); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Test for the createSection() method. |
105
|
|
|
* |
106
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::createSection() |
107
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
108
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
109
|
|
|
*/ |
110
|
|
|
public function testCreateSectionThrowsInvalidArgumentException() |
111
|
|
|
{ |
112
|
|
|
$repository = $this->getRepository(); |
113
|
|
|
|
114
|
|
|
/* BEGIN: Use Case */ |
115
|
|
|
$sectionService = $repository->getSectionService(); |
116
|
|
|
|
117
|
|
|
$sectionCreateOne = $sectionService->newSectionCreateStruct(); |
118
|
|
|
$sectionCreateOne->name = 'Test section one'; |
119
|
|
|
$sectionCreateOne->identifier = 'uniqueKey'; |
120
|
|
|
|
121
|
|
|
$sectionService->createSection($sectionCreateOne); |
122
|
|
|
|
123
|
|
|
$sectionCreateTwo = $sectionService->newSectionCreateStruct(); |
124
|
|
|
$sectionCreateTwo->name = 'Test section two'; |
125
|
|
|
$sectionCreateTwo->identifier = 'uniqueKey'; |
126
|
|
|
|
127
|
|
|
// This will fail, because identifier uniqueKey already exists. |
128
|
|
|
$sectionService->createSection($sectionCreateTwo); |
129
|
|
|
/* END: Use Case */ |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Test for the loadSection() method. |
134
|
|
|
* |
135
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::loadSection() |
136
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
137
|
|
|
*/ |
138
|
|
|
public function testLoadSection() |
139
|
|
|
{ |
140
|
|
|
$repository = $this->getRepository(); |
141
|
|
|
|
142
|
|
|
$sectionId = $this->generateId('section', 2); |
143
|
|
|
/* BEGIN: Use Case */ |
144
|
|
|
$sectionService = $repository->getSectionService(); |
145
|
|
|
|
146
|
|
|
// Loads user section |
147
|
|
|
// $sectionId contains the corresponding ID |
148
|
|
|
$section = $sectionService->loadSection($sectionId); |
149
|
|
|
/* END: Use Case */ |
150
|
|
|
|
151
|
|
|
$this->assertEquals('users', $section->identifier); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Test for the loadSection() method. |
156
|
|
|
* |
157
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::loadSection() |
158
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
159
|
|
|
*/ |
160
|
|
|
public function testLoadSectionThrowsNotFoundException() |
161
|
|
|
{ |
162
|
|
|
$repository = $this->getRepository(); |
163
|
|
|
|
164
|
|
|
$nonExistentSectionId = $this->generateId('section', self::DB_INT_MAX); |
165
|
|
|
/* BEGIN: Use Case */ |
166
|
|
|
$sectionService = $repository->getSectionService(); |
167
|
|
|
|
168
|
|
|
// This call should fail with a NotFoundException |
169
|
|
|
// $nonExistentSectionId contains a section ID that is not known |
170
|
|
|
$sectionService->loadSection($nonExistentSectionId); |
171
|
|
|
/* END: Use Case */ |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Test for the newSectionUpdateStruct() method. |
176
|
|
|
* |
177
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::newSectionUpdateStruct() |
178
|
|
|
*/ |
179
|
|
|
public function testNewSectionUpdateStruct() |
180
|
|
|
{ |
181
|
|
|
$repository = $this->getRepository(); |
182
|
|
|
|
183
|
|
|
/* BEGIN: Use Case */ |
184
|
|
|
$sectionService = $repository->getSectionService(); |
185
|
|
|
|
186
|
|
|
$sectionUpdate = $sectionService->newSectionUpdateStruct(); |
187
|
|
|
/* END: Use Case */ |
188
|
|
|
|
189
|
|
|
$this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\SectionUpdateStruct', $sectionUpdate); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Test for the updateSection() method. |
194
|
|
|
* |
195
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::updateSection() |
196
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
197
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSection |
198
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testNewSectionUpdateStruct |
199
|
|
|
*/ |
200
|
|
View Code Duplication |
public function testUpdateSection() |
201
|
|
|
{ |
202
|
|
|
$repository = $this->getRepository(); |
203
|
|
|
|
204
|
|
|
$standardSectionId = $this->generateId('section', 1); |
205
|
|
|
/* BEGIN: Use Case */ |
206
|
|
|
// $standardSectionId contains the ID of the "Standard" section in a eZ |
207
|
|
|
// Publish demo installation. |
208
|
|
|
|
209
|
|
|
$sectionService = $repository->getSectionService(); |
210
|
|
|
|
211
|
|
|
$section = $sectionService->loadSection($standardSectionId); |
212
|
|
|
|
213
|
|
|
$sectionUpdate = $sectionService->newSectionUpdateStruct(); |
214
|
|
|
$sectionUpdate->name = 'New section name'; |
215
|
|
|
$sectionUpdate->identifier = 'newUniqueKey'; |
216
|
|
|
|
217
|
|
|
$updatedSection = $sectionService->updateSection($section, $sectionUpdate); |
218
|
|
|
/* END: Use Case */ |
219
|
|
|
|
220
|
|
|
// Verify that service returns an instance of Section |
221
|
|
|
$this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\Section', $updatedSection); |
222
|
|
|
|
223
|
|
|
// Verify that the service also persists the changes |
224
|
|
|
$updatedSection = $sectionService->loadSection($standardSectionId); |
225
|
|
|
|
226
|
|
|
$this->assertEquals('New section name', $updatedSection->name); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* Test for the updateSection() method. |
231
|
|
|
* |
232
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::updateSection() |
233
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testUpdateSection |
234
|
|
|
*/ |
235
|
|
|
public function testUpdateSectionKeepsSectionIdentifierOnNameUpdate() |
236
|
|
|
{ |
237
|
|
|
$repository = $this->getRepository(); |
238
|
|
|
|
239
|
|
|
$standardSectionId = $this->generateId('section', 1); |
240
|
|
|
/* BEGIN: Use Case */ |
241
|
|
|
// $standardSectionId contains the ID of the "Standard" section in a eZ |
242
|
|
|
// Publish demo installation. |
243
|
|
|
|
244
|
|
|
$sectionService = $repository->getSectionService(); |
245
|
|
|
|
246
|
|
|
$section = $sectionService->loadSection($standardSectionId); |
247
|
|
|
$sectionUpdate = $sectionService->newSectionUpdateStruct(); |
248
|
|
|
$sectionUpdate->name = 'New section name'; |
249
|
|
|
|
250
|
|
|
$updatedSection = $sectionService->updateSection($section, $sectionUpdate); |
251
|
|
|
/* END: Use Case */ |
252
|
|
|
|
253
|
|
|
$this->assertEquals('standard', $updatedSection->identifier); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Test for the updateSection() method. |
258
|
|
|
* |
259
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::updateSection() |
260
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testUpdateSection |
261
|
|
|
*/ |
262
|
|
View Code Duplication |
public function testUpdateSectionWithSectionIdentifierOnNameUpdate() |
263
|
|
|
{ |
264
|
|
|
$repository = $this->getRepository(); |
265
|
|
|
|
266
|
|
|
$standardSectionId = $this->generateId('section', 1); |
267
|
|
|
/* BEGIN: Use Case */ |
268
|
|
|
// $standardSectionId contains the ID of the "Standard" section in a eZ |
269
|
|
|
// Publish demo installation. |
270
|
|
|
|
271
|
|
|
$sectionService = $repository->getSectionService(); |
272
|
|
|
|
273
|
|
|
$section = $sectionService->loadSection($standardSectionId); |
274
|
|
|
$sectionUpdate = $sectionService->newSectionUpdateStruct(); |
275
|
|
|
$sectionUpdate->name = 'New section name'; |
276
|
|
|
|
277
|
|
|
// section identifier remains the same |
278
|
|
|
$sectionUpdate->identifier = $section->identifier; |
279
|
|
|
|
280
|
|
|
$updatedSection = $sectionService->updateSection($section, $sectionUpdate); |
281
|
|
|
/* END: Use Case */ |
282
|
|
|
|
283
|
|
|
$this->assertEquals('standard', $updatedSection->identifier); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* Test for the updateSection() method. |
288
|
|
|
* |
289
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::updateSection() |
290
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testUpdateSection |
291
|
|
|
*/ |
292
|
|
|
public function testUpdateSectionKeepsSectionNameOnIdentifierUpdate() |
293
|
|
|
{ |
294
|
|
|
$repository = $this->getRepository(); |
295
|
|
|
|
296
|
|
|
$standardSectionId = $this->generateId('section', 1); |
297
|
|
|
/* BEGIN: Use Case */ |
298
|
|
|
// $standardSectionId contains the ID of the "Standard" section in a eZ |
299
|
|
|
// Publish demo installation. |
300
|
|
|
|
301
|
|
|
$sectionService = $repository->getSectionService(); |
302
|
|
|
|
303
|
|
|
$section = $sectionService->loadSection($standardSectionId); |
304
|
|
|
|
305
|
|
|
$sectionUpdate = $sectionService->newSectionUpdateStruct(); |
306
|
|
|
$sectionUpdate->identifier = 'newUniqueKey'; |
307
|
|
|
|
308
|
|
|
$updatedSection = $sectionService->updateSection($section, $sectionUpdate); |
309
|
|
|
/* END: Use Case */ |
310
|
|
|
|
311
|
|
|
$this->assertEquals('Standard', $updatedSection->name); |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* Test for the updateSection() method. |
316
|
|
|
* |
317
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::updateSection() |
318
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
319
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testUpdateSection |
320
|
|
|
*/ |
321
|
|
View Code Duplication |
public function testUpdateSectionThrowsInvalidArgumentException() |
322
|
|
|
{ |
323
|
|
|
$repository = $this->getRepository(); |
324
|
|
|
|
325
|
|
|
$standardSectionId = $this->generateId('section', 1); |
326
|
|
|
/* BEGIN: Use Case */ |
327
|
|
|
// $standardSectionId contains the ID of the "Standard" section in a eZ |
328
|
|
|
// Publish demo installation. |
329
|
|
|
|
330
|
|
|
$sectionService = $repository->getSectionService(); |
331
|
|
|
|
332
|
|
|
// Create section with conflict identifier |
333
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
334
|
|
|
$sectionCreate->name = 'Conflict section'; |
335
|
|
|
$sectionCreate->identifier = 'conflictKey'; |
336
|
|
|
|
337
|
|
|
$sectionService->createSection($sectionCreate); |
338
|
|
|
|
339
|
|
|
// Load an existing section and update to an existing identifier |
340
|
|
|
$section = $sectionService->loadSection($standardSectionId); |
341
|
|
|
|
342
|
|
|
$sectionUpdate = $sectionService->newSectionUpdateStruct(); |
343
|
|
|
$sectionUpdate->identifier = 'conflictKey'; |
344
|
|
|
|
345
|
|
|
// This call should fail with an InvalidArgumentException |
346
|
|
|
$sectionService->updateSection($section, $sectionUpdate); |
347
|
|
|
/* END: Use Case */ |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Test for the loadSections() method. |
352
|
|
|
* |
353
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::loadSections() |
354
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
355
|
|
|
*/ |
356
|
|
|
public function testLoadSections() |
357
|
|
|
{ |
358
|
|
|
$repository = $this->getRepository(); |
359
|
|
|
|
360
|
|
|
/* BEGIN: Use Case */ |
361
|
|
|
$sectionService = $repository->getSectionService(); |
362
|
|
|
|
363
|
|
|
$sections = $sectionService->loadSections(); |
364
|
|
|
foreach ($sections as $section) { |
365
|
|
|
// Operate on all sections. |
366
|
|
|
} |
367
|
|
|
/* END: Use Case */ |
368
|
|
|
|
369
|
|
|
$this->assertEquals(6, count($sections)); |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* Test for the loadSections() method. |
374
|
|
|
* |
375
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::loadSections() |
376
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
377
|
|
|
*/ |
378
|
|
|
public function testLoadSectionsReturnsDefaultSectionsByDefault() |
379
|
|
|
{ |
380
|
|
|
$repository = $this->getRepository(); |
381
|
|
|
|
382
|
|
|
$sectionService = $repository->getSectionService(); |
383
|
|
|
|
384
|
|
|
$this->assertEquals( |
385
|
|
|
array( |
386
|
|
|
new Section( |
387
|
|
|
array( |
388
|
|
|
'id' => $this->generateId('section', 1), |
389
|
|
|
'name' => 'Standard', |
390
|
|
|
'identifier' => 'standard', |
391
|
|
|
) |
392
|
|
|
), |
393
|
|
|
new Section( |
394
|
|
|
array( |
395
|
|
|
'id' => $this->generateId('section', 2), |
396
|
|
|
'name' => 'Users', |
397
|
|
|
'identifier' => 'users', |
398
|
|
|
) |
399
|
|
|
), |
400
|
|
|
new Section( |
401
|
|
|
array( |
402
|
|
|
'id' => $this->generateId('section', 3), |
403
|
|
|
'name' => 'Media', |
404
|
|
|
'identifier' => 'media', |
405
|
|
|
) |
406
|
|
|
), |
407
|
|
|
new Section( |
408
|
|
|
array( |
409
|
|
|
'id' => $this->generateId('section', 4), |
410
|
|
|
'name' => 'Setup', |
411
|
|
|
'identifier' => 'setup', |
412
|
|
|
) |
413
|
|
|
), |
414
|
|
|
new Section( |
415
|
|
|
array( |
416
|
|
|
'id' => $this->generateId('section', 5), |
417
|
|
|
'name' => 'Design', |
418
|
|
|
'identifier' => 'design', |
419
|
|
|
) |
420
|
|
|
), |
421
|
|
|
new Section( |
422
|
|
|
array( |
423
|
|
|
'id' => $this->generateId('section', 6), |
424
|
|
|
'name' => 'Restricted', |
425
|
|
|
'identifier' => '', |
426
|
|
|
) |
427
|
|
|
), |
428
|
|
|
), |
429
|
|
|
$sectionService->loadSections() |
430
|
|
|
); |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* Test for the loadSectionByIdentifier() method. |
435
|
|
|
* |
436
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::loadSectionByIdentifier() |
437
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
438
|
|
|
*/ |
439
|
|
View Code Duplication |
public function testLoadSectionByIdentifier() |
440
|
|
|
{ |
441
|
|
|
$repository = $this->getRepository(); |
442
|
|
|
|
443
|
|
|
/* BEGIN: Use Case */ |
444
|
|
|
$sectionService = $repository->getSectionService(); |
445
|
|
|
|
446
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
447
|
|
|
$sectionCreate->name = 'Test Section'; |
448
|
|
|
$sectionCreate->identifier = 'uniqueKey'; |
449
|
|
|
|
450
|
|
|
$sectionId = $sectionService->createSection($sectionCreate)->id; |
451
|
|
|
|
452
|
|
|
$section = $sectionService->loadSectionByIdentifier('uniqueKey'); |
453
|
|
|
/* END: Use Case */ |
454
|
|
|
|
455
|
|
|
$this->assertEquals($sectionId, $section->id); |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
/** |
459
|
|
|
* Test for the loadSectionByIdentifier() method. |
460
|
|
|
* |
461
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::loadSectionByIdentifier() |
462
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
463
|
|
|
*/ |
464
|
|
|
public function testLoadSectionByIdentifierThrowsNotFoundException() |
465
|
|
|
{ |
466
|
|
|
$repository = $this->getRepository(); |
467
|
|
|
|
468
|
|
|
/* BEGIN: Use Case */ |
469
|
|
|
$sectionService = $repository->getSectionService(); |
470
|
|
|
|
471
|
|
|
// This call should fail with a NotFoundException |
472
|
|
|
$sectionService->loadSectionByIdentifier('someUnknownSectionIdentifier'); |
473
|
|
|
/* END: Use Case */ |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* Test for the countAssignedContents() method. |
478
|
|
|
* |
479
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::countAssignedContents() |
480
|
|
|
*/ |
481
|
|
View Code Duplication |
public function testCountAssignedContents() |
482
|
|
|
{ |
483
|
|
|
$repository = $this->getRepository(); |
484
|
|
|
|
485
|
|
|
$sectionService = $repository->getSectionService(); |
486
|
|
|
|
487
|
|
|
$standardSectionId = $this->generateId('section', 1); |
488
|
|
|
/* BEGIN: Use Case */ |
489
|
|
|
// $standardSectionId contains the ID of the "Standard" section in a eZ |
490
|
|
|
// Publish demo installation. |
491
|
|
|
|
492
|
|
|
$standardSection = $sectionService->loadSection($standardSectionId); |
493
|
|
|
|
494
|
|
|
$numberOfAssignedContent = $sectionService->countAssignedContents( |
|
|
|
|
495
|
|
|
$standardSection |
496
|
|
|
); |
497
|
|
|
/* END: Use Case */ |
498
|
|
|
|
499
|
|
|
$this->assertEquals( |
500
|
|
|
2, // Taken from the fixture |
501
|
|
|
$numberOfAssignedContent |
502
|
|
|
); |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* Test for the isSectionUsed() method. |
507
|
|
|
* |
508
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::isSectionUsed() |
509
|
|
|
*/ |
510
|
|
View Code Duplication |
public function testIsSectionUsed() |
511
|
|
|
{ |
512
|
|
|
$repository = $this->getRepository(); |
513
|
|
|
|
514
|
|
|
$sectionService = $repository->getSectionService(); |
515
|
|
|
|
516
|
|
|
$standardSectionId = $this->generateId('section', 1); |
517
|
|
|
/* BEGIN: Use Case */ |
518
|
|
|
// $standardSectionId contains the ID of the "Standard" section in a eZ |
519
|
|
|
// Publish demo installation. |
520
|
|
|
|
521
|
|
|
$standardSection = $sectionService->loadSection($standardSectionId); |
522
|
|
|
|
523
|
|
|
$isSectionUsed = $sectionService->isSectionUsed( |
524
|
|
|
$standardSection |
525
|
|
|
); |
526
|
|
|
/* END: Use Case */ |
527
|
|
|
|
528
|
|
|
$this->assertTrue( |
529
|
|
|
// Taken from the fixture |
530
|
|
|
$isSectionUsed |
531
|
|
|
); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* Test for the assignSection() method. |
536
|
|
|
* |
537
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::assignSection() |
538
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCountAssignedContents |
539
|
|
|
*/ |
540
|
|
View Code Duplication |
public function testAssignSection() |
541
|
|
|
{ |
542
|
|
|
$repository = $this->getRepository(); |
543
|
|
|
$sectionService = $repository->getSectionService(); |
544
|
|
|
|
545
|
|
|
$standardSectionId = $this->generateId('section', 1); |
546
|
|
|
$mediaSectionId = $this->generateId('section', 3); |
547
|
|
|
|
548
|
|
|
$beforeStandardCount = $sectionService->countAssignedContents( |
|
|
|
|
549
|
|
|
$sectionService->loadSection($standardSectionId) |
550
|
|
|
); |
551
|
|
|
$beforeMediaCount = $sectionService->countAssignedContents( |
|
|
|
|
552
|
|
|
$sectionService->loadSection($mediaSectionId) |
553
|
|
|
); |
554
|
|
|
|
555
|
|
|
/* BEGIN: Use Case */ |
556
|
|
|
// $mediaSectionId contains the ID of the "Media" section in a eZ |
557
|
|
|
// Publish demo installation. |
558
|
|
|
|
559
|
|
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
560
|
|
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
561
|
|
|
|
562
|
|
|
$contentService = $repository->getContentService(); |
563
|
|
|
$sectionService = $repository->getSectionService(); |
564
|
|
|
|
565
|
|
|
// Load a content info instance |
566
|
|
|
$contentInfo = $contentService->loadContentInfoByRemoteId( |
567
|
|
|
$mediaRemoteId |
568
|
|
|
); |
569
|
|
|
|
570
|
|
|
// Load the "Standard" section |
571
|
|
|
$section = $sectionService->loadSection($standardSectionId); |
572
|
|
|
|
573
|
|
|
// Assign Section to ContentInfo |
574
|
|
|
$sectionService->assignSection($contentInfo, $section); |
575
|
|
|
/* END: Use Case */ |
576
|
|
|
|
577
|
|
|
$this->assertEquals( |
578
|
|
|
$beforeStandardCount + 1, |
579
|
|
|
$sectionService->countAssignedContents( |
|
|
|
|
580
|
|
|
$sectionService->loadSection($standardSectionId) |
581
|
|
|
) |
582
|
|
|
); |
583
|
|
|
$this->assertEquals( |
584
|
|
|
$beforeMediaCount - 1, |
585
|
|
|
$sectionService->countAssignedContents( |
|
|
|
|
586
|
|
|
$sectionService->loadSection($mediaSectionId) |
587
|
|
|
) |
588
|
|
|
); |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
/** |
592
|
|
|
* Test for the assignSectionToSubtree() method. |
593
|
|
|
* |
594
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::assignSectionToSubtree() |
595
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
596
|
|
|
*/ |
597
|
|
View Code Duplication |
public function testAssignSectionToSubtree() |
598
|
|
|
{ |
599
|
|
|
$repository = $this->getRepository(); |
600
|
|
|
$sectionService = $repository->getSectionService(); |
601
|
|
|
|
602
|
|
|
$standardSectionId = $this->generateId('section', 1); |
603
|
|
|
$mediaSectionId = $this->generateId('section', 3); |
604
|
|
|
|
605
|
|
|
$beforeStandardCount = $sectionService->countAssignedContents( |
|
|
|
|
606
|
|
|
$sectionService->loadSection($standardSectionId) |
607
|
|
|
); |
608
|
|
|
|
609
|
|
|
$beforeMediaCount = $sectionService->countAssignedContents( |
|
|
|
|
610
|
|
|
$sectionService->loadSection($mediaSectionId) |
611
|
|
|
); |
612
|
|
|
|
613
|
|
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
614
|
|
|
$mediaRemoteId = '75c715a51699d2d309a924eca6a95145'; |
615
|
|
|
|
616
|
|
|
/* BEGIN: Use Case */ |
617
|
|
|
$locationService = $repository->getLocationService(); |
618
|
|
|
|
619
|
|
|
// Load a location instance |
620
|
|
|
$location = $locationService->loadLocationByRemoteId($mediaRemoteId); |
621
|
|
|
|
622
|
|
|
// Load the "Standard" section |
623
|
|
|
$section = $sectionService->loadSection($standardSectionId); |
624
|
|
|
|
625
|
|
|
// Assign Section to ContentInfo |
626
|
|
|
$sectionService->assignSectionToSubtree($location, $section); |
627
|
|
|
|
628
|
|
|
/* END: Use Case */ |
629
|
|
|
$this->assertEquals( |
630
|
|
|
$beforeStandardCount + 4, |
631
|
|
|
$sectionService->countAssignedContents( |
|
|
|
|
632
|
|
|
$sectionService->loadSection($standardSectionId) |
633
|
|
|
) |
634
|
|
|
); |
635
|
|
|
$this->assertEquals( |
636
|
|
|
$beforeMediaCount - 4, |
637
|
|
|
$sectionService->countAssignedContents( |
|
|
|
|
638
|
|
|
$sectionService->loadSection($mediaSectionId) |
639
|
|
|
) |
640
|
|
|
); |
641
|
|
|
} |
642
|
|
|
|
643
|
|
|
/** |
644
|
|
|
* Test for the countAssignedContents() method. |
645
|
|
|
* |
646
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::countAssignedContents() |
647
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
648
|
|
|
*/ |
649
|
|
View Code Duplication |
public function testCountAssignedContentsReturnsZeroByDefault() |
650
|
|
|
{ |
651
|
|
|
$repository = $this->getRepository(); |
652
|
|
|
|
653
|
|
|
/* BEGIN: Use Case */ |
654
|
|
|
$sectionService = $repository->getSectionService(); |
655
|
|
|
|
656
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
657
|
|
|
$sectionCreate->name = 'Test Section'; |
658
|
|
|
$sectionCreate->identifier = 'uniqueKey'; |
659
|
|
|
|
660
|
|
|
$section = $sectionService->createSection($sectionCreate); |
661
|
|
|
|
662
|
|
|
// The number of assigned contents should be zero |
663
|
|
|
$assignedContents = $sectionService->countAssignedContents($section); |
|
|
|
|
664
|
|
|
/* END: Use Case */ |
665
|
|
|
|
666
|
|
|
$this->assertSame(0, $assignedContents); |
667
|
|
|
} |
668
|
|
|
|
669
|
|
|
/** |
670
|
|
|
* Test for the isSectionUsed() method. |
671
|
|
|
* |
672
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::isSectionUsed() |
673
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
674
|
|
|
*/ |
675
|
|
View Code Duplication |
public function testIsSectionUsedReturnsZeroByDefault() |
676
|
|
|
{ |
677
|
|
|
$repository = $this->getRepository(); |
678
|
|
|
|
679
|
|
|
/* BEGIN: Use Case */ |
680
|
|
|
$sectionService = $repository->getSectionService(); |
681
|
|
|
|
682
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
683
|
|
|
$sectionCreate->name = 'Test Section'; |
684
|
|
|
$sectionCreate->identifier = 'uniqueKey'; |
685
|
|
|
|
686
|
|
|
$section = $sectionService->createSection($sectionCreate); |
687
|
|
|
|
688
|
|
|
// The number of assigned contents should be zero |
689
|
|
|
$isSectionUsed = $sectionService->isSectionUsed($section); |
690
|
|
|
/* END: Use Case */ |
691
|
|
|
|
692
|
|
|
$this->assertFalse($isSectionUsed); |
693
|
|
|
} |
694
|
|
|
|
695
|
|
|
/** |
696
|
|
|
* Test for the deleteSection() method. |
697
|
|
|
* |
698
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::deleteSection() |
699
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSections |
700
|
|
|
*/ |
701
|
|
View Code Duplication |
public function testDeleteSection() |
702
|
|
|
{ |
703
|
|
|
$repository = $this->getRepository(); |
704
|
|
|
|
705
|
|
|
/* BEGIN: Use Case */ |
706
|
|
|
$sectionService = $repository->getSectionService(); |
707
|
|
|
|
708
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
709
|
|
|
$sectionCreate->name = 'Test Section'; |
710
|
|
|
$sectionCreate->identifier = 'uniqueKey'; |
711
|
|
|
|
712
|
|
|
$section = $sectionService->createSection($sectionCreate); |
713
|
|
|
|
714
|
|
|
// Delete the newly created section |
715
|
|
|
$sectionService->deleteSection($section); |
716
|
|
|
/* END: Use Case */ |
717
|
|
|
|
718
|
|
|
$this->assertEquals(6, count($sectionService->loadSections())); |
719
|
|
|
} |
720
|
|
|
|
721
|
|
|
/** |
722
|
|
|
* Test for the deleteSection() method. |
723
|
|
|
* |
724
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::deleteSection() |
725
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
726
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testDeleteSection |
727
|
|
|
*/ |
728
|
|
View Code Duplication |
public function testDeleteSectionThrowsNotFoundException() |
729
|
|
|
{ |
730
|
|
|
$repository = $this->getRepository(); |
731
|
|
|
|
732
|
|
|
/* BEGIN: Use Case */ |
733
|
|
|
$sectionService = $repository->getSectionService(); |
734
|
|
|
|
735
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
736
|
|
|
$sectionCreate->name = 'Test Section'; |
737
|
|
|
$sectionCreate->identifier = 'uniqueKey'; |
738
|
|
|
|
739
|
|
|
$section = $sectionService->createSection($sectionCreate); |
740
|
|
|
|
741
|
|
|
// Delete the newly created section |
742
|
|
|
$sectionService->deleteSection($section); |
743
|
|
|
|
744
|
|
|
// This call should fail with a NotFoundException |
745
|
|
|
$sectionService->deleteSection($section); |
746
|
|
|
/* END: Use Case */ |
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
/** |
750
|
|
|
* Test for the deleteSection() method. |
751
|
|
|
* |
752
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::deleteSection() |
753
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
754
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testAssignSection |
755
|
|
|
*/ |
756
|
|
|
public function testDeleteSectionThrowsBadStateException() |
757
|
|
|
{ |
758
|
|
|
$repository = $this->getRepository(); |
759
|
|
|
|
760
|
|
|
$standardSectionId = $this->generateId('section', 1); |
761
|
|
|
/* BEGIN: Use Case */ |
762
|
|
|
// $standardSectionId contains the ID of the "Standard" section in a eZ |
763
|
|
|
// Publish demo installation. |
764
|
|
|
|
765
|
|
|
// RemoteId of the "Media" page of an eZ Publish demo installation |
766
|
|
|
$mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
767
|
|
|
|
768
|
|
|
$contentService = $repository->getContentService(); |
769
|
|
|
$sectionService = $repository->getSectionService(); |
770
|
|
|
|
771
|
|
|
// Load the "Media" ContentInfo |
772
|
|
|
$contentInfo = $contentService->loadContentInfoByRemoteId($mediaRemoteId); |
773
|
|
|
|
774
|
|
|
// Load the "Standard" section |
775
|
|
|
$section = $sectionService->loadSection($standardSectionId); |
776
|
|
|
|
777
|
|
|
// Assign "Media" to "Standard" section |
778
|
|
|
$sectionService->assignSection($contentInfo, $section); |
779
|
|
|
|
780
|
|
|
// This call should fail with a BadStateException, because there are assigned contents |
781
|
|
|
$sectionService->deleteSection($section); |
782
|
|
|
/* END: Use Case */ |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
/** |
786
|
|
|
* Test for the createSection() method. |
787
|
|
|
* |
788
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::createSection() |
789
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
790
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSectionByIdentifier |
791
|
|
|
*/ |
792
|
|
View Code Duplication |
public function testCreateSectionInTransactionWithRollback() |
793
|
|
|
{ |
794
|
|
|
$repository = $this->getRepository(); |
795
|
|
|
|
796
|
|
|
/* BEGIN: Use Case */ |
797
|
|
|
$sectionService = $repository->getSectionService(); |
798
|
|
|
|
799
|
|
|
// Start a new transaction |
800
|
|
|
$repository->beginTransaction(); |
801
|
|
|
|
802
|
|
|
try { |
803
|
|
|
// Get a create struct and set some properties |
804
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
805
|
|
|
$sectionCreate->name = 'Test Section'; |
806
|
|
|
$sectionCreate->identifier = 'uniqueKey'; |
807
|
|
|
|
808
|
|
|
// Create a new section |
809
|
|
|
$sectionService->createSection($sectionCreate); |
810
|
|
|
} catch (Exception $e) { |
811
|
|
|
// Cleanup hanging transaction on error |
812
|
|
|
$repository->rollback(); |
813
|
|
|
throw $e; |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
// Rollback all changes |
817
|
|
|
$repository->rollback(); |
818
|
|
|
|
819
|
|
|
try { |
820
|
|
|
// This call will fail with a not found exception |
821
|
|
|
$sectionService->loadSectionByIdentifier('uniqueKey'); |
822
|
|
|
} catch (NotFoundException $e) { |
823
|
|
|
// Expected execution path |
824
|
|
|
} |
825
|
|
|
/* END: Use Case */ |
826
|
|
|
|
827
|
|
|
$this->assertTrue(isset($e), 'Can still load section after rollback.'); |
828
|
|
|
} |
829
|
|
|
|
830
|
|
|
/** |
831
|
|
|
* Test for the createSection() method. |
832
|
|
|
* |
833
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::createSection() |
834
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testCreateSection |
835
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSectionByIdentifier |
836
|
|
|
*/ |
837
|
|
|
public function testCreateSectionInTransactionWithCommit() |
838
|
|
|
{ |
839
|
|
|
$repository = $this->getRepository(); |
840
|
|
|
|
841
|
|
|
/* BEGIN: Use Case */ |
842
|
|
|
$sectionService = $repository->getSectionService(); |
843
|
|
|
|
844
|
|
|
// Start a new transaction |
845
|
|
|
$repository->beginTransaction(); |
846
|
|
|
|
847
|
|
|
try { |
848
|
|
|
// Get a create struct and set some properties |
849
|
|
|
$sectionCreate = $sectionService->newSectionCreateStruct(); |
850
|
|
|
$sectionCreate->name = 'Test Section'; |
851
|
|
|
$sectionCreate->identifier = 'uniqueKey'; |
852
|
|
|
|
853
|
|
|
// Create a new section |
854
|
|
|
$sectionService->createSection($sectionCreate); |
855
|
|
|
|
856
|
|
|
// Commit all changes |
857
|
|
|
$repository->commit(); |
858
|
|
|
} catch (Exception $e) { |
859
|
|
|
// Cleanup hanging transaction on error |
860
|
|
|
$repository->rollback(); |
861
|
|
|
throw $e; |
862
|
|
|
} |
863
|
|
|
|
864
|
|
|
// Load new section |
865
|
|
|
$section = $sectionService->loadSectionByIdentifier('uniqueKey'); |
866
|
|
|
/* END: Use Case */ |
867
|
|
|
|
868
|
|
|
$this->assertEquals('uniqueKey', $section->identifier); |
869
|
|
|
} |
870
|
|
|
|
871
|
|
|
/** |
872
|
|
|
* Test for the createSection() method. |
873
|
|
|
* |
874
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::createSection() |
875
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testUpdateSection |
876
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSectionByIdentifier |
877
|
|
|
*/ |
878
|
|
|
public function testUpdateSectionInTransactionWithRollback() |
879
|
|
|
{ |
880
|
|
|
$repository = $this->getRepository(); |
881
|
|
|
|
882
|
|
|
/* BEGIN: Use Case */ |
883
|
|
|
$sectionService = $repository->getSectionService(); |
884
|
|
|
|
885
|
|
|
// Start a new transaction |
886
|
|
|
$repository->beginTransaction(); |
887
|
|
|
|
888
|
|
|
try { |
889
|
|
|
// Load standard section |
890
|
|
|
$section = $sectionService->loadSectionByIdentifier('standard'); |
891
|
|
|
|
892
|
|
|
// Get an update struct and change section name |
893
|
|
|
$sectionUpdate = $sectionService->newSectionUpdateStruct(); |
894
|
|
|
$sectionUpdate->name = 'My Standard'; |
895
|
|
|
|
896
|
|
|
// Update section |
897
|
|
|
$sectionService->updateSection($section, $sectionUpdate); |
898
|
|
|
} catch (Exception $e) { |
899
|
|
|
// Cleanup hanging transaction on error |
900
|
|
|
$repository->rollback(); |
901
|
|
|
throw $e; |
902
|
|
|
} |
903
|
|
|
|
904
|
|
|
// Rollback all changes |
905
|
|
|
$repository->rollback(); |
906
|
|
|
|
907
|
|
|
// Load updated section, name will still be "Standard" |
908
|
|
|
$updatedStandard = $sectionService->loadSectionByIdentifier('standard'); |
909
|
|
|
/* END: Use Case */ |
910
|
|
|
|
911
|
|
|
$this->assertEquals('Standard', $updatedStandard->name); |
912
|
|
|
} |
913
|
|
|
|
914
|
|
|
/** |
915
|
|
|
* Test for the createSection() method. |
916
|
|
|
* |
917
|
|
|
* @see \eZ\Publish\API\Repository\SectionService::createSection() |
918
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testUpdateSection |
919
|
|
|
* @depends eZ\Publish\API\Repository\Tests\SectionServiceTest::testLoadSectionByIdentifier |
920
|
|
|
*/ |
921
|
|
|
public function testUpdateSectionInTransactionWithCommit() |
922
|
|
|
{ |
923
|
|
|
$repository = $this->getRepository(); |
924
|
|
|
|
925
|
|
|
/* BEGIN: Use Case */ |
926
|
|
|
$sectionService = $repository->getSectionService(); |
927
|
|
|
|
928
|
|
|
// Start a new transaction |
929
|
|
|
$repository->beginTransaction(); |
930
|
|
|
|
931
|
|
|
try { |
932
|
|
|
// Load standard section |
933
|
|
|
$section = $sectionService->loadSectionByIdentifier('standard'); |
934
|
|
|
|
935
|
|
|
// Get an update struct and change section name |
936
|
|
|
$sectionUpdate = $sectionService->newSectionUpdateStruct(); |
937
|
|
|
$sectionUpdate->name = 'My Standard'; |
938
|
|
|
|
939
|
|
|
// Update section |
940
|
|
|
$sectionService->updateSection($section, $sectionUpdate); |
941
|
|
|
|
942
|
|
|
// Commit all changes |
943
|
|
|
$repository->commit(); |
944
|
|
|
} catch (Exception $e) { |
945
|
|
|
// Cleanup hanging transaction on error |
946
|
|
|
$repository->rollback(); |
947
|
|
|
throw $e; |
948
|
|
|
} |
949
|
|
|
|
950
|
|
|
// Load updated section, name will now be "My Standard" |
951
|
|
|
$updatedStandard = $sectionService->loadSectionByIdentifier('standard'); |
952
|
|
|
/* END: Use Case */ |
953
|
|
|
|
954
|
|
|
$this->assertEquals('My Standard', $updatedStandard->name); |
955
|
|
|
} |
956
|
|
|
} |
957
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.