Skip to content

Commit

Permalink
MDL-65323 core: replace uses of now deprecated assertInternalType
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed May 17, 2019
1 parent b742fe1 commit ff88b95
Show file tree
Hide file tree
Showing 35 changed files with 171 additions and 171 deletions.
2 changes: 1 addition & 1 deletion admin/tool/installaddon/tests/installer_test.php
Expand Up @@ -44,7 +44,7 @@ public function test_get_addons_repository_url() {
$this->assertEquals(1, preg_match('~^site=(.+)$~', $query, $matches));
$site = rawurldecode($matches[1]);
$site = json_decode(base64_decode($site), true);
$this->assertInternalType('array', $site);
$this->assertIsArray($site);
$this->assertEquals(3, count($site));
$this->assertSame('Nasty site', $site['fullname']);
$this->assertSame('file:///etc/passwd', $site['url']);
Expand Down
14 changes: 7 additions & 7 deletions admin/tool/log/tests/manager_test.php
Expand Up @@ -33,7 +33,7 @@ public function test_get_log_manager() {
$this->assertInstanceOf('core\log\manager', $manager);

$stores = $manager->get_readers();
$this->assertInternalType('array', $stores);
$this->assertIsArray($stores);
$this->assertCount(0, $stores);

$this->assertFileExists("$CFG->dirroot/$CFG->admin/tool/log/store/standard/version.php");
Expand All @@ -44,27 +44,27 @@ public function test_get_log_manager() {
$this->assertInstanceOf('core\log\manager', $manager);

$stores = $manager->get_readers();
$this->assertInternalType('array', $stores);
$this->assertIsArray($stores);
$this->assertCount(2, $stores);
foreach ($stores as $key => $store) {
$this->assertInternalType('string', $key);
$this->assertIsString($key);
$this->assertInstanceOf('core\log\sql_reader', $store);
}

$stores = $manager->get_readers('core\log\sql_internal_table_reader');
$this->assertInternalType('array', $stores);
$this->assertIsArray($stores);
$this->assertCount(1, $stores);
foreach ($stores as $key => $store) {
$this->assertInternalType('string', $key);
$this->assertIsString($key);
$this->assertSame('logstore_standard', $key);
$this->assertInstanceOf('core\log\sql_internal_table_reader', $store);
}

$stores = $manager->get_readers('core\log\sql_reader');
$this->assertInternalType('array', $stores);
$this->assertIsArray($stores);
$this->assertCount(2, $stores);
foreach ($stores as $key => $store) {
$this->assertInternalType('string', $key);
$this->assertIsString($key);
$this->assertInstanceOf('core\log\sql_reader', $store);
}
}
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/usertours/tests/cache_test.php
Expand Up @@ -248,7 +248,7 @@ public function test_get_stepdata_no_steps() {
$tour = $this->helper_create_tour((object)['enabled' => false]);

$data = \tool_usertours\cache::get_stepdata($tour->get_id());
$this->assertInternalType('array', $data);
$this->assertIsArray($data);
$this->assertEmpty($data);
}

Expand All @@ -265,11 +265,11 @@ public function test_get_stepdata_correct_tour() {
$tour2 = $this->helper_create_tour((object)['enabled' => false]);

$data = \tool_usertours\cache::get_stepdata($tour1->get_id());
$this->assertInternalType('array', $data);
$this->assertIsArray($data);
$this->assertCount(3, $data);

$data = \tool_usertours\cache::get_stepdata($tour2->get_id());
$this->assertInternalType('array', $data);
$this->assertIsArray($data);
$this->assertEmpty($data);
}

Expand All @@ -292,7 +292,7 @@ public function test_get_stepdata_ordered_steps() {
$steps[0]->set_sortorder(10)->persist();

$data = \tool_usertours\cache::get_stepdata($tour->get_id());
$this->assertInternalType('array', $data);
$this->assertIsArray($data);
$this->assertCount(4, $data);

// Re-order the steps.
Expand Down
2 changes: 1 addition & 1 deletion analytics/tests/model_test.php
Expand Up @@ -424,7 +424,7 @@ public function test_export_config() {
$modeldata = $method->invoke($modelconfig);

$this->assertArrayHasKey('core', $modeldata->dependencies);
$this->assertInternalType('float', $modeldata->dependencies['core']);
$this->assertIsFloat($modeldata->dependencies['core']);
$this->assertNotEmpty($modeldata->target);
$this->assertNotEmpty($modeldata->timesplitting);
$this->assertCount(3, $modeldata->indicators);
Expand Down
2 changes: 1 addition & 1 deletion badges/tests/badgeslib_test.php
Expand Up @@ -379,7 +379,7 @@ public function test_badges_get_user_badges() {

// Make sure the first user has no badges.
$result = badges_get_user_badges($user1->id);
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(0, $result);

// Check that the second user has the expected 11 badges.
Expand Down
16 changes: 8 additions & 8 deletions cache/tests/administration_helper_test.php
Expand Up @@ -74,7 +74,7 @@ public function test_get_summaries() {
)));

$storesummaries = cache_administration_helper::get_store_instance_summaries();
$this->assertInternalType('array', $storesummaries);
$this->assertIsArray($storesummaries);
$this->assertArrayHasKey('summariesstore', $storesummaries);
$summary = $storesummaries['summariesstore'];
// Check the keys
Expand All @@ -95,7 +95,7 @@ public function test_get_summaries() {
$this->assertEquals(1, $summary['mappings']);

$definitionsummaries = cache_administration_helper::get_definition_summaries();
$this->assertInternalType('array', $definitionsummaries);
$this->assertIsArray($definitionsummaries);
$this->assertArrayHasKey('core/eventinvalidation', $definitionsummaries);
$summary = $definitionsummaries['core/eventinvalidation'];
// Check the keys
Expand All @@ -111,11 +111,11 @@ public function test_get_summaries() {
$this->assertEquals(cache_store::MODE_APPLICATION, $summary['mode']);
$this->assertEquals('core', $summary['component']);
$this->assertEquals('eventinvalidation', $summary['area']);
$this->assertInternalType('array', $summary['mappings']);
$this->assertIsArray($summary['mappings']);
$this->assertContains('summariesstore', $summary['mappings']);

$pluginsummaries = cache_administration_helper::get_store_plugin_summaries();
$this->assertInternalType('array', $pluginsummaries);
$this->assertIsArray($pluginsummaries);
$this->assertArrayHasKey('file', $pluginsummaries);
$summary = $pluginsummaries['file'];
// Check the keys
Expand All @@ -127,18 +127,18 @@ public function test_get_summaries() {
$this->assertArrayHasKey('canaddinstance', $summary);

$locksummaries = cache_administration_helper::get_lock_summaries();
$this->assertInternalType('array', $locksummaries);
$this->assertIsArray($locksummaries);
$this->assertTrue(count($locksummaries) > 0);

$mappings = cache_administration_helper::get_default_mode_stores();
$this->assertInternalType('array', $mappings);
$this->assertIsArray($mappings);
$this->assertCount(3, $mappings);
$this->assertArrayHasKey(cache_store::MODE_APPLICATION, $mappings);
$this->assertInternalType('array', $mappings[cache_store::MODE_APPLICATION]);
$this->assertIsArray($mappings[cache_store::MODE_APPLICATION]);
$this->assertContains('summariesstore', $mappings[cache_store::MODE_APPLICATION]);

$potentials = cache_administration_helper::get_definition_store_options('core', 'eventinvalidation');
$this->assertInternalType('array', $potentials); // Currently used, suitable, default
$this->assertIsArray($potentials); // Currently used, suitable, default
$this->assertCount(3, $potentials);
$this->assertArrayHasKey('summariesstore', $potentials[0]);
$this->assertArrayHasKey('summariesstore', $potentials[1]);
Expand Down
30 changes: 15 additions & 15 deletions cache/tests/cache_test.php
Expand Up @@ -122,7 +122,7 @@ public function test_cache_config() {
$this->assertCount(3, $stores);
foreach ($stores as $name => $store) {
// Check its an array.
$this->assertInternalType('array', $store);
$this->assertIsArray($store);
// Check the name is the key.
$this->assertEquals($name, $store['name']);
// Check that it has been declared default.
Expand Down Expand Up @@ -370,11 +370,11 @@ protected function run_on_cache(cache_loader $cache) {
'key1' => array(1, 2, 3),
'key2' => array(3, 2, 1),
));
$this->assertInternalType('array', $cache->get('key1'));
$this->assertInternalType('array', $cache->get('key2'));
$this->assertIsArray($cache->get('key1'));
$this->assertIsArray($cache->get('key2'));
$this->assertCount(3, $cache->get('key1'));
$this->assertCount(3, $cache->get('key2'));
$this->assertInternalType('array', $cache->get_many(array('key1', 'key2')));
$this->assertIsArray($cache->get_many(array('key1', 'key2')));
$this->assertCount(2, $cache->get_many(array('key1', 'key2')));
$this->assertEquals(2, $cache->delete_many(array('key1', 'key2')));

Expand Down Expand Up @@ -539,7 +539,7 @@ public function test_definition_data_loader() {
$this->assertTrue($cache->purge());
$this->assertTrue($cache->set('b', 'B'));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
Expand Down Expand Up @@ -675,7 +675,7 @@ public function test_application_ttl_negative() {
// Test with multiple keys.
$this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
Expand All @@ -686,7 +686,7 @@ public function test_application_ttl_negative() {

// Test with multiple keys including missing ones.
$result = $cache->get_many(array('a', 'c', 'e'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('c', $result);
Expand Down Expand Up @@ -724,7 +724,7 @@ public function test_application_ttl_positive() {
// Test with multiple keys.
$this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
Expand All @@ -735,7 +735,7 @@ public function test_application_ttl_positive() {

// Test with multiple keys including missing ones.
$result = $cache->get_many(array('a', 'c', 'e'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('c', $result);
Expand Down Expand Up @@ -773,7 +773,7 @@ public function test_session_ttl_positive() {
// Test with multiple keys.
$this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
Expand All @@ -784,7 +784,7 @@ public function test_session_ttl_positive() {

// Test with multiple keys including missing ones.
$result = $cache->get_many(array('a', 'c', 'e'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('c', $result);
Expand Down Expand Up @@ -1407,7 +1407,7 @@ public function test_multiple_application_loaders() {
// Test the many commands.
$this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
Expand All @@ -1418,7 +1418,7 @@ public function test_multiple_application_loaders() {
$this->assertEquals($result, $cache->get_many(array('a', 'b', 'c')));
$this->assertEquals(2, $cache->delete_many(array('a', 'c')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
Expand Down Expand Up @@ -1476,7 +1476,7 @@ public function test_multiple_session_loaders() {
// Test the many commands.
$this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
Expand All @@ -1487,7 +1487,7 @@ public function test_multiple_session_loaders() {
$this->assertEquals($result, $cache->get_many(array('a', 'b', 'c')));
$this->assertEquals(2, $cache->delete_many(array('a', 'c')));
$result = $cache->get_many(array('a', 'b', 'c'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(3, $result);
$this->assertArrayHasKey('a', $result);
$this->assertArrayHasKey('b', $result);
Expand Down
2 changes: 1 addition & 1 deletion cache/tests/config_writer_test.php
Expand Up @@ -270,7 +270,7 @@ public function test_set_definition_mappings() {

$config = cache_config_writer::instance();
$this->assertTrue($config->add_store_instance('setdefinitiontest', 'file'));
$this->assertInternalType('array', $config->get_definition_by_id('phpunit/testdefinition'));
$this->assertIsArray($config->get_definition_by_id('phpunit/testdefinition'));
$config->set_definition_mappings('phpunit/testdefinition', array('setdefinitiontest', 'default_application'));

try {
Expand Down
8 changes: 4 additions & 4 deletions cache/tests/fixtures/stores.php
Expand Up @@ -131,16 +131,16 @@ public function run_tests(cache_store $instance) {

// Test get with an int.
$this->assertSame(1, $instance->get('test1'));
$this->assertInternalType('int', $instance->get('test1'));
$this->assertIsInt($instance->get('test1'));
$this->assertSame(2, $instance->get('test2'));
$this->assertInternalType('int', $instance->get('test2'));
$this->assertIsInt($instance->get('test2'));

// Test set with a bool.
$this->assertTrue($instance->set('test1', true));

// Test get with an bool.
$this->assertSame(true, $instance->get('test1'));
$this->assertInternalType('boolean', $instance->get('test1'));
$this->assertIsBool($instance->get('test1'));

// Test with an object.
$this->assertTrue($instance->set('obj', $object));
Expand Down Expand Up @@ -177,7 +177,7 @@ public function run_tests(cache_store $instance) {

// Test get_many.
$result = $instance->get_many(array('many1', 'many3', 'many5', 'many6'));
$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertCount(4, $result);
$this->assertSame(array(
'many1' => 'many1',
Expand Down

0 comments on commit ff88b95

Please sign in to comment.