Code Duplication    Length = 43-47 lines in 2 locations

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

@@ 597-639 (lines=43) @@
594
     * @covers \eZ\Publish\API\Repository\ObjectStateService::updateObjectStateGroup
595
     * @depends eZ\Publish\API\Repository\Tests\ObjectStateServiceTest::testLoadObjectStateGroup
596
     */
597
    public function testUpdateObjectStateGroup()
598
    {
599
        $repository = $this->getRepository();
600
601
        $objectStateGroupId = $this->generateId('objectstategroup', 2);
602
        /* BEGIN: Use Case */
603
        // $objectStateGroupId contains the ID of the standard object state
604
        // group ez_lock.
605
        $objectStateService = $repository->getObjectStateService();
606
607
        $loadedObjectStateGroup = $objectStateService->loadObjectStateGroup(
608
            $objectStateGroupId
609
        );
610
611
        $groupUpdateStruct = $objectStateService->newObjectStateGroupUpdateStruct();
612
        $groupUpdateStruct->identifier = 'sindelfingen';
613
        $groupUpdateStruct->defaultLanguageCode = 'ger-DE';
614
        $groupUpdateStruct->names = array(
615
            'ger-DE' => 'Sindelfingen',
616
        );
617
        $groupUpdateStruct->descriptions = array(
618
            'ger-DE' => 'Sindelfingen ist nicht nur eine Stadt',
619
        );
620
621
        // Updates the $loadObjectStateGroup with the data from
622
        // $groupUpdateStruct and returns the updated group
623
        $updatedObjectStateGroup = $objectStateService->updateObjectStateGroup(
624
            $loadedObjectStateGroup,
625
            $groupUpdateStruct
626
        );
627
        /* END: Use Case */
628
629
        $this->assertInstanceOf(
630
            '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectStateGroup',
631
            $updatedObjectStateGroup
632
        );
633
634
        return array(
635
            $loadedObjectStateGroup,
636
            $groupUpdateStruct,
637
            $updatedObjectStateGroup,
638
        );
639
    }
640
641
    /**
642
     * Test service method for partially updating object state group.
@@ 761-807 (lines=47) @@
758
     * @depends testLoadObjectStateGroup
759
     * @depends testNewObjectStateCreateStruct
760
     */
761
    public function testCreateObjectState()
762
    {
763
        $repository = $this->getRepository();
764
765
        $objectStateGroupId = $this->generateId('objectstategroup', 2);
766
        /* BEGIN: Use Case */
767
        // $objectStateGroupId contains the ID of the standard object state
768
        // group ez_lock.
769
        $objectStateService = $repository->getObjectStateService();
770
771
        $loadedObjectStateGroup = $objectStateService->loadObjectStateGroup(
772
            $objectStateGroupId
773
        );
774
775
        $objectStateCreateStruct = $objectStateService->newObjectStateCreateStruct(
776
            'locked_and_unlocked'
777
        );
778
        $objectStateCreateStruct->priority = 23;
779
        $objectStateCreateStruct->defaultLanguageCode = 'eng-US';
780
        $objectStateCreateStruct->names = array(
781
            'eng-US' => 'Locked and Unlocked',
782
        );
783
        $objectStateCreateStruct->descriptions = array(
784
            'eng-US' => 'A state between locked and unlocked.',
785
        );
786
787
        // Creates a new object state in the $loadObjectStateGroup with the
788
        // data from $objectStateCreateStruct
789
        $createdObjectState = $objectStateService->createObjectState(
790
            $loadedObjectStateGroup,
791
            $objectStateCreateStruct
792
        );
793
        /* END: Use Case */
794
795
        $this->assertInstanceOf(
796
            '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectState',
797
            $createdObjectState
798
        );
799
        // Object sequences are renumbered
800
        $objectStateCreateStruct->priority = 2;
801
802
        return array(
803
            $loadedObjectStateGroup,
804
            $objectStateCreateStruct,
805
            $createdObjectState,
806
        );
807
    }
808
809
    /**
810
     * Test service method for creating object state in empty group.