|
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); |
|
|
|
|
|
|
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
|
|
|
|