Skip to content

Commit

Permalink
Updated test code for newer Omeka; all tests now pass
Browse files Browse the repository at this point in the history
Version is set to 2.4.0-ehri for eventual release.

Requires running again latest Omeka builds however that are
compatible w/ PHP 8.0.

This includes CI config for Travis and Github Actions but after
lots of teeth gnashing that still fail w/ MySQL timeout errors
for reasons I do not understand.
  • Loading branch information
mikesname committed Feb 8, 2021
1 parent 508365e commit 762a405
Show file tree
Hide file tree
Showing 48 changed files with 4,014 additions and 494 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Run Tests

on:
push:
pull_request:

env:
OMEKA_DIR: Omeka
DB_DATABASE: omeka_test
DB_USER: root
DB_PASSWORD: root


jobs:
phpunit:
runs-on: ubuntu-latest

steps:
- name: Set up MySQL
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
- name: Checkout
uses: actions/checkout@v2

- name: Set permissions on Solr core
run: chmod 0777 solr-core/omeka

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mbstring, xml, xsl, mysql, gd
ini-values: post_max_size=256M, max_execution_time=180

- name: Build the docker-compose stack
run: docker-compose up -d

- name: Create solr.ini
run: |
cat <<EOF > tests/phpunit/solr.ini
port = 18983
server = localhost
core = /solr/omeka/
EOF
- name: Setup host Omeka instance
run: |
git clone https://github.com/omeka/Omeka.git
cd Omeka
git checkout 08bfdf470e234edb68e5307a2fef8c899d89256c
mv application/config/config.ini.changeme application/config/config.ini
mv application/tests/config.ini.changeme application/tests/config.ini
mv db.ini.changeme db.ini
for f in db.ini application/tests/config.ini
do
sed -Ei 's/(db\.)?host\s*=\s*"[^"]*"/\1host = "127.0.0.1"/' $f
sed -Ei 's/(db\.)?username\s*=\s*"[^"]*"/\1username = "${{ env.DB_USER }}"/' $f
sed -Ei 's/(db\.)?password\s*=\s*"[^"]*"/\1password = "${{ env.DB_PASSWORD}}"/' $f
sed -Ei 's/(db\.)?dbname\s*=\s*"[^"]*"/\1dbname = "${{ env.DB_DATABASE }}"\n\1port = 3306/' $f
done
composer -q update
composer install -q --no-ansi --no-interaction --no-scripts --no-progress
- name: Install dependencies
run: |
composer -q update
composer install -q --no-ansi --no-interaction --no-scripts --no-progress
- name: Run test suite
run: composer -vvv test
# run: php test.php
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pkg

tests/phpunit/solr.ini
solr-core/omeka/data
tests/phpunit/.phpunit.result.cache
51 changes: 51 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
language: php

matrix:
include:
- php: 7.2
dist: bionic

services:
- mysql
- docker

sudo: false

env:
- OMEKA_DIR=./Omeka

before_install:
- docker-compose up -d

before_script:
- set -e
- git clone https://github.com/omeka/Omeka
- cd Omeka
- git checkout 08bfdf470e234edb68e5307a2fef8c899d89256c
- mysql -e "create database IF NOT EXISTS omeka_test;" -uroot
- mv application/config/config.ini.changeme application/config/config.ini
- mv application/tests/config.ini.changeme application/tests/config.ini
- mv db.ini.changeme db.ini
- |
for f in db.ini application/tests/config.ini
do
sed -Ei 's/(db\.)?host\s*=\s*"[^"]*"/\1host = "127.0.0.1"/' $f
sed -Ei 's/(db\.)?username\s*=\s*"[^"]*"/\1username = "root"/' $f
sed -Ei 's/(db\.)?password\s*=\s*"[^"]*"/\1password = ""/' $f
sed -Ei 's/(db\.)?dbname\s*=\s*"[^"]*"/\1dbname = "omeka_test"/' $f
done
- composer -q update
- composer install -q --no-ansi --no-interaction --no-scripts --no-progress
- cd ..
- |
cat <<EOF > tests/phpunit/solr.ini
port = 18983
server = localhost
core = /solr/omeka/
EOF
- chmod 0777 solr-core/omeka

script:
- composer -q update
- composer install -q --no-ansi --no-interaction --no-scripts --no-progress
- composer test
14 changes: 10 additions & 4 deletions SolrSearchPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public function hookUninstall()
public function hookUpgrade($args)
{
self::_createSolrTables();
if (version_compare($args['old_version'], '1.0.1', '<=')) {
$oldVersion = $args['old_version'];
if (version_compare($oldVersion, '1.0.1', '<=')) {
self::_installFacetMappings();
self::_setOptions();
}
Expand All @@ -91,9 +92,14 @@ public function hookUpgrade($args)
$this->_installGenericFacet('featured', __('Featured'));
}

if (version_compare($args['old_version'], '2.2.1', '<=')) {
if (version_compare($oldVersion, '2.2.1', '<=')) {
set_option('solr_search_hl_max_analyzed_chars', '51200');
}
if ($oldVersion < '2.4.0') {
$tableName = $fields->getTableName();
$this->_db->query("ALTER TABLE `$tableName` MODIFY `slug` VARCHAR(512) COLLATE utf8_unicode_ci NOT NULL UNIQUE");
}

}


Expand Down Expand Up @@ -314,7 +320,7 @@ protected function _createSolrTables()
CREATE TABLE IF NOT EXISTS {$this->_db->prefix}solr_search_fields (
id int(10) unsigned NOT NULL auto_increment,
element_id int(10) unsigned,
slug tinytext collate utf8_unicode_ci NOT NULL,
slug VARCHAR(512) collate utf8_unicode_ci NOT NULL UNIQUE,
label tinytext collate utf8_unicode_ci NOT NULL,
is_indexed tinyint unsigned DEFAULT 0,
is_facet tinyint unsigned DEFAULT 0,
Expand Down Expand Up @@ -361,7 +367,7 @@ protected function _installGenericFacet($slug, $label)
{
$this->_db
->getTable('SolrSearchField')
->installGenericFacet($slub, $label);
->installGenericFacet($slug, $label);
}


Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"require-dev": {
"phpunit/phpunit": "^4.8"
"phpunit/phpunit": "^4.8|^6|^7|^8"
},
"scripts": {
"test": "./vendor/bin/phpunit -c tests/phpunit/phpunit.xml tests"
},
"require": {
"ext-mysqli": "*"
}
}
Loading

0 comments on commit 762a405

Please sign in to comment.