Code Duplication    Length = 16-33 lines in 2 locations

eZ/Publish/API/Repository/Tests/ObjectStateServiceTest.php 1 location

@@ 769-801 (lines=33) @@
766
     * @depends testLoadObjectStateGroup
767
     * @depends testCreateObjectState
768
     */
769
    public function testCreateObjectStateThrowsInvalidArgumentException()
770
    {
771
        $repository = $this->getRepository();
772
773
        $objectStateGroupId = $this->generateId('objectstategroup', 2);
774
        // $objectStateGroupId contains the ID of the standard object state
775
        // group ez_lock.
776
        $objectStateService = $repository->getObjectStateService();
777
778
        $loadedObjectStateGroup = $objectStateService->loadObjectStateGroup(
779
            $objectStateGroupId
780
        );
781
782
        $objectStateCreateStruct = $objectStateService->newObjectStateCreateStruct(
783
            // 'not_locked' is the identifier of already existing state
784
            'not_locked'
785
        );
786
        $objectStateCreateStruct->priority = 23;
787
        $objectStateCreateStruct->defaultLanguageCode = 'eng-US';
788
        $objectStateCreateStruct->names = array(
789
            'eng-US' => 'Locked and Unlocked',
790
        );
791
        $objectStateCreateStruct->descriptions = array(
792
            'eng-US' => 'A state between locked and unlocked.',
793
        );
794
795
        // This call will fail because object state with
796
        // 'not_locked' identifier already exists
797
        $objectStateService->createObjectState(
798
            $loadedObjectStateGroup,
799
            $objectStateCreateStruct
800
        );
801
    }
802
803
    /**
804
     * testCreateObjectStateStructValues.

eZ/Publish/Core/Repository/Tests/Service/Integration/ObjectStateBase.php 1 location

@@ 372-387 (lines=16) @@
369
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
370
     * @covers \eZ\Publish\API\Repository\ObjectStateService::updateObjectStateGroup
371
     */
372
    public function testUpdateObjectStateGroupThrowsInvalidArgumentException()
373
    {
374
        $objectStateService = $this->repository->getObjectStateService();
375
376
        $groupCreateStruct = $objectStateService->newObjectStateGroupCreateStruct('test');
377
        $groupCreateStruct->defaultLanguageCode = 'eng-GB';
378
        $groupCreateStruct->names = array('eng-GB' => 'Test');
379
        $groupCreateStruct->descriptions = array('eng-GB' => 'Test description');
380
381
        $createdGroup = $objectStateService->createObjectStateGroup($groupCreateStruct);
382
383
        $groupUpdateStruct = $objectStateService->newObjectStateGroupUpdateStruct();
384
        $groupUpdateStruct->identifier = 'ez_lock';
385
386
        $objectStateService->updateObjectStateGroup($createdGroup, $groupUpdateStruct);
387
    }
388
389
    /**
390
     * Test service method for deleting object state group.