Completed
Push — master ( 1e31bb...ffcce3 )
by Korotkov
03:55 queued 02:23
created

FactoryMethodTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @license   https://mit-license.org/ MIT
8
 */
9
10
namespace Creational\FactoryMethod\Tests;
11
12
use Creational\FactoryMethod\FirstProduct;
13
use Creational\FactoryMethod\SecondProduct;
14
use Creational\FactoryMethod\FactoryMethod;
15
use Creational\FactoryMethod\ProductInterface;
16
use Creational\FactoryMethod\FactoryMethodInterface;
17
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
18
19
/**
20
 * Class FactoryMethodTest
21
 */
22
class FactoryMethodTest extends PHPUnit_Framework_TestCase
23
{
24
25
    /**
26
     * @var FactoryMethod
27
     */
28
    protected $factory;
29
30
    protected function setUp(): void
31
    {
32
        $this->factory = new FactoryMethod();
33
    }
34
35
    public function testProducts()
36
    {
37
        $this->assertEquals($this->factory->getProduct('FirstProduct')->getClassName(), FirstProduct::class);
38
        $this->assertEquals($this->factory->getProduct('SecondProduct')->getClassName(), SecondProduct::class);
39
    }
40
41
    public function testFactoryMethod()
42
    {
43
        $this->assertInstanceOf(FactoryMethodInterface::class, $this->factory);
44
        $this->assertInstanceOf(ProductInterface::class, $this->factory->getProduct('FirstProduct'));
45
        $this->assertInstanceOf(ProductInterface::class, $this->factory->getProduct('SecondProduct'));
46
    }
47
}
48