class AggregatorPluginSettingsBaseTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php \Drupal\Tests\aggregator\Unit\Plugin\AggregatorPluginSettingsBaseTest
Tests settings configuration of individual aggregator plugins.
@group aggregator
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\aggregator\Unit\Plugin\AggregatorPluginSettingsBaseTest
Expanded class hierarchy of AggregatorPluginSettingsBaseTest
File
- core/
modules/ aggregator/ tests/ src/ Unit/ Plugin/ AggregatorPluginSettingsBaseTest.php, line 19 - Contains \Drupal\Tests\aggregator\Unit\Plugin\AggregatorPluginSettingsBaseTest.
Namespace
Drupal\Tests\aggregator\Unit\PluginView source
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AggregatorPluginSettingsBaseTest:: |
protected | property | The stubbed config factory object. | |
AggregatorPluginSettingsBaseTest:: |
protected | property | The stubbed aggregator plugin managers array. | |
AggregatorPluginSettingsBaseTest:: |
protected | property | The aggregator settings form object under test. | |
AggregatorPluginSettingsBaseTest:: |
protected | function |
Overrides UnitTestCase:: |
|
AggregatorPluginSettingsBaseTest:: |
public | function | Test for AggregatorPluginSettingsBase. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |