Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tome_add_paths
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
tome_add_paths
Merge requests
!2
Add functional test
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add functional test
issue/tome_add_paths-3456912:3456912-add-test-to-module
into
1.0.x
Overview
0
Commits
2
Pipelines
4
Changes
1
Merged
Brett Hoffman
requested to merge
issue/tome_add_paths-3456912:3456912-add-test-to-module
into
1.0.x
11 months ago
Overview
0
Commits
2
Pipelines
4
Changes
1
Expand
Closes
#3456912
0
0
Merge request reports
Compare
1.0.x
version 3
05fe7f05
4 months ago
version 2
05fe7f05
11 months ago
version 1
81f760fa
11 months ago
1.0.x (base)
and
latest version
latest version
05fe7f05
2 commits,
4 months ago
version 3
05fe7f05
2 commits,
4 months ago
version 2
05fe7f05
2 commits,
11 months ago
version 1
81f760fa
1 commit,
11 months ago
1 file
+
98
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
tests/src/Functional/TomeAddPathsTest.php
0 → 100644
+
98
−
0
Options
<?php
namespace
Drupal\Tests\tome_add_paths\Functional
;
use
Drupal\Tests\BrowserTestBase
;
use
Drupal\tome_static
\Event\CollectPathsEvent
;
use
Drupal\tome_static
\Event\TomeStaticEvents
;
/**
* Tests the functionality of Tome Add Paths.
*
* @coversDefaultClass \Drupal\tome_add_paths\EventSubscriber\AddPathsEventSubscriber
* @group tome_add_paths
*/
class
TomeAddPathsTest
extends
BrowserTestBase
{
/**
* The configuration factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected
$configFactory
;
/**
* The event dispatcher.
*
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
protected
$eventDispatcher
;
/**
* Modules to enable.
*
* @var array
*/
protected
static
$modules
=
[
'node'
,
'tome_add_paths'
,
];
/**
* {@inheritdoc}
*/
protected
$defaultTheme
=
'stark'
;
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
configFactory
=
\Drupal
::
service
(
'config.factory'
);
$this
->
eventDispatcher
=
\Drupal
::
service
(
'event_dispatcher'
);
$this
->
drupalLogin
(
$this
->
createUser
([
'use tome static'
]));
$this
->
drupalCreateContentType
([
'type'
=>
'article'
]);
$this
->
drupalCreateNode
([
'type'
=>
'article'
,
'title'
=>
'My First Article'
,
'path'
=>
'/my-first-path'
]);
$this
->
drupalCreateNode
([
'type'
=>
'article'
,
'title'
=>
'My Second Article'
,
'path'
=>
'/my-second-path'
]);
$this
->
drupalGet
(
'/admin/config/tome/config'
);
$this
->
SubmitForm
([
'paths'
=>
'/my-first-path\r\n/my-second-path'
,
],
'Save configuration'
);
}
/**
* Tests the Tome Add Paths admin form.
*/
public
function
testAddPathsForm
()
{
$config
=
$this
->
configFactory
->
get
(
'tome_add_paths.config'
)
->
get
(
'paths'
);
$paths
=
explode
(
'\r\n'
,
str_replace
(
"
\r\n
"
,
'\r\n'
,
$config
));
$this
->
assertSame
(
$paths
,
[
'/my-first-path'
,
'/my-second-path'
]);
}
/**
* @covers \Drupal\tome_add_paths\EventSubscriber\AddPathsEventSubscriber::addPaths
*/
public
function
testAddPaths
()
{
$this
->
eventDispatcher
->
addListener
(
TomeStaticEvents
::
COLLECT_PATHS
,
[
$this
,
'addPaths'
]);
$event
=
new
CollectPathsEvent
([]);
$this
->
eventDispatcher
->
dispatch
(
$event
,
TomeStaticEvents
::
COLLECT_PATHS
);
$paths
=
$event
->
getPaths
();
$this
->
assertContains
(
'/my-first-path'
,
$paths
);
$this
->
assertContains
(
'/my-second-path'
,
$paths
);
}
/**
* Emulates the addPaths() listener.
*
* @param \Drupal\tome_static\Event\CollectPathsEvent $event
* The collect paths event.
*/
public
function
addPaths
(
CollectPathsEvent
$event
)
{
$config
=
$this
->
configFactory
->
get
(
'tome_add_paths.config'
)
->
get
(
'paths'
);
$paths
=
explode
(
'\r\n'
,
str_replace
(
"
\r\n
"
,
'\r\n'
,
$config
));
$event
->
addPaths
(
$paths
);
}
}
Loading