Passed
Push — master ( cbeadc...e0bd91 )
by Francis
01:04
created

RefactorTest::testDirectUnsetRule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
rs 9.7998
1
<?php
2
declare(strict_types=1);
3
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
5
class RefactorTest extends TestCase {
6
  /**
7
   * Code Igniter Instance.
8
   * @var object
9
   */
10
  private static $ci;
11
  /**
12
   * Package name for simplicity
13
   * @var string
14
   */
15
  private const PACKAGE = "francis94c/refactor-ci";
16
17
  /**
18
   * Prerquisites for the Unit Tests.
19
   *
20
   * @covers JWT::__construct
21
   */
22
  public static function setUpBeforeClass(): void {
23
    self::$ci =& get_instance();
0 ignored issues
show
Bug introduced by
The function get_instance was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

23
    self::$ci =& /** @scrutinizer ignore-call */ get_instance();
Loading history...
24
  }
25
  /**
26
   * [testLoadPackage description]
27
   */
28
  public function testLoadPackage():void {
29
    self::$ci->load->package(self::PACKAGE);
30
    $this->assertTrue(isset(self::$ci->refactor));
31
  }
32
  /**
33
   * [testDirectUnsetRule description]
34
   *
35
   * @depends testLoadPackage
36
   */
37
  public function testDirectUnsetRule():void {
38
    $payload = [
39
      'name'     => 'collins',
40
      'pc_brand' => 'HP',
41
      'phone'    => '+2349086756453',
42
      'school'   => 'Delloite',
43
      'company'  => 'Google'
44
    ];
45
    $rule = [
46
      'unset' => [
47
        'school',
48
        'phone'
49
      ]
50
    ];
51
    self::$ci->refactor->run($payload, $rule);
52
    $this->assertFalse(isset($payload['school']));
53
    $this->assertFalse(isset($payload['phone']));
54
    $this->assertTrue(isset($payload['company']));
55
  }
56
}
57