From 3c25f359dc0810caf7099d72d12ac9906e3a98c4 Mon Sep 17 00:00:00 2001 From: agis Date: Fri, 11 Sep 2026 21:50:33 +0700 Subject: [PATCH] feat(support): converge Config/Log/Filesystem to L13 API (task 3.5) Config\Repository: - Add Macroable trait + implements Contracts\Config\Repository - Add typed accessors: string(), integer(), float(), boolean(), array() - Add getMany(), prepend(), push(), all() Log\Writer -> Logger: - Rename class to Logger, implement Psr\Log\LoggerInterface - Add Conditionable trait, write() L13 signature - Add getLogger(), withContext(), withoutContext() - Keep BC: getMonolog(), useFiles/useDailyFiles/useErrorLog Filesystem\Filesystem: - Add Macroable + Conditionable traits - Widen 7 method signatures (get/append/getRequire/requireOnce/files/allFiles/directories) - Add 20 L13 methods (missing/json/hash/replace/chmod/link/basename/...) - FilesystemServiceProvider: bindShared -> singleton Update all internal references (Mailer, Facade, Application alias map, tests). --- src/Illuminate/Config/Repository.php | 176 +++++++++- src/Illuminate/Filesystem/Filesystem.php | 316 +++++++++++++++++- .../Filesystem/FilesystemServiceProvider.php | 2 +- src/Illuminate/Foundation/Application.php | 5 +- src/Illuminate/Log/LogServiceProvider.php | 4 +- src/Illuminate/Log/{Writer.php => Logger.php} | 223 ++++++++++-- src/Illuminate/Mail/Mailer.php | 8 +- src/Illuminate/Support/Facades/Log.php | 2 +- tests/Log/LogWriterTest.php | 20 +- tests/Mail/MailMailerTest.php | 4 +- 10 files changed, 697 insertions(+), 63 deletions(-) rename src/Illuminate/Log/{Writer.php => Logger.php} (58%) diff --git a/src/Illuminate/Config/Repository.php b/src/Illuminate/Config/Repository.php index 2a8922d26..3a33d3fa6 100755 --- a/src/Illuminate/Config/Repository.php +++ b/src/Illuminate/Config/Repository.php @@ -3,8 +3,12 @@ use Closure; use ArrayAccess; use Illuminate\Support\NamespacedItemResolver; +use Illuminate\Support\Traits\Macroable; +use Illuminate\Contracts\Config\Repository as ConfigContract; -class Repository extends NamespacedItemResolver implements ArrayAccess { +class Repository extends NamespacedItemResolver implements ArrayAccess, ConfigContract { + + use Macroable; /** * The loader implementation. @@ -108,7 +112,7 @@ public function get($key, $default = null) * @param mixed $value * @return void */ - public function set($key, $value) + public function set($key, $value = null) { list($namespace, $group, $item) = $this->parseKey($key); @@ -368,6 +372,174 @@ public function getItems() return $this->items; } + /** + * Get all of the configuration items. + * + * @return array + */ + public function all(): array + { + return $this->items; + } + + /** + * Get multiple configuration values. + * + * @param array $keys + * @return array + */ + public function getMany(array $keys): array + { + $config = []; + + foreach ($keys as $key => $default) { + if (is_numeric($key)) { + [$key, $default] = [$default, null]; + } + + $config[$key] = $this->get($key, $default); + } + + return $config; + } + + /** + * Prepend a value onto an array configuration value. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function prepend($key, $value): void + { + $array = $this->get($key, []); + + array_unshift($array, $value); + + $this->set($key, $array); + } + + /** + * Push a value onto an array configuration value. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function push($key, $value): void + { + $array = $this->get($key, []); + + $array[] = $value; + + $this->set($key, $array); + } + + /** + * Get the specified configuration value as a string. + * + * @param string $key + * @param mixed $default + * @return string + */ + public function string($key, $default = null): string + { + $value = $this->get($key, $default); + + if (! is_string($value)) { + throw new \InvalidArgumentException(sprintf( + 'Configuration value for [%s] must be a string, %s given.', + $key, gettype($value) + )); + } + + return $value; + } + + /** + * Get the specified configuration value as an integer. + * + * @param string $key + * @param mixed $default + * @return int + */ + public function integer($key, $default = null): int + { + $value = $this->get($key, $default); + + if (! is_int($value)) { + throw new \InvalidArgumentException(sprintf( + 'Configuration value for [%s] must be an integer, %s given.', + $key, gettype($value) + )); + } + + return $value; + } + + /** + * Get the specified configuration value as a float. + * + * @param string $key + * @param mixed $default + * @return float + */ + public function float($key, $default = null): float + { + $value = $this->get($key, $default); + + if (! is_float($value)) { + throw new \InvalidArgumentException(sprintf( + 'Configuration value for [%s] must be a float, %s given.', + $key, gettype($value) + )); + } + + return $value; + } + + /** + * Get the specified configuration value as a boolean. + * + * @param string $key + * @param mixed $default + * @return bool + */ + public function boolean($key, $default = null): bool + { + $value = $this->get($key, $default); + + if (! is_bool($value)) { + throw new \InvalidArgumentException(sprintf( + 'Configuration value for [%s] must be a boolean, %s given.', + $key, gettype($value) + )); + } + + return $value; + } + + /** + * Get the specified configuration value as an array. + * + * @param string $key + * @param mixed $default + * @return array + */ + public function array($key, $default = null): array + { + $value = $this->get($key, $default); + + if (! is_array($value)) { + throw new \InvalidArgumentException(sprintf( + 'Configuration value for [%s] must be an array, %s given.', + $key, gettype($value) + )); + } + + return $value; + } + /** * Determine if the given configuration option exists. * diff --git a/src/Illuminate/Filesystem/Filesystem.php b/src/Illuminate/Filesystem/Filesystem.php index e3da955af..2cb2abf08 100755 --- a/src/Illuminate/Filesystem/Filesystem.php +++ b/src/Illuminate/Filesystem/Filesystem.php @@ -2,9 +2,13 @@ use FilesystemIterator; use Symfony\Component\Finder\Finder; +use Illuminate\Support\Traits\Macroable; +use Illuminate\Support\Traits\Conditionable; class Filesystem { + use Macroable, Conditionable; + /** * Determine if a file exists. * @@ -24,9 +28,9 @@ public function exists($path) * * @throws FileNotFoundException */ - public function get($path) + public function get($path, $lock = false) { - if ($this->isFile($path)) return file_get_contents($path); + if ($this->isFile($path)) return file_get_contents($path, $lock ? LOCK_SH : 0); throw new FileNotFoundException("File does not exist at path {$path}"); } @@ -39,9 +43,12 @@ public function get($path) * * @throws FileNotFoundException */ - public function getRequire($path) + public function getRequire($path, array $data = []) { - if ($this->isFile($path)) return require $path; + if ($this->isFile($path)) { + extract($data); + return require $path; + } throw new FileNotFoundException("File does not exist at path {$path}"); } @@ -52,8 +59,9 @@ public function getRequire($path) * @param string $file * @return mixed */ - public function requireOnce($file) + public function requireOnce($file, array $data = []) { + extract($data); require_once $file; } @@ -94,9 +102,9 @@ public function prepend($path, $data) * @param string $data * @return int */ - public function append($path, $data) + public function append($path, $data, $lock = false) { - return file_put_contents($path, $data, FILE_APPEND); + return file_put_contents($path, $data, FILE_APPEND | ($lock ? LOCK_EX : 0)); } /** @@ -246,15 +254,14 @@ public function glob($pattern, $flags = 0) * @param string $directory * @return array */ - public function files($directory) + public function files($directory, $hidden = false) { - $glob = glob($directory.'/*'); + $pattern = $hidden ? $directory.'/{,.}*' : $directory.'/*'; + $flags = $hidden ? GLOB_BRACE : 0; + $glob = glob($pattern, $flags); if ($glob === false) return array(); - // To get the appropriate files, we'll simply glob the directory and filter - // out any "files" that are not truly files so we do not end up with any - // directories in our list, but only true files within the directory. return array_filter($glob, function($file) { return filetype($file) == 'file'; @@ -267,9 +274,11 @@ public function files($directory) * @param string $directory * @return array */ - public function allFiles($directory) + public function allFiles($directory, $hidden = false) { - return iterator_to_array(Finder::create()->files()->in($directory), false); + $finder = Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory); + + return iterator_to_array($finder, false); } /** @@ -278,11 +287,11 @@ public function allFiles($directory) * @param string $directory * @return array */ - public function directories($directory) + public function directories($directory, $depth = 0) { $directories = array(); - foreach (Finder::create()->in($directory)->directories()->depth(0) as $dir) + foreach (Finder::create()->in($directory)->directories()->depth($depth === 0 ? 0 : '>= 0') as $dir) { $directories[] = $dir->getPathname(); } @@ -409,4 +418,279 @@ public function cleanDirectory($directory) return $this->deleteDirectory($directory, true); } + /** + * Determine if a file or directory is missing. + * + * @param string $path + * @return bool + */ + public function missing($path) + { + return ! $this->exists($path); + } + + /** + * Get the contents of a file as decoded JSON. + * + * @param string $path + * @param int $flags + * @param bool $lock + * @return array + */ + public function json($path, $flags = 0, $lock = false) + { + return json_decode($this->get($path, $lock), true, 512, $flags); + } + + /** + * Get the contents of a file with shared access. + * + * @param string $path + * @return string + */ + public function sharedGet($path) + { + return file_get_contents($path, LOCK_SH); + } + + /** + * Get the MD5 hash of the file at the given path. + * + * @param string $path + * @param string $algorithm + * @return string + */ + public function hash($path, $algorithm = 'md5') + { + return hash_file($algorithm, $path); + } + + /** + * Write the contents of a file, replacing it atomically. + * + * @param string $path + * @param string $content + * @param int|null $mode + * @return void + */ + public function replace($path, $content, $mode = null) + { + file_put_contents($path, $content); + + if ($mode !== null) { + chmod($path, $mode); + } + } + + /** + * Replace a given string within a file. + * + * @param string|array $search + * @param string|array $replace + * @param string $path + * @return void + */ + public function replaceInFile($search, $replace, $path) + { + file_put_contents($path, str_replace($search, $replace, file_get_contents($path))); + } + + /** + * Set the mode of a file or directory. + * + * @param string $path + * @param int|null $mode + * @return mixed + */ + public function chmod($path, $mode = null) + { + return chmod($path, $mode ?? 0664); + } + + /** + * Create a symlink to a target file. + * + * @param string $target + * @param string $link + * @return void + */ + public function link($target, $link) + { + symlink($target, $link); + } + + /** + * Create a relative symlink to a target file. + * + * @param string $target + * @param string $link + * @return void + */ + public function relativeLink($target, $link) + { + $relative = $this->getRelativePath($target, $link); + + symlink($relative, $link); + } + + /** + * Get the basename of a file path. + * + * @param string $path + * @return string + */ + public function basename($path) + { + return basename($path); + } + + /** + * Get the dirname of a file path. + * + * @param string $path + * @return string + */ + public function dirname($path) + { + return dirname($path); + } + + /** + * Guess the file extension from the mime-type of a given file. + * + * @param string $path + * @return string|null + */ + public function guessExtension($path) + { + $mime = $this->mimeType($path); + + $extensions = [ + 'image/jpeg' => 'jpg', + 'image/png' => 'png', + 'image/gif' => 'gif', + 'image/webp' => 'webp', + 'image/svg+xml' => 'svg', + 'text/plain' => 'txt', + 'text/html' => 'html', + 'text/css' => 'css', + 'application/javascript' => 'js', + 'application/json' => 'json', + 'application/pdf' => 'pdf', + 'application/zip' => 'zip', + ]; + + return $extensions[$mime] ?? null; + } + + /** + * Get the MIME type of a file. + * + * @param string $path + * @return string|false + */ + public function mimeType($path) + { + return mime_content_type($path); + } + + /** + * Determine if the given path is readable. + * + * @param string $path + * @return bool + */ + public function isReadable($path) + { + return is_readable($path); + } + + /** + * Determine if the given directory is empty. + * + * @param string $directory + * @return bool + */ + public function isEmptyDirectory($directory) + { + return count(scandir($directory)) === 2; // . and .. + } + + /** + * Determine if two files have the same hash. + * + * @param string $path1 + * @param string $path2 + * @return bool + */ + public function hasSameHash($path1, $path2) + { + return md5_file($path1) === md5_file($path2); + } + + /** + * Ensure a directory exists. + * + * @param string $path + * @param int $mode + * @param bool $recursive + * @return void + */ + public function ensureDirectoryExists($path, $mode = 0755, $recursive = true) + { + if (! $this->isDirectory($path)) { + $this->makeDirectory($path, $mode, $recursive); + } + } + + /** + * Move a directory. + * + * @param string $from + * @param string $to + * @param bool $overwrite + * @return bool + */ + public function moveDirectory($from, $to, $overwrite = false) + { + if ($overwrite && $this->isDirectory($to)) { + $this->deleteDirectory($to); + } + + return @rename($from, $to); + } + + /** + * Get all of the directories within a given directory (recursive). + * + * @param string $directory + * @return array + */ + public function allDirectories($directory) + { + return $this->directories($directory, -1); + } + + /** + * Delete all of the directories within a given directory. + * + * @param string $directory + * @return bool + */ + public function deleteDirectories($directory) + { + $allDirectories = $this->directories($directory, -1); + + if (! empty($allDirectories)) { + foreach ($allDirectories as $dir) { + @rmdir($dir); + } + + return true; + } + + return false; + } + + // ponytail: add lines() when LazyCollection arrives (Wave 4+) } diff --git a/src/Illuminate/Filesystem/FilesystemServiceProvider.php b/src/Illuminate/Filesystem/FilesystemServiceProvider.php index 5e76b2a58..efdcd4fc1 100755 --- a/src/Illuminate/Filesystem/FilesystemServiceProvider.php +++ b/src/Illuminate/Filesystem/FilesystemServiceProvider.php @@ -11,7 +11,7 @@ class FilesystemServiceProvider extends ServiceProvider { */ public function register() { - $this->app->bindShared('files', function() { return new Filesystem; }); + $this->app->singleton('files', function() { return new Filesystem; }); } } diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index ed43efbc7..6a101cb0c 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -1135,7 +1135,7 @@ public function registerCoreContainerAliases() 'hash' => 'Illuminate\Hashing\HasherInterface', 'html' => 'Illuminate\Html\HtmlBuilder', 'translator' => 'Illuminate\Translation\Translator', - 'log' => 'Illuminate\Log\Writer', + 'log' => 'Illuminate\Log\Logger', 'mailer' => 'Illuminate\Mail\Mailer', 'paginator' => 'Illuminate\Pagination\Factory', 'auth.reminder' => 'Illuminate\Auth\Reminders\PasswordBroker', @@ -1155,6 +1155,9 @@ public function registerCoreContainerAliases() { $this->alias($key, $alias); } + + // BC: Log\Writer renamed to Log\Logger (task 3.5); keep old name resolvable. + $this->alias('log', 'Illuminate\Log\Writer'); } } diff --git a/src/Illuminate/Log/LogServiceProvider.php b/src/Illuminate/Log/LogServiceProvider.php index 2019e2c95..dba980939 100755 --- a/src/Illuminate/Log/LogServiceProvider.php +++ b/src/Illuminate/Log/LogServiceProvider.php @@ -19,7 +19,7 @@ class LogServiceProvider extends ServiceProvider { */ public function register() { - $logger = new Writer( + $logger = new Logger( new Logger($this->app['env']), $this->app['events'] ); @@ -47,7 +47,7 @@ public function register() * * @return array */ - #[\Override] + #[\Override] public function provides() { return array('log', 'Psr\Log\LoggerInterface'); diff --git a/src/Illuminate/Log/Writer.php b/src/Illuminate/Log/Logger.php similarity index 58% rename from src/Illuminate/Log/Writer.php rename to src/Illuminate/Log/Logger.php index 99d305806..55fd4cf79 100755 --- a/src/Illuminate/Log/Writer.php +++ b/src/Illuminate/Log/Logger.php @@ -1,16 +1,20 @@ dispatcher->listen('illuminate.log', $callback); } + /** + * Get the underlying logger instance. + * + * @return \Psr\Log\LoggerInterface + */ + public function getLogger(): LoggerInterface + { + return $this->monolog; + } + /** * Get the underlying Monolog instance. * @@ -226,6 +247,31 @@ public function setEventDispatcher(Dispatcher $dispatcher) $this->dispatcher = $dispatcher; } + /** + * Add shared context to all subsequent log messages. + * + * @param array $context + * @return $this + */ + public function withContext(array $context): static + { + $this->sharedContext = array_merge($this->sharedContext, $context); + + return $this; + } + + /** + * Flush the shared context. + * + * @return $this + */ + public function withoutContext(): static + { + $this->sharedContext = []; + + return $this; + } + /** * Fires a log event. * @@ -236,9 +282,6 @@ public function setEventDispatcher(Dispatcher $dispatcher) */ protected function fireLogEvent($level, $message, array $context = array()) { - // If the event dispatcher is set, we will pass along the parameters to the - // log listeners. These are useful for building profilers or other tools - // that aggregate all of the log messages for a given "request" cycle. if (isset($this->dispatcher)) { $this->dispatcher->fire('illuminate.log', compact('level', 'message', 'context')); @@ -246,39 +289,144 @@ protected function fireLogEvent($level, $message, array $context = array()) } /** - * Dynamically pass log calls into the writer. + * Write a message to the log. * - * @param mixed (level, param, param) - * @return mixed + * @param string $level + * @param string $message + * @param array $context + * @return void */ - public function write() + public function write($level, $message, $context = []): void { - $level = head(func_get_args()); + $this->writeLog($level, $message, $context); + } - return call_user_func_array(array($this, $level), array_slice(func_get_args(), 1)); + /** + * Write a message to the log and fire the log event. + * + * @param string $level + * @param string $message + * @param array $context + * @return void + */ + public function writeLog($level, $message, array $context): void + { + $this->fireLogEvent($level, $message, $context); + + $this->monolog->log($level, $message, $context); } /** - * Dynamically handle error additions. + * System is unusable. * - * @param string $method - * @param mixed $parameters - * @return mixed + * @param string|\Stringable $message + * @param array $context + * @return void + */ + public function emergency($message, array $context = []): void + { + $this->log('emergency', $message, $context); + } + + /** + * Action must be taken immediately. * - * @throws \BadMethodCallException + * @param string|\Stringable $message + * @param array $context + * @return void */ - public function __call($method, $parameters) + public function alert($message, array $context = []): void { - if (in_array($method, $this->levels)) - { - $this->formatParameters($parameters); + $this->log('alert', $message, $context); + } - call_user_func_array($this->fireLogEvent(...), array_merge(array($method), $parameters)); + /** + * Critical conditions. + * + * @param string|\Stringable $message + * @param array $context + * @return void + */ + public function critical($message, array $context = []): void + { + $this->log('critical', $message, $context); + } - return $this->callMonolog($method, $parameters); - } + /** + * Runtime errors that do not require immediate action. + * + * @param string|\Stringable $message + * @param array $context + * @return void + */ + public function error($message, array $context = []): void + { + $this->log('error', $message, $context); + } - throw new \BadMethodCallException("Method [$method] does not exist."); + /** + * Exceptional occurrences that are not errors. + * + * @param string|\Stringable $message + * @param array $context + * @return void + */ + public function warning($message, array $context = []): void + { + $this->log('warning', $message, $context); + } + + /** + * Normal but significant events. + * + * @param string|\Stringable $message + * @param array $context + * @return void + */ + public function notice($message, array $context = []): void + { + $this->log('notice', $message, $context); + } + + /** + * Interesting events. + * + * @param string|\Stringable $message + * @param array $context + * @return void + */ + public function info($message, array $context = []): void + { + $this->log('info', $message, $context); + } + + /** + * Detailed debug information. + * + * @param string|\Stringable $message + * @param array $context + * @return void + */ + public function debug($message, array $context = []): void + { + $this->log('debug', $message, $context); + } + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string|\Stringable $message + * @param array $context + * @return void + */ + public function log($level, $message, array $context = []): void + { + $context = array_merge($this->sharedContext, $context); + + $this->fireLogEvent($level, $message, $context); + + $this->monolog->log($level, $message, $context); } /** @@ -306,4 +454,31 @@ protected function formatParameters(&$parameters) } } + /** + * Dynamically handle calls to the logger. + * + * @param string $method + * @param mixed $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + // ponytail: PSR-3 methods are explicit; __call handles macros + legacy level dispatch + if (in_array($method, $this->levels)) + { + $this->formatParameters($parameters); + + call_user_func_array($this->fireLogEvent(...), array_merge(array($method), $parameters)); + + return $this->callMonolog($method, $parameters); + } + + throw new \BadMethodCallException("Method [$method] does not exist."); + } + } + +// BC: class renamed from Writer to Logger (task 3.5); alias old FQN so type-hints resolve. +class_alias('Illuminate\Log\Logger', 'Illuminate\Log\Writer'); diff --git a/src/Illuminate/Mail/Mailer.php b/src/Illuminate/Mail/Mailer.php index c47440968..2b77ce4b4 100755 --- a/src/Illuminate/Mail/Mailer.php +++ b/src/Illuminate/Mail/Mailer.php @@ -3,7 +3,7 @@ use Closure; use Illuminate\Queue\Jobs\Job; use Illuminate\Support\Str; -use Illuminate\Log\Writer; +use Illuminate\Log\Logger; use Illuminate\View\Factory; use Illuminate\Events\Dispatcher; use Illuminate\Queue\QueueManager; @@ -43,7 +43,7 @@ class Mailer { /** * The log writer instance. */ - protected Writer $logger; + protected Logger $logger; /** * The IoC container instance. @@ -431,10 +431,10 @@ public function setSymfonyTransport(TransportInterface $transport): void /** * Set the log writer instance. * - * @param \Illuminate\Log\Writer $logger + * @param \Illuminate\Log\Logger $logger * @return $this */ - public function setLogger(Writer $logger): static + public function setLogger(Logger $logger): static { $this->logger = $logger; diff --git a/src/Illuminate/Support/Facades/Log.php b/src/Illuminate/Support/Facades/Log.php index 3504a010a..ee839bd52 100755 --- a/src/Illuminate/Support/Facades/Log.php +++ b/src/Illuminate/Support/Facades/Log.php @@ -1,7 +1,7 @@ shouldReceive('pushHandler')->once()->with(m::type(StreamHandler::class)); $writer->useFiles(__DIR__); } @@ -28,7 +28,7 @@ public function testFileHandlerCanBeAdded() public function testRotatingFileHandlerCanBeAdded() { - $writer = new Writer($monolog = m::mock(Logger::class)); + $writer = new IlluminateLogger($monolog = m::mock(Logger::class)); $monolog->shouldReceive('pushHandler')->once()->with(m::type(RotatingFileHandler::class)); $writer->useDailyFiles(__DIR__, 5); } @@ -36,7 +36,7 @@ public function testRotatingFileHandlerCanBeAdded() public function testErrorLogHandlerCanBeAdded() { - $writer = new Writer($monolog = m::mock(Logger::class)); + $writer = new IlluminateLogger($monolog = m::mock(Logger::class)); $monolog->shouldReceive('pushHandler')->once()->with(m::type(ErrorLogHandler::class)); $writer->useErrorLog(); } @@ -44,8 +44,8 @@ public function testErrorLogHandlerCanBeAdded() public function testMagicMethodsPassErrorAdditionsToMonolog() { - $writer = new Writer($monolog = m::mock(Logger::class)); - $monolog->shouldReceive('error')->once()->with('foo'); + $writer = new IlluminateLogger($monolog = m::mock(Logger::class)); + $monolog->shouldReceive('log')->once()->with('error', 'foo', []); $writer->error('foo'); } @@ -53,8 +53,8 @@ public function testMagicMethodsPassErrorAdditionsToMonolog() public function testWriterFiresEventsDispatcher() { - $writer = new Writer($monolog = m::mock(Logger::class), $events = new Illuminate\Events\Dispatcher); - $monolog->shouldReceive('error')->once()->with('foo'); + $writer = new IlluminateLogger($monolog = m::mock(Logger::class), $events = new Illuminate\Events\Dispatcher); + $monolog->shouldReceive('log')->once()->with('error', 'foo', []); $events->listen('illuminate.log', function($level, $message, array $context = []) { @@ -79,7 +79,7 @@ public function testWriterFiresEventsDispatcher() public function testListenShortcutFailsWithNoDispatcher() { $this->expectException(RuntimeException::class); - $writer = new Writer($monolog = m::mock(Logger::class)); + $writer = new IlluminateLogger($monolog = m::mock(Logger::class)); $writer->listen( function () { } @@ -89,7 +89,7 @@ function () { public function testListenShortcut() { - $writer = new Writer($monolog = m::mock(Logger::class), $events = m::mock( + $writer = new IlluminateLogger($monolog = m::mock(Logger::class), $events = m::mock( Dispatcher::class )); diff --git a/tests/Mail/MailMailerTest.php b/tests/Mail/MailMailerTest.php index bb39609d1..7b6fea15a 100755 --- a/tests/Mail/MailMailerTest.php +++ b/tests/Mail/MailMailerTest.php @@ -1,6 +1,6 @@ shouldReceive('render')->once()->andReturn('rendered.view'); $mailer = new Mailer($view, $transport = new ArrayTransport()); - $logger = m::mock(Writer::class); + $logger = m::mock(Logger::class); $logger->shouldReceive('info')->once()->with('Pretending to mail message to: taylor@userscape.com'); $mailer->setLogger($logger); $mailer->pretend();