This repository has been archived by the owner on Aug 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give it a first try to get data from European data Portal endpoint.
- Loading branch information
1 parent
c3c27e4
commit 595d1c7
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\dcat_demo\Functional; | ||
|
||
use Drupal\Tests\BrowserTestBase; | ||
use Drupal\Tests\rdf_entity\Traits\RdfDatabaseConnectionTrait; | ||
|
||
/** | ||
* Makes a demo as functional test. | ||
*/ | ||
class DcatDemoTest extends BrowserTestBase { | ||
|
||
use RdfDatabaseConnectionTrait { | ||
getSparqlConnectionInfo as getSparqlConnectionInfoTrait; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = [ | ||
'dcat_demo', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp() { | ||
$this->setUpSparql(); | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function test() { | ||
$query = <<<Query | ||
SELECT DISTINCT ?Concept | ||
WHERE { | ||
[] a ?Concept | ||
} | ||
LIMIT 100 | ||
Query; | ||
$response = $this->sparql->query($query); | ||
print $response->count(); | ||
foreach ($response as $row) { | ||
print_r($row->Concept->getUri() . "\n"); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getSparqlConnectionInfo(): array { | ||
if (!isset($this->sparqlConnectionInfo)) { | ||
$this->getSparqlConnectionInfoTrait(); | ||
$this->sparqlConnectionInfo['host'] = 'data.europa.eu'; | ||
$this->sparqlConnectionInfo['port'] = 80; | ||
$this->sparqlConnectionInfo['database'] = 'euodp/sparqlep'; | ||
} | ||
return $this->sparqlConnectionInfo; | ||
} | ||
|
||
} |