42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace WPContentSync\Tests\Unit\Admin;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use WPContentSync\Settings\Settings;
|
|
|
|
class DashboardTemplateTest extends TestCase {
|
|
protected function tearDown(): void {
|
|
$_GET = array();
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function test_it_renders_import_error_notices(): void {
|
|
$_GET['wpcs_import_error'] = 'The selected file is not valid JSON.';
|
|
|
|
$output = $this->renderDashboard();
|
|
|
|
self::assertStringContainsString( 'notice-error', $output );
|
|
self::assertStringContainsString( 'The selected file is not valid JSON.', $output );
|
|
}
|
|
|
|
public function test_it_renders_import_success_notices(): void {
|
|
$_GET['wpcs_imported'] = '1';
|
|
|
|
$output = $this->renderDashboard();
|
|
|
|
self::assertStringContainsString( 'notice-success', $output );
|
|
self::assertStringContainsString( 'The package JSON file was validated successfully.', $output );
|
|
}
|
|
|
|
private function renderDashboard(): string {
|
|
$settings = Settings::fromArray( array() );
|
|
|
|
ob_start();
|
|
include WPCS_PLUGIN_DIR . 'templates/admin/dashboard.php';
|
|
|
|
return (string) ob_get_clean();
|
|
}
|
|
}
|