LogTraitTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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\TestSuite\TestCase;
  18. /**
  19. * Test case for LogTrait
  20. *
  21. */
  22. class LogTraitTest extends TestCase
  23. {
  24. public function tearDown()
  25. {
  26. parent::tearDown();
  27. Log::drop('trait_test');
  28. }
  29. /**
  30. * Test log method.
  31. *
  32. * @return void
  33. */
  34. public function testLog()
  35. {
  36. $mock = $this->getMock('Psr\Log\LoggerInterface');
  37. $mock->expects($this->at(0))
  38. ->method('log')
  39. ->with('error', 'Testing');
  40. $mock->expects($this->at(1))
  41. ->method('log')
  42. ->with('debug', [1, 2]);
  43. Log::config('trait_test', ['engine' => $mock]);
  44. $subject = $this->getObjectForTrait('Cake\Log\LogTrait');
  45. $subject->log('Testing');
  46. $subject->log([1, 2], 'debug');
  47. }
  48. }