FixtureManagerTest.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /**
  26. * Setup method
  27. *
  28. * @return void
  29. */
  30. public function setUp()
  31. {
  32. parent::setUp();
  33. $this->manager = new FixtureManager();
  34. }
  35. /**
  36. * Test loading core fixtures.
  37. *
  38. * @return void
  39. */
  40. public function testFixturizeCore()
  41. {
  42. $test = $this->getMock('Cake\TestSuite\TestCase');
  43. $test->fixtures = ['core.articles'];
  44. $this->manager->fixturize($test);
  45. $fixtures = $this->manager->loaded();
  46. $this->assertCount(1, $fixtures);
  47. $this->assertArrayHasKey('core.articles', $fixtures);
  48. $this->assertInstanceOf('Cake\Test\Fixture\ArticlesFixture', $fixtures['core.articles']);
  49. }
  50. /**
  51. * Test loading app fixtures.
  52. *
  53. * @return void
  54. */
  55. public function testFixturizePlugin()
  56. {
  57. Plugin::load('TestPlugin');
  58. $test = $this->getMock('Cake\TestSuite\TestCase');
  59. $test->fixtures = ['plugin.test_plugin.articles'];
  60. $this->manager->fixturize($test);
  61. $fixtures = $this->manager->loaded();
  62. $this->assertCount(1, $fixtures);
  63. $this->assertArrayHasKey('plugin.test_plugin.articles', $fixtures);
  64. $this->assertInstanceOf(
  65. 'TestPlugin\Test\Fixture\ArticlesFixture',
  66. $fixtures['plugin.test_plugin.articles']
  67. );
  68. }
  69. /**
  70. * Test loading app fixtures.
  71. *
  72. * @return void
  73. */
  74. public function testFixturizeCustom()
  75. {
  76. $test = $this->getMock('Cake\TestSuite\TestCase');
  77. $test->fixtures = ['plugin.Company/TestPluginThree.articles'];
  78. $this->manager->fixturize($test);
  79. $fixtures = $this->manager->loaded();
  80. $this->assertCount(1, $fixtures);
  81. $this->assertArrayHasKey('plugin.Company/TestPluginThree.articles', $fixtures);
  82. $this->assertInstanceOf(
  83. 'Company\TestPluginThree\Test\Fixture\ArticlesFixture',
  84. $fixtures['plugin.Company/TestPluginThree.articles']
  85. );
  86. }
  87. }