Passed
Push — master ( ddb2f3...fd433b )
by Kevin
03:42
created

ModelFactoryServiceTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A skipIfNotUsingFoundryBundle() 0 4 2
A can_create_service_factory() 0 6 1
A service_factories_are_not_the_same_object() 0 3 1
1
<?php
2
3
namespace Zenstruck\Foundry\Tests\Functional;
4
5
use Zenstruck\Foundry\Tests\Fixtures\Factories\CategoryServiceFactory;
6
use Zenstruck\Foundry\Tests\FunctionalTestCase;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
final class ModelFactoryServiceTest extends FunctionalTestCase
12
{
13
    /**
14
     * @before
15
     */
16
    public function skipIfNotUsingFoundryBundle(): void
17
    {
18
        if (!\getenv('USE_FOUNDRY_BUNDLE')) {
19
            $this->markTestSkipped('ZenstruckFoundryBundle not enabled.');
20
        }
21
    }
22
23
    /**
24
     * @test
25
     */
26
    public function can_create_service_factory(): void
27
    {
28
        $factory = CategoryServiceFactory::new();
29
30
        $this->assertSame('From Service', $factory->create()->getName());
0 ignored issues
show
Bug introduced by
The method getName() does not exist on Zenstruck\Foundry\Proxy. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        $this->assertSame('From Service', $factory->create()->/** @scrutinizer ignore-call */ getName());
Loading history...
31
        $this->assertSame('From Factory Create', $factory->create(['name' => 'From Factory Create'])->getName());
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function service_factories_are_not_the_same_object(): void
38
    {
39
        $this->assertNotSame(CategoryServiceFactory::new(), CategoryServiceFactory::new());
40
    }
41
}
42