Code Duplication    Length = 52-53 lines in 2 locations

eZ/Publish/Core/Persistence/Cache/Tests/ObjectStateHandlerTest.php 2 locations

@@ 85-136 (lines=52) @@
82
    /**
83
     * @covers eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup
84
     */
85
    public function testLoadGroup()
86
    {
87
        $expectedGroup = new SPIObjectStateGroup(
88
            array(
89
                'id' => 1,
90
                'identifier' => 'test_state_group',
91
                'name' => 'Test State Group',
92
            )
93
        );
94
95
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
96
        $this->cacheMock
97
            ->expects($this->once())
98
            ->method('getItem')
99
            ->with('objectstategroup', 1)
100
            ->will($this->returnValue($cacheItemMock));
101
        $cacheItemMock
102
            ->expects($this->once())
103
            ->method('get')
104
            ->will($this->returnValue(null));
105
        $cacheItemMock
106
            ->expects($this->once())
107
            ->method('isMiss')
108
            ->will($this->returnValue(true));
109
        $cacheItemMock
110
            ->expects($this->once())
111
            ->method('set')
112
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Group'))
113
            ->will($this->returnValue($cacheItemMock));
114
        $cacheItemMock
115
            ->expects($this->once())
116
            ->method('save')
117
            ->with();
118
119
        $this->loggerMock->expects($this->once())->method('logCall');
120
121
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler');
122
        $this->persistenceHandlerMock
123
            ->expects($this->once())
124
            ->method('objectStateHandler')
125
            ->will($this->returnValue($innerHandlerMock));
126
127
        $innerHandlerMock
128
            ->expects($this->once())
129
            ->method('loadGroup')
130
            ->with(1)
131
            ->will($this->returnValue($expectedGroup));
132
133
        $handler = $this->persistenceCacheHandler->objectStateHandler();
134
        $group = $handler->loadGroup(1);
135
        $this->assertEquals($group, $expectedGroup);
136
    }
137
138
    /**
139
     * @covers eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup
@@ 652-704 (lines=53) @@
649
    /**
650
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load
651
     */
652
    public function testLoad()
653
    {
654
        $expectedState = new SPIObjectState(
655
            array(
656
                'id' => 1,
657
                'identifier' => 'test_state',
658
                'name' => 'Test State',
659
                'groupId' => 1,
660
            )
661
        );
662
663
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
664
        $this->cacheMock
665
            ->expects($this->once())
666
            ->method('getItem')
667
            ->with('objectstate', 1)
668
            ->will($this->returnValue($cacheItemMock));
669
        $cacheItemMock
670
            ->expects($this->once())
671
            ->method('get')
672
            ->will($this->returnValue(null));
673
        $cacheItemMock
674
            ->expects($this->once())
675
            ->method('isMiss')
676
            ->will($this->returnValue(true));
677
        $cacheItemMock
678
            ->expects($this->once())
679
            ->method('set')
680
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState'))
681
            ->will($this->returnValue($cacheItemMock));
682
        $cacheItemMock
683
            ->expects($this->once())
684
            ->method('save')
685
            ->with();
686
687
        $this->loggerMock->expects($this->once())->method('logCall');
688
689
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler');
690
        $this->persistenceHandlerMock
691
            ->expects($this->once())
692
            ->method('objectStateHandler')
693
            ->will($this->returnValue($innerHandlerMock));
694
695
        $innerHandlerMock
696
            ->expects($this->once())
697
            ->method('load')
698
            ->with(1)
699
            ->will($this->returnValue($expectedState));
700
701
        $handler = $this->persistenceCacheHandler->objectStateHandler();
702
        $state = $handler->load(1);
703
        $this->assertEquals($state, $expectedState);
704
    }
705
706
    /**
707
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load