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,70 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\aggregator\Unit\Menu\AggregatorLocalTasksTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\aggregator\Unit\Menu;
|
||||
|
||||
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
|
||||
|
||||
/**
|
||||
* Tests existence of aggregator local tasks.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->directoryList = array('aggregator' => 'core/modules/aggregator');
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests local task existence.
|
||||
*
|
||||
* @dataProvider getAggregatorAdminRoutes
|
||||
*/
|
||||
public function testAggregatorAdminLocalTasks($route) {
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('aggregator.admin_overview', 'aggregator.admin_settings'),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of routes to test.
|
||||
*/
|
||||
public function getAggregatorAdminRoutes() {
|
||||
return array(
|
||||
array('aggregator.admin_overview'),
|
||||
array('aggregator.admin_settings'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks aggregator source tasks.
|
||||
*
|
||||
* @dataProvider getAggregatorSourceRoutes
|
||||
*/
|
||||
public function testAggregatorSourceLocalTasks($route) {
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'),
|
||||
));
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of source routes to test.
|
||||
*/
|
||||
public function getAggregatorSourceRoutes() {
|
||||
return array(
|
||||
array('entity.aggregator_feed.canonical'),
|
||||
array('entity.aggregator_feed.edit_form'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\aggregator\Unit\Plugin\AggregatorPluginSettingsBaseTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\aggregator\Unit\Plugin {
|
||||
|
||||
use Drupal\aggregator\Form\SettingsForm;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* Tests settings configuration of individual aggregator plugins.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The aggregator settings form object under test.
|
||||
*
|
||||
* @var \Drupal\aggregator\Form\SettingsForm
|
||||
*/
|
||||
protected $settingsForm;
|
||||
|
||||
/**
|
||||
* The stubbed config factory object.
|
||||
*
|
||||
* @var \PHPUnit_Framework_MockObject_MockBuilder
|
||||
*/
|
||||
protected $configFactory;
|
||||
|
||||
/**
|
||||
* The stubbed aggregator plugin managers array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $managers;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->configFactory = $this->getConfigFactoryStub(
|
||||
array(
|
||||
'aggregator.settings' => array(
|
||||
'processors' => array('aggregator_test'),
|
||||
),
|
||||
'aggregator_test.settings' => array(),
|
||||
)
|
||||
);
|
||||
foreach (array('fetcher', 'parser', 'processor') as $type) {
|
||||
$this->managers[$type] = $this->getMockBuilder('Drupal\aggregator\Plugin\AggregatorPluginManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->managers[$type]->expects($this->once())
|
||||
->method('getDefinitions')
|
||||
->will($this->returnValue(array('aggregator_test' => array('title' => '', 'description' => ''))));
|
||||
}
|
||||
|
||||
$this->settingsForm = new SettingsForm(
|
||||
$this->configFactory,
|
||||
$this->managers['fetcher'],
|
||||
$this->managers['parser'],
|
||||
$this->managers['processor'],
|
||||
$this->getStringTranslationStub()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for AggregatorPluginSettingsBase.
|
||||
*
|
||||
* Ensure that the settings form calls build, validate and submit methods on
|
||||
* plugins that extend AggregatorPluginSettingsBase.
|
||||
*/
|
||||
public function testSettingsForm() {
|
||||
// Emulate a form state of a submitted form.
|
||||
$form_state = (new FormState())->setValues([
|
||||
'dummy_length' => '',
|
||||
'aggregator_allowed_html_tags' => '',
|
||||
]);
|
||||
|
||||
$test_processor = $this->getMock(
|
||||
'Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor',
|
||||
array('buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'),
|
||||
array(array(), 'aggregator_test', array('description' => ''), $this->configFactory)
|
||||
);
|
||||
$test_processor->expects($this->at(0))
|
||||
->method('buildConfigurationForm')
|
||||
->with($this->anything(), $form_state)
|
||||
->will($this->returnArgument(0));
|
||||
$test_processor->expects($this->at(1))
|
||||
->method('validateConfigurationForm')
|
||||
->with($this->anything(), $form_state);
|
||||
$test_processor->expects($this->at(2))
|
||||
->method('submitConfigurationForm')
|
||||
->with($this->anything(), $form_state);
|
||||
|
||||
$this->managers['processor']->expects($this->once())
|
||||
->method('createInstance')
|
||||
->with($this->equalTo('aggregator_test'))
|
||||
->will($this->returnValue($test_processor));
|
||||
|
||||
$form = $this->settingsForm->buildForm(array(), $form_state);
|
||||
$this->settingsForm->validateForm($form, $form_state);
|
||||
$this->settingsForm->submitForm($form, $form_state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
// @todo Delete after https://www.drupal.org/node/1858196 is in.
|
||||
if (!function_exists('drupal_set_message')) {
|
||||
function drupal_set_message() {}
|
||||
}
|
||||
}
|
||||
Reference in a new issue