Code Duplication    Length = 39-42 lines in 2 locations

eZ/Publish/Core/Repository/Tests/Service/Integration/ObjectStateBase.php 2 locations

@@ 429-470 (lines=42) @@
426
     *
427
     * @covers \eZ\Publish\API\Repository\ObjectStateService::createObjectState
428
     */
429
    public function testCreateObjectState()
430
    {
431
        $objectStateService = $this->repository->getObjectStateService();
432
433
        $group = $objectStateService->loadObjectStateGroup(2);
434
435
        $stateCreateStruct = $objectStateService->newObjectStateCreateStruct('test');
436
        $stateCreateStruct->priority = 2;
437
        $stateCreateStruct->defaultLanguageCode = 'eng-GB';
438
        $stateCreateStruct->names = array('eng-GB' => 'Test');
439
        $stateCreateStruct->descriptions = array('eng-GB' => 'Test description');
440
441
        $createdState = $objectStateService->createObjectState(
442
            $group,
443
            $stateCreateStruct
444
        );
445
446
        $this->assertInstanceOf(
447
            '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectState',
448
            $createdState
449
        );
450
451
        $this->assertPropertiesCorrect(
452
            array(
453
                'id' => 3,
454
                'identifier' => 'test',
455
                'priority' => 2,
456
                'defaultLanguageCode' => 'eng-GB',
457
                'languageCodes' => array('eng-GB'),
458
                'names' => array('eng-GB' => 'Test'),
459
                'descriptions' => array('eng-GB' => 'Test description'),
460
            ),
461
            $createdState
462
        );
463
464
        $this->assertInstanceOf(
465
            '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectStateGroup',
466
            $createdState->getObjectStateGroup()
467
        );
468
469
        $this->assertEquals($group->id, $createdState->getObjectStateGroup()->id);
470
    }
471
472
    /**
473
     * Test service method for creating object state in empty group.
@@ 601-639 (lines=39) @@
598
     *
599
     * @covers \eZ\Publish\API\Repository\ObjectStateService::updateObjectState
600
     */
601
    public function testUpdateObjectState()
602
    {
603
        $objectStateService = $this->repository->getObjectStateService();
604
605
        $stateUpdateStruct = $objectStateService->newObjectStateUpdateStruct();
606
        $stateUpdateStruct->identifier = 'test';
607
        $stateUpdateStruct->defaultLanguageCode = 'eng-GB';
608
        $stateUpdateStruct->names = array('eng-GB' => 'Test');
609
        $stateUpdateStruct->descriptions = array('eng-GB' => 'Test description');
610
611
        $state = $objectStateService->loadObjectState(1);
612
613
        $updatedState = $objectStateService->updateObjectState($state, $stateUpdateStruct);
614
615
        $this->assertInstanceOf(
616
            '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectState',
617
            $updatedState
618
        );
619
620
        $this->assertPropertiesCorrect(
621
            array(
622
                'id' => 1,
623
                'identifier' => 'test',
624
                'priority' => 0,
625
                'defaultLanguageCode' => 'eng-GB',
626
                'languageCodes' => array('eng-GB'),
627
                'names' => array('eng-GB' => 'Test'),
628
                'descriptions' => array('eng-GB' => 'Test description'),
629
            ),
630
            $updatedState
631
        );
632
633
        $this->assertInstanceOf(
634
            '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectStateGroup',
635
            $updatedState->getObjectStateGroup()
636
        );
637
638
        $this->assertEquals($state->getObjectStateGroup()->id, $updatedState->getObjectStateGroup()->id);
639
    }
640
641
    /**
642
     * Test service method for partially updating object state.