diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 2b0c8fca60..b0dc92c53f 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -2,6 +2,24 @@
--------
- #2290 Add Extended Metadata Field for Datasets
+7.x-1.14.3
+----------
+ - #2377 Upgrade entity to 1.9
+
+7.x-1.14.2
+----------
+ - #2359 Upgrade filefield_sources to 1.11
+ - #2341 Modifies curl settings so url headers and info can be properly acquired with curl
+ - #2370 Patch features to add new line after div.version {
+ color: #eee;
+}
diff --git a/docs/admin/index.rst b/docs/admin/index.rst
index 6bf99d2630..519a90bc1b 100644
--- a/docs/admin/index.rst
+++ b/docs/admin/index.rst
@@ -35,8 +35,10 @@ Appearance
:maxdepth: 1
account_access_and_setup
+ adding_new_content
+ admin_menu
appearance
data_and_content/index
people/index
structure
- admin_menu
+
diff --git a/docs/admin/sitemanagermaintenance b/docs/admin/sitemanagermaintenance
new file mode 100644
index 0000000000..92fba7536e
--- /dev/null
+++ b/docs/admin/sitemanagermaintenance
@@ -0,0 +1,47 @@
+# Site Manager Monthly Maintenance Checklist
+
+
+### Content
+*(Accessible via the “Content” tab on the black site administration toolbar)*
+
+- Check the “Content” list for an overview of the content currently hosted on your site.
+
+- Is there any content that needs to be published or unpublished? Are there duplicates? If so, take a moment to clean up your content.
+
+### Groups
+*(Accessible via the “Groups” button on the main site navigation bar)*
+
+- Is the Groups list up to date?
+
+- Does each Group have an appropriate image and description?
+
+### Tags and Taxonomies
+*(Mouse over Site Configuration on the black site administration toolbar, then click “Taxonomy”)*
+
+- Check your site’s list of Tags, located in the Taxonomy menu. To view a list of all Tags on the site, click “List terms.”
+
+- Are there any misspelled tags? Are there any duplicate tags? If so, take a moment to clean up your tags.
+
+### User management
+*(Accessible via the “People” tab on the black site administration toolbar)*
+
+- Is the user list up to date? For site security, always double-check that there aren’t any accounts accessible to users who have left your organization. If this is the case, their accounts should be canceled or blocked.
+
+- Do all of the users in your organization have the proper site roles? (Site Manager, Editor, Content Creator.)
+
+### Workbench (Optional, if the Workbench/Workflow Modules have been enabled)
+*(Accessible via the “My Workbench” tab in the site administration bar)*
+
+- Workbench moderation queue tasks - check each of these tabs:
+
+**My drafts**
+- Are there any drafts that ought to be pushed to “Published” or “Needs Review”?
+
+**Needs review**
+- Are there any items under review that ought to be pushed back to “Draft” or published?
+
+**Stale drafts**
+- These are drafts that have been unmoderated for over 72 hours. Make sure content doesn’t build up under this queue!
+
+**Stale reviews**
+- These are items under review that have been unmoderated for over 72 hours.
diff --git a/docs/community/help.rst b/docs/community/help.rst
index f30b940d23..5dbc0d4c92 100644
--- a/docs/community/help.rst
+++ b/docs/community/help.rst
@@ -7,3 +7,13 @@ For professional DKAN development services and support:
- `Angry Cactus `_
- `National Democratic Institute `_
- `Annai `_
+
+Add your company
+=================
+
+If you provide DKAN development and/or support services, here's how to add your company to business directory:
+
+- Create a /dkan page on your website (ex: https://civicactions.com/dkan/)
+- Create a [new issue](https://github.com/GetDKAN/dkan/issues/new) and include logo, company name, link to /dkan page, brief description of services with respect to DKAN
+
+Someone on the DKAN team will review your request and add your company if it's appropriate for the DKAN community.
diff --git a/docs/conf.py b/docs/conf.py
index f530f7dcd3..a31e3b7ef4 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -19,13 +19,13 @@
master_doc = 'index'
# General information about the project.
-project = u'DKAN'
+project = u'DKAN Docs'
copyright = u'2017'
author = u'DKAN Team'
-version = '1.13'
-release = '1.13'
+version = '1.14'
+release = '1.14'
language = 'en'
@@ -214,6 +214,7 @@
github_doc_root = 'https://github.com/GetDKAN/dkan/tree/rtd/docs/'
def setup(app):
+ app.add_stylesheet( "css/custom.css" )
app.add_config_value('recommonmark_config', {
'url_resolver': lambda url: github_doc_root + url,
'auto_toc_tree_section': 'Contents',
diff --git a/docs/requirements.txt b/docs/requirements.txt
index c50eac206b..e62fbc1865 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,4 +1,4 @@
-sphinx>=1.5.2
+sphinx==1.5.6
sphinx-rtd-theme>=0.2.4
recommonmark==0.4.0
# sphinxcontrib-httpdomain==1.5.0
diff --git a/drupal-org.make b/drupal-org.make
index 066f042d0e..ede9de1d75 100644
--- a/drupal-org.make
+++ b/drupal-org.make
@@ -1,21 +1,22 @@
+---
api: '2'
core: 7.x
includes:
- - "https://raw.githubusercontent.com/NuCivic/visualization_entity/7.x-1.x/visualization_entity.make"
- - "https://raw.githubusercontent.com/NuCivic/open_data_schema_map/7.x-1.x/open_data_schema_map.make"
- - "https://raw.githubusercontent.com/NuCivic/leaflet_draw_widget/master/leaflet_widget.make"
- - "https://raw.githubusercontent.com/NuCivic/recline/7.x-1.x/recline.make"
+- https://raw.githubusercontent.com/NuCivic/visualization_entity/7.x-2.0/visualization_entity.make
+- https://raw.githubusercontent.com/NuCivic/open_data_schema_map/7.x-2.0/open_data_schema_map.make
+- https://raw.githubusercontent.com/NuCivic/leaflet_draw_widget/5a5f8faf664aeca02371f6692307580d9fab9116/leaflet_widget.make
+- https://raw.githubusercontent.com/NuCivic/recline/7.x-2.0/recline.make
projects:
admin_menu:
- version: '3.0-rc5'
+ version: 3.0-rc5
admin_menu_source:
version: '1.1'
patch:
- 2441283: 'https://www.drupal.org/files/issues/allow_ordering_of_the-2441283-5.patch'
+ 2441283: https://www.drupal.org/files/issues/allow_ordering_of_the-2441283-5.patch
admin_views:
version: '1.6'
patch:
- 1780004: 'https://www.drupal.org/files/issues/admin_views-duplicate_system_path-1780004-54.patch'
+ 1780004: https://www.drupal.org/files/issues/admin_views-duplicate_system_path-1780004-54.patch
adminrole:
version: '1.1'
autocomplete_deluxe:
@@ -60,7 +61,7 @@ projects:
date:
version: '2.10'
defaultconfig:
- version: '1.0-alpha11'
+ version: 1.0-alpha11
devel:
version: '1.5'
diff:
@@ -76,7 +77,7 @@ projects:
version: '2.1'
entity:
download:
- full_version: 7.x-1.8
+ full_version: 7.x-1.9
patch:
2341611: https://www.drupal.org/files/issues/entity-multivalue-token-replacement-fix-2341611-0.patch
2564119: https://www.drupal.org/files/issues/Use-array-in-foreach-statement-2564119-1.patch
@@ -98,6 +99,8 @@ projects:
version: '1.4'
features:
version: '2.10'
+ patch:
+ 2765721: https://www.drupal.org/files/issues/features-blank-line-after-php-tag-2765721-0.patch
features_roles_permissions:
version: '1.2'
feeds:
@@ -120,8 +123,8 @@ projects:
feeds_flatstore_processor:
download:
type: git
- url: 'https://github.com/GetDKAN/feeds_flatstore_processor.git'
- branch: master
+ url: https://github.com/GetDKAN/feeds_flatstore_processor.git
+ revision: 82b2a05bd133dbf870bdf09f1c0a45711f1432e3
field_group:
version: '1.5'
patch:
@@ -150,7 +153,7 @@ projects:
url: https://git.drupal.org/project/file_resup.git
revision: 6cf030c2c139374c75527221775965ff0242df15
filefield_sources:
- version: '1.10'
+ version: '1.11'
font_icon_select:
download:
type: git
@@ -191,8 +194,8 @@ projects:
leaflet_draw_widget:
download:
type: git
- url: 'https://github.com/GetDKAN/leaflet_draw_widget.git'
- branch: 'master'
+ url: https://github.com/GetDKAN/leaflet_draw_widget.git
+ revision: 5a5f8faf664aeca02371f6692307580d9fab9116
libraries:
version: '2.3'
link:
@@ -250,7 +253,7 @@ projects:
download:
type: git
url: https://github.com/GetDKAN/open_data_schema_map.git
- branch: 7.x-1.x
+ tag: 7.x-2.0
panelizer:
version: '3.4'
panels:
@@ -283,8 +286,8 @@ projects:
recline:
download:
type: git
- url: 'https://github.com/GetDKAN/recline.git'
- branch: 7.x-1.x
+ url: https://github.com/GetDKAN/recline.git
+ tag: 7.x-2.0
ref_field:
download:
type: git
@@ -296,7 +299,7 @@ projects:
download:
type: git
url: https://github.com/GetDKAN/remote_stream_wrapper.git
- branch: 7.x-1.x
+ revision: 20311eee8f0ba87cbb7e48788b176c34e0313a78
replicate:
version: '1.2'
replicate_paragraphs:
@@ -338,8 +341,8 @@ projects:
taxonomy_fixtures:
download:
type: git
- url: 'https://github.com/GetDKAN/taxonomy_fixtures.git'
- branch: 7.x-1.x
+ url: https://github.com/GetDKAN/taxonomy_fixtures.git
+ revision: efabb2362509f80c40084109456c7483b5452b0a
token:
version: '1.7'
token_tweaks:
@@ -361,7 +364,7 @@ projects:
download:
type: git
url: https://github.com/GetDKAN/visualization_entity.git
- branch: 7.x-1.x
+ tag: 7.x-2.0
type: module
workbench:
version: '1.2'
diff --git a/modules/dkan/dkan_dataset/includes/getRemoteFileInfo.php b/modules/dkan/dkan_dataset/includes/getRemoteFileInfo.php
index 51a8c17ebf..0464afae3e 100644
--- a/modules/dkan/dkan_dataset/includes/getRemoteFileInfo.php
+++ b/modules/dkan/dkan_dataset/includes/getRemoteFileInfo.php
@@ -12,86 +12,14 @@ class GetRemoteFileInfo {
*
* @var info
*/
- public $info = FALSE;
public $url;
- public $agent;
- public $followRedirect;
/**
* Class constructor.
*/
public function __construct($url, $agent, $followRedirect = TRUE) {
$this->url = $url;
- $this->agent = $agent;
- $this->followRedirect = $followRedirect;
-
- $this->info = $this->curlHeader($this->url, $this->agent, $this->followRedirect);
- }
-
- /**
- * Retrieves headers from url.
- */
- public function curlHeader($url, $agent, $followRedirect) {
- $info = array();
-
- $ch = $this->getBaseCh($url, $agent, $followRedirect);
-
- // This changes the request method to HEAD. No need to "GET" the hole link.
- curl_setopt($ch, CURLOPT_NOBODY, TRUE);
-
- $http_heading = curl_exec($ch);
-
- if (!$http_heading) {
- // Should set the GetRemoteFileInfo::$info to false.
- return FALSE;
- }
-
- $info['header'] = $this->httpParseHeaders($http_heading);
- $info['info'] = curl_getinfo($ch);
- $info['effective_url'] = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
- curl_close($ch);
-
- return $info;
- }
-
- /**
- * Helper method to construct a base cURL handle.
- */
- private function getBaseCh($url, $agent, $followRedirect) {
- $ch = curl_init();
-
- curl_setopt($ch, CURLOPT_URL, $url);
- // Spoof the User Agent.
- curl_setopt($ch, CURLOPT_USERAGENT, $agent);
-
- // Wait only 5 seconds.
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
-
- // Return the transfer as a string of the return value of curl_exec()
- // instead of outputting it out directly.
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
-
- // Follow redirects.
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followRedirect);
- curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
-
- // Force the use of a new connection instead of a cached one.
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
-
- // Attempt to retrieve the modification date of the remote document.
- curl_setopt($ch, CURLOPT_FILETIME, TRUE);
-
- // Cookies.
- curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
- curl_setopt($ch, CURLOPT_COOKIE, "");
-
- // Include the header in the output.
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
- curl_setopt($ch, CURLOPT_HEADER, TRUE);
-
- return $ch;
+ $this->info = $this->getFileInfo($this->url);
}
/**
@@ -106,18 +34,16 @@ public function getInfo() {
*/
public function getType() {
if ($info = $this->getInfo()) {
- $type = $info['header']['Content-Type'];
- // If the url had redirects, CURL will stack the Content Types from all
- // the urls. Get the last url.
- if (is_array($type)) {
- $type = array_pop($type);
- }
+ if (!empty($info["Content-Type"])) {
+ $content_types = array_values($info["Content-Type"]);
+ $array_size = count($content_types);
+ $last_element = $array_size - 1;
- if ($explode = explode(";", $type)) {
- return $explode[0];
- }
- else {
- return $type;
+ $type = $content_types[$last_element];
+
+ $pieces = explode(";", $type);
+
+ return trim($pieces[0]);
}
}
@@ -176,45 +102,18 @@ public function getExtension() {
*/
public function getEffectiveUrl() {
$info = $this->getInfo();
- if (!empty($info)) {
- return $info['effective_url'];
- }
- return FALSE;
- }
- /**
- * Retrieves URL from end of string.
- */
- public function getNameFromUrl() {
- $basename = basename($this->url);
- $name = explode('.', $basename);
- if (count($name) > 2) {
- $name = parse_url($basename);
- if (isset($name['path'])) {
- return $name['path'];
- }
- }
- elseif (count($name) == 1) {
- return $name[0];
- }
- return FALSE;
- }
+ if (!empty($info['Location'])) {
+ $urls = array_values($info["Location"]);
+ $array_size = count($urls);
+ $last_element = $array_size - 1;
- /**
- * Finds filename from Content Disposition header.
- */
- public function checkDisposition($disposition) {
- if (preg_match('/.*?filename=(.+)/i', $disposition, $matches)) {
- return trim($matches[1]);
- }
- elseif (preg_match('/.*?filename="(.+?)"/i', $disposition, $matches)) {
- return trim($matches[1]);
- }
- elseif (preg_match('/.*?filename=([^; ]+)/i', $header, $matches)) {
- return trim($matches[1]);
+ $url = $urls[$last_element];
+
+ return trim($url);
}
- elseif ($exploded = explode('filename=', $disposition)) {
- return trim($exploded[1]);
+ else {
+ return $this->url;
}
}
@@ -228,72 +127,134 @@ public function checkDisposition($disposition) {
*/
public function getName() {
if ($info = $this->getInfo()) {
- // Check Location for proper URL.
- // When URL have redirects the ['header']['Location'] will be an array.
- if (isset($info['header']['Location']) && is_array($info['header']['Location'])) {
- $location = $info['header']['Location'];
- $location = array_shift($location);
- }
-
- if (isset($location) && valid_url($location)) {
- if ($name = $this->getNameFromUrl($this->url)) {
+ $spellings = [
+ 'Content-Disposition',
+ 'Content-disposition',
+ 'content-disposition'
+ ];
+
+ foreach ($spellings as $spelling) {
+ if (isset($info[$spelling]) && $name = $this->checkDisposition($info[$spelling])) {
return $name;
}
}
- // Check content disposition.
- if (isset($info['header']['Content-Disposition'])) {
- return $this->checkDisposition($info['header']['Content-Disposition']);
- }
- elseif (isset($info['header']['Content-disposition'])) {
- return $this->checkDisposition($info['header']['Content-disposition']);
- }
- elseif (isset($info['header']['content-disposition'])) {
- return $this->checkDisposition($info['header']['content-disposition']);
- }
// Check URL for filename at end of string.
- if ($name = $this->getNameFromUrl($this->url)) {
+ if ($name = $this->getNameFromUrl()) {
return $name;
}
else {
return NULL;
}
}
- else {
- return NULL;
+
+ return NULL;
+ }
+
+ /**
+ * Helper function.
+ */
+ private function getFileInfoHelper($url, $no_body = TRUE) {
+ ob_start();
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ if ($no_body) {
+ curl_setopt($ch, CURLOPT_NOBODY, 1);
+ }
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Range: bytes=0-1000"));
+
+ $ok = curl_exec($ch);
+
+ curl_close($ch);
+
+ $data = ob_get_contents();
+ @ob_end_clean();
+
+ if ($ok) {
+ $info = $this->parseRequestData($data);
+ if (empty($info['Content-Type'])) {
+ return FALSE;
+ }
+ return $info;
}
+
+ return FALSE;
+ }
+
+ /**
+ * Retrieves info from url.
+ */
+ private function getFileInfo($url) {
+ if ($info = $this->getFileInfoHelper($url)) {
+ return $info;
+ }
+
+ if ($info = $this->getFileInfoHelper($url, FALSE)) {
+ return $info;
+ }
+
+ return FALSE;
}
/**
* Converts headers from curl request to array.
*/
- public function httpParseHeaders($raw_headers) {
- $headers = array();
- $key = '';
- foreach (explode("\n", $raw_headers) as $i => $h) {
- $h = explode(':', $h, 2);
- if (isset($h[1])) {
- if (!isset($headers[$h[0]])) {
- $headers[$h[0]] = trim($h[1]);
- }
- elseif (is_array($headers[$h[0]])) {
- $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
- }
- else {
- $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
- }
- $key = $h[0];
+ private function parseRequestData($request_data) {
+ $info = [];
+ $pieces = explode(PHP_EOL, $request_data);
+
+ foreach ($pieces as $piece) {
+ $key_value = explode(":", $piece);
+ if (count($key_value) >= 2) {
+ $key = array_shift($key_value);
+ $info[$key][] = implode(":", $key_value);
}
- else {
- if (substr($h[0], 0, 1) == "\t") {
- $headers[$key] .= "\r\n\t" . trim($h[0]);
- }
- elseif (!$key) {
- $headers[0] = trim($h[0]);trim($h[0]);
- }
+ }
+
+ return $info;
+ }
+
+ /**
+ * Retrieves URL from end of string.
+ */
+ private function getNameFromUrl() {
+
+ $url = $this->getEffectiveUrl();
+
+ $parsed = parse_url($url);
+
+ if (isset($parsed['path'])) {
+ $pieces = explode('/', $parsed['path']);
+ return $pieces[count($pieces) - 1];
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Finds filename from Content Disposition header.
+ */
+ private function checkDisposition($disposition) {
+ $disposition = array_shift($disposition);
+
+ $regexes = [
+ '/.*?filename=(.+)/i',
+ '/.*?filename="(.+?)"/i',
+ '/.*?filename=([^; ]+)/i'
+ ];
+
+ foreach ($regexes as $regex) {
+ if (preg_match($regex, $disposition, $matches)) {
+ return trim($matches[1]);
}
}
- return $headers;
+
+ if ($exploded = explode('filename=', $disposition)) {
+ return trim($exploded[1]);
+ }
+
+ return FALSE;
}
}
diff --git a/modules/dkan/dkan_datastore/modules/dkan_datastore_api/dkan_datastore_api.module b/modules/dkan/dkan_datastore/modules/dkan_datastore_api/dkan_datastore_api.module
index 52698dad73..7dc0d355dc 100644
--- a/modules/dkan/dkan_datastore/modules/dkan_datastore_api/dkan_datastore_api.module
+++ b/modules/dkan/dkan_datastore/modules/dkan_datastore_api/dkan_datastore_api.module
@@ -903,7 +903,6 @@ function dkan_datastore_api_output($data_select, $results, $table, $fields, $res
$return->limit = (int) $limit;
$return->total = (int) $count;
$return->records = $items;
- $return->sql = dkan_datastore_api_debug($data_select);
return $help + $success + array('result' => $return);
}
diff --git a/modules/dkan/dkan_sitewide/dkan_sitewide.views_default.inc b/modules/dkan/dkan_sitewide/dkan_sitewide.views_default.inc
index 284ca9c1e5..af201f909b 100644
--- a/modules/dkan/dkan_sitewide/dkan_sitewide.views_default.inc
+++ b/modules/dkan/dkan_sitewide/dkan_sitewide.views_default.inc
@@ -114,6 +114,10 @@ function dkan_sitewide_views_default_views() {
);
$handler->display->display_options['style_options']['sticky'] = TRUE;
$handler->display->display_options['style_options']['empty_table'] = TRUE;
+ /* Header: Global: Result summary */
+ $handler->display->display_options['header']['result']['id'] = 'result';
+ $handler->display->display_options['header']['result']['table'] = 'views';
+ $handler->display->display_options['header']['result']['field'] = 'result';
/* No results behavior: Global: Unfiltered text */
$handler->display->display_options['empty']['area_text_custom']['id'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['table'] = 'views';
@@ -434,6 +438,10 @@ function dkan_sitewide_views_default_views() {
);
$handler->display->display_options['style_options']['sticky'] = TRUE;
$handler->display->display_options['style_options']['empty_table'] = TRUE;
+ /* Header: Global: Result summary */
+ $handler->display->display_options['header']['result']['id'] = 'result';
+ $handler->display->display_options['header']['result']['table'] = 'views';
+ $handler->display->display_options['header']['result']['field'] = 'result';
/* No results behavior: Global: Unfiltered text */
$handler->display->display_options['empty']['area_text_custom']['id'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['table'] = 'views';
diff --git a/test/features/resource.all.feature b/test/features/resource.all.feature
index edcf6c525c..79ec229a3b 100644
--- a/test/features/resource.all.feature
+++ b/test/features/resource.all.feature
@@ -87,7 +87,7 @@ Feature: Resource
Then I should see "The Resource ID for this resource is"
And I should see "Example Query"
- @resource_all_06 @api @noworkflow
+ @resource_all_06 @api @noworkflow
Scenario: View previous revisions of published resource
Given I am logged in as a user with the "administrator" role
And I am on "Resource 01" page
@@ -122,7 +122,9 @@ Feature: Resource
@resource_all_09 @api
Scenario: View dataset reference on Resource teaser
Given I am on "/search"
- And I click "Resource"
+ And I click "Resource" in the "facet container" region
+ And I fill in "edit-query" with "Resource 01"
+ And I press "Apply"
Then I should see "Dataset 01"
@resource_all_10 @api @noworkflow
@@ -143,7 +145,7 @@ Feature: Resource
When I click "Resource 01"
Then I should see "Edit"
When I click "Edit"
- ## If you use selenium uncomment this
+ ## If you use selenium uncomment this
# And I click "Remote file"
And I fill in "edit-field-link-remote-file-und-0-filefield-dkan-remotefile-url" with "https://s3.amazonaws.com/dkan-default-content-files/files/district_centerpoints_0.csv"
And I press "edit-submit"
diff --git a/test/phpunit/dkan_dataset/getRemoteFileInfoTest.php b/test/phpunit/dkan_dataset/getRemoteFileInfoTest.php
index ebf8d7796e..74dfc0555f 100644
--- a/test/phpunit/dkan_dataset/getRemoteFileInfoTest.php
+++ b/test/phpunit/dkan_dataset/getRemoteFileInfoTest.php
@@ -40,24 +40,33 @@ public function getHeaders($url) {
* Run test URLs threw the getRemoteFileInfo class.
*/
public function testUrls() {
- $url = 'https://data.wa.gov/api/views/mu24-67ke/rows.csv?accessType=DOWNLOAD';
- $fileInfo = new getRemoteFileInfo($url, 'test', TRUE);
- $this->assertEquals($fileInfo->getType(), 'text/csv');
- $this->assertEquals($fileInfo->getName(), 'Hospital_Inpatient_Discharges_by_DRG__Northwest__FY2011.csv');
- }
+ $urls = [];
+ $urls[0]['url'] = 'https://data.wa.gov/api/views/mu24-67ke/rows.csv?accessType=DOWNLOAD';
+ $urls[0]['type'] = 'text/csv';
+ $urls[0]['extension'] = 'csv';
+ $urls[0]['name'] = "Hospital_Inpatient_Discharges_by_DRG__Northwest__FY2011.csv";
- /**
- * Test URL extension.
- *
- * Mimetype can have multiple extensions associated to it. This test make sure
- * that the returned extension matches both the Mimetype and the actual file
- * extension.
- */
- public function testUrlExtension() {
- $url = "https://s3.amazonaws.com/dkan-default-content-files/files/albo.xls";
- $fileInfo = new getRemoteFileInfo($url, 'test', TRUE);
- $this->assertEquals($fileInfo->getType(), 'application/vnd.ms-excel');
- $this->assertEquals($fileInfo->getExtension(), 'xls');
+ $urls[1]['url'] = "https://data.ca.gov/node/1801/download";
+ $urls[1]['type'] = 'text/csv';
+ $urls[1]['extension'] = 'csv';
+ $urls[1]['name'] = "uw_supplier_data020618.csv";
+
+ $urls[2]['url'] = "https://s3.amazonaws.com/dkan-default-content-files/files/albo.xls";
+ $urls[2]['type'] = 'application/vnd.ms-excel';
+ $urls[2]['extension'] = 'xls';
+ $urls[2]['name'] = "albo.xls";
+
+ $urls[3]['url'] = "https://data.chhs.ca.gov/dataset/596b5eed-31de-4fd8-a645-249f3f9b19c4/resource/57da6c9a-41a7-44b0-ab8d-815ff2cd5913/download/cscpopendata.csv";
+ $urls[3]['type'] = 'text/csv';
+ $urls[3]['extension'] = 'csv';
+ $urls[3]['name'] = "cscpopendata.csv";
+
+ foreach ($urls as $key => $info) {
+ $fileInfo = new getRemoteFileInfo($info['url'], 'test', TRUE);
+ $this->assertEquals($fileInfo->getType(), $info['type']);
+ $this->assertEquals($fileInfo->getExtension(), $info['extension']);
+ $this->assertEquals($fileInfo->getName(), $info['name']);
+ }
}
}