install event plugins in ci
Some checks failed
PHPUnit / PHPUnit – PHP 8.1 (push) Failing after 1m5s
PHPUnit / PHPUnit – PHP 8.2 (push) Failing after 1m1s
PHPUnit / PHPUnit – PHP 8.3 (push) Failing after 56s

This commit is contained in:
André Menrath 2024-09-23 20:07:36 +02:00
parent 68b7963fe6
commit 8d2c8b2d35
4 changed files with 56 additions and 5 deletions

View file

@ -4,6 +4,7 @@ on:
push:
branches:
- main
- improve_tests
pull_request:
env:

View file

@ -30,6 +30,11 @@ require_once "{$_tests_dir}/includes/functions.php";
*/
function _manually_load_plugin() {
require dirname( __DIR__ ) . '/activitypub-event-extensions.php';
$event_plugin = getenv( 'WP_EVENT_PLUGIN' );
switch ( $event_plugin ) {
case 'the-events-calendar':
require ABSPATH . '/wp-content/mu-plugins/the-events-calendar/the-events-calendar.php';
}
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );

View file

@ -15,6 +15,16 @@ SKIP_WP_INSTALL=${7-false}
SKIP_PLUGINS_INSTALL=${8-false}
SKIP_TEST_SUITE_INSTALL=${9-false}
# Initialize the plugin list
PLUGINS=""
# Parse optional --plugins argument
while [[ "$#" -gt 0 ]]; do
case $1 in
--plugins) PLUGINS="$2"; shift ;;
esac
shift
done
TMPDIR=${TMPDIR-/tmp}
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
@ -189,16 +199,42 @@ install_db() {
fi
}
install_wp_plugin() {
PLUGIN_NAME=$1
if [ -d "$WP_CORE_DIR/wp-content/mu-plugins/$PLUGIN_NAME" ]; then
return;
fi
# Get the latest tag.
LATEST_TAG=$(svn log https://plugins.svn.wordpress.org/$PLUGIN_NAME/tags --limit 1 | awk 'NR == 4 { print $4 }')
PLUGIN_FILE="$PLUGIN_NAME.$LATEST_TAG.zip"
URL="https://downloads.wordpress.org/plugin/$PLUGIN_FILE"
# Check if the plugin file already exists
if ! test -f "$TMPDIR/$PLUGIN_FILE"; then
download $URL "$TMPDIR/$PLUGIN_FILE"
fi
# Unzip the plugin into the WordPress must-use plugins directory
unzip -o "$TMPDIR/$PLUGIN_FILE" -d "$WP_CORE_DIR/wp-content/mu-plugins/"
}
install_wp_plugins() {
if [ "$SKIP_PLUGINS_INSTALL" = "true" ]; then
echo "Skipping WordPress plugin installation."
return 0
fi
ACTIVITYPUB_FILE="activitypub.3.2.5.zip"
if ! test -f $TMPDIR/$ACTIVITYPUB_FILE; then
download https://downloads.wordpress.org/plugin/$ACTIVITYPUB_FILE $TMPDIR/$ACTIVITYPUB_FILE
fi
unzip -o $TMPDIR/$ACTIVITYPUB_FILE -d $WP_CORE_DIR/wp-content/plugins/
# Always install the ActivityPub plugin.
install_wp_plugin activitypub
install_wp_plugin the-events-calendar
# Install additional plugins.
# if [[ -n "$PLUGINS" ]]; then
# IFS=',' read -ra PLUGIN_ARRAY <<< "$PLUGINS"
# for plugin in "${PLUGIN_ARRAY[@]}"; do
# install_wp_plugin "$plugin"
# done
# fi
}
install_wp

View file

@ -17,4 +17,13 @@ class Test_Sample extends WP_UnitTestCase {
// Replace this with some actual testing code.
$this->assertTrue( true );
}
/**
* Tesd tes
*/
public function test_the_events_calendar() {
// Replace this with some actual testing code.
$class_exists = class_exists( 'Tribe__Events__Main' );
$this->assertTrue( $class_exists );
}
}