diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 350c837..46a19c6 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -5,7 +5,7 @@ on: - 'main-built' jobs: - test: + e2e: timeout-minutes: 60 runs-on: ubuntu-latest strategy: @@ -20,6 +20,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: '20.11' + cache: 'yarn' - name: Cache Composer dependencies uses: actions/cache@v4 diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index 18e19ee..6e1d325 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -5,8 +5,7 @@ on: - 'main-built' jobs: - build: - name: Lint & Test + lint-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -15,6 +14,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: 20.11 + cache: 'yarn' - name: Install packages run: yarn install --immutable @@ -24,3 +24,11 @@ jobs: - name: JS test run: yarn test:js + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: js-report + path: js-report/ + retention-days: 30 diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index ee81930..d593720 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -6,20 +6,17 @@ on: jobs: lint-test: - name: ${{ matrix.php-versions }} Lint & Test + timeout-minutes: 60 runs-on: ubuntu-latest strategy: fail-fast: false - matrix: - php-versions: ['8.3'] steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.11' + cache: 'yarn' - name: Cache Composer dependencies uses: actions/cache@v4 @@ -27,17 +24,13 @@ jobs: path: /tmp/composer-cache key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - name: Setup PHP with tools - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - tools: composer:v2 - - name: Validate Composer run: composer validate --strict - - name: Install dependencies - run: composer install --prefer-dist + - name: Setup composer + uses: php-actions/composer@v6 + with: + php_version: '8.3' - name: PHP Lint run: composer lint @@ -48,5 +41,43 @@ jobs: - name: PHPMD run: composer phpmd + - name: Install wp-env + run: yarn add @wordpress/env -D + + - name: Start wp-env + run: yarn wp-env:coverage + - name: WordPress unit test - run: composer test:unit + run: yarn php:unit + + - name: Unit test coverage report + uses: codecov/codecov-action@v4 + with: + files: ./unit-coverage.xml + flags: unittests + name: codecov-unit + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: WordPress integration test + run: yarn php:integration + + - name: Integration test coverage report + uses: codecov/codecov-action@v4 + with: + files: ./integration-coverage.xml + flags: integrationtests + name: codecov-integration + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: WordPress integration test as multisite + run: yarn php:multisite + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: php-report + path: php-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index 20f8030..a38d132 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ vendor build yarn-error.log .phpunit.result.cache +.phpunit.cache .DS_Store testingdb .env @@ -14,3 +15,5 @@ tests-examples/ /blob-report/ /playwright/.cache/ build-script.sh +integration-coverage.xml +unit-coverage.xml diff --git a/.wp-env.json b/.wp-env.json index 2a95c30..3b88d98 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -1,5 +1,12 @@ { "core": null, "plugins": ["."], - "phpVersion": "8.3" + "phpVersion": "8.3", + "env": { + "tests": { + "mappings": { + "wp-content/plugins/feature-flags": "." + } + } + } } diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh deleted file mode 100755 index 26836f7..0000000 --- a/bin/install-wp-tests.sh +++ /dev/null @@ -1,155 +0,0 @@ -#!/usr/bin/env bash - -if [ $# -lt 3 ]; then - echo "usage: $0 [db-host] [wp-version] [skip-database-creation]" - exit 1 -fi - -DB_NAME=$1 -DB_USER=$2 -DB_PASS=$3 -DB_HOST=${4-localhost} -WP_VERSION=${5-latest} -SKIP_DB_CREATE=${6-false} - -TMPDIR=${TMPDIR-/tmp} -TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") -WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib} -WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/} - -download() { - if [ `which curl` ]; then - curl -s "$1" > "$2"; - elif [ `which wget` ]; then - wget -nv -O "$2" "$1" - fi -} - -if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then - WP_BRANCH=${WP_VERSION%\-*} - WP_TESTS_TAG="branches/$WP_BRANCH" - -elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then - WP_TESTS_TAG="branches/$WP_VERSION" -elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then - if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then - # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x - WP_TESTS_TAG="tags/${WP_VERSION%??}" - else - WP_TESTS_TAG="tags/$WP_VERSION" - fi -elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then - WP_TESTS_TAG="trunk" -else - # http serves a single offer, whereas https serves multiple. we only want one - download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json - grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json - LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') - if [[ -z "$LATEST_VERSION" ]]; then - echo "Latest WordPress version could not be found" - exit 1 - fi - WP_TESTS_TAG="tags/$LATEST_VERSION" -fi -set -ex - -install_wp() { - - if [ -d $WP_CORE_DIR ]; then - return; - fi - - mkdir -p $WP_CORE_DIR - - if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then - mkdir -p $TMPDIR/wordpress-nightly - download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip - unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/ - mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR - else - if [ $WP_VERSION == 'latest' ]; then - local ARCHIVE_NAME='latest' - elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then - # https serves multiple offers, whereas http serves single. - download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json - if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then - # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x - LATEST_VERSION=${WP_VERSION%??} - else - # otherwise, scan the releases and get the most up to date minor version of the major release - local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` - LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1) - fi - if [[ -z "$LATEST_VERSION" ]]; then - local ARCHIVE_NAME="wordpress-$WP_VERSION" - else - local ARCHIVE_NAME="wordpress-$LATEST_VERSION" - fi - else - local ARCHIVE_NAME="wordpress-$WP_VERSION" - fi - download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz - tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR - fi - - download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php -} - -install_test_suite() { - # portable in-place argument for both GNU sed and Mac OSX sed - if [[ $(uname -s) == 'Darwin' ]]; then - local ioption='-i.bak' - else - local ioption='-i' - fi - - # set up testing suite if it doesn't yet exist - if [ ! -d $WP_TESTS_DIR ]; then - # set up testing suite - mkdir -p $WP_TESTS_DIR - svn co --ignore-externals --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes - svn co --ignore-externals --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data - fi - - if [ ! -f wp-tests-config.php ]; then - download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php - # remove all forward slashes in the end - WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") - sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php - fi - -} - -install_db() { - - if [ ${SKIP_DB_CREATE} = "true" ]; then - return 0 - fi - - # parse DB_HOST for port or socket references - local PARTS=(${DB_HOST//\:/ }) - local DB_HOSTNAME=${PARTS[0]}; - local DB_SOCK_OR_PORT=${PARTS[1]}; - local EXTRA="" - - if ! [ -z $DB_HOSTNAME ] ; then - if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then - EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" - elif ! [ -z $DB_SOCK_OR_PORT ] ; then - EXTRA=" --socket=$DB_SOCK_OR_PORT" - elif ! [ -z $DB_HOSTNAME ] ; then - EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" - fi - fi - - # create database - mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA -} - -install_wp -install_test_suite -install_db diff --git a/composer.json b/composer.json index 9432d81..c3ae331 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,8 @@ "newsuk/nuk-wp-phpmd-config": "^0.1.0", "newsuk/nuk-wp-phpstan-config": "^0.1.0", "phpunit/phpunit": "^9.4", - "wordpress/wordpress": "^6.4", "yoast/wp-test-utils": "^1.2" }, - "repositories": [ - { - "type": "vcs", - "url": "https://git@github.com/WordPress/wordpress-develop" - } - ], "autoload": { "psr-4": { "CodeB\\FeatureFlags\\": [ @@ -48,8 +41,8 @@ "phpmd": "phpmd plugin.php,includes text phpmd.xml.dist --color", "phpstan": "phpstan analyse --memory-limit=2048M", "phpstan-baseline": "phpstan analyse -b --allow-empty-baseline --memory-limit=2048M", - "test:integration": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration.xml --testsuite integration --testdox --coverage-text", - "test:multisite": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration-multisite.xml --testsuite integration --testdox --coverage-text", - "test:unit": "phpunit --dont-report-useless-tests --configuration ./phpunit.xml --testsuite unit --testdox --coverage-text" + "test:integration": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration.xml --testsuite integration --testdox", + "test:multisite": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration-multisite.xml --testsuite integration --testdox ", + "test:unit": "phpunit --dont-report-useless-tests --configuration ./phpunit.xml --testsuite unit --testdox" } } diff --git a/composer.lock b/composer.lock index 89e9f9a..6733bb0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "184bc1b9afe3bddb1872a436264d8f1d", + "content-hash": "f77b8b730bc595a76e2ed4a42225010f", "packages": [], "packages-dev": [ { @@ -4375,61 +4375,6 @@ ], "time": "2023-11-20T00:12:19+00:00" }, - { - "name": "wordpress/wordpress", - "version": "6.4.3", - "source": { - "type": "git", - "url": "https://git@github.com/WordPress/wordpress-develop", - "reference": "9e9559d6d6bd2327dee822c305b2905b65a91ef2" - }, - "require": { - "php": ">=7.0" - }, - "require-dev": { - "phpcompatibility/phpcompatibility-wp": "~2.1.3", - "squizlabs/php_codesniffer": "3.7.2", - "wp-coding-standards/wpcs": "~3.0.1", - "yoast/phpunit-polyfills": "^1.1.0" - }, - "suggest": { - "ext-dom": "*" - }, - "type": "library", - "scripts": { - "compat": [ - "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --standard=phpcompat.xml.dist --report=summary,source" - ], - "format": [ - "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --report=summary,source" - ], - "lint": [ - "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary,source" - ], - "lint:errors": [ - "@lint -n" - ], - "test": [ - "Composer\\Config::disableProcessTimeout", - "@php ./vendor/phpunit/phpunit/phpunit" - ] - }, - "license": [ - "GPL-2.0-or-later" - ], - "description": "WordPress is open source software you can use to create a beautiful website, blog, or app.", - "homepage": "https://wordpress.org", - "keywords": [ - "blog", - "cms", - "wordpress", - "wp" - ], - "support": { - "issues": "https://core.trac.wordpress.org/" - }, - "time": "2024-01-30T19:25:29+00:00" - }, { "name": "wp-coding-standards/wpcs", "version": "3.0.1", diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index d50fea8..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,30 +0,0 @@ -version: "3.7" - -services: - php: - build: - context: . - dockerfile: docker/php/Dockerfile - user: 1000:1000 - env_file: .env - environment: - WORDPRESS_DB_HOST: ${DB_HOST} - WORDPRESS_DB_PASSWORD: ${DB_PASSWORD} - WORDPRESS_DB_NAME: ${DB_NAME} - volumes: - - .:/usr/src - - ~/.composer:/var/cache/composer - links: - - mysql - depends_on: - - mysql - mysql: - image: mysql:8.0 - env_file: .env - environment: - MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} - MYSQL_DATABASE: ${DB_NAME} - volumes: - - ./testingdb:/var/lib/mysql -volumes: - testingdb: diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile deleted file mode 100644 index 6c1a60c..0000000 --- a/docker/php/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -FROM php:8.3 - -# Container + PHP Setup -ARG XDEBUG_INI="/usr/local/etc/php/conf.d/xdebug.ini" -# Install, enable and configure xdebug -RUN pecl install xdebug \ - && docker-php-ext-enable xdebug \ - && echo "[xdebug]" > $XDEBUG_INI \ - && echo "xdebug.mode = coverage" >> $XDEBUG_INI - -RUN docker-php-ext-install mysqli - -# Install Composer -RUN curl -s https://getcomposer.org/installer | php && \ - mv composer.phar /usr/local/bin/composer - -RUN mkdir /var/cache/composer -VOLUME /var/cache/composer -RUN chown -R www-data:www-data /var/cache/composer -ENV COMPOSER_HOME=/var/cache/composer - -# WP CLI Setup -ENV WORDPRESS_CLI_VERSION 2.9.0 - -RUN set -ex; \ - curl -o /usr/local/bin/wp -fSL "https://github.com/wp-cli/wp-cli/releases/download/v${WORDPRESS_CLI_VERSION}/wp-cli-${WORDPRESS_CLI_VERSION}.phar"; \ - curl -o /usr/local/bin/wp.sha512 -fSL "https://github.com/wp-cli/wp-cli/releases/download/v${WORDPRESS_CLI_VERSION}/wp-cli-${WORDPRESS_CLI_VERSION}.phar.sha512"; \ - \ - echo "$(cat /usr/local/bin/wp.sha512) /usr/local/bin/wp" | sha512sum -c -; \ - chmod +x /usr/local/bin/wp; \ - \ - wp --allow-root --version - -ENV WP_TESTS_DIR /usr/src/vendor/wordpress/wordpress/tests/phpunit -ENV WP_TESTS_CONFIG_FILE_PATH /usr/src/tests/functional - -VOLUME /usr/src -WORKDIR /usr/src diff --git a/local b/local deleted file mode 100755 index 4ecfcde..0000000 --- a/local +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if [ ! -f ".env" ]; then - cp .env.dist .env -fi - -docker-compose -p plugin-testing up -d mysql -docker-compose -p plugin-testing run --entrypoint bash php diff --git a/package.json b/package.json index 4930db2..870faa0 100644 --- a/package.json +++ b/package.json @@ -1,60 +1,64 @@ { - "name": "codeb-feature-flags", - "version": "0.3.0", - "description": "Allows developers to enable / disable features based on flags.", - "license": "ISC", - "author": "Mohan Raj ", - "scripts": { - "build": "wp-scripts build", - "lint:css": "wp-scripts lint-style", - "lint:css:fix": "npm run lint:css -- --fix", - "lint:js": "wp-scripts lint-js", - "lint:js:fix": "wp-scripts lint-js --fix", - "prepare": "husky", - "start": "wp-scripts start", - "test:e2e": "npx playwright test --reporter=list", - "test:js": "wp-scripts test-unit-js", - "test:watch": "wp-scripts test-unit-js --watch", - "version:major": "node ./scripts/version major", - "version:minor": "node ./scripts/version minor", - "version:patch": "node ./scripts/version patch", - "wp-env": "wp-env start" - }, - "dependencies": { - "@wordpress/api-fetch": "^6.48.0", - "@wordpress/components": "^27.0.0", - "@wordpress/data": "^9.22.0", - "@wordpress/dom-ready": "^3.52.0", - "@wordpress/hooks": "^3.52.0", - "@wordpress/i18n": "^4.52.0", - "@wordpress/notices": "^4.20.0", - "dotenv": "^16.4.5", - "react": "18.2.0", - "react-dom": "18.2.0", - "react-syntax-highlighter": "^15.5.0", - "react-test-renderer": "^18.2.0", - "ts-loader": "^9.5.1", - "typescript": "^5.3.3" - }, - "devDependencies": { - "@playwright/test": "^1.42.0", - "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "14.2.1", - "@types/jest": "^29.5.12", - "@types/node": "^20.11.20", - "@types/react-syntax-highlighter": "^15.5.11", - "@types/wordpress__components": "^23.0.11", - "@wordpress/e2e-test-utils-playwright": "^0.20.0", - "@wordpress/env": "^9.4.0", - "@wordpress/eslint-plugin": "^17.9.0", - "@wordpress/scripts": "^27.3.0", - "eslint": "^8.57.0", - "eslint-import-resolver-alias": "^1.1.2", - "eslint-plugin-cypress": "^2.15.1", - "eslint-plugin-import": "^2.29.1", - "husky": "^9.0.11", - "jest-environment-jsdom": "^29.7.0", - "prettier": "^3.2.5" - }, - "keywords": [] -} \ No newline at end of file + "name": "codeb-feature-flags", + "version": "0.3.1", + "description": "Allows developers to enable / disable features based on flags.", + "license": "ISC", + "author": "Mohan Raj ", + "scripts": { + "build": "wp-scripts build", + "lint:css": "wp-scripts lint-style", + "lint:css:fix": "npm run lint:css -- --fix", + "lint:js": "wp-scripts lint-js", + "lint:js:fix": "wp-scripts lint-js --fix", + "prepare": "husky", + "start": "wp-scripts start", + "test:e2e": "npx playwright test --reporter=list", + "test:js": "wp-scripts test-unit-js", + "test:watch": "wp-scripts test-unit-js --watch", + "version:major": "node ./scripts/version major", + "version:minor": "node ./scripts/version minor", + "version:patch": "node ./scripts/version patch", + "wp-env": "wp-env start", + "wp-env:coverage": "wp-env start --xdebug=coverage", + "php:unit": "wp-env run --env-cwd='wp-content/plugins/feature-flags' tests-wordpress composer test:unit", + "php:integration": "wp-env run tests-wordpress --env-cwd=wp-content/plugins/feature-flags composer test:integration", + "php:multisite": "wp-env run tests-wordpress --env-cwd=wp-content/plugins/feature-flags composer test:multisite" + }, + "dependencies": { + "@wordpress/api-fetch": "^6.48.0", + "@wordpress/components": "^27.0.0", + "@wordpress/data": "^9.22.0", + "@wordpress/dom-ready": "^3.52.0", + "@wordpress/hooks": "^3.52.0", + "@wordpress/i18n": "^4.52.0", + "@wordpress/notices": "^4.20.0", + "dotenv": "^16.4.5", + "react": "18.2.0", + "react-dom": "18.2.0", + "react-syntax-highlighter": "^15.5.0", + "react-test-renderer": "^18.2.0", + "ts-loader": "^9.5.1", + "typescript": "^5.3.3" + }, + "devDependencies": { + "@playwright/test": "^1.42.0", + "@testing-library/jest-dom": "^6.4.2", + "@testing-library/react": "14.2.1", + "@types/jest": "^29.5.12", + "@types/node": "^20.11.20", + "@types/react-syntax-highlighter": "^15.5.11", + "@types/wordpress__components": "^23.0.11", + "@wordpress/e2e-test-utils-playwright": "^0.20.0", + "@wordpress/env": "^9.4.0", + "@wordpress/eslint-plugin": "^17.9.0", + "@wordpress/scripts": "^27.3.0", + "eslint": "^8.57.0", + "eslint-import-resolver-alias": "^1.1.2", + "eslint-plugin-cypress": "^2.15.1", + "eslint-plugin-import": "^2.29.1", + "husky": "^9.0.11", + "jest-environment-jsdom": "^29.7.0", + "prettier": "^3.2.5" + }, + "keywords": [] +} diff --git a/phpunit-integration-multisite.xml b/phpunit-integration-multisite.xml index 259f198..c96a01d 100644 --- a/phpunit-integration-multisite.xml +++ b/phpunit-integration-multisite.xml @@ -1,6 +1,10 @@ - - + + + + ./includes + + diff --git a/phpunit-integration.xml b/phpunit-integration.xml index bf755a2..b62fcc6 100644 --- a/phpunit-integration.xml +++ b/phpunit-integration.xml @@ -1,9 +1,12 @@ - - + + ./includes + + + diff --git a/phpunit.xml b/phpunit.xml index 1b4e982..65ca033 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,9 +1,12 @@ - - + + ./includes + + + diff --git a/plugin.php b/plugin.php index 3b4e936..0beac5a 100644 --- a/plugin.php +++ b/plugin.php @@ -9,7 +9,7 @@ * Plugin Name: Feature Flags * Plugin URI: https://github.com/codebtech/wp-feature-flags * Description: Allows developers to enable / disable features based on flags. - * Version: 0.3.0 + * Version: 0.3.1 * Requires at least: 6.4 * Requires PHP: 8.1 * Author: Mohan Raj diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/delete-flag-modal-chromium-darwin.png b/tests/e2e/visual-comparison.spec.ts-snapshots/delete-flag-modal-chromium-darwin.png index e7e8d1b..e69a7d4 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/delete-flag-modal-chromium-darwin.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/delete-flag-modal-chromium-darwin.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/delete-flag-modal-chromium-linux.png b/tests/e2e/visual-comparison.spec.ts-snapshots/delete-flag-modal-chromium-linux.png index 0db7277..c27f9b7 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/delete-flag-modal-chromium-linux.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/delete-flag-modal-chromium-linux.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/flag-disabled-chromium-darwin.png b/tests/e2e/visual-comparison.spec.ts-snapshots/flag-disabled-chromium-darwin.png index 468f3f4..d8ebe49 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/flag-disabled-chromium-darwin.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/flag-disabled-chromium-darwin.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/flag-disabled-chromium-linux.png b/tests/e2e/visual-comparison.spec.ts-snapshots/flag-disabled-chromium-linux.png index 0a473a3..15052e4 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/flag-disabled-chromium-linux.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/flag-disabled-chromium-linux.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/no-flags-chromium-darwin.png b/tests/e2e/visual-comparison.spec.ts-snapshots/no-flags-chromium-darwin.png index 029d383..7ed01f4 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/no-flags-chromium-darwin.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/no-flags-chromium-darwin.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/no-flags-chromium-linux.png b/tests/e2e/visual-comparison.spec.ts-snapshots/no-flags-chromium-linux.png index a98dee9..d7a1f43 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/no-flags-chromium-linux.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/no-flags-chromium-linux.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/sdk-modal-chromium-darwin.png b/tests/e2e/visual-comparison.spec.ts-snapshots/sdk-modal-chromium-darwin.png index fb6243a..6177ea7 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/sdk-modal-chromium-darwin.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/sdk-modal-chromium-darwin.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/sdk-modal-chromium-linux.png b/tests/e2e/visual-comparison.spec.ts-snapshots/sdk-modal-chromium-linux.png index 3eb8a5b..9daca34 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/sdk-modal-chromium-linux.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/sdk-modal-chromium-linux.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/some-flags-chromium-darwin.png b/tests/e2e/visual-comparison.spec.ts-snapshots/some-flags-chromium-darwin.png index dd2411c..3c2ff74 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/some-flags-chromium-darwin.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/some-flags-chromium-darwin.png differ diff --git a/tests/e2e/visual-comparison.spec.ts-snapshots/some-flags-chromium-linux.png b/tests/e2e/visual-comparison.spec.ts-snapshots/some-flags-chromium-linux.png index 0649a60..7e02d26 100644 Binary files a/tests/e2e/visual-comparison.spec.ts-snapshots/some-flags-chromium-linux.png and b/tests/e2e/visual-comparison.spec.ts-snapshots/some-flags-chromium-linux.png differ diff --git a/tests/integration/FlagsApiTest.php b/tests/integration/FlagsApiTest.php index 104203f..da48cfa 100644 --- a/tests/integration/FlagsApiTest.php +++ b/tests/integration/FlagsApiTest.php @@ -8,6 +8,7 @@ use WP_REST_Request; use WP_UnitTest_Factory; use WP_Test_REST_Controller_Testcase; +use CodeB\FeatureFlags\Flag; class FlagsApiTest extends WP_Test_REST_Controller_Testcase { @@ -35,7 +36,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { public static function wpTearDownAfterClass() { wp_delete_user( self::$editor ); - delete_option( Flags::$option_name ); + delete_option( Flag::$option_name ); } public function set_up() { @@ -77,7 +78,7 @@ public function test_get_items_as_admin_returns_200() { public function test_get_items() { wp_set_current_user( self::$admin ); $flags = [['id'=>1, 'name'=>'test', 'enabled'=>true], ['id'=>2, 'name'=>'test2', 'enabled'=>false]]; - update_option( Flags::$option_name, $flags ); + update_option( Flag::$option_name, $flags ); $request = new WP_REST_Request( 'GET', self::$api_endpoint ); $response = rest_get_server()->dispatch( $request ); @@ -120,7 +121,7 @@ public function test_create_item() { $this->assertSame( 200, $response->get_status() ); $this->assertTrue( $response->get_data()['success'] ); - $options = get_option(Flags::$option_name); + $options = get_option(Flag::$option_name); $this->assertSame($options, $flags); } @@ -136,7 +137,7 @@ public function test_create_item_with_empty_array() { $this->assertSame( 200, $response->get_status() ); $this->assertTrue( $response->get_data()['success'] ); - $options = get_option(Flags::$option_name); + $options = get_option(Flag::$option_name); $this->assertSame($options, $flags); } diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php index e49f9e3..14adbc6 100644 --- a/tests/integration/bootstrap.php +++ b/tests/integration/bootstrap.php @@ -29,6 +29,4 @@ function _manually_load_plugin(): void { tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); -define( 'WP_TESTS_CONFIG_FILE_PATH', __DIR__ . '/wp-tests-config.php' ); - bootstrap_it(); diff --git a/tests/integration/wp-tests-config.php b/tests/integration/wp-tests-config.php deleted file mode 100644 index 428ee39..0000000 --- a/tests/integration/wp-tests-config.php +++ /dev/null @@ -1,70 +0,0 @@ -