Code Duplication    Length = 25-26 lines in 2 locations

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

@@ 127-151 (lines=25) @@
124
     * @covers eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup
125
     * @depends testLoadGroup
126
     */
127
    public function testLoadGroupHasCache()
128
    {
129
        $expectedGroup = new SPIObjectStateGroup(
130
            array(
131
                'id' => 1,
132
                'identifier' => 'test_state_group',
133
                'name' => 'Test State Group',
134
            )
135
        );
136
137
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
138
        $this->cacheMock
139
            ->expects($this->once())
140
            ->method('getItem')
141
            ->with('objectstategroup', 1)
142
            ->will($this->returnValue($cacheItemMock));
143
        $cacheItemMock
144
            ->expects($this->once())
145
            ->method('get')
146
            ->will($this->returnValue($expectedGroup));
147
148
        $handler = $this->persistenceCacheHandler->objectStateHandler();
149
        $group = $handler->loadGroup(1);
150
        $this->assertEquals($group, $expectedGroup);
151
    }
152
153
    /**
154
     * @covers eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadGroupByIdentifier
@@ 668-693 (lines=26) @@
665
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load
666
     * @depends testLoad
667
     */
668
    public function testLoadCached()
669
    {
670
        $expectedState = new SPIObjectState(
671
            array(
672
                'id' => 1,
673
                'identifier' => 'test_state',
674
                'name' => 'Test State',
675
                'groupId' => 1,
676
            )
677
        );
678
679
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
680
        $this->cacheMock
681
            ->expects($this->once())
682
            ->method('getItem')
683
            ->with('objectstate', 1)
684
            ->will($this->returnValue($cacheItemMock));
685
        $cacheItemMock
686
            ->expects($this->once())
687
            ->method('get')
688
            ->will($this->returnValue($expectedState));
689
690
        $handler = $this->persistenceCacheHandler->objectStateHandler();
691
        $state = $handler->load(1);
692
        $this->assertEquals($state, $expectedState);
693
    }
694
695
    /**
696
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadByIdentifier