Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
config-devel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mikke Schirén
config-devel
Commits
3619d82e
Commit
3619d82e
authored
10 years ago
by
bircher
Committed by
Karoly Negyesi
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added unit tests for writeBackConfig #2300717 by bircher
parent
134c786f
Branches
Branches containing commit
Tags
8.x-1.0-alpha14
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/src/ConfigDevelAutoExportSubscriberTest.php
+57
-0
57 additions, 0 deletions
tests/src/ConfigDevelAutoExportSubscriberTest.php
tests/src/ConfigDevelTestBase.php
+54
-0
54 additions, 0 deletions
tests/src/ConfigDevelTestBase.php
with
111 additions
and
0 deletions
tests/src/ConfigDevelAutoExportSubscriberTest.php
0 → 100644
+
57
−
0
View file @
3619d82e
<?php
/**
* @file
* Contains \Drupal\config_devel\Tests\ConfigDevelAutoExportSubscriberTest.
*/
namespace
Drupal\config_devel\Tests
;
use
org\bovigo\vfs\vfsStream
;
use
Drupal\Component\Serialization\Yaml
;
use
Drupal\config_devel
\EventSubscriber\ConfigDevelAutoExportSubscriber
;
/**
* @coversDefaultClass \Drupal\config_devel\EventSubscriber\ConfigDevelAutoExportSubscriber
* @group config_devel
*/
class
ConfigDevelAutoExportSubscriberTest
extends
ConfigDevelTestBase
{
/**
* Test ConfigDevelAutoExportSubscriber::writeBackConfig().
*/
public
function
testWriteBackConfig
()
{
$config_data
=
array
(
'id'
=>
$this
->
randomName
(),
'langcode'
=>
'en'
,
'uuid'
=>
'836769f4-6791-402d-9046-cc06e20be87f'
,
);
$config
=
$this
->
getMockBuilder
(
'\Drupal\Core\Config\Config'
)
->
disableOriginalConstructor
()
->
getMock
();
$config
->
expects
(
$this
->
any
())
->
method
(
'getName'
)
->
will
(
$this
->
returnValue
(
$this
->
randomName
()));
$config
->
expects
(
$this
->
any
())
->
method
(
'get'
)
->
will
(
$this
->
returnValue
(
$config_data
));
$file_names
=
array
(
vfsStream
::
url
(
'public://'
.
$this
->
randomName
()
.
'.yml'
),
vfsStream
::
url
(
'public://'
.
$this
->
randomName
()
.
'.yml'
),
);
$configDevelSubscriber
=
new
ConfigDevelAutoExportSubscriber
(
$this
->
configFactory
,
$this
->
configManager
,
$this
->
fileStorage
);
$configDevelSubscriber
->
writeBackConfig
(
$config
,
$file_names
);
$data
=
$config_data
;
unset
(
$data
[
'uuid'
]);
foreach
(
$file_names
as
$file_name
)
{
$this
->
assertEquals
(
$data
,
Yaml
::
decode
(
file_get_contents
(
$file_name
)));
}
}
}
This diff is collapsed.
Click to expand it.
tests/src/ConfigDevelTestBase.php
0 → 100644
+
54
−
0
View file @
3619d82e
<?php
/**
* @file
* Contains \Drupal\config_devel\Tests\ConfigDevelTestBase.
*/
namespace
Drupal\config_devel\Tests
;
use
org\bovigo\vfs\vfsStream
;
use
Drupal\Tests\UnitTestCase
;
/**
* Helper class with mock objects.
*/
abstract
class
ConfigDevelTestBase
extends
UnitTestCase
{
/**
* @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected
$configFactory
;
/**
* @var \Drupal\Core\Config\ConfigManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected
$configManager
;
/**
* @var \Drupal\Core\Config\FileStorage|\PHPUnit_Framework_MockObject_MockObject
*/
protected
$fileStorage
;
/**
* {@inheritdoc}
*/
public
function
setUp
()
{
parent
::
setUp
();
$this
->
configFactory
=
$this
->
getMock
(
'Drupal\Core\Config\ConfigFactoryInterface'
);
$this
->
configManager
=
$this
->
getMock
(
'Drupal\Core\Config\ConfigManagerInterface'
);
$this
->
configManager
->
expects
(
$this
->
any
())
->
method
(
'getEntityTypeIdByName'
)
->
will
(
$this
->
returnArgument
(
0
));
$this
->
fileStorage
=
$this
->
getMockBuilder
(
'Drupal\Core\Config\FileStorage'
)
->
disableOriginalConstructor
()
->
getMock
();
$this
->
fileStorage
->
expects
(
$this
->
any
())
->
method
(
'encode'
)
->
will
(
$this
->
returnCallback
(
'Drupal\Component\Serialization\Yaml::encode'
));
vfsStream
::
setup
(
'public://'
);
}
}
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