@@ 308-331 (lines=24) @@ | ||
305 | * @see \eZ\Publish\API\Repository\RoleService::createRoleDraft() |
|
306 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testNewRoleCreateStruct |
|
307 | */ |
|
308 | public function testCreateRoleDraft() |
|
309 | { |
|
310 | $repository = $this->getRepository(); |
|
311 | ||
312 | /* BEGIN: Use Case */ |
|
313 | ||
314 | $roleService = $repository->getRoleService(); |
|
315 | $roleCreate = $roleService->newRoleCreateStruct('roleName'); |
|
316 | ||
317 | // @todo uncomment when support for multilingual names and descriptions is added EZP-24776 |
|
318 | // $roleCreate->mainLanguageCode = 'eng-US'; |
|
319 | ||
320 | $roleDraft = $roleService->createRole($roleCreate); |
|
321 | $roleService->publishRoleDraft($roleDraft); |
|
322 | $role = $roleService->loadRole($roleDraft->id); |
|
323 | $newRoleDraft = $roleService->createRoleDraft($role); |
|
324 | ||
325 | /* END: Use Case */ |
|
326 | ||
327 | $this->assertInstanceOf( |
|
328 | '\\eZ\\Publish\\API\\Repository\\Values\\User\\RoleDraft', |
|
329 | $newRoleDraft |
|
330 | ); |
|
331 | } |
|
332 | ||
333 | /** |
|
334 | * Test for the createRole() method. |
|
@@ 365-388 (lines=24) @@ | ||
362 | * @see \eZ\Publish\API\Repository\RoleService::createRoleDraft() |
|
363 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRoleDraft |
|
364 | */ |
|
365 | public function testCreateRoleDraftThrowsInvalidArgumentException() |
|
366 | { |
|
367 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class); |
|
368 | ||
369 | $repository = $this->getRepository(); |
|
370 | ||
371 | /* BEGIN: Use Case */ |
|
372 | ||
373 | $roleService = $repository->getRoleService(); |
|
374 | $roleCreate = $roleService->newRoleCreateStruct('Editor'); |
|
375 | ||
376 | // @todo uncomment when support for multilingual names and descriptions is added EZP-24776 |
|
377 | // $roleCreate->mainLanguageCode = 'eng-US'; |
|
378 | ||
379 | $roleDraft = $roleService->createRole($roleCreate); |
|
380 | $roleService->publishRoleDraft($roleDraft); |
|
381 | $role = $roleService->loadRole($roleDraft->id); |
|
382 | $roleService->createRoleDraft($role); // First role draft |
|
383 | ||
384 | // This call will fail with an InvalidArgumentException, because there is already a draft |
|
385 | $roleService->createRoleDraft($role); |
|
386 | ||
387 | /* END: Use Case */ |
|
388 | } |
|
389 | ||
390 | /** |
|
391 | * Test for the createRole() method. |