UpgradeStatusAnalyseTest.php in Upgrade Status 8
File
tests/src/Functional/UpgradeStatusAnalyseTest.php
View source
<?php
namespace Drupal\Tests\upgrade_status\Functional;
class UpgradeStatusAnalyseTest extends UpgradeStatusTestBase {
public function testAnalyser() {
$this
->drupalLogin($this
->drupalCreateUser([
'administer software updates',
]));
$this
->runFullScan();
$key_value = \Drupal::service('keyvalue')
->get('upgrade_status_scan_results');
$this
->assertTrue($key_value
->has('upgrade_status_test_error'));
$this
->assertTrue($key_value
->has('upgrade_status_test_no_error'));
$this
->assertTrue($key_value
->has('upgrade_status_test_submodules'));
$this
->assertTrue($key_value
->has('upgrade_status_test_contrib_error'));
$this
->assertTrue($key_value
->has('upgrade_status_test_contrib_no_error'));
$this
->assertFalse($key_value
->has('upgrade_status_test_submodules_a'));
$project = $key_value
->get('upgrade_status_test_error');
$this
->assertNotEmpty($project);
$report = json_decode($project, TRUE);
$this
->assertEquals(4, $report['data']['totals']['file_errors']);
$this
->assertCount(4, $report['data']['files']);
$file = reset($report['data']['files']);
$file = next($report['data']['files']);
$message = $file['messages'][0];
$this
->assertEquals("Syntax error, unexpected T_STRING on line 3", $message['message']);
$this
->assertEquals(3, $message['line']);
$file = next($report['data']['files']);
$message = $file['messages'][0];
$this
->assertEquals("Call to deprecated function menu_cache_clear_all(). Deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use\n\\Drupal::cache('menu')->invalidateAll() instead.", $message['message']);
$this
->assertEquals(10, $message['line']);
$project = $key_value
->get('upgrade_status_test_no_error');
$this
->assertNotEmpty($project);
$report = json_decode($project, TRUE);
$this
->assertEquals(0, $report['data']['totals']['file_errors']);
$this
->assertCount(0, $report['data']['files']);
$project = $key_value
->get('upgrade_status_test_contrib_error');
$this
->assertNotEmpty($project);
$report = json_decode($project, TRUE);
$this
->assertEquals(2, $report['data']['totals']['file_errors']);
$this
->assertCount(2, $report['data']['files']);
$file = reset($report['data']['files']);
$file = next($report['data']['files']);
$message = $file['messages'][0];
$this
->assertEquals("Call to deprecated function format_string(). Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.\nUse \\Drupal\\Component\\Render\\FormattableMarkup instead.", $message['message']);
$this
->assertEquals(15, $message['line']);
}
}