Code Duplication    Length = 52-53 lines in 2 locations

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

@@ 95-146 (lines=52) @@
92
    /**
93
     * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup
94
     */
95
    public function testLoadGroup()
96
    {
97
        $expectedGroup = new SPIObjectStateGroup(
98
            array(
99
                'id' => 1,
100
                'identifier' => 'test_state_group',
101
                'name' => 'Test State Group',
102
            )
103
        );
104
105
        $cacheItemMock = $this->getCacheItemMock();
106
        $this->cacheMock
107
            ->expects($this->once())
108
            ->method('getItem')
109
            ->with('objectstategroup', 1)
110
            ->will($this->returnValue($cacheItemMock));
111
        $cacheItemMock
112
            ->expects($this->once())
113
            ->method('get')
114
            ->will($this->returnValue(null));
115
        $cacheItemMock
116
            ->expects($this->once())
117
            ->method('isMiss')
118
            ->will($this->returnValue(true));
119
        $cacheItemMock
120
            ->expects($this->once())
121
            ->method('set')
122
            ->with($this->isInstanceOf(SPIObjectStateGroup::class))
123
            ->will($this->returnValue($cacheItemMock));
124
        $cacheItemMock
125
            ->expects($this->once())
126
            ->method('save')
127
            ->with();
128
129
        $this->loggerMock->expects($this->once())->method('logCall');
130
131
        $innerHandlerMock = $this->getSPIObjectStateHandler();
132
        $this->persistenceHandlerMock
133
            ->expects($this->once())
134
            ->method('objectStateHandler')
135
            ->will($this->returnValue($innerHandlerMock));
136
137
        $innerHandlerMock
138
            ->expects($this->once())
139
            ->method('loadGroup')
140
            ->with(1)
141
            ->will($this->returnValue($expectedGroup));
142
143
        $handler = $this->persistenceCacheHandler->objectStateHandler();
144
        $group = $handler->loadGroup(1);
145
        $this->assertEquals($group, $expectedGroup);
146
    }
147
148
    /**
149
     * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup
@@ 596-648 (lines=53) @@
593
    /**
594
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load
595
     */
596
    public function testLoad()
597
    {
598
        $expectedState = new SPIObjectState(
599
            array(
600
                'id' => 1,
601
                'identifier' => 'test_state',
602
                'name' => 'Test State',
603
                'groupId' => 1,
604
            )
605
        );
606
607
        $cacheItemMock = $this->getCacheItemMock();
608
        $this->cacheMock
609
            ->expects($this->once())
610
            ->method('getItem')
611
            ->with('objectstate', 1)
612
            ->will($this->returnValue($cacheItemMock));
613
        $cacheItemMock
614
            ->expects($this->once())
615
            ->method('get')
616
            ->will($this->returnValue(null));
617
        $cacheItemMock
618
            ->expects($this->once())
619
            ->method('isMiss')
620
            ->will($this->returnValue(true));
621
        $cacheItemMock
622
            ->expects($this->once())
623
            ->method('set')
624
            ->with($this->isInstanceOf(SPIObjectState::class))
625
            ->will($this->returnValue($cacheItemMock));
626
        $cacheItemMock
627
            ->expects($this->once())
628
            ->method('save')
629
            ->with();
630
631
        $this->loggerMock->expects($this->once())->method('logCall');
632
633
        $innerHandlerMock = $this->getSPIObjectStateHandler();
634
        $this->persistenceHandlerMock
635
            ->expects($this->once())
636
            ->method('objectStateHandler')
637
            ->will($this->returnValue($innerHandlerMock));
638
639
        $innerHandlerMock
640
            ->expects($this->once())
641
            ->method('load')
642
            ->with(1)
643
            ->will($this->returnValue($expectedState));
644
645
        $handler = $this->persistenceCacheHandler->objectStateHandler();
646
        $state = $handler->load(1);
647
        $this->assertEquals($state, $expectedState);
648
    }
649
650
    /**
651
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load