Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PHP
on: [push]
jobs:
lint-test:
name: ${{ matrix.php-versions }} Lint & Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['8.1']
steps:
- name: Checkout
uses: actions/checkout@v3

# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install

- name: PHP Lint
run: vendor/bin/phpcs

- name: PHP test
run: vendor/bin/phpunit --testdox
21 changes: 7 additions & 14 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
<?xml version="1.0"?>
<phpunit
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuites>
<testsuite name="unit">
<directory suffix=".php">./tests/Unit/</directory>
</testsuite>

</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" backupGlobals="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage/>
<testsuites>
<testsuite name="unit">
<directory suffix=".php">./tests/Unit/</directory>
</testsuite>
</testsuites>
</phpunit>
17 changes: 9 additions & 8 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
declare( strict_types = 1 );

namespace MR\FeatureFlags;

use MR\FeatureFlags\Api\Flags;

// If this file is called directly, abort.
Expand Down Expand Up @@ -52,8 +53,8 @@ function(): void {


$feature_flag_meta = get_option( FeatureFlags::$option_name );
$flags_list = [];
if(is_array($feature_flag_meta)) {
$flags_list = [];
if ( is_array( $feature_flag_meta ) ) {
$flags_list = $feature_flag_meta;
}

Expand Down Expand Up @@ -108,7 +109,7 @@ function load_settings_scripts(): void {

add_action(
'admin_enqueue_scripts',
function(string $page): void {
function( string $page ): void {
$plugin_url = plugin_dir_url( MR_FEATURE_FLAGS_PLUGIN_PATH );
$script_asset_file = include_once plugin_dir_path( MR_FEATURE_FLAGS_PLUGIN_PATH ) . 'build/index.asset.php';

Expand All @@ -121,8 +122,8 @@ function(string $page): void {
);

$feature_flag_meta = get_option( Utils::$option_name );
$flags_list = [];
if(is_array($feature_flag_meta)) {
$flags_list = [];
if ( is_array( $feature_flag_meta ) ) {
$flags_list = $feature_flag_meta;
}

Expand All @@ -146,9 +147,9 @@ function(string $page): void {



add_filter( 'plugin_action_links_mr-feature-flags/plugin.php', function ( $links )
{

add_filter(
'plugin_action_links_mr-feature-flags/plugin.php',
function ( $links ) {
$url = esc_url(
add_query_arg(
'page',
Expand Down
6 changes: 6 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/**
* Bootstap file for PHPUnit test.
*
* @package mr-feature-flags
*/

if ( file_exists( __DIR__ . '/../vendor/autoload.php' ) ) {
include __DIR__ . '/../vendor/autoload.php';
}
Expand Down