From 8c3aae2a46bedb39a35c40aac514f0f7b7feeb57 Mon Sep 17 00:00:00 2001
From: Renaat Debleu <rdebleu@eWallah.net>
Date: Wed, 15 May 2024 15:04:01 +0000
Subject: [PATCH] infection

---
 .github/workflows/infection.yml | 60 +++++++++++++++++++++++++++++++++
 .infection.json5                | 17 ++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 .github/workflows/infection.yml
 create mode 100644 .infection.json5

diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml
new file mode 100644
index 0000000..4d43007
--- /dev/null
+++ b/.github/workflows/infection.yml
@@ -0,0 +1,60 @@
+name: Tests
+
+on: [push, pull_request]
+
+jobs:
+  ci:
+    name: ci
+    runs-on: ubuntu-latest
+
+    strategy:
+      fail-fast: false
+      matrix:
+        moodle-branch: ['main']
+        php: ['8.1']
+        database: ['mysqli']
+
+    steps:
+      - name: checkout plugin
+        uses: actions/checkout@v4
+        with:
+          path: this-plugin
+
+      - name: setup PHP
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: ${{ matrix.php }}
+          ini-values: max_input_vars=5000
+          tools: infection, phpunit
+          coverage: pcov
+
+      - name: composer
+        run: |
+           composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci
+           echo $(cd ci/bin; pwd) >> $GITHUB_PATH
+           echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
+           sudo locale-gen en_AU.UTF-8
+           sudo systemctl start mysql.service
+
+      - name: install Moodle
+        run: moodle-plugin-ci install --db-user=root --db-pass=root --db-host=127.0.0.1 --plugin this-plugin
+        env:
+          DB: ${{ matrix.database }}
+          MOODLE_BRANCH: ${{ matrix.moodle-branch }}
+
+      - name: phpunit warm
+        if: ${{ !cancelled() }}
+        run: moodle-plugin-ci --ansi phpunit --testdox --coverage-text
+
+      - name: autoload
+        working-directory: moodle
+        run: |
+           echo "<?php
+define('PHPUNIT_UTIL', true);
+require(__DIR__ . '/../lib/phpunit/bootstrap.php');
+require('autoload.php');" > vendor/autoloadmoodle.php
+
+      - name: infection
+        if: ${{ !cancelled() }}
+        run: infection -s --only-covered --configuration=availability/condition/language/.infection.json5
+        working-directory: moodle
diff --git a/.infection.json5 b/.infection.json5
new file mode 100644
index 0000000..d0d5700
--- /dev/null
+++ b/.infection.json5
@@ -0,0 +1,17 @@
+{
+    "$schema": "https://raw.githubusercontent.com/infection/infection/0.27.0/resources/schema.json",
+    "source": {
+        "directories": [
+            ".",
+        ],
+    },
+    "mutators": {
+        "@default": true,
+    },
+    "phpUnit": {
+        "configDir": ".",
+        "customPath": "./vendor/bin/phpunit"
+    },
+    "initialTestsPhpOptions": "-dxdebug.mode=off -dpcov.enabled=1 -dpcov.directory=.",
+    "bootstrap": "./vendor/autoloadmoodle.php"
+}