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

can_create_service_factory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
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