Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aggregator
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
aggregator
Commits
ff00a655
Commit
ff00a655
authored
1 year ago
by
David Cameron
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3383550
by dcam, larowlan: Improve the new DefaultProcessorTest
parent
3bedab43
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Kernel/Plugin/aggregator/processor/DefaultProcessorTest.php
+25
-9
25 additions, 9 deletions
...rnel/Plugin/aggregator/processor/DefaultProcessorTest.php
with
25 additions
and
9 deletions
tests/src/Kernel/Plugin/aggregator/processor/DefaultProcessorTest.php
+
25
−
9
View file @
ff00a655
...
...
@@ -16,6 +16,13 @@ class DefaultProcessorTest extends KernelTestBase {
*/
protected
static
$modules
=
[
'aggregator'
,
'options'
];
/**
* An instance of the DefaultProcessor plugin.
*
* @var \Drupal\aggregator\Plugin\aggregator\processor\DefaultProcessor
*/
protected
$processor
;
/**
* {@inheritdoc}
*/
...
...
@@ -23,6 +30,11 @@ class DefaultProcessorTest extends KernelTestBase {
parent
::
setUp
();
$this
->
installEntitySchema
(
'aggregator_feed'
);
$this
->
installEntitySchema
(
'aggregator_item'
);
/** @var \Drupal\aggregator\Plugin\AggregatorPluginManager $plugin_manager */
$plugin_manager
=
$this
->
container
->
get
(
'plugin.manager.aggregator.processor'
);
/** @var \Drupal\aggregator\Plugin\aggregator\processor\DefaultProcessor $processor */
$this
->
processor
=
$plugin_manager
->
createInstance
(
'aggregator'
);
}
/**
...
...
@@ -30,23 +42,27 @@ class DefaultProcessorTest extends KernelTestBase {
*
* @dataProvider provideProcessData
*/
public
function
testProcess
(
array
$items
,
int
$expected_item_
count
)
{
public
function
testProcess
(
array
$items
,
array
$expected_item_
guids
)
{
$feed
=
Feed
::
create
([
'title'
=>
'Processor test feed'
,
'url'
=>
'https://example.com/rss.xml'
,
'items'
=>
$items
,
]);
$feed
->
save
();
/** @var \Drupal\aggregator\Plugin\AggregatorPluginManager $plugin_manager */
$plugin_manager
=
$this
->
container
->
get
(
'plugin.manager.aggregator.processor'
);
/** @var \Drupal\aggregator\Plugin\aggregator\processor\DefaultProcessor $processor */
$processor
=
$plugin_manager
->
createInstance
(
'aggregator'
);
$processor
->
process
(
$feed
);
$results
=
\Drupal
::
entityQuery
(
'aggregator_item'
)
$this
->
processor
->
process
(
$feed
);
// Assert that the items we expected were created.
$guid_check_results
=
\Drupal
::
entityQuery
(
'aggregator_item'
)
->
accessCheck
(
FALSE
)
->
condition
(
'guid'
,
$expected_item_guids
)
->
execute
();
$this
->
assertSame
(
count
(
$expected_item_guids
),
count
(
$guid_check_results
));
// Assert that no additional items were created.
$total_items_results
=
\Drupal
::
entityQuery
(
'aggregator_item'
)
->
accessCheck
(
FALSE
)
->
execute
();
$this
->
assertSame
(
$expected_item_
count
,
count
(
$results
));
$this
->
assertSame
(
count
(
$expected_item_
guids
)
,
count
(
$
total_items_
results
));
}
/**
...
...
@@ -75,7 +91,7 @@ class DefaultProcessorTest extends KernelTestBase {
'timestamp'
=>
0
,
],
],
1
,
[
2
]
,
],
];
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment