Code Duplication    Length = 30-30 lines in 2 locations

src/Bundle/ResourceBundle/Tests/Rest/View/EventSubscriber/GridViewSubscriberTest.php 1 location

@@ 120-149 (lines=30) @@
117
        $this->subscriber->onApi($event);
118
    }
119
120
    public function testApiWithGrid()
121
    {
122
        $this->parameterResolver
123
            ->expects($this->once())
124
            ->method('resolveApi')
125
            ->will($this->returnValue(true));
126
127
        $event = $this->createViewEventMock();
128
        $event
129
            ->expects($this->once())
130
            ->method('getView')
131
            ->will($this->returnValue($view = $this->createViewMock()));
132
133
        $view
134
            ->expects($this->once())
135
            ->method('getData')
136
            ->will($this->returnValue(['grid' => $gridView = $this->createGridViewMock()]));
137
138
        $gridView
139
            ->expects($this->once())
140
            ->method('getDataSource')
141
            ->will($this->returnValue($dataSource = 'data_source'));
142
143
        $view
144
            ->expects($this->once())
145
            ->method('setData')
146
            ->with($this->identicalTo($dataSource));
147
148
        $this->subscriber->onApi($event);
149
    }
150
151
    public function testViewWithApi()
152
    {

src/Bundle/ResourceBundle/Tests/Rest/View/EventSubscriber/PagerfantaViewSubscriberTest.php 1 location

@@ 126-155 (lines=30) @@
123
        $this->subscriber->onApi($event);
124
    }
125
126
    public function testApiWithPagerfanta()
127
    {
128
        $this->parameterResolver
129
            ->expects($this->once())
130
            ->method('resolveApi')
131
            ->will($this->returnValue(true));
132
133
        $event = $this->createViewEventMock();
134
        $event
135
            ->expects($this->once())
136
            ->method('getView')
137
            ->will($this->returnValue($view = $this->createViewMock()));
138
139
        $view
140
            ->expects($this->once())
141
            ->method('getData')
142
            ->will($this->returnValue($pagerfanta = $this->createPagerfantaMock()));
143
144
        $pagerfanta
145
            ->expects($this->once())
146
            ->method('getIterator')
147
            ->will($this->returnValue(new \ArrayIterator($values = ['value'])));
148
149
        $view
150
            ->expects($this->once())
151
            ->method('setData')
152
            ->with($this->identicalTo($values));
153
154
        $this->subscriber->onApi($event);
155
    }
156
157
    public function testApiWithHateoas()
158
    {