Skip to content

Commit

Permalink
[phalcon#13438] - Correction to the syslog adapter; Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niden authored and CameronHall committed Dec 8, 2018
1 parent 96847b0 commit 4cb7b9f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 19 deletions.
3 changes: 2 additions & 1 deletion phalcon/logger/adapter/syslog.zep
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
namespace Phalcon\Logger\Adapter;

use Phalcon\Logger;
use Phalcon\Logger\Exception;
use Phalcon\Logger\Adapter;
use Phalcon\Logger\Exception;
use Phalcon\Logger\Formatter\FormatterInterface;
use Phalcon\Logger\Item;

/**
* Phalcon\Logger\Adapter\Syslog
Expand Down
67 changes: 50 additions & 17 deletions tests/unit/Logger/Adapter/Syslog/AddCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,61 @@
* file that was distributed with this source code.
*/

namespace Phalcon\Test\Unit\Logger\Adapter\Syslog;

use UnitTester;

/**
* Class AddCest
*
* @package Phalcon\Test\Unit\Logger
* @todo Until I figure this approach, this stays here and can be used for other
* tests in this namespace
*/
class AddCest
{
namespace Phalcon\Test\Unit\Logger\Adapter\Syslog {
function syslog($level, $message)
{
}

function closelog()
{
return true;
}

use Phalcon\Logger;
use Phalcon\Logger\Adapter\Syslog;
use Phalcon\Logger\Item;
use UnitTester;

/**
* Tests Phalcon\Logger\Adapter\Syslog :: add()
* Class AddCest
*
* @param UnitTester $I
*
* @author Phalcon Team <team@phalconphp.com>
* @since 2018-11-13
* @package Phalcon\Test\Unit\Logger
*/
public function loggerAdapterSyslogAdd(UnitTester $I)
class AddCest
{
$I->wantToTest('Logger\Adapter\Syslog - add()');
$I->skipTest('Need implementation');
/**
* Tests Phalcon\Logger\Adapter\Syslog :: add()
*
* @param UnitTester $I
*
* @author Phalcon Team <team@phalconphp.com>
* @since 2018-11-13
*/
public function loggerAdapterSyslogAdd(UnitTester $I)
{
$I->wantToTest('Logger\Adapter\Syslog - add()');
$streamName = $I->getNewFileName('log', 'log');
$adapter = new Syslog($streamName);

$adapter->begin();
$item1 = new Item('Message 1', 'debug', Logger::DEBUG);
$item2 = new Item('Message 2', 'debug', Logger::DEBUG);
$item3 = new Item('Message 3', 'debug', Logger::DEBUG);

$adapter
->add($item1)
->add($item2)
->add($item3)
;

$adapter->commit();

$actual = $adapter->close();
$I->assertTrue($actual);
}
}
}
12 changes: 11 additions & 1 deletion tests/unit/Logger/Adapter/Syslog/ProcessCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

namespace Phalcon\Test\Unit\Logger\Adapter\Syslog;

use Phalcon\Logger;
use Phalcon\Logger\Adapter\Syslog;
use Phalcon\Logger\Item;
use UnitTester;

/**
Expand All @@ -32,6 +35,13 @@ class ProcessCest
public function loggerAdapterSyslogProcess(UnitTester $I)
{
$I->wantToTest('Logger\Adapter\Syslog - process()');
$I->skipTest('Need implementation');
$streamName = $I->getNewFileName('log', 'log');
$adapter = new Syslog($streamName);

$item = new Item('Message 1', 'debug', Logger::DEBUG);
$adapter->process($item);

$actual = $adapter->close();
$I->assertTrue($actual);
}
}

0 comments on commit 4cb7b9f

Please sign in to comment.