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

PHPUnit test for class LoggerTime #5

Merged
merged 3 commits into from
Aug 9, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ updates:
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
interval: "weekly"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#disable temporary and log files and dirs
*.log
/.phpunit.result.cache

#disable composer-managed libraries
/vendor/
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### `Security` in case of vulnerabilities

## [2.0.1] - 2024-08-10
### Added
- PHPUnit test for class LoggerTime

## [2.0] - 2024-07-27
Stable version for `"php": "^7.1 || ^8.0"`. (As of PHP 7.1.0 visibility modifiers are allowed for class constants.)

Expand All @@ -33,7 +37,8 @@ Stable version for `"php": "^5.3 || ^7.0"`
## [0.1] - 2024-07-12
- A [PSR-3](https://www.php-fig.org/psr/psr-3/) compliant logger with adjustable verbosity (based on Backyard\BackyardError)

[Unreleased]: https://github.com/WorkOfStan/seablast-logger/compare/v2.0...HEAD
[Unreleased]: https://github.com/WorkOfStan/seablast-logger/compare/v2.0.1...HEAD
[2.0.1]: https://github.com/WorkOfStan/seablast-logger/compare/v2.0...v2.0.1
[2.0]: https://github.com/WorkOfStan/seablast-logger/compare/v1.0...v2.0
[1.0]: https://github.com/WorkOfStan/seablast-logger/compare/v0.2...v1.0
[0.2]: https://github.com/WorkOfStan/seablast-logger/compare/v0.1...v0.2
Expand Down
88 changes: 88 additions & 0 deletions Test/LoggerTimeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace Seablast\Logger\Test;

use PHPUnit\Framework\TestCase;
use Seablast\Logger\LoggerTime;

/**
* Generated by PHPUnit_SkeletonGenerator on 2016-06-25 at 17:57:37.
*/
class LoggerTimeTest extends TestCase
{
/** @var LoggerTime */
protected $object;

/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*/
protected function setUp(): void
{
error_reporting(E_ALL); // incl E_NOTICE
$this->object = new LoggerTime();
}

/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @return void
*/
protected function tearDown(): void
{
// no action
}

/**
* @covers Seablast\Logger\LoggerTime::getmicrotime
*
* @return void
*/
public function testGetmicrotime(): void
{
$this->assertTrue(is_float($this->object->getmicrotime()));
}

/**
* @covers Seablast\Logger\LoggerTime::getRunningTime
*
* @return void
*/
public function testGetRunningTime(): void
{
$expected = '0.0';

//$this->assertEquals($expected, substr((string) $this->object->getRunningTime(), 0, 3));
$this->assertEquals((float) $expected, (float) substr((string) $this->object->getRunningTime(), 0, 3));
}

/**
* @covers Seablast\Logger\LoggerTime::pageGeneratedIn
*
* @return void
*/
public function testPageGeneratedInDefault(): void
{
$expected = '0.0';

//$this->assertEquals($expected, substr($this->object->pageGeneratedIn(), 0, 3));
$this->assertEquals((float) $expected, (float) substr((string) $this->object->pageGeneratedIn(), 0, 3));
}

/**
* @return void
*/
public function testPageGeneratedInLangString(): void
{
$langStringPageGeneratedIn = "Page Generated in %s";
$expected = 'Page Generated in 0';

$this->assertEquals(
$expected,
substr($this->object->pageGeneratedIn($langStringPageGeneratedIn), 0, strlen($expected))
);
}
}
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"psr/log": "^1.0 || ^2.0 || ^3.0",
"tracy/tracy": "^2.6.0"
},
"require-dev": {
"phpunit/phpunit": "^6 || ^7 || ^8 || ^9 || ^10 || ^11"
},
"license": "MIT",
"authors": [
{
Expand All @@ -28,5 +31,10 @@
"psr-4": {
"Seablast\\Logger\\": ["src/"]
}
},
"autoload-dev": {
"psr-4": {
"Seablast\\Logger\\Test\\": ["Test/"]
}
}
}
14 changes: 14 additions & 0 deletions conf/phpunit-github.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stderr="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./../Test/</directory>
</testsuite>
</testsuites>
</phpunit>
14 changes: 14 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stderr="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./Test/</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 2 additions & 0 deletions src/ErrorLogFailureException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Seablast\Logger;

class ErrorLogFailureException extends \Exception
Expand Down
Loading