FixtureManagerTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestSuite;
  16. use Cake\Core\Plugin;
  17. use Cake\Database\ConnectionManager;
  18. use Cake\TestSuite\Fixture\FixtureManager;
  19. use Cake\TestSuite\TestCase;
  20. /**
  21. * Fixture manager test case.
  22. */
  23. class FixtureManagerTest extends TestCase {
  24. /**
  25. * Setup method
  26. *
  27. * @return void
  28. */
  29. public function setUp() {
  30. parent::setUp();
  31. $this->manager = new FixtureManager();
  32. }
  33. /**
  34. * Test loading core fixtures.
  35. *
  36. * @return void
  37. */
  38. public function testFixturizeCore() {
  39. $test = $this->getMock('Cake\TestSuite\TestCase');
  40. $test->fixtures = ['core.article'];
  41. $this->manager->fixturize($test);
  42. $fixtures = $this->manager->loaded();
  43. $this->assertCount(1, $fixtures);
  44. $this->assertArrayHasKey('core.article', $fixtures);
  45. $this->assertInstanceOf('Cake\Test\Fixture\ArticleFixture', $fixtures['core.article']);
  46. }
  47. /**
  48. * Test loading app fixtures.
  49. *
  50. * @return void
  51. */
  52. public function testFixturizePlugin() {
  53. Plugin::load('TestPlugin');
  54. $test = $this->getMock('Cake\TestSuite\TestCase');
  55. $test->fixtures = ['plugin.test_plugin.article'];
  56. $this->manager->fixturize($test);
  57. $fixtures = $this->manager->loaded();
  58. $this->assertCount(1, $fixtures);
  59. $this->assertArrayHasKey('plugin.test_plugin.article', $fixtures);
  60. $this->assertInstanceOf(
  61. 'TestPlugin\Test\Fixture\ArticleFixture',
  62. $fixtures['plugin.test_plugin.article']
  63. );
  64. }
  65. }