Completed
Push — master ( 9e9c4d...878d3c )
by Babak
02:26
created

DemoTest::createApplication()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 2
eloc 8
nc 2
nop 0
1
<?php
2
3
namespace Alive2212\ArrayHelperTest\Unit;
4
5
use Alive2212\ArrayHelper\ArrayHelper;
6
use Alive2212\LaravelSmartMeta\Cache;
7
use Alive2212\LaravelSmartMeta\SmartMeta;
8
use Alive2212\LaravelSmartMeta\SmartMetaClass;
9
use Alive2212\LaravelSmartResponse\ResponseModel;
10
use Illuminate\Container\Container;
11
use Illuminate\Database\Eloquent\Model;
12
use Illuminate\Support\Facades\Facade;
13
use PHPUnit\Framework\TestCase;
14
15
class DemoTest extends TestCase
16
{
17
    /**
18
     * @var string
19
     */
20
    private $PACKAGE_NAME = "ArrayHelper";
21
22
    /**
23
     * @var array
24
     */
25
    private $PACKAGE_CLASSES = [
26
        "ArrayHelper",
27
    ];
28
29
    /**
30
     * @var string
31
     */
32
    private $VENDOR = 'Alive2212';
33
34
    protected $app;
35
36
    public function __construct()
37
    {
38
        parent::__construct();
39
        $this->createApplication();
40
    }
41
42
    public function createApplication()
43
    {
44
        $app = new Container();
45
        $app->bind('app', 'Illuminate\Container\Container');
46
47
        foreach ($this->PACKAGE_CLASSES as $PACKAGE_CLASS) {
48
            $app->bind($PACKAGE_CLASS, $this->VENDOR.'\\'.$this->PACKAGE_NAME.'\\'.$PACKAGE_CLASS);
49
        }
50
51
        $app->bind('Cache', 'Illuminate\Support\Facades\Cache');
52
53
        $this->app = $app;
54
        Facade::setFacadeApplication($app);
0 ignored issues
show
Documentation introduced by
$app is of type object<Illuminate\Container\Container>, but the function expects a object<Illuminate\Contra...Foundation\Application>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55
    }
56
57
    /**
58
     * A basic test example.
59
     *
60
     * @return void
61
     */
62
    public function testBasicTest()
63
    {
64
        // create String Helper
65
        foreach ($this->PACKAGE_CLASSES as $PACKAGE_CLASS) {
66
            ${$PACKAGE_CLASS} = $this->app->make($PACKAGE_CLASS);
67
        }
68
69
        $arrayHelper = new ArrayHelper();
70
        $testArray = [
71
            'key1' => 'value1',
72
            'key2' => [
73
                'key21' => 'value21',
74
            ]
75
        ];
76
77
        $this->assertTrue($arrayHelper->isMapArray($testArray));
78
79
        $this->assertTrue($arrayHelper->getDeep($testArray,'key2.key21') == 'value21');
80
81
        $this->assertTrue(is_array($arrayHelper->serializeArray($testArray)->getValue()));
82
83
        $this->assertTrue(true);
84
    }
85
}
86