Skip to content

Commit

Permalink
Test file includes and missing config added
Browse files Browse the repository at this point in the history
  • Loading branch information
Kemal Yenilmez committed Jul 18, 2016
1 parent 65051e7 commit 941f311
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 14 deletions.
18 changes: 18 additions & 0 deletions phpunit.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
4 changes: 2 additions & 2 deletions src/Glog.php
Expand Up @@ -98,10 +98,10 @@ protected function connectHttp()
throw new \LogicException('The curl extension is needed to use http URLs');
}

$this->httpConnection = curl_init(config('glog.remote_host', 'http://ap.gazatem.com'));
$this->httpConnection = curl_init(config('glog.remote_host', 'http://test.gazatem.com'));

if (!$this->httpConnection) {
throw new \LogicException('Unable to connect to ' . config('glog.remote_host', 'http://ap.gazatem.com'));
throw new \LogicException('Unable to connect to ' . config('glog.remote_host', 'http://test.gazatem.com'));
}

curl_setopt($this->httpConnection, CURLOPT_POST, "POST");
Expand Down
12 changes: 0 additions & 12 deletions tests/DBLoggerTest.php

This file was deleted.

33 changes: 33 additions & 0 deletions tests/GlogTest.php
@@ -0,0 +1,33 @@
<?php

use Mockery as m;
use Monolog\Logger;


class GlogTest extends TestCase
{

public function testWrite()
{
$record = $this->getRecord(Logger::WARNING, 'log', array('data' => new \stdClass, 'foo' => 34));
$handler = new Gazatem\Glog\Glog();
try{
$handler->handle($record);
}catch (\RuntimeException $e){
$this->markTestSkipped('Log failed!');
}
}

protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array())
{
return array(
'message' => $message,
'context' => $context,
'level' => $level,
'level_name' => Logger::getLevelName($level),
'channel' => 'test',
'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
'extra' => array(),
);
}
}

0 comments on commit 941f311

Please sign in to comment.