|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Namefy\Tests\Strategies; |
|
4
|
|
|
|
|
5
|
|
|
use ByTIC\Namefy\Name; |
|
6
|
|
|
use ByTIC\Namefy\Strategies\ByTICStrategy; |
|
7
|
|
|
use ByTIC\Namefy\Tests\AbstractTest; |
|
8
|
|
|
use ByTIC\Namefy\Tests\Fixtures\Models\Payments\PurchasableRecordManager; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class ByTICStrategyTest |
|
12
|
|
|
* @package ByTIC\Namefy\Tests\Strategies |
|
13
|
|
|
*/ |
|
14
|
|
|
class ByTICStrategyTest extends AbstractTest |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @param $slug |
|
18
|
|
|
* @param $result |
|
19
|
|
|
* @dataProvider data_fromRepository |
|
20
|
|
|
*/ |
|
21
|
|
|
public function test_fromRepository($slug, $result) |
|
22
|
|
|
{ |
|
23
|
|
|
$name = new Name(); |
|
24
|
|
|
$strategy = new ByTICStrategy(); |
|
25
|
|
|
self::assertSame($result, $strategy->fromRepository($slug, $name)); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function data_fromRepository(): array |
|
29
|
|
|
{ |
|
30
|
|
|
return [ |
|
31
|
|
|
['books', 'books'], |
|
32
|
|
|
['Books', 'books'], |
|
33
|
|
|
['Books\Books', 'books'], |
|
34
|
|
|
['Books_Chapters', 'books-chapters'], |
|
35
|
|
|
['Books\Chapters\BooksChapters', 'books-chapters'], |
|
36
|
|
|
]; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param $slug |
|
41
|
|
|
* @param $result |
|
42
|
|
|
* @dataProvider data_fromModel |
|
43
|
|
|
*/ |
|
44
|
|
|
public function test_fromModel($slug, $result) |
|
45
|
|
|
{ |
|
46
|
|
|
$name = new Name(); |
|
47
|
|
|
$strategy = new ByTICStrategy(); |
|
48
|
|
|
self::assertSame($result, $strategy->fromModel($slug, $name)); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function data_fromModel(): array |
|
52
|
|
|
{ |
|
53
|
|
|
return [ |
|
54
|
|
|
['book', 'books'], |
|
55
|
|
|
['Book', 'books'], |
|
56
|
|
|
['Books\Book', 'books'], |
|
57
|
|
|
['Books_Chapter', 'books-chapters'], |
|
58
|
|
|
['Books\Chapters\BooksChapter', 'books-chapters'], |
|
59
|
|
|
[PurchasableRecordManager::class, 'payments'], |
|
60
|
|
|
]; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|