Code Duplication    Length = 18-23 lines in 4 locations

tests/ResolvesViewsTest.php 4 locations

@@ 103-124 (lines=22) @@
100
    /**
101
     * @test
102
     */
103
    public function it_can_use_the_config_for_default_layout_options()
104
    {
105
        // Add the view.
106
        $this->createView('configDefault');
107
108
        // Use the default layout.
109
        $this->loadLayout();
110
111
        // Set up the config entry to specify a view to use.
112
        $this->app['config']->set('jumpgate.view-resolution.layout_options.default', 'configDefault');
113
114
        // Call the route and get the auto view debug information.
115
        $this->call('GET', '/auto-route');
116
117
        $debug = viewResolver()->debug();
118
119
        // Assert.
120
        $this->assertEquals('configDefault', $debug->layout);
121
122
        // Clean up.
123
        $this->deleteView('configDefault');
124
    }
125
126
    /**
127
     * @test
@@ 129-149 (lines=21) @@
126
    /**
127
     * @test
128
     */
129
    public function it_can_automatically_resolve_a_view()
130
    {
131
        // Add the view.
132
        $this->makeViewDir('route');
133
        $this->createView('route/autoroute');
134
135
        // Use the default layout.
136
        $this->loadLayout();
137
138
        // Call the route and get the auto view debug information.
139
        $this->call('GET', '/auto-route');
140
141
        $debug = viewResolver()->debug();
142
143
        // Assert.
144
        $this->assertEquals('route.autoroute', $debug->view);
145
        $this->assertEquals('auto', $debug->type);
146
147
        // Clean up.
148
        $this->deleteViewDir('route');
149
    }
150
151
    /**
152
     * @test
@@ 172-189 (lines=18) @@
169
    /**
170
     * @test
171
     */
172
    public function it_can_manually_specify_a_layout()
173
    {
174
        // Add the view.
175
        $this->createView('testLayout');
176
177
        // Call the route and get the auto view debug information.
178
        $this->call('GET', '/manual-layout-route');
179
180
        $debug = viewResolver()->debug();
181
182
        // Assert.
183
        $this->assertEquals('test', $debug->view);
184
        $this->assertEquals('manual', $debug->type);
185
        $this->assertEquals('testLayout', $debug->layout);
186
187
        // Clean up.
188
        $this->deleteView('testLayout');
189
    }
190
191
    /**
192
     * @test
@@ 194-216 (lines=23) @@
191
    /**
192
     * @test
193
     */
194
    public function it_can_get_a_view_from_the_config()
195
    {
196
        // Add the view.
197
        $this->createView('configView');
198
199
        // Use the default layout.
200
        $this->loadLayout();
201
202
        // Set up the config entry to specify a view to use.
203
        $this->app['config']->set('jumpgate.view-resolution.view_locations.Tests\Resources\RouteController.autoroute', 'configView');
204
205
        // Call the route and get the auto view debug information.
206
        $this->call('GET', '/auto-route');
207
208
        $debug = viewResolver()->debug();
209
210
        // Asset.
211
        $this->assertEquals('configView', $debug->view);
212
        $this->assertEquals('config', $debug->type);
213
214
        // Clean up.
215
        $this->deleteView('configView');
216
    }
217
218
    private function loadLayout($boolean = true)
219
    {