PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/cake/tests/cases/libs/configure.test.php

https://github.com/Forbin/cakephp2x
PHP | 755 lines | 426 code | 135 blank | 194 comment | 8 complexity | 8ed695ecad832ff1962c4bfb15f1013d MD5 | raw file
  1. <?php
  2. /**
  3. * ConfigureTest file
  4. *
  5. * Holds several tests
  6. *
  7. * PHP Version 5.x
  8. *
  9. * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
  10. * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. *
  12. * Licensed under The Open Group Test Suite License
  13. * Redistributions of files must retain the above copyright notice.
  14. *
  15. * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16. * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
  17. * @package cake
  18. * @subpackage cake.tests.cases.libs
  19. * @since CakePHP(tm) v 1.2.0.5432
  20. * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
  21. */
  22. App::import('Core', 'Configure');
  23. /**
  24. * ConfigureTest
  25. *
  26. * @package cake
  27. * @subpackage cake.tests.cases.libs
  28. */
  29. class ConfigureTest extends CakeTestCase {
  30. /**
  31. * setUp method
  32. *
  33. * @access public
  34. * @return void
  35. */
  36. function setUp() {
  37. $this->_cacheDisable = Configure::read('Cache.disable');
  38. $this->_debug = Configure::read('debug');
  39. Configure::write('Cache.disable', true);
  40. }
  41. /**
  42. * endTest
  43. *
  44. * @access public
  45. * @return void
  46. */
  47. function endTest() {
  48. App::build();
  49. }
  50. /**
  51. * tearDown method
  52. *
  53. * @access public
  54. * @return void
  55. */
  56. function tearDown() {
  57. if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_core_paths')) {
  58. unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_core_paths');
  59. }
  60. if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_dir_map')) {
  61. unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_dir_map');
  62. }
  63. if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_file_map')) {
  64. unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_file_map');
  65. }
  66. if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_object_map')) {
  67. unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_object_map');
  68. }
  69. if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'test.config.php')) {
  70. unlink(TMP . 'cache' . DS . 'persistent' . DS . 'test.config.php');
  71. }
  72. if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'test.php')) {
  73. unlink(TMP . 'cache' . DS . 'persistent' . DS . 'test.php');
  74. }
  75. Configure::write('debug', $this->_debug);
  76. Configure::write('Cache.disable', $this->_cacheDisable);
  77. }
  78. /**
  79. * testRead method
  80. *
  81. * @access public
  82. * @return void
  83. */
  84. function testRead() {
  85. $expected = 'ok';
  86. Configure::write('level1.level2.level3_1', $expected);
  87. Configure::write('level1.level2.level3_2', 'something_else');
  88. $result = Configure::read('level1.level2.level3_1');
  89. $this->assertEqual($expected, $result);
  90. $result = Configure::read('level1.level2.level3_2');
  91. $this->assertEqual($result, 'something_else');
  92. $result = Configure::read('debug');
  93. $this->assertTrue($result >= 0);
  94. }
  95. /**
  96. * testWrite method
  97. *
  98. * @access public
  99. * @return void
  100. */
  101. function testWrite() {
  102. Configure::write('SomeName.someKey', 'myvalue');
  103. $result = Configure::read('SomeName.someKey');
  104. $this->assertEqual($result, 'myvalue');
  105. Configure::write('SomeName.someKey', null);
  106. $result = Configure::read('SomeName.someKey');
  107. $this->assertEqual($result, null);
  108. $expected = array('One' => array('Two' => array('Three' => array('Four' => array('Five' => 'cool')))));
  109. Configure::write('Key', $expected);
  110. $result = Configure::read('Key');
  111. $this->assertEqual($expected, $result);
  112. $result = Configure::read('Key.One');
  113. $this->assertEqual($expected['One'], $result);
  114. $result = Configure::read('Key.One.Two');
  115. $this->assertEqual($expected['One']['Two'], $result);
  116. $result = Configure::read('Key.One.Two.Three.Four.Five');
  117. $this->assertEqual('cool', $result);
  118. }
  119. /**
  120. * testSetErrorReporting Level
  121. *
  122. * @return void
  123. */
  124. function testSetErrorReportingLevel() {
  125. Configure::write('log', false);
  126. Configure::write('debug', 0);
  127. $result = ini_get('error_reporting');
  128. $this->assertEqual($result, 0);
  129. Configure::write('debug', 2);
  130. $result = ini_get('error_reporting');
  131. $this->assertEqual($result, E_ALL & ~E_DEPRECATED);
  132. $result = ini_get('display_errors');
  133. $this->assertEqual($result, 1);
  134. Configure::write('debug', 0);
  135. $result = ini_get('error_reporting');
  136. $this->assertEqual($result, 0);
  137. }
  138. /**
  139. * test that log and debug configure values interact well.
  140. *
  141. * @return void
  142. */
  143. function testInteractionOfDebugAndLog() {
  144. Configure::write('log', false);
  145. Configure::write('debug', 0);
  146. $this->assertEqual(ini_get('error_reporting'), 0);
  147. $this->assertEqual(ini_get('display_errors'), 0);
  148. Configure::write('log', E_WARNING);
  149. Configure::write('debug', 0);
  150. $this->assertEqual(ini_get('error_reporting'), E_WARNING);
  151. $this->assertEqual(ini_get('display_errors'), 0);
  152. Configure::write('debug', 2);
  153. $this->assertEqual(ini_get('error_reporting'), E_ALL & ~E_DEPRECATED);
  154. $this->assertEqual(ini_get('display_errors'), 1);
  155. Configure::write('debug', 0);
  156. Configure::write('log', false);
  157. $this->assertEqual(ini_get('error_reporting'), 0);
  158. $this->assertEqual(ini_get('display_errors'), 0);
  159. }
  160. /**
  161. * testDelete method
  162. *
  163. * @access public
  164. * @return void
  165. */
  166. function testDelete() {
  167. Configure::write('SomeName.someKey', 'myvalue');
  168. $result = Configure::read('SomeName.someKey');
  169. $this->assertEqual($result, 'myvalue');
  170. Configure::delete('SomeName.someKey');
  171. $result = Configure::read('SomeName.someKey');
  172. $this->assertTrue($result === null);
  173. Configure::write('SomeName', array('someKey' => 'myvalue', 'otherKey' => 'otherValue'));
  174. $result = Configure::read('SomeName.someKey');
  175. $this->assertEqual($result, 'myvalue');
  176. $result = Configure::read('SomeName.otherKey');
  177. $this->assertEqual($result, 'otherValue');
  178. Configure::delete('SomeName');
  179. $result = Configure::read('SomeName.someKey');
  180. $this->assertTrue($result === null);
  181. $result = Configure::read('SomeName.otherKey');
  182. $this->assertTrue($result === null);
  183. }
  184. /**
  185. * testLoad method
  186. *
  187. * @access public
  188. * @return void
  189. */
  190. function testLoad() {
  191. $result = Configure::load('non_existing_configuration_file');
  192. $this->assertFalse($result);
  193. $result = Configure::load('config');
  194. $this->assertTrue($result === null);
  195. $result = Configure::load('../../index');
  196. $this->assertFalse($result);
  197. }
  198. /**
  199. * testLoad method
  200. *
  201. * @access public
  202. * @return void
  203. */
  204. function testLoadPlugin() {
  205. App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
  206. $result = Configure::load('test_plugin.load');
  207. $this->assertTrue($result === null);
  208. $expected = '/test_app/plugins/test_plugin/config/load.php';
  209. $config = Configure::read('plugin_load');
  210. $this->assertEqual($config, $expected);
  211. $result = Configure::load('test_plugin.more.load');
  212. $this->assertTrue($result === null);
  213. $expected = '/test_app/plugins/test_plugin/config/more.load.php';
  214. $config = Configure::read('plugin_more_load');
  215. $this->assertEqual($config, $expected);
  216. }
  217. /**
  218. * testStore method
  219. *
  220. * @access public
  221. * @return void
  222. */
  223. function testStoreAndLoad() {
  224. Configure::write('Cache.disable', false);
  225. $expected = array('data' => 'value with backslash \, \'singlequote\' and "doublequotes"');
  226. Configure::store('SomeExample', 'test', $expected);
  227. Configure::load('test');
  228. $config = Configure::read('SomeExample');
  229. $this->assertEqual($config, $expected);
  230. $expected = array(
  231. 'data' => array('first' => 'value with backslash \, \'singlequote\' and "doublequotes"', 'second' => 'value2'),
  232. 'data2' => 'value'
  233. );
  234. Configure::store('AnotherExample', 'test_config', $expected);
  235. Configure::load('test_config');
  236. $config = Configure::read('AnotherExample');
  237. $this->assertEqual($config, $expected);
  238. }
  239. /**
  240. * testVersion method
  241. *
  242. * @access public
  243. * @return void
  244. */
  245. function testVersion() {
  246. $result = Configure::version();
  247. $this->assertTrue(version_compare($result, '1.2', '>='));
  248. }
  249. }
  250. /**
  251. * AppImportTest class
  252. *
  253. * @package cake
  254. * @subpackage cake.tests.cases.libs
  255. */
  256. class AppImportTest extends UnitTestCase {
  257. /**
  258. * testBuild method
  259. *
  260. * @access public
  261. * @return void
  262. */
  263. function testBuild() {
  264. $old = App::path('models');
  265. $expected = array_merge(array(
  266. APP . 'models' . DS,
  267. APP),
  268. App::core('models'));
  269. $this->assertEqual($expected, $old);
  270. App::build(array('models' => array('/path/to/models/')));
  271. $new = App::path('models');
  272. $expected = array_merge(array(
  273. APP . 'models' . DS,
  274. '/path/to/models/',
  275. APP),
  276. App::core('models'));
  277. $this->assertEqual($expected, $new);
  278. App::build(); //reset defaults
  279. $defaults = App::path('models');
  280. $this->assertEqual($old, $defaults);
  281. }
  282. /**
  283. * testBuildWithReset method
  284. *
  285. * @access public
  286. * @return void
  287. */
  288. function testBuildWithReset() {
  289. $old = App::path('models');
  290. $expected = array_merge(array(
  291. APP . 'models' . DS,
  292. APP),
  293. App::core('models'));
  294. $this->assertEqual($expected, $old);
  295. App::build(array('models' => array('/path/to/models/')), true);
  296. $new = App::path('models');
  297. $expected = array(
  298. '/path/to/models/'
  299. );
  300. $this->assertEqual($expected, $new);
  301. App::build(); //reset defaults
  302. $defaults = App::path('models');
  303. $this->assertEqual($old, $defaults);
  304. }
  305. /**
  306. * testCore method
  307. *
  308. * @access public
  309. * @return void
  310. * @todo fix test cases to pass when webroot is outside normal package directory structure
  311. */
  312. function testCore() {
  313. if (!$this->skipif(true, 'ConfigureTest::testCore() does not pass when webroot is outside normal package directory structure')) {
  314. return true;
  315. }
  316. $model = App::core('models');
  317. $this->assertEqual(array(ROOT . DS . LIBS . 'model' . DS), $model);
  318. $view = App::core('views');
  319. $this->assertEqual(array(ROOT . DS . LIBS . 'view' . DS), $view);
  320. $controller = App::core('controllers');
  321. $this->assertEqual(array(ROOT . DS . LIBS . 'controller' . DS), $controller);
  322. }
  323. /**
  324. * testListObjects method
  325. *
  326. * @access public
  327. * @return void
  328. */
  329. function testListObjects() {
  330. $result = App::objects('class', TEST_CAKE_CORE_INCLUDE_PATH . 'libs');
  331. $this->assertTrue(in_array('Xml', $result));
  332. $this->assertTrue(in_array('Cache', $result));
  333. $this->assertTrue(in_array('HttpSocket', $result));
  334. $result = App::objects('behavior');
  335. $this->assertTrue(in_array('Tree', $result));
  336. $result = App::objects('controller');
  337. $this->assertTrue(in_array('Pages', $result));
  338. $result = App::objects('component');
  339. $this->assertTrue(in_array('Auth', $result));
  340. $result = App::objects('view');
  341. $this->assertTrue(in_array('Media', $result));
  342. $result = App::objects('helper');
  343. $this->assertTrue(in_array('Html', $result));
  344. $result = App::objects('model');
  345. $notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
  346. foreach ($notExpected as $class) {
  347. $this->assertFalse(in_array($class, $result));
  348. }
  349. $result = App::objects('file');
  350. $this->assertFalse($result);
  351. $result = App::objects('file', 'non_existing_configure');
  352. $expected = array();
  353. $this->assertEqual($result, $expected);
  354. $result = App::objects('NonExistingType');
  355. $this->assertFalse($result);
  356. }
  357. /**
  358. * test that pluginPath can find paths for plugins.
  359. *
  360. * @return void
  361. */
  362. function testPluginPath() {
  363. App::build(array(
  364. 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
  365. ));
  366. $path = App::pluginPath('test_plugin');
  367. $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
  368. $this->assertEqual($path, $expected);
  369. $path = App::pluginPath('TestPlugin');
  370. $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
  371. $this->assertEqual($path, $expected);
  372. $path = App::pluginPath('TestPluginTwo');
  373. $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS;
  374. $this->assertEqual($path, $expected);
  375. App::build();
  376. }
  377. /**
  378. * testClassLoading method
  379. *
  380. * @access public
  381. * @return void
  382. */
  383. function testClassLoading() {
  384. $file = App::import();
  385. $this->assertTrue($file);
  386. $file = App::import('Model', 'Model', false);
  387. $this->assertTrue($file);
  388. $this->assertTrue(class_exists('Model'));
  389. $file = App::import('Controller', 'Controller', false);
  390. $this->assertTrue($file);
  391. $this->assertTrue(class_exists('Controller'));
  392. $file = App::import('Component', 'Component', false);
  393. $this->assertTrue($file);
  394. $this->assertTrue(class_exists('Component'));
  395. $file = App::import('Shell', 'Shell', false);
  396. $this->assertTrue($file);
  397. $this->assertTrue(class_exists('Shell'));
  398. $file = App::import('Model', 'SomeRandomModelThatDoesNotExist', false);
  399. $this->assertFalse($file);
  400. $file = App::import('Model', 'AppModel', false);
  401. $this->assertTrue($file);
  402. $this->assertTrue(class_exists('AppModel'));
  403. $file = App::import('WrongType', null, true, array(), '');
  404. $this->assertTrue($file);
  405. $file = App::import('Model', 'NonExistingPlugin.NonExistingModel', false);
  406. $this->assertFalse($file);
  407. $file = App::import('Core', 'NonExistingPlugin.NonExistingModel', false);
  408. $this->assertFalse($file);
  409. $file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
  410. $this->assertFalse($file);
  411. $file = App::import('Core', array('NonExistingPlugin.NonExistingModel'), false);
  412. $this->assertFalse($file);
  413. $file = App::import('Core', array('NonExistingPlugin.NonExistingModel.AnotherChild'), false);
  414. $this->assertFalse($file);
  415. if (!class_exists('AppController')) {
  416. $classes = array_flip(get_declared_classes());
  417. $this->assertFalse(isset($classes['PagesController']));
  418. $this->assertFalse(isset($classes['AppController']));
  419. $file = App::import('Controller', 'Pages');
  420. $this->assertTrue($file);
  421. $this->assertTrue(class_exists('PagesController'));
  422. $classes = array_flip(get_declared_classes());
  423. $this->assertTrue(isset($classes['PagesController']));
  424. $this->assertTrue(isset($classes['AppController']));
  425. $file = App::import('Behavior', 'Containable');
  426. $this->assertTrue($file);
  427. $this->assertTrue(class_exists('ContainableBehavior'));
  428. $file = App::import('Component', 'RequestHandler');
  429. $this->assertTrue($file);
  430. $this->assertTrue(class_exists('RequestHandlerComponent'));
  431. $file = App::import('Helper', 'Form');
  432. $this->assertTrue($file);
  433. $this->assertTrue(class_exists('FormHelper'));
  434. $file = App::import('Model', 'NonExistingModel');
  435. $this->assertFalse($file);
  436. $file = App::import('Datasource', 'DboSource');
  437. $this->assertTrue($file);
  438. $this->assertTrue(class_exists('DboSource'));
  439. }
  440. App::build(array(
  441. 'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
  442. 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
  443. ));
  444. $result = App::import('Controller', 'TestPlugin.Tests');
  445. $this->assertTrue($result);
  446. $this->assertTrue(class_exists('TestPluginAppController'));
  447. $this->assertTrue(class_exists('TestsController'));
  448. $result = App::import('Lib', 'TestPlugin.TestPluginLibrary');
  449. $this->assertTrue($result);
  450. $this->assertTrue(class_exists('TestPluginLibrary'));
  451. $result = App::import('Lib', 'Library');
  452. $this->assertTrue($result);
  453. $this->assertTrue(class_exists('Library'));
  454. $result = App::import('Helper', 'TestPlugin.OtherHelper');
  455. $this->assertTrue($result);
  456. $this->assertTrue(class_exists('OtherHelperHelper'));
  457. $result = App::import('Datasource', 'TestPlugin.TestSource');
  458. $this->assertTrue($result);
  459. $this->assertTrue(class_exists('TestSource'));
  460. App::build();
  461. }
  462. /**
  463. * testFileLoading method
  464. *
  465. * @access public
  466. * @return void
  467. */
  468. function testFileLoading () {
  469. $file = App::import('File', 'RealFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php');
  470. $this->assertTrue($file);
  471. $file = App::import('File', 'NoFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
  472. $this->assertFalse($file);
  473. }
  474. // import($type = null, $name = null, $parent = true, $file = null, $search = array(), $return = false) {
  475. /**
  476. * testFileLoadingWithArray method
  477. *
  478. * @access public
  479. * @return void
  480. */
  481. function testFileLoadingWithArray() {
  482. $type = array('type' => 'File', 'name' => 'SomeName', 'parent' => false,
  483. 'file' => TEST_CAKE_CORE_INCLUDE_PATH . DS . 'config' . DS . 'config.php');
  484. $file = App::import($type);
  485. $this->assertTrue($file);
  486. $type = array('type' => 'File', 'name' => 'NoFile', 'parent' => false,
  487. 'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
  488. $file = App::import($type);
  489. $this->assertFalse($file);
  490. }
  491. /**
  492. * testFileLoadingReturnValue method
  493. *
  494. * @access public
  495. * @return void
  496. */
  497. function testFileLoadingReturnValue () {
  498. $file = App::import('File', 'Name', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', true);
  499. $this->assertTrue($file);
  500. $this->assertTrue(isset($file['Cake.version']));
  501. $type = array('type' => 'File', 'name' => 'OtherName', 'parent' => false,
  502. 'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', 'return' => true);
  503. $file = App::import($type);
  504. $this->assertTrue($file);
  505. $this->assertTrue(isset($file['Cake.version']));
  506. }
  507. /**
  508. * testLoadingWithSearch method
  509. *
  510. * @access public
  511. * @return void
  512. */
  513. function testLoadingWithSearch () {
  514. $file = App::import('File', 'NewName', false, array(TEST_CAKE_CORE_INCLUDE_PATH ), 'config.php');
  515. $this->assertTrue($file);
  516. $file = App::import('File', 'AnotherNewName', false, array(LIBS), 'config.php');
  517. $this->assertFalse($file);
  518. }
  519. /**
  520. * testLoadingWithSearchArray method
  521. *
  522. * @access public
  523. * @return void
  524. */
  525. function testLoadingWithSearchArray () {
  526. $type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(TEST_CAKE_CORE_INCLUDE_PATH ));
  527. $file = App::import($type);
  528. $this->assertTrue($file);
  529. $type = array('type' => 'File', 'name' => 'AnotherRandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(LIBS));
  530. $file = App::import($type);
  531. $this->assertFalse($file);
  532. }
  533. /**
  534. * testMultipleLoading method
  535. *
  536. * @access public
  537. * @return void
  538. */
  539. function testMultipleLoading() {
  540. $toLoad = array('I18n', 'CakeSocket');
  541. $classes = array_flip(get_declared_classes());
  542. $this->assertFalse(isset($classes['i18n']));
  543. $this->assertFalse(isset($classes['CakeSocket']));
  544. $load = App::import($toLoad);
  545. $this->assertTrue($load);
  546. $classes = array_flip(get_declared_classes());
  547. $this->assertTrue(isset($classes['I18n']));
  548. $load = App::import(array('I18n', 'SomeNotFoundClass', 'CakeSocket'));
  549. $this->assertFalse($load);
  550. $load = App::import($toLoad);
  551. $this->assertTrue($load);
  552. }
  553. /**
  554. * This test only works if you have plugins/my_plugin set up.
  555. * plugins/my_plugin/models/my_plugin.php and other_model.php
  556. */
  557. /*
  558. function testMultipleLoadingByType() {
  559. $classes = array_flip(get_declared_classes());
  560. $this->assertFalse(isset($classes['OtherPlugin']));
  561. $this->assertFalse(isset($classes['MyPlugin']));
  562. $load = App::import('Model', array('MyPlugin.OtherPlugin', 'MyPlugin.MyPlugin'));
  563. $this->assertTrue($load);
  564. $classes = array_flip(get_declared_classes());
  565. $this->assertTrue(isset($classes['OtherPlugin']));
  566. $this->assertTrue(isset($classes['MyPlugin']));
  567. }
  568. */
  569. function testLoadingVendor() {
  570. App::build(array(
  571. 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
  572. 'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
  573. ), true);
  574. ob_start();
  575. $result = App::import('Vendor', 'TestPlugin.TestPluginAsset', array('ext' => 'css'));
  576. $text = ob_get_clean();
  577. $this->assertTrue($result);
  578. $this->assertEqual($text, 'this is the test plugin asset css file');
  579. ob_start();
  580. $result = App::import('Vendor', 'TestAsset', array('ext' => 'css'));
  581. $text = ob_get_clean();
  582. $this->assertTrue($result);
  583. $this->assertEqual($text, 'this is the test asset css file');
  584. $result = App::import('Vendor', 'TestPlugin.SamplePlugin');
  585. $this->assertTrue($result);
  586. $this->assertTrue(class_exists('SamplePluginClassTestName'));
  587. $result = App::import('Vendor', 'ConfigureTestVendorSample');
  588. $this->assertTrue($result);
  589. $this->assertTrue(class_exists('ConfigureTestVendorSample'));
  590. ob_start();
  591. $result = App::import('Vendor', 'SomeName', array('file' => 'some.name.php'));
  592. $text = ob_get_clean();
  593. $this->assertTrue($result);
  594. $this->assertEqual($text, 'This is a file with dot in file name');
  595. ob_start();
  596. $result = App::import('Vendor', 'TestHello', array('file' => 'Test'.DS.'hello.php'));
  597. $text = ob_get_clean();
  598. $this->assertTrue($result);
  599. $this->assertEqual($text, 'This is the hello.php file in Test directory');
  600. ob_start();
  601. $result = App::import('Vendor', 'MyTest', array('file' => 'Test'.DS.'MyTest.php'));
  602. $text = ob_get_clean();
  603. $this->assertTrue($result);
  604. $this->assertEqual($text, 'This is the MyTest.php file');
  605. ob_start();
  606. $result = App::import('Vendor', 'Welcome');
  607. $text = ob_get_clean();
  608. $this->assertTrue($result);
  609. $this->assertEqual($text, 'This is the welcome.php file in vendors directory');
  610. ob_start();
  611. $result = App::import('Vendor', 'TestPlugin.Welcome');
  612. $text = ob_get_clean();
  613. $this->assertTrue($result);
  614. $this->assertEqual($text, 'This is the welcome.php file in test_plugin/vendors directory');
  615. }
  616. }
  617. ?>