Completed
Push — master ( 2d3cdd...c9e6e0 )
by Babak
04:15
created

DemoTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 61
rs 10
c 3
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createApplication() 0 12 2
A testBasicTest() 0 20 1
1
<?php
2
3
namespace Alive2212\LaravelStringHelper\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 = "LaravelStringHelper";
15
16
    /**
17
     * @var array
18
     */
19
    private $PACKAGE_CLASSES = [
20
        "StringHelper",
21
    ];
22
23
    protected $app;
24
25
    public function __construct()
26
    {
27
        parent::__construct();
28
        $this->createApplication();
29
    }
30
31
    public function createApplication()
32
    {
33
        $app = new Container();
34
        $app->bind('app', 'Illuminate\Container\Container');
35
36
        foreach ($this->PACKAGE_CLASSES as $PACKAGE_CLASS) {
37
            $app->bind($PACKAGE_CLASS, 'Alive2212\\'.$this->PACKAGE_NAME.'\\'.$PACKAGE_CLASS);
38
        }
39
40
        $this->app = $app;
41
        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...
42
    }
43
44
    /**
45
     * A basic test example.
46
     *
47
     * @return void
48
     */
49
    public function testBasicTest()
50
    {
51
        // create String Helper
52
        $stringHelper = $this->app->make("StringHelper");
53
54
        // check toTag method
55
        $this->assertTrue($stringHelper->toTag("TestCase")=="test_case");
56
57
        // upperFirstLetter
58
        $this->assertTrue($stringHelper->upperFirstLetter("testCase")=="TestCase");
59
60
        // lowerFirstLetter
61
        $this->assertTrue($stringHelper->lowerFirstLetter("TestCase")=="testCase");
62
63
        // toCamel
64
        $this->assertTrue($stringHelper->toCamel("test_case")=="testCase");
65
66
        // toPascal
67
        $this->assertTrue($stringHelper->toPascal("test_case")=="TestCase");
68
    }
69
}
70