Skip to content

Commit

Permalink
Refactoring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carusogabriel committed Dec 20, 2017
1 parent 3ecfcaa commit dfa52f3
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 78 deletions.
4 changes: 2 additions & 2 deletions tests/codeigniter/core/Benchmark_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_mark()

$this->benchmark->mark('code_start');

$this->assertEquals(1, count($this->benchmark->marker));
$this->assertCount(1, $this->benchmark->marker);
$this->assertArrayHasKey('code_start', $this->benchmark->marker);
}

Expand Down Expand Up @@ -64,4 +64,4 @@ public function test_memory_usage()
$this->assertEquals('{memory_usage}', $this->benchmark->memory_usage());
}

}
}
6 changes: 3 additions & 3 deletions tests/codeigniter/core/Common_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class Common_test extends CI_TestCase {

public function test_is_php()
{
$this->assertEquals(TRUE, is_php('1.2.0'));
$this->assertEquals(FALSE, is_php('9999.9.9'));
$this->assertTrue(is_php('1.2.0'));
$this->assertFalse(is_php('9999.9.9'));
}

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -66,4 +66,4 @@ public function test_remove_invisible_characters()
$removed_string = 'Here is a string containing url_encoded invisible text.';
$this->assertEquals($removed_string, remove_invisible_characters($raw_string));
}
}
}
8 changes: 4 additions & 4 deletions tests/codeigniter/core/Input_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function set_up()

public function test_get_not_exists()
{
$this->assertTrue($this->input->get() === array());
$this->assertTrue($this->input->get('foo') === NULL);
$this->assertSame(array(), $this->input->get());
$this->assertNull($this->input->get('foo'));
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -51,8 +51,8 @@ public function test_get_exist_with_xss_clean()

public function test_post_not_exists()
{
$this->assertTrue($this->input->post() === array());
$this->assertTrue($this->input->post('foo') === NULL);
$this->assertSame(array(), $this->input->post());
$this->assertNull($this->input->post('foo'));
}

// --------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/codeigniter/core/Log_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function test_configuration()
$this->assertEquals($date_fmt->getValue($instance), 'd.m.Y');
$this->assertEquals($file_ext->getValue($instance), 'php');
$this->assertEquals($file_perms->getValue($instance), 0644);
$this->assertEquals($enabled->getValue($instance), FALSE);
$this->assertFalse($enabled->getValue($instance));

$this->ci_set_config('log_path', '');
$this->ci_set_config('log_threshold', '0');
Expand Down Expand Up @@ -60,4 +60,4 @@ public function test_format_line()
"LEVEL - Timestamp --> Message\n"
);
}
}
}
2 changes: 1 addition & 1 deletion tests/codeigniter/core/Security_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function test_xss_hash()
// Perform hash
$this->security->xss_hash();

$this->assertTrue(preg_match('#^[0-9a-f]{32}$#iS', $this->security->xss_hash) === 1);
$this->assertRegExp('#^[0-9a-f]{32}$#iS', $this->security->xss_hash);
}

// --------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/codeigniter/core/Utf8_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function test_clean_string()
elseif (ICONV_ENABLED)
{
// This is a known issue, iconv doesn't always work with //IGNORE
$this->assertTrue(in_array($utf8->clean_string($illegal_utf8), array('тест', ''), TRUE));
$this->assertContains($utf8->clean_string($illegal_utf8), array('тест', ''));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion tests/codeigniter/core/compat/password_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ public function test_password_verify()
$this->assertTrue(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi'));
}

}
}
10 changes: 5 additions & 5 deletions tests/codeigniter/database/DB_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function test_db_valid()

$db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE);

$this->assertTrue($db instanceof CI_DB);
$this->assertTrue($db instanceof CI_DB_Driver);
$this->assertInstanceOf('CI_DB', $db);
$this->assertInstanceOf('CI_DB_Driver', $db);
}

// ------------------------------------------------------------------------
Expand All @@ -53,9 +53,9 @@ public function test_db_failover()
$connection = new Mock_Database_DB($config);
$db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER.'_failover'), TRUE);
$this->assertTrue($db instanceof CI_DB);
$this->assertTrue($db instanceof CI_DB_Driver);
$this->assertInstanceOf('CI_DB', $db);
$this->assertInstanceOf('CI_DB_Driver', $db);
}
*/

}
}
4 changes: 2 additions & 2 deletions tests/codeigniter/database/query_builder/distinct_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function test_distinct()
->get('user')
->result_array();

$this->assertEquals(3, count($users));
$this->assertCount(3, $users);
}

}
}
4 changes: 2 additions & 2 deletions tests/codeigniter/database/query_builder/empty_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function test_empty_table()
// Check initial record
$jobs = $this->db->get('job')->result_array();

$this->assertEquals(4, count($jobs));
$this->assertCount(4, $jobs);

// Do the empty
$this->db->empty_table('job');
Expand All @@ -36,4 +36,4 @@ public function test_empty_table()
$this->assertEmpty($jobs->result_array());
}

}
}
6 changes: 3 additions & 3 deletions tests/codeigniter/database/query_builder/escape_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function test_escape_like_percent_sign()
$res = $this->db->query($sql)->result_array();

// Check the result
$this->assertEquals(1, count($res));
$this->assertCount(1, $res);
}

// ------------------------------------------------------------------------
Expand All @@ -62,7 +62,7 @@ public function test_escape_like_backslash_sign()
$res = $this->db->query($sql)->result_array();

// Check the result
$this->assertEquals(2, count($res));
$this->assertCount(2, $res);
}

}
}
4 changes: 2 additions & 2 deletions tests/codeigniter/database/query_builder/from_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function test_from_simple()
->get()
->result_array();

$this->assertEquals(4, count($jobs));
$this->assertCount(4, $jobs);
}

// ------------------------------------------------------------------------
Expand All @@ -46,4 +46,4 @@ public function test_from_with_where()
$this->assertEquals('Awesome job, but sometimes makes you bored', $job1->description);
}

}
}
12 changes: 6 additions & 6 deletions tests/codeigniter/database/query_builder/group_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function test_group_by()
->get()
->result_array();

$this->assertEquals(4, count($jobs));
$this->assertCount(4, $jobs);
}

// ------------------------------------------------------------------------
Expand All @@ -45,7 +45,7 @@ public function test_having_by()
->get()
->result_array();

$this->assertEquals(2, count($jobs));
$this->assertCount(2, $jobs);
}

// ------------------------------------------------------------------------
Expand All @@ -62,7 +62,7 @@ public function test_having_in()
->get()
->result_array();

$this->assertEquals(2, count($jobs));
$this->assertCount(2, $jobs);
}

// ------------------------------------------------------------------------
Expand All @@ -80,7 +80,7 @@ public function test_or_having_in()
->get()
->result_array();

$this->assertEquals(2, count($jobs));
$this->assertCount(2, $jobs);
}

// ------------------------------------------------------------------------
Expand All @@ -97,7 +97,7 @@ public function test_having_not_in()
->get()
->result_array();

$this->assertEquals(3, count($jobs));
$this->assertCount(3, $jobs);
}

// ------------------------------------------------------------------------
Expand All @@ -115,6 +115,6 @@ public function test_or_having_not_in()
->get()
->result_array();

$this->assertEquals(2, count($jobs));
$this->assertCount(2, $jobs);
}
}
12 changes: 6 additions & 6 deletions tests/codeigniter/database/query_builder/like_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function test_or_like()
->result_array();

// Check the result
$this->assertEquals(3, count($jobs));
$this->assertCount(3, $jobs);
$this->assertEquals('Developer', $jobs[0]['name']);
$this->assertEquals('Politician', $jobs[1]['name']);
$this->assertEquals('Musician', $jobs[2]['name']);
Expand All @@ -62,7 +62,7 @@ public function test_not_like()
->result_array();

// Check the result
$this->assertEquals(3, count($jobs));
$this->assertCount(3, $jobs);
$this->assertEquals('Politician', $jobs[0]['name']);
$this->assertEquals('Accountant', $jobs[1]['name']);
$this->assertEquals('Musician', $jobs[2]['name']);
Expand All @@ -81,7 +81,7 @@ public function test_or_not_like()
->result_array();

// Check the result
$this->assertEquals(3, count($jobs));
$this->assertCount(3, $jobs);
$this->assertEquals('Politician', $jobs[0]['name']);
$this->assertEquals('Accountant', $jobs[1]['name']);
$this->assertEquals('Musician', $jobs[2]['name']);
Expand All @@ -99,8 +99,8 @@ public function test_like_spaces_and_tabs()
$spaces = $this->db->like('value', ' ')->get('misc')->result_array();
$tabs = $this->db->like('value', "\t")->get('misc')->result_array();

$this->assertEquals(1, count($spaces));
$this->assertEquals(1, count($tabs));
$this->assertCount(1, $spaces);
$this->assertCount(1, $tabs);
}

}
}
6 changes: 3 additions & 3 deletions tests/codeigniter/database/query_builder/limit_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function test_limit()
->get('job')
->result_array();

$this->assertEquals(2, count($jobs));
$this->assertCount(2, $jobs);
}

// ------------------------------------------------------------------------
Expand All @@ -40,9 +40,9 @@ public function test_limit_and_offset()
->get('job')
->result_array();

$this->assertEquals(2, count($jobs));
$this->assertCount(2, $jobs);
$this->assertEquals('Accountant', $jobs[0]['name']);
$this->assertEquals('Musician', $jobs[1]['name']);
}

}
}
6 changes: 3 additions & 3 deletions tests/codeigniter/database/query_builder/order_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function test_order_ascending()
->result_array();

// Check the result
$this->assertEquals(4, count($jobs));
$this->assertCount(4, $jobs);
$this->assertEquals('Accountant', $jobs[0]['name']);
$this->assertEquals('Developer', $jobs[1]['name']);
$this->assertEquals('Musician', $jobs[2]['name']);
Expand All @@ -45,11 +45,11 @@ public function test_order_descending()
->get('job')
->result_array();

$this->assertEquals(4, count($jobs));
$this->assertCount(4, $jobs);
$this->assertEquals('Politician', $jobs[0]['name']);
$this->assertEquals('Musician', $jobs[1]['name']);
$this->assertEquals('Developer', $jobs[2]['name']);
$this->assertEquals('Accountant', $jobs[3]['name']);
}

}
}
6 changes: 3 additions & 3 deletions tests/codeigniter/database/query_builder/select_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function test_select_only_one_collumn()

// Check rows item
$this->assertArrayHasKey('name',$jobs_name[0]);
$this->assertFalse(array_key_exists('id', $jobs_name[0]));
$this->assertFalse(array_key_exists('description', $jobs_name[0]));
$this->assertArrayNotHasKey('id', $jobs_name[0]);
$this->assertArrayNotHasKey('description', $jobs_name[0]);
}

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -92,4 +92,4 @@ public function test_select_sum()
$this->assertEquals('10', $job_sum->id);
}

}
}
6 changes: 3 additions & 3 deletions tests/codeigniter/database/query_builder/truncate_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function test_truncate()
{
// Check initial record
$jobs = $this->db->get('job')->result_array();
$this->assertEquals(4, count($jobs));
$this->assertCount(4, $jobs);

// Do the empty
$this->db->truncate('job');
Expand All @@ -43,7 +43,7 @@ public function test_truncate_with_from()
{
// Check initial record
$users = $this->db->get('user')->result_array();
$this->assertEquals(4, count($users));
$this->assertCount(4, $users);

// Do the empty
$this->db->from('user')->truncate();
Expand All @@ -53,4 +53,4 @@ public function test_truncate_with_from()
$this->assertEmpty($users->result_array());
}

}
}
Loading

0 comments on commit dfa52f3

Please sign in to comment.