Code Duplication    Length = 23-28 lines in 6 locations

eZ/Publish/Core/Persistence/Legacy/Tests/Content/ContentHandlerTest.php 1 location

@@ 821-848 (lines=28) @@
818
    /**
819
     * @covers eZ\Publish\Core\Persistence\Legacy\Content\Handler::loadReverseRelations
820
     */
821
    public function testLoadReverseRelations()
822
    {
823
        $handler = $this->getContentHandler();
824
825
        $gatewayMock = $this->getGatewayMock();
826
        $mapperMock = $this->getMapperMock();
827
828
        $gatewayMock->expects($this->once())
829
            ->method('loadReverseRelations')
830
            ->with(
831
                $this->equalTo(23),
832
                $this->equalTo(null)
833
            )->will(
834
                $this->returnValue(array(42))
835
            );
836
837
        $mapperMock->expects($this->once())
838
            ->method('extractRelationsFromRows')
839
            ->with($this->equalTo(array(42)))
840
            ->will($this->returnValue($this->getRelationFixture()));
841
842
        $result = $handler->loadReverseRelations(23);
843
844
        $this->assertEquals(
845
            $result,
846
            $this->getRelationFixture()
847
        );
848
    }
849
850
    public function testAddRelation()
851
    {

eZ/Publish/Core/Persistence/Legacy/Tests/Content/ObjectState/ObjectStateHandlerTest.php 5 locations

@@ 76-98 (lines=23) @@
73
    /**
74
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::loadGroup
75
     */
76
    public function testLoadGroup()
77
    {
78
        $handler = $this->getObjectStateHandler();
79
        $mapperMock = $this->getMapperMock();
80
        $gatewayMock = $this->getGatewayMock();
81
82
        $gatewayMock->expects($this->once())
83
            ->method('loadObjectStateGroupData')
84
            ->with($this->equalTo(2))
85
            ->will($this->returnValue(array(array())));
86
87
        $mapperMock->expects($this->once())
88
            ->method('createObjectStateGroupFromData')
89
            ->with($this->equalTo(array(array())))
90
            ->will($this->returnValue($this->getObjectStateGroupFixture()));
91
92
        $result = $handler->loadGroup(2);
93
94
        $this->assertInstanceOf(
95
            'eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Group',
96
            $result
97
        );
98
    }
99
100
    /**
101
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::loadGroup
@@ 120-142 (lines=23) @@
117
    /**
118
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::loadGroupByIdentifier
119
     */
120
    public function testLoadGroupByIdentifier()
121
    {
122
        $handler = $this->getObjectStateHandler();
123
        $mapperMock = $this->getMapperMock();
124
        $gatewayMock = $this->getGatewayMock();
125
126
        $gatewayMock->expects($this->once())
127
            ->method('loadObjectStateGroupDataByIdentifier')
128
            ->with($this->equalTo('ez_lock'))
129
            ->will($this->returnValue(array(array())));
130
131
        $mapperMock->expects($this->once())
132
            ->method('createObjectStateGroupFromData')
133
            ->with($this->equalTo(array(array())))
134
            ->will($this->returnValue($this->getObjectStateGroupFixture()));
135
136
        $result = $handler->loadGroupByIdentifier('ez_lock');
137
138
        $this->assertInstanceOf(
139
            'eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Group',
140
            $result
141
        );
142
    }
143
144
    /**
145
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::loadGroupByIdentifier
@@ 340-362 (lines=23) @@
337
    /**
338
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::load
339
     */
340
    public function testLoad()
341
    {
342
        $handler = $this->getObjectStateHandler();
343
        $mapperMock = $this->getMapperMock();
344
        $gatewayMock = $this->getGatewayMock();
345
346
        $gatewayMock->expects($this->once())
347
            ->method('loadObjectStateData')
348
            ->with($this->equalTo(1))
349
            ->will($this->returnValue(array(array())));
350
351
        $mapperMock->expects($this->once())
352
            ->method('createObjectStateFromData')
353
            ->with($this->equalTo(array(array())))
354
            ->will($this->returnValue($this->getObjectStateFixture()));
355
356
        $result = $handler->load(1);
357
358
        $this->assertInstanceOf(
359
            'eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState',
360
            $result
361
        );
362
    }
363
364
    /**
365
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::load
@@ 384-406 (lines=23) @@
381
    /**
382
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::loadByIdentifier
383
     */
384
    public function testLoadByIdentifier()
385
    {
386
        $handler = $this->getObjectStateHandler();
387
        $mapperMock = $this->getMapperMock();
388
        $gatewayMock = $this->getGatewayMock();
389
390
        $gatewayMock->expects($this->once())
391
            ->method('loadObjectStateDataByIdentifier')
392
            ->with($this->equalTo('not_locked'), $this->equalTo(2))
393
            ->will($this->returnValue(array(array())));
394
395
        $mapperMock->expects($this->once())
396
            ->method('createObjectStateFromData')
397
            ->with($this->equalTo(array(array())))
398
            ->will($this->returnValue($this->getObjectStateFixture()));
399
400
        $result = $handler->loadByIdentifier('not_locked', 2);
401
402
        $this->assertInstanceOf(
403
            'eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState',
404
            $result
405
        );
406
    }
407
408
    /**
409
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::loadByIdentifier
@@ 597-619 (lines=23) @@
594
    /**
595
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::getContentState
596
     */
597
    public function testGetContentState()
598
    {
599
        $handler = $this->getObjectStateHandler();
600
        $mapperMock = $this->getMapperMock();
601
        $gatewayMock = $this->getGatewayMock();
602
603
        $gatewayMock->expects($this->once())
604
            ->method('loadObjectStateDataForContent')
605
            ->with($this->equalTo(42), $this->equalTo(2))
606
            ->will($this->returnValue(array(array())));
607
608
        $mapperMock->expects($this->once())
609
            ->method('createObjectStateFromData')
610
            ->with($this->equalTo(array(array())))
611
            ->will($this->returnValue($this->getObjectStateFixture()));
612
613
        $result = $handler->getContentState(42, 2);
614
615
        $this->assertInstanceOf(
616
            'eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState',
617
            $result
618
        );
619
    }
620
621
    /**
622
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::getContentCount