unit testing - How do you test loggers? In PHP -
consider following class:
<?php namespace eveonline\logging; use log; use monolog\handler\streamhandler; use monolog\logger; class eveloghandler { public function requestlog($response, $filename) { $streamhandler = new streamhandler(storage_path($filename), logger::info); $loginstance = log::getmonolog(); $loginstance->sethandlers(array($streamhandler)); $loginstance->addinfo('fetched', [$response->getstatuscode(), $response->getbody()->getcontents()]); $response->getbody()->rewind(); } public function messagelog($message, $filename) { $streamhandler = new streamhandler(storage_path($filename), logger::info); $loginstance = log::getmonolog(); $loginstance->sethandlers(array($streamhandler)); $loginstance->addinfo('message', [$message]); } }
now used in library building log out guzzle responses , until have been mocking out class methods.
two things:
how test it? how test class? how verify file written or i?
second part , important storage_path
laravel global function. library separate of laravel. intended used laravel. how around function ??
Comments
Post a Comment