Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
subrequests
Commits
71e3b0d7
Unverified
Commit
71e3b0d7
authored
Sep 12, 2017
by
Mateu Aguiló Bosch
Browse files
test(Misc): Add test coverage to the MultiresponseNormalizer
parent
29e43d2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/src/Unit/Normalizer/MultiresponseNormalizerTest.php
0 → 100644
View file @
71e3b0d7
<?php
namespace
Drupal\Tests\subrequests\Normalizer
;
use
Drupal\subrequests\Normalizer\MultiresponseNormalizer
;
use
Drupal\Tests\UnitTestCase
;
use
Symfony\Component\HttpFoundation\Response
;
/**
* @coversDefaultClass \Drupal\subrequests\Normalizer\MultiresponseNormalizer
* @group subrequests
*/
class
MultiresponseNormalizerTest
extends
UnitTestCase
{
/**
* @var \Drupal\subrequests\Normalizer\MultiresponseNormalizer
*/
protected
$sut
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
sut
=
new
MultiresponseNormalizer
();
}
/**
* @dataProvider dataProviderSupportsNormalization
* @covers ::supportsNormalization
*/
public
function
testSupportsNormalization
(
$data
,
$format
,
$is_supported
)
{
$actual
=
$this
->
sut
->
supportsNormalization
(
$data
,
$format
);
$this
->
assertSame
(
$is_supported
,
$actual
);
}
public
function
dataProviderSupportsNormalization
()
{
return
[
[[
Response
::
create
(
''
)],
'multipart-related'
,
TRUE
],
[[],
'multipart-related'
,
TRUE
],
[[
Response
::
create
(
''
)],
'fail'
,
FALSE
],
[
NULL
,
'multipart-related'
,
FALSE
],
[[
Response
::
create
(
''
),
NULL
],
'multipart-related'
,
FALSE
],
];
}
/**
* @covers ::normalize
*/
public
function
testNormalize
()
{
$delimiter
=
$this
->
getRandomGenerator
()
->
string
();
$data
=
[
Response
::
create
(
'Foo!'
),
Response
::
create
(
'Bar'
)];
$actual
=
$this
->
sut
->
normalize
(
$data
,
NULL
,
[
'delimiter'
=>
$delimiter
]);
$this
->
assertStringStartsWith
(
'--'
.
$delimiter
,
$actual
);
$this
->
assertStringEndsWith
(
'--'
.
$delimiter
.
'--'
,
$actual
);
$this
->
assertRegExp
(
"/
\r\n
Foo!
\r\n
/"
,
$actual
);
$this
->
assertRegExp
(
"/
\r\n
Bar
\r\n
/"
,
$actual
);
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment