ConfigurationTest.php in Weather 8
File
tests/src/Functional/ConfigurationTest.php
View source
<?php
namespace Drupal\Tests\weather\Functional;
use Drupal\Tests\BrowserTestBase;
class ConfigurationTest extends BrowserTestBase {
public static $modules = [
'weather',
'block',
];
protected $defaultTheme = 'stark';
use WeatherCommonTestTrait;
public function testConfiguration() {
$admin_user = $this
->drupalCreateUser([
'access content',
'administer system-wide weather',
'administer blocks',
]);
$this
->drupalLogin($admin_user);
$config = \Drupal::configFactory()
->getEditable('weather.settings');
$config
->set('weather_time_for_testing', 1381176000)
->save();
$this
->drupalGet('admin/config/user-interface/weather/system-wide/add');
$this
->submitForm([], 'Save');
$this
->drupalGet('admin/config/user-interface/weather/system-wide/1/add');
$this
->assertText('You do not have any weather places in system.');
$this
->weatherFillWeatherSchema('geonames_703448.xml');
$this
->drupalGet('admin/config/user-interface/weather/system-wide/1/add');
$this
->submitForm([], 'Save');
\Drupal::cache()
->invalidateAll();
$this
->drupalGet('admin/structure/block/add/weather_system_display_block:1/stark');
$this
->submitForm([
'region' => 'sidebar_first',
], 'Save block');
$this
->drupalGet('admin/structure/block/list/stark');
$this
->assertText('Weather: system-wide display (#1)');
$this
->drupalGet('weather/Ukraine/Kiev/Kyiv/1');
$this
->assertRaw('<div class="weather">');
$this
->assertText('00:00-06:00');
$this
->assertRaw(' °C');
$this
->assertText('18:00-00:00');
$this
->assertRaw(' °C');
$edit = [
'config[temperature]' => 'fahrenheit',
];
$this
->drupalGet('admin/config/user-interface/weather/system-wide/1/edit');
$this
->submitForm($edit, 'Save');
\Drupal::cache()
->invalidateAll();
$this
->drupalGet('weather/Ukraine/Kiev/Kyiv/1');
$this
->assertRaw(' °F');
$this
->assertRaw(' °F');
$this
->drupalLogout();
}
}