Completed
Pull Request — master (#194)
by Alex
09:29 queued 02:52
created

InfrastructureTest::testCanGetServiceMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: alex
5
 * Date: 1/02/20
6
 * Time: 3:03 PM
7
 */
8
9
namespace AlgoWeb\PODataLaravel\Orchestra\Tests\Unit;
10
11
use AlgoWeb\PODataLaravel\Orchestra\Tests\Models\OrchestraTestModel;
12
use AlgoWeb\PODataLaravel\Orchestra\Tests\TestCase;
13
use AlgoWeb\PODataLaravel\Providers\MetadataProvider;
14
use Illuminate\Foundation\Testing\DatabaseMigrations;
15
use Illuminate\Support\Facades\App;
16
17
class InfrastructureTest extends TestCase
18
{
19
    public function testCanSaveOrchestraTestModel()
20
    {
21
        $foo = new OrchestraTestModel();
22
        $this->assertTrue($foo->save());
23
24
        $this->assertEquals(1, OrchestraTestModel::count());
25
    }
26
27
    public function testCanGetServiceDoc()
28
    {
29
        $url = 'odata.svc/';
30
31
        $result = $this->get($url);
32
        $this->assertEquals(200, $result->getStatusCode());
33
        $this->assertContains('OrchestraTestModel', $result->getContent());
34
    }
35
36
    public function testCanGetServiceMetadata()
37
    {
38
        $url = 'odata.svc/$metadata';
39
40
        $result = $this->get($url);
41
        $this->assertEquals(200, $result->getStatusCode());
42
    }
43
44
    /**
45
     * @throws \ReflectionException
46
     */
47
    public function testGetCandidateModels()
48
    {
49
        $app = App::make('app');
50
        $foo = new MetadataProvider($app);
51
52
        $reflec = new \ReflectionClass($foo);
0 ignored issues
show
Unused Code introduced by
The assignment to $reflec is dead and can be removed.
Loading history...
53
        $prop = new \ReflectionMethod($foo, 'getCandidateModels');
54
        $prop->setAccessible(true);
55
        $cand = $prop->invoke($foo);
56
        $this->assertTrue(0 < count($cand), 'Candidate model list empty');
57
    }
58
}
59