PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/msadouni/cakephp2x
PHP | 750 lines | 422 code | 134 blank | 194 comment | 8 complexity | 190c05b1d13da1a25d76e4818c15ec3c 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. }
  156. /**
  157. * testDelete method
  158. *
  159. * @access public
  160. * @return void
  161. */
  162. function testDelete() {
  163. Configure::write('SomeName.someKey', 'myvalue');
  164. $result = Configure::read('SomeName.someKey');
  165. $this->assertEqual($result, 'myvalue');
  166. Configure::delete('SomeName.someKey');
  167. $result = Configure::read('SomeName.someKey');
  168. $this->assertTrue($result === null);
  169. Configure::write('SomeName', array('someKey' => 'myvalue', 'otherKey' => 'otherValue'));
  170. $result = Configure::read('SomeName.someKey');
  171. $this->assertEqual($result, 'myvalue');
  172. $result = Configure::read('SomeName.otherKey');
  173. $this->assertEqual($result, 'otherValue');
  174. Configure::delete('SomeName');
  175. $result = Configure::read('SomeName.someKey');
  176. $this->assertTrue($result === null);
  177. $result = Configure::read('SomeName.otherKey');
  178. $this->assertTrue($result === null);
  179. }
  180. /**
  181. * testLoad method
  182. *
  183. * @access public
  184. * @return void
  185. */
  186. function testLoad() {
  187. $result = Configure::load('non_existing_configuration_file');
  188. $this->assertFalse($result);
  189. $result = Configure::load('config');
  190. $this->assertTrue($result === null);
  191. $result = Configure::load('../../index');
  192. $this->assertFalse($result);
  193. }
  194. /**
  195. * testLoad method
  196. *
  197. * @access public
  198. * @return void
  199. */
  200. function testLoadPlugin() {
  201. App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
  202. $result = Configure::load('test_plugin.load');
  203. $this->assertTrue($result === null);
  204. $expected = '/test_app/plugins/test_plugin/config/load.php';
  205. $config = Configure::read('plugin_load');
  206. $this->assertEqual($config, $expected);
  207. $result = Configure::load('test_plugin.more.load');
  208. $this->assertTrue($result === null);
  209. $expected = '/test_app/plugins/test_plugin/config/more.load.php';
  210. $config = Configure::read('plugin_more_load');
  211. $this->assertEqual($config, $expected);
  212. }
  213. /**
  214. * testStore method
  215. *
  216. * @access public
  217. * @return void
  218. */
  219. function testStoreAndLoad() {
  220. Configure::write('Cache.disable', false);
  221. $expected = array('data' => 'value with backslash \, \'singlequote\' and "doublequotes"');
  222. Configure::store('SomeExample', 'test', $expected);
  223. Configure::load('test');
  224. $config = Configure::read('SomeExample');
  225. $this->assertEqual($config, $expected);
  226. $expected = array(
  227. 'data' => array('first' => 'value with backslash \, \'singlequote\' and "doublequotes"', 'second' => 'value2'),
  228. 'data2' => 'value'
  229. );
  230. Configure::store('AnotherExample', 'test_config', $expected);
  231. Configure::load('test_config');
  232. $config = Configure::read('AnotherExample');
  233. $this->assertEqual($config, $expected);
  234. }
  235. /**
  236. * testVersion method
  237. *
  238. * @access public
  239. * @return void
  240. */
  241. function testVersion() {
  242. $result = Configure::version();
  243. $this->assertTrue(version_compare($result, '1.2', '>='));
  244. }
  245. }
  246. /**
  247. * AppImportTest class
  248. *
  249. * @package cake
  250. * @subpackage cake.tests.cases.libs
  251. */
  252. class AppImportTest extends UnitTestCase {
  253. /**
  254. * testBuild method
  255. *
  256. * @access public
  257. * @return void
  258. */
  259. function testBuild() {
  260. $old = App::path('models');
  261. $expected = array_merge(array(
  262. APP . 'models' . DS,
  263. APP),
  264. App::core('models'));
  265. $this->assertEqual($expected, $old);
  266. App::build(array('models' => array('/path/to/models/')));
  267. $new = App::path('models');
  268. $expected = array_merge(array(
  269. APP . 'models' . DS,
  270. '/path/to/models/',
  271. APP),
  272. App::core('models'));
  273. $this->assertEqual($expected, $new);
  274. App::build(); //reset defaults
  275. $defaults = App::path('models');
  276. $this->assertEqual($old, $defaults);
  277. }
  278. /**
  279. * testBuildWithReset method
  280. *
  281. * @access public
  282. * @return void
  283. */
  284. function testBuildWithReset() {
  285. $old = App::path('models');
  286. $expected = array_merge(array(
  287. APP . 'models' . DS,
  288. APP),
  289. App::core('models'));
  290. $this->assertEqual($expected, $old);
  291. App::build(array('models' => array('/path/to/models/')), true);
  292. $new = App::path('models');
  293. $expected = array(
  294. '/path/to/models/'
  295. );
  296. $this->assertEqual($expected, $new);
  297. App::build(); //reset defaults
  298. $defaults = App::path('models');
  299. $this->assertEqual($old, $defaults);
  300. }
  301. /**
  302. * testCore method
  303. *
  304. * @access public
  305. * @return void
  306. * @todo fix test cases to pass when webroot is outside normal package directory structure
  307. */
  308. function testCore() {
  309. if (!$this->skipif(true, 'ConfigureTest::testCore() does not pass when webroot is outside normal package directory structure')) {
  310. return true;
  311. }
  312. $model = App::core('models');
  313. $this->assertEqual(array(ROOT . DS . LIBS . 'model' . DS), $model);
  314. $view = App::core('views');
  315. $this->assertEqual(array(ROOT . DS . LIBS . 'view' . DS), $view);
  316. $controller = App::core('controllers');
  317. $this->assertEqual(array(ROOT . DS . LIBS . 'controller' . DS), $controller);
  318. }
  319. /**
  320. * testListObjects method
  321. *
  322. * @access public
  323. * @return void
  324. */
  325. function testListObjects() {
  326. $result = App::objects('class', TEST_CAKE_CORE_INCLUDE_PATH . 'libs');
  327. $this->assertTrue(in_array('Xml', $result));
  328. $this->assertTrue(in_array('Cache', $result));
  329. $this->assertTrue(in_array('HttpSocket', $result));
  330. $result = App::objects('behavior');
  331. $this->assertTrue(in_array('Tree', $result));
  332. $result = App::objects('controller');
  333. $this->assertTrue(in_array('Pages', $result));
  334. $result = App::objects('component');
  335. $this->assertTrue(in_array('Auth', $result));
  336. $result = App::objects('view');
  337. $this->assertTrue(in_array('Media', $result));
  338. $result = App::objects('helper');
  339. $this->assertTrue(in_array('Html', $result));
  340. $result = App::objects('model');
  341. $notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
  342. foreach ($notExpected as $class) {
  343. $this->assertFalse(in_array($class, $result));
  344. }
  345. $result = App::objects('file');
  346. $this->assertFalse($result);
  347. $result = App::objects('file', 'non_existing_configure');
  348. $expected = array();
  349. $this->assertEqual($result, $expected);
  350. $result = App::objects('NonExistingType');
  351. $this->assertFalse($result);
  352. }
  353. /**
  354. * test that pluginPath can find paths for plugins.
  355. *
  356. * @return void
  357. */
  358. function testPluginPath() {
  359. App::build(array(
  360. 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
  361. ));
  362. $path = App::pluginPath('test_plugin');
  363. $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
  364. $this->assertEqual($path, $expected);
  365. $path = App::pluginPath('TestPlugin');
  366. $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
  367. $this->assertEqual($path, $expected);
  368. $path = App::pluginPath('TestPluginTwo');
  369. $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS;
  370. $this->assertEqual($path, $expected);
  371. App::build();
  372. }
  373. /**
  374. * testClassLoading method
  375. *
  376. * @access public
  377. * @return void
  378. */
  379. function testClassLoading() {
  380. $file = App::import();
  381. $this->assertTrue($file);
  382. $file = App::import('Model', 'Model', false);
  383. $this->assertTrue($file);
  384. $this->assertTrue(class_exists('Model'));
  385. $file = App::import('Controller', 'Controller', false);
  386. $this->assertTrue($file);
  387. $this->assertTrue(class_exists('Controller'));
  388. $file = App::import('Component', 'Component', false);
  389. $this->assertTrue($file);
  390. $this->assertTrue(class_exists('Component'));
  391. $file = App::import('Shell', 'Shell', false);
  392. $this->assertTrue($file);
  393. $this->assertTrue(class_exists('Shell'));
  394. $file = App::import('Model', 'SomeRandomModelThatDoesNotExist', false);
  395. $this->assertFalse($file);
  396. $file = App::import('Model', 'AppModel', false);
  397. $this->assertTrue($file);
  398. $this->assertTrue(class_exists('AppModel'));
  399. $file = App::import('WrongType', null, true, array(), '');
  400. $this->assertTrue($file);
  401. $file = App::import('Model', 'NonExistingPlugin.NonExistingModel', false);
  402. $this->assertFalse($file);
  403. $file = App::import('Core', 'NonExistingPlugin.NonExistingModel', false);
  404. $this->assertFalse($file);
  405. $file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
  406. $this->assertFalse($file);
  407. $file = App::import('Core', array('NonExistingPlugin.NonExistingModel'), false);
  408. $this->assertFalse($file);
  409. $file = App::import('Core', array('NonExistingPlugin.NonExistingModel.AnotherChild'), false);
  410. $this->assertFalse($file);
  411. if (!class_exists('AppController')) {
  412. $classes = array_flip(get_declared_classes());
  413. $this->assertFalse(isset($classes['PagesController']));
  414. $this->assertFalse(isset($classes['AppController']));
  415. $file = App::import('Controller', 'Pages');
  416. $this->assertTrue($file);
  417. $this->assertTrue(class_exists('PagesController'));
  418. $classes = array_flip(get_declared_classes());
  419. $this->assertTrue(isset($classes['PagesController']));
  420. $this->assertTrue(isset($classes['AppController']));
  421. $file = App::import('Behavior', 'Containable');
  422. $this->assertTrue($file);
  423. $this->assertTrue(class_exists('ContainableBehavior'));
  424. $file = App::import('Component', 'RequestHandler');
  425. $this->assertTrue($file);
  426. $this->assertTrue(class_exists('RequestHandlerComponent'));
  427. $file = App::import('Helper', 'Form');
  428. $this->assertTrue($file);
  429. $this->assertTrue(class_exists('FormHelper'));
  430. $file = App::import('Model', 'NonExistingModel');
  431. $this->assertFalse($file);
  432. $file = App::import('Datasource', 'DboSource');
  433. $this->assertTrue($file);
  434. $this->assertTrue(class_exists('DboSource'));
  435. }
  436. App::build(array(
  437. 'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
  438. 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
  439. ));
  440. $result = App::import('Controller', 'TestPlugin.Tests');
  441. $this->assertTrue($result);
  442. $this->assertTrue(class_exists('TestPluginAppController'));
  443. $this->assertTrue(class_exists('TestsController'));
  444. $result = App::import('Lib', 'TestPlugin.TestPluginLibrary');
  445. $this->assertTrue($result);
  446. $this->assertTrue(class_exists('TestPluginLibrary'));
  447. $result = App::import('Lib', 'Library');
  448. $this->assertTrue($result);
  449. $this->assertTrue(class_exists('Library'));
  450. $result = App::import('Helper', 'TestPlugin.OtherHelper');
  451. $this->assertTrue($result);
  452. $this->assertTrue(class_exists('OtherHelperHelper'));
  453. $result = App::import('Datasource', 'TestPlugin.TestSource');
  454. $this->assertTrue($result);
  455. $this->assertTrue(class_exists('TestSource'));
  456. App::build();
  457. }
  458. /**
  459. * testFileLoading method
  460. *
  461. * @access public
  462. * @return void
  463. */
  464. function testFileLoading () {
  465. $file = App::import('File', 'RealFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php');
  466. $this->assertTrue($file);
  467. $file = App::import('File', 'NoFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
  468. $this->assertFalse($file);
  469. }
  470. // import($type = null, $name = null, $parent = true, $file = null, $search = array(), $return = false) {
  471. /**
  472. * testFileLoadingWithArray method
  473. *
  474. * @access public
  475. * @return void
  476. */
  477. function testFileLoadingWithArray() {
  478. $type = array('type' => 'File', 'name' => 'SomeName', 'parent' => false,
  479. 'file' => TEST_CAKE_CORE_INCLUDE_PATH . DS . 'config' . DS . 'config.php');
  480. $file = App::import($type);
  481. $this->assertTrue($file);
  482. $type = array('type' => 'File', 'name' => 'NoFile', 'parent' => false,
  483. 'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
  484. $file = App::import($type);
  485. $this->assertFalse($file);
  486. }
  487. /**
  488. * testFileLoadingReturnValue method
  489. *
  490. * @access public
  491. * @return void
  492. */
  493. function testFileLoadingReturnValue () {
  494. $file = App::import('File', 'Name', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', true);
  495. $this->assertTrue($file);
  496. $this->assertTrue(isset($file['Cake.version']));
  497. $type = array('type' => 'File', 'name' => 'OtherName', 'parent' => false,
  498. 'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', 'return' => true);
  499. $file = App::import($type);
  500. $this->assertTrue($file);
  501. $this->assertTrue(isset($file['Cake.version']));
  502. }
  503. /**
  504. * testLoadingWithSearch method
  505. *
  506. * @access public
  507. * @return void
  508. */
  509. function testLoadingWithSearch () {
  510. $file = App::import('File', 'NewName', false, array(TEST_CAKE_CORE_INCLUDE_PATH ), 'config.php');
  511. $this->assertTrue($file);
  512. $file = App::import('File', 'AnotherNewName', false, array(LIBS), 'config.php');
  513. $this->assertFalse($file);
  514. }
  515. /**
  516. * testLoadingWithSearchArray method
  517. *
  518. * @access public
  519. * @return void
  520. */
  521. function testLoadingWithSearchArray () {
  522. $type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(TEST_CAKE_CORE_INCLUDE_PATH ));
  523. $file = App::import($type);
  524. $this->assertTrue($file);
  525. $type = array('type' => 'File', 'name' => 'AnotherRandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(LIBS));
  526. $file = App::import($type);
  527. $this->assertFalse($file);
  528. }
  529. /**
  530. * testMultipleLoading method
  531. *
  532. * @access public
  533. * @return void
  534. */
  535. function testMultipleLoading() {
  536. $toLoad = array('I18n', 'CakeSocket');
  537. $classes = array_flip(get_declared_classes());
  538. $this->assertFalse(isset($classes['i18n']));
  539. $this->assertFalse(isset($classes['CakeSocket']));
  540. $load = App::import($toLoad);
  541. $this->assertTrue($load);
  542. $classes = array_flip(get_declared_classes());
  543. $this->assertTrue(isset($classes['I18n']));
  544. $load = App::import(array('I18n', 'SomeNotFoundClass', 'CakeSocket'));
  545. $this->assertFalse($load);
  546. $load = App::import($toLoad);
  547. $this->assertTrue($load);
  548. }
  549. /**
  550. * This test only works if you have plugins/my_plugin set up.
  551. * plugins/my_plugin/models/my_plugin.php and other_model.php
  552. */
  553. /*
  554. function testMultipleLoadingByType() {
  555. $classes = array_flip(get_declared_classes());
  556. $this->assertFalse(isset($classes['OtherPlugin']));
  557. $this->assertFalse(isset($classes['MyPlugin']));
  558. $load = App::import('Model', array('MyPlugin.OtherPlugin', 'MyPlugin.MyPlugin'));
  559. $this->assertTrue($load);
  560. $classes = array_flip(get_declared_classes());
  561. $this->assertTrue(isset($classes['OtherPlugin']));
  562. $this->assertTrue(isset($classes['MyPlugin']));
  563. }
  564. */
  565. function testLoadingVendor() {
  566. App::build(array(
  567. 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
  568. 'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
  569. ), true);
  570. ob_start();
  571. $result = App::import('Vendor', 'TestPlugin.TestPluginAsset', array('ext' => 'css'));
  572. $text = ob_get_clean();
  573. $this->assertTrue($result);
  574. $this->assertEqual($text, 'this is the test plugin asset css file');
  575. ob_start();
  576. $result = App::import('Vendor', 'TestAsset', array('ext' => 'css'));
  577. $text = ob_get_clean();
  578. $this->assertTrue($result);
  579. $this->assertEqual($text, 'this is the test asset css file');
  580. $result = App::import('Vendor', 'TestPlugin.SamplePlugin');
  581. $this->assertTrue($result);
  582. $this->assertTrue(class_exists('SamplePluginClassTestName'));
  583. $result = App::import('Vendor', 'ConfigureTestVendorSample');
  584. $this->assertTrue($result);
  585. $this->assertTrue(class_exists('ConfigureTestVendorSample'));
  586. ob_start();
  587. $result = App::import('Vendor', 'SomeName', array('file' => 'some.name.php'));
  588. $text = ob_get_clean();
  589. $this->assertTrue($result);
  590. $this->assertEqual($text, 'This is a file with dot in file name');
  591. ob_start();
  592. $result = App::import('Vendor', 'TestHello', array('file' => 'Test'.DS.'hello.php'));
  593. $text = ob_get_clean();
  594. $this->assertTrue($result);
  595. $this->assertEqual($text, 'This is the hello.php file in Test directory');
  596. ob_start();
  597. $result = App::import('Vendor', 'MyTest', array('file' => 'Test'.DS.'MyTest.php'));
  598. $text = ob_get_clean();
  599. $this->assertTrue($result);
  600. $this->assertEqual($text, 'This is the MyTest.php file');
  601. ob_start();
  602. $result = App::import('Vendor', 'Welcome');
  603. $text = ob_get_clean();
  604. $this->assertTrue($result);
  605. $this->assertEqual($text, 'This is the welcome.php file in vendors directory');
  606. ob_start();
  607. $result = App::import('Vendor', 'TestPlugin.Welcome');
  608. $text = ob_get_clean();
  609. $this->assertTrue($result);
  610. $this->assertEqual($text, 'This is the welcome.php file in test_plugin/vendors directory');
  611. }
  612. }
  613. ?>