Code Duplication    Length = 52-53 lines in 2 locations

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

@@ 83-134 (lines=52) @@
80
    /**
81
     * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup
82
     */
83
    public function testLoadGroup()
84
    {
85
        $expectedGroup = new SPIObjectStateGroup(
86
            array(
87
                'id' => 1,
88
                'identifier' => 'test_state_group',
89
                'name' => 'Test State Group',
90
            )
91
        );
92
93
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
94
        $this->cacheMock
95
            ->expects($this->once())
96
            ->method('getItem')
97
            ->with('objectstategroup', 1)
98
            ->will($this->returnValue($cacheItemMock));
99
        $cacheItemMock
100
            ->expects($this->once())
101
            ->method('get')
102
            ->will($this->returnValue(null));
103
        $cacheItemMock
104
            ->expects($this->once())
105
            ->method('isMiss')
106
            ->will($this->returnValue(true));
107
        $cacheItemMock
108
            ->expects($this->once())
109
            ->method('set')
110
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Group'))
111
            ->will($this->returnValue($cacheItemMock));
112
        $cacheItemMock
113
            ->expects($this->once())
114
            ->method('save')
115
            ->with();
116
117
        $this->loggerMock->expects($this->once())->method('logCall');
118
119
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler');
120
        $this->persistenceHandlerMock
121
            ->expects($this->once())
122
            ->method('objectStateHandler')
123
            ->will($this->returnValue($innerHandlerMock));
124
125
        $innerHandlerMock
126
            ->expects($this->once())
127
            ->method('loadGroup')
128
            ->with(1)
129
            ->will($this->returnValue($expectedGroup));
130
131
        $handler = $this->persistenceCacheHandler->objectStateHandler();
132
        $group = $handler->loadGroup(1);
133
        $this->assertEquals($group, $expectedGroup);
134
    }
135
136
    /**
137
     * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup
@@ 617-669 (lines=53) @@
614
    /**
615
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load
616
     */
617
    public function testLoad()
618
    {
619
        $expectedState = new SPIObjectState(
620
            array(
621
                'id' => 1,
622
                'identifier' => 'test_state',
623
                'name' => 'Test State',
624
                'groupId' => 1,
625
            )
626
        );
627
628
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
629
        $this->cacheMock
630
            ->expects($this->once())
631
            ->method('getItem')
632
            ->with('objectstate', 1)
633
            ->will($this->returnValue($cacheItemMock));
634
        $cacheItemMock
635
            ->expects($this->once())
636
            ->method('get')
637
            ->will($this->returnValue(null));
638
        $cacheItemMock
639
            ->expects($this->once())
640
            ->method('isMiss')
641
            ->will($this->returnValue(true));
642
        $cacheItemMock
643
            ->expects($this->once())
644
            ->method('set')
645
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState'))
646
            ->will($this->returnValue($cacheItemMock));
647
        $cacheItemMock
648
            ->expects($this->once())
649
            ->method('save')
650
            ->with();
651
652
        $this->loggerMock->expects($this->once())->method('logCall');
653
654
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler');
655
        $this->persistenceHandlerMock
656
            ->expects($this->once())
657
            ->method('objectStateHandler')
658
            ->will($this->returnValue($innerHandlerMock));
659
660
        $innerHandlerMock
661
            ->expects($this->once())
662
            ->method('load')
663
            ->with(1)
664
            ->will($this->returnValue($expectedState));
665
666
        $handler = $this->persistenceCacheHandler->objectStateHandler();
667
        $state = $handler->load(1);
668
        $this->assertEquals($state, $expectedState);
669
    }
670
671
    /**
672
     * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load