Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like ContentTypeServiceTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ContentTypeServiceTest, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 28 | class ContentTypeServiceTest extends BaseContentTypeServiceTest | ||
| 29 | { | ||
| 30 | /** | ||
| 31 | * Test for the newContentTypeGroupCreateStruct() method. | ||
| 32 | * | ||
| 33 | * @see \eZ\Publish\API\Repository\ContentTypeService::newContentTypeGroupCreateStruct() | ||
| 34 | * @group user | ||
| 35 | */ | ||
| 36 | public function testNewContentTypeGroupCreateStruct() | ||
| 55 | |||
| 56 | /** | ||
| 57 | * Test for the newContentTypeGroupCreateStruct() method. | ||
| 58 | * | ||
| 59 | * @see \eZ\Publish\API\Repository\ContentTypeService::newContentTypeGroupCreateStruct() | ||
| 60 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testNewContentTypeGroupCreateStruct | ||
| 61 | */ | ||
| 62 | public function testNewContentTypeGroupCreateStructValues($createStruct) | ||
| 76 | |||
| 77 | /** | ||
| 78 | * Test for the createContentTypeGroup() method. | ||
| 79 | * | ||
| 80 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeGroup() | ||
| 81 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testNewContentTypeGroupCreateStruct | ||
| 82 | * @group user | ||
| 83 | */ | ||
| 84 | public function testCreateContentTypeGroup() | ||
| 85 |     { | ||
| 86 | $repository = $this->getRepository(); | ||
| 87 | |||
| 88 | /* BEGIN: Use Case */ | ||
| 89 | $contentTypeService = $repository->getContentTypeService(); | ||
| 90 | $permissionResolver = $repository->getPermissionResolver(); | ||
| 91 | |||
| 92 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct( | ||
| 93 | 'new-group' | ||
| 94 | ); | ||
| 95 |         $groupCreate->creatorId = $this->generateId('user', $permissionResolver->getCurrentUserReference()->getUserId()); | ||
| 96 | $groupCreate->creationDate = $this->createDateTime(); | ||
| 97 | /* @todo uncomment when support for multilingual names and descriptions is added | ||
| 98 | $groupCreate->mainLanguageCode = 'ger-DE'; | ||
| 99 | $groupCreate->names = array( 'eng-GB' => 'A name.' ); | ||
| 100 | $groupCreate->descriptions = array( 'eng-GB' => 'A description.' ); | ||
| 101 | */ | ||
| 102 | |||
| 103 | $group = $contentTypeService->createContentTypeGroup($groupCreate); | ||
| 104 | /* END: Use Case */ | ||
| 105 | |||
| 106 | $this->assertInstanceOf( | ||
| 107 | '\\eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentTypeGroup', | ||
| 108 | $group | ||
| 109 | ); | ||
| 110 | |||
| 111 | return [ | ||
| 112 | 'createStruct' => $groupCreate, | ||
| 113 | 'group' => $group, | ||
| 114 | ]; | ||
| 115 | } | ||
| 116 | |||
| 117 | /** | ||
| 118 | * Test for the createContentTypeGroup() method. | ||
| 119 | * | ||
| 120 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeGroup() | ||
| 121 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup | ||
| 122 | */ | ||
| 123 | public function testCreateContentTypeGroupStructValues(array $data) | ||
| 124 |     { | ||
| 125 | $createStruct = $data['createStruct']; | ||
| 126 | $group = $data['group']; | ||
| 127 | |||
| 128 | $this->assertEquals( | ||
| 129 | [ | ||
| 130 | 'identifier' => $group->identifier, | ||
| 131 | 'creatorId' => $group->creatorId, | ||
| 132 | 'creationDate' => $group->creationDate->getTimestamp(), | ||
| 133 | ], | ||
| 134 | [ | ||
| 135 | 'identifier' => $createStruct->identifier, | ||
| 136 | 'creatorId' => $createStruct->creatorId, | ||
| 137 | 'creationDate' => $createStruct->creationDate->getTimestamp(), | ||
| 138 | ] | ||
| 139 | ); | ||
| 140 | $this->assertNotNull( | ||
| 141 | $group->id | ||
| 142 | ); | ||
| 143 | |||
| 144 | return $data; | ||
| 145 | } | ||
| 146 | |||
| 147 | /** | ||
| 148 | * Test for the createContentTypeGroup() method. | ||
| 149 | * | ||
| 150 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeGroup() | ||
| 151 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroupStructValues | ||
| 152 | */ | ||
| 153 | public function testCreateContentTypeGroupStructLanguageDependentValues(array $data) | ||
| 154 |     { | ||
| 155 | $createStruct = $data['createStruct']; | ||
| 156 | $group = $data['group']; | ||
| 157 | |||
| 158 | $this->assertStructPropertiesCorrect( | ||
| 159 | $createStruct, | ||
| 160 | $group | ||
| 161 | /* @todo uncomment when support for multilingual names and descriptions is added | ||
| 162 | array( 'names', 'descriptions', 'mainLanguageCode' ) | ||
| 163 | */ | ||
| 164 | ); | ||
| 165 | } | ||
| 166 | |||
| 167 | /** | ||
| 168 | * Test for the createContentTypeGroup() method. | ||
| 169 | * | ||
| 170 | * @covers \eZ\Publish\API\Repository\ContentTypeService::createContentTypeGroup | ||
| 171 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup | ||
| 172 | */ | ||
| 173 | public function testCreateContentTypeGroupThrowsInvalidArgumentException() | ||
| 174 |     { | ||
| 175 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class); | ||
| 176 |         $this->expectExceptionMessage('Argument \'$contentTypeGroupCreateStruct\' is invalid: A group with the identifier \'Content\' already exists'); | ||
| 177 | |||
| 178 | $repository = $this->getRepository(); | ||
| 179 | |||
| 180 | /* BEGIN: Use Case */ | ||
| 181 | $contentTypeService = $repository->getContentTypeService(); | ||
| 182 | |||
| 183 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct( | ||
| 184 | 'Content' | ||
| 185 | ); | ||
| 186 | |||
| 187 | // Throws an Exception, since group "Content" already exists | ||
| 188 | $contentTypeService->createContentTypeGroup($groupCreate); | ||
| 189 | /* END: Use Case */ | ||
| 190 | } | ||
| 191 | |||
| 192 | /** | ||
| 193 | * Test for the loadContentTypeGroup() method. | ||
| 194 | * | ||
| 195 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeGroup() | ||
| 196 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup | ||
| 197 | * @group user | ||
| 198 | */ | ||
| 199 | public function testLoadContentTypeGroup() | ||
| 200 |     { | ||
| 201 | $repository = $this->getRepository(); | ||
| 202 | |||
| 203 |         $contentTypeGroupId = $this->generateId('typegroup', 2); | ||
| 204 | /* BEGIN: Use Case */ | ||
| 205 | $contentTypeService = $repository->getContentTypeService(); | ||
| 206 | |||
| 207 | // Loads the "Users" group | ||
| 208 | // $contentTypeGroupId is the ID of an existing content type group | ||
| 209 | $loadedGroup = $contentTypeService->loadContentTypeGroup($contentTypeGroupId); | ||
| 210 | /* END: Use Case */ | ||
| 211 | |||
| 212 | $this->assertInstanceOf( | ||
| 213 | '\\eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentTypeGroup', | ||
| 214 | $loadedGroup | ||
| 215 | ); | ||
| 216 | |||
| 217 | return $loadedGroup; | ||
| 218 | } | ||
| 219 | |||
| 220 | /** | ||
| 221 | * Test for the loadContentTypeGroup() method. | ||
| 222 | * | ||
| 223 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeGroup() | ||
| 224 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup | ||
| 225 | */ | ||
| 226 | public function testLoadContentTypeGroupStructValues(ContentTypeGroup $group) | ||
| 227 |     { | ||
| 228 | $this->assertPropertiesCorrect( | ||
| 229 | [ | ||
| 230 |                 'id' => $this->generateId('typegroup', 2), | ||
| 231 | 'identifier' => 'Users', | ||
| 232 | 'creationDate' => $this->createDateTime(1031216941), | ||
| 233 | 'modificationDate' => $this->createDateTime(1033922113), | ||
| 234 |                 'creatorId' => $this->generateId('user', 14), | ||
| 235 |                 'modifierId' => $this->generateId('user', 14), | ||
| 236 | ], | ||
| 237 | $group | ||
| 238 | ); | ||
| 239 | } | ||
| 240 | |||
| 241 | /** | ||
| 242 | * Test for the loadContentTypeGroup() method. | ||
| 243 | * | ||
| 244 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeGroup() | ||
| 245 | */ | ||
| 246 | public function testLoadContentTypeGroupThrowsNotFoundException() | ||
| 247 |     { | ||
| 248 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\NotFoundException::class); | ||
| 249 | |||
| 250 | $repository = $this->getRepository(); | ||
| 251 | |||
| 252 | $contentTypeService = $repository->getContentTypeService(); | ||
| 253 |         $loadedGroup = $contentTypeService->loadContentTypeGroup($this->generateId('typegroup', 2342)); | ||
|  | |||
| 254 | } | ||
| 255 | |||
| 256 | /** | ||
| 257 | * Test for the loadContentTypeGroupByIdentifier() method. | ||
| 258 | * | ||
| 259 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeGroupByIdentifier() | ||
| 260 | * @group user | ||
| 261 | * @group field-type | ||
| 262 | */ | ||
| 263 | public function testLoadContentTypeGroupByIdentifier() | ||
| 264 |     { | ||
| 265 | $repository = $this->getRepository(); | ||
| 266 | |||
| 267 | /* BEGIN: Use Case */ | ||
| 268 | $contentTypeService = $repository->getContentTypeService(); | ||
| 269 | |||
| 270 | $loadedGroup = $contentTypeService->loadContentTypeGroupByIdentifier( | ||
| 271 | 'Media' | ||
| 272 | ); | ||
| 273 | /* END: Use Case */ | ||
| 274 | |||
| 275 | $this->assertInstanceOf( | ||
| 276 | '\\eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentTypeGroup', | ||
| 277 | $loadedGroup | ||
| 278 | ); | ||
| 279 | |||
| 280 | return $loadedGroup; | ||
| 281 | } | ||
| 282 | |||
| 283 | /** | ||
| 284 | * Test for the loadContentTypeGroupByIdentifier() method. | ||
| 285 | * | ||
| 286 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeGroupByIdentifier() | ||
| 287 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifier | ||
| 288 | */ | ||
| 289 | public function testLoadContentTypeGroupByIdentifierStructValues(ContentTypeGroup $group) | ||
| 290 |     { | ||
| 291 | $repository = $this->getRepository(); | ||
| 292 | $contentTypeService = $repository->getContentTypeService(); | ||
| 293 | |||
| 294 | $this->assertEquals( | ||
| 295 |             $contentTypeService->loadContentTypeGroup($this->generateId('typegroup', 3)), | ||
| 296 | $group | ||
| 297 | ); | ||
| 298 | } | ||
| 299 | |||
| 300 | /** | ||
| 301 | * Test for the loadContentTypeGroupByIdentifier() method. | ||
| 302 | * | ||
| 303 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeGroupByIdentifier() | ||
| 304 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifier | ||
| 305 | */ | ||
| 306 | public function testLoadContentTypeGroupByIdentifierThrowsNotFoundException() | ||
| 307 |     { | ||
| 308 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\NotFoundException::class); | ||
| 309 | |||
| 310 | $repository = $this->getRepository(); | ||
| 311 | |||
| 312 | /* BEGIN: Use Case */ | ||
| 313 | $contentTypeService = $repository->getContentTypeService(); | ||
| 314 | |||
| 315 | // Throws exception | ||
| 316 | $loadedGroup = $contentTypeService->loadContentTypeGroupByIdentifier( | ||
| 317 | 'not-exists' | ||
| 318 | ); | ||
| 319 | /* END: Use Case */ | ||
| 320 | } | ||
| 321 | |||
| 322 | /** | ||
| 323 | * Test for the loadContentTypeGroups() method. | ||
| 324 | * | ||
| 325 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeGroups() | ||
| 326 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup | ||
| 327 | */ | ||
| 328 | public function testLoadContentTypeGroups() | ||
| 329 |     { | ||
| 330 | $repository = $this->getRepository(); | ||
| 331 | |||
| 332 | /* BEGIN: Use Case */ | ||
| 333 | $contentTypeService = $repository->getContentTypeService(); | ||
| 334 | |||
| 335 | // Loads an array with all content type groups | ||
| 336 | $loadedGroups = $contentTypeService->loadContentTypeGroups(); | ||
| 337 | /* END: Use Case */ | ||
| 338 | |||
| 339 | $this->assertIsArray($loadedGroups | ||
| 340 | ); | ||
| 341 | |||
| 342 | View Code Duplication |         foreach ($loadedGroups as $loadedGroup) { | |
| 343 | $this->assertStructPropertiesCorrect( | ||
| 344 | $contentTypeService->loadContentTypeGroup($loadedGroup->id), | ||
| 345 | $loadedGroup, | ||
| 346 | [ | ||
| 347 | 'id', | ||
| 348 | 'identifier', | ||
| 349 | 'creationDate', | ||
| 350 | 'modificationDate', | ||
| 351 | 'creatorId', | ||
| 352 | 'modifierId', | ||
| 353 | ] | ||
| 354 | ); | ||
| 355 | } | ||
| 356 | |||
| 357 | return $loadedGroups; | ||
| 358 | } | ||
| 359 | |||
| 360 | /** | ||
| 361 | * Test for the loadContentTypeGroups() method. | ||
| 362 | * | ||
| 363 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeGroups() | ||
| 364 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroups | ||
| 365 | */ | ||
| 366 | public function testLoadContentTypeGroupsIdentifiers($groups) | ||
| 367 |     { | ||
| 368 | $this->assertCount(4, $groups); | ||
| 369 | |||
| 370 | $expectedIdentifiers = [ | ||
| 371 | 'Content' => true, | ||
| 372 | 'Users' => true, | ||
| 373 | 'Media' => true, | ||
| 374 | 'Setup' => true, | ||
| 375 | ]; | ||
| 376 | |||
| 377 | $actualIdentifiers = []; | ||
| 378 |         foreach ($groups as $group) { | ||
| 379 | $actualIdentifiers[$group->identifier] = true; | ||
| 380 | } | ||
| 381 | |||
| 382 | ksort($expectedIdentifiers); | ||
| 383 | ksort($actualIdentifiers); | ||
| 384 | |||
| 385 | $this->assertEquals( | ||
| 386 | $expectedIdentifiers, | ||
| 387 | $actualIdentifiers, | ||
| 388 | 'Identifier missmatch in loaded groups.' | ||
| 389 | ); | ||
| 390 | } | ||
| 391 | |||
| 392 | /** | ||
| 393 | * Test for the newContentTypeGroupUpdateStruct() method. | ||
| 394 | * | ||
| 395 | * @see \eZ\Publish\API\Repository\ContentTypeService::newContentTypeGroupUpdateStruct() | ||
| 396 | */ | ||
| 397 | public function testNewContentTypeGroupUpdateStruct() | ||
| 398 |     { | ||
| 399 | $repository = $this->getRepository(); | ||
| 400 | |||
| 401 | /* BEGIN: Use Case */ | ||
| 402 | $contentTypeService = $repository->getContentTypeService(); | ||
| 403 | |||
| 404 | $groupUpdate = $contentTypeService->newContentTypeGroupUpdateStruct(); | ||
| 405 | /* END: Use Case */ | ||
| 406 | |||
| 407 | $this->assertInstanceOf( | ||
| 408 | '\\eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentTypeGroupUpdateStruct', | ||
| 409 | $groupUpdate | ||
| 410 | ); | ||
| 411 | } | ||
| 412 | |||
| 413 | /** | ||
| 414 | * Test for the updateContentTypeGroup() method. | ||
| 415 | * | ||
| 416 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeGroup() | ||
| 417 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup | ||
| 418 | */ | ||
| 419 | public function testUpdateContentTypeGroup() | ||
| 420 |     { | ||
| 421 | $repository = $this->getRepository(); | ||
| 422 | |||
| 423 |         $modifierId = $this->generateId('user', 42); | ||
| 424 | /* BEGIN: Use Case */ | ||
| 425 | $contentTypeService = $repository->getContentTypeService(); | ||
| 426 | |||
| 427 |         $group = $contentTypeService->loadContentTypeGroupByIdentifier('Setup'); | ||
| 428 | |||
| 429 | $groupUpdate = $contentTypeService->newContentTypeGroupUpdateStruct(); | ||
| 430 | |||
| 431 | $groupUpdate->identifier = 'Teardown'; | ||
| 432 | $groupUpdate->modifierId = $modifierId; | ||
| 433 | $groupUpdate->modificationDate = $this->createDateTime(); | ||
| 434 | /* @todo uncomment when support for multilingual names and descriptions is added | ||
| 435 | $groupUpdate->mainLanguageCode = 'eng-GB'; | ||
| 436 | |||
| 437 | $groupUpdate->names = array( | ||
| 438 | 'eng-GB' => 'A name', | ||
| 439 | 'eng-US' => 'A name', | ||
| 440 | ); | ||
| 441 | $groupUpdate->descriptions = array( | ||
| 442 | 'eng-GB' => 'A description', | ||
| 443 | 'eng-US' => 'A description', | ||
| 444 | ); | ||
| 445 | */ | ||
| 446 | |||
| 447 | $contentTypeService->updateContentTypeGroup($group, $groupUpdate); | ||
| 448 | /* END: Use Case */ | ||
| 449 | |||
| 450 | $updatedGroup = $contentTypeService->loadContentTypeGroup($group->id); | ||
| 451 | |||
| 452 | $this->assertInstanceOf( | ||
| 453 | '\\eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentTypeGroupUpdateStruct', | ||
| 454 | $groupUpdate | ||
| 455 | ); | ||
| 456 | |||
| 457 | return [ | ||
| 458 | 'originalGroup' => $group, | ||
| 459 | 'updateStruct' => $groupUpdate, | ||
| 460 | 'updatedGroup' => $updatedGroup, | ||
| 461 | ]; | ||
| 462 | } | ||
| 463 | |||
| 464 | /** | ||
| 465 | * Test for the updateContentTypeGroup() method. | ||
| 466 | * | ||
| 467 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeGroup() | ||
| 468 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeGroup | ||
| 469 | */ | ||
| 470 | View Code Duplication | public function testUpdateContentTypeGroupStructValues(array $data) | |
| 471 |     { | ||
| 472 | $expectedValues = [ | ||
| 473 | 'identifier' => $data['updateStruct']->identifier, | ||
| 474 | 'creationDate' => $data['originalGroup']->creationDate, | ||
| 475 | 'modificationDate' => $data['updateStruct']->modificationDate, | ||
| 476 | 'creatorId' => $data['originalGroup']->creatorId, | ||
| 477 | 'modifierId' => $data['updateStruct']->modifierId, | ||
| 478 | ]; | ||
| 479 | |||
| 480 | $this->assertPropertiesCorrect($expectedValues, $data['updatedGroup']); | ||
| 481 | |||
| 482 | return $data; | ||
| 483 | } | ||
| 484 | |||
| 485 | /** | ||
| 486 | * Test for the updateContentTypeGroup() method. | ||
| 487 | * | ||
| 488 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeGroup() | ||
| 489 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeGroupStructValues | ||
| 490 | */ | ||
| 491 | View Code Duplication | public function testUpdateContentTypeGroupStructLanguageDependentValues(array $data) | |
| 492 |     { | ||
| 493 | $expectedValues = [ | ||
| 494 | 'identifier' => $data['updateStruct']->identifier, | ||
| 495 | 'creationDate' => $data['originalGroup']->creationDate, | ||
| 496 | 'modificationDate' => $data['updateStruct']->modificationDate, | ||
| 497 | 'creatorId' => $data['originalGroup']->creatorId, | ||
| 498 | 'modifierId' => $data['updateStruct']->modifierId, | ||
| 499 | /* @todo uncomment when support for multilingual names and descriptions is added | ||
| 500 | 'mainLanguageCode' => $data['updateStruct']->mainLanguageCode, | ||
| 501 | 'names' => $data['updateStruct']->names, | ||
| 502 | 'descriptions' => $data['updateStruct']->descriptions, | ||
| 503 | */ | ||
| 504 | ]; | ||
| 505 | |||
| 506 | $this->assertPropertiesCorrect($expectedValues, $data['updatedGroup']); | ||
| 507 | } | ||
| 508 | |||
| 509 | /** | ||
| 510 | * Test for the updateContentTypeGroup() method. | ||
| 511 | * | ||
| 512 | * @covers \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeGroup | ||
| 513 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeGroup | ||
| 514 | */ | ||
| 515 | public function testUpdateContentTypeGroupThrowsInvalidArgumentException() | ||
| 516 |     { | ||
| 517 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class); | ||
| 518 |         $this->expectExceptionMessage('Argument \'$contentTypeGroupUpdateStruct->identifier\' is invalid: given identifier already exists'); | ||
| 519 | |||
| 520 | $repository = $this->getRepository(); | ||
| 521 | |||
| 522 | /* BEGIN: Use Case */ | ||
| 523 | $contentTypeService = $repository->getContentTypeService(); | ||
| 524 | |||
| 525 | $group = $contentTypeService->loadContentTypeGroupByIdentifier( | ||
| 526 | 'Media' | ||
| 527 | ); | ||
| 528 | |||
| 529 | $groupUpdate = $contentTypeService->newContentTypeGroupUpdateStruct(); | ||
| 530 | $groupUpdate->identifier = 'Users'; | ||
| 531 | |||
| 532 | // Exception, because group with identifier "Users" exists | ||
| 533 | $contentTypeService->updateContentTypeGroup($group, $groupUpdate); | ||
| 534 | /* END: Use Case */ | ||
| 535 | } | ||
| 536 | |||
| 537 | /** | ||
| 538 | * Test for the deleteContentTypeGroup() method. | ||
| 539 | * | ||
| 540 | * @covers \eZ\Publish\API\Repository\ContentTypeService::deleteContentTypeGroup | ||
| 541 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup | ||
| 542 | */ | ||
| 543 | public function testDeleteContentTypeGroup() | ||
| 544 |     { | ||
| 545 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\NotFoundException::class); | ||
| 546 | |||
| 547 | $repository = $this->getRepository(); | ||
| 548 | |||
| 549 | /* BEGIN: Use Case */ | ||
| 550 | $contentTypeService = $repository->getContentTypeService(); | ||
| 551 | |||
| 552 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct( | ||
| 553 | 'new-group' | ||
| 554 | ); | ||
| 555 | $contentTypeService->createContentTypeGroup($groupCreate); | ||
| 556 | |||
| 557 |         $group = $contentTypeService->loadContentTypeGroupByIdentifier('new-group'); | ||
| 558 | |||
| 559 | $contentTypeService->deleteContentTypeGroup($group); | ||
| 560 | /* END: Use Case */ | ||
| 561 | |||
| 562 | // loadContentTypeGroup should throw NotFoundException | ||
| 563 | $contentTypeService->loadContentTypeGroup($group->id); | ||
| 564 | |||
| 565 |         $this->fail('Content type group not deleted.'); | ||
| 566 | } | ||
| 567 | |||
| 568 | /** | ||
| 569 | * Test for the newContentTypeCreateStruct() method. | ||
| 570 | * | ||
| 571 | * @see \eZ\Publish\API\Repository\ContentTypeService::newContentTypeCreateStruct() | ||
| 572 | * @group user | ||
| 573 | * @group field-type | ||
| 574 | */ | ||
| 575 | public function testNewContentTypeCreateStruct() | ||
| 576 |     { | ||
| 577 | $repository = $this->getRepository(); | ||
| 578 | |||
| 579 | /* BEGIN: Use Case */ | ||
| 580 | $contentTypeService = $repository->getContentTypeService(); | ||
| 581 | |||
| 582 | $typeCreate = $contentTypeService->newContentTypeCreateStruct( | ||
| 583 | 'new-type' | ||
| 584 | ); | ||
| 585 | /* END: Use Case */ | ||
| 586 | |||
| 587 | $this->assertInstanceOf( | ||
| 588 | '\\eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentTypeCreateStruct', | ||
| 589 | $typeCreate | ||
| 590 | ); | ||
| 591 | |||
| 592 | return $typeCreate; | ||
| 593 | } | ||
| 594 | |||
| 595 | /** | ||
| 596 | * Test for the newContentTypeCreateStruct() method. | ||
| 597 | * | ||
| 598 | * @see \eZ\Publish\API\Repository\ContentTypeService::newContentTypeCreateStruct() | ||
| 599 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testNewContentTypeCreateStruct | ||
| 600 | */ | ||
| 601 | public function testNewContentTypeCreateStructValues($createStruct) | ||
| 602 |     { | ||
| 603 | $this->assertPropertiesCorrect( | ||
| 604 | [ | ||
| 605 | 'identifier' => 'new-type', | ||
| 606 | 'mainLanguageCode' => null, | ||
| 607 | 'remoteId' => null, | ||
| 608 | 'urlAliasSchema' => null, | ||
| 609 | 'nameSchema' => null, | ||
| 610 | 'isContainer' => false, | ||
| 611 | 'defaultSortField' => Location::SORT_FIELD_PUBLISHED, | ||
| 612 | 'defaultSortOrder' => Location::SORT_ORDER_DESC, | ||
| 613 | 'defaultAlwaysAvailable' => true, | ||
| 614 | 'names' => null, | ||
| 615 | 'descriptions' => null, | ||
| 616 | 'creatorId' => null, | ||
| 617 | 'creationDate' => null, | ||
| 618 | ], | ||
| 619 | $createStruct | ||
| 620 | ); | ||
| 621 | } | ||
| 622 | |||
| 623 | /** | ||
| 624 | * Test for the newFieldDefinitionCreateStruct() method. | ||
| 625 | * | ||
| 626 | * @see \eZ\Publish\API\Repository\ContentTypeService::newFieldDefinitionCreateStruct() | ||
| 627 | * @group user | ||
| 628 | * @group field-type | ||
| 629 | */ | ||
| 630 | public function testNewFieldDefinitionCreateStruct() | ||
| 631 |     { | ||
| 632 | $repository = $this->getRepository(); | ||
| 633 | |||
| 634 | /* BEGIN: Use Case */ | ||
| 635 | $contentTypeService = $repository->getContentTypeService(); | ||
| 636 | |||
| 637 |         $fieldDefinitionCreate = $contentTypeService->newFieldDefinitionCreateStruct('title', 'ezstring'); | ||
| 638 | /* END: Use Case */ | ||
| 639 | |||
| 640 | $this->assertInstanceOf( | ||
| 641 | '\\eZ\\Publish\\API\\Repository\\Values\\ContentType\\FieldDefinitionCreateStruct', | ||
| 642 | $fieldDefinitionCreate | ||
| 643 | ); | ||
| 644 | |||
| 645 | return $fieldDefinitionCreate; | ||
| 646 | } | ||
| 647 | |||
| 648 | /** | ||
| 649 | * Test for the newFieldDefinitionCreateStruct() method. | ||
| 650 | * | ||
| 651 | * @see \eZ\Publish\API\Repository\ContentTypeService::newFieldDefinitionCreateStruct() | ||
| 652 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testNewFieldDefinitionCreateStruct | ||
| 653 | */ | ||
| 654 | public function testNewFieldDefinitionCreateStructValues($createStruct) | ||
| 655 |     { | ||
| 656 | $this->assertPropertiesCorrect( | ||
| 657 | [ | ||
| 658 | 'fieldTypeIdentifier' => 'ezstring', | ||
| 659 | 'identifier' => 'title', | ||
| 660 | 'names' => null, | ||
| 661 | 'descriptions' => null, | ||
| 662 | 'fieldGroup' => null, | ||
| 663 | 'position' => null, | ||
| 664 | 'isTranslatable' => null, | ||
| 665 | 'isRequired' => null, | ||
| 666 | 'isInfoCollector' => null, | ||
| 667 | 'validatorConfiguration' => null, | ||
| 668 | 'fieldSettings' => null, | ||
| 669 | 'defaultValue' => null, | ||
| 670 | 'isSearchable' => null, | ||
| 671 | ], | ||
| 672 | $createStruct | ||
| 673 | ); | ||
| 674 | } | ||
| 675 | |||
| 676 | /** | ||
| 677 | * Test for the deleteContentTypeGroup() method. | ||
| 678 | * | ||
| 679 | * @see \eZ\Publish\API\Repository\ContentTypeService::deleteContentTypeGroup() | ||
| 680 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testDeleteContentTypeGroup | ||
| 681 | */ | ||
| 682 | public function testDeleteContentTypeGroupThrowsInvalidArgumentException() | ||
| 683 |     { | ||
| 684 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class); | ||
| 685 | |||
| 686 | $repository = $this->getRepository(); | ||
| 687 | |||
| 688 | /* BEGIN: Use Case */ | ||
| 689 | $contentTypeService = $repository->getContentTypeService(); | ||
| 690 | |||
| 691 |         $contentGroup = $contentTypeService->loadContentTypeGroupByIdentifier('Content'); | ||
| 692 | |||
| 693 | // Throws exception, since group contains types | ||
| 694 | $contentTypeService->deleteContentTypeGroup($contentGroup); | ||
| 695 | /* END: Use Case */ | ||
| 696 | } | ||
| 697 | |||
| 698 | /** | ||
| 699 | * Test for the createContentType() method. | ||
| 700 | * | ||
| 701 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentType() | ||
| 702 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testNewContentTypeCreateStruct | ||
| 703 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testNewFieldDefinitionCreateStruct | ||
| 704 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifier | ||
| 705 | * @group user | ||
| 706 | * @group field-type | ||
| 707 | */ | ||
| 708 | public function testCreateContentType() | ||
| 709 |     { | ||
| 710 | $repository = $this->getRepository(); | ||
| 711 | |||
| 712 | /* BEGIN: Use Case */ | ||
| 713 | $contentTypeService = $repository->getContentTypeService(); | ||
| 714 | $permissionResolver = $repository->getPermissionResolver(); | ||
| 715 | |||
| 716 |         $typeCreate = $contentTypeService->newContentTypeCreateStruct('blog-post'); | ||
| 717 | $typeCreate->mainLanguageCode = 'eng-GB'; | ||
| 718 | $typeCreate->remoteId = '384b94a1bd6bc06826410e284dd9684887bf56fc'; | ||
| 719 | $typeCreate->urlAliasSchema = 'url|scheme'; | ||
| 720 | $typeCreate->nameSchema = 'name|scheme'; | ||
| 721 | $typeCreate->names = [ | ||
| 722 | 'eng-GB' => 'Blog post', | ||
| 723 | 'ger-DE' => 'Blog-Eintrag', | ||
| 724 | ]; | ||
| 725 | $typeCreate->descriptions = [ | ||
| 726 | 'eng-GB' => 'A blog post', | ||
| 727 | 'ger-DE' => 'Ein Blog-Eintrag', | ||
| 728 | ]; | ||
| 729 |         $typeCreate->creatorId = $this->generateId('user', $permissionResolver->getCurrentUserReference()->getUserId()); | ||
| 730 | $typeCreate->creationDate = $this->createDateTime(); | ||
| 731 | |||
| 732 |         $titleFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('title', 'ezstring'); | ||
| 733 | $titleFieldCreate->names = [ | ||
| 734 | 'eng-GB' => 'Title', | ||
| 735 | 'ger-DE' => 'Titel', | ||
| 736 | ]; | ||
| 737 | $titleFieldCreate->descriptions = [ | ||
| 738 | 'eng-GB' => 'Title of the blog post', | ||
| 739 | 'ger-DE' => 'Titel des Blog-Eintrages', | ||
| 740 | ]; | ||
| 741 | $titleFieldCreate->fieldGroup = 'blog-content'; | ||
| 742 | $titleFieldCreate->position = 1; | ||
| 743 | $titleFieldCreate->isTranslatable = true; | ||
| 744 | $titleFieldCreate->isRequired = true; | ||
| 745 | $titleFieldCreate->isInfoCollector = false; | ||
| 746 | $titleFieldCreate->validatorConfiguration = [ | ||
| 747 | 'StringLengthValidator' => [ | ||
| 748 | 'minStringLength' => 0, | ||
| 749 | 'maxStringLength' => 0, | ||
| 750 | ], | ||
| 751 | ]; | ||
| 752 | $titleFieldCreate->fieldSettings = []; | ||
| 753 | $titleFieldCreate->isSearchable = true; | ||
| 754 | $titleFieldCreate->defaultValue = 'default title'; | ||
| 755 | |||
| 756 | $typeCreate->addFieldDefinition($titleFieldCreate); | ||
| 757 | |||
| 758 |         $bodyFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('body', 'ezstring'); | ||
| 759 | $bodyFieldCreate->names = [ | ||
| 760 | 'eng-GB' => 'Body', | ||
| 761 | 'ger-DE' => 'Textkörper', | ||
| 762 | ]; | ||
| 763 | $bodyFieldCreate->descriptions = [ | ||
| 764 | 'eng-GB' => 'Body of the blog post', | ||
| 765 | 'ger-DE' => 'Textkörper des Blog-Eintrages', | ||
| 766 | ]; | ||
| 767 | $bodyFieldCreate->fieldGroup = 'blog-content'; | ||
| 768 | $bodyFieldCreate->position = 2; | ||
| 769 | $bodyFieldCreate->isTranslatable = true; | ||
| 770 | $bodyFieldCreate->isRequired = true; | ||
| 771 | $bodyFieldCreate->isInfoCollector = false; | ||
| 772 | $bodyFieldCreate->validatorConfiguration = [ | ||
| 773 | 'StringLengthValidator' => [ | ||
| 774 | 'minStringLength' => 0, | ||
| 775 | 'maxStringLength' => 0, | ||
| 776 | ], | ||
| 777 | ]; | ||
| 778 | $bodyFieldCreate->fieldSettings = []; | ||
| 779 | $bodyFieldCreate->isSearchable = true; | ||
| 780 | $bodyFieldCreate->defaultValue = 'default content'; | ||
| 781 | |||
| 782 | $typeCreate->addFieldDefinition($bodyFieldCreate); | ||
| 783 | |||
| 784 | $groups = [ | ||
| 785 |             $contentTypeService->loadContentTypeGroupByIdentifier('Media'), | ||
| 786 |             $contentTypeService->loadContentTypeGroupByIdentifier('Setup'), | ||
| 787 | ]; | ||
| 788 | |||
| 789 | $contentTypeDraft = $contentTypeService->createContentType( | ||
| 790 | $typeCreate, | ||
| 791 | $groups | ||
| 792 | ); | ||
| 793 | /* END: Use Case */ | ||
| 794 | |||
| 795 | $this->assertInstanceOf( | ||
| 796 | 'eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentType', | ||
| 797 | $contentTypeDraft | ||
| 798 | ); | ||
| 799 | |||
| 800 | return [ | ||
| 801 | 'typeCreate' => $typeCreate, | ||
| 802 | 'contentType' => $contentTypeDraft, | ||
| 803 | 'groups' => $groups, | ||
| 804 | ]; | ||
| 805 | } | ||
| 806 | |||
| 807 | /** | ||
| 808 | * Test for the createContentType() method struct values. | ||
| 809 | * | ||
| 810 | * @covers \eZ\Publish\API\Repository\ContentTypeService::createContentType | ||
| 811 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 812 | * | ||
| 813 | * @param array $data | ||
| 814 | */ | ||
| 815 | public function testCreateContentTypeStructValues(array $data) | ||
| 857 | |||
| 858 | /** | ||
| 859 | * Asserts field definition creation. | ||
| 860 | * | ||
| 861 | * Asserts that all field definitions defined through created structs in | ||
| 862 | * $expectedDefinitionCreates have been correctly created in | ||
| 863 | * $actualDefinitions. | ||
| 864 | * | ||
| 865 | * @param \eZ\Publish\API\Repository\Values\FieldDefinitionCreateStruct[] $expectedDefinitionCreates | ||
| 866 | * @param \eZ\Publish\API\Repository\Values\FieldDefinition[] $actualDefinitions | ||
| 867 | */ | ||
| 868 | protected function assertFieldDefinitionsCorrect(array $expectedDefinitionCreates, array $actualDefinitions) | ||
| 890 | |||
| 891 | /** | ||
| 892 | * Asserts that a field definition has been correctly created. | ||
| 893 | * | ||
| 894 | * Asserts that the given $actualDefinition is correctly created from the | ||
| 895 | * create struct in $expectedCreate. | ||
| 896 | * | ||
| 897 | * @param \eZ\Publish\API\Repository\Values\FieldDefinitionCreateStruct $expectedDefinitionCreate | ||
| 898 | * @param \eZ\Publish\API\Repository\Values\FieldDefinition $actualDefinition | ||
| 899 | */ | ||
| 900 | protected function assertFieldDefinitionsEqual($expectedCreate, $actualDefinition) | ||
| 909 | |||
| 910 | /** | ||
| 911 | * Asserts that two sets of ContentTypeGroups are equal. | ||
| 912 | * | ||
| 913 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup[] $expectedGroups | ||
| 914 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup[] $actualGroups | ||
| 915 | */ | ||
| 916 | protected function assertContentTypeGroupsCorrect($expectedGroups, $actualGroups) | ||
| 940 | |||
| 941 | /** | ||
| 942 | * Test for the createContentType() method. | ||
| 943 | * | ||
| 944 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentType() | ||
| 945 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 946 | */ | ||
| 947 | View Code Duplication | public function testCreateContentTypeThrowsInvalidArgumentExceptionDuplicateIdentifier() | |
| 973 | |||
| 974 | /** | ||
| 975 | * Test for the createContentType() method trying to create Content Type with already existing | ||
| 976 | * remoteId. | ||
| 977 | * | ||
| 978 | * @covers \eZ\Publish\API\Repository\ContentTypeService::createContentType() | ||
| 979 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 980 | */ | ||
| 981 | View Code Duplication | public function testCreateContentTypeThrowsInvalidArgumentExceptionDuplicateRemoteId() | |
| 1008 | |||
| 1009 | /** | ||
| 1010 | * Test for the createContentType() method creating content with duplicate field identifiers. | ||
| 1011 | * | ||
| 1012 | * @covers \eZ\Publish\API\Repository\ContentTypeService::createContentType | ||
| 1013 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 1014 | */ | ||
| 1015 | public function testCreateContentTypeThrowsInvalidArgumentExceptionDuplicateFieldIdentifier() | ||
| 1044 | |||
| 1045 | /** | ||
| 1046 | * Test for the createContentTypeGroup() method trying to create a content type with already | ||
| 1047 | * existing identifier. | ||
| 1048 | * | ||
| 1049 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 1050 | * @covers \eZ\Publish\Core\Repository\ContentTypeService::createContentType | ||
| 1051 | */ | ||
| 1052 | public function testCreateContentTypeThrowsInvalidArgumentExceptionDuplicateContentTypeIdentifier() | ||
| 1083 | |||
| 1084 | /** | ||
| 1085 | * Test for the createContentType() method. | ||
| 1086 | * | ||
| 1087 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentType() | ||
| 1088 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 1089 | */ | ||
| 1090 | public function testCreateContentTypeThrowsContentTypeFieldDefinitionValidationException() | ||
| 1141 | |||
| 1142 | /** | ||
| 1143 | * Test for the createContentTypeGroup() method called with no groups. | ||
| 1144 | * | ||
| 1145 | * @depends testCreateContentType | ||
| 1146 | * @covers \eZ\Publish\Core\Repository\ContentTypeService::createContentTypeGroup | ||
| 1147 | */ | ||
| 1148 | public function testCreateContentTypeThrowsInvalidArgumentExceptionGroupsEmpty() | ||
| 1166 | |||
| 1167 | /** | ||
| 1168 | * Test for the newContentTypeUpdateStruct() method. | ||
| 1169 | * | ||
| 1170 | * @see \eZ\Publish\API\Repository\ContentTypeService::newContentTypeUpdateStruct() | ||
| 1171 | */ | ||
| 1172 | public function testNewContentTypeUpdateStruct() | ||
| 1189 | |||
| 1190 | /** | ||
| 1191 | * Test for the newContentTypeUpdateStruct() method. | ||
| 1192 | * | ||
| 1193 | * @see \eZ\Publish\API\Repository\ContentTypeService::newContentTypeUpdateStruct() | ||
| 1194 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testNewContentTypeUpdateStruct | ||
| 1195 | */ | ||
| 1196 | public function testNewContentTypeUpdateStructValues($typeUpdate) | ||
| 1205 | |||
| 1206 | /** | ||
| 1207 | * Test for the loadContentTypeDraft() method. | ||
| 1208 | * | ||
| 1209 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeDraft() | ||
| 1210 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 1211 | */ | ||
| 1212 | public function testLoadContentTypeDraft() | ||
| 1230 | |||
| 1231 | /** | ||
| 1232 | * Test for the loadContentTypeDraft() method. | ||
| 1233 | * | ||
| 1234 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeDraft() | ||
| 1235 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeDraft | ||
| 1236 | */ | ||
| 1237 | public function testLoadContentTypeDraftThrowsNotFoundException() | ||
| 1238 |     { | ||
| 1239 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\NotFoundException::class); | ||
| 1240 | |||
| 1241 | $repository = $this->getRepository(); | ||
| 1242 | |||
| 1243 |         $nonExistingContentTypeId = $this->generateId('type', 2342); | ||
| 1244 | /* BEGIN: Use Case */ | ||
| 1245 | $contentTypeService = $repository->getContentTypeService(); | ||
| 1246 | |||
| 1247 | // Throws exception, since 2342 does not exist | ||
| 1248 | $contentTypeDraft = $contentTypeService->loadContentTypeDraft($nonExistingContentTypeId); | ||
| 1249 | /* END: Use Case */ | ||
| 1250 | } | ||
| 1251 | |||
| 1252 | /** | ||
| 1253 | * Test for the loadContentTypeDraft() method. | ||
| 1254 | * | ||
| 1255 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeDraft() | ||
| 1256 | */ | ||
| 1257 | public function testLoadContentTypeDraftThrowsNotFoundExceptionIfDiffrentOwner() | ||
| 1272 | |||
| 1273 | /** | ||
| 1274 | * Test for the loadContentTypeDraft() method. | ||
| 1275 | * | ||
| 1276 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeDraft() | ||
| 1277 | */ | ||
| 1278 | public function testCanLoadContentTypeDraftEvenIfDiffrentOwner() | ||
| 1294 | |||
| 1295 | /** | ||
| 1296 | * Test for the updateContentTypeDraft() method. | ||
| 1297 | * | ||
| 1298 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeDraft() | ||
| 1299 | */ | ||
| 1300 | public function testUpdateContentTypeDraft() | ||
| 1346 | |||
| 1347 | /** | ||
| 1348 | * Test for the updateContentTypeDraft() method. | ||
| 1349 | * | ||
| 1350 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeDraft() | ||
| 1351 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeDraft | ||
| 1352 | */ | ||
| 1353 | public function testUpdateContentTypeDraftStructValues($data) | ||
| 1390 | |||
| 1391 | /** | ||
| 1392 | * @covers \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeDraft | ||
| 1393 | * | ||
| 1394 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException | ||
| 1395 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException | ||
| 1396 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException | ||
| 1397 | */ | ||
| 1398 | public function testUpdateContentTypeDraftWithNewTranslation() | ||
| 1430 | |||
| 1431 | /** | ||
| 1432 | * Test for the updateContentTypeDraft() method. | ||
| 1433 | * | ||
| 1434 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeDraft() | ||
| 1435 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeDraft | ||
| 1436 | */ | ||
| 1437 | View Code Duplication | public function testUpdateContentTypeDraftThrowsInvalidArgumentExceptionDuplicateIdentifier() | |
| 1454 | |||
| 1455 | /** | ||
| 1456 | * Test for the updateContentTypeDraft() method. | ||
| 1457 | * | ||
| 1458 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeDraft() | ||
| 1459 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeDraft | ||
| 1460 | */ | ||
| 1461 | View Code Duplication | public function testUpdateContentTypeDraftThrowsInvalidArgumentExceptionDuplicateRemoteId() | |
| 1478 | |||
| 1479 | /** | ||
| 1480 | * Test for the updateContentTypeDraft() method. | ||
| 1481 | * | ||
| 1482 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeDraft | ||
| 1483 | * @covers \eZ\Publish\Core\Repository\ContentTypeService::updateContentTypeDraft | ||
| 1484 | */ | ||
| 1485 | public function testUpdateContentTypeDraftThrowsInvalidArgumentExceptionNoDraftForAuthenticatedUser() | ||
| 1514 | |||
| 1515 | /** | ||
| 1516 | * Test for the addFieldDefinition() method. | ||
| 1517 | * | ||
| 1518 | * @return array | ||
| 1519 | * | ||
| 1520 | * @see \eZ\Publish\API\Repository\ContentTypeService::addFieldDefinition() | ||
| 1521 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 1522 | */ | ||
| 1523 | public function testAddFieldDefinition() | ||
| 1570 | |||
| 1571 | /** | ||
| 1572 | * Test for the addFieldDefinition() method. | ||
| 1573 | * | ||
| 1574 | * @see \eZ\Publish\API\Repository\ContentTypeService::addFieldDefinition() | ||
| 1575 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAddFieldDefinition | ||
| 1576 | */ | ||
| 1577 | public function testAddFieldDefinitionStructValues(array $data) | ||
| 1597 | |||
| 1598 | /** | ||
| 1599 | * Test for the addFieldDefinition() method. | ||
| 1600 | * | ||
| 1601 | * @see \eZ\Publish\API\Repository\ContentTypeService::addFieldDefinition() | ||
| 1602 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAddFieldDefinition | ||
| 1603 | */ | ||
| 1604 | View Code Duplication | public function testAddFieldDefinitionThrowsInvalidArgumentExceptionDuplicateFieldIdentifier() | |
| 1620 | |||
| 1621 | /** | ||
| 1622 | * Test for the addFieldDefinition() method. | ||
| 1623 | * | ||
| 1624 | * Testing that field definition of non-repeatable field type can not be added multiple | ||
| 1625 | * times to the same ContentType. | ||
| 1626 | * | ||
| 1627 | * @see \eZ\Publish\API\Repository\ContentTypeService::addFieldDefinition() | ||
| 1628 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAddFieldDefinition | ||
| 1629 | */ | ||
| 1630 | public function testAddFieldDefinitionThrowsContentTypeFieldDefinitionValidationException() | ||
| 1679 | |||
| 1680 | /** | ||
| 1681 | * Test for the addFieldDefinition() method. | ||
| 1682 | * | ||
| 1683 | * Testing that field definition of non-repeatable field type can not be added multiple | ||
| 1684 | * times to the same ContentType. | ||
| 1685 | * | ||
| 1686 | * @see \eZ\Publish\API\Repository\ContentTypeService::addFieldDefinition() | ||
| 1687 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAddFieldDefinition | ||
| 1688 | */ | ||
| 1689 | View Code Duplication | public function testAddFieldDefinitionThrowsBadStateExceptionNonRepeatableField() | |
| 1721 | |||
| 1722 | /** | ||
| 1723 | * Test for the ContentTypeService::createContentType() method. | ||
| 1724 | * | ||
| 1725 | * Testing that field definition of non-repeatable field type can not be added multiple | ||
| 1726 | * times to the same ContentTypeCreateStruct. | ||
| 1727 | * | ||
| 1728 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentType() | ||
| 1729 | */ | ||
| 1730 | public function testCreateContentThrowsContentTypeValidationException() | ||
| 1774 | |||
| 1775 | /** | ||
| 1776 | * Test for the addFieldDefinition() method. | ||
| 1777 | * | ||
| 1778 | * Testing adding field definition of the field type that can not be added to the ContentType that | ||
| 1779 | * already has Content instances. | ||
| 1780 | * | ||
| 1781 | * @see \eZ\Publish\API\Repository\ContentTypeService::addFieldDefinition() | ||
| 1782 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAddFieldDefinition | ||
| 1783 | */ | ||
| 1784 | View Code Duplication | public function testAddFieldDefinitionThrowsBadStateExceptionContentInstances() | |
| 1816 | |||
| 1817 | /** | ||
| 1818 | * Test for the removeFieldDefinition() method. | ||
| 1819 | * | ||
| 1820 | * @return array | ||
| 1821 | * | ||
| 1822 | * @see \eZ\Publish\API\Repository\ContentTypeService::removeFieldDefinition() | ||
| 1823 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 1824 | */ | ||
| 1825 | public function testRemoveFieldDefinition() | ||
| 1850 | |||
| 1851 | /** | ||
| 1852 | * Test for the removeFieldDefinition() method. | ||
| 1853 | * | ||
| 1854 | * @param array $data | ||
| 1855 | * | ||
| 1856 | * @see \eZ\Publish\API\Repository\ContentTypeService::removeFieldDefinition() | ||
| 1857 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testRemoveFieldDefinition | ||
| 1858 | */ | ||
| 1859 | public function testRemoveFieldDefinitionRemoved(array $data) | ||
| 1875 | |||
| 1876 | /** | ||
| 1877 | * Test for the removeFieldDefinition() method. | ||
| 1878 | * | ||
| 1879 | * @see \eZ\Publish\API\Repository\ContentTypeService::removeFieldDefinition() | ||
| 1880 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testRemoveFieldDefinition | ||
| 1881 | */ | ||
| 1882 | public function testRemoveFieldDefinitionThrowsInvalidArgumentException() | ||
| 1901 | |||
| 1902 | /** | ||
| 1903 | * Test removeFieldDefinition() method for field in a different draft throws an exception. | ||
| 1904 | * | ||
| 1905 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testRemoveFieldDefinition | ||
| 1906 | * @covers \eZ\Publish\Core\Repository\ContentTypeService::removeFieldDefinition | ||
| 1907 | */ | ||
| 1908 | View Code Duplication | public function testRemoveFieldDefinitionThrowsInvalidArgumentExceptionOnWrongDraft() | |
| 1923 | |||
| 1924 | /** | ||
| 1925 | * Test for the removeFieldDefinition() method. | ||
| 1926 | * | ||
| 1927 | * @see \eZ\Publish\API\Repository\ContentTypeService::removeFieldDefinition() | ||
| 1928 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testRemoveFieldDefinition | ||
| 1929 | */ | ||
| 1930 | public function testRemoveFieldDefinitionRemovesFieldFromContent() | ||
| 1991 | |||
| 1992 | /** | ||
| 1993 | * Test for the removeFieldDefinition() method. | ||
| 1994 | * | ||
| 1995 | * @param \eZ\Publish\API\Repository\Values\Content\Content[] $data | ||
| 1996 | * | ||
| 1997 | * @see \eZ\Publish\API\Repository\ContentTypeService::removeFieldDefinition() | ||
| 1998 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testRemoveFieldDefinitionRemovesFieldFromContent | ||
| 1999 | */ | ||
| 2000 | public function testRemoveFieldDefinitionRemovesFieldFromContentRemoved($data) | ||
| 2021 | |||
| 2022 | /** | ||
| 2023 | * Test for the addFieldDefinition() method. | ||
| 2024 | * | ||
| 2025 | * @see \eZ\Publish\API\Repository\ContentTypeService::addFieldDefinition() | ||
| 2026 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAddFieldDefinition | ||
| 2027 | */ | ||
| 2028 | public function testAddFieldDefinitionAddsFieldToContent() | ||
| 2110 | |||
| 2111 | /** | ||
| 2112 | * Test for the addFieldDefinition() method. | ||
| 2113 | * | ||
| 2114 | * @param \eZ\Publish\API\Repository\Values\Content\Content[] $data | ||
| 2115 | * | ||
| 2116 | * @see \eZ\Publish\API\Repository\ContentTypeService::addFieldDefinition() | ||
| 2117 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAddFieldDefinitionAddsFieldToContent | ||
| 2118 | */ | ||
| 2119 | public function testAddFieldDefinitionAddsFieldToContentAdded(array $data) | ||
| 2149 | |||
| 2150 | /** | ||
| 2151 | * Test for the newFieldDefinitionUpdateStruct() method. | ||
| 2152 | * | ||
| 2153 | * @see \eZ\Publish\API\Repository\ContentTypeService::newFieldDefinitionUpdateStruct() | ||
| 2154 | */ | ||
| 2155 | public function testNewFieldDefinitionUpdateStruct() | ||
| 2172 | |||
| 2173 | /** | ||
| 2174 | * Test for the newFieldDefinitionUpdateStruct() method. | ||
| 2175 | * | ||
| 2176 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testNewFieldDefinitionUpdateStruct | ||
| 2177 | * @covers \eZ\Publish\Core\Repository\ContentTypeService::newContentTypeUpdateStruct | ||
| 2178 | * | ||
| 2179 | * @param \eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct | ||
| 2180 | */ | ||
| 2181 | public function testNewFieldDefinitionUpdateStructValues($fieldDefinitionUpdateStruct) | ||
| 2190 | |||
| 2191 | /** | ||
| 2192 | * Test for the updateFieldDefinition() method. | ||
| 2193 | * | ||
| 2194 | * @return array | ||
| 2195 | * | ||
| 2196 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateFieldDefinition() | ||
| 2197 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeDraft | ||
| 2198 | */ | ||
| 2199 | public function testUpdateFieldDefinition() | ||
| 2249 | |||
| 2250 | /** | ||
| 2251 | * @covers \eZ\Publish\API\Repository\ContentTypeService::updateFieldDefinition | ||
| 2252 | */ | ||
| 2253 | public function testUpdateFieldDefinitionWithNewTranslation() | ||
| 2313 | |||
| 2314 | /** | ||
| 2315 | * Test for the updateFieldDefinition() method. | ||
| 2316 | * | ||
| 2317 | * @param array $data | ||
| 2318 | * | ||
| 2319 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateFieldDefinition() | ||
| 2320 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateFieldDefinition | ||
| 2321 | */ | ||
| 2322 | public function testUpdateFieldDefinitionStructValues(array $data) | ||
| 2347 | |||
| 2348 | /** | ||
| 2349 | * Test for the updateFieldDefinition() method using an empty FieldDefinitionUpdateStruct. | ||
| 2350 | * | ||
| 2351 | * @see \eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionUpdateStruct | ||
| 2352 | * | ||
| 2353 | * @covers \eZ\Publish\Core\Repository\ContentTypeService::updateFieldDefinition | ||
| 2354 | */ | ||
| 2355 | public function testUpdateFieldDefinitionWithEmptyStruct() | ||
| 2377 | |||
| 2378 | /** | ||
| 2379 | * Test for the updateFieldDefinition() method with already defined field identifier. | ||
| 2380 | * | ||
| 2381 | * @covers \eZ\Publish\API\Repository\ContentTypeService::updateFieldDefinition | ||
| 2382 | * depends \eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeDraft | ||
| 2383 | */ | ||
| 2384 | public function testUpdateFieldDefinitionThrowsInvalidArgumentExceptionFieldIdentifierExists() | ||
| 2409 | |||
| 2410 | /** | ||
| 2411 | * Test for the updateFieldDefinition() method trying to update non-existent field. | ||
| 2412 | * | ||
| 2413 | * @covers \eZ\Publish\API\Repository\ContentTypeService::updateFieldDefinition() | ||
| 2414 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeDraft | ||
| 2415 | */ | ||
| 2416 | public function testUpdateFieldDefinitionThrowsInvalidArgumentExceptionForUndefinedField() | ||
| 2442 | |||
| 2443 | /** | ||
| 2444 | * Test for the publishContentTypeDraft() method. | ||
| 2445 | * | ||
| 2446 | * @see \eZ\Publish\API\Repository\ContentTypeService::publishContentTypeDraft() | ||
| 2447 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeDraft | ||
| 2448 | */ | ||
| 2449 | public function testPublishContentTypeDraft() | ||
| 2471 | |||
| 2472 | /** | ||
| 2473 | * Test for the publishContentTypeDraft() method setting proper ContentType nameSchema. | ||
| 2474 | * | ||
| 2475 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testPublishContentTypeDraft | ||
| 2476 | * @covers \eZ\Publish\Core\Repository\ContentTypeService::publishContentTypeDraft | ||
| 2477 | */ | ||
| 2478 | public function testPublishContentTypeDraftSetsNameSchema() | ||
| 2508 | |||
| 2509 | /** | ||
| 2510 | * Test that publishing Content Type Draft refreshes list of Content Types in Content Type Groups. | ||
| 2511 | * | ||
| 2512 | * @covers \eZ\Publish\API\Repository\ContentTypeService::publishContentTypeDraft | ||
| 2513 | */ | ||
| 2514 | public function testPublishContentTypeDraftRefreshesContentTypesList() | ||
| 2562 | |||
| 2563 | /** | ||
| 2564 | * Test for the publishContentTypeDraft() method. | ||
| 2565 | * | ||
| 2566 | * @see \eZ\Publish\API\Repository\ContentTypeService::publishContentTypeDraft() | ||
| 2567 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testPublishContentTypeDraft | ||
| 2568 | */ | ||
| 2569 | public function testPublishContentTypeDraftThrowsBadStateException() | ||
| 2585 | |||
| 2586 | /** | ||
| 2587 | * Test for the createContentTypeGroup() method trying to create Content Type without any fields. | ||
| 2588 | * | ||
| 2589 | * @covers \eZ\Publish\API\Repository\ContentTypeService::publishContentTypeDraft() | ||
| 2590 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testPublishContentTypeDraft | ||
| 2591 | */ | ||
| 2592 | public function testPublishContentTypeDraftThrowsInvalidArgumentExceptionWithoutFields() | ||
| 2619 | |||
| 2620 | /** | ||
| 2621 | * Test for the loadContentType() method. | ||
| 2622 | * | ||
| 2623 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentType() | ||
| 2624 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 2625 | * @group user | ||
| 2626 | * @group field-type | ||
| 2627 | */ | ||
| 2628 | public function testLoadContentType() | ||
| 2647 | |||
| 2648 | /** | ||
| 2649 | * Test that multi-language logic respects prioritized language list. | ||
| 2650 | * | ||
| 2651 | * @dataProvider getPrioritizedLanguageList | ||
| 2652 | * | ||
| 2653 | * @param string[] $languageCodes | ||
| 2654 | */ | ||
| 2655 | public function testLoadContentTypeWithPrioritizedLanguagesList(array $languageCodes) | ||
| 2686 | |||
| 2687 | /** | ||
| 2688 | * @return array | ||
| 2689 | */ | ||
| 2690 | public function getPrioritizedLanguageList() | ||
| 2700 | |||
| 2701 | /** | ||
| 2702 | * Test for the loadContentType() method. | ||
| 2703 | * | ||
| 2704 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentType() | ||
| 2705 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentType | ||
| 2706 | */ | ||
| 2707 | public function testLoadContentTypeStructValues($userGroupType) | ||
| 2741 | |||
| 2742 | /** | ||
| 2743 | * Test for the loadContentType() method. | ||
| 2744 | * | ||
| 2745 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentType() | ||
| 2746 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeStructValues | ||
| 2747 | */ | ||
| 2748 | public function testLoadContentTypeFieldDefinitions(APIFieldDefinitionCollection $fieldDefinitions) | ||
| 2836 | |||
| 2837 | /** | ||
| 2838 | * Test for the loadContentType() method. | ||
| 2839 | * | ||
| 2840 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentType() | ||
| 2841 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentType | ||
| 2842 | */ | ||
| 2843 | public function testLoadContentTypeThrowsNotFoundException() | ||
| 2857 | |||
| 2858 | /** | ||
| 2859 | * Test for the loadContentTypeByIdentifier() method. | ||
| 2860 | * | ||
| 2861 | * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType | ||
| 2862 | * | ||
| 2863 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeByIdentifier() | ||
| 2864 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentType | ||
| 2865 | * @group user | ||
| 2866 | */ | ||
| 2867 | public function testLoadContentTypeByIdentifier() | ||
| 2884 | |||
| 2885 | /** | ||
| 2886 | * Test for the loadContentTypeByIdentifier() method. | ||
| 2887 | * | ||
| 2888 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType | ||
| 2889 | * | ||
| 2890 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeByIdentifier() | ||
| 2891 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier | ||
| 2892 | */ | ||
| 2893 | public function testLoadContentTypeByIdentifierReturnsCorrectInstance($contentType) | ||
| 2903 | |||
| 2904 | /** | ||
| 2905 | * Test for the loadContentTypeByIdentifier() method. | ||
| 2906 | * | ||
| 2907 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeByIdentifier() | ||
| 2908 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier | ||
| 2909 | */ | ||
| 2910 | public function testLoadContentTypeByIdentifierThrowsNotFoundException() | ||
| 2923 | |||
| 2924 | /** | ||
| 2925 | * Test for the loadContentTypeByRemoteId() method. | ||
| 2926 | * | ||
| 2927 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeByRemoteId() | ||
| 2928 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentType | ||
| 2929 | */ | ||
| 2930 | public function testLoadContentTypeByRemoteId() | ||
| 2950 | |||
| 2951 | /** | ||
| 2952 | * Test for the loadContentTypeByRemoteId() method. | ||
| 2953 | * | ||
| 2954 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeByRemoteId() | ||
| 2955 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByRemoteId | ||
| 2956 | */ | ||
| 2957 | public function testLoadContentTypeByRemoteIdReturnsCorrectInstance($contentType) | ||
| 2967 | |||
| 2968 | /** | ||
| 2969 | * Test for the loadContentTypeByRemoteId() method. | ||
| 2970 | * | ||
| 2971 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeByRemoteId() | ||
| 2972 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentType | ||
| 2973 | */ | ||
| 2974 | public function testLoadContentTypeByRemoteIdThrowsNotFoundException() | ||
| 2987 | |||
| 2988 | /** | ||
| 2989 | * Test for the loadContentTypeList() method. | ||
| 2990 | * | ||
| 2991 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypeList() | ||
| 2992 | * @depends testLoadContentType | ||
| 2993 | */ | ||
| 2994 | public function testLoadContentTypeList() | ||
| 3011 | |||
| 3012 | /** | ||
| 3013 | * Test for the loadContentTypes() method. | ||
| 3014 | * | ||
| 3015 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypes() | ||
| 3016 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentType | ||
| 3017 | */ | ||
| 3018 | public function testLoadContentTypes() | ||
| 3037 | |||
| 3038 | /** | ||
| 3039 | * Test for the loadContentTypes() method. | ||
| 3040 | * | ||
| 3041 | * @see \eZ\Publish\API\Repository\ContentTypeService::loadContentTypes() | ||
| 3042 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypes | ||
| 3043 | */ | ||
| 3044 | public function testLoadContentTypesContent(array $types) | ||
| 3067 | |||
| 3068 | /** | ||
| 3069 | * Test for the createContentTypeDraft() method. | ||
| 3070 | * | ||
| 3071 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeDraft() | ||
| 3072 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentType | ||
| 3073 | */ | ||
| 3074 | public function testCreateContentTypeDraft() | ||
| 3075 |     { | ||
| 3076 | $repository = $this->getRepository(); | ||
| 3077 | |||
| 3078 | /* BEGIN: Use Case */ | ||
| 3079 | $contentTypeService = $repository->getContentTypeService(); | ||
| 3080 | |||
| 3081 |         $commentType = $contentTypeService->loadContentTypeByIdentifier('comment', Language::ALL); | ||
| 3082 | |||
| 3083 | $commentTypeDraft = $contentTypeService->createContentTypeDraft($commentType); | ||
| 3084 | /* END: Use Case */ | ||
| 3085 | |||
| 3086 | $this->assertInstanceOf( | ||
| 3087 | 'eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentTypeDraft', | ||
| 3088 | $commentTypeDraft | ||
| 3089 | ); | ||
| 3090 | |||
| 3091 | return [ | ||
| 3092 | 'originalType' => $commentType, | ||
| 3093 | 'typeDraft' => $commentTypeDraft, | ||
| 3094 | ]; | ||
| 3095 | } | ||
| 3096 | |||
| 3097 | /** | ||
| 3098 | * Test for the createContentTypeDraft() method. | ||
| 3099 | * | ||
| 3100 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeDraft() | ||
| 3101 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeDraft | ||
| 3102 | */ | ||
| 3103 | public function testCreateContentTypeDraftStructValues(array $data) | ||
| 3148 | |||
| 3149 | /** | ||
| 3150 | * Test for the createContentTypeDraft() method. | ||
| 3151 | * | ||
| 3152 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeDraft() | ||
| 3153 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeDraftStructValues | ||
| 3154 | */ | ||
| 3155 | public function testCreateContentTypeDraftStructLanguageDependentValues(array $data) | ||
| 3171 | |||
| 3172 | /** | ||
| 3173 | * Test for the createContentTypeDraft() method. | ||
| 3174 | * | ||
| 3175 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeDraft() | ||
| 3176 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeDraft | ||
| 3177 | */ | ||
| 3178 | View Code Duplication | public function testCreateContentTypeDraftThrowsBadStateException() | |
| 3195 | |||
| 3196 | /** | ||
| 3197 | * Test for the deleteContentType() method. | ||
| 3198 | * | ||
| 3199 | * @covers \eZ\Publish\API\Repository\ContentTypeService::deleteContentType() | ||
| 3200 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier | ||
| 3201 | */ | ||
| 3202 | public function testDeleteContentType() | ||
| 3219 | |||
| 3220 | /** | ||
| 3221 | * Test for the deleteContentType() method. | ||
| 3222 | * | ||
| 3223 | * @see \eZ\Publish\API\Repository\ContentTypeService::deleteContentType() | ||
| 3224 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testDeleteContentType | ||
| 3225 | */ | ||
| 3226 | View Code Duplication | public function testDeleteContentTypeThrowsBadStateException() | |
| 3242 | |||
| 3243 | /** | ||
| 3244 | * Test for the copyContentType() method. | ||
| 3245 | * | ||
| 3246 | * @return array | ||
| 3247 | * | ||
| 3248 | * @see \eZ\Publish\API\Repository\ContentTypeService::copyContentType() | ||
| 3249 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier | ||
| 3250 | */ | ||
| 3251 | public function testCopyContentType() | ||
| 3252 |     { | ||
| 3253 | $repository = $this->getRepository(); | ||
| 3254 | |||
| 3255 | /* BEGIN: Use Case */ | ||
| 3256 | $contentTypeService = $repository->getContentTypeService(); | ||
| 3257 | |||
| 3258 |         $commentType = $contentTypeService->loadContentTypeByIdentifier('comment'); | ||
| 3259 | |||
| 3260 | // Complete copy of the "comment" type | ||
| 3261 | $copiedType = $contentTypeService->copyContentType($commentType); | ||
| 3262 | /* END: Use Case */ | ||
| 3263 | |||
| 3264 | $this->assertInstanceOf( | ||
| 3265 | '\\eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentType', | ||
| 3266 | $copiedType | ||
| 3267 | ); | ||
| 3268 | |||
| 3269 | return [ | ||
| 3270 | 'originalType' => $commentType, | ||
| 3271 | 'copiedType' => $copiedType, | ||
| 3272 | ]; | ||
| 3273 | } | ||
| 3274 | |||
| 3275 | /** | ||
| 3276 | * Test for the copyContentType() method. | ||
| 3277 | * | ||
| 3278 | * @param array $data | ||
| 3279 | * | ||
| 3280 | * @see \eZ\Publish\API\Repository\ContentTypeService::copyContentType() | ||
| 3281 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCopyContentType | ||
| 3282 | */ | ||
| 3283 | public function testCopyContentTypeStructValues(array $data) | ||
| 3290 | |||
| 3291 | /** | ||
| 3292 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $originalType | ||
| 3293 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $copiedType | ||
| 3294 | * @param array $excludedProperties | ||
| 3295 | */ | ||
| 3296 | private function assertCopyContentTypeValues($originalType, $copiedType, $excludedProperties = []) | ||
| 3366 | |||
| 3367 | /** | ||
| 3368 | * Test for the copyContentType() method. | ||
| 3369 | * | ||
| 3370 | * @see \eZ\Publish\API\Repository\ContentTypeService::copyContentType($contentType, $user) | ||
| 3371 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCopyContentType | ||
| 3372 | */ | ||
| 3373 | public function testCopyContentTypeWithSecondParameter() | ||
| 3397 | |||
| 3398 | /** | ||
| 3399 | * Test for the assignContentTypeGroup() method. | ||
| 3400 | * | ||
| 3401 | * @see \eZ\Publish\API\Repository\ContentTypeService::assignContentTypeGroup() | ||
| 3402 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifier | ||
| 3403 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier | ||
| 3404 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentType | ||
| 3405 | */ | ||
| 3406 | public function testAssignContentTypeGroup() | ||
| 3433 | |||
| 3434 | /** | ||
| 3435 | * Test for the assignContentTypeGroup() method. | ||
| 3436 | * | ||
| 3437 | * @see \eZ\Publish\API\Repository\ContentTypeService::assignContentTypeGroup() | ||
| 3438 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAssignContentTypeGroup | ||
| 3439 | */ | ||
| 3440 | View Code Duplication | public function testAssignContentTypeGroupThrowsInvalidArgumentException() | |
| 3458 | |||
| 3459 | /** | ||
| 3460 | * Test for the unassignContentTypeGroup() method. | ||
| 3461 | * | ||
| 3462 | * @see \eZ\Publish\API\Repository\ContentTypeService::unassignContentTypeGroup() | ||
| 3463 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAssignContentTypeGroup | ||
| 3464 | */ | ||
| 3465 | public function testUnassignContentTypeGroup() | ||
| 3496 | |||
| 3497 | /** | ||
| 3498 | * Test for the unassignContentTypeGroup() method. | ||
| 3499 | * | ||
| 3500 | * @see \eZ\Publish\API\Repository\ContentTypeService::unassignContentTypeGroup() | ||
| 3501 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUnassignContentTypeGroup | ||
| 3502 | */ | ||
| 3503 | View Code Duplication | public function testUnassignContentTypeGroupThrowsInvalidArgumentException() | |
| 3519 | |||
| 3520 | /** | ||
| 3521 | * Test for the unassignContentTypeGroup() method. | ||
| 3522 | * | ||
| 3523 | * @see \eZ\Publish\API\Repository\ContentTypeService::unassignContentTypeGroup() | ||
| 3524 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUnassignContentTypeGroup | ||
| 3525 | */ | ||
| 3526 | View Code Duplication | public function testUnassignContentTypeGroupThrowsBadStateException() | |
| 3544 | |||
| 3545 | /** | ||
| 3546 | * Test for the createContentTypeGroup() method. | ||
| 3547 | * | ||
| 3548 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeGroup() | ||
| 3549 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup | ||
| 3550 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup | ||
| 3551 | */ | ||
| 3552 | View Code Duplication | public function testCreateContentTypeGroupInTransactionWithRollback() | |
| 3590 | |||
| 3591 | /** | ||
| 3592 | * Test for the createContentTypeGroup() method. | ||
| 3593 | * | ||
| 3594 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentTypeGroup() | ||
| 3595 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup | ||
| 3596 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup | ||
| 3597 | */ | ||
| 3598 | View Code Duplication | public function testCreateContentTypeGroupInTransactionWithCommit() | |
| 3632 | |||
| 3633 | /** | ||
| 3634 | * Test for the updateContentTypeGroup() method. | ||
| 3635 | * | ||
| 3636 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeGroup() | ||
| 3637 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeGroup | ||
| 3638 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifier | ||
| 3639 | */ | ||
| 3640 | public function testUpdateContentTypeGroupInTransactionWithRollback() | ||
| 3675 | |||
| 3676 | /** | ||
| 3677 | * Test for the updateContentTypeGroup() method. | ||
| 3678 | * | ||
| 3679 | * @see \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeGroup() | ||
| 3680 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testUpdateContentTypeGroup | ||
| 3681 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifier | ||
| 3682 | */ | ||
| 3683 | public function testUpdateContentTypeGroupInTransactionWithCommit() | ||
| 3720 | |||
| 3721 | /** | ||
| 3722 | * Test for the deleteContentTypeGroup() method. | ||
| 3723 | * | ||
| 3724 | * @see \eZ\Publish\API\Repository\ContentTypeService::deleteContentTypeGroup() | ||
| 3725 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testDeleteContentTypeGroup | ||
| 3726 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifierThrowsNotFoundException | ||
| 3727 | */ | ||
| 3728 | View Code Duplication | public function testDeleteContentTypeGroupWithRollback() | |
| 3768 | |||
| 3769 | /** | ||
| 3770 | * Test for the deleteContentTypeGroup() method. | ||
| 3771 | * | ||
| 3772 | * @see \eZ\Publish\API\Repository\ContentTypeService::deleteContentTypeGroup() | ||
| 3773 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testDeleteContentTypeGroup | ||
| 3774 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifierThrowsNotFoundException | ||
| 3775 | */ | ||
| 3776 | View Code Duplication | public function testDeleteContentTypeGroupWithCommit() | |
| 3816 | |||
| 3817 | /** | ||
| 3818 | * Test for the createContentType() method. | ||
| 3819 | * | ||
| 3820 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentType() | ||
| 3821 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 3822 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifierThrowsNotFoundException | ||
| 3823 | */ | ||
| 3824 | public function testCreateContentTypeInTransactionWithRollback() | ||
| 3876 | |||
| 3877 | /** | ||
| 3878 | * Test for the createContentType() method. | ||
| 3879 | * | ||
| 3880 | * @see \eZ\Publish\API\Repository\ContentTypeService::createContentType() | ||
| 3881 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentType | ||
| 3882 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifierThrowsNotFoundException | ||
| 3883 | */ | ||
| 3884 | public function testCreateContentTypeInTransactionWithCommit() | ||
| 3932 | |||
| 3933 | /** | ||
| 3934 | * Test for the copyContentType() method. | ||
| 3935 | * | ||
| 3936 | * @see \eZ\Publish\API\Repository\ContentTypeService::copyContentType() | ||
| 3937 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCopyContentType | ||
| 3938 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier | ||
| 3939 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException | ||
| 3940 | */ | ||
| 3941 | View Code Duplication | public function testCopyContentTypeInTransactionWithRollback() | |
| 3976 | |||
| 3977 | /** | ||
| 3978 | * Test for the copyContentType() method. | ||
| 3979 | * | ||
| 3980 | * @see \eZ\Publish\API\Repository\ContentTypeService::copyContentType() | ||
| 3981 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCopyContentType | ||
| 3982 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier | ||
| 3983 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException | ||
| 3984 | */ | ||
| 3985 | View Code Duplication | public function testCopyContentTypeInTransactionWithCommit() | |
| 4016 | |||
| 4017 | /** | ||
| 4018 | * Test for the deleteContentType() method. | ||
| 4019 | * | ||
| 4020 | * @see \eZ\Publish\API\Repository\ContentTypeService::deleteContentType() | ||
| 4021 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCopyContentType | ||
| 4022 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifierThrowsNotFoundException | ||
| 4023 | */ | ||
| 4024 | public function testDeleteContentTypeInTransactionWithRollback() | ||
| 4055 | |||
| 4056 | /** | ||
| 4057 | * Test for the deleteContentType() method. | ||
| 4058 | * | ||
| 4059 | * @see \eZ\Publish\API\Repository\ContentTypeService::deleteContentType() | ||
| 4060 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCopyContentType | ||
| 4061 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifierThrowsNotFoundException | ||
| 4062 | */ | ||
| 4063 | View Code Duplication | public function testDeleteContentTypeInTransactionWithCommit() | |
| 4098 | |||
| 4099 | /** | ||
| 4100 | * Test for the assignContentTypeGroup() method. | ||
| 4101 | * | ||
| 4102 | * @see \eZ\Publish\API\Repository\ContentTypeService::assignContentTypeGroup() | ||
| 4103 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAssignContentTypeGroup | ||
| 4104 | */ | ||
| 4105 | View Code Duplication | public function testAssignContentTypeGroupInTransactionWithRollback() | |
| 4144 | |||
| 4145 | /** | ||
| 4146 | * Test for the assignContentTypeGroup() method. | ||
| 4147 | * | ||
| 4148 | * @see \eZ\Publish\API\Repository\ContentTypeService::assignContentTypeGroup() | ||
| 4149 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testAssignContentTypeGroup | ||
| 4150 | */ | ||
| 4151 | View Code Duplication | public function testAssignContentTypeGroupInTransactionWithCommit() | |
| 4190 | |||
| 4191 | /** | ||
| 4192 | * Test for the isContentTypeUsed() method. | ||
| 4193 | * | ||
| 4194 | * @see \eZ\Publish\API\Repository\ContentTypeService::isContentTypeUsed() | ||
| 4195 | */ | ||
| 4196 | public function testIsContentTypeUsed() | ||
| 4213 | |||
| 4214 | /** | ||
| 4215 | * @covers \eZ\Publish\API\Repository\ContentTypeService::removeContentTypeTranslation | ||
| 4216 | * | ||
| 4217 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException | ||
| 4218 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException | ||
| 4219 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException | ||
| 4220 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException | ||
| 4221 | */ | ||
| 4222 | public function testRemoveContentTypeTranslation() | ||
| 4255 | |||
| 4256 | /** | ||
| 4257 | * @covers \eZ\Publish\API\Repository\ContentTypeService::removeContentTypeTranslation | ||
| 4258 | * | ||
| 4259 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException | ||
| 4260 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException | ||
| 4261 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException | ||
| 4262 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException | ||
| 4263 | */ | ||
| 4264 | public function testRemoveContentTypeTranslationWithMultilingualData() | ||
| 4318 | |||
| 4319 | /** | ||
| 4320 | * @covers \eZ\Publish\API\Repository\ContentTypeService::updateContentTypeDraft | ||
| 4321 | * | ||
| 4322 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException | ||
| 4323 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException | ||
| 4324 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException | ||
| 4325 | */ | ||
| 4326 | public function testUpdateContentTypeDraftWithNewTranslationWithMultilingualData() | ||
| 4449 | |||
| 4450 | /** | ||
| 4451 | * Test for the deleteUserDrafts() method. | ||
| 4452 | * | ||
| 4453 | * @see \eZ\Publish\API\Repository\ContentTypeService::deleteUserDrafts() | ||
| 4454 | */ | ||
| 4455 | View Code Duplication | public function testDeleteUserDrafts() | |
| 4470 | } | ||
| 4471 | 
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.