GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a9bc98...b864c9 )
by butschster
10:50
created

AdminTest::test_set_model()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
rs 9.4285
1
<?php
2
3
use Mockery as m;
4
5
class AdminTest extends TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    /**
8
     * @var SleepingOwl\Admin\Admin
9
     */
10
    private $admin;
11
12
    public function setUp()
13
    {
14
        parent::setUp();
15
16
        $this->admin = new SleepingOwl\Admin\Admin();
17
    }
18
19
    /**
20
     * @covers SleepingOwl\Admin\Admin::registerModel
21
     * @covers SleepingOwl\Admin\Admin::getModels
22
     */
23
    public function test_registers_models()
24
    {
25
        $this->admin->registerModel(TestModel::class, function () {
26
        });
27
        $this->assertCount(1, $this->admin->getModels());
28
29
        $this->admin->registerModel(TestModel::class, function () {
30
        });
31
        $this->assertCount(1, $this->admin->getModels());
32
33
        $this->admin->registerModel(OtherTestModel::class, function () {
34
        });
35
        $this->assertCount(2, $this->admin->getModels());
36
    }
37
38
    /**
39
     * @covers SleepingOwl\Admin\Admin::register
40
     * @covers SleepingOwl\Admin\Admin::getModels
41
     */
42
    public function test_register_configuration()
43
    {
44
        $configuration = $this->createMock(\SleepingOwl\Admin\Contracts\ModelConfigurationInterface::class);
45
        $configuration->expects($this->once())->method('getClass')->will($this->returnValue(TestModel::class));
46
47
        $this->admin->register($configuration);
48
49
        $configuration1 = $this->createMock(TestModelConfiguration::class);
50
        $configuration1->expects($this->once())->method('getClass')->will($this->returnValue(OtherTestModel::class));
51
        $configuration1->expects($this->once())->method('initialize');
52
53
        $this->admin->register($configuration1);
54
55
        $configuration2 = $this->createMock(TestModelConfiguration::class);
56
        $configuration2->expects($this->once())->method('getClass')->will($this->returnValue(TestModel::class));
57
        $this->admin->register($configuration2);
58
59
        $this->assertCount(2, $this->admin->getModels());
60
    }
61
62
    /**
63
     * @covers SleepingOwl\Admin\Admin::modelAliases
64
     * @covers SleepingOwl\Admin\Admin::getModels
65
     */
66
    public function test_returns_form_aliases()
67
    {
68
        $this->admin->registerModel(TestModel::class, function () {
69
        });
70
        $aliases = $this->admin->modelAliases();
71
72
        $this->assertEquals('test_models', $aliases['TestModel']);
73
    }
74
75
    /**
76
     * @covers SleepingOwl\Admin\Admin::getModel
77
     */
78
    public function test_gets_model()
79
    {
80
        $configuration = $this->createMock(\SleepingOwl\Admin\Contracts\ModelConfigurationInterface::class);
81
        $configuration->expects($this->once())->method('getClass')->will($this->returnValue(TestModel::class));
82
83
        $this->admin->register($configuration);
84
85
        $model = $this->admin->getModel(TestModel::class);
86
        $this->assertEquals($configuration, $model);
87
88
        $model = $this->admin->getModel(new TestModel());
89
        $this->assertEquals($configuration, $model);
90
91
        $model = $this->admin->getModel(OtherTestModel::class);
92
93
        $this->assertInstanceOf(
94
            \SleepingOwl\Admin\Contracts\ModelConfigurationInterface::class,
95
            $model
96
        );
97
    }
98
99
    /**
100
     * @covers SleepingOwl\Admin\Admin::setModel
101
     */
102
    public function test_set_model()
103
    {
104
        $configuration = $this->createMock(\SleepingOwl\Admin\Contracts\ModelConfigurationInterface::class);
105
106
        $this->admin->setModel(TestClass::class, $configuration);
107
        $this->assertCount(1, $this->admin->getModels());
108
    }
109
110
    /**
111
     * @covers SleepingOwl\Admin\Admin::hasModel
112
     */
113
    public function test_checks_if_has_model()
114
    {
115
        $this->admin->registerModel(TestModel::class, function () {
116
        });
117
        $this->assertTrue($this->admin->hasModel(TestModel::class));
118
        $this->assertFalse($this->admin->hasModel(OtherTestModel::class));
119
    }
120
121
    /**
122
     * @covers SleepingOwl\Admin\Admin::template
123
     */
124
    public function test_returns_template()
125
    {
126
        $this->assertInstanceOf(
127
            \SleepingOwl\Admin\Contracts\TemplateInterface::class,
128
            $this->admin->template()
129
        );
130
    }
131
132
    /**
133
     * @covers SleepingOwl\Admin\Admin::addMenuPage
134
     */
135
    public function test_adds_menu_page()
136
    {
137
        $navigation = m::mock(\SleepingOwl\Admin\Navigation::class);
138
        $this->app->instance('sleeping_owl.navigation', $navigation);
139
        $navigation->shouldReceive('addPage')->once();
140
141
        $this->admin->addMenuPage(TestModel::class);
142
    }
143
144
    /**
145
     * @covers SleepingOwl\Admin\Admin::getNavigation
146
     */
147
    public function test_get_navigation()
148
    {
149
        $navigation = m::mock(\SleepingOwl\Admin\Navigation::class);
150
        $this->app->instance('sleeping_owl.navigation', $navigation);
151
152
        $this->assertInstanceOf(
153
            \SleepingOwl\Admin\Navigation::class,
154
            $this->admin->getNavigation()
155
        );
156
    }
157
158
    /**
159
     * @covers SleepingOwl\Admin\Admin::view
160
     */
161
    public function test_renders_view()
162
    {
163
        $arguments = ['content', 'title'];
164
        $controllerClass = \SleepingOwl\Admin\Http\Controllers\AdminController::class;
165
166
        $controller = m::mock($controllerClass);
167
        $this->app->instance($controllerClass, $controller);
168
        $controller->shouldReceive('renderContent')
169
                   ->withArgs($arguments)
170
                   ->once();
171
172
        $this->admin->view($arguments[0], $arguments[1]);
173
    }
174
}
175
176
class TestModel extends \Illuminate\Database\Eloquent\Model
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
177
{
178
}
179
class OtherTestModel extends \Illuminate\Database\Eloquent\Model
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
180
{
181
}
182
183
abstract class TestModelConfiguration implements \SleepingOwl\Admin\Contracts\ModelConfigurationInterface, \SleepingOwl\Admin\Contracts\Initializable
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
184
{
185
}
186