Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(wip) SimpleFormatterTest #18

Draft
wants to merge 44 commits into
base: FRAMEWORK_6_0
Choose a base branch
from
Draft
Changes from 5 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2fda405
no errors, but two risky tests left
marcoabbrancati Mar 10, 2021
7c0a71b
no errors left
marcoabbrancati Mar 15, 2021
8f688b3
added condition to bootstrap.php
marcoabbrancati Mar 19, 2021
d64b1d2
no errors, added ci.yml
marcoabbrancati Mar 23, 2021
e6bf458
Merge pull request #1 from marcoabbrancati/FRAMEWORK_6_0
marcoabbrancati Mar 30, 2021
596dfaa
Update ci.yml
marcoabbrancati Mar 30, 2021
2538549
Update ci.yml
marcoabbrancati Mar 30, 2021
957c0b2
Update bootstrap.php
marcoabbrancati Mar 30, 2021
2b4b18f
Add CI job for satis repo update
Jul 15, 2021
0e724b3
Allow PHP 8, move Unit tests to own namespace
ralflang Aug 5, 2021
eae528c
New PSR-3 compatible logger design
ralflang Nov 21, 2021
99fa36e
Released Log-3.0.0alpha4
ralflang Nov 21, 2021
24c0285
Development mode for Log-3.0.0alpha5
ralflang Nov 21, 2021
3e30713
Add latest php version
ralflang Nov 21, 2021
16dd288
Formatting
ralflang Nov 21, 2021
3007654
unittests and fix for MaximumLevelFilter
midahp Nov 22, 2021
e6a5604
added paths to gitignore
midahp Nov 22, 2021
e3a0b20
fixed FirebugHandler buffer type/hint
midahp Nov 22, 2021
fbc06e9
Merge pull request #2 from midahp/FRAMEWORK_6_0
ralflang Nov 22, 2021
081fa21
wip MinimumLevelFilterTest außer es stimmt alles
moritz2111 Nov 22, 2021
7e161aa
Merge pull request #6 from moritz2111/FRAMEWORK_6_0
ralflang Nov 22, 2021
e10b006
Add a wrapper for other PSR-3 loggers
ralflang Nov 22, 2021
f072526
Add a builder for logger setups
ralflang Nov 22, 2021
c5f8f89
Update workflows
ralflang Nov 22, 2021
b696b35
Added fixes unittests for ExactLevelFilter
daweeb Nov 23, 2021
8dff5cb
unittests for CliFormatter
boekhorstb1 Nov 24, 2021
38ea35b
Unittests for ConstraintFilter, MessageFilter and SuppressFilter
boekhorstb1 Nov 24, 2021
43a9f76
This one is actually new and not by Mike.
ralflang Nov 24, 2021
a783a47
PHP 8 Compatibility
ralflang Nov 24, 2021
26ea7cd
Even stricter error handling for edge cases.
ralflang Nov 24, 2021
71e713d
Make options real objects
ralflang Nov 27, 2021
af97758
Released Log-3.0.0alpha5
ralflang Nov 28, 2021
393bd16
Development mode for Log-3.0.0alpha6
ralflang Nov 28, 2021
8e0f1ca
automatic generation of composer.json - [ci skip]
Nov 28, 2021
efa7108
wip SimpleFormatterTestt
moritz2111 Dec 2, 2021
61e1cd1
SimpleFormatterTest
moritz2111 Dec 13, 2021
6334aa6
SimpleFormatterTest (glaube Fertig)
moritz2111 Dec 21, 2021
7aa508a
SimpleFormatterTest (glaub fertig)
moritz2111 Dec 21, 2021
807f06f
SimpleFormatterTest (glaub fertig)
moritz2111 Dec 21, 2021
f9109fb
wip SimpleFormatterTest
moritz2111 Dec 22, 2021
93de326
wip SimpleFormatterTest
moritz2111 Dec 22, 2021
7839551
wip SimpleFormatterTest
moritz2111 Dec 22, 2021
6f9d8fc
wip SimpleFormatterTest
moritz2111 Dec 22, 2021
30c6107
SimpleFormatterTest finished
moritz2111 Dec 23, 2021
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
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches:
- master
- maintaina-composerfixed
- FRAMEWORK_6_0
pull_request:
branches:
- master
- maintaina-composerfixed
- FRAMEWORK_6_0


# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-20.04']
php-versions: ['7.4']
phpunit-versions: ['latest', '9.5', '9.0']
steps:
- name: Setup github ssh key
run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter
ini-values: post_max_size=512M, max_execution_time=360
coverage: xdebug
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2
- name: Setup Github Token as composer credential
run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- name: Install horde/test dependency and other dependencies
run: |
## For unclear reasons, github action fails randomly if we do not install before we require.
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer require --dev horde/test dev-FRAMEWORK_6_0 horde/log dev-FRAMEWORK_6_0
- name: run phpunit
run: phpunit --bootstrap test/Horde/Log/bootstrap.php test/Horde/Log/
69 changes: 69 additions & 0 deletions .github/workflows/phpdoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This is a basic workflow to help you get started with Actions

name: PHPDOC

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches:
- master
- maintaina-composerfixed
- FRAMEWORK_6_0
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
run:
runs-on: ubuntu-20.04
steps:
- name: Setup github ssh key
run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
- name: Setup uut dir
run: |
export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
export UUT_DIR=$(pwd)
export WORK_DIR=~
export BIN_DIR="${WORK_DIR}/bin"
mkdir -p $BIN_DIR
git config --global user.name "PHPDOC CI Job"
git config --global user.email "[email protected]"
- name: Checkout
uses: actions/checkout@v2
- name: Checkout Doc Dir
uses: actions/checkout@v2
with:
repository: maintaina/phpdoc
token: ${{secrets.PHPDOC_TOKEN}}
path: "phpdoc-git"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter
ini-values: post_max_size=512M, max_execution_time=360
coverage: xdebug
tools: composer:v2
- name: Setup Github Token as composer credential
run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- name: phpdocumentor run
run: |
export UUT_DIR=$(pwd)
export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
export WORK_DIR=/home/runner/
export BIN_DIR="${WORK_DIR}/bin"
wget https://phpdoc.org/phpDocumentor.phar
mkdir "${WORK_DIR}/phpdoc-out"
mv phpDocumentor.phar $BIN_DIR/phpdocumentor
chmod +x "${BIN_DIR}/phpdocumentor"
echo "Creating UUT related dir in docu repo"
mkdir -p $UUT_DIR/phpdoc-git/${GITHUB_REF##*/}/${REPO}/
## TODO: check for and include lib, src, app (if they exist) but not test or script dirs
$BIN_DIR/phpdocumentor -d $UUT_DIR/lib/ -t "${UUT_DIR}/phpdoc-git/${GITHUB_REF##*/}/${REPO}/"
cd ${UUT_DIR}/phpdoc-git
git add "${GITHUB_REF##*/}/${REPO}"
php indexer.php ${GITHUB_REF##*/} $REPO
git add index.html index.json
git commit -m "Updated phpdoc for $GITHUB_REPOSITORY (${GITHUB_REF##*/} branch) from ci"
git push
4 changes: 3 additions & 1 deletion test/Horde/Log/AllTests.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php
require_once 'Horde/Test/AllTests.php';
if (!class_exists('Horde_Test_AllTests')) {
require_once 'Horde/Test/AllTests.php';
}
Horde_Test_AllTests::init(__FILE__)->run();
24 changes: 15 additions & 9 deletions test/Horde/Log/Filter/ChainingTest.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,12 @@
* @package Log
* @subpackage UnitTests
*/
namespace Horde\Log;
use \Filter;
use \PHPUnit\Framework\TestCase;
use \Horde_Log;
use \Horde_Log_Logger;
use \Horde_Log_Handler_Stream;

/**
* @author Mike Naberezny <[email protected]>
@@ -22,9 +28,9 @@
* @package Log
* @subpackage UnitTests
*/
class Horde_Log_Filter_ChainingTest extends PHPUnit_Framework_TestCase
class ChainingTest extends TestCase
{
public function setUp()
public function setUp(): void
{
date_default_timezone_set('America/New_York');

@@ -33,7 +39,7 @@ public function setUp()
$this->logger->addHandler(new Horde_Log_Handler_Stream($this->log));
}

public function tearDown()
public function tearDown(): void
{
fclose($this->log);
}
@@ -49,8 +55,8 @@ public function testFilterAllHandlers()
rewind($this->log);
$logdata = stream_get_contents($this->log);

$this->assertNotContains($ignored, $logdata);
$this->assertContains($logged, $logdata);
$this->assertStringNotContainsString($ignored, $logdata);
$this->assertStringContainsString($logged, $logdata);
}


@@ -67,13 +73,13 @@ public function testFilterOnSpecificHandler()

rewind($this->log);
$logdata = stream_get_contents($this->log);
$this->assertContains($warn, $logdata);
$this->assertContains($err, $logdata);
$this->assertStringContainsString($warn, $logdata);
$this->assertStringContainsString($err, $logdata);

rewind($log2);
$logdata = stream_get_contents($log2);
$this->assertContains($err, $logdata);
$this->assertNotContains($warn, $logdata);
$this->assertStringContainsString($err, $logdata);
$this->assertStringNotContainsString($warn, $logdata);
}

}
13 changes: 9 additions & 4 deletions test/Horde/Log/Filter/ConstraintTest.php
Original file line number Diff line number Diff line change
@@ -8,6 +8,11 @@
* @package Log
* @subpackage UnitTests
*/
namespace Horde\Log;
use \Filter;
Use \Horde_Test_Case;
use \Horde_Log_Filter_Constraint;
use \Horde_Constraint_AlwaysFalse;

/**
* @author James Pepin <[email protected]>
@@ -16,7 +21,7 @@
* @package Log
* @subpackage UnitTests
*/
class Horde_Log_Filter_ConstraintTest extends Horde_Test_Case
class ConstraintTest extends Horde_Test_Case
{
public function testFilterDoesNotAcceptWhenRequiredFieldIsMissing()
{
@@ -67,7 +72,7 @@ public function testFilterAcceptsWhenRegex_DOESNOT_MatcheField()

private function getConstraintMock($returnVal)
{
$const = $this->getMock('Horde_Constraint', array('evaluate'));
$const = $this->getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
$const->expects($this->once())
->method('evaluate')
->will($this->returnValue($returnVal));
@@ -90,7 +95,7 @@ public function testFilterStopsWhenItFindsAFalseCondition()
$filterator->addConstraint('fieldname', $this->getConstraintMock(true));
$filterator->addConstraint('fieldname', new Horde_Constraint_AlwaysFalse());

$const = $this->getMock('Horde_Constraint', array('evaluate'));
$const = $this->getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
$const->expects($this->never())
->method('evaluate');
$filterator->addConstraint('fieldname', $const);
@@ -101,7 +106,7 @@ public function testFilterStopsWhenItFindsAFalseCondition()
public function testFilterAcceptCallsConstraintOnNullWhenFieldDoesnotExist()
{
$filterator = new Horde_Log_Filter_Constraint();
$const = $this->getMock('Horde_Constraint', array('evaluate'));
$const = $this->getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
$const->expects($this->once())
->method('evaluate')
->with(null);
18 changes: 9 additions & 9 deletions test/Horde/Log/Filter/ExactLevelTest.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,11 @@
* @package Log
* @subpackage UnitTests
*/
namespace Horde\Log;
use \Filter;
use \PHPUnit\Framework\TestCase;
use \Horde_Log_Filter_Level;
use \Horde_Log_Filter_ExactLevel;

/**
* @author Mike Naberezny <[email protected]>
@@ -22,9 +27,9 @@
* @package Log
* @subpackage UnitTests
*/
class Horde_Log_Filter_ExactLevelTest extends PHPUnit_Framework_TestCase
class ExactLevelTest extends TestCase
{
public function setUp()
public function setUp(): void
{
// accept at and only at level 2
$this->filter = new Horde_Log_Filter_ExactLevel(2);
@@ -43,12 +48,7 @@ public function testLevelFilterReject()

public function testConstructorThrowsOnInvalidLevel()
{
try {
new Horde_Log_Filter_Level('foo');
$this->fail();
} catch (Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e);
$this->assertRegExp('/must be an integer/i', $e->getMessage());
}
$this->expectException('InvalidArgumentException');
new Horde_Log_Filter_Level('foo');
}
}
16 changes: 7 additions & 9 deletions test/Horde/Log/Filter/LevelTest.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,9 @@
* @package Log
* @subpackage UnitTests
*/
namespace Horde\Log\Filter;
use \PHPUnit\Framework\TestCase;
use \Horde_Log_Filter_Level;

/**
* @author Mike Naberezny <[email protected]>
@@ -22,9 +25,9 @@
* @package Log
* @subpackage UnitTests
*/
class Horde_Log_Filter_LevelTest extends PHPUnit_Framework_TestCase
class LevelTest extends TestCase
{
public function setUp()
public function setUp(): void
{
// accept at or below level 2
$this->filter = new Horde_Log_Filter_Level(2);
@@ -43,12 +46,7 @@ public function testLevelFilterReject()

public function testConstructorThrowsOnInvalidLevel()
{
try {
new Horde_Log_Filter_Level('foo');
$this->fail();
} catch (Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e);
$this->assertRegExp('/must be an integer/i', $e->getMessage());
}
$this->expectException('InvalidArgumentException');
new Horde_Log_Filter_Level('foo');
}
}
13 changes: 6 additions & 7 deletions test/Horde/Log/Filter/MessageTest.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,9 @@
* @package Log
* @subpackage UnitTests
*/
namespace Horde\Log\Filter;
use \PHPUnit\Framework\TestCase;
use \Horde_Log_Filter_Message;

/**
* @author Mike Naberezny <[email protected]>
@@ -22,17 +25,13 @@
* @package Log
* @subpackage UnitTests
*/
class Horde_Log_Filter_MessageTest extends PHPUnit_Framework_TestCase
class MessageTest extends TestCase
{

public function testMessageFilterRecognizesInvalidRegularExpression()
{
try {
$filter = new Horde_Log_Filter_Message('invalid regexp');
$this->fail();
} catch (InvalidArgumentException $e) {
$this->assertRegexp('/invalid reg/i', $e->getMessage());
}
$this->expectException('InvalidArgumentException');
new Horde_Log_Filter_Message('invalid regexp');
}

public function testMessageFilter()
7 changes: 5 additions & 2 deletions test/Horde/Log/Filter/SuppressTest.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,9 @@
* @package Log
* @subpackage UnitTests
*/
namespace Horde\Log\Filter;
use \PHPUnit\Framework\TestCase;
use \Horde_Log_Filter_Suppress;

/**
* @author Mike Naberezny <[email protected]>
@@ -22,9 +25,9 @@
* @package Log
* @subpackage UnitTests
*/
class Horde_Log_Filter_SuppressTest extends PHPUnit_Framework_TestCase
class SuppressTest extends TestCase
{
public function setUp()
public function setUp(): void
{
$this->filter = new Horde_Log_Filter_Suppress();
}
Loading