Code Duplication    Length = 43-47 lines in 2 locations

eZ/Publish/API/Repository/Tests/ObjectStateServiceTest.php 2 locations

@@ 588-630 (lines=43) @@
585
     * @see \eZ\Publish\API\Repository\ObjectStateService::updateObjectStateGroup()
586
     * @depends testLoadObjectStateGroup
587
     */
588
    public function testUpdateObjectStateGroup()
589
    {
590
        $repository = $this->getRepository();
591
592
        $objectStateGroupId = $this->generateId('objectstategroup', 2);
593
        /* BEGIN: Use Case */
594
        // $objectStateGroupId contains the ID of the standard object state
595
        // group ez_lock.
596
        $objectStateService = $repository->getObjectStateService();
597
598
        $loadedObjectStateGroup = $objectStateService->loadObjectStateGroup(
599
            $objectStateGroupId
600
        );
601
602
        $groupUpdateStruct = $objectStateService->newObjectStateGroupUpdateStruct();
603
        $groupUpdateStruct->identifier = 'sindelfingen';
604
        $groupUpdateStruct->defaultLanguageCode = 'ger-DE';
605
        $groupUpdateStruct->names = array(
606
            'ger-DE' => 'Sindelfingen',
607
        );
608
        $groupUpdateStruct->descriptions = array(
609
            'ger-DE' => 'Sindelfingen ist nicht nur eine Stadt',
610
        );
611
612
        // Updates the $loadObjectStateGroup with the data from
613
        // $groupUpdateStruct and returns the updated group
614
        $updatedObjectStateGroup = $objectStateService->updateObjectStateGroup(
615
            $loadedObjectStateGroup,
616
            $groupUpdateStruct
617
        );
618
        /* END: Use Case */
619
620
        $this->assertInstanceOf(
621
            '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectStateGroup',
622
            $updatedObjectStateGroup
623
        );
624
625
        return array(
626
            $loadedObjectStateGroup,
627
            $groupUpdateStruct,
628
            $updatedObjectStateGroup,
629
        );
630
    }
631
632
    /**
633
     * Test for the updateObjectStateGroup() method.
@@ 712-758 (lines=47) @@
709
     * @depends testLoadObjectStateGroup
710
     * @depends testNewObjectStateCreateStruct
711
     */
712
    public function testCreateObjectState()
713
    {
714
        $repository = $this->getRepository();
715
716
        $objectStateGroupId = $this->generateId('objectstategroup', 2);
717
        /* BEGIN: Use Case */
718
        // $objectStateGroupId contains the ID of the standard object state
719
        // group ez_lock.
720
        $objectStateService = $repository->getObjectStateService();
721
722
        $loadedObjectStateGroup = $objectStateService->loadObjectStateGroup(
723
            $objectStateGroupId
724
        );
725
726
        $objectStateCreateStruct = $objectStateService->newObjectStateCreateStruct(
727
            'locked_and_unlocked'
728
        );
729
        $objectStateCreateStruct->priority = 23;
730
        $objectStateCreateStruct->defaultLanguageCode = 'eng-US';
731
        $objectStateCreateStruct->names = array(
732
            'eng-US' => 'Locked and Unlocked',
733
        );
734
        $objectStateCreateStruct->descriptions = array(
735
            'eng-US' => 'A state between locked and unlocked.',
736
        );
737
738
        // Creates a new object state in the $loadObjectStateGroup with the
739
        // data from $objectStateCreateStruct
740
        $createdObjectState = $objectStateService->createObjectState(
741
            $loadedObjectStateGroup,
742
            $objectStateCreateStruct
743
        );
744
        /* END: Use Case */
745
746
        $this->assertInstanceOf(
747
            '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectState',
748
            $createdObjectState
749
        );
750
        // Object sequences are renumbered
751
        $objectStateCreateStruct->priority = 2;
752
753
        return array(
754
            $loadedObjectStateGroup,
755
            $objectStateCreateStruct,
756
            $createdObjectState,
757
        );
758
    }
759
760
    /**
761
     * Test for the createObjectState() method.