Skip to content

Instantly share code, notes, and snippets.

Created May 22, 2010 12:32
Show Gist options
  • Select an option

  • Save anonymous/410039 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/410039 to your computer and use it in GitHub Desktop.
<?php
require_once dirname(__FILE__) . '/../../../TestHelper.php';
require_once 'Zfast/Compiler/Detector/Oop.php';
require_once 'Zfast/Compiler/Class.php';
class Zfast_Compiler_Detector_OopTest extends PHPUnit_Framework_TestCase {
public function testDetectImplementedInterfaces() {
$detector = new Zfast_Compiler_Detector_Oop();
// implements one interface
$source = Zfast_Compiler_Class::factory('<?php class A implements B {}', '/tmp/A.php');
$this->assertEquals(array('B'), $detector->detect($source->getSource()));
// implements many interfaces
$source = Zfast_Compiler_Class::factory('<?php class A implements B, C, D, E, F {}', '/tmp/A.php');
$this->assertEquals(array('B', 'C', 'D', 'E', 'F'), $detector->detect($source->getSource()));
}
public function testDetectExtendedClasses() {
$detector = new Zfast_Compiler_Detector_Oop();
// extends class B
$source = Zfast_Compiler_Class::factory('<?php class A extends B {}', '/tmp/A.php');
$this->assertEquals(array('B'), $detector->detect($source->getSource()));
// extends class C
$source = Zfast_Compiler_Class::factory('<?php class A extends C {}', '/tmp/A.php');
$this->assertEquals(array('C'), $detector->detect($source->getSource()));
}
public function testNoDependencies() {
$detector = new Zfast_Compiler_Detector_Oop();
// class A
$source = Zfast_Compiler_Class::factory('<?php class A {}', '/tmp/A.php');
$this->assertEquals(array(), $detector->detect($source->getSource()));
}
public function testDetectsClassesAndInterfaces() {
$detector = new Zfast_Compiler_Detector_Oop();
// extends and implements
$source = Zfast_Compiler_Class::factory('<?php class A extends B implements C, D, E, F {}', '/tmp/A.php');
$this->assertEquals(array('B', 'C', 'D', 'E', 'F'), $detector->detect($source->getSource()));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment