1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of graze/sprout. |
4
|
|
|
* |
5
|
|
|
* Copyright © 2018 Nature Delivered Ltd. <https://www.graze.com> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @license https://github.com/graze/sprout/blob/master/LICENSE.md |
11
|
|
|
* @link https://github.com/graze/sprout |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Graze\Sprout\Test\Unit\Parser; |
15
|
|
|
|
16
|
|
|
use Graze\Sprout\Config\SchemaConfigInterface; |
17
|
|
|
use Graze\Sprout\Parser\ParsedSchema; |
18
|
|
|
use Graze\Sprout\Test\TestCase; |
19
|
|
|
use Mockery; |
20
|
|
|
|
21
|
|
|
class ParsedSchemaTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
public function testConstructor() |
24
|
|
|
{ |
25
|
|
|
$configuration = Mockery::mock(SchemaConfigInterface::class); |
26
|
|
|
$configuration->allows() |
27
|
|
|
->getSchema() |
|
|
|
|
28
|
|
|
->andReturns('the_schema'); |
29
|
|
|
$parsedSchema = new ParsedSchema($configuration, 'path', ['table1', 'table2']); |
|
|
|
|
30
|
|
|
|
31
|
|
|
$this->assertSame($configuration, $parsedSchema->getSchemaConfig()); |
32
|
|
|
$this->assertEquals('the_schema', $parsedSchema->getSchemaName()); |
33
|
|
|
$this->assertEquals('path', $parsedSchema->getPath()); |
34
|
|
|
$this->assertEquals(['table1', 'table2'], $parsedSchema->getTables()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testTheTablesCanBeChanged() |
38
|
|
|
{ |
39
|
|
|
$configuration = Mockery::mock(SchemaConfigInterface::class); |
40
|
|
|
$parsedSchema = new ParsedSchema($configuration, 'path', []); |
|
|
|
|
41
|
|
|
|
42
|
|
|
$this->assertSame($configuration, $parsedSchema->getSchemaConfig()); |
43
|
|
|
$this->assertEquals([], $parsedSchema->getTables()); |
44
|
|
|
|
45
|
|
|
$this->assertSame($parsedSchema, $parsedSchema->setTables(['table1', 'table2', 'table3'])); |
46
|
|
|
$this->assertEquals(['table1', 'table2', 'table3'], $parsedSchema->getTables()); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|