BehaviorTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetBehavior() 0 6 1
A testGetCategories() 0 9 2
1
<?php
2
3
namespace common\unit\models;
4
5
use Yii;
6
use Codeception\Specify;
7
use common\models\Behavior;
8
9
date_default_timezone_set('UTC');
10
11
/**
12
 * Time test
13
 */
14
15
class BehaviorTest extends \Codeception\Test\Unit {
16
  use Specify;
17
18
  public function testGetCategories() {
19
    $behaviors = Behavior::getCategories();
0 ignored issues
show
Bug Best Practice introduced by
The method common\models\Behavior::getCategories() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
    /** @scrutinizer ignore-call */ 
20
    $behaviors = Behavior::getCategories();
Loading history...
20
21
    expect('getCategories should return an array of 7 categories', $this->assertEquals(count($behaviors), 7));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals(count($behaviors), 7) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
22
23
    foreach($behaviors as $behavior) {
24
      expect('this behavior to have a "name" key', $this->assertArrayHasKey('name', $behavior));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertArrayHasKey('name', $behavior) targeting PHPUnit\Framework\Assert::assertArrayHasKey() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
25
      expect('this behavior to have a "behavior_count" key', $this->assertArrayHasKey('behavior_count', $behavior));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertArrayHasKey...vior_count', $behavior) targeting PHPUnit\Framework\Assert::assertArrayHasKey() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
26
      expect('this behavior to have a "category_id" key', $this->assertArrayHasKey('category_id', $behavior));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertArrayHasKey...ategory_id', $behavior) targeting PHPUnit\Framework\Assert::assertArrayHasKey() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
27
    }
28
  }
29
30
  public function testGetBehavior() {
31
    expect('getBehavior should return false when asked for an behavior that does not exist', $this->assertEquals(Behavior::getBehavior('id', 99999999), false));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals(comm...'id', 99999999), false) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
32
33
    expect('getBehavior should return the asked-for behavior data', $this->assertEquals(Behavior::getBehavior('id', 3), ["id" => 3, "name" => "identifying fears and feelings", "category_id" => 1]));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals(comm...', 'category_id' => 1)) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
34
35
    expect('getBehavior SHOULD NOT work quite right for indexing by category_id', $this->assertEquals(Behavior::getBehavior('category_id', 3), ["id" => 28, "name" => "worry", "category_id" => 3]));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals(comm...', 'category_id' => 3)) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
36
  }
37
38
}
39