Code Duplication    Length = 25-26 lines in 2 locations

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

@@ 140-164 (lines=25) @@
137
     * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup
138
     * @depends testLoadGroup
139
     */
140
    public function testLoadGroupHasCache()
141
    {
142
        $expectedGroup = new SPIObjectStateGroup(
143
            array(
144
                'id' => 1,
145
                'identifier' => 'test_state_group',
146
                'name' => 'Test State Group',
147
            )
148
        );
149
150
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
151
        $this->cacheMock
152
            ->expects($this->once())
153
            ->method('getItem')
154
            ->with('objectstategroup', 1)
155
            ->will($this->returnValue($cacheItemMock));
156
        $cacheItemMock
157
            ->expects($this->once())
158
            ->method('get')
159
            ->will($this->returnValue($expectedGroup));
160
161
        $handler = $this->persistenceCacheHandler->objectStateHandler();
162
        $group = $handler->loadGroup(1);
163
        $this->assertEquals($group, $expectedGroup);
164
    }
165
166
    /**
167
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadGroupByIdentifier
@@ 616-641 (lines=26) @@
613
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load
614
     * @depends testLoad
615
     */
616
    public function testLoadCached()
617
    {
618
        $expectedState = new SPIObjectState(
619
            array(
620
                'id' => 1,
621
                'identifier' => 'test_state',
622
                'name' => 'Test State',
623
                'groupId' => 1,
624
            )
625
        );
626
627
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
628
        $this->cacheMock
629
            ->expects($this->once())
630
            ->method('getItem')
631
            ->with('objectstate', 1)
632
            ->will($this->returnValue($cacheItemMock));
633
        $cacheItemMock
634
            ->expects($this->once())
635
            ->method('get')
636
            ->will($this->returnValue($expectedState));
637
638
        $handler = $this->persistenceCacheHandler->objectStateHandler();
639
        $state = $handler->load(1);
640
        $this->assertEquals($state, $expectedState);
641
    }
642
643
    /**
644
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::loadByIdentifier