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

Commit

Permalink
Merge pull request #44 from ec-europa/travis-ci
Browse files Browse the repository at this point in the history
Run tests with Travis CI
  • Loading branch information
pfrenssen committed Jul 11, 2018
2 parents 68f35f8 + 0a9eee8 commit 4624f64
Show file tree
Hide file tree
Showing 26 changed files with 292 additions and 159 deletions.
66 changes: 66 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
language: php

php:
- 7.1
- 7.2

sudo: false

mysql:
database: rdf_entity_test
username: root
encoding: utf8

env:
global:
- SITE_DIR="$HOME/build/testing_site"
matrix:
- TEST=PHP_CodeSniffer
- TEST=PHPUnit

matrix:
fast_finish: true
exclude:
- php: 7.2
env: TEST=PHP_CodeSniffer

before_install:
- composer --verbose self-update
- mkdir -p ${SITE_DIR}/web/modules
- cd ${SITE_DIR}

### PHP_CodeSniffer only.

# We only need the PHP Code Sniffer (and the Drupal coder).
- test ${TEST} == "PHPUnit" || composer require drupal/coder

### PHPUnit only (till the end).

# Deploy the codebase.
- test ${TEST} == "PHP_CodeSniffer" || cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/composer.json.dist ${SITE_DIR}/composer.json
- test ${TEST} == "PHP_CodeSniffer" || cp ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/phpunit.xml.dist ${SITE_DIR}/web/phpunit.xml
- test ${TEST} == "PHP_CodeSniffer" || sed -i -e 's#\$TRAVIS_BUILD_DIR#'${TRAVIS_BUILD_DIR}'#g' composer.json
- test ${TEST} == "PHP_CodeSniffer" || composer install --no-interaction
# Virtuoso setup.
- test ${TEST} == "PHP_CodeSniffer" || mkdir ${SITE_DIR}/virtuoso
- test ${TEST} == "PHP_CodeSniffer" || docker run --name virtuoso -p 8890:8890 -p 1111:1111 -e SPARQL_UPDATE=true -v ${SITE_DIR}/virtuoso:/data -d tenforce/virtuoso
# Create the MySQL database.
- test ${TEST} == "PHP_CodeSniffer" || mysql -e 'CREATE DATABASE rdf_entity_test'
# Install Drupal.
- test ${TEST} == "PHP_CodeSniffer" || ./vendor/bin/drush site:install testing --yes --root=${SITE_DIR}/web --db-url=mysql://root:@127.0.0.1/rdf_entity_test
# Add the SPARQL connection to settings.php.
- test ${TEST} == "PHP_CodeSniffer" || chmod 0775 ${SITE_DIR}/web/sites/default/settings.php
- test ${TEST} == "PHP_CodeSniffer" || cat ${TRAVIS_BUILD_DIR}/tests/travis-ci/fixtures/connection.txt >> ${SITE_DIR}/web/sites/default/settings.php
# Enable the 'rdf_entity' module.
- test ${TEST} == "PHP_CodeSniffer" || ./vendor/bin/drush pm:enable rdf_entity --yes --root=${SITE_DIR}/web
# Start the webserver for browser tests.
- cd ${SITE_DIR}/web
- test ${TEST} == "PHP_CodeSniffer" || nohup php -S localhost:8888 > /dev/null 2>&1 &
# Wait until the web server is responding.
- test ${TEST} == "PHP_CodeSniffer" || until curl -s localhost:8888; do true; done > /dev/null
- cd ..

script: ${TRAVIS_BUILD_DIR}/tests/travis-ci/scripts/run_tests ${TEST}

notifications:
email: false
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/ec-europa/rdf_entity.svg?branch=8.x-1.x)](https://travis-ci.org/ec-europa/rdf_entity)

# Getting started
A working Sparql endpoint is needed to use the rdf entity module.
You could either use a remote Sparql endpoint, or you could set one up locally.
Expand Down
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@
"require": {
"php": ">=7.1",
"easyrdf/easyrdf": "0.10.0-alpha.1 as 0.9.2"
},
"require-dev": {
"minimaxir/big-list-of-naughty-strings": "dev-master"
}
}
5 changes: 2 additions & 3 deletions modules/rdf_taxonomy/tests/src/Kernel/SparqlTaxonomyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Drupal\rdf_entity\Entity\Rdf;
use Drupal\taxonomy\Entity\Term;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;
use Drupal\Tests\rdf_entity\Kernel\RdfKernelTestBase;

/**
* Tests Entity Query functionality of the Sparql backend.
Expand All @@ -13,7 +13,7 @@
*
* @group Entity
*/
class SparqlTaxonomyTest extends JoinupKernelTestBase {
class SparqlTaxonomyTest extends RdfKernelTestBase {

/**
* Modules to enable.
Expand All @@ -22,7 +22,6 @@ class SparqlTaxonomyTest extends JoinupKernelTestBase {
*/
public static $modules = [
'field_test',
'datetime',
'language',
'rdf_taxonomy',
'rdf_taxonomy_test',
Expand Down
3 changes: 0 additions & 3 deletions rdf_entity.module
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Database\Database;
use Drupal\Core\Entity\BundleEntityFormBase;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Form\FormStateInterface;
Expand All @@ -23,7 +21,6 @@ use Drupal\field\FieldStorageConfigInterface;
use Drupal\rdf_entity\Entity\RdfEntityMapping;
use Drupal\rdf_entity\Entity\RdfEntitySparqlStorage;
use Drupal\rdf_entity\RdfEntityGraphInterface;
use Drupal\rdf_entity\RdfEntitySparqlStorageInterface;
use Drupal\rdf_entity\RdfFieldHandler;
use Drupal\rdf_entity\RdfInterface;
use EasyRdf\Http;
Expand Down
1 change: 0 additions & 1 deletion src/Entity/Query/Sparql/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ protected function prepare() {
}
$this->query .= "\n";


if (!$this->graphIds) {
// If no graph IDs were requested, allow all graphs that Drupal is aware
// for this entity type.
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Query/Sparql/SparqlCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SparqlCondition extends ConditionFundamentals implements ConditionInterfac
'>=',
'<>',
'IN',
'NOT IN'
'NOT IN',
];

/**
Expand Down
2 changes: 0 additions & 2 deletions src/Entity/RdfEntitySparqlStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Drupal\Core\Entity\ContentEntityStorageBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityPublishedInterface;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
Expand All @@ -23,7 +22,6 @@
use Drupal\rdf_entity\Exception\DuplicatedIdException;
use Drupal\rdf_entity\RdfEntityIdPluginManager;
use Drupal\rdf_entity\RdfEntitySparqlStorageInterface;
use Drupal\rdf_entity\RdfFieldHandler;
use Drupal\rdf_entity\RdfFieldHandlerInterface;
use Drupal\rdf_entity\RdfGraphHandlerInterface;
use EasyRdf\Graph;
Expand Down
1 change: 0 additions & 1 deletion src/Form/RdfFieldStorageConfigEditForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Drupal\rdf_entity\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\field_ui\Form\FieldStorageConfigEditForm;
use Drupal\rdf_entity\Entity\RdfEntitySparqlStorage;

Expand Down
2 changes: 1 addition & 1 deletion src/RdfEntitySparqlStorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function loadByProperties(array $values = [], array $graph_ids = NULL): a
/**
* Resets the internal, static entity cache.
*
* @param $ids
* @param array|null $ids
* (optional) If specified, the cache is reset for the entities with the
* given ids only.
* @param string[]|null $graph_ids
Expand Down
124 changes: 64 additions & 60 deletions src/RdfFieldHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,76 +18,80 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
* Contains helper methods that help with the uri mappings of Drupal elements.
* Contains helper methods that help with the URI mappings of Drupal elements.
*
* Mainly, two field maps are created and statically cached:
*
* The OUTBOUND MAP, witch is a Drupal oriented property mapping array. A YAML
* representation of this array would look like:
* @codingStandardsIgnoreStart
* rdf_entity:
* bundle_key: rid
* bundles:
* catalog: http://www.w3.org/ns/dcat#Catalog
* other_bundle: ...
* fields:
* label:
* main_property: value
* columns:
* value:
* catalog:
* predicate: http://purl.org/dc/terms/title
* format: t_literal
* serialize: false
* data_type: string
* other_bundle:
* predicate: ...
* ...
* other_column:
* catalog:
* ...
* other_field: ...
* other_entity_type:
* bundle_key: ...
* ...
* @codingStandardsIgnoreEnd
*
* The INBOUND MAP, witch is a SPARQL oriented property mapping array. A YAML
* representation of this array would look like:
* @codingStandardsIgnoreStart
* rdf_entity:
* bundle_key: rid
* bundles:
* http://www.w3.org/ns/dcat#Catalog:
* - catalog
* - collection
* http://example.com:
* - other_bundle
* fields:
* http://purl.org/dc/terms/title:
* catalog:
* field_name: label
* column: value
* serialize: false
* type: string
* data_type: string
* other_field:
* field_name: ...
* ...
* http://example.com/field_mapping:
* ....
* other_entity_type:
* bundle_key: ...
* ...
* @codingStandardsIgnoreEnd
*/
class RdfFieldHandler implements RdfFieldHandlerInterface {

/**
* A Drupal oriented property mapping array.
*
* A YAML representation of this array would look like:
* @code
* rdf_entity:
* bundle_key: rid
* bundles:
* catalog: http://www.w3.org/ns/dcat#Catalog
* other_bundle: ...
* fields:
* label:
* main_property: value
* columns:
* value:
* catalog:
* predicate: http://purl.org/dc/terms/title
* format: t_literal
* serialize: false
* data_type: string
* other_bundle:
* predicate: ...
* ...
* other_column:
* catalog:
* ...
* other_field: ...
* other_entity_type:
* bundle_key: ...
* ...
* @endcode
* The static cache of outbound map.
*
* @var array
*/
protected $outboundMap;

/**
* A SPARQL oriented property mapping array.
*
* A YAML representation of this array would look like:
* @code
* rdf_entity:
* bundle_key: rid
* bundles:
* http://www.w3.org/ns/dcat#Catalog:
* - catalog
* - collection
* http://example.com:
* - other_bundle
* fields:
* http://purl.org/dc/terms/title:
* catalog:
* field_name: label
* column: value
* serialize: false
* type: string
* data_type: string
* other_field:
* field_name: ...
* ...
* http://example.com/field_mapping:
* ....
* other_entity_type:
* bundle_key: ...
* ...
* @endcode
* The static cache of inbound map.
*
* @var array
*/
Expand Down
54 changes: 0 additions & 54 deletions tests/src/Functional/RdfWebTestBase.php

This file was deleted.

3 changes: 1 addition & 2 deletions tests/src/Kernel/RdfDateFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

use Drupal\rdf_entity\Entity\Query\Sparql\SparqlArg;
use Drupal\rdf_entity\Entity\Rdf;
use Drupal\Tests\joinup_core\Kernel\JoinupKernelTestBase;

/**
* Tests date fields in rdf entities.
*
* @group rdf_entity
*/
class RdfDateFieldsTest extends JoinupKernelTestBase {
class RdfDateFieldsTest extends RdfKernelTestBase {

/**
* Tests handling of timestamp field properties.
Expand Down
Loading

0 comments on commit 4624f64

Please sign in to comment.