ClearRedundantPromocodesTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_returns_null_if_there_is_no_redundant_promocodes() 0 7 1
A it_removes_expired_or_used_promocodes_and_relations() 0 17 1
1
<?php
2
3
namespace Gabievi\Promocodes\Tests;
4
5
use Promocodes;
6
use Gabievi\Promocodes\Models\Promocode;
7
use Gabievi\Promocodes\Tests\Models\User;
8
9
class ClearRedundantPromocodesTest extends TestCase
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: artisan, be, call, seed
Loading history...
10
{
11
    /** @test */
12
    public function it_returns_null_if_there_is_no_redundant_promocodes()
13
    {
14
        $promocodes = Promocodes::create(3);
15
16
        $this->assertCount(3, $promocodes);
17
        $this->assertNull(Promocodes::clearRedundant());
18
    }
19
20
    /** @test */
21
    public function it_removes_expired_or_used_promocodes_and_relations()
22
    {
23
        $user = User::find(1);
24
        $this->actingAs($user);
0 ignored issues
show
Bug introduced by
The method actingAs() does not seem to exist on object<Gabievi\Promocode...edundantPromocodesTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
26
        $disposablePromocodes = Promocodes::createDisposable(2);
27
        $multiusePromocodes = Promocodes::create(2);
28
29
        $this->assertCount(4, Promocode::all());
0 ignored issues
show
Bug introduced by
It seems like \Gabievi\Promocodes\Models\Promocode::all() targeting Illuminate\Database\Eloquent\Model::all() can also be of type array<integer,object<Ill...base\Eloquent\Builder>>; however, PHPUnit\Framework\Assert::assertCount() does only seem to accept object<Countable>|object...nit\Framework\iterable>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
30
31
        Promocodes::redeem($disposablePromocodes->first()['code']);
32
        Promocodes::disable($multiusePromocodes->first()['code']);
33
34
        Promocodes::clearRedundant();
35
36
        $this->assertCount(2, Promocode::all());
0 ignored issues
show
Bug introduced by
It seems like \Gabievi\Promocodes\Models\Promocode::all() targeting Illuminate\Database\Eloquent\Model::all() can also be of type array<integer,object<Ill...base\Eloquent\Builder>>; however, PHPUnit\Framework\Assert::assertCount() does only seem to accept object<Countable>|object...nit\Framework\iterable>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
37
    }
38
}
39