Passed
Push — master ( 68c7df...152166 )
by Francis
01:20
created

BlogTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 10
rs 10
1
<?php
2
use PHPUnit\Framework\TestCase;
1 ignored issue
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...
3
4
final class BlogTest extends TestCase {
5
6
  private $ci;
7
8
  public function setUp(): void {
9
    $this->ci =& get_instance();
1 ignored issue
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

9
    $this->ci =& /** @scrutinizer ignore-call */ get_instance();
Loading history...
10
    $this->ci->load->database();
11
    $this->ci->db->query("USE test_db;");
12
    $queries = [
13
      "CREATE TABLE IF NOT EXISTS admins (id INT(7) AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20) NOT NULL, password TEXT NOT NULL) Engine=InnoDB;",
14
      "INSERT INTO admins (id, name, password) VALUES (1, \"Dev\", \"does_not_matter_for_this_test\");"
15
    ];
16
    foreach ($queries as $query) {
17
      $this->assertTrue($this->ci->db->query($query), "$query, Ran sucessfully.");
18
    }
19
  }
20
21
  public function testLoadBlog() {
22
    $this->ci->load->splint("francis94c/blog", "+Blogger", null, "blogger");
23
    $this->assertTrue($this->ci->blogger->install("test_blog"), "Blog Installed Successfuly without admin ID constraint.");
24
    $this->assertTrue($this->ci->blogger->install("test_blog"), "Verify CREATE IF NOT EXISTS clause");
25
    $this->assertTrue($this->ci->blogger->install("admin_test_blog", "admins", "id", 7), "Create Blog with existent admin constarint");
26
    $this->assertTrue($this->ci->blogger->loadEditor("callback"), "Load Editor");
27
    $this->ci->blogger->setBlog("test_blog");
28
    $this->assertTrue($this->ci->blogger->renderPostItems(null, null, null, 1, 0), "Test load empty posts set");
29
  }
30
31
  public function tearDown(): void {
32
    $this->ci->db->empty_table("admins");
33
  }
34
}
35