├── .editorconfig ├── .github └── workflows │ ├── coding-styles.yml │ ├── mariadb-10.10.yml │ ├── mariadb-10.11.yml │ ├── mariadb-10.5.yml │ ├── mariadb-10.6.yml │ ├── mariadb-10.9.yml │ ├── mysql-5.5.yml │ ├── mysql-5.6.yml │ ├── mysql-5.7.yml │ ├── mysql-8.0.yml │ └── mysql-8.1.yml ├── .gitignore ├── .php-cs-fixer.php ├── ARC2.php ├── ARC2_Class.php ├── ARC2_Graph.php ├── ARC2_Reader.php ├── ARC2_Resource.php ├── ARC2_getFormat.php ├── ARC2_getPreferredFormat.php ├── LICENSE ├── README.md ├── build.xml ├── composer.json ├── doc ├── SPARQL-support.md └── developer.md ├── docker ├── Dockerfile ├── Makefile ├── custom.ini ├── docker-compose.yml └── sql │ └── arc2_test.sql ├── extractors ├── ARC2_DcExtractor.php ├── ARC2_ErdfExtractor.php ├── ARC2_MicroformatsExtractor.php ├── ARC2_OpenidExtractor.php ├── ARC2_PoshRdfExtractor.php ├── ARC2_RDFExtractor.php ├── ARC2_RdfaExtractor.php └── ARC2_TwitterProfilePicExtractor.php ├── parsers ├── ARC2_AtomParser.php ├── ARC2_CBJSONParser.php ├── ARC2_JSONParser.php ├── ARC2_LegacyXMLParser.php ├── ARC2_RDFParser.php ├── ARC2_RDFXMLParser.php ├── ARC2_RSSParser.php ├── ARC2_SGAJSONParser.php ├── ARC2_SPARQLParser.php ├── ARC2_SPARQLPlusParser.php ├── ARC2_SPARQLXMLResultParser.php ├── ARC2_SPOGParser.php ├── ARC2_SemHTMLParser.php └── ARC2_TurtleParser.php ├── phpunit.xml ├── serializers ├── ARC2_JSONLDSerializer.php ├── ARC2_LegacyHTMLSerializer.php ├── ARC2_LegacyJSONSerializer.php ├── ARC2_LegacyXMLSerializer.php ├── ARC2_MicroRDFSerializer.php ├── ARC2_NTriplesSerializer.php ├── ARC2_POSHRDFSerializer.php ├── ARC2_RDFJSONSerializer.php ├── ARC2_RDFSerializer.php ├── ARC2_RDFXMLSerializer.php ├── ARC2_RSS10Serializer.php └── ARC2_TurtleSerializer.php ├── sparqlscript ├── ARC2_SPARQLScriptParser.php └── ARC2_SPARQLScriptProcessor.php ├── src └── ARC2 │ └── Store │ └── Adapter │ ├── AbstractAdapter.php │ ├── AdapterFactory.php │ └── PDOAdapter.php ├── store ├── ARC2_MemStore.php ├── ARC2_RemoteStore.php ├── ARC2_Store.php ├── ARC2_StoreAskQueryHandler.php ├── ARC2_StoreAtomLoader.php ├── ARC2_StoreCBJSONLoader.php ├── ARC2_StoreConstructQueryHandler.php ├── ARC2_StoreDeleteQueryHandler.php ├── ARC2_StoreDescribeQueryHandler.php ├── ARC2_StoreDumpQueryHandler.php ├── ARC2_StoreDumper.php ├── ARC2_StoreEndpoint.php ├── ARC2_StoreHelper.php ├── ARC2_StoreInsertQueryHandler.php ├── ARC2_StoreLoadQueryHandler.php ├── ARC2_StoreQueryHandler.php ├── ARC2_StoreRDFXMLLoader.php ├── ARC2_StoreRSSLoader.php ├── ARC2_StoreSGAJSONLoader.php ├── ARC2_StoreSPOGLoader.php ├── ARC2_StoreSelectQueryHandler.php ├── ARC2_StoreSemHTMLLoader.php ├── ARC2_StoreTableManager.php └── ARC2_StoreTurtleLoader.php └── tests ├── ARC2_TestCase.php ├── ARC2_TestHandler.php ├── bootstrap.php ├── config.php.dist ├── data ├── atom │ └── feed.atom ├── json │ ├── crunchbase-facebook.js │ └── sparql-select-result.json ├── nt │ ├── saft-arc2-addition-regression1.nt │ └── test.nt ├── rdfxml │ └── planetrdf-bloggers.rdf └── turtle │ └── manifest.ttl ├── db_adapter_depended ├── README.md ├── sparql_1_1_tests │ ├── AggregatesTest.php │ ├── ComplianceTest.php │ ├── ConstructTest.php │ ├── DropTest.php │ ├── SyntaxUpdate1Test.php │ └── w3c-tests │ │ ├── aggregates │ │ ├── agg-avg-01.rq │ │ ├── agg-avg-01.srx │ │ ├── agg-avg-02.rq │ │ ├── agg-avg-02.srx │ │ ├── agg-empty-group.rq │ │ ├── agg-empty-group.srx │ │ ├── agg-err-01.rq │ │ ├── agg-err-01.srx │ │ ├── agg-err-01.ttl │ │ ├── agg-err-02.rq │ │ ├── agg-err-02.srx │ │ ├── agg-err-02.ttl │ │ ├── agg-groupconcat-1.rq │ │ ├── agg-groupconcat-1.srx │ │ ├── agg-groupconcat-1.ttl │ │ ├── agg-groupconcat-2.rq │ │ ├── agg-groupconcat-2.srx │ │ ├── agg-groupconcat-3.rq │ │ ├── agg-groupconcat-3.srx │ │ ├── agg-max-01.rq │ │ ├── agg-max-01.srx │ │ ├── agg-max-02.rq │ │ ├── agg-max-02.srx │ │ ├── agg-min-01.rq │ │ ├── agg-min-01.srx │ │ ├── agg-min-02.rq │ │ ├── agg-min-02.srx │ │ ├── agg-numeric.ttl │ │ ├── agg-numeric2.ttl │ │ ├── agg-sample-01.rq │ │ ├── agg-sample-01.srx │ │ ├── agg-sum-01.rq │ │ ├── agg-sum-01.srx │ │ ├── agg-sum-02.rq │ │ ├── agg-sum-02.srx │ │ ├── agg01.rq │ │ ├── agg01.srx │ │ ├── agg01.ttl │ │ ├── agg02.rq │ │ ├── agg02.srx │ │ ├── agg03.rq │ │ ├── agg03.srx │ │ ├── agg04.rq │ │ ├── agg04.srx │ │ ├── agg05.rq │ │ ├── agg05.srx │ │ ├── agg06.rq │ │ ├── agg06.srx │ │ ├── agg07.rq │ │ ├── agg07.srx │ │ ├── agg08.rq │ │ ├── agg08.ttl │ │ ├── agg08b.rq │ │ ├── agg08b.srx │ │ ├── agg09.rq │ │ ├── agg10.rq │ │ ├── agg11.rq │ │ ├── agg12.rq │ │ ├── empty.ttl │ │ └── manifest.ttl │ │ ├── construct │ │ ├── constructwhere01.rq │ │ ├── constructwhere01result.ttl │ │ ├── constructwhere02.rq │ │ ├── constructwhere02result.ttl │ │ ├── constructwhere03.rq │ │ ├── constructwhere03result.ttl │ │ ├── constructwhere04.rq │ │ ├── constructwhere04result.ttl │ │ ├── constructwhere05.rq │ │ ├── constructwhere06.rq │ │ ├── data.ttl │ │ └── manifest.ttl │ │ ├── delete │ │ ├── delete-01.ru │ │ ├── delete-02.ru │ │ ├── delete-03.ru │ │ ├── delete-04.ru │ │ ├── delete-05.ru │ │ ├── delete-06.ru │ │ ├── delete-07.ru │ │ ├── delete-post-01f.ttl │ │ ├── delete-post-01s.ttl │ │ ├── delete-post-01s2.ttl │ │ ├── delete-post-02f.ttl │ │ ├── delete-post-02s.ttl │ │ ├── delete-post-03f.ttl │ │ ├── delete-pre-01.ttl │ │ ├── delete-pre-02.ttl │ │ ├── delete-pre-03.ttl │ │ ├── delete-using-01.ru │ │ ├── delete-using-02.ru │ │ ├── delete-using-03.ru │ │ ├── delete-using-04.ru │ │ ├── delete-using-05.ru │ │ ├── delete-using-06.ru │ │ ├── delete-with-01.ru │ │ ├── delete-with-02.ru │ │ ├── delete-with-03.ru │ │ ├── delete-with-04.ru │ │ ├── delete-with-05.ru │ │ ├── delete-with-06.ru │ │ └── manifest.ttl │ │ ├── drop │ │ ├── drop-all-01.ru │ │ ├── drop-default-01.ru │ │ ├── drop-default.ttl │ │ ├── drop-g1.ttl │ │ ├── drop-g2.ttl │ │ ├── drop-graph-01.ru │ │ ├── drop-named-01.ru │ │ └── manifest.ttl │ │ ├── exists │ │ ├── exists01.rq │ │ ├── exists01.srx │ │ ├── exists01.ttl │ │ ├── exists02.rq │ │ ├── exists02.srx │ │ ├── exists02.ttl │ │ ├── exists03.rq │ │ ├── exists03.srx │ │ ├── exists04.rq │ │ ├── exists04.srx │ │ ├── exists05.rq │ │ ├── exists05.srx │ │ └── manifest.ttl │ │ ├── move │ │ ├── manifest.ttl │ │ ├── move-01.ru │ │ ├── move-01.ttl │ │ ├── move-02.ttl │ │ ├── move-03.ru │ │ ├── move-06.ru │ │ ├── move-07.ru │ │ └── move-default.ttl │ │ └── syntax-update-1 │ │ ├── manifest.ttl │ │ ├── syntax-update-01.ru │ │ ├── syntax-update-02.ru │ │ ├── syntax-update-03.ru │ │ ├── syntax-update-04.ru │ │ ├── syntax-update-05.ru │ │ ├── syntax-update-06.ru │ │ ├── syntax-update-07.ru │ │ ├── syntax-update-08.ru │ │ ├── syntax-update-09.ru │ │ ├── syntax-update-10.ru │ │ ├── syntax-update-11.ru │ │ ├── syntax-update-12.ru │ │ ├── syntax-update-13.ru │ │ ├── syntax-update-14.ru │ │ ├── syntax-update-15.ru │ │ ├── syntax-update-16.ru │ │ ├── syntax-update-17.ru │ │ ├── syntax-update-18.ru │ │ ├── syntax-update-19.ru │ │ ├── syntax-update-20.ru │ │ ├── syntax-update-21.ru │ │ ├── syntax-update-22.ru │ │ ├── syntax-update-23.ru │ │ ├── syntax-update-24.ru │ │ ├── syntax-update-25.ru │ │ ├── syntax-update-26.ru │ │ ├── syntax-update-27.ru │ │ ├── syntax-update-28.ru │ │ ├── syntax-update-29.ru │ │ ├── syntax-update-30.ru │ │ ├── syntax-update-31.ru │ │ ├── syntax-update-32.ru │ │ ├── syntax-update-33.ru │ │ ├── syntax-update-34.ru │ │ ├── syntax-update-35.ru │ │ ├── syntax-update-36.ru │ │ ├── syntax-update-37.ru │ │ ├── syntax-update-38.ru │ │ ├── syntax-update-39.ru │ │ ├── syntax-update-40.ru │ │ ├── syntax-update-53.ru │ │ ├── syntax-update-54.ru │ │ ├── syntax-update-bad-01.ru │ │ ├── syntax-update-bad-02.ru │ │ ├── syntax-update-bad-03.ru │ │ ├── syntax-update-bad-04.ru │ │ ├── syntax-update-bad-05.ru │ │ ├── syntax-update-bad-06.ru │ │ ├── syntax-update-bad-07.ru │ │ ├── syntax-update-bad-08.ru │ │ ├── syntax-update-bad-09.ru │ │ ├── syntax-update-bad-10.ru │ │ ├── syntax-update-bad-11.ru │ │ └── syntax-update-bad-12.ru └── store │ ├── ARC2_StoreAskQueryHandlerTest.php │ ├── ARC2_StoreInsertQueryHandlerTest.php │ ├── ARC2_StoreLoadQueryHandlerTest.php │ ├── ARC2_StoreTest.php │ └── query │ ├── AskQueryTest.php │ ├── DeleteQueryTest.php │ ├── DescribeQueryTest.php │ ├── ErrorHandlingInQueriesTest.php │ ├── InsertIntoQueryTest.php │ ├── KnownNotWorkingSparqlQueriesTest.php │ ├── LoadQueryTest.php │ └── SelectQueryTest.php ├── integration └── src │ └── ARC2 │ └── Store │ └── Adapter │ ├── AbstractAdapterTest.php │ ├── AdapterFactoryTest.php │ └── PDOAdapterTest.php └── unit ├── ARC2_ClassTest.php ├── ARC2_GraphTest.php ├── ARC2_ReaderTest.php ├── ARC2_Test.php ├── ARC2_getFormatTest.php ├── ARC2_getPreferredFormatTest.php └── store ├── ARC2_StoreEndpointTest.php ├── ARC2_StoreLoadQueryHandlerTest.php └── ARC2_StoreTest.php /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.github/workflows/coding-styles.yml: -------------------------------------------------------------------------------- 1 | name: "Coding Styles" 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | tests: 7 | name: Coding Styles 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | fail-fast: true 12 | matrix: 13 | php: 14 | - 8.2 15 | 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v2 19 | 20 | - name: Install PHP 21 | uses: shivammathur/setup-php@v2 22 | with: 23 | php-version: ${{ matrix.php }} 24 | coverage: xdebug 25 | ini-values: memory_limit=1G 26 | tools: cs2pr 27 | 28 | - name: Validate Composer files 29 | run: composer validate --no-check-all --strict 30 | 31 | - name: Install Composer dependencies 32 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 33 | 34 | - name: Coding styles 35 | run: php vendor/bin/php-cs-fixer fix --verbose --dry-run --format=checkstyle | cs2pr 36 | -------------------------------------------------------------------------------- /.github/workflows/mariadb-10.10.yml: -------------------------------------------------------------------------------- 1 | name: MariaDB 10.10 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MariaDB 10.10 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mariadb:10.10 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.github/workflows/mariadb-10.11.yml: -------------------------------------------------------------------------------- 1 | name: MariaDB 10.11 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MariaDB 10.11 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mariadb:10.11 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.github/workflows/mariadb-10.5.yml: -------------------------------------------------------------------------------- 1 | name: MariaDB 10.5 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MariaDB 10.5 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mariadb:10.5 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.github/workflows/mariadb-10.6.yml: -------------------------------------------------------------------------------- 1 | name: MariaDB 10.6 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MariaDB 10.6 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mariadb:10.6 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.github/workflows/mariadb-10.9.yml: -------------------------------------------------------------------------------- 1 | name: MariaDB 10.9 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MariaDB 10.9 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mariadb:10.9 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.github/workflows/mysql-5.5.yml: -------------------------------------------------------------------------------- 1 | name: MySQL 5.5 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MySQL 5.5 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mysql:5.5 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.github/workflows/mysql-5.6.yml: -------------------------------------------------------------------------------- 1 | name: MySQL 5.6 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MySQL 5.6 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | services: 24 | testdb: 25 | image: mysql:5.6 26 | env: 27 | MYSQL_ROOT_PASSWORD: Pass123 28 | MYSQL_DATABASE: arc2_test 29 | MYSQL_ALLOW_EMPTY_PASSWORD: false 30 | ports: 31 | - 3306 32 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 33 | 34 | steps: 35 | - name: Checkout 36 | uses: actions/checkout@v2 37 | 38 | - name: Install PHP 39 | uses: shivammathur/setup-php@v2 40 | with: 41 | php-version: ${{ matrix.php }} 42 | ini-values: memory_limit=1G 43 | 44 | - name: Install Composer dependencies 45 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 46 | 47 | - name: Tests 48 | run: | 49 | vendor/bin/phpunit 50 | env: 51 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 52 | -------------------------------------------------------------------------------- /.github/workflows/mysql-5.7.yml: -------------------------------------------------------------------------------- 1 | name: MySQL 5.7 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MySQL 5.7 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mysql:5.7 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.github/workflows/mysql-8.0.yml: -------------------------------------------------------------------------------- 1 | name: MySQL 8.0 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MySQL 8.0 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.0 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mysql:8.0 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.github/workflows/mysql-8.1.yml: -------------------------------------------------------------------------------- 1 | name: MySQL 8.1 Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | pdo-mysql: 7 | name: MySQL 8.1 Tests - PHP ${{ matrix.php }} PDO mysql 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | DB_ADAPTER: pdo 12 | DB_PDO_PROTOCOL: mysql 13 | 14 | strategy: 15 | # if one of the matrix-entries break, all entries getting canceled. 16 | fail-fast: true 17 | matrix: 18 | php: 19 | - 8.1 20 | - 8.1 21 | - 8.2 22 | - 8.3 23 | 24 | services: 25 | testdb: 26 | image: mysql:8.1 27 | env: 28 | MYSQL_ROOT_PASSWORD: Pass123 29 | MYSQL_DATABASE: arc2_test 30 | MYSQL_ALLOW_EMPTY_PASSWORD: false 31 | ports: 32 | - 3306 33 | options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=3s --health-retries=4 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v2 38 | 39 | - name: Install PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | ini-values: memory_limit=1G 44 | 45 | - name: Install Composer dependencies 46 | run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader 47 | 48 | - name: Tests 49 | run: | 50 | vendor/bin/phpunit 51 | env: 52 | DB_PORT: ${{ job.services.testdb.ports[3306] }} 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | .php_cs.cache 3 | .phpunit.result.cache 4 | composer.lock 5 | plugins/* 6 | triggers/* 7 | tests/coverage/* 8 | tests/config.php 9 | vendor/ 10 | /.php-cs-fixer.cache 11 | -------------------------------------------------------------------------------- /.php-cs-fixer.php: -------------------------------------------------------------------------------- 1 | in(__DIR__.'/extractors') 8 | ->in(__DIR__.'/parsers') 9 | ->in(__DIR__.'/serializers') 10 | ->in(__DIR__.'/sparqlscript') 11 | ->in(__DIR__.'/src') 12 | ->in(__DIR__.'/store') 13 | ->in(__DIR__.'/tests') 14 | ->in(__DIR__.'/') 15 | ->name('*.php') 16 | ; 17 | 18 | $config = new Config(); 19 | $config 20 | ->setFinder($finder) 21 | ->setRiskyAllowed(true) 22 | ->setRules([ 23 | '@PSR12' => true, 24 | 'phpdoc_summary' => false, 25 | ]) 26 | ; 27 | 28 | return $config; 29 | -------------------------------------------------------------------------------- /ARC2_getFormat.php: -------------------------------------------------------------------------------- 1 | 6 | * @license W3C Software License and GPL 7 | * 8 | * @version 2010-11-16 9 | */ 10 | function ARC2_getFormat($v, $mtype = '', $ext = '') 11 | { 12 | $r = false; 13 | /* mtype check (atom, rdf/xml, turtle, n3, mp3, jpg) */ 14 | $r = (!$r && preg_match('/\/atom\+xml/', $mtype)) ? 'atom' : $r; 15 | $r = (!$r && preg_match('/\/rdf\+xml/', $mtype)) ? 'rdfxml' : $r; 16 | $r = (!$r && preg_match('/\/(x\-)?turtle/', $mtype)) ? 'turtle' : $r; 17 | $r = (!$r && preg_match('/\/rdf\+n3/', $mtype)) ? 'n3' : $r; 18 | $r = (!$r && preg_match('/\/sparql-results\+xml/', $mtype)) ? 'sparqlxml' : $r; 19 | /* xml sniffing */ 20 | if ( 21 | !$r 22 | /* starts with angle brackets */ 23 | && preg_match('/^\s*\<[^\s]/s', $v) 24 | /* has an xmlns:* declaration or a matching pair of tags */ 25 | && (preg_match('/\sxmlns\:?/', $v) || preg_match('/\<([^\s]+).+\<\/\\1\>/s', $v)) // && 26 | ) { 27 | while (preg_match('/^\s*\<\?xml[^\r\n]+\?\>\s*/s', $v)) { 28 | $v = preg_replace('/^\s*\<\?xml[^\r\n]+\?\>\s*/s', '', $v); 29 | } 30 | while (preg_match('/^\s*\<\!--.+?--\>\s*/s', $v)) { 31 | $v = preg_replace('/^\s*\<\!--.+?--\>\s*/s', '', $v); 32 | } 33 | /* doctype checks (html, rdf) */ 34 | $r = (!$r && preg_match('/^\s*\<\!DOCTYPE\s+html[\s|\>]/is', $v)) ? 'html' : $r; 35 | $r = (!$r && preg_match('/^\s*\<\!DOCTYPE\s+[a-z0-9\_\-]\:RDF\s/is', $v)) ? 'rdfxml' : $r; 36 | /* markup checks */ 37 | $v = preg_replace('/^\s*\<\!DOCTYPE\s.*\]\>/is', '', $v); 38 | $r = (!$r && preg_match('/^\s*\]*version/s', $v)) ? 'rss' : $r; 39 | $r = (!$r && preg_match('/^\s*\]+http\:\/\/www\.w3\.org\/2005\/Atom/s', $v)) ? 'atom' : $r; 40 | $r = (!$r && preg_match('/^\s*\]/is', $v)) ? 'html' : $r; 42 | $r = (!$r && preg_match('/^\s*\]+http\:\/\/www\.w3\.org\/2005\/sparql\-results\#/s', $v)) ? 'sparqlxml' : $r; 43 | $r = (!$r && preg_match('/^\s*\<[^\>]+http\:\/\/www\.w3\.org\/2005\/sparql\-results#/s', $v)) ? 'srx' : $r; 44 | $r = (!$r && preg_match('/^\s*\<[^\s]*RDF[\s\>]/s', $v)) ? 'rdfxml' : $r; 45 | $r = (!$r && preg_match('/^\s*\<[^\>]+http\:\/\/www\.w3\.org\/1999\/02\/22\-rdf/s', $v)) ? 'rdfxml' : $r; 46 | 47 | $r = !$r ? 'xml' : $r; 48 | } 49 | /* json|jsonp */ 50 | if (!$r && preg_match('/^[a-z0-9\.\(]*\s*[\{\[].*/s', trim($v))) { 51 | /* google social graph api */ 52 | $r = (!$r && preg_match('/\"canonical_mapping\"/', $v)) ? 'sgajson' : $r; 53 | /* crunchbase api */ 54 | $r = (!$r && preg_match('/\"permalink\"/', $v)) ? 'cbjson' : $r; 55 | 56 | $r = !$r ? 'json' : $r; 57 | } 58 | /* turtle/n3 */ 59 | $r = (!$r && preg_match('/\@(prefix|base)/i', $v)) ? 'turtle' : $r; 60 | $r = (!$r && preg_match('/^(ttl)$/', $ext)) ? 'turtle' : $r; 61 | $r = (!$r && preg_match('/^(n3)$/', $ext)) ? 'n3' : $r; 62 | /* ntriples */ 63 | $r = (!$r && preg_match('/^\s*(_:|<).+?\s+<[^>]+?>\s+\S.+?\s*\.\s*$/sm', $v)) ? 'ntriples' : $r; 64 | $r = (!$r && preg_match('/^(nt)$/', $ext)) ? 'ntriples' : $r; 65 | 66 | return $r; 67 | } 68 | -------------------------------------------------------------------------------- /ARC2_getPreferredFormat.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * @version 2010-11-16 11 | */ 12 | function ARC2_getPreferredFormat($default = 'plain') 13 | { 14 | $formats = [ 15 | 'html' => 'HTML', 'text/html' => 'HTML', 'xhtml+xml' => 'HTML', 16 | 'rdfxml' => 'RDFXML', 'rdf+xml' => 'RDFXML', 17 | 'ntriples' => 'NTriples', 18 | 'rdf+n3' => 'Turtle', 'x-turtle' => 'Turtle', 'turtle' => 'Turtle', 'text/turtle' => 'Turtle', 19 | 'rdfjson' => 'RDFJSON', 'json' => 'RDFJSON', 20 | 'xml' => 'XML', 21 | 'legacyjson' => 'LegacyJSON', 22 | ]; 23 | $prefs = []; 24 | $o_vals = []; 25 | /* accept header */ 26 | $vals = explode(',', $_SERVER['HTTP_ACCEPT']); 27 | if ($vals) { 28 | foreach ($vals as $val) { 29 | if (preg_match('/(rdf\+n3|(x\-|text\/)turtle|rdf\+xml|text\/html|xhtml\+xml|xml|json)/', $val, $m)) { 30 | $o_vals[$m[1]] = 1; 31 | if (preg_match('/\;q\=([0-9\.]+)/', $val, $sub_m)) { 32 | $o_vals[$m[1]] = 1 * $sub_m[1]; 33 | } 34 | } 35 | } 36 | } 37 | /* arg */ 38 | if (isset($_GET['format'])) { 39 | $o_vals[$_GET['format']] = 1.1; 40 | } 41 | /* rank */ 42 | arsort($o_vals); 43 | foreach ($o_vals as $val => $prio) { 44 | $prefs[] = $val; 45 | } 46 | /* default */ 47 | $prefs[] = $default; 48 | foreach ($prefs as $pref) { 49 | if (isset($formats[$pref])) { 50 | return $formats[$pref]; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ARC2 2 | 3 | [![Latest Stable Version](https://poser.pugx.org/semsol/arc2/v/stable.svg)](https://packagist.org/packages/semsol/arc2) 4 | [![Total Downloads](https://poser.pugx.org/semsol/arc2/downloads.svg)](https://packagist.org/packages/semsol/arc2) 5 | [![Latest Unstable Version](https://poser.pugx.org/semsol/arc2/v/unstable.svg)](https://packagist.org/packages/semsol/arc2) 6 | [![License](https://poser.pugx.org/semsol/arc2/license.svg)](https://packagist.org/packages/semsol/arc2) 7 | 8 | ARC2 is a PHP 8.0+ library for working with RDF. 9 | It also provides a MySQL-based triplestore with SPARQL support. 10 | Older versions of PHP may work, but are not longer tested. 11 | 12 | **Test status:** 13 | 14 | | Database | Status | 15 | |---------------|-----------------------------------------------------------------------------------------------------| 16 | | MariaDB 10.5 | ![](https://github.com/semsol/arc2/workflows/MariaDB%2010.5%20Tests/badge.svg) | 17 | | MariaDB 10.6 | ![](https://github.com/semsol/arc2/workflows/MariaDB%2010.6%20Tests/badge.svg) | 18 | | MariaDB 10.9 | ![](https://github.com/semsol/arc2/workflows/MariaDB%2010.9%20Tests/badge.svg) | 19 | | MariaDB 10.10 | ![](https://github.com/semsol/arc2/workflows/MariaDB%2010.10%20Tests/badge.svg) | 20 | | MariaDB 10.11 | ![](https://github.com/semsol/arc2/workflows/MariaDB%2010.11%20Tests/badge.svg) | 21 | | MySQL 5.5 | ![](https://github.com/semsol/arc2/workflows/MySQL%205.5%20Tests/badge.svg) | 22 | | MySQL 5.6 | ![](https://github.com/semsol/arc2/workflows/MySQL%205.6%20Tests/badge.svg) | 23 | | MySQL 5.7 | ![](https://github.com/semsol/arc2/workflows/MySQL%205.7%20Tests/badge.svg) | 24 | | MySQL 8.0 | ![](https://github.com/semsol/arc2/workflows/MySQL%208.0%20Tests/badge.svg) - incomplete! see below | 25 | | MySQL 8.1 | ![](https://github.com/semsol/arc2/workflows/MySQL%208.1%20Tests/badge.svg) - incomplete! see below | 26 | 27 | ## Documentation 28 | 29 | For the documentation, see the [Wiki](https://github.com/semsol/arc2/wiki#core-documentation). To quickly get started, see the [Getting started guide](https://github.com/semsol/arc2/wiki/Getting-started-with-ARC2). 30 | 31 | ## Installation 32 | 33 | Requires **PHP 8.0**+. 34 | 35 | Package available on [Composer](https://packagist.org/packages/semsol/arc2). 36 | 37 | You should use Composer for installation: 38 | 39 | ```bash 40 | composer require semsol/arc2:^3 41 | ``` 42 | 43 | Further information about Composer usage can be found [here](https://getcomposer.org/doc/01-basic-usage.md#autoloading), for instance about autoloading ARC2 classes. 44 | 45 | ## RDF triple store 46 | 47 | ### SPARQL support 48 | 49 | Please have a look into [SPARQL-support.md](doc/SPARQL-support.md) to see which SPARQL 1.0/1.1 features are currently supported. 50 | 51 | ### Known database problems 52 | 53 | #### MySQL 8.0+ 54 | 55 | The following error occurs when using a REGEX function inside a SELECT query. 56 | 57 | > General error: 3995 Character set 'utf8mb3_unicode_ci' cannot be used in conjunction with 'binary' in call to regexp_like. 58 | 59 | ## Internal information for developers 60 | 61 | Please have a look [here](doc/developer.md) to find information about maintaining and extending ARC2 as well as our docker setup for local development. 62 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "semsol/arc2", 3 | "type": "library", 4 | "description": "ARC2 is a PHP library for working with RDF. It also provides a MySQL-based triplestore with SPARQL support.", 5 | "keywords": ["rdf","sparql"], 6 | "homepage": "https://github.com/semsol/arc2", 7 | "license": [ 8 | "GPL-2.0-or-later", 9 | "W3C" 10 | ], 11 | "support": { 12 | "issues": "https://github.com/semsol/arc2/issues" 13 | }, 14 | "authors": [ 15 | { 16 | "name": "Benji Nowack", 17 | "homepage": "http://bnowack.de/", 18 | "role": "Creator, Developer" 19 | }, 20 | { 21 | "name": "Konrad Abicht", 22 | "homepage": "https://inspirito.de", 23 | "email": "hi@inspirito.de", 24 | "role": "Maintainer, Developer" 25 | } 26 | ], 27 | "require": { 28 | "ext-mbstring": "*", 29 | "php": "^8.0.0" 30 | }, 31 | "require-dev": { 32 | "friendsofphp/php-cs-fixer": "^3", 33 | "phpunit/phpunit": "^9" 34 | }, 35 | "autoload": { 36 | "classmap": ["parsers/", "serializers/", "store/"], 37 | "files": [ 38 | "./ARC2.php", 39 | "./ARC2_Class.php", 40 | "./ARC2_getFormat.php", 41 | "./ARC2_getPreferredFormat.php", 42 | "./ARC2_Graph.php", 43 | "./ARC2_Reader.php", 44 | "./ARC2_Resource.php" 45 | ], 46 | "psr-4": { 47 | "ARC2\\": [ 48 | "src/ARC2/" 49 | ] 50 | } 51 | }, 52 | "autoload-dev": { 53 | "psr-4": { 54 | "Tests\\": [ 55 | "tests" 56 | ] 57 | } 58 | }, 59 | "scripts": { 60 | "phpunit": "vendor/bin/phpunit", 61 | "phpunit-with-coverage": "vendor/bin/phpunit --coverage-clover gen/coverage/clover.xml" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /doc/developer.md: -------------------------------------------------------------------------------- 1 | # Developer information 2 | 3 | This document contains information about ARC2 internals which are relevant for maintaining and extending ARC2. 4 | 5 | ## Run test environment 6 | 7 | To run test environment execute: 8 | 9 | ```bash 10 | vendor/bin/phpunit 11 | ``` 12 | 13 | Tests are split into different groups currently: 14 | * unit 15 | * db_adapter_depended 16 | 17 | You can run the `unit` group directly, but you need to set some environment variables for `db_adapter_depended`. 18 | 19 | #### config.php 20 | 21 | Currently, we use the following standard database credentials to connect with the database: 22 | 23 | ```php 24 | $dbConfig = array( 25 | 'db_name' => 'arc2_test', 26 | 'db_user' => 'root', 27 | 'db_pwd' => 'Pass123', 28 | 'db_host' => '127.0.0.1', 29 | ); 30 | ``` 31 | 32 | If you have different credentials, copy the `tests/config.php.dist` to `tests/config.php` and set your credentials. 33 | 34 | ## Editor 35 | 36 | Please make sure your editor uses our `.editorconfig` file. 37 | 38 | ## Docker setup 39 | 40 | For ARC2 developers we recommend using our docker setup (see folder `docker`). It provides a pre-configured set of software (for PHP, DBS etc.) and allows quick switches between different software versions. 41 | 42 | No matter if one needs a MariaDB 10.3 with PHP 7.2 or a PHP 5.6 with MySQL 5.7.0. If there is a docker container, it runs. 43 | 44 | ### Start 45 | 46 | In your terminal go to `docker` folder and run `make`. It will build and start the docker environment as well as log you in. 47 | 48 | ### Docker and Travis 49 | 50 | We use a very wide range of software-combinations to test ARC2. 51 | Currently, all combinations of supported versions of PHP and database systems (currently MySQL and MariaDB only) are checked. 52 | 53 | Using a Docker setup for local development allows to switch the backend very easily. 54 | So, if a test with a certain DBS/PHP version combination fails, its very likely that you can reproduce it locally. 55 | Dont forget to run `composer update` after a switch to make sure appropriate software is used. 56 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.2-cli 2 | 3 | RUN apt-get update && apt-get install -y curl git gnupg libicu-dev libzip-dev make nano net-tools zip zlib1g-dev 4 | 5 | RUN docker-php-ext-install intl pdo pdo_mysql zip \ 6 | && docker-php-ext-enable intl pdo pdo_mysql zip 7 | 8 | # install composer globally 9 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 10 | 11 | # add custom PHP.ini settings 12 | RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" 13 | COPY ./custom.ini /usr/local/etc/php/conf.d/custom.ini 14 | 15 | WORKDIR /var/www/html/ 16 | 17 | # adds user "arc2", adds him to group "www-data" and sets his home folder 18 | # for more background information see: 19 | # https://medium.com/@mccode/understanding-how-uid-and-gid-work-in-docker-containers-c37a01d01cf 20 | RUN useradd -r --home /home/arc2 -u 1000 arc2 21 | RUN usermod -a -G www-data arc2 22 | RUN mkdir /home/arc2 23 | RUN chown arc2:www-data /home/arc2 24 | 25 | EXPOSE 3306 26 | 27 | ENTRYPOINT ["tail", "-f", "/dev/null"] 28 | -------------------------------------------------------------------------------- /docker/Makefile: -------------------------------------------------------------------------------- 1 | default: 2 | make build 3 | make run 4 | docker exec -it --user arc2 arc2 bash 5 | 6 | build: 7 | docker-compose build 8 | 9 | clean: 10 | -@docker ps -a -q | xargs docker stop 11 | -@docker ps -a -q | xargs docker rm 12 | -@docker volume ls -f dangling=true -q| xargs docker volume rm 13 | docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi -f 14 | 15 | run: 16 | docker-compose up --build -d --remove-orphans 17 | -------------------------------------------------------------------------------- /docker/custom.ini: -------------------------------------------------------------------------------- 1 | ; phpmyadmin related, for bigger uploads 2 | file_uploads = On 3 | memory_limit = 512M 4 | upload_max_filesize = 64M 5 | post_max_size = 64M 6 | max_execution_time = 600 7 | 8 | ; error reporting 9 | error_reporting = E_ALL 10 | display_errors = On 11 | display_startup_errors = On 12 | -------------------------------------------------------------------------------- /docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | arc2: 5 | build: 6 | context: . 7 | dockerfile: Dockerfile 8 | container_name: arc2 9 | volumes: 10 | - ./../:/var/www/html/ 11 | depends_on: 12 | - db 13 | links: 14 | - db:mysql 15 | 16 | db: 17 | image: mariadb:10.3.29 18 | container_name: db 19 | environment: 20 | MYSQL_DATABASE: arc2 21 | MYSQL_ROOT_PASSWORD: Pass123 22 | volumes: 23 | # server is empty at the start because it uses RAM to store data 24 | - data:/var/cache 25 | - data:/var/lib/mysql 26 | # for SQL commands to be run after the server starts 27 | - ./sql:/docker-entrypoint-initdb.d 28 | 29 | phpmyadmin: 30 | image: phpmyadmin/phpmyadmin 31 | container_name: phpmyadmin 32 | links: 33 | - db:mysql 34 | ports: 35 | - 8002:80 36 | environment: 37 | MYSQL_USERNAME: root 38 | MYSQL_ROOT_PASSWORD: Pass123 39 | PMA_HOST: mysql 40 | UPLOAD_LIMIT: 2G 41 | 42 | volumes: 43 | data: 44 | driver_opts: 45 | type: tmpfs 46 | device: tmpfs 47 | -------------------------------------------------------------------------------- /docker/sql/arc2_test.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `arc2_test`; 2 | GRANT ALL ON `arc2_test`.* TO 'root'@'%'; 3 | -------------------------------------------------------------------------------- /extractors/ARC2_DcExtractor.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 DC Extractor 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('RDFExtractor'); 12 | 13 | class ARC2_DcExtractor extends ARC2_RDFExtractor 14 | { 15 | public function __construct($a, &$caller) 16 | { 17 | parent::__construct($a, $caller); 18 | } 19 | 20 | public function __init() 21 | { 22 | parent::__init(); 23 | $this->a['ns']['dc'] = 'http://purl.org/dc/elements/1.1/'; 24 | } 25 | 26 | public function extractRDF() 27 | { 28 | $t_vals = []; 29 | $t = ''; 30 | foreach ($this->nodes as $n) { 31 | foreach (['title', 'link', 'meta'] as $tag) { 32 | if ($n['tag'] == $tag) { 33 | $m = 'extract'.ucfirst($tag); 34 | list($t_vals, $t) = $this->$m($n, $t_vals, $t); 35 | } 36 | } 37 | } 38 | if ($t) { 39 | $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']); 40 | $this->addTs(ARC2::getTriplesFromIndex($doc)); 41 | } 42 | } 43 | 44 | public function extractTitle($n, $t_vals, $t) 45 | { 46 | if ($t_vals['title'] = $this->getPlainContent($n)) { 47 | $t .= '<'.$n['doc_url'].'> dc:title ?title . '; 48 | } 49 | 50 | return [$t_vals, $t]; 51 | } 52 | 53 | public function extractLink($n, $t_vals, $t) 54 | { 55 | if ($this->hasRel($n, 'alternate') || $this->hasRel($n, 'meta')) { 56 | if ($href = $this->v('href uri', '', $n['a'])) { 57 | $t .= '<'.$n['doc_url'].'> rdfs:seeAlso <'.$href.'> . '; 58 | if ($v = $this->v('type', '', $n['a'])) { 59 | $t .= '<'.$href.'> dc:format "'.$v.'" . '; 60 | } 61 | if ($v = $this->v('title', '', $n['a'])) { 62 | $t .= '<'.$href.'> dc:title "'.$v.'" . '; 63 | } 64 | } 65 | } 66 | 67 | return [$t_vals, $t]; 68 | } 69 | 70 | public function extractMeta($n, $t_vals, $t) 71 | { 72 | if ($this->hasAttribute('http-equiv', $n, 'Content-Type') || $this->hasAttribute('http-equiv', $n, 'content-type')) { 73 | if ($v = $this->v('content', '', $n['a'])) { 74 | $t .= '<'.$n['doc_url'].'> dc:format "'.$v.'" . '; 75 | } 76 | } 77 | 78 | return [$t_vals, $t]; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /extractors/ARC2_OpenidExtractor.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 foaf:openid Extractor 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('RDFExtractor'); 12 | 13 | class ARC2_OpenidExtractor extends ARC2_RDFExtractor 14 | { 15 | public function __construct($a, &$caller) 16 | { 17 | parent::__construct($a, $caller); 18 | } 19 | 20 | public function __init() 21 | { 22 | parent::__init(); 23 | $this->a['ns']['foaf'] = 'http://xmlns.com/foaf/0.1/'; 24 | } 25 | 26 | public function extractRDF() 27 | { 28 | $t_vals = []; 29 | $t = ''; 30 | foreach ($this->nodes as $n) { 31 | if (isset($n['tag']) && 'link' == $n['tag']) { 32 | $m = 'extract'.ucfirst($n['tag']); 33 | list($t_vals, $t) = $this->$m($n, $t_vals, $t); 34 | } 35 | } 36 | if ($t) { 37 | $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']); 38 | $this->addTs(ARC2::getTriplesFromIndex($doc)); 39 | } 40 | } 41 | 42 | public function extractLink($n, $t_vals, $t) 43 | { 44 | if ($this->hasRel($n, 'openid.server')) { 45 | if ($href = $this->v('href uri', '', $n['a'])) { 46 | $t_vals['doc_owner'] = $this->getDocOwnerID($n); 47 | $t_vals['doc_id'] = $this->getDocID($n); 48 | $t .= '?doc_owner foaf:homepage ?doc_id ; foaf:openid ?doc_id . '; 49 | } 50 | } 51 | if ($this->hasRel($n, 'openid.delegate')) { 52 | if ($href = $this->v('href uri', '', $n['a'])) { 53 | $t_vals['doc_owner'] = $this->getDocOwnerID($n); 54 | $t .= '?doc_owner foaf:homepage <'.$href.'> ; foaf:openid <'.$href.'> . '; 55 | } 56 | } 57 | 58 | return [$t_vals, $t]; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /extractors/ARC2_TwitterProfilePicExtractor.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Extractor 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('RDFExtractor'); 12 | 13 | class ARC2_TwitterProfilePicExtractor extends ARC2_RDFExtractor 14 | { 15 | public function __construct($a, &$caller) 16 | { 17 | parent::__construct($a, $caller); 18 | } 19 | 20 | public function __init() 21 | { 22 | parent::__init(); 23 | $this->a['ns']['foaf'] = 'http://xmlns.com/foaf/0.1/'; 24 | $this->a['ns']['mf'] = 'http://poshrdf.org/ns/mf#'; 25 | } 26 | 27 | public function extractRDF() 28 | { 29 | $t_vals = []; 30 | $t = ''; 31 | foreach ($this->nodes as $n) { 32 | if (isset($n['tag']) && ('img' == $n['tag']) && ('profile-image' == $this->v('id', '', $n['a']))) { 33 | $t_vals['vcard_id'] = $this->getDocID($n).'#resource(side/1/2/1)'; 34 | $t .= '?vcard_id mf:photo <'.$n['a']['src'].'> . '; 35 | break; 36 | } 37 | } 38 | if ($t) { 39 | $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']); 40 | $this->addTs(ARC2::getTriplesFromIndex($doc)); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /parsers/ARC2_SGAJSONParser.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 SG API JSON Parser 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('JSONParser'); 12 | 13 | class ARC2_SGAJSONParser extends ARC2_JSONParser 14 | { 15 | public string $rdf; 16 | 17 | /** 18 | * @var array 19 | */ 20 | public array $struct; 21 | 22 | public function __construct($a, &$caller) 23 | { 24 | parent::__construct($a, $caller); 25 | } 26 | 27 | public function __init() 28 | {/* reader */ 29 | parent::__init(); 30 | $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; 31 | $this->nsp = [$this->rdf => 'rdf']; 32 | } 33 | 34 | public function done() 35 | { 36 | $this->extractRDF(); 37 | } 38 | 39 | public function extractRDF($formats = '') 40 | { 41 | $s = $this->getContext(); 42 | $os = $this->getURLs($this->struct); 43 | foreach ($os as $o) { 44 | if ($o != $s) { 45 | $this->addT($s, 'http://www.w3.org/2000/01/rdf-schema#seeAlso', $o, 'uri', 'uri'); 46 | } 47 | } 48 | } 49 | 50 | public function getContext() 51 | { 52 | if (!isset($this->struct['canonical_mapping'])) { 53 | return ''; 54 | } 55 | foreach ($this->struct['canonical_mapping'] as $k => $v) { 56 | return $v; 57 | } 58 | } 59 | 60 | public function getURLs($struct) 61 | { 62 | $r = []; 63 | if (is_array($struct)) { 64 | foreach ($struct as $k => $v) { 65 | if (preg_match('/^http:\/\//', $k) && !in_array($k, $r)) { 66 | $r[] = $k; 67 | } 68 | $sub_r = $this->getURLs($v); 69 | foreach ($sub_r as $sub_v) { 70 | if (!in_array($sub_v, $r)) { 71 | $r[] = $sub_v; 72 | } 73 | } 74 | } 75 | } elseif (preg_match('/^http:\/\//', $struct) && !in_array($struct, $r)) { 76 | $r[] = $struct; 77 | } 78 | 79 | return $r; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /parsers/ARC2_SPARQLXMLResultParser.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 SPARQL Result XML Parser 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('LegacyXMLParser'); 12 | 13 | class ARC2_SPARQLXMLResultParser extends ARC2_LegacyXMLParser 14 | { 15 | public int $allowCDataNodes; 16 | 17 | /** 18 | * @var array 19 | */ 20 | public array $nodes; 21 | public string $srx; 22 | public string $xml; 23 | 24 | public function __construct($a, &$caller) 25 | { 26 | parent::__construct($a, $caller); 27 | } 28 | 29 | public function __init() 30 | {/* reader */ 31 | parent::__init(); 32 | $this->srx = 'http://www.w3.org/2005/sparql-results#'; 33 | $this->nsp[$this->srx] = 'srx'; 34 | $this->allowCDataNodes = 0; 35 | } 36 | 37 | public function done() 38 | { 39 | } 40 | 41 | public function getVariables() 42 | { 43 | $r = []; 44 | foreach ($this->nodes as $node) { 45 | if ($node['tag'] == $this->srx.'variable') { 46 | $r[] = $node['a']['name']; 47 | } 48 | } 49 | 50 | return $r; 51 | } 52 | 53 | public function getRows() 54 | { 55 | $r = []; 56 | $index = $this->getNodeIndex(); 57 | foreach ($this->nodes as $node) { 58 | if ($node['tag'] == $this->srx.'result') { 59 | $row = []; 60 | $row_id = $node['id']; 61 | $bindings = isset($index[$row_id]) ? $index[$row_id] : []; 62 | foreach ($bindings as $binding) { 63 | $row = array_merge($row, $this->getBinding($binding)); 64 | } 65 | if ($row) { 66 | $r[] = $row; 67 | } 68 | } 69 | } 70 | 71 | return $r; 72 | } 73 | 74 | public function getBinding($node) 75 | { 76 | $r = []; 77 | $index = $this->getNodeIndex(); 78 | $var = $node['a']['name']; 79 | $term = $index[$node['id']][0]; 80 | $r[$var.' type'] = preg_replace('/^uri$/', 'uri', substr($term['tag'], strlen($this->srx))); 81 | $r[$var] = ('bnode' == $r[$var.' type']) ? '_:'.$term['cdata'] : $term['cdata']; 82 | if (isset($term['a']['datatype'])) { 83 | $r[$var.' datatype'] = $term['a']['datatype']; 84 | } elseif (isset($term['a'][$this->xml.'lang'])) { 85 | $r[$var.' lang'] = $term['a'][$this->xml.'lang']; 86 | } 87 | 88 | return $r; 89 | } 90 | 91 | public function getBooleanInsertedDeleted() 92 | { 93 | foreach ($this->nodes as $node) { 94 | if ($node['tag'] == $this->srx.'boolean') { 95 | return ('true' == $node['cdata']) ? ['boolean' => true] : ['boolean' => false]; 96 | } elseif ($node['tag'] == $this->srx.'inserted') { 97 | return ['inserted' => $node['cdata']]; 98 | } elseif ($node['tag'] == $this->srx.'deleted') { 99 | return ['deleted' => $node['cdata']]; 100 | } elseif ($node['tag'] == $this->srx.'results') { 101 | return ''; 102 | } 103 | } 104 | 105 | return ''; 106 | } 107 | 108 | public function getStructure() 109 | { 110 | $r = ['variables' => $this->getVariables(), 'rows' => $this->getRows()]; 111 | /* boolean|inserted|deleted */ 112 | if ($sub_r = $this->getBooleanInsertedDeleted()) { 113 | foreach ($sub_r as $k => $v) { 114 | $r[$k] = $v; 115 | } 116 | } 117 | 118 | return $r; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./extractors 6 | ./parsers 7 | ./serializers 8 | ./sparqlscript 9 | ./src 10 | ./store 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ./tests 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /serializers/ARC2_JSONLDSerializer.php: -------------------------------------------------------------------------------- 1 | 6 | * @license W3C Software License and GPL 7 | * 8 | * @homepage 9 | */ 10 | ARC2::inc('RDFSerializer'); 11 | 12 | class ARC2_JSONLDSerializer extends ARC2_RDFSerializer 13 | { 14 | public string $content_header; 15 | 16 | public function __construct($a, &$caller) 17 | { 18 | parent::__construct($a, $caller); 19 | } 20 | 21 | public function __init() 22 | { 23 | parent::__init(); 24 | $this->content_header = 'application/ld+json'; 25 | } 26 | 27 | public function getTerm($v, $term = 's') 28 | { 29 | if (!is_array($v)) { 30 | if (preg_match('/^\_\:/', $v)) { 31 | return ('o' == $term) ? $this->getTerm(['value' => $v, 'type' => 'bnode'], 'o') : '"'.$v.'"'; 32 | } 33 | 34 | return ('o' == $term) ? $this->getTerm(['value' => $v, 'type' => 'uri'], 'o') : '"'.$v.'"'; 35 | } 36 | if (!isset($v['type']) || ('literal' != $v['type'])) { 37 | if ('o' != $term) { 38 | return $this->getTerm($v['value'], $term); 39 | } 40 | 41 | return '{ "@id" : "'.$this->jsonEscape($v['value']).'" }'; 42 | } 43 | /* literal */ 44 | $r = '{ "@value" : "'.$this->jsonEscape($v['value']).'"'; 45 | $suffix = isset($v['datatype']) ? ', "@type" : "'.$v['datatype'].'"' : ''; 46 | $suffix = isset($v['lang']) ? ', "@language" : "'.$v['lang'].'"' : $suffix; 47 | $r .= $suffix.' }'; 48 | 49 | return $r; 50 | } 51 | 52 | public function jsonEscape($v) 53 | { 54 | if (function_exists('json_encode')) { 55 | return preg_replace('/^"(.*)"$/', '\\1', str_replace("\/", '/', json_encode($v))); 56 | } 57 | $from = ['\\', "\r", "\t", "\n", '"', "\b", "\f"]; 58 | $to = ['\\\\', '\r', '\t', '\n', '\"', '\b', '\f']; 59 | 60 | return str_replace($from, $to, $v); 61 | } 62 | 63 | public function getSerializedIndex($index, $raw = 0) 64 | { 65 | $r = ''; 66 | $nl = "\n"; 67 | foreach ($index as $s => $ps) { 68 | $r .= $r ? ','.$nl.$nl : ''; 69 | $r .= ' { '.$nl.' "@id" : '.$this->getTerm($s); 70 | // $first_p = 1; 71 | foreach ($ps as $p => $os) { 72 | $r .= ','.$nl; 73 | $r .= ' '.$this->getTerm($p).' : ['; 74 | $first_o = 1; 75 | if (!is_array($os)) {/* single literal o */ 76 | $os = [['value' => $os, 'type' => 'literal']]; 77 | } 78 | foreach ($os as $o) { 79 | $r .= $first_o ? $nl : ','.$nl; 80 | $r .= ' '.$this->getTerm($o, 'o'); 81 | $first_o = 0; 82 | } 83 | $r .= $nl.' ]'; 84 | } 85 | $r .= $nl.' }'; 86 | } 87 | $r .= $r ? ' ' : ''; 88 | 89 | return '['.$nl.$r.$nl.']'; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /serializers/ARC2_LegacyHTMLSerializer.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Legacy XML Serializer 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('Class'); 12 | 13 | class ARC2_LegacyHTMLSerializer extends ARC2_Class 14 | { 15 | public string $content_header; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | $this->content_header = 'text/html'; 26 | } 27 | 28 | public function getSerializedArray($struct, $root = 1, $ind = ' ') 29 | { 30 | $n = "\n"; 31 | $r = ''; 32 | $is_flat = $this->isAssociativeArray($struct) ? 0 : 1; 33 | foreach ($struct as $k => $v) { 34 | if (!$is_flat) { 35 | $r .= $n.$ind.$ind.'
'.$k.'
'; 36 | } 37 | $r .= $n.$ind.$ind.'
'.(is_array($v) ? $this->getSerializedArray($v, 0, $ind.$ind.$ind).$n.$ind.$ind : htmlspecialchars($v)).'
'; 38 | } 39 | 40 | return $n.$ind.'
'.$r.$n.$ind.'
'; 41 | } 42 | 43 | public function isAssociativeArray($v) 44 | { 45 | foreach (array_keys($v) as $k => $val) { 46 | if ($k !== $val) { 47 | return 1; 48 | } 49 | } 50 | 51 | return 0; 52 | } 53 | 54 | public function getSerializedNode($index, $node, $level = 0, $raw = 0) 55 | { 56 | $r = ''; 57 | $tag = $this->v('tag', '', $node); 58 | if (preg_match('/^(comment|script)$/', $tag)) { 59 | } elseif ('cdata' == $tag) { 60 | $r .= $this->v('cdata', '', $node); 61 | $r .= $this->v('value', '', $node['a']); 62 | } else { 63 | /* open tag */ 64 | if (preg_match('/^(div|form|p|section)$/', $tag)) { 65 | $r .= str_pad("\n", $level + 1, ' '); 66 | } 67 | $r .= '<'.$tag; 68 | $attrs = $this->v('a', [], $node); 69 | foreach ($attrs as $k => $v) { 70 | /* use uri, if detected */ 71 | if ('id' != $k) { 72 | $v = $this->v($k.' uri', $v, $attrs); 73 | } 74 | /* skip arrays and other derived attrs */ 75 | if (preg_match('/\s/s', $k)) { 76 | continue; 77 | } 78 | $r .= ' '.$k.'="'.$v.'"'; 79 | } 80 | if ($node['empty']) { 81 | $r .= '/>'; 82 | } else { 83 | $r .= '>'; 84 | /* cdata */ 85 | $r .= $this->v('cdata', '', $node); 86 | /* sub-nodes */ 87 | $sub_nodes = $this->v($node['id'], [], $index); 88 | foreach ($sub_nodes as $sub_node) { 89 | $r .= $this->getSerializedNode($index, $sub_node, $level + 1, 1); 90 | } 91 | /* close tag */ 92 | // $r .= str_pad("\n", $level + 1, " ") . ''; 93 | $r .= ''; 94 | if (preg_match('/^(div|form|p|section)$/', $tag)) { 95 | $r .= str_pad("\n", $level + 1, ' '); 96 | } 97 | } 98 | } 99 | /* doc envelope, in case of sub-structure serializing */ 100 | if (!$raw && (0 == $level) && ($node['level'] > 1)) { 101 | $r = ' 102 | 103 | 104 | 105 | 106 | 107 | '.$r.' 108 | 109 | 110 | '; 111 | } 112 | 113 | return $r; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /serializers/ARC2_LegacyJSONSerializer.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Legacy JSON Serializer 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('Class'); 12 | 13 | class ARC2_LegacyJSONSerializer extends ARC2_Class 14 | { 15 | public string $content_header; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | $this->content_header = 'application/json'; 26 | } 27 | 28 | public function getSerializedArray($struct, $ind = '') 29 | { 30 | $n = "\n"; 31 | if (function_exists('json_encode')) { 32 | return str_replace('","', '",'.$n.'"', str_replace("\/", '/', json_encode($struct))); 33 | } 34 | $r = ''; 35 | $from = ['\\', "\r", "\t", "\n", '"', "\b", "\f"]; 36 | $to = ['\\\\', '\r', '\t', '\n', '\"', '\b', '\f']; 37 | $is_flat = $this->isAssociativeArray($struct) ? 0 : 1; 38 | foreach ($struct as $k => $v) { 39 | $r .= $r ? ','.$n.$ind.$ind : $ind.$ind; 40 | $r .= $is_flat ? '' : '"'.$k.'": '; 41 | $r .= is_array($v) ? $this->getSerializedArray($v, $ind.' ') : '"'.str_replace($from, $to, $v).'"'; 42 | } 43 | 44 | return $is_flat ? $ind.'['.$n.$r.$n.$ind.']' : $ind.'{'.$n.$r.$n.$ind.'}'; 45 | } 46 | 47 | public function isAssociativeArray($v) 48 | { 49 | foreach (array_keys($v) as $k => $val) { 50 | if ($k !== $val) { 51 | return 1; 52 | } 53 | } 54 | 55 | return 0; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /serializers/ARC2_LegacyXMLSerializer.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Legacy XML Serializer 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('Class'); 12 | 13 | class ARC2_LegacyXMLSerializer extends ARC2_Class 14 | { 15 | public string $content_header; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | $this->content_header = 'text/xml'; 26 | } 27 | 28 | public function getSerializedArray($struct, $root = 1, $ind = ' ') 29 | { 30 | $n = "\n"; 31 | $r = ''; 32 | $is_flat = $this->isAssociativeArray($struct) ? 0 : 1; 33 | foreach ($struct as $k => $v) { 34 | $tag = $is_flat ? 'item' : preg_replace('/[\s]/s', '_', $k); 35 | $tag = preg_replace('/^.*([a-z0-9\-\_]+)$/Uis', '\\1', $tag); 36 | $r .= $n.$ind.'<'.$tag.'>'.(is_array($v) ? $this->getSerializedArray($v, 0, $ind.' ').$n.$ind : htmlspecialchars($v)).''; 37 | } 38 | if ($root) { 39 | $r = $this->getHead().$r.$this->getFooter(); 40 | } 41 | 42 | return $r; 43 | } 44 | 45 | public function getHead() 46 | { 47 | $n = "\n"; 48 | $r = ''; 49 | $r .= $n.''; 50 | 51 | return $r; 52 | } 53 | 54 | public function getFooter() 55 | { 56 | $n = "\n"; 57 | $r = $n.''; 58 | 59 | return $r; 60 | } 61 | 62 | public function isAssociativeArray($v) 63 | { 64 | foreach (array_keys($v) as $k => $val) { 65 | if ($k !== $val) { 66 | return 1; 67 | } 68 | } 69 | 70 | return 0; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /serializers/ARC2_POSHRDFSerializer.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 POSH RDF Serializer 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('RDFSerializer'); 12 | 13 | class ARC2_POSHRDFSerializer extends ARC2_RDFSerializer 14 | { 15 | public string $content_header; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | $this->content_header = 'text/html'; 26 | } 27 | 28 | public function getLabel($res, $ps = '') 29 | { 30 | if (!$ps) { 31 | $ps = []; 32 | } 33 | foreach ($ps as $p => $os) { 34 | if (preg_match('/[\/\#](name|label|summary|title|fn)$/i', $p)) { 35 | return $os[0]['value']; 36 | } 37 | } 38 | if (preg_match('/^\_\:/', $res)) { 39 | return 'An unnamed resource'; 40 | } 41 | 42 | return preg_replace("/^(.*[\/\#])([^\/\#]+)$/", '\\2', str_replace('_', ' ', $res)); 43 | } 44 | 45 | public function getSerializedIndex($index, $res = '') 46 | { 47 | $r = ''; 48 | $n = "\n"; 49 | if ($res) { 50 | $index = [$res => $index[$res]]; 51 | } 52 | // return Trice::dump($index); 53 | foreach ($index as $s => $ps) { 54 | /* node */ 55 | $r .= ' 56 |
57 |

'.$this->getLabel($s, $ps).'

58 | '; 59 | /* arcs */ 60 | foreach ($ps as $p => $os) { 61 | $r .= ' 62 |
63 | '.ucfirst($this->getLabel($p)).' 64 | '; 65 | foreach ($os as $o) { 66 | $r .= $n.$this->getObjectValue($o); 67 | } 68 | $r .= ' 69 |
70 | '; 71 | } 72 | /* node */ 73 | $r .= ' 74 |
75 |
76 | '; 77 | } 78 | 79 | return $r; 80 | } 81 | 82 | public function getObjectValue($o) 83 | { 84 | if ('uri' == $o['type']) { 85 | if (preg_match('/(jpe?g|gif|png)$/i', $o['value'])) { 86 | return $this->getImageObjectValue($o); 87 | } 88 | 89 | return $this->getURIObjectValue($o); 90 | } 91 | if ('bnode' == $o['type']) { 92 | return $this->getBNodeObjectValue($o); 93 | } 94 | 95 | return $this->getLiteralObjectValue($o); 96 | } 97 | 98 | public function getImageObjectValue($o) 99 | { 100 | return 'img'; 101 | } 102 | 103 | public function getURIObjectValue($o) 104 | { 105 | $href = htmlspecialchars($o['value']); 106 | $label = $o['value']; 107 | $label = preg_replace('/^https?\:\/\/(www\.)?/', '', $label); 108 | 109 | return ''.$label.''; 110 | } 111 | 112 | public function getBNodeObjectValue($o) 113 | { 114 | return '
An unnamed resource
'; 115 | } 116 | 117 | public function getLiteralObjectValue($o) 118 | { 119 | return '
'.$o['value'].'
'; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /serializers/ARC2_RDFJSONSerializer.php: -------------------------------------------------------------------------------- 1 | 6 | * @license W3C Software License and GPL 7 | * 8 | * @homepage 9 | */ 10 | ARC2::inc('RDFSerializer'); 11 | 12 | class ARC2_RDFJSONSerializer extends ARC2_RDFSerializer 13 | { 14 | public string $content_header; 15 | 16 | public function __construct($a, &$caller) 17 | { 18 | parent::__construct($a, $caller); 19 | } 20 | 21 | public function __init() 22 | { 23 | parent::__init(); 24 | $this->content_header = 'application/json'; 25 | } 26 | 27 | public function getTerm($v, $term = 's') 28 | { 29 | if (!is_array($v)) { 30 | if (preg_match('/^\_\:/', $v)) { 31 | return ('o' == $term) ? $this->getTerm(['value' => $v, 'type' => 'bnode'], 'o') : '"'.$v.'"'; 32 | } 33 | 34 | return ('o' == $term) ? $this->getTerm(['value' => $v, 'type' => 'uri'], 'o') : '"'.$v.'"'; 35 | } 36 | if (!isset($v['type']) || ('literal' != $v['type'])) { 37 | if ('o' != $term) { 38 | return $this->getTerm($v['value'], $term); 39 | } 40 | if (preg_match('/^\_\:/', $v['value'])) { 41 | return '{ "value" : "'.$this->jsonEscape($v['value']).'", "type" : "bnode" }'; 42 | } 43 | 44 | return '{ "value" : "'.$this->jsonEscape($v['value']).'", "type" : "uri" }'; 45 | } 46 | /* literal */ 47 | $r = '{ "value" : "'.$this->jsonEscape($v['value']).'", "type" : "literal"'; 48 | $suffix = isset($v['datatype']) ? ', "datatype" : "'.$v['datatype'].'"' : ''; 49 | $suffix = isset($v['lang']) ? ', "lang" : "'.$v['lang'].'"' : $suffix; 50 | $r .= $suffix.' }'; 51 | 52 | return $r; 53 | } 54 | 55 | public function jsonEscape($v) 56 | { 57 | if (function_exists('json_encode')) { 58 | return preg_replace('/^"(.*)"$/', '\\1', str_replace("\/", '/', json_encode($v))); 59 | } 60 | $from = ['\\', "\r", "\t", "\n", '"', "\b", "\f"]; 61 | $to = ['\\\\', '\r', '\t', '\n', '\"', '\b', '\f']; 62 | 63 | return str_replace($from, $to, $v); 64 | } 65 | 66 | public function getSerializedIndex($index, $raw = 0) 67 | { 68 | $r = ''; 69 | $nl = "\n"; 70 | foreach ($index as $s => $ps) { 71 | $r .= $r ? ','.$nl.$nl : ''; 72 | $r .= ' '.$this->getTerm($s).' : {'; 73 | $first_p = 1; 74 | foreach ($ps as $p => $os) { 75 | $r .= $first_p ? $nl : ','.$nl; 76 | $r .= ' '.$this->getTerm($p).' : ['; 77 | $first_o = 1; 78 | if (!is_array($os)) {/* single literal o */ 79 | $os = [['value' => $os, 'type' => 'literal']]; 80 | } 81 | foreach ($os as $o) { 82 | $r .= $first_o ? $nl : ','.$nl; 83 | $r .= ' '.$this->getTerm($o, 'o'); 84 | $first_o = 0; 85 | } 86 | $first_p = 0; 87 | $r .= $nl.' ]'; 88 | } 89 | $r .= $nl.' }'; 90 | } 91 | $r .= $r ? ' ' : ''; 92 | 93 | return '{'.$nl.$r.$nl.'}'; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /serializers/ARC2_RDFSerializer.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * @version 2010-11-16 11 | */ 12 | ARC2::inc('Class'); 13 | 14 | class ARC2_RDFSerializer extends ARC2_Class 15 | { 16 | public function __construct($a, &$caller) 17 | { 18 | parent::__construct($a, $caller); 19 | } 20 | 21 | public function __init() 22 | { 23 | parent::__init(); 24 | foreach ($this->ns as $k => $v) { 25 | $this->nsp[$v] = $k; 26 | } 27 | } 28 | 29 | public function xgetPName($v) 30 | {/* moved to merged getPName in ARC2_CLass */ 31 | if (preg_match('/^([a-z0-9\_\-]+)\:([a-z\_][a-z0-9\_\-]*)$/i', $v, $m) && isset($this->ns[$m[1]])) { 32 | $this->used_ns = !in_array($this->ns[$m[1]], $this->used_ns) ? array_merge($this->used_ns, [$this->ns[$m[1]]]) : $this->used_ns; 33 | 34 | return $v; 35 | } 36 | if (preg_match('/^(.*[\/\#])([a-z\_][a-z0-9\-\_]*)$/i', $v, $m)) { 37 | return $this->getPrefix($m[1]).':'.$m[2]; 38 | } 39 | 40 | return 0; 41 | } 42 | 43 | public function getSerializedTriples($triples, $raw = 0) 44 | { 45 | $index = ARC2::getSimpleIndex($triples, 0); 46 | 47 | return $this->getSerializedIndex($index, $raw); 48 | } 49 | 50 | public function getSerializedIndex($index, $raw = 0) 51 | { 52 | return ''; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /serializers/ARC2_RSS10Serializer.php: -------------------------------------------------------------------------------- 1 | 10 | * 11 | * @version 2010-11-16 12 | */ 13 | ARC2::inc('RDFXMLSerializer'); 14 | 15 | class ARC2_RSS10Serializer extends ARC2_RDFXMLSerializer 16 | { 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | $this->content_header = 'application/rss+xml'; 26 | $this->default_ns = 'http://purl.org/rss/1.0/'; 27 | $this->type_nodes = true; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/ARC2/Store/Adapter/AbstractAdapter.php: -------------------------------------------------------------------------------- 1 | 5 | * @author Konrad Abicht 6 | * @license W3C Software License and GPL 7 | * 8 | * @homepage 9 | */ 10 | 11 | namespace ARC2\Store\Adapter; 12 | 13 | abstract class AbstractAdapter 14 | { 15 | protected $configuration; 16 | protected $db; 17 | 18 | /** 19 | * @var int 20 | */ 21 | protected $lastRowCount; 22 | 23 | /** 24 | * Sent queries. 25 | * 26 | * @var array 27 | */ 28 | protected $queries = []; 29 | 30 | /** 31 | * @param array $configuration default is array() 32 | */ 33 | public function __construct(array $configuration = []) 34 | { 35 | $this->configuration = $configuration; 36 | $this->lastRowCount = 0; 37 | 38 | $this->checkRequirements(); 39 | } 40 | 41 | public function deleteAllTables(): void 42 | { 43 | // remove all tables 44 | $tables = $this->fetchList('SHOW TABLES'); 45 | foreach ($tables as $table) { 46 | $this->exec('DROP TABLE '.$table['Tables_in_'.$this->configuration['db_name']]); 47 | } 48 | } 49 | 50 | public function getAllTables(): array 51 | { 52 | $tables = $this->fetchList('SHOW TABLES'); 53 | $result = []; 54 | foreach ($tables as $table) { 55 | $result[] = $table['Tables_in_'.$this->configuration['db_name']]; 56 | } 57 | 58 | return $result; 59 | } 60 | 61 | public function getConfiguration(): array 62 | { 63 | return $this->configuration; 64 | } 65 | 66 | public function getQueries(): array 67 | { 68 | return $this->queries; 69 | } 70 | 71 | abstract public function checkRequirements(); 72 | 73 | /** 74 | * Connect to server. 75 | * 76 | * It returns current object for the connection, such as an instance of \PDO. 77 | */ 78 | abstract public function connect($existingConnection = null); 79 | 80 | abstract public function disconnect(); 81 | 82 | abstract public function escape($value); 83 | 84 | abstract public function exec($sql); 85 | 86 | abstract public function fetchList($sql); 87 | 88 | abstract public function fetchRow($sql); 89 | 90 | abstract public function getAdapterName(); 91 | 92 | abstract public function getCollation(); 93 | 94 | abstract public function getDBSName(); 95 | 96 | abstract public function getLastInsertId(); 97 | 98 | abstract public function getErrorMessage(); 99 | 100 | abstract public function getNumberOfRows($sql); 101 | 102 | abstract public function getStoreName(); 103 | 104 | abstract public function getTablePrefix(); 105 | 106 | abstract public function simpleQuery($sql); 107 | } 108 | -------------------------------------------------------------------------------- /src/ARC2/Store/Adapter/AdapterFactory.php: -------------------------------------------------------------------------------- 1 | 5 | * @author Konrad Abicht 6 | * @license W3C Software License and GPL 7 | * 8 | * @homepage 9 | */ 10 | 11 | namespace ARC2\Store\Adapter; 12 | 13 | /** 14 | * It provides an adapter instance for requested adapter name. 15 | */ 16 | class AdapterFactory 17 | { 18 | /** 19 | * @param string $adapterName 20 | * @param array $configuration Default is array() 21 | * 22 | * @throws \Exception if unknown adapter name was given 23 | */ 24 | public function getInstanceFor($adapterName, $configuration = []) 25 | { 26 | if (\in_array($adapterName, $this->getSupportedAdapters())) { 27 | if ('pdo' == $adapterName) { 28 | // no cache 29 | if (false == class_exists(PDOAdapter::class)) { 30 | require_once 'PDOAdapter.php'; 31 | } 32 | 33 | return new PDOAdapter($configuration); 34 | } 35 | } 36 | 37 | throw new \Exception('Unknown adapter name given. Currently supported are: '.implode(', ', $this->getSupportedAdapters())); 38 | } 39 | 40 | /** 41 | * @return array 42 | */ 43 | public function getSupportedAdapters() 44 | { 45 | return ['pdo']; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /store/ARC2_StoreAskQueryHandler.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * @version 2010-11-16 11 | */ 12 | ARC2::inc('StoreSelectQueryHandler'); 13 | 14 | class ARC2_StoreAskQueryHandler extends ARC2_StoreSelectQueryHandler 15 | { 16 | public function __construct($a, &$caller) 17 | {/* caller has to be a store */ 18 | parent::__construct($a, $caller); 19 | } 20 | 21 | public function __init() 22 | { 23 | parent::__init(); 24 | $this->store = $this->caller; 25 | } 26 | 27 | public function runQuery($infos) 28 | { 29 | $infos['query']['limit'] = 1; 30 | $this->infos = $infos; 31 | $this->buildResultVars(); 32 | 33 | return parent::runQuery($this->infos); 34 | } 35 | 36 | public function buildResultVars() 37 | { 38 | $this->infos['query']['result_vars'][] = ['var' => '1', 'aggregate' => '', 'alias' => 'success']; 39 | } 40 | 41 | public function getFinalQueryResult($q_sql, $tmp_tbl) 42 | { 43 | $row = $this->store->a['db_object']->fetchRow('SELECT success FROM '.$tmp_tbl); 44 | $r = isset($row['success']) ? $row['success'] : 0; 45 | 46 | return $r ? true : false; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /store/ARC2_StoreAtomLoader.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Store Atom(2) Loader 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('AtomParser'); 12 | 13 | class ARC2_StoreAtomLoader extends ARC2_AtomParser 14 | { 15 | public int $t_count = 0; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | } 26 | 27 | public function addT($t) 28 | { 29 | $this->caller->addT($t['s'], $t['p'], $t['o'], $t['s_type'], $t['o_type'], $t['o_datatype'], $t['o_lang']); 30 | ++$this->t_count; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /store/ARC2_StoreCBJSONLoader.php: -------------------------------------------------------------------------------- 1 | 6 | * @license W3C Software License and GPL 7 | * 8 | * @homepage 9 | * 10 | * @version 2010-11-16 11 | */ 12 | ARC2::inc('CBJSONParser'); 13 | 14 | class ARC2_StoreCBJSONLoader extends ARC2_CBJSONParser 15 | { 16 | public function __construct($a, &$caller) 17 | { 18 | parent::__construct($a, $caller); 19 | } 20 | 21 | public function __init() 22 | { 23 | parent::__init(); 24 | } 25 | 26 | public function done() 27 | { 28 | $this->extractRDF(); 29 | } 30 | 31 | public function addT($s = '', $p = '', $o = '', $s_type = '', $o_type = '', $o_dt = '', $o_lang = '') 32 | { 33 | $o = $this->toUTF8($o); 34 | $this->caller->addT($s, $p, $o, $s_type, $o_type, $o_dt, $o_lang); 35 | ++$this->t_count; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /store/ARC2_StoreConstructQueryHandler.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 RDF Store CONSTRUCT Query Handler 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('StoreSelectQueryHandler'); 12 | 13 | class ARC2_StoreConstructQueryHandler extends ARC2_StoreSelectQueryHandler 14 | { 15 | public function __construct($a, &$caller) 16 | {/* caller has to be a store */ 17 | parent::__construct($a, $caller); 18 | } 19 | 20 | public function __init() 21 | { 22 | parent::__init(); 23 | $this->store = $this->caller; 24 | } 25 | 26 | public function runQuery($infos) 27 | { 28 | $this->infos = $infos; 29 | $this->buildResultVars(); 30 | $this->infos['query']['distinct'] = 1; 31 | $sub_r = parent::runQuery($this->infos); 32 | $rf = $this->v('result_format', '', $infos); 33 | if (in_array($rf, ['sql', 'structure', 'index'])) { 34 | return $sub_r; 35 | } 36 | 37 | return $this->getResultIndex($sub_r); 38 | } 39 | 40 | public function buildResultVars() 41 | { 42 | $r = []; 43 | foreach ($this->infos['query']['construct_triples'] as $t) { 44 | foreach (['s', 'p', 'o'] as $term) { 45 | if ('var' == $t[$term.'_type']) { 46 | if (!in_array($t[$term], $r)) { 47 | $r[] = ['var' => $t[$term], 'aggregate' => '', 'alias' => '']; 48 | } 49 | } 50 | } 51 | } 52 | $this->infos['query']['result_vars'] = $r; 53 | } 54 | 55 | public function getResultIndex($qr) 56 | { 57 | $r = []; 58 | $added = []; 59 | $rows = $this->v('rows', [], $qr); 60 | $cts = $this->infos['query']['construct_triples']; 61 | $bnc = 0; 62 | foreach ($rows as $row) { 63 | ++$bnc; 64 | foreach ($cts as $ct) { 65 | $skip_t = 0; 66 | $t = []; 67 | foreach (['s', 'p', 'o'] as $term) { 68 | $val = $ct[$term]; 69 | $type = $ct[$term.'_type']; 70 | $val = ('bnode' == $type) ? $val.$bnc : $val; 71 | if ('var' == $type) { 72 | $skip_t = !isset($row[$val]) ? 1 : $skip_t; 73 | $type = !$skip_t ? $row[$val.' type'] : ''; 74 | $val = (!$skip_t) ? $row[$val] : ''; 75 | } 76 | $t[$term] = $val; 77 | $t[$term.'_type'] = $type; 78 | if (isset($row[$ct[$term].' lang'])) { 79 | $t[$term.'_lang'] = $row[$ct[$term].' lang']; 80 | } 81 | if (isset($row[$ct[$term].' datatype'])) { 82 | $t[$term.'_datatype'] = $row[$ct[$term].' datatype']; 83 | } 84 | } 85 | if (!$skip_t) { 86 | $s = $t['s']; 87 | $p = $t['p']; 88 | $o = $t['o']; 89 | if (!isset($r[$s])) { 90 | $r[$s] = []; 91 | } 92 | if (!isset($r[$s][$p])) { 93 | $r[$s][$p] = []; 94 | } 95 | $o = ['value' => $o]; 96 | foreach (['lang', 'type', 'datatype'] as $suffix) { 97 | if (isset($t['o_'.$suffix]) && $t['o_'.$suffix]) { 98 | $o[$suffix] = $t['o_'.$suffix]; 99 | } 100 | } 101 | if (!isset($added[md5($s.' '.$p.' '.serialize($o))])) { 102 | $r[$s][$p][] = $o; 103 | $added[md5($s.' '.$p.' '.serialize($o))] = 1; 104 | } 105 | } 106 | } 107 | } 108 | 109 | return $r; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /store/ARC2_StoreDumpQueryHandler.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 RDF Store DUMP Query Handler 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('StoreQueryHandler'); 12 | 13 | class ARC2_StoreDumpQueryHandler extends ARC2_StoreQueryHandler 14 | { 15 | /** 16 | * @var array 17 | */ 18 | public array $infos; 19 | 20 | public function __construct($a, &$caller) 21 | {/* caller has to be a store */ 22 | parent::__construct($a, $caller); 23 | } 24 | 25 | public function __init() 26 | { 27 | parent::__init(); 28 | $this->store = $this->caller; 29 | } 30 | 31 | /** 32 | * @param int $keep_bnode_ids Deprecated and value will be ignored! 33 | * 34 | * @return int Always returns 1 35 | */ 36 | public function runQuery($infos, $keep_bnode_ids = 0) 37 | { 38 | $this->infos = $infos; 39 | ARC2::inc('StoreDumper'); 40 | $d = new ARC2_StoreDumper($this->a, $this->store); 41 | $d->dumpSPOG(); 42 | 43 | return 1; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /store/ARC2_StoreHelper.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 RDF Store Helper 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('Class'); 12 | 13 | class ARC2_StoreHelper extends ARC2_Class 14 | { 15 | public $store; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | $this->store = $this->caller; 26 | } 27 | 28 | public function changeNamespaceURI($old_uri, $new_uri) 29 | { 30 | $id_changes = 0; 31 | $t_changes = 0; 32 | /* table lock */ 33 | if ($this->store->getLock()) { 34 | foreach (['id', 's', 'o'] as $id_col) { 35 | $tbl = $this->store->getTablePrefix().$id_col.'2val'; 36 | $sql = 'SELECT id, val FROM '.$tbl.' WHERE val LIKE "'.$this->store->a['db_object']->escape($old_uri).'%"'; 37 | $rows = $this->store->a['db_object']->fetchList($sql); 38 | 39 | if (false == is_array($rows)) { 40 | continue; 41 | } 42 | foreach ($rows as $row) { 43 | $new_val = str_replace($old_uri, $new_uri, $row['val']); 44 | $new_id = $this->store->getTermID($new_val, $id_col); 45 | if (!$new_id) {/* unknown ns uri, overwrite current id value */ 46 | $sub_sql = 'UPDATE '.$tbl." SET val = '".$this->store->a['db_object']->escape($new_val)."' WHERE id = ".$row['id']; 47 | $sub_r = $this->store->a['db_object']->simpleQuery($sub_sql); 48 | ++$id_changes; 49 | } else {/* replace ids */ 50 | $t_tbls = $this->store->getTables(); 51 | foreach ($t_tbls as $t_tbl) { 52 | if (preg_match('/^triple/', $t_tbl)) { 53 | foreach (['s', 'p', 'o', 'o_lang_dt'] as $t_col) { 54 | $sub_sql = 'UPDATE '.$this->store->getTablePrefix().$t_tbl.' SET '.$t_col.' = '.$new_id.' WHERE '.$t_col.' = '.$row['id']; 55 | $sub_r = $this->store->a['db_object']->simpleQuery($sub_sql); 56 | $t_changes += $this->store->a['db_object']->getAffectedRows(); 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | $this->store->releaseLock(); 64 | } 65 | 66 | return ['id_replacements' => $id_changes, 'triple_updates' => $t_changes]; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /store/ARC2_StoreInsertQueryHandler.php: -------------------------------------------------------------------------------- 1 | 6 | * @license W3C Software License and GPL 7 | * 8 | * @homepage 9 | */ 10 | ARC2::inc('StoreQueryHandler'); 11 | 12 | class ARC2_StoreInsertQueryHandler extends ARC2_StoreQueryHandler 13 | { 14 | /** 15 | * @var array 16 | */ 17 | public array $infos; 18 | 19 | public function __construct($a, &$caller) 20 | {/* caller has to be a store */ 21 | parent::__construct($a, $caller); 22 | } 23 | 24 | public function __init() 25 | { 26 | parent::__init(); 27 | $this->store = $this->caller; 28 | } 29 | 30 | public function runQuery($infos, $keep_bnode_ids = 0) 31 | { 32 | $this->infos = $infos; 33 | /* insert */ 34 | if (!$this->v('pattern', [], $this->infos['query'])) { 35 | $triples = $this->infos['query']['construct_triples']; 36 | /* don't execute empty INSERTs as they trigger a LOAD on the graph URI */ 37 | if ($triples) { 38 | return $this->store->insert($triples, $this->infos['query']['target_graph'], $keep_bnode_ids); 39 | } else { 40 | return ['t_count' => 0, 'load_time' => 0]; 41 | } 42 | } else { 43 | $keep_bnode_ids = 1; 44 | ARC2::inc('StoreConstructQueryHandler'); 45 | $h = new ARC2_StoreConstructQueryHandler($this->a, $this->store); 46 | $sub_r = $h->runQuery($this->infos); 47 | if ($sub_r) { 48 | return $this->store->insert($sub_r, $this->infos['query']['target_graph'], $keep_bnode_ids); 49 | } 50 | 51 | return ['t_count' => 0, 'load_time' => 0]; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /store/ARC2_StoreQueryHandler.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * @version 2010-11-16 11 | */ 12 | ARC2::inc('Class'); 13 | 14 | class ARC2_StoreQueryHandler extends ARC2_Class 15 | { 16 | public int $allow_extension_functions; 17 | public int $keep_time_limit; 18 | public string $handler_type; 19 | public string $mrg_table_id; 20 | public object $store; 21 | public string $xsd; 22 | 23 | public function __construct($a, &$caller) 24 | { 25 | parent::__construct($a, $caller); 26 | } 27 | 28 | public function __init() 29 | { 30 | parent::__init(); 31 | $this->xsd = 'http://www.w3.org/2001/XMLSchema#'; 32 | $this->allow_extension_functions = $this->v('store_allow_extension_functions', 1, $this->a); 33 | $this->keep_time_limit = $this->v('keep_time_limit', 0, $this->a); 34 | $this->handler_type = ''; 35 | } 36 | 37 | public function getTermID($val, $term = '') 38 | { 39 | return $this->store->getTermID($val, $term); 40 | } 41 | 42 | public function hasHashColumn($tbl) 43 | { 44 | return $this->store->hasHashColumn($tbl); 45 | } 46 | 47 | public function getValueHash($val) 48 | { 49 | return $this->store->getValueHash($val); 50 | } 51 | 52 | public function getTripleTable() 53 | { 54 | $r = $this->store->getTablePrefix().'triple'; 55 | 56 | return $r; 57 | } 58 | 59 | public function createMergeTable() 60 | { 61 | $split_ps = $this->store->getSetting('split_predicates', []); 62 | if (!$split_ps) { 63 | return 1; 64 | } 65 | $this->mrg_table_id = 'MRG_'.$this->store->getTablePrefix().crc32(uniqid(rand())); 66 | $this->getDBObject()->query('FLUSH TABLES'); 67 | $indexes = $this->v('store_indexes', ['sp (s,p)', 'os (o,s)', 'po (p,o)'], $this->a); 68 | $index_code = $indexes ? 'KEY '.implode(', KEY ', $indexes).', ' : ''; 69 | $prefix = $this->store->getTablePrefix(); 70 | $sql = ' 71 | CREATE TEMPORARY TABLE IF NOT EXISTS '.$prefix.'triple_all ( 72 | t mediumint UNSIGNED NOT NULL, 73 | s mediumint UNSIGNED NOT NULL, 74 | p mediumint UNSIGNED NOT NULL, 75 | o mediumint UNSIGNED NOT NULL, 76 | o_lang_dt mediumint UNSIGNED NOT NULL, 77 | o_comp char(35) NOT NULL, /* normalized value for ORDER BY operations */ 78 | s_type tinyint(1) NOT NULL default 0, /* uri/bnode => 0/1 */ 79 | o_type tinyint(1) NOT NULL default 0, /* uri/bnode/literal => 0/1/2 */ 80 | misc tinyint(1) NOT NULL default 0, /* temporary flags */ 81 | UNIQUE KEY (t), '.$index_code.' KEY (misc) 82 | ) 83 | '; 84 | $v = $this->store->getDBVersion(); 85 | $sql .= (($v < '04-01-00') && ($v >= '04-00-18')) ? 'ENGINE' : (($v >= '04-01-02') ? 'ENGINE' : 'TYPE'); 86 | $sql .= '=MERGE UNION=('.$prefix.'triple'; 87 | foreach ($split_ps as $pos => $p) { 88 | $sql .= ','.$prefix.'triple_'.abs(crc32($p)); 89 | } 90 | $sql .= ')'; 91 | 92 | // TODO whats about that? 93 | // $sql .= ($v >= '04-00-00') ? " CHARACTER SET utf8" : ""; 94 | // $sql .= ($v >= '04-01-00') ? " COLLATE utf8_unicode_ci" : ""; 95 | // echo $sql; 96 | return $this->getDBObject()->query($sql); 97 | } 98 | 99 | public function dropMergeTable() 100 | { 101 | return 1; 102 | // TODO triple_all table seems not used anymore, therefore this function can be removed? 103 | $sql = 'DROP TABLE IF EXISTS '.$this->store->getTablePrefix().'triple_all'; 104 | // echo $sql; 105 | // return $this->queryDB($sql, $this->store->getDBCon()); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /store/ARC2_StoreRDFXMLLoader.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Store RDF/XML Loader 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('RDFXMLParser'); 12 | 13 | class ARC2_StoreRDFXMLLoader extends ARC2_RDFXMLParser 14 | { 15 | public function __construct($a, &$caller) 16 | { 17 | parent::__construct($a, $caller); 18 | } 19 | 20 | public function __init() 21 | { 22 | parent::__init(); 23 | } 24 | 25 | public function addT($s, $p, $o, $s_type, $o_type, $o_dt = '', $o_lang = '') 26 | { 27 | $this->caller->addT($s, $p, $o, $s_type, $o_type, $o_dt, $o_lang); 28 | ++$this->t_count; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /store/ARC2_StoreRSSLoader.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Store RSS(2) Loader 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('RSSParser'); 12 | 13 | class ARC2_StoreRSSLoader extends ARC2_RSSParser 14 | { 15 | public int $t_count = 0; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | } 26 | 27 | public function addT($t) 28 | { 29 | $this->caller->addT($t['s'], $t['p'], $t['o'], $t['s_type'], $t['o_type'], $t['o_datatype'], $t['o_lang']); 30 | ++$this->t_count; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /store/ARC2_StoreSGAJSONLoader.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Store SG API JSON Loader 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('SGAJSONParser'); 12 | 13 | class ARC2_StoreSGAJSONLoader extends ARC2_SGAJSONParser 14 | { 15 | public function __construct($a, &$caller) 16 | { 17 | parent::__construct($a, $caller); 18 | } 19 | 20 | public function __init() 21 | { 22 | parent::__init(); 23 | } 24 | 25 | public function done() 26 | { 27 | $this->extractRDF(); 28 | } 29 | 30 | public function addT($s = '', $p = '', $o = '', $s_type = '', $o_type = '', $o_dt = '', $o_lang = '') 31 | { 32 | $this->caller->addT($s, $p, $o, $s_type, $o_type, $o_dt, $o_lang); 33 | ++$this->t_count; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /store/ARC2_StoreSPOGLoader.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Store SPOG Loader 7 | author: Morten H�ybye Frederiksen / Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('SPOGParser'); 12 | 13 | class ARC2_StoreSPOGLoader extends ARC2_SPOGParser 14 | { 15 | public int $t_count = 0; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | } 26 | 27 | public function addT($s = '', $p = '', $o = '', $s_type = '', $o_type = '', $o_dt = '', $o_lang = '', $g = '') 28 | { 29 | if (!($s && $p && $o)) { 30 | return 0; 31 | } 32 | if (!$g) { 33 | $g = $this->caller->target_graph; 34 | } 35 | if ($this->caller->fixed_target_graph) { 36 | $g = $this->caller->fixed_target_graph; 37 | } 38 | $prev_g = $this->caller->target_graph; 39 | $this->caller->target_graph = $g; 40 | $this->caller->addT($s, $p, $o, $s_type, $o_type, $o_dt, $o_lang); 41 | $this->caller->target_graph = $prev_g; 42 | ++$this->t_count; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /store/ARC2_StoreSemHTMLLoader.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Store SemHTML Loader 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('SemHTMLParser'); 12 | 13 | class ARC2_StoreSemHTMLLoader extends ARC2_SemHTMLParser 14 | { 15 | public int $t_count = 0; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | } 26 | 27 | public function done() 28 | { 29 | $this->extractRDF(); 30 | } 31 | 32 | public function addT($t) 33 | { 34 | $this->caller->addT($t['s'], $t['p'], $t['o'], $t['s_type'], $t['o_type'], $t['o_datatype'], $t['o_lang']); 35 | ++$this->t_count; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /store/ARC2_StoreTurtleLoader.php: -------------------------------------------------------------------------------- 1 | 4 | @license W3C Software License and GPL 5 | 6 | class: ARC2 Store Turtle Loader 7 | author: Benjamin Nowack 8 | version: 2010-11-16 9 | */ 10 | 11 | ARC2::inc('TurtleParser'); 12 | 13 | class ARC2_StoreTurtleLoader extends ARC2_TurtleParser 14 | { 15 | public int $t_count = 0; 16 | 17 | public function __construct($a, &$caller) 18 | { 19 | parent::__construct($a, $caller); 20 | } 21 | 22 | public function __init() 23 | { 24 | parent::__init(); 25 | } 26 | 27 | public function addT($t) 28 | { 29 | $this->caller->addT( 30 | $t['s'], 31 | $t['p'], 32 | $t['o'], 33 | $t['s_type'], 34 | $t['o_type'], 35 | $t['o_datatype'], 36 | $t['o_lang'] 37 | ); 38 | 39 | ++$this->t_count; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/ARC2_TestCase.php: -------------------------------------------------------------------------------- 1 | dbConfig = $dbConfig; 28 | } 29 | 30 | /** 31 | * Depending on the DB config returns current table prefix. It consists of table prefix and store name, if available. 32 | * 33 | * @return string 34 | */ 35 | protected function getSqlTablePrefix() 36 | { 37 | $prefix = isset($this->dbConfig['db_table_prefix']) ? $this->dbConfig['db_table_prefix'].'_' : ''; 38 | $prefix .= isset($this->dbConfig['store_name']) ? $this->dbConfig['store_name'].'_' : ''; 39 | 40 | return $prefix; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | 'arc2_test', 31 | 'db_user' => 'root', 32 | 'db_pwd' => 'Pass123', 33 | 'db_host' => '127.0.0.1', 34 | 'db_port' => $_SERVER['DB_PORT'] ?? 3306, 35 | ]; 36 | 37 | /* 38 | * DB Adapter 39 | */ 40 | $dbConfig['db_adapter'] = getenv('DB_ADAPTER') ?? $_SERVER['DB_ADAPTER']; 41 | if (false === $dbConfig['db_adapter']) { 42 | $dbConfig['db_adapter'] = 'pdo'; 43 | } 44 | 45 | // in pre 3.x ARC2 supported mysqli too. because of that the switch is still there just in case 46 | // another adapter will be added in the future 47 | 48 | if ('pdo' == $dbConfig['db_adapter']) { 49 | $dbConfig['db_pdo_protocol'] = getenv('DB_PDO_PROTOCOL') ?? $_SERVER['DB_PDO_PROTOCOL']; 50 | if (false === $dbConfig['db_pdo_protocol']) { 51 | $dbConfig['db_pdo_protocol'] = 'mysql'; 52 | } 53 | 54 | if (is_string($dbConfig['db_pdo_protocol']) && '' !== $dbConfig['db_pdo_protocol']) { 55 | // OK 56 | } else { 57 | $msg = 'Neither environment variable DB_PDO_PROTOCOL nor $_SERVER["DB_PDO_PROTOCOL"] are set.' 58 | .' Possible values are: mysql'; 59 | throw new Exception($msg); 60 | } 61 | } else { 62 | throw new Exception('Neither environment variable DB_ADAPTER nor $_SERVER["DB_ADAPTER"] are set.'); 63 | } 64 | 65 | // set defaults for dbConfig entries 66 | if (false == isset($dbConfig['store_name'])) { 67 | $dbConfig['store_name'] = 'arc'; 68 | } 69 | 70 | $dbConfig['db_table_prefix'] = $dbConfig['db_table_prefix'] ?? null; 71 | } else { 72 | $dbConfig = require 'config.php.dist'; 73 | } 74 | -------------------------------------------------------------------------------- /tests/config.php.dist: -------------------------------------------------------------------------------- 1 | 'arc2_test', 9 | 'db_user' => 'root', 10 | 'db_pwd' => 'Pass123', 11 | 'db_host' => 'db', 12 | 'db_port' => 3306, 13 | 'db_adapter' => 'pdo', 14 | 'db_pdo_protocol' => 'mysql', 15 | 'store_name' => 'arc', 16 | ); 17 | -------------------------------------------------------------------------------- /tests/data/atom/feed.atom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Example Feed 5 | 6 | 2003-12-13T18:30:02Z 7 | 8 | John Doe 9 | 10 | urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 11 | 12 | 13 | Atom-Powered Robots Run Amok 14 | 15 | urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a 16 | 2003-12-13T18:30:02Z 17 | Some text. 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/data/json/sparql-select-result.json: -------------------------------------------------------------------------------- 1 | { 2 | "head": { 3 | "link": [ 4 | "http://www.w3.org/TR/rdf-sparql-XMLres/example.rq" 5 | ], 6 | "vars": [ 7 | "x", 8 | "hpage", 9 | "name", 10 | "mbox", 11 | "age", 12 | "blurb", 13 | "friend" 14 | ] 15 | }, 16 | "results": { 17 | "bindings": [ 18 | { 19 | "x" : { 20 | "type": "bnode", 21 | "value": "r1" 22 | }, 23 | 24 | "hpage" : { 25 | "type": "uri", 26 | "value": "http://work.example.org/alice/" 27 | }, 28 | 29 | "name" : { 30 | "type": "literal", 31 | "value": "Alice" 32 | }, 33 | 34 | "mbox" : { 35 | "type": "literal", 36 | "value": "" 37 | }, 38 | 39 | "blurb" : { 40 | "datatype": "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral", 41 | "type": "typed-literal", 42 | "value": "

My name is alice

" 43 | }, 44 | 45 | "friend" : { 46 | "type": "bnode", 47 | "value": "r2" 48 | } 49 | },{ 50 | "x" : { 51 | "type": "bnode", 52 | "value": "r2" 53 | }, 54 | 55 | "hpage" : { 56 | "type": "uri", 57 | "value": "http://work.example.org/bob/" 58 | }, 59 | 60 | "name" : { 61 | "type": "literal", 62 | "value": "Bob", 63 | "xml:lang": "en" 64 | }, 65 | 66 | "mbox" : { 67 | "type": "uri", 68 | "value": "mailto:bob@work.example.org" 69 | }, 70 | 71 | "friend" : { 72 | "type": "bnode", 73 | "value": "r1" 74 | } 75 | } 76 | ] 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | All tests in this folder are dependend on what environment variables are set OR what `tests/config.php` contains. 4 | 5 | If you want to check certain database backends, adapt `tests/config.php` accordingly. 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/AggregatesTest.php: -------------------------------------------------------------------------------- 1 | w3cTestsFolderPath = __DIR__.'/w3c-tests/aggregates'; 19 | $this->testPref = 'http://www.w3.org/2009/sparql/docs/tests/data-sparql11/aggregates/manifest#'; 20 | } 21 | 22 | /* 23 | * tests 24 | */ 25 | 26 | public function testAggAvg01() 27 | { 28 | $this->loadManifestFileIntoStore($this->w3cTestsFolderPath); 29 | 30 | $testname = 'agg-avg-01'; 31 | 32 | // get test data 33 | $data = $this->getTestData($this->testPref.$testname); 34 | 35 | // load test data into graph 36 | $this->store->insert($data, $this->dataGraphUri); 37 | 38 | // get query to test 39 | $testQuery = $this->getTestQuery($this->testPref.$testname); 40 | 41 | // get actual result for given test query 42 | $actualResult = $this->store->query($testQuery); 43 | $actualResultAsXml = $this->getXmlVersionOfResult($actualResult); 44 | 45 | $this->assertEquals( 46 | '2', 47 | (string) $actualResultAsXml->results->result->binding->literal[0] 48 | ); 49 | 50 | // remember current behavior, but skip test anyway to show developer here is still a problem. 51 | $this->markTestSkipped( 52 | 'Rounding bug in AVG function (MySQL). See https://github.com/semsol/arc2/issues/99' 53 | ); 54 | } 55 | 56 | public function testAggEmptyGroup() 57 | { 58 | $this->assertTrue($this->runTestFor('agg-empty-group')); 59 | } 60 | 61 | public function testAggMin01() 62 | { 63 | $this->markTestSkipped( 64 | 'Skipped, because of known bug that ARC2 \'s Turtle parser can not parse decimals. ' 65 | .'For more information, see #136' 66 | ); 67 | 68 | /* 69 | * it seems the Turtle parser is not able to detect "1.0", but only "1" 70 | * 71 | * see file db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-numeric.ttl 72 | */ 73 | 74 | $this->assertTrue($this->runTestFor('agg-min-01')); 75 | } 76 | 77 | public function testAgg01() 78 | { 79 | $this->assertTrue($this->runTestFor('agg01')); 80 | } 81 | 82 | public function testAgg02() 83 | { 84 | $this->assertTrue($this->runTestFor('agg02')); 85 | } 86 | 87 | public function testAgg04() 88 | { 89 | $this->assertTrue($this->runTestFor('agg04')); 90 | } 91 | 92 | public function testAgg05() 93 | { 94 | $this->assertTrue($this->runTestFor('agg05')); 95 | } 96 | 97 | public function testAgg08() 98 | { 99 | $this->assertTrue($this->runTestFor('agg08')); 100 | } 101 | 102 | public function testAgg09() 103 | { 104 | $this->assertTrue($this->runTestFor('agg09')); 105 | } 106 | 107 | public function testAgg10() 108 | { 109 | $this->assertTrue($this->runTestFor('agg10')); 110 | } 111 | 112 | public function testAgg11() 113 | { 114 | $this->assertTrue($this->runTestFor('agg11')); 115 | } 116 | 117 | public function testAgg12() 118 | { 119 | $this->assertTrue($this->runTestFor('agg12')); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/DropTest.php: -------------------------------------------------------------------------------- 1 | w3cTestsFolderPath = __DIR__.'/w3c-tests/drop'; 19 | $this->testPref = 'http://www.w3.org/2009/sparql/docs/tests/data-sparql11/drop/manifest#'; 20 | } 21 | 22 | /** 23 | * Helper function to get test query for a given test. 24 | * 25 | * @param string $testUri 26 | * 27 | * @return string query to test 28 | */ 29 | protected function getTestQuery($testUri) 30 | { 31 | /* 32 | example: 33 | 34 | :group1 mf:action [ 35 | qt:query 36 | ] 37 | */ 38 | $query = $this->store->query(' 39 | PREFIX mf: . 40 | PREFIX ut: . 41 | SELECT * FROM <'.$this->manifestGraphUri.'> WHERE { 42 | <'.$testUri.'> mf:action [ ut:request ?queryFile ] . 43 | } 44 | '); 45 | 46 | return $query['result']['rows'][0]['queryFile']; 47 | } 48 | 49 | /* 50 | * tests 51 | */ 52 | 53 | // this test is not part of the W3C test collection 54 | // it tests DELETE FROM <...> command which is the ARC2 equivalent to DROP GRAPH <...> 55 | public function testDeleteGraph() 56 | { 57 | $graphUri = 'http://example.org/g1'; 58 | 59 | $this->store->query('INSERT INTO <'.$graphUri.'> { 60 | "G1" ; 61 | "Graph 1" . 62 | }'); 63 | 64 | // check if graph really contains data 65 | $res = $this->store->query('SELECT * WHERE {?s ?p ?o.}'); 66 | $this->assertTrue(0 < \count($res['result']['rows']), 'No test data in graph found.'); 67 | 68 | // run test query 69 | $res = $this->store->query('DELETE FROM <'.$graphUri.'>'); 70 | 71 | // check if test data are still available 72 | $res = $this->store->query('SELECT * FROM <'.$graphUri.'> WHERE {?s ?p ?o.}'); 73 | $this->assertTrue(0 == \count($res['result']['rows'])); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-avg-01.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT (AVG(?o) AS ?avg) 3 | WHERE { 4 | ?s :dec ?o 5 | } 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-avg-01.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2.22 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-avg-02.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT ?s (AVG(?o) AS ?avg) 3 | WHERE { 4 | ?s ?p ?o 5 | } 6 | GROUP BY ?s 7 | HAVING (AVG(?o) <= 2.0) 8 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-avg-02.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/mixed1 11 | 12 | 13 | 1.6 14 | 15 | 16 | 17 | 18 | http://www.example.org/mixed2 19 | 20 | 21 | 2.0E-1 22 | 23 | 24 | 25 | 26 | http://www.example.org/ints 27 | 28 | 29 | 2.0 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-empty-group.rq: -------------------------------------------------------------------------------- 1 | PREFIX ex: 2 | SELECT ?x (MAX(?value) AS ?max) 3 | WHERE { 4 | ?x ex:p ?value 5 | } GROUP BY ?x 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-empty-group.srx: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-err-01.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT ?g (AVG(?p) AS ?avg) ((MIN(?p) + MAX(?p)) / 2 AS ?c) 3 | WHERE { 4 | ?g :p ?p . 5 | } 6 | GROUP BY ?g 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-err-01.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://example.com/data/#x 11 | 2.5 12 | 2.5 13 | 14 | 15 | http://example.com/data/#y 16 | 17 | 18 | http://example.com/data/#z 19 | 2.5 20 | 2.5 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-err-01.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :x :p 1, 2, 3, 4 . 4 | :y :p 1, _:b2, 3, 4 . 5 | :z :p 1.0, 2.0, 3.0, 4 . 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-err-02.rq: -------------------------------------------------------------------------------- 1 | PREFIX xsd: 2 | PREFIX : 3 | SELECT ?g 4 | (AVG(IF(isNumeric(?p), ?p, COALESCE(xsd:double(?p),0))) AS ?avg) 5 | WHERE { 6 | ?g :p ?p . 7 | } 8 | GROUP BY ?g 9 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-err-02.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://example.com/data/#x 11 | 12 | 13 | 2.5E0 14 | 15 | 16 | 17 | 18 | http://example.com/data/#y 19 | 20 | 21 | 2.0 22 | 23 | 24 | 25 | 26 | http://example.com/data/#z 27 | 28 | 29 | 2.5E0 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-err-02.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :x :p 1, "2", 3, 4 . 4 | :y :p 1, _:b2, 3, 4 . 5 | :z :p 2.5E0, "not a double" , 3.5, 4 . 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-groupconcat-1.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | ASK { 3 | {SELECT (GROUP_CONCAT(?o) AS ?g) WHERE { 4 | [] :p1 ?o 5 | }} 6 | FILTER(?g = "1 22" || ?g = "22 1") 7 | } 8 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-groupconcat-1.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-groupconcat-1.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s :p1 "1", "22" . 4 | :s :p2 "aaa", "bb", "c" . 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-groupconcat-2.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT (COUNT(*) AS ?c) { 3 | {SELECT ?p (GROUP_CONCAT(?o) AS ?g) WHERE { 4 | [] ?p ?o 5 | } GROUP BY ?p} 6 | FILTER( 7 | (?p = :p1 && (?g = "1 22" || ?g = "22 1")) 8 | || (?p = :p2 && (?g = "aaa bb c" || ?g = "aaa c bb" || ?g = "bb aaa c" || ?g = "bb c aaa" || ?g = "c aaa bb" || ?g = "c bb aaa")) 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-groupconcat-2.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-groupconcat-3.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | ASK { 3 | {SELECT (GROUP_CONCAT(?o;SEPARATOR=":") AS ?g) WHERE { 4 | [] :p1 ?o 5 | }} 6 | FILTER(?g = "1:22" || ?g = "22:1") 7 | } 8 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-groupconcat-3.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-max-01.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT (MAX(?o) AS ?max) 3 | WHERE { 4 | ?s ?p ?o 5 | } 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-max-01.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3.0E4 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-max-02.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT ?s (MAX(?o) AS ?max) 3 | WHERE { 4 | ?s ?p ?o 5 | } 6 | GROUP BY ?s 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-max-02.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/ints 11 | 12 | 13 | 3 14 | 15 | 16 | 17 | 18 | http://www.example.org/decimals 19 | 20 | 21 | 3.5 22 | 23 | 24 | 25 | 26 | http://www.example.org/doubles 27 | 28 | 29 | 3.0E4 30 | 31 | 32 | 33 | 34 | http://www.example.org/mixed1 35 | 36 | 37 | 2.2 38 | 39 | 40 | 41 | 42 | http://www.example.org/mixed2 43 | 44 | 45 | 2.2 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-min-01.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT (MIN(?o) AS ?min) 3 | WHERE { 4 | ?s :dec ?o 5 | } 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-min-01.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1.0 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-min-02.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT ?s (MIN(?o) AS ?min) 3 | WHERE { 4 | ?s ?p ?o 5 | } 6 | GROUP BY ?s 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-min-02.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/ints 11 | 12 | 13 | 1 14 | 15 | 16 | 17 | 18 | http://www.example.org/decimals 19 | 20 | 21 | 1.0 22 | 23 | 24 | 25 | 26 | http://www.example.org/doubles 27 | 28 | 29 | 1.0E2 30 | 31 | 32 | 33 | 34 | http://www.example.org/mixed1 35 | 36 | 37 | 1 38 | 39 | 40 | 41 | 42 | http://www.example.org/mixed2 43 | 44 | 45 | 2.0E-1 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-numeric.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix xsd: . 3 | 4 | :ints :int 1, 2, 3 . 5 | :decimals :dec 1.0, 2.2, 3.5 . 6 | :doubles :double 1.0E2, 2.0E3, 3.0E4 . 7 | :mixed1 :int 1 ; :dec 2.2 . 8 | :mixed2 :double 2E-1 ; :dec 2.2 . 9 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-numeric2.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix xsd: . 3 | 4 | :ints :int 1, 2, 3 . 5 | :decimals :dec 1.0, 2.2, 3.5 . 6 | :doubles :double 1.0E2, 2.0E3, 3.0E4 . 7 | :mixed1 :int 1 ; :dec 2.2 . 8 | :mixed2 :double 2E-1 ; :dec 0.2 . 9 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-sample-01.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | ASK { 3 | { 4 | SELECT (SAMPLE(?o) AS ?sample) 5 | WHERE { 6 | ?s :dec ?o 7 | } 8 | } 9 | FILTER(?sample = 1.0 || ?sample = 2.2 || ?sample = 3.5) 10 | } 11 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-sample-01.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-sum-01.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT (SUM(?o) AS ?sum) 3 | WHERE { 4 | ?s :dec ?o 5 | } 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-sum-01.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11.1 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-sum-02.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | SELECT ?s (SUM(?o) AS ?sum) 3 | WHERE { 4 | ?s ?p ?o 5 | } 6 | GROUP BY ?s 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg-sum-02.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/ints 11 | 12 | 13 | 6 14 | 15 | 16 | 17 | 18 | http://www.example.org/decimals 19 | 20 | 21 | 6.7 22 | 23 | 24 | 25 | 26 | http://www.example.org/doubles 27 | 28 | 29 | 3.21E4 30 | 31 | 32 | 33 | 34 | http://www.example.org/mixed1 35 | 36 | 37 | 3.2 38 | 39 | 40 | 41 | 42 | http://www.example.org/mixed2 43 | 44 | 45 | 4.0E-1 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg01.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT (COUNT(?O) AS ?C) 4 | WHERE { ?S ?P ?O } 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg01.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 5 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg01.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s :p1 :o1, :o2, :o3. 4 | :s :p2 :o1, :o2. 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg02.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ?P (COUNT(?O) AS ?C) 4 | WHERE { ?S ?P ?O } 5 | GROUP BY ?P 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg02.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/p1 11 | 12 | 13 | 3 14 | 15 | 16 | 17 | 18 | http://www.example.org/p2 19 | 20 | 21 | 2 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg03.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ?P (COUNT(?O) AS ?C) 4 | WHERE { ?S ?P ?O } 5 | GROUP BY ?P 6 | HAVING (COUNT(?O) > 2 ) 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg03.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/p1 11 | 12 | 13 | 3 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg04.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT (COUNT(*) AS ?C) 4 | WHERE { ?S ?P ?O } 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg04.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 5 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg05.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ?P (COUNT(*) AS ?C) 4 | WHERE { ?S ?P ?O } 5 | GROUP BY ?P 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg05.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/p1 11 | 12 | 13 | 3 14 | 15 | 16 | 17 | 18 | http://www.example.org/p2 19 | 20 | 21 | 2 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg06.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT (COUNT(*) AS ?C) 4 | WHERE { ?S ?P ?O } 5 | HAVING (COUNT(*) > 0 ) 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg06.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 5 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg07.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ?P (COUNT(*) AS ?C) 4 | WHERE { ?S ?P ?O } 5 | GROUP BY ?P 6 | HAVING ( COUNT(*) > 2 ) 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg07.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/p1 11 | 12 | 13 | 3 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg08.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ((?O1 + ?O2) AS ?O12) (COUNT(?O1) AS ?C) 4 | WHERE { ?S :p ?O1; :q ?O2 } GROUP BY (?O1 + ?O2) 5 | ORDER BY ?O12 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg08.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s :p 0,1,2 . 4 | :s :q 0,1,2 . 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg08b.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ?O12 (COUNT(?O1) AS ?C) 4 | WHERE { ?S :p ?O1; :q ?O2 } GROUP BY ((?O1 + ?O2) AS ?O12) 5 | ORDER BY ?O12 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg08b.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 0 11 | 12 | 13 | 1 14 | 15 | 16 | 17 | 18 | 1 19 | 20 | 21 | 2 22 | 23 | 24 | 25 | 26 | 2 27 | 28 | 29 | 3 30 | 31 | 32 | 33 | 34 | 3 35 | 36 | 37 | 2 38 | 39 | 40 | 41 | 42 | 4 43 | 44 | 45 | 1 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg09.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ?P (COUNT(?O) AS ?C) 4 | WHERE { ?S ?P ?O } GROUP BY ?S 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg10.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ?P (COUNT(?O) AS ?C) 4 | WHERE { ?S ?P ?O } 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg11.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ((?O1 + ?O2) AS ?O12) (COUNT(?O1) AS ?C) 4 | WHERE { ?S :p ?O1; :q ?O2 } GROUP BY (?S) 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/agg12.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | SELECT ?O1 (COUNT(?O2) AS ?C) 4 | WHERE { ?S :p ?O1; :q ?O2 } GROUP BY (?O1 + ?O2) 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/aggregates/empty.ttl: -------------------------------------------------------------------------------- 1 | @prefix ex: . 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere01.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | CONSTRUCT WHERE { ?s ?p ?o} -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere01result.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s2 :p :o1 ; 4 | :p :o2 . 5 | 6 | :s1 :p :o1 . 7 | 8 | :s3 :p :o3 . 9 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere02.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | CONSTRUCT WHERE { :s1 :p ?o . ?s2 :p ?o } -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere02result.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s2 :p :o1 . 4 | 5 | :s1 :p :o1 . 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere03.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | CONSTRUCT WHERE { :s2 :p ?o1, ?o2 } -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere03result.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s2 :p :o1 ; 4 | :p :o2 . 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere04.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | CONSTRUCT 4 | FROM 5 | WHERE { ?s ?p ?o } -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere04result.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s2 :p :o1 ; 4 | :p :o2 . 5 | 6 | :s1 :p :o1 . 7 | 8 | :s3 :p :o3 . 9 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere05.rq: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | CONSTRUCT 4 | WHERE { ?s ?p ?o FILTER ( ?o = :o1) } -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/constructwhere06.rq: -------------------------------------------------------------------------------- 1 | CONSTRUCT 2 | WHERE { GRAPH { ?s ?p ?o } } -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/data.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s1 :p :o1 . 4 | :s2 :p :o1 . 5 | :s2 :p :o2 . 6 | :s3 :p :o3 . 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/construct/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix : . 3 | @prefix rdfs: . 4 | @prefix mf: . 5 | @prefix qt: . 6 | @prefix dawgt: . 7 | 8 | <> rdf:type mf:Manifest ; 9 | rdfs:label "CONSTRUCT" ; 10 | mf:entries 11 | ( 12 | :constructwhere01 13 | :constructwhere02 14 | :constructwhere03 15 | :constructwhere04 16 | :constructwhere05 17 | :constructwhere06 18 | ) . 19 | 20 | :constructwhere01 rdf:type mf:QueryEvaluationTest ; 21 | mf:name "constructwhere01 - CONSTRUCT WHERE" ; 22 | rdfs:comment "CONSTRUCT WHERE { ?S ?P ?O }"; 23 | dawgt:approval dawgt:Approved ; 24 | dawgt:approvedBy ; 25 | mf:action 26 | [ qt:query ; 27 | qt:data ] ; 28 | mf:result 29 | . 30 | 31 | :constructwhere02 rdf:type mf:QueryEvaluationTest ; 32 | mf:name "constructwhere02 - CONSTRUCT WHERE" ; 33 | rdfs:comment "CONSTRUCT WHERE with join"; 34 | dawgt:approval dawgt:Approved ; 35 | dawgt:approvedBy ; 36 | mf:action 37 | [ qt:query ; 38 | qt:data ] ; 39 | mf:result 40 | . 41 | 42 | :constructwhere03 rdf:type mf:QueryEvaluationTest ; 43 | mf:name "constructwhere03 - CONSTRUCT WHERE" ; 44 | rdfs:comment "CONSTRUCT WHERE with join, using shortcut notation"; 45 | dawgt:approval dawgt:Approved ; 46 | dawgt:approvedBy ; 47 | mf:action 48 | [ qt:query ; 49 | qt:data ] ; 50 | mf:result 51 | . 52 | :constructwhere04 rdf:type mf:QueryEvaluationTest ; 53 | mf:name "constructwhere04 - CONSTRUCT WHERE" ; 54 | rdfs:comment "CONSTRUCT WHERE with DatasetClause"; 55 | dawgt:approval dawgt:Approved ; 56 | dawgt:approvedBy ; 57 | mf:action 58 | [ qt:query ] ; 59 | mf:result 60 | . 61 | 62 | :constructwhere05 rdf:type mf:NegativeSyntaxTest11 ; 63 | mf:name "constructwhere05 - CONSTRUCT WHERE" ; 64 | rdfs:comment "CONSTRUCT WHERE with FILTER"; 65 | dawgt:approval dawgt:Approved ; 66 | dawgt:approvedBy ; 67 | mf:action . 68 | 69 | :constructwhere06 rdf:type mf:NegativeSyntaxTest11 ; 70 | mf:name "constructwhere06 - CONSTRUCT WHERE" ; 71 | mf:description "CONSTRUCT WHERE with GRAPH"; 72 | dawgt:approval dawgt:Approved ; 73 | dawgt:approvedBy ; 74 | mf:action . 75 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-01.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | ?s ?p ?o . 7 | } 8 | WHERE 9 | { 10 | :a foaf:knows ?s . 11 | ?s ?p ?o 12 | } 13 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-02.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | GRAPH { ?s ?p ?o } 7 | } 8 | WHERE 9 | { 10 | GRAPH { :a foaf:knows ?s . 11 | ?s ?p ?o } 12 | } 13 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-03.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | ?s ?p ?o . 7 | } 8 | WHERE 9 | { 10 | ?s foaf:knows :c . 11 | ?s ?p ?o 12 | } 13 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-04.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | GRAPH { ?s ?p ?o } 7 | } 8 | WHERE 9 | { 10 | GRAPH { ?s foaf:knows :c . 11 | ?s ?p ?o } 12 | } 13 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-05.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | ?s ?p ?o . 7 | } 8 | WHERE 9 | { 10 | :a foaf:knows ?s . 11 | ?s ?p ?o 12 | } 13 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-06.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | GRAPH { ?s ?p ?o } 7 | } 8 | WHERE 9 | { 10 | GRAPH { ?s foaf:name "Chris" . 11 | ?s ?p ?o } 12 | } 13 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-07.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | ?s ?p ?o . 7 | } 8 | WHERE 9 | { 10 | :a foaf:knows ?s . 11 | } 12 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-post-01f.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :a foaf:name "Alan" . 5 | :a foaf:mbox "alan@example.org" . 6 | :b foaf:name "Bob" . 7 | :b foaf:mbox "bob@example.org" . 8 | :a foaf:knows :b . 9 | 10 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-post-01s.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :a foaf:name "Alan" . 5 | :a foaf:mbox "alan@example.org" . 6 | :a foaf:knows :b . 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-post-01s2.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :b foaf:name "Bob" . 5 | :b foaf:mbox "bob@example.org" . 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-post-02f.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :a foaf:knows :b . 5 | :b foaf:name "Bob" . 6 | :b foaf:mbox "bob@example.org" . 7 | :c foaf:name "Chris" . 8 | :c foaf:mbox "chris@example.org" . 9 | :b foaf:knows :c . 10 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-post-02s.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :a foaf:knows :b . 5 | :b foaf:name "Bob" . 6 | :b foaf:mbox "bob@example.org" . 7 | :b foaf:knows :c . 8 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-post-03f.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :c foaf:name "Chris" . 5 | :c foaf:mbox "chris@example.org" . 6 | :d foaf:name "Dan" . 7 | :d foaf:mbox "dan@example.org" . 8 | :c foaf:knows :d . 9 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-pre-01.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :a foaf:name "Alan" . 5 | :a foaf:mbox "alan@example.org" . 6 | :b foaf:name "Bob" . 7 | :b foaf:mbox "bob@example.org" . 8 | :a foaf:knows :b . 9 | 10 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-pre-02.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :a foaf:knows :b . 5 | :b foaf:name "Bob" . 6 | :b foaf:mbox "bob@example.org" . 7 | :c foaf:name "Chris" . 8 | :c foaf:mbox "chris@example.org" . 9 | :b foaf:knows :c . 10 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-pre-03.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix foaf: . 3 | 4 | :c foaf:name "Chris" . 5 | :c foaf:mbox "chris@example.org" . 6 | :d foaf:name "Dan" . 7 | :d foaf:mbox "dan@example.org" . 8 | :c foaf:knows :d . 9 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-using-01.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | ?s ?p ?o . 7 | } 8 | USING 9 | WHERE 10 | { 11 | :a foaf:knows ?s . 12 | ?s ?p ?o 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-using-02.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | ?s ?p ?o . 7 | } 8 | USING 9 | WHERE 10 | { 11 | GRAPH { :a foaf:knows ?s . 12 | ?s ?p ?o } 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-using-03.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | ?s ?p ?o . 7 | } 8 | USING 9 | WHERE 10 | { 11 | ?s foaf:knows :d . 12 | ?s ?p ?o 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-using-04.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | ?s ?p ?o . 7 | } 8 | USING 9 | WHERE 10 | { 11 | GRAPH { ?s foaf:knows :d . 12 | ?s ?p ?o } 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-using-05.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | GRAPH { ?s ?p ?o } 7 | } 8 | USING 9 | WHERE 10 | { 11 | ?s foaf:knows :b . 12 | ?s ?p ?o 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-using-06.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | DELETE 5 | { 6 | GRAPH { ?s ?p ?o } 7 | } 8 | USING 9 | WHERE 10 | { 11 | GRAPH { ?s foaf:name "Chris" . 12 | ?s ?p ?o } 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-with-01.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | WITH 5 | DELETE 6 | { 7 | ?s ?p ?o . 8 | } 9 | WHERE 10 | { 11 | :a foaf:knows ?s . 12 | ?s ?p ?o 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-with-02.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | WITH 5 | DELETE 6 | { 7 | GRAPH { ?s ?p ?o } 8 | } 9 | WHERE 10 | { 11 | GRAPH { :a foaf:knows ?s . 12 | ?s ?p ?o } 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-with-03.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | WITH 5 | DELETE 6 | { 7 | ?s ?p ?o . 8 | } 9 | WHERE 10 | { 11 | ?s foaf:knows :c . 12 | ?s ?p ?o 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-with-04.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | WITH 5 | DELETE 6 | { 7 | GRAPH { ?s ?p ?o } 8 | } 9 | WHERE 10 | { 11 | GRAPH { ?s foaf:knows :c . 12 | ?s ?p ?o } 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-with-05.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | WITH 5 | DELETE 6 | { 7 | ?s ?p ?o . 8 | } 9 | WHERE 10 | { 11 | ?s foaf:knows :b . 12 | ?s ?p ?o 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/delete/delete-with-06.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX foaf: 3 | 4 | WITH 5 | DELETE 6 | { 7 | GRAPH { ?s ?p ?o } 8 | } 9 | WHERE 10 | { 11 | GRAPH { ?s foaf:name "Chris" . 12 | ?s ?p ?o } 13 | } 14 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/drop/drop-all-01.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | DROP ALL 4 | 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/drop/drop-default-01.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | DROP DEFAULT 4 | 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/drop/drop-default.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | <> :name "Default Graph" . 4 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/drop/drop-g1.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :g1 :name "G1" ; 4 | :description "Graph 1" ; 5 | . 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/drop/drop-g2.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :g2 :name "G2" ; 4 | . 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/drop/drop-graph-01.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | DROP GRAPH :g1 4 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/drop/drop-named-01.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | DROP NAMED 4 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists01.rq: -------------------------------------------------------------------------------- 1 | prefix ex: 2 | 3 | select * where { 4 | ?s ?p ?o 5 | filter exists {?s ?p ex:o} 6 | } 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists01.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | http://www.example.org/s 11 | http://www.example.org/o 12 | http://www.example.org/p 13 | 14 | 15 | http://www.example.org/s 16 | http://www.example.org/o1 17 | http://www.example.org/p 18 | 19 | 20 | http://www.example.org/s 21 | http://www.example.org/o2 22 | http://www.example.org/p 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists01.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :s :p :o, :o1, :o2. 4 | :t :p :o1, :o2. 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists02.rq: -------------------------------------------------------------------------------- 1 | prefix ex: 2 | 3 | select * where { 4 | ?s ?p ex:o2 5 | filter exists {ex:s ex:p ex:o} 6 | } 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists02.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | http://www.example.org/s 10 | http://www.example.org/p 11 | 12 | 13 | http://www.example.org/t 14 | http://www.example.org/p 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists02.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :a :p :o1. 4 | :b :p :o1, :o2. 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists03.rq: -------------------------------------------------------------------------------- 1 | prefix ex: 2 | 3 | select * where { 4 | graph { 5 | ?s ?p ex:o1 6 | filter exists { ?s ?p ex:o2 } 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists03.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | http://www.example.org/b 10 | http://www.example.org/p 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists04.rq: -------------------------------------------------------------------------------- 1 | prefix ex: 2 | 3 | select * where { 4 | ?s ?p ex:o 5 | filter exists { ?s ?p ex:o1 filter exists { ?s ?p ex:o2 } } 6 | } 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists04.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | http://www.example.org/s 10 | http://www.example.org/p 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists05.rq: -------------------------------------------------------------------------------- 1 | prefix ex: 2 | 3 | select * where { 4 | ?s ?p ex:o 5 | filter exists { ?s ?p ex:o1 filter not exists { ?s ?p ex:o2 } } 6 | } 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/exists05.srx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/exists/manifest.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix : . 3 | @prefix rdfs: . 4 | @prefix mf: . 5 | @prefix qt: . 6 | @prefix dawgt: . 7 | @prefix sparql: . 8 | 9 | <> rdf:type mf:Manifest ; 10 | rdfs:label "Positive Exists" ; 11 | mf:entries 12 | ( 13 | :exists01 14 | :exists02 15 | :exists03 16 | :exists04 17 | :exists05 18 | ). 19 | 20 | 21 | :exists01 rdf:type mf:QueryEvaluationTest ; 22 | mf:name "Exists with one constant"; 23 | mf:feature sparql:exists ; 24 | dawgt:approval dawgt:Approved; 25 | dawgt:approvedBy ; 26 | mf:action 27 | [ qt:query ; 28 | qt:data ] ; 29 | mf:result 30 | . 31 | 32 | 33 | :exists02 rdf:type mf:QueryEvaluationTest ; 34 | mf:name "Exists with ground triple"; 35 | mf:feature sparql:exists ; 36 | dawgt:approval dawgt:Approved; 37 | dawgt:approvedBy ; 38 | mf:action 39 | [ qt:query ; 40 | qt:data ] ; 41 | mf:result 42 | . 43 | 44 | :exists03 rdf:type mf:QueryEvaluationTest ; 45 | mf:name "Exists within graph pattern"; 46 | mf:feature sparql:exists ; 47 | rdfs:comment "Checks that exists is interpreted within named graph" ; 48 | dawgt:approval dawgt:Approved; 49 | dawgt:approvedBy ; 50 | mf:action 51 | [ qt:query ; 52 | qt:data ; 53 | qt:graphData 54 | ] ; 55 | mf:result 56 | . 57 | 58 | 59 | :exists04 rdf:type mf:QueryEvaluationTest ; 60 | mf:name "Nested positive exists"; 61 | mf:feature sparql:exists ; 62 | dawgt:approval dawgt:Approved; 63 | dawgt:approvedBy ; 64 | mf:action 65 | [ qt:query ; 66 | qt:data ; 67 | ] ; 68 | mf:result 69 | . 70 | 71 | :exists05 rdf:type mf:QueryEvaluationTest ; 72 | mf:name "Nested negative exists in positive exists"; 73 | mf:feature sparql:exists ; 74 | dawgt:approval dawgt:Approved; 75 | dawgt:approvedBy ; 76 | mf:action 77 | [ qt:query ; 78 | qt:data ; 79 | ] ; 80 | mf:result 81 | . 82 | 83 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/move/move-01.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | MOVE DEFAULT TO :g1 -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/move/move-01.ttl: -------------------------------------------------------------------------------- 1 | @prefix foaf: . 2 | @prefix : . 3 | 4 | :jerry a foaf:Person . 5 | :jerry foaf:givenName "Jerry" . 6 | :jerry foaf:mbox . -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/move/move-02.ttl: -------------------------------------------------------------------------------- 1 | @prefix foaf: . 2 | @prefix : . 3 | 4 | :mickey a foaf:Person . 5 | :mickey foaf:givenName "Mickey" . 6 | :mickey foaf:mbox . -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/move/move-03.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | MOVE :g1 TO :g2 -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/move/move-06.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | MOVE :g1 TO DEFAULT -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/move/move-07.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | MOVE :g1 TO :g1 -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/move/move-default.ttl: -------------------------------------------------------------------------------- 1 | @prefix foaf: . 2 | @prefix : . 3 | 4 | :tom a foaf:Person . 5 | :tom foaf:givenName "Tom" . 6 | :tom foaf:mbox . -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-01.ru: -------------------------------------------------------------------------------- 1 | BASE 2 | PREFIX : 3 | LOAD 4 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-02.ru: -------------------------------------------------------------------------------- 1 | # Comment 2 | BASE 3 | # Comment 4 | PREFIX : 5 | # Comment 6 | LOAD 7 | # Comment 8 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-03.ru: -------------------------------------------------------------------------------- 1 | LOAD ; 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-04.ru: -------------------------------------------------------------------------------- 1 | LOAD INTO GRAPH 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-05.ru: -------------------------------------------------------------------------------- 1 | DROP NAMED 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-06.ru: -------------------------------------------------------------------------------- 1 | DROP DEFAULT 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-07.ru: -------------------------------------------------------------------------------- 1 | DROP ALL 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-08.ru: -------------------------------------------------------------------------------- 1 | DROP GRAPH 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-09.ru: -------------------------------------------------------------------------------- 1 | DROP SILENT NAMED 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-10.ru: -------------------------------------------------------------------------------- 1 | DROP SILENT DEFAULT 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-11.ru: -------------------------------------------------------------------------------- 1 | DROP SILENT ALL 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-12.ru: -------------------------------------------------------------------------------- 1 | DROP SILENT GRAPH 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-13.ru: -------------------------------------------------------------------------------- 1 | CREATE GRAPH 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-14.ru: -------------------------------------------------------------------------------- 1 | CREATE SILENT GRAPH 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-15.ru: -------------------------------------------------------------------------------- 1 | CLEAR NAMED 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-16.ru: -------------------------------------------------------------------------------- 1 | CLEAR DEFAULT 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-17.ru: -------------------------------------------------------------------------------- 1 | CLEAR ALL 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-18.ru: -------------------------------------------------------------------------------- 1 | CLEAR GRAPH 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-19.ru: -------------------------------------------------------------------------------- 1 | CLEAR SILENT NAMED 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-20.ru: -------------------------------------------------------------------------------- 1 | CLEAR SILENT DEFAULT 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-21.ru: -------------------------------------------------------------------------------- 1 | CLEAR SILENT ALL 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-22.ru: -------------------------------------------------------------------------------- 1 | CLEAR SILENT GRAPH 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-23.ru: -------------------------------------------------------------------------------- 1 | INSERT DATA {

'o1', 'o2', 'o3' } 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-24.ru: -------------------------------------------------------------------------------- 1 | INSERT DATA { GRAPH {

'o1', 'o2', 'o3' } } 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-25.ru: -------------------------------------------------------------------------------- 1 | INSERT DATA { 2 | 3 | GRAPH { 'o1'; } 4 | GRAPH { 'o1'; } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-26.ru: -------------------------------------------------------------------------------- 1 | INSERT 2 | # Comment 3 | DATA { GRAPH {

'o1', 'o2', 'o3' } } 4 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-27.ru: -------------------------------------------------------------------------------- 1 | INSERT 2 | DATA { } 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-28.ru: -------------------------------------------------------------------------------- 1 | INSERT 2 | DATA { GRAPH {} } 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-29.ru: -------------------------------------------------------------------------------- 1 | DELETE DATA {

'o1', 'o2', 'o3' } 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-30.ru: -------------------------------------------------------------------------------- 1 | DELETE DATA { GRAPH {

'o1', 'o2', 'o3' } } 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-31.ru: -------------------------------------------------------------------------------- 1 | DELETE DATA { 2 | 3 | GRAPH { 'o1'; } 4 | GRAPH { 'o1'; } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-32.ru: -------------------------------------------------------------------------------- 1 | BASE 2 | PREFIX : 3 | 4 | WITH :g 5 | DELETE { 6 | ?p ?o . 7 | } 8 | INSERT { 9 | ?s ?p <#o> . 10 | } 11 | USING 12 | USING 13 | USING NAMED :gn1 14 | USING NAMED :gn2 15 | WHERE 16 | { ?s ?p ?o } 17 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-33.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | WITH :g 3 | DELETE { 4 | ?p ?o . 5 | } 6 | WHERE 7 | { ?s ?p ?o } 8 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-34.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | WITH :g 3 | INSERT { 4 | ?p ?o . 5 | } 6 | WHERE 7 | { ?s ?p ?o } 8 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-35.ru: -------------------------------------------------------------------------------- 1 | DELETE WHERE { ?s ?p ?o } 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-36.ru: -------------------------------------------------------------------------------- 1 | # Comment 2 | DELETE 3 | # Comment 4 | WHERE 5 | # Comment 6 | { GRAPH {

123 ; 4567.0 . } } 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-37.ru: -------------------------------------------------------------------------------- 1 | CREATE GRAPH ; 2 | LOAD INTO GRAPH ; 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-38.ru: -------------------------------------------------------------------------------- 1 | # Empty 2 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-39.ru: -------------------------------------------------------------------------------- 1 | BASE 2 | # Otherwise empty 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-40.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | # Otherwise empty 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-53.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | INSERT DATA { 4 | GRAPH { _:b1 :p :o } 5 | GRAPH { _:b1 :p :o } 6 | } 7 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-54.ru: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | INSERT DATA { _:b1 :p :o } 4 | ; 5 | INSERT DATA { _:b1 :p :o } 6 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-01.ru: -------------------------------------------------------------------------------- 1 | # No URL 2 | LOAD ; 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-02.ru: -------------------------------------------------------------------------------- 1 | # Typo in keyword. 2 | CREATE DEAFULT 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-03.ru: -------------------------------------------------------------------------------- 1 | # Variable in data. 2 | DELETE DATA { ?s

} 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-04.ru: -------------------------------------------------------------------------------- 1 | # Variable in data. 2 | INSERT DATA { GRAPH ?g {

} } 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-05.ru: -------------------------------------------------------------------------------- 1 | # Nested GRAPH 2 | DELETE DATA { 3 | GRAPH { 4 |

. 5 | GRAPH { 'o1' } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-06.ru: -------------------------------------------------------------------------------- 1 | # Missing template 2 | INSERT WHERE { ?s ?p ?o } 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-07.ru: -------------------------------------------------------------------------------- 1 | # No separator 2 | CREATE GRAPH 3 | LOAD INTO GRAPH 4 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-08.ru: -------------------------------------------------------------------------------- 1 | # Too many separators 2 | CREATE GRAPH 3 | ;; 4 | LOAD INTO GRAPH 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-09.ru: -------------------------------------------------------------------------------- 1 | CREATE GRAPH 2 | ; 3 | LOAD INTO GRAPH 4 | ;; 5 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-10.ru: -------------------------------------------------------------------------------- 1 | # BNode in DELETE WHERE 2 | DELETE WHERE { _:a

} 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-11.ru: -------------------------------------------------------------------------------- 1 | # BNode in DELETE template 2 | DELETE {

[] } WHERE { ?x

} 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/sparql_1_1_tests/w3c-tests/syntax-update-1/syntax-update-bad-12.ru: -------------------------------------------------------------------------------- 1 | # BNode in DELETE DATA 2 | DELETE DATA { _:a

} 3 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/store/ARC2_StoreAskQueryHandlerTest.php: -------------------------------------------------------------------------------- 1 | store = \ARC2::getStore($this->dbConfig); 16 | $this->store->drop(); 17 | $this->store->setup(); 18 | 19 | $this->fixture = new \ARC2_StoreAskQueryHandler($this->store->a, $this->store); 20 | } 21 | 22 | protected function tearDown(): void 23 | { 24 | $this->store->closeDBCon(); 25 | } 26 | 27 | /* 28 | * Tests for __init 29 | */ 30 | 31 | public function testInit() 32 | { 33 | $this->fixture = new \ARC2_StoreAskQueryHandler($this->store->a, $this->store); 34 | $this->fixture->__init(); 35 | $this->assertEquals($this->store, $this->fixture->store); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/store/ARC2_StoreInsertQueryHandlerTest.php: -------------------------------------------------------------------------------- 1 | store = \ARC2::getStore($this->dbConfig); 16 | $this->store->drop(); 17 | $this->store->setup(); 18 | 19 | $this->fixture = new \ARC2_StoreInsertQueryHandler($this->store->a, $this->store); 20 | } 21 | 22 | protected function tearDown(): void 23 | { 24 | $this->store->closeDBCon(); 25 | } 26 | 27 | /* 28 | * Tests for __init 29 | */ 30 | 31 | public function testInit() 32 | { 33 | $this->fixture = new \ARC2_StoreInsertQueryHandler($this->store->a, $this->store); 34 | $this->fixture->__init(); 35 | $this->assertEquals($this->store, $this->fixture->store); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/store/ARC2_StoreLoadQueryHandlerTest.php: -------------------------------------------------------------------------------- 1 | store = \ARC2::getStore($this->dbConfig); 16 | $this->store->createDBCon(); 17 | 18 | // remove all tables 19 | $this->store->getDBObject()->deleteAllTables(); 20 | $this->store->setUp(); 21 | 22 | $this->fixture = new \ARC2_StoreLoadQueryHandler($this->store, $this); 23 | } 24 | 25 | protected function tearDown(): void 26 | { 27 | $this->store->closeDBCon(); 28 | } 29 | 30 | /** 31 | * Tests behavior, if has to extend columns. 32 | */ 33 | public function testExtendColumns(): void 34 | { 35 | $this->fixture->setStore($this->store); 36 | $this->fixture->column_type = 'mediumint'; 37 | $this->fixture->max_term_id = 16750001; 38 | 39 | $this->assertEquals(16750001, $this->fixture->getStoredTermID('', '', '')); 40 | 41 | // MySQL 42 | $table_fields = $this->store->getDBObject()->fetchList('DESCRIBE arc_g2t'); 43 | $this->assertStringContainsString('int', $table_fields[0]['Type']); 44 | $this->assertStringContainsString('unsigned', $table_fields[0]['Type']); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/store/query/AskQueryTest.php: -------------------------------------------------------------------------------- 1 | fixture = \ARC2::getStore($this->dbConfig); 17 | $this->fixture->drop(); 18 | $this->fixture->setup(); 19 | } 20 | 21 | protected function tearDown(): void 22 | { 23 | $this->fixture->closeDBCon(); 24 | } 25 | 26 | public function testAskDefaultGraph() 27 | { 28 | // test data 29 | $this->fixture->query('INSERT INTO { 30 | "baz" . 31 | }'); 32 | 33 | $res = $this->fixture->query('ASK { ?o.}'); 34 | $this->assertEquals( 35 | [ 36 | 'query_type' => 'ask', 37 | 'result' => true, 38 | 'query_time' => $res['query_time'], 39 | ], 40 | $res 41 | ); 42 | } 43 | 44 | public function testAskGraphSpecified() 45 | { 46 | // test data 47 | $this->fixture->query('INSERT INTO { 48 | "baz" . 49 | }'); 50 | 51 | $res = $this->fixture->query('ASK FROM { ?o.}'); 52 | $this->assertEquals( 53 | [ 54 | 'query_type' => 'ask', 55 | 'result' => true, 56 | 'query_time' => $res['query_time'], 57 | ], 58 | $res 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/store/query/DescribeQueryTest.php: -------------------------------------------------------------------------------- 1 | fixture = \ARC2::getStore($this->dbConfig); 17 | $this->fixture->drop(); 18 | $this->fixture->setup(); 19 | } 20 | 21 | protected function tearDown(): void 22 | { 23 | $this->fixture->closeDBCon(); 24 | } 25 | 26 | public function testDescribeDefaultGraph() 27 | { 28 | // test data 29 | $this->fixture->query('INSERT INTO { 30 | "baz" . 31 | }'); 32 | 33 | $res = $this->fixture->query('DESCRIBE '); 34 | $this->assertEquals( 35 | [ 36 | 'query_type' => 'describe', 37 | 'result' => [ 38 | 'http://s' => [ 39 | 'http://p1' => [ 40 | [ 41 | 'value' => 'baz', 42 | 'type' => 'literal', 43 | ], 44 | ], 45 | ], 46 | ], 47 | 'query_time' => $res['query_time'], 48 | ], 49 | $res 50 | ); 51 | } 52 | 53 | public function testDescribeWhereDefaultGraph() 54 | { 55 | // test data 56 | $this->fixture->query('INSERT INTO { 57 | "baz" . 58 | }'); 59 | 60 | $res = $this->fixture->query('DESCRIBE ?s WHERE {?s ?p "baz".}'); 61 | $this->assertEquals( 62 | [ 63 | 'query_type' => 'describe', 64 | 'result' => [ 65 | 'http://s' => [ 66 | 'http://p1' => [ 67 | [ 68 | 'value' => 'baz', 69 | 'type' => 'literal', 70 | ], 71 | ], 72 | ], 73 | ], 74 | 'query_time' => $res['query_time'], 75 | ], 76 | $res 77 | ); 78 | } 79 | 80 | public function testDescribeWhereDefaultGraph2() 81 | { 82 | // test data 83 | $this->fixture->query('INSERT INTO { 84 | "baz" . 85 | }'); 86 | 87 | $res = $this->fixture->query('DESCRIBE * WHERE {?s ?p "baz".}'); 88 | $this->assertEquals( 89 | [ 90 | 'query_type' => 'describe', 91 | 'result' => [ 92 | 'http://s' => [ 93 | 'http://p1' => [ 94 | [ 95 | 'value' => 'baz', 96 | 'type' => 'literal', 97 | ], 98 | ], 99 | ], 100 | ], 101 | 'query_time' => $res['query_time'], 102 | ], 103 | $res 104 | ); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/store/query/ErrorHandlingInQueriesTest.php: -------------------------------------------------------------------------------- 1 | fixture = \ARC2::getStore($this->dbConfig); 17 | $this->fixture->drop(); 18 | $this->fixture->setup(); 19 | } 20 | 21 | protected function tearDown(): void 22 | { 23 | $this->fixture->closeDBCon(); 24 | } 25 | 26 | /** 27 | * What if a result variable is not used in query. 28 | */ 29 | public function testResultVariableNotUsedInQuery() 30 | { 31 | $res = $this->fixture->query(' 32 | SELECT ?not_used_in_query ?s WHERE { 33 | ?s ?p ?o . 34 | } 35 | '); 36 | 37 | $this->assertEquals( 38 | [ 39 | 'query_type' => 'select', 40 | 'result' => [ 41 | 'variables' => [ 42 | 'not_used_in_query', 's', 43 | ], 44 | 'rows' => [ 45 | ], 46 | ], 47 | 'query_time' => $res['query_time'], 48 | ], 49 | $res 50 | ); 51 | 52 | $this->assertTrue(2 <= \count($this->fixture->errors)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/db_adapter_depended/store/query/LoadQueryTest.php: -------------------------------------------------------------------------------- 1 | fixture = \ARC2::getStore($this->dbConfig); 17 | $this->fixture->drop(); 18 | $this->fixture->setup(); 19 | } 20 | 21 | protected function tearDown(): void 22 | { 23 | $this->fixture->closeDBCon(); 24 | } 25 | 26 | public function testLoad() 27 | { 28 | // check that store is empty 29 | $res = $this->fixture->query('SELECT * WHERE {?s ?p ?o.}'); 30 | $this->assertEquals(0, \count($res['result']['rows'])); 31 | 32 | $filepath = 'https://raw.githubusercontent.com/semsol/arc2/' 33 | .'master/tests/data/turtle/manifest.ttl'; 34 | $this->fixture->query('LOAD <'.$filepath.'>'); 35 | 36 | // check that triples were inserted 37 | $res = $this->fixture->query(' 38 | SELECT * 39 | FROM 41 | WHERE {?s ?p ?o.} 42 | '); 43 | $this->assertEquals(1860, \count($res['result']['rows'])); 44 | } 45 | 46 | public function testLoadInto() 47 | { 48 | // check that store is empty 49 | $res = $this->fixture->query('SELECT * FROM WHERE {?s ?p ?o.}'); 50 | $this->assertEquals(0, \count($res['result']['rows'])); 51 | 52 | $filepath = 'https://raw.githubusercontent.com/semsol/arc2/' 53 | .'master/tests/data/turtle/manifest.ttl'; 54 | $this->fixture->query('LOAD <'.$filepath.'> INTO '); 55 | 56 | // check that triples were inserted 57 | $res = $this->fixture->query('SELECT * FROM WHERE {?s ?p ?o.}'); 58 | $this->assertEquals(1860, \count($res['result']['rows'])); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /tests/integration/src/ARC2/Store/Adapter/AdapterFactoryTest.php: -------------------------------------------------------------------------------- 1 | fixture = new AdapterFactory(); 16 | } 17 | 18 | /* 19 | * Tests for getInstanceFor 20 | */ 21 | 22 | public function testGetInstanceFor() 23 | { 24 | // PDO (mysql) 25 | $instance = $this->fixture->getInstanceFor('pdo', ['db_pdo_protocol' => 'mysql']); 26 | $this->assertTrue($instance instanceof AbstractAdapter); 27 | } 28 | 29 | public function testGetInstanceForInvalidAdapterName() 30 | { 31 | $this->expectException(\Exception::class); 32 | $this->expectExceptionMessage('Unknown adapter name given. Currently supported are: pdo'); 33 | 34 | $this->fixture->getInstanceFor('invalid'); 35 | } 36 | 37 | public function testGetInstanceForInvalidPDOProtocol() 38 | { 39 | $this->expectException(\Exception::class); 40 | $this->expectExceptionMessage('Only "mysql" protocol is supported at the moment.'); 41 | 42 | $instance = $this->fixture->getInstanceFor('pdo', ['db_pdo_protocol' => 'invalid']); 43 | $this->assertFalse($instance instanceof AbstractAdapter); 44 | } 45 | 46 | /* 47 | * Tests for getSupportedAdapters 48 | */ 49 | 50 | public function testGetSupportedAdapters() 51 | { 52 | $this->assertEquals(['pdo'], $this->fixture->getSupportedAdapters()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/unit/ARC2_ClassTest.php: -------------------------------------------------------------------------------- 1 | arc2 = new ARC2_Class($array, $stdClass); 12 | } 13 | 14 | public function testCamelCase() 15 | { 16 | $this->assertSame('Fish', $this->arc2->camelCase('fish')); 17 | $this->assertSame('fish', $this->arc2->camelCase('fish', true)); 18 | $this->assertSame('fish', $this->arc2->camelCase('fish', true, true)); 19 | 20 | $this->assertSame('FishHeads', $this->arc2->camelCase('fish_heads')); 21 | $this->assertSame('fishHeads', $this->arc2->camelCase('fish_heads', true)); 22 | $this->assertSame('fishHeads', $this->arc2->camelCase('fish_heads', true, true)); 23 | 24 | $this->assertSame('ALLCAPITALS', $this->arc2->camelCase('ALL_CAPITALS')); 25 | } 26 | 27 | public function testDeCamelCase() 28 | { 29 | $this->assertSame('fish', $this->arc2->deCamelCase('fish')); 30 | $this->assertSame('Fish', $this->arc2->deCamelCase('fish', true)); 31 | 32 | $this->assertSame('fish heads', $this->arc2->deCamelCase('fish_heads')); 33 | $this->assertSame('Fish heads', $this->arc2->deCamelCase('fish_heads', true)); 34 | 35 | $this->assertSame('ALL CAPITALS', $this->arc2->deCamelCase('ALL_CAPITALS')); 36 | } 37 | 38 | public function testV() 39 | { 40 | $this->assertFalse($this->arc2->v(null)); 41 | $this->assertFalse($this->arc2->v('cats', false, [])); 42 | $this->assertTrue($this->arc2->v('cats', false, ['cats' => true])); 43 | 44 | $o = new stdClass(); 45 | $o->cats = true; 46 | $this->assertTrue($this->arc2->v('cats', false, $o)); 47 | } 48 | 49 | public function testV1() 50 | { 51 | $this->assertFalse($this->arc2->v1(null)); 52 | $this->assertFalse($this->arc2->v1('cats', false, [])); 53 | $this->assertTrue($this->arc2->v1('cats', false, ['cats' => true])); 54 | $this->assertSame('blackjack', $this->arc2->v1('cats', 'blackjack', ['cats' => null])); 55 | 56 | $o = new stdClass(); 57 | $o->cats = true; 58 | $this->assertTrue($this->arc2->v1('cats', false, $o)); 59 | 60 | $o = new stdClass(); 61 | $o->cats = 0; 62 | $this->assertSame('blackjack', $this->arc2->v1('cats', 'blackjack', $o)); 63 | } 64 | 65 | public function testExtractTermLabel() 66 | { 67 | $this->assertSame('bar', $this->arc2->extractTermLabel('http://example.com/foo#bar')); 68 | $this->assertSame('bar cats', $this->arc2->extractTermLabel('http://example.com/foo#bar?cats')); 69 | $this->assertSame('bar', $this->arc2->extractTermLabel('#bar')); 70 | $this->assertSame('bar', $this->arc2->extractTermLabel('http://example.com/bar')); 71 | $this->assertSame('bar', $this->arc2->extractTermLabel('http://example.com/bar/')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /tests/unit/ARC2_ReaderTest.php: -------------------------------------------------------------------------------- 1 | reader = \ARC2::getReader(); 16 | $this->reader->__init(); 17 | } 18 | 19 | public function testFullQualifiedURIIgnoresPreviousParts() 20 | { 21 | $parts_of_previous_uri = ['port' => 8081, 'scheme' => 'https', 'host' => 'foo.bar', 'path' => '/baz']; 22 | $uri_parts = $this->reader->getURIPartsFromURIAndPreviousURIParts('http://google.com:80/urlpath', $parts_of_previous_uri); 23 | 24 | $this->assertEquals('http', $uri_parts['scheme']); 25 | $this->assertEquals('80', $uri_parts['port']); 26 | $this->assertEquals('google.com', $uri_parts['host']); 27 | $this->assertEquals('/urlpath', $uri_parts['path']); 28 | } 29 | 30 | public function testWhenARelativeURIIsPassedSchemeHostAndPortAreInferredFromPreviousParts() 31 | { 32 | $parts_of_previous_uri = ['port' => 8081, 'scheme' => 'https', 'host' => 'foo.bar', 'path' => '/baz']; 33 | $uri_parts = $this->reader->getURIPartsFromURIAndPreviousURIParts('/urlbits/andbobs', $parts_of_previous_uri); 34 | 35 | $this->assertEquals('https', $uri_parts['scheme']); 36 | $this->assertEquals('8081', $uri_parts['port']); 37 | $this->assertEquals('foo.bar', $uri_parts['host']); 38 | $this->assertEquals('/urlbits/andbobs', $uri_parts['path']); 39 | } 40 | 41 | public function testWhenTheSchemeChangesButPortIsNotExplicitThePortIsInferredFromTheSchemeNotThePreviousParts() 42 | { 43 | $parts_of_previous_uri = ['port' => 8081, 'scheme' => 'https', 'host' => 'foo.bar', 'path' => '/baz']; 44 | $uri_parts = $this->reader->getURIPartsFromURIAndPreviousURIParts('http://bbc.co.uk/news', $parts_of_previous_uri); 45 | 46 | $this->assertEquals('http', $uri_parts['scheme']); 47 | $this->assertEquals('80', $uri_parts['port']); 48 | $this->assertEquals('bbc.co.uk', $uri_parts['host']); 49 | $this->assertEquals('/news', $uri_parts['path']); 50 | } 51 | 52 | public function testWhenTheSchemeHasNotChangedAndPortIsNotExplicitThePortIsInferredFromThePreviousParts() 53 | { 54 | /* not totally convinced this is actually the right behaviour. Possibly if there is a scheme but no port then the scheme should always set the port */ 55 | $parts_of_previous_uri = ['port' => 8081, 'scheme' => 'https', 'host' => 'foo.bar', 'path' => '/baz']; 56 | $uri_parts = $this->reader->getURIPartsFromURIAndPreviousURIParts('https://bbc.co.uk/news', $parts_of_previous_uri); 57 | 58 | $this->assertEquals('https', $uri_parts['scheme']); 59 | $this->assertEquals('8081', $uri_parts['port']); 60 | $this->assertEquals('bbc.co.uk', $uri_parts['host']); 61 | $this->assertEquals('/news', $uri_parts['path']); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tests/unit/ARC2_getFormatTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('atom', $actual); 17 | 18 | $actual = \ARC2::getFormat($data); 19 | $this->assertEquals('atom', $actual); 20 | } 21 | 22 | public function testGetFormatWithRdfXml() 23 | { 24 | $data = file_get_contents(TESTS_FOLDER_PATH.'data/rdfxml/planetrdf-bloggers.rdf'); 25 | 26 | $actual = \ARC2::getFormat($data, 'application/rdf+xml'); 27 | $this->assertEquals('rdfxml', $actual); 28 | 29 | $actual = \ARC2::getFormat($data); 30 | $this->assertEquals('rdfxml', $actual); 31 | } 32 | 33 | public function testGetFormatWithTurtle() 34 | { 35 | $data = file_get_contents(TESTS_FOLDER_PATH.'data/turtle/manifest.ttl'); 36 | 37 | $actual = \ARC2::getFormat($data, 'text/turtle'); 38 | $this->assertEquals('turtle', $actual); 39 | 40 | $actual = \ARC2::getFormat($data); 41 | $this->assertEquals('turtle', $actual); 42 | } 43 | 44 | public function testGetFormatWithJson() 45 | { 46 | $data = file_get_contents(TESTS_FOLDER_PATH.'data/json/sparql-select-result.json'); 47 | 48 | $actual = \ARC2::getFormat($data, 'application/json'); 49 | $this->assertEquals('json', $actual); 50 | 51 | $actual = \ARC2::getFormat($data); 52 | $this->assertEquals('json', $actual); 53 | 54 | $data = file_get_contents(TESTS_FOLDER_PATH.'data/json/crunchbase-facebook.js'); 55 | 56 | $actual = \ARC2::getFormat($data); 57 | $this->assertEquals('cbjson', $actual); 58 | } 59 | 60 | public function testGetFormatWithN3() 61 | { 62 | $data = file_get_contents(TESTS_FOLDER_PATH.'data/nt/test.nt'); 63 | 64 | $actual = \ARC2::getFormat($data, 'application/rdf+n3'); 65 | $this->assertEquals('n3', $actual); 66 | 67 | $actual = \ARC2::getFormat($data, '', 'n3'); 68 | $this->assertEquals('n3', $actual); 69 | } 70 | 71 | public function testGetFormatWithNTriples() 72 | { 73 | $data = file_get_contents(TESTS_FOLDER_PATH.'data/nt/test.nt'); 74 | 75 | $actual = \ARC2::getFormat($data); 76 | $this->assertEquals('ntriples', $actual); 77 | 78 | $actual = \ARC2::getFormat($data, '', 'nt'); 79 | $this->assertEquals('ntriples', $actual); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /tests/unit/ARC2_getPreferredFormatTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('XML', $actual); 21 | 22 | $actual = \ARC2::getPreferredFormat('foo'); 23 | $this->assertNull($actual); 24 | 25 | $_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; 26 | $actual = \ARC2::getPreferredFormat(); 27 | $this->assertEquals('HTML', $actual); 28 | 29 | $_SERVER['HTTP_ACCEPT'] = 'application/rdf+xml,text/html;q=0.9,*/*;q=0.8'; 30 | $actual = \ARC2::getPreferredFormat(); 31 | $this->assertEquals('RDFXML', $actual); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/unit/store/ARC2_StoreEndpointTest.php: -------------------------------------------------------------------------------- 1 | endpoint = \ARC2::getStoreEndpoint($this->dbConfig); 16 | $this->endpoint->createDBCon(); 17 | } 18 | 19 | public function testJSON() 20 | { 21 | $data = [ 22 | 'result' => [ 23 | 'variables' => [ 24 | 'a', 25 | 'b', 26 | 'c', 27 | ], 28 | 'rows' => [ 29 | [ 30 | 'a' => 'http://de.dbpedia.org/resource/Johann_von_Pont', 31 | 'a type' => 'uri', 32 | 'b' => 'http://dbpedia.org/ontology/deathPlace', 33 | 'b type' => 'uri', 34 | 'c' => 'http://de.dbpedia.org/resource/Aachen', 35 | 'c type' => 'uri', 36 | ], 37 | [ 38 | 'a' => 'http://de.dbpedia.org/resource/Aachen', 39 | 'a type' => 'uri', 40 | 'b' => 'http://dbpedia.org/ontology/elevation', 41 | 'b type' => 'uri', 42 | 'c' => '173.0', 43 | 'c type' => 'literal', 44 | 'c datatype' => 'http://www.w3.org/2001/XMLSchema#double', 45 | ], 46 | [ 47 | 'a' => 'http://de.dbpedia.org/resource/Aachen', 48 | 'a type' => 'uri', 49 | 'b' => 'http://dbpedia.org/ontology/leaderTitle', 50 | 'b type' => 'uri', 51 | 'c' => 'Oberbürgermeister', 52 | 'c type' => 'literal', 53 | 'c lang' => 'de', 54 | ], 55 | ], 56 | ], 57 | 'query_time' => 1, 58 | ]; 59 | $res = json_decode($this->endpoint->getSPARQLJSONSelectResultDoc($data), true); 60 | $this->assertArrayHasKey('head', $res); 61 | $this->assertArrayHasKey('results', $res); 62 | $this->assertEquals($res['head']['vars'][0], 'a'); 63 | $this->assertEquals($res['results']['bindings'][0]['a']['value'], 'http://de.dbpedia.org/resource/Johann_von_Pont'); 64 | $this->assertEquals($res['results']['bindings'][1]['c']['type'], 'typed-literal'); 65 | $this->assertEquals($res['results']['bindings'][2]['c']['type'], 'literal'); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tests/unit/store/ARC2_StoreLoadQueryHandlerTest.php: -------------------------------------------------------------------------------- 1 | store = \ARC2::getStore($this->dbConfig); 16 | $this->store->createDBCon(); 17 | 18 | $this->fixture = new \ARC2_StoreLoadQueryHandler($this->store, $this); 19 | 20 | // fresh setup of ARC2 21 | $this->store->setup(); 22 | } 23 | 24 | protected function tearDown(): void 25 | { 26 | $this->store->closeDBCon(); 27 | } 28 | 29 | /* 30 | * Tests for getOComp 31 | */ 32 | 33 | /** 34 | * Tests to behavior, if a datetime string was given. 35 | */ 36 | public function testGetOComp() 37 | { 38 | // case with +hourse 39 | $string = '2009-05-28T18:03:38+09:00'; 40 | $this->assertEquals('2009-05-28T09:03:38Z', $this->fixture->getOComp($string)); 41 | 42 | // GMT case 43 | $string = '2009-05-28T18:03:38GMT'; 44 | $this->assertEquals('2009-05-28T18:03:38Z', $this->fixture->getOComp($string)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/unit/store/ARC2_StoreTest.php: -------------------------------------------------------------------------------- 1 | fixture = \ARC2::getStore($this->dbConfig); 14 | $this->fixture->createDBCon(); 15 | 16 | // remove all tables 17 | $this->fixture->getDBObject()->deleteAllTables(); 18 | 19 | // fresh setup of ARC2 20 | $this->fixture->setup(); 21 | } 22 | 23 | protected function tearDown(): void 24 | { 25 | $this->fixture->closeDBCon(); 26 | } 27 | } 28 | --------------------------------------------------------------------------------