LogTraitTest.php 1.4 KB

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