Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Open
LU API
Commits
fa3d1f2f
Commit
fa3d1f2f
authored
Feb 22, 2022
by
Dainis Abols
Browse files
EmailTest
parent
ddd2d679
Changes
1
Hide whitespace changes
Inline
Side-by-side
Tests/Functional/EmailTest.php
0 → 100644
View file @
fa3d1f2f
<?php
declare
(
strict_types
=
1
);
namespace
Lu\LuApi\Functional
;
use
Lu\LuApi\Helpers\DataHelper
;
use
Vendor\MyExtension\Service\AbstractSomethingService
;
use
TYPO3\TestingFramework\Core\Unit\UnitTestCase
;
/**
* Test for route `?r=email`
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @since 22.02.2022
*/
class
EmailTest
extends
UnitTestCase
{
protected
$resetSingletonInstances
=
true
;
/**
* Public API URL
*
* @var string
*/
private
string
$url
=
'https://www.lu.lv/api/?r=email/search'
;
/**
* Email test
*
* @test
*/
public
function
emailTest
()
{
// Read url
$url
=
$this
->
url
;
$result
=
(
new
DataHelper
())
->
fetchUrl
(
$url
);
// Assert url read
$code
=
!
empty
(
$result
)
?
$result
->
getStatusCode
()
:
500
;
$this
->
assertEquals
(
200
,
$code
,
'Email Url read failed'
);
// Assert json return
$content
=
@
$result
->
getBody
()
->
getContents
();
$this
->
assertJson
(
$content
,
'Email Url response is not JSON'
);
// Check top level structure
$content
=
json_decode
(
$content
,
true
);
$this
->
assertTrue
(
count
(
$content
)
===
2
,
'Email structure count does not match'
);
$structure
=
function
(
$c
)
{
return
isset
(
$c
[
'view'
])
&&
isset
(
$c
[
'data'
])
&&
is_Array
(
$c
[
'data'
]);
};
$this
->
assertTrue
(
$structure
(
$content
),
'Email structure does not match'
);
// Check data object
$this
->
assertNotEmpty
(
$content
[
'data'
],
'Email has no data received'
);
// Check data object structure
$structure
=
function
(
$c
)
{
return
isset
(
$c
[
'webmail'
])
&&
isset
(
$c
[
'googleAccountUrl'
]);
};
$this
->
assertTrue
(
$structure
(
$content
[
'data'
]),
'Email data structure does not match'
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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