1 | <?php |
||
6 | class TwigFakerExtensionTest extends PHPUnit_Framework_TestCase |
||
|
|||
7 | { |
||
8 | protected $twigFaker; |
||
9 | |||
10 | public function setUp() |
||
16 | |||
17 | /** |
||
18 | * @test |
||
19 | */ |
||
20 | public function it_registers_the_extension_name_correctly() |
||
26 | |||
27 | /** |
||
28 | * @test |
||
29 | */ |
||
30 | public function it_registers_a_fake_function() |
||
36 | |||
37 | /** |
||
38 | * @test |
||
39 | * |
||
40 | * @expectedException Ablett\TwigFaker\InvalidFactoryException |
||
41 | */ |
||
42 | public function it_throws_an_exception_when_an_invalid_factory_is_used() |
||
43 | { |
||
44 | $data = $this->twigFaker->fakerData('does-not-exist'); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @test |
||
49 | */ |
||
50 | public function it_returns_one_fake_item_when_no_count_is_passed() |
||
56 | |||
57 | /** |
||
58 | * @test |
||
59 | */ |
||
60 | public function it_returns_fifteen_fake_items_when_the_count_is_passed() |
||
66 | |||
67 | /** |
||
68 | * @test |
||
69 | */ |
||
70 | public function it_caches_a_single_fake_item_when_given_a_cache_key() |
||
71 | { |
||
72 | $fakePerson = $this->twigFaker->fakerData('person', 1, 'my-cache-key'); |
||
73 | $cachedFakePerson = $this->twigFaker->fakerData('person', 1, 'my-cache-key'); |
||
74 | |||
75 | $this->assertSame($fakePerson, $cachedFakePerson); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @test |
||
80 | */ |
||
81 | public function it_caches_multiple_fake_item_when_given_a_cache_key() |
||
82 | { |
||
83 | $fakePeople = $this->twigFaker->fakerData('person', 35, 'my-cache-key'); |
||
84 | $cachedFakePeople = $this->twigFaker->fakerData('person', 35, 'my-cache-key'); |
||
85 | |||
86 | $this->assertSame($fakePeople, $cachedFakePeople); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @test |
||
91 | */ |
||
92 | public function it_caches_single_fake_items_with_different_cache_keys() |
||
104 | |||
105 | /** |
||
106 | * @test |
||
107 | */ |
||
108 | public function it_allows_the_same_cache_key_to_be_used_for_different_factories() |
||
115 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.