DemoTest::testBasicTest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Alive2212\LaravelSmartMeta\Unit;
4
5
use Alive2212\LaravelSmartMeta\SmartMeta;
6
use Illuminate\Container\Container;
7
use Illuminate\Database\Eloquent\Model;
8
use Illuminate\Support\Facades\Facade;
9
use PHPUnit\Framework\TestCase;
10
11
class DemoTest extends TestCase
12
{
13
    /**
14
     * @var string
15
     */
16
    private $PACKAGE_NAME = "LaravelSmartMeta";
17
18
    /**
19
     * @var array
20
     */
21
    private $PACKAGE_CLASSES = [
22
        "SmartMeta",
23
    ];
24
25
    protected $app;
26
27
    public function __construct()
28
    {
29
        parent::__construct();
30
        $this->createApplication();
31
    }
32
33
    public function createApplication()
34
    {
35
        $app = new Container();
36
        $app->bind('app', 'Illuminate\Container\Container');
37
38
        foreach ($this->PACKAGE_CLASSES as $PACKAGE_CLASS) {
39
            $app->bind($PACKAGE_CLASS, 'Alive2212\\'.$this->PACKAGE_NAME.'\\'.$PACKAGE_CLASS);
40
        }
41
42
        $this->app = $app;
43
        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...
44
    }
45
46
    /**
47
     * A basic test example.
48
     *
49
     * @return void
50
     */
51
    public function testBasicTest()
52
    {
53
        // create String Helper
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
//        $smartMeta = $this->app->make($this->PACKAGE_CLASSES);
55
56
        $model = new class extends Model{
57
            use SmartMeta;
58
        };
59
60
        $model->setId(1);
61
        $model->setGlobalKey('test'.'_'.$model->getId());
62
//        $model->initCache();
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
63
        $this->assertTrue($model->getId() == 1);
64
65
//        $this->assertTrue($model->initCache()->getId() == 1);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
66
67
68
        $this->assertTrue(true);
69
    }
70
}
71