Passed
Push — master ( d547da...a192e7 )
by Babak
02:05
created

DemoTest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Alive2212\LaravelQueryHelperTest\Unit;
4
5
use Illuminate\Container\Container;
6
use Illuminate\Support\Facades\Facade;
7
use PHPUnit\Framework\TestCase;
8
9
class DemoTest extends TestCase
10
{
11
    /**
12
     * @var string
13
     */
14
    private $PACKAGE_NAME = "LaravelQueryHelper";
15
16
    /**
17
     * @var array
18
     */
19
    private $PACKAGE_CLASSES = [
20
        "QueryHelper",
21
    ];
22
23
    /**
24
     * @var string
25
     */
26
    private $VENDOR = 'Alive2212';
27
28
    protected $app;
29
30
    public function __construct()
31
    {
32
        parent::__construct();
33
        $this->createApplication();
34
    }
35
36
    public function createApplication()
37
    {
38
        $app = new Container();
39
        $app->bind('app', 'Illuminate\Container\Container');
40
41
        foreach ($this->PACKAGE_CLASSES as $PACKAGE_CLASS) {
42
            $app->bind($PACKAGE_CLASS, $this->VENDOR.'\\'.$this->PACKAGE_NAME.'\\'.$PACKAGE_CLASS);
43
        }
44
45
        $app->bind('Cache', 'Illuminate\Support\Facades\Cache');
46
47
        $this->app = $app;
48
        Facade::setFacadeApplication($app);
0 ignored issues
show
Bug introduced by
$app of type Illuminate\Container\Container is incompatible with the type Illuminate\Contracts\Foundation\Application expected by parameter $app of Illuminate\Support\Facad...:setFacadeApplication(). ( Ignorable by Annotation )

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

48
        Facade::setFacadeApplication(/** @scrutinizer ignore-type */ $app);
Loading history...
49
    }
50
51
    /**
52
     * A basic test example.
53
     *
54
     * @return void
55
     */
56
    public function testBasicTest()
57
    {
58
        // create String Helper
59
        foreach ($this->PACKAGE_CLASSES as $PACKAGE_CLASS) {
60
            ${$PACKAGE_CLASS} = $this->app->make($PACKAGE_CLASS);
61
        }
62
        $this->assertTrue(true);
63
    }
64
}
65