/** * Returns test cases for testAutoload() * * A test case is class name and a path to the definition of this * class name. * * @see testAutoload() * @return array */ public function provideTestAutoload() { $autoloaderTestHelper = new AutoloaderTestHelper($this); $return = array(); $class = $autoloaderTestHelper->makeClass("ClassA", 'testInternal'); $return[] = array($class, $autoloaderTestHelper->getGeneratedClassPath($class)); $class = $autoloaderTestHelper->makeClass("ClassA2", 'testInternal'); $return[] = array($class, $autoloaderTestHelper->getGeneratedClassPath($class)); $class = $autoloaderTestHelper->makeClass("ClassB", 'testInternal/sub'); $return[] = array($class, $autoloaderTestHelper->getGeneratedClassPath($class)); return $return; }
/** * Provides testLoadsOfFiles() with test cases * * A test case is an instance of AutoloaderFileIterator and a class path. * The class path should contain a large amount of files. * * @see testLoadsOfFiles() * @return Array */ public function provideTestLoadsOfFiles() { AutoloaderTestHelper::deleteDirectory("testLoadsOfFiles"); $alTestHelper = new AutoloaderTestHelper($this); for ($i = 0; $i < 150; $i++) { $alTestHelper->makeClass("anyClass", "testLoadsOfFiles/flat"); } for ($i = 0; $i < 150; $i++) { $alTestHelper->makeClass("anyClass", "testLoadsOfFiles" . str_repeat('/sub', $i)); } return array(array(new AutoloaderFileIterator_PriorityList(), "testLoadsOfFiles/flat"), array(new AutoloaderFileIterator_Simple(), "testLoadsOfFiles/flat"), array(new AutoloaderFileIterator_SimpleCached(), "testLoadsOfFiles/flat"), array(new AutoloaderFileIterator_PriorityList(), "testLoadsOfFiles/sub"), array(new AutoloaderFileIterator_Simple(), "testLoadsOfFiles/sub"), array(new AutoloaderFileIterator_SimpleCached(), "testLoadsOfFiles/sub")); }
/** * Provides test cases for testFailBuildIndex() * * A test case is an Autoloader instance. The class path of that instance * should contain multiple class definitions for the same class name. * * @see testFailBuildIndex() * @return Array */ public function provideTestFailBuildIndex() { $cases = array(); $definition = "<?php class XXXTest" . uniqid() . " {} ?>"; $testHelper = new AutoloaderTestHelper($this); $testHelper->makeClass('Test', 'testFailBuildIndexA/'); $testHelper->makeClass('Test', 'testFailBuildIndexA/', $definition); $testHelper->makeClass('Test', 'testFailBuildIndexA/', $definition); $cases[] = array(new Autoloader($testHelper->getClassDirectory('testFailBuildIndexA'))); $testHelper = new AutoloaderTestHelper($this); $testHelper->makeClass('Test', 'testFailBuildIndexB/A', $definition); $testHelper->makeClass('Test', 'testFailBuildIndexB/A'); $testHelper->makeClass('Test', 'testFailBuildIndexB/B', $definition); $testHelper->makeClass('Test', 'testFailBuildIndexB/B'); $cases[] = array(new Autoloader($testHelper->getClassDirectory('testFailBuildIndexB'))); return $cases; }