Skip to content

Commit bf108dc

Browse files
committed
testing setup, lint fixes
1 parent c75f95a commit bf108dc

File tree

11 files changed

+422
-265
lines changed

11 files changed

+422
-265
lines changed

.github/workflows/testing.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Testing
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- master
8+
workflow_dispatch:
9+
workflow_call:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
behat:
17+
name: Functional / PHP ${{ matrix.php }}
18+
strategy:
19+
matrix:
20+
php: ['8.2']
21+
runs-on: ubuntu-latest
22+
services:
23+
mysql:
24+
image: mysql:8
25+
env:
26+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
27+
MYSQL_DATABASE: wp_cli_test
28+
MYSQL_USER: wp_cli_test
29+
MYSQL_PASSWORD: password1
30+
MYSQL_HOST: 127.0.0.1
31+
ports:
32+
- 3306
33+
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
34+
steps:
35+
- name: Check out source code
36+
uses: actions/checkout@v4
37+
38+
- name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: ${{ matrix.php }}
42+
tools: composer
43+
44+
- name: Install composer packages
45+
run: composer install
46+
47+
- name: Run Behat
48+
run: composer behat
49+
env:
50+
WP_CLI_TEST_DBUSER: wp_cli_test
51+
WP_CLI_TEST_DBPASS: password1
52+
WP_CLI_TEST_DBNAME: wp_cli_test
53+
WP_CLI_TEST_DBHOST: 127.0.0.1:${{ job.services.mysql.ports[3306] }}
54+
55+
unit: #-----------------------------------------------------------------------
56+
name: Unit test / PHP ${{ matrix.php }}
57+
strategy:
58+
matrix:
59+
php: [ '8.2' ]
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Check out source code
64+
uses: actions/checkout@v4
65+
66+
- name: Set up PHP environment
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: '${{ matrix.php }}'
70+
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
71+
coverage: none
72+
tools: composer,cs2pr
73+
74+
- name: Install Composer dependencies & cache dependencies
75+
uses: ramsey/composer-install@v3
76+
env:
77+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
78+
with:
79+
# Bust the cache at least once a month - output format: YYYY-MM.
80+
custom-cache-suffix: $(date -u "+%Y-%m")
81+
82+
- name: Grab PHPUnit version
83+
id: phpunit_version
84+
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
85+
86+
# PHPUnit 10 may fail a test run when the "old" configuration format is used.
87+
# Luckily, there is a build-in migration tool since PHPUnit 9.3.
88+
- name: Migrate PHPUnit configuration for PHPUnit 10+
89+
if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
90+
continue-on-error: true
91+
run: composer phpunit -- --migrate-configuration
92+
93+
- name: Setup problem matcher to provide annotations for PHPUnit
94+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
95+
96+
- name: Run PHPUnit
97+
run: composer phpunit

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":1,"defects":[],"times":{"AiCommand\\Tests\\MCP\\Client\\ClientTest::test_runs":0.001}}

.travis.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

behat.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
default:
2+
suites:
3+
default:
4+
contexts:
5+
- WP_CLI\Tests\Context\FeatureContext
6+
paths:
7+
- features

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
"license": "MIT",
77
"authors": [],
88
"require": {
9-
"gemini-api-php/client": "^1.7",
10-
"logiscape/mcp-sdk-php": "^1.0",
11-
"symfony/http-client": "^7.2",
9+
"php": "^8.2",
1210
"wp-cli/wp-cli": "^2.12"
1311
},
1412
"require-dev": {
15-
"wp-cli/wp-cli-tests": "^v4.3.6"
13+
"roave/security-advisories": "dev-latest",
14+
"wp-cli/wp-cli-tests": "^v4.3.9"
1615
},
1716
"config": {
1817
"process-timeout": 7200,
@@ -48,6 +47,7 @@
4847
"behat-rerun": "rerun-behat-tests",
4948
"lint": "run-linter-tests",
5049
"phpcs": "run-phpcs-tests",
50+
"phpcbf": "run-phpcbf-cleanup",
5151
"phpunit": "run-php-unit-tests",
5252
"prepare-tests": "install-package-tests",
5353
"test": [

phpcs.xml.dist

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="ai-command">
3+
<description>Custom ruleset for ai-command</description>
4+
5+
<!--
6+
#############################################################################
7+
COMMAND LINE ARGUMENTS
8+
For help understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
9+
For help using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage
10+
#############################################################################
11+
-->
12+
13+
<!-- What to scan. -->
14+
<file>.</file>
15+
16+
<!-- Show progress. -->
17+
<arg value="p"/>
18+
19+
<!-- Strip the filepaths down to the relevant bit. -->
20+
<arg name="basepath" value="./"/>
21+
22+
<!-- Check up to 8 files simultaneously. -->
23+
<arg name="parallel" value="8"/>
24+
25+
<!--
26+
#############################################################################
27+
USE THE WP_CLI_CS RULESET
28+
#############################################################################
29+
-->
30+
31+
<rule ref="WP_CLI_CS"/>-
32+
33+
<!--
34+
#############################################################################
35+
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
36+
#############################################################################
37+
-->
38+
39+
<!-- For help understanding the `testVersion` configuration setting:
40+
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
41+
<config name="testVersion" value="8.2-"/>
42+
43+
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
44+
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
45+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
46+
<properties>
47+
<property name="prefixes" type="array">
48+
<element value="WP_CLI\AiCommand"/><!-- Namespaces. -->
49+
<element value="ai_command"/><!-- Global variables and such. -->
50+
</property>
51+
</properties>
52+
</rule>
53+
54+
</ruleset>

phpunit.xml.dist

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
3+
bootstrap="vendor/autoload.php"
4+
backupGlobals="false"
5+
beStrictAboutCoversAnnotation="true"
6+
beStrictAboutOutputDuringTests="true"
7+
beStrictAboutTestsThatDoNotTestAnything="true"
8+
beStrictAboutTodoAnnotatedTests="true"
9+
convertErrorsToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
convertNoticesToExceptions="true"
12+
convertDeprecationsToExceptions="true"
13+
colors="true"
14+
verbose="true">
15+
<testsuites>
16+
<testsuite name="ai-command tests">
17+
<directory suffix="Test.php">tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<coverage processUncoveredFiles="false">
22+
<include>
23+
<directory suffix=".php">src</directory>
24+
</include>
25+
</coverage>
26+
</phpunit>

0 commit comments

Comments
 (0)