Skip to content
Open
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
35 changes: 26 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PHPUnit, PHPCS, Psalm

on: # event list
push: # on push to each of these branches
push:
branches:
- dev
- fix
Expand All @@ -11,8 +11,9 @@ on: # event list
branches:
- dev
- master
- beta

env: # environment variables (available in any part of the action)
env:
PHP_VERSION: 7.4

jobs:
Expand All @@ -28,36 +29,52 @@ jobs:
DB_PASSWORD: root

steps:
# Checkout
- name: Code Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 #

# install PHP
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mbstring, intl, mysqli, xdebug

# Run Composer
- name: Install Dependencies
run: composer install --prefer-dist --no-interaction

# Run MySQL
- name: Run MySQL server
run: sudo systemctl start mysql

- name: Code Checkout
uses: actions/checkout@v4

- name: Make the script files executable
# WP Run
- name: Make WP setup script executable
run: chmod +x ./tests/wp-test-setup.sh

- name: Install WP develop
run: ./tests/wp-test-setup.sh wordpress_test root root localhost latest

- name: Install Dependencies
run: composer i

# Run PHPUnit с coverage
- name: Running tests
env:
CLEANTALK_TEST_API_KEY: ${{ secrets.CLEANTALK_TEST_API_KEY }}
run: composer test

# Load coverage на Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage.clover
fail_ci_if_error: true
flags: unittests
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# Matrix
- name: Matrix notify on failure
if: failure()
uses: Glomberg/matrix-messenger-action@master
Expand Down
23 changes: 23 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
codecov:
require_ci_to_pass: true

coverage:
precision: 2
round: down
range: "20..100"

status:
project: true
patch: true

comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false

ignore:
- vendor/**
- tests/**
- node_modules/**
- "**/*.md"
- lib/Cleantalk/Common/ContactsEncoder/**/*.php
7 changes: 7 additions & 0 deletions lib/Cleantalk/Common/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ public static function httpRequest($url, $data = array(), $presets = array(), $o
* @param array $urls Array of URLs to requests
*
* @return array|bool
* @codeCoverageIgnore
*/
public static function httpMultiRequest($urls, $write_to = '')
{
Expand Down Expand Up @@ -641,7 +642,13 @@ static function ($content, $url) use ($write_to) {
: 'error';
}

/**
* @codeCoverageIgnoreStart
*/
return $content;
/**
* @codeCoverageIgnoreEnd
*/
}
);
}
Expand Down
6 changes: 5 additions & 1 deletion tests/ApbctWP/ContactsEncoder/TestContactsEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ public function setUp()

public function testPlainTextEncodeDecodeSSL()
{
global $apbct;
/**
* @var State $apbct
*/
$apbct->errorDeleteAll();
$encoded_plain = $this->contacts_encoder->encoder->encodeString($this->plain_text);
$this->assertNotEmpty($encoded_plain);
$this->assertIsString($encoded_plain);
$decoded_entity = $this->contacts_encoder->encoder->decodeString($encoded_plain);
$this->assertNotEmpty($decoded_entity);
$this->assertIsString($decoded_entity);
global $apbct;
$this->assertFalse($apbct->isHaveErrors());
$this->assertEquals($decoded_entity, $this->plain_text);
}
Expand Down
20 changes: 0 additions & 20 deletions tests/Common/HelperTest.php

This file was deleted.

12 changes: 10 additions & 2 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="bootstrap.php"
colors="true"
Expand All @@ -16,14 +16,22 @@
</testsuites>

<filter>
<whitelist>
<whitelist processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">../</directory>
<exclude>
<directory>../vendor</directory>
<directory>../tests</directory>
<directory>../node_modules</directory>
<directory>../js</directory>
<directory>../css</directory>
<directory>../lib/Cleantalk/Common/ContactsEncoder</directory>
<file>../bootstrap.php</file>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="coverage.clover"/>
<log type="coverage-text" target="php://stdout"/>
</logging>
</phpunit>