Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\system\Tests\Condition\ConditionFormTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\Condition;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests that condition plugins basic form handling is working.
|
||||
*
|
||||
* Checks condition forms and submission and gives a very cursory check to make
|
||||
* sure the configuration that was submitted actually causes the condition to
|
||||
* validate correctly.
|
||||
*
|
||||
* @group Condition
|
||||
*/
|
||||
class ConditionFormTest extends WebTestBase {
|
||||
|
||||
public static $modules = array('node', 'condition_test');
|
||||
|
||||
/**
|
||||
* Submit the condition_node_type_test_form to test condition forms.
|
||||
*/
|
||||
function testConfigForm() {
|
||||
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Page'));
|
||||
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
|
||||
$article = entity_create('node', array('type' => 'article', 'title' => $this->randomMachineName()));
|
||||
$article->save();
|
||||
$this->drupalGet('condition_test');
|
||||
$this->assertField('bundles[article]', 'There is an article bundle selector.');
|
||||
$this->assertField('bundles[page]', 'There is a page bundle selector.');
|
||||
$this->drupalPostForm(NULL, array('bundles[page]' => 'page', 'bundles[article]' => 'article'), t('Submit'));
|
||||
// @see \Drupal\condition_test\FormController::submitForm()
|
||||
$this->assertText('Bundle: page');
|
||||
$this->assertText('Bundle: article');
|
||||
$this->assertText('Executed successfully.', 'The form configured condition executed properly.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\system\Tests\Condition\CurrentThemeConditionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\Condition;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests the CurrentThemeCondition plugin.
|
||||
*
|
||||
* @group Condition
|
||||
*/
|
||||
class CurrentThemeConditionTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('system', 'theme_test');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('system', array('router'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the current theme condition.
|
||||
*/
|
||||
public function testCurrentTheme() {
|
||||
\Drupal::service('theme_handler')->install(array('test_theme'));
|
||||
|
||||
$manager = \Drupal::service('plugin.manager.condition');
|
||||
/** @var $condition \Drupal\Core\Condition\ConditionInterface */
|
||||
$condition = $manager->createInstance('current_theme');
|
||||
$condition->setConfiguration(array('theme' => 'test_theme'));
|
||||
/** @var $condition_negated \Drupal\Core\Condition\ConditionInterface */
|
||||
$condition_negated = $manager->createInstance('current_theme');
|
||||
$condition_negated->setConfiguration(array('theme' => 'test_theme', 'negate' => TRUE));
|
||||
|
||||
$this->assertEqual($condition->summary(), SafeMarkup::format('The current theme is @theme', array('@theme' => 'test_theme')));
|
||||
$this->assertEqual($condition_negated->summary(), SafeMarkup::format('The current theme is not @theme', array('@theme' => 'test_theme')));
|
||||
|
||||
// The expected theme has not been set up yet.
|
||||
$this->assertFalse($condition->execute());
|
||||
$this->assertTrue($condition_negated->execute());
|
||||
|
||||
// Set the expected theme to be used.
|
||||
$this->config('system.theme')->set('default', 'test_theme')->save();
|
||||
\Drupal::theme()->resetActiveTheme();
|
||||
|
||||
$this->assertTrue($condition->execute());
|
||||
$this->assertFalse($condition_negated->execute());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue