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