Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Commit

Permalink
Give it a first try to get data from European data Portal endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed May 28, 2018
1 parent c3c27e4 commit 595d1c7
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions modules/dcat_demo/tests/src/Functional/DcatDemoTest.php
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;
}

}

0 comments on commit 595d1c7

Please sign in to comment.