Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PHP GBIF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Res Telæ
PHP GBIF
Commits
a6db970e
Commit
a6db970e
authored
Aug 3, 2022
by
Gwendolen Lynch
Committed by
Felip Manyer i Ballester
Aug 3, 2022
Browse files
Options
Downloads
Patches
Plain Diff
Test ResTelae\Gbif\Gbif
parent
e6bbb9b7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/Unit/GbifTest.php
+96
-0
96 additions, 0 deletions
tests/Unit/GbifTest.php
with
96 additions
and
0 deletions
tests/Unit/GbifTest.php
0 → 100644
+
96
−
0
View file @
a6db970e
<?php
declare
(
strict_types
=
1
);
namespace
ResTelae\Gbif\Tests\Unit
;
use
PHPUnit\Framework\TestCase
;
use
ResTelae\Gbif\Gbif
;
use
ResTelae\Gbif\GbifException
;
/**
* @covers \ResTelae\Gbif\Gbif
* @internal
*/
final
class
GbifTest
extends
TestCase
{
public
function
providerName
():
iterable
{
yield
[
'enumeration/license'
,
[],
[
'http://creativecommons.org/publicdomain/zero/1.0/legalcode'
,
'http://creativecommons.org/licenses/by/4.0/legalcode'
,
'http://creativecommons.org/licenses/by-nc/4.0/legalcode'
,
'UNSPECIFIED'
,
'UNSUPPORTED'
,
],
];
}
/** @dataProvider providerName */
public
function
testClientGet
(
string
$uri
,
array
$args
,
array
$expected
):
void
{
static
::
assertSame
(
$expected
,
$this
->
getGbif
()
->
gbifGet
(
$uri
,
$args
));
}
public
function
testClientGetShouldThrowExceptionOnClientException
():
void
{
$this
->
expectException
(
GbifException
::
class
);
$this
->
getGbif
()
->
gbifGet
(
'invalid'
);
}
public
function
providerQueryString
():
iterable
{
yield
'Empty args'
=>
[[],
''
];
yield
'Flat args'
=>
[
[
'q'
=>
'Puma'
,
'rank'
=>
'GENUS'
,
'offset'
=>
0
,
'limit'
=>
20
],
'q=Puma&rank=GENUS&offset=0&limit=20'
,
];
yield
'Nested args'
=>
[
[
'q'
=>
[
'Puma'
,
'Cougar'
],
'rank'
=>
'GENUS'
,
'offset'
=>
0
,
'limit'
=>
20
],
'q=Puma&q=Cougar&rank=GENUS&offset=0&limit=20'
,
];
}
/** @dataProvider providerQueryString */
public
function
testFormatQueryString
(
array
$args
,
string
$expected
):
void
{
static
::
assertSame
(
$expected
,
$this
->
getGbif
()
->
formatQueryString
(
$args
));
}
public
function
providerBooleans
():
iterable
{
yield
'TRUE'
=>
[
true
,
'true'
];
yield
'FALSE'
=>
[
false
,
'false'
];
}
/** @dataProvider providerBooleans */
public
function
testBooleanToStringConversion
(
bool
$val
,
string
$expected
):
void
{
static
::
assertSame
(
$expected
,
$this
->
getGbif
()
->
bool2str
(
$val
));
}
private
function
getGbif
():
Gbif
{
return
new
class
()
extends
Gbif
{
public
function
gbifGet
(
$uri
,
array
$args
=
[])
{
return
parent
::
gbifGet
(
$uri
,
$args
);
}
public
function
formatQueryString
(
array
$args
)
{
return
parent
::
formatQueryString
(
$args
);
}
public
function
bool2str
(
bool
$val
)
{
return
parent
::
bool2str
(
$val
);
}
};
}
}
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