Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dkan_datastore
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
dkan_datastore
Commits
4145f3e5
Commit
4145f3e5
authored
8 years ago
by
Mariano Carballal
Committed by
NuCivic Devops
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add getUUID function to avoid uuid mistyping
parent
1d954b24
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/dkan_datastore_api/tests/phpunit/DkanDatastoreAPITest.php
+37
-18
37 additions, 18 deletions
...dkan_datastore_api/tests/phpunit/DkanDatastoreAPITest.php
with
37 additions
and
18 deletions
modules/dkan_datastore_api/tests/phpunit/DkanDatastoreAPITest.php
+
37
−
18
View file @
4145f3e5
...
...
@@ -5,19 +5,33 @@
*/
class
DkanDatastoreAPITest
extends
\PHPUnit_Framework_TestCase
{
/**
* {@inheritdoc}
*/
public
static
function
setUpBeforeClass
()
{
$resources
=
self
::
getResources
();
foreach
(
$resources
as
$resource
)
{
self
::
addResource
(
$resource
);
}
}
/**
* Retrieves an keyed array of resources.
*/
private
static
function
getResources
()
{
$resources
=
array
(
array
(
'gold_prices'
=>
array
(
'filename'
=>
'gold_prices.csv'
,
'title'
=>
'Gold Prices'
,
'uuid'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae77'
),
array
(
'gold_prices_states'
=>
array
(
'filename'
=>
'gold_prices_states.csv'
,
'title'
=>
'Gold Prices States'
,
'uuid'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae78'
),
array
(
'polling_places'
=>
array
(
'filename'
=>
'polling_places.csv'
,
'title'
=>
'Polling Places'
,
'uuid'
=>
'3a05eb9c-3733-11e6-ac61-9e71128cae79'
...
...
@@ -25,17 +39,22 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
);
return
$resources
;
}
/**
*
{@inheritdoc}
*
Given a resource key retrieves a uuid.
*/
public
static
function
setUpBeforeClass
()
{
$resources
=
self
::
getResources
();
foreach
(
$resources
as
$resource
)
{
self
::
addResource
(
$resource
);
private
static
function
getUUID
(
$key
,
$resources
)
{
if
(
array_key_exists
(
$key
,
$resources
))
{
return
$resources
[
$key
][
'uuid'
];
}
else
{
throw
new
\Exception
(
'Resource is not defined'
);
}
}
/**
* Add a resource to test.
*/
private
static
function
addResource
(
$resource
)
{
// Create resource.
...
...
@@ -78,7 +97,7 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
public
function
test_dkan_datstore_api_query
()
{
$params
=
array
(
'resource_id'
=>
array
(
'polling_places'
=>
'3a05eb9c-3733-11e6-ac61-9e71128cae79'
'polling_places'
=>
self
::
getUUID
(
'polling_places'
,
self
::
getResources
()),
),
'limit'
=>
1000
,
'query'
=>
'City'
...
...
@@ -94,7 +113,7 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
public
function
test_dkan_datstore_api_filters
()
{
$params
=
array
(
'resource_id'
=>
array
(
'gold_prices'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae77'
'gold_prices'
=>
self
::
getUUID
(
'gold_prices'
,
self
::
getResources
()),
),
'limit'
=>
1000
,
'filters'
=>
array
(
...
...
@@ -112,7 +131,7 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
public
function
test_dkan_datstore_api_offset
()
{
$params
=
array
(
'resource_id'
=>
array
(
'gold_prices_states'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae78'
'gold_prices_states'
=>
self
::
getUUID
(
'gold_prices_states'
,
self
::
getResources
()),
),
'limit'
=>
1
,
'offset'
=>
1
,
...
...
@@ -128,7 +147,7 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
public
function
test_dkan_datstore_api_limit
()
{
$params
=
array
(
'resource_id'
=>
array
(
'gold_prices_states'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae78'
'gold_prices_states'
=>
self
::
getUUID
(
'gold_prices_states'
,
self
::
getResources
()),
),
'limit'
=>
1
);
...
...
@@ -143,7 +162,7 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
public
function
test_dkan_datstore_api_fields
()
{
$params
=
array
(
'resource_id'
=>
array
(
'gold_prices
'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae78'
'gold_prices
_states'
=>
self
::
getUUID
(
'gold_prices_states'
,
self
::
getResources
()),
),
'fields'
=>
array
(
'nombre'
),
'limit'
=>
1
,
...
...
@@ -159,7 +178,7 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
public
function
test_dkan_datstore_api_sort
()
{
$params
=
array
(
'resource_id'
=>
array
(
'gold_prices_states'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae78'
'gold_prices_states'
=>
self
::
getUUID
(
'gold_prices_states'
,
self
::
getResources
()),
),
'sort'
=>
array
(
'state_id'
=>
'desc'
),
'limit'
=>
1
...
...
@@ -175,7 +194,7 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
public
function
test_dkan_datstore_api_group_by
()
{
$params
=
array
(
'resource_id'
=>
array
(
'gold_prices'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae77'
'gold_prices'
=>
self
::
getUUID
(
'gold_prices'
,
self
::
getResources
()),
),
'limit'
=>
1000
,
'group_by'
=>
array
(
'price'
)
...
...
@@ -191,11 +210,11 @@ class DkanDatastoreAPITest extends \PHPUnit_Framework_TestCase {
public
function
test_dkan_datstore_api_join
()
{
$params
=
array
(
'resource_id'
=>
array
(
'
states'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae78'
,
'gold_prices'
=>
'3a05eb8c-3733-11e6-ac61-9e71128cae77'
'
gold_prices_states'
=>
self
::
getUUID
(
'gold_prices_states'
,
self
::
getResources
())
,
'gold_prices'
=>
self
::
getUUID
(
'gold_prices'
,
self
::
getResources
()),
),
'join'
=>
array
(
'states'
=>
'state_id'
,
'
gold_prices_
states'
=>
'state_id'
,
'gold_prices'
=>
'state_id'
,
),
'limit'
=>
5
,
...
...
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