1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Alive2212\LaravelSmartResponseTest\Unit; |
4
|
|
|
|
5
|
|
|
use Alive2212\LaravelSmartMeta\Cache; |
|
|
|
|
6
|
|
|
use Alive2212\LaravelSmartMeta\SmartMeta; |
|
|
|
|
7
|
|
|
use Alive2212\LaravelSmartMeta\SmartMetaClass; |
|
|
|
|
8
|
|
|
use Alive2212\LaravelSmartResponse\ResponseModel; |
9
|
|
|
use Illuminate\Container\Container; |
10
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
|
|
|
11
|
|
|
use Illuminate\Support\Facades\Facade; |
12
|
|
|
use PHPUnit\Framework\TestCase; |
13
|
|
|
|
14
|
|
|
class DemoTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
private $PACKAGE_NAME = "LaravelSmartResponse"; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
private $PACKAGE_CLASSES = [ |
25
|
|
|
"ResponseModel", |
26
|
|
|
"SmartResponse", |
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); |
|
|
|
|
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
|
|
|
$ResponseModel = new ResponseModel(); |
70
|
|
|
|
71
|
|
|
$testArray = [ |
72
|
|
|
'key1' => 'value1', |
73
|
|
|
'key2' => [ |
74
|
|
|
'key21' => 'value21', |
75
|
|
|
] |
76
|
|
|
]; |
77
|
|
|
|
78
|
|
|
$ResponseModel->setStatus(true); |
|
|
|
|
79
|
|
|
$this->assertTrue($ResponseModel->getStatus()); |
|
|
|
|
80
|
|
|
|
81
|
|
|
$ResponseModel->setStatusCode(200); |
82
|
|
|
$this->assertTrue($ResponseModel->getStatusCode()==200); |
83
|
|
|
|
84
|
|
|
$ResponseModel->setMessage('test message'); |
85
|
|
|
$this->assertTrue($ResponseModel->getMessage() == 'test message'); |
86
|
|
|
|
87
|
|
|
$ResponseModel->setData(collect(['hello'])); |
88
|
|
|
$this->assertTrue($ResponseModel->getData()->toArray() == ['hello']); |
89
|
|
|
|
90
|
|
|
$ResponseModel->setBeautifulData(collect(['data'=>$testArray]), ['key1' => 'key1']); |
91
|
|
|
|
92
|
|
|
$this->assertTrue(is_array($ResponseModel->getData()->toArray())); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths