summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Horrigan <dan@dhorrigan.com>2014-03-18 09:21:22 -0400
committerDan Horrigan <dan@dhorrigan.com>2014-03-18 09:21:22 -0400
commit98e94467c3e967e1277024c007dc20e8237e4027 (patch)
tree05c7e409196bb136d950de2ab1fe52a6e7e7cab0
parentcda35d293d9c4cbb64c2839fdea68ffe60518dc3 (diff)
downloadKLogger-98e94467c3e967e1277024c007dc20e8237e4027.zip
KLogger-98e94467c3e967e1277024c007dc20e8237e4027.tar.gz
KLogger-98e94467c3e967e1277024c007dc20e8237e4027.tar.bz2
Preparing for Unit Tests.
-rw-r--r--.gitignore6
-rw-r--r--composer.json3
-rwxr-xr-xexample/example.php21
-rw-r--r--phpunit.xml18
-rw-r--r--tests/LoggerTest.php20
-rw-r--r--tests/logs/.gitkeep0
6 files changed, 42 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index 6d37e8d..b8128aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,3 @@
-src/test.php
-test/
-test/*
-test.php
-
+/tests/logs/*.txt
/vendor/
composer.lock \ No newline at end of file
diff --git a/composer.json b/composer.json
index a24f841..f7e7a61 100644
--- a/composer.json
+++ b/composer.json
@@ -4,6 +4,9 @@
"require": {
"psr/log": "1.0.0"
},
+ "require-dev": {
+ "phpunit/phpunit": "4.0.*"
+ },
"license": "MIT",
"authors": [
{
diff --git a/example/example.php b/example/example.php
deleted file mode 100755
index 4714021..0000000
--- a/example/example.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-
-# Should log to the same directory as this file
-require dirname(__FILE__).'/../vendor/autoload.php';
-
-$obj = new stdClass();
-$obj->foo = 'bar';
-$log = new Katzgrau\KLogger\Logger(dirname(__FILE__), Psr\Log\LogLevel::DEBUG);
-$args1 = array('a' => array('b' => 'c'), 'd' => null, 'e' => $obj);
-$args2 = NULL;
-
-$log->emergency('Emergency Test');
-$log->alert('Alert Test');
-$log->critical('Critical Test');
-$log->error('Error Test');
-$log->warning('Warning Test');
-$log->notice('Notice Test');
-$log->info('Info Test');
-$log->debug('Debug Test');
-
-$log->info('Testing passing an array or object', $args1);
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 0000000..3a470a0
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit colors="true"
+ stopOnFailure="false"
+ bootstrap="./vendor/autoload.php"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true">
+ <testsuites>
+ <testsuite name="common">
+ <directory suffix="Test.php">tests</directory>
+ </testsuite>
+ </testsuites>
+ <filter>
+ <blacklist>
+ <directory>./vendor</directory>
+ </blacklist>
+ </filter>
+</phpunit>
diff --git a/tests/LoggerTest.php b/tests/LoggerTest.php
new file mode 100644
index 0000000..ebe65d8
--- /dev/null
+++ b/tests/LoggerTest.php
@@ -0,0 +1,20 @@
+<?php
+
+use Katzgrau\KLogger\Logger;
+
+class LoggerTest extends PHPUnit_Framework_TestCase
+{
+ private $logPath;
+ private $logger;
+
+ public function setUp()
+ {
+ $this->logPath = __DIR__.'/logs';
+ $this->logger = new Logger($this->logPath);
+ }
+
+ public function testImplementsPsr3LoggerInterface()
+ {
+ $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->logger);
+ }
+}
diff --git a/tests/logs/.gitkeep b/tests/logs/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/logs/.gitkeep