Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coccoinomane/phpunit-log
Log from within your PHPUnit tests
https://github.com/coccoinomane/phpunit-log
Last synced: about 1 month ago
JSON representation
Log from within your PHPUnit tests
- Host: GitHub
- URL: https://github.com/coccoinomane/phpunit-log
- Owner: coccoinomane
- Created: 2023-02-02T09:51:50.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-02T10:18:04.000Z (almost 2 years ago)
- Last Synced: 2024-04-25T21:44:57.940Z (8 months ago)
- Language: PHP
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Defines the `Loggable` trait to log from within your PHPUnit tests.
# Usage
1. Install the package with `composer require --dev coccoinomane/phpunit-log`.
1. Include the trait in your TestCase with `\use PHPUnitLog\Loggable;`.
1. Start logging with `this->log( $message )` or `this->print( $message )`.# Features
- To log a message to screen, call `self::print( $message )`.
- To log a message to file, call `self::log( $message )`.
- The file will be named after the test class and placed in the subfolder _tests/logs_.
- Customize the log folder via the `logsPath` environment variable.
- To delete the log files before each run:
```php
public static function setUpBeforeClass(): void {
static::deleteLogFile();
}
```
- For further customizations, see the docs in [`Loggable`](./src/Loggable.php) or the tests in [`LoggableTest`](./tests/LoggableTest.php).The `Loggable` trait is used by [`WordPressTestCase`](https://github.com/idearia/wp-tests).
# Custom folder for the logs
By default, the log files will be placed in the _tests/logs_ folder; set the `logsPath` environment variable to use a different folder.
You can use both relative and absolute paths.To set `logsPath` in _phpunit.xml_:
```xml
```