|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Bukashk0zzzYmlGenerator |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Denis Golubovskiy <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Bukashk0zzz\YmlGenerator\Tests; |
|
13
|
|
|
|
|
14
|
|
|
use Bukashk0zzz\YmlGenerator\Generator; |
|
15
|
|
|
use Bukashk0zzz\YmlGenerator\Model\ShopInfo; |
|
16
|
|
|
use Bukashk0zzz\YmlGenerator\Settings; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Generator test |
|
20
|
|
|
*/ |
|
21
|
|
|
class GeneratorTest extends \PHPUnit_Framework_TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @expectedException \RuntimeException |
|
25
|
|
|
*/ |
|
26
|
|
|
public function testExceptionForIncompatibleAnnotations() |
|
27
|
|
|
{ |
|
28
|
|
|
(new Generator((new Settings())->setOutputFile(''))) |
|
29
|
|
|
->generate(new ShopInfo(), [], [], []) |
|
30
|
|
|
; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @expectedException \LogicException |
|
35
|
|
|
*/ |
|
36
|
|
|
public function testExceptionIfManyDestinationUsed() |
|
37
|
|
|
{ |
|
38
|
|
|
$settings = (new Settings()) |
|
39
|
|
|
->setOutputFile('') |
|
40
|
|
|
->setReturnResultYMLString(true) |
|
41
|
|
|
; |
|
42
|
|
|
|
|
43
|
|
|
(new Generator($settings)) |
|
44
|
|
|
->generate(new ShopInfo(), [], [], []) |
|
45
|
|
|
; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Test equal returned value and printed |
|
50
|
|
|
*/ |
|
51
|
|
|
public function testGenerationEchoValueEqualsReturnValue() |
|
52
|
|
|
{ |
|
53
|
|
|
$settings = (new Settings()) |
|
54
|
|
|
->setReturnResultYMLString(true) |
|
55
|
|
|
; |
|
56
|
|
|
$value = (new Generator($settings)) |
|
57
|
|
|
->generate(new ShopInfo(), [], [], [], []); |
|
58
|
|
|
|
|
59
|
|
|
\ob_start(); |
|
60
|
|
|
(new Generator(new Settings())) |
|
61
|
|
|
->generate(new ShopInfo(), [], [], [], []); |
|
62
|
|
|
$value2 = \ob_get_clean(); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertEquals($value, $value2); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|