1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MathieuTu\Exporter\Tests; |
4
|
|
|
|
5
|
|
|
use MathieuTu\Exporter\Tests\Fixtures\Model; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
class ExporterTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
public function testExport() |
11
|
|
|
{ |
12
|
|
|
$this->assertSame( |
13
|
|
|
$this->expectedExport(), |
14
|
|
|
$this->exportable()->export($this->attributesToExport())->toArray() |
15
|
|
|
); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
protected function expectedExport(): array |
19
|
|
|
{ |
20
|
|
|
return [ |
21
|
|
|
'test' => 'testTUDISCO', |
22
|
|
|
'bar' => ['bar2' => 'testBar2'], |
23
|
|
|
'bar.bar1' => 'testBar1', |
24
|
|
|
'foobar' => 'testFooBar2', |
25
|
|
|
'baz' => [ |
26
|
|
|
['baz1' => 'baz1A', 'baz3' => 'baz3A'], |
27
|
|
|
['baz1' => 'baz1B', 'baz3' => 'baz3B'], |
28
|
|
|
['baz1' => 'baz1C', 'baz3' => 'baz3C'], |
29
|
|
|
], |
30
|
|
|
]; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
protected function exportable(): Model |
34
|
|
|
{ |
35
|
|
|
return new Model([ |
36
|
|
|
'foo' => 'testFoo', |
37
|
|
|
'bar' => ['bar1' => 'testBar1', 'bar2' => 'testBar2'], |
38
|
|
|
'foobar' => ['foobar1' => 'testFooBar1', 'foobar2' => 'testFooBar2'], |
39
|
|
|
'baz' => [ |
40
|
|
|
['baz1' => 'baz1A', 'baz2' => 'baz2A', 'baz3' => 'baz3A'], |
41
|
|
|
['baz1' => 'baz1B', 'baz2' => 'baz2B', 'baz3' => 'baz3B'], |
42
|
|
|
['baz1' => 'baz1C', 'baz2' => 'baz2C', 'baz3' => 'baz3C'], |
43
|
|
|
], |
44
|
|
|
]); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function attributesToExport(): array |
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
|
|
'test(Mathieu)', |
51
|
|
|
'test(TUDISCO)', |
52
|
|
|
'bar' => ['bar2'], |
53
|
|
|
'bar.bar1', |
54
|
|
|
'foobar' => 'foobar2', |
55
|
|
|
'baz' => ['*' => ['baz1', 'baz3']], |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|