LogTraitTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  10. * @link http://cakephp.org CakePHP(tm) Project
  11. * @since 3.0.0
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Cake\Test\TestCase\Log;
  15. use Cake\Log\Log;
  16. use Cake\Log\LogInterface;
  17. use Cake\Log\LogTrait;
  18. use Cake\TestSuite\TestCase;
  19. /**
  20. * Test case for LogTrait
  21. *
  22. */
  23. class LogTraitTest extends TestCase {
  24. public function tearDown() {
  25. parent::tearDown();
  26. Log::drop('trait_test');
  27. }
  28. /**
  29. * Test log method.
  30. *
  31. * @return void
  32. */
  33. public function testLog() {
  34. $mock = $this->getMock('Psr\Log\LoggerInterface');
  35. $mock->expects($this->at(0))
  36. ->method('log')
  37. ->with('error', 'Testing');
  38. $mock->expects($this->at(1))
  39. ->method('log')
  40. ->with('debug', array(1, 2));
  41. Log::config('trait_test', ['engine' => $mock]);
  42. $subject = $this->getObjectForTrait('Cake\Log\LogTrait');
  43. $subject->log('Testing');
  44. $subject->log(array(1, 2), 'debug');
  45. }
  46. }