LogTraitTest.php 1.3 KB

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