LocatorAwareTraitTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
  10. * @link https://cakephp.org CakePHP(tm) Project
  11. * @since 3.1.0
  12. * @license https://opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Cake\Test\TestCase\ORM\Locator;
  15. use Cake\TestSuite\TestCase;
  16. /**
  17. * LocatorAwareTrait test case
  18. */
  19. class LocatorAwareTraitTest extends TestCase
  20. {
  21. /**
  22. * setup
  23. *
  24. * @return void
  25. */
  26. public function setUp()
  27. {
  28. parent::setUp();
  29. $this->subject = $this->getObjectForTrait('Cake\ORM\Locator\LocatorAwareTrait');
  30. }
  31. /**
  32. * Tests tableLocator method
  33. *
  34. * @group deprecated
  35. * @return void
  36. */
  37. public function testTableLocator()
  38. {
  39. $this->deprecated(function () {
  40. $tableLocator = $this->subject->tableLocator();
  41. $this->assertSame($this->getTableLocator(), $tableLocator);
  42. $newLocator = $this->getMockBuilder('Cake\ORM\Locator\LocatorInterface')->getMock();
  43. $subjectLocator = $this->subject->tableLocator($newLocator);
  44. $this->assertSame($newLocator, $subjectLocator);
  45. });
  46. }
  47. /**
  48. * Tests testGetTableLocator method
  49. *
  50. * @return void
  51. */
  52. public function testGetTableLocator()
  53. {
  54. $tableLocator = $this->subject->getTableLocator();
  55. $this->assertSame($this->getTableLocator(), $tableLocator);
  56. }
  57. /**
  58. * Tests testSetTableLocator method
  59. *
  60. * @return void
  61. */
  62. public function testSetTableLocator()
  63. {
  64. $newLocator = $this->getMockBuilder('Cake\ORM\Locator\LocatorInterface')->getMock();
  65. $this->subject->setTableLocator($newLocator);
  66. $subjectLocator = $this->subject->getTableLocator();
  67. $this->assertSame($newLocator, $subjectLocator);
  68. }
  69. }