3 * CakeFixtureManager file
5 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
6 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
8 * Licensed under The MIT License
9 * For full copyright and license information, please see the LICENSE.txt
10 * Redistributions of files must retain the above copyright notice.
12 * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
13 * @link http://cakephp.org CakePHP Project
14 * @package Cake.Test.Case.TestSuite.Fixture
15 * @since CakePHP v 2.5
16 * @license http://www.opensource.org/licenses/mit-license.php MIT License
19 App::uses('DboSource', 'Model/Datasource');
20 App::uses('CakeFixtureManager', 'TestSuite/Fixture');
21 App::uses('UuidFixture', 'Test/Fixture');
24 * Test Case for CakeFixtureManager class
26 * @package Cake.Test.Case.TestSuite
28 class CakeFixtureManagerTest extends CakeTestCase {
35 public function setUp() {
37 $this->fixtureManager = new CakeFixtureManager();
45 public function tearDown() {
47 unset($this->fixtureManager);
51 * testLoadTruncatesTable
55 public function testLoadTruncatesTable() {
56 $MockFixture = $this->getMock('UuidFixture', array('truncate'));
58 ->expects($this->once())
60 ->will($this->returnValue(true));
62 $fixtureManager = $this->fixtureManager;
63 $fixtureManagerReflection = new ReflectionClass($fixtureManager);
65 $loadedProperty = $fixtureManagerReflection->getProperty('_loaded');
66 $loadedProperty->setAccessible(true);
67 $loadedProperty->setValue($fixtureManager, array('core.uuid' => $MockFixture));
69 $TestCase = $this->getMock('CakeTestCase');
70 $TestCase->fixtures = array('core.uuid');
71 $TestCase->autoFixtures = true;
72 $TestCase->dropTables = false;
74 $fixtureManager->load($TestCase);
78 * testLoadSingleTruncatesTable
82 public function testLoadSingleTruncatesTable() {
83 $MockFixture = $this->getMock('UuidFixture', array('truncate'));
85 ->expects($this->once())
87 ->will($this->returnValue(true));
89 $fixtureManager = $this->fixtureManager;
90 $fixtureManagerReflection = new ReflectionClass($fixtureManager);
92 $fixtureMapProperty = $fixtureManagerReflection->getProperty('_fixtureMap');
93 $fixtureMapProperty->setAccessible(true);
94 $fixtureMapProperty->setValue($fixtureManager, array('UuidFixture' => $MockFixture));
96 $dboMethods = array_diff(get_class_methods('DboSource'), array('enabled'));
97 $dboMethods[] = 'connect';
98 $db = $this->getMock('DboSource', $dboMethods);
99 $db->config['prefix'] = '';
101 $fixtureManager->loadSingle('Uuid', $db, false);