예제 #1
0
 public function test_interface_delegation()
 {
     parse_and_eval(dirname(__FILE__) . '/interface_delegation_test_interface.phpx');
     parse_and_eval(dirname(__FILE__) . '/interface_delegation_test_class.phpx');
     $a = new EIDTC_Addressable();
     assert_equal("message sent to foo@bar.com", $a->send_to("*****@*****.**"));
 }
예제 #2
0
파일: mixin_test.php 프로젝트: jaz303/phpx
 public function test_mixins()
 {
     parse_and_eval(dirname(__FILE__) . '/mixin_test_mixins.phpx');
     parse_and_eval(dirname(__FILE__) . '/mixin_test_classes.phpx');
     $thing = new EMT_Foo();
     assert_equal('foo', $thing->foo());
     assert_equal('bar', EMT_Foo::bar());
     assert_equal('baz', EMT_Foo::BAZ);
 }
예제 #3
0
 public function test_annotations()
 {
     parse_and_eval(dirname(__FILE__) . '/annotation_test_class.phpx');
     assert_equal(array('model' => true), phpx\annotations_for('ExamplesAnnotationTestClass'));
     assert_equal(array('model' => true), phpx\annotations_for(new ExamplesAnnotationTestClass()));
     assert_equal(array('foo' => 'bar'), phpx\annotations_for('ExamplesAnnotationTestClass', '$baz'));
     assert_equal(array('foo' => 'bar'), phpx\annotations_for(new ExamplesAnnotationTestClass(), '$baz'));
     assert_equal(array('access' => array('admin', 'public')), phpx\annotations_for('ExamplesAnnotationTestClass', 'find_all'));
     assert_equal(array('access' => array('admin', 'public')), phpx\annotations_for(new ExamplesAnnotationTestClass(), 'find_all'));
 }
예제 #4
0
 public function test_mixins()
 {
     phpx\register_macro('ecet_greet', 'ECET_GreetMacro');
     parse_and_eval(dirname(__FILE__) . '/class_eval_test_class.phpx');
     assert_equal(15, ExamplesClassEvalTestClass::add(10, 5));
     $foo = new ExamplesClassEvalTestClass();
     $foo->set_foo('hello world');
     assert_equal('HELLO WORLD', $foo->get_foo());
     assert_equal('Hello Jason', $foo->greet('Jason'));
 }
예제 #5
0
 public function test_mixins()
 {
     parse_and_eval(dirname(__FILE__) . '/hierarchy_test_1.phpx');
     parse_and_eval(dirname(__FILE__) . '/hierarchy_test_2.phpx');
     parse_and_eval(dirname(__FILE__) . '/hierarchy_test_3.phpx');
     $class_def = \phpx\Library::get_class_definition('\\HHT3');
     $hierarchy = $class_def->get_class_hierarchy();
     assert_equal(3, count($hierarchy));
     assert_equal('\\HHT1', $hierarchy[0]->get_qualified_name());
     assert_equal('\\HHT2', $hierarchy[1]->get_qualified_name());
     assert_equal('\\HHT3', $hierarchy[2]->get_qualified_name());
 }
예제 #6
0
 public function test_pattern_matching()
 {
     parse_and_eval(dirname(__FILE__) . '/pattern_matching_test_class.phpx');
     $i = new ExamplesPatternMatchingTestClass();
     assert_equal('foo:render', $i->render_template('foo'));
     assert_equal('bar:display', $i->display_template('bar'));
     assert_equal('people', $i->find_people());
     assert_equal('managers', $i->find_managers());
     assert_equal('all:1', ExamplesPatternMatchingTestClass::find_all(1));
     assert_equal('one:2', ExamplesPatternMatchingTestClass::find_one(2));
     assert_equal('foo', ExamplesPatternMatchingTestClass::foo());
     assert_equal('bar', ExamplesPatternMatchingTestClass::bar());
 }
예제 #7
0
 public function test_forward_declarations()
 {
     phpx\Forward::before('ExamplesForwardTestClass', function ($class) {
         $class->define_public_instance_method('forward_1', 'return "forward_1";');
     });
     phpx\Forward::before('ExamplesForwardTestClass')->define_public_instance_method('forward_2', 'return "forward_2";');
     phpx\Forward::after('ExamplesForwardTestClass', function ($class) {
         $class->define_public_instance_method('after_1', 'return "after_1";');
     });
     phpx\Forward::after('ExamplesForwardTestClass')->define_public_instance_method('after_2', 'return "after_2";');
     parse_and_eval(dirname(__FILE__) . '/forward_test_class.phpx');
     $item = new ExamplesForwardTestClass();
     assert_equal('forward_1', $item->forward_1());
     assert_equal('forward_2', $item->forward_2());
     assert_equal('after_1', $item->after_1());
     assert_equal('after_2', $item->after_2());
 }
예제 #8
0
 public function test_mixins()
 {
     parse_and_eval(dirname(__FILE__) . '/inheritable_attribute_test_1.phpx');
     parse_and_eval(dirname(__FILE__) . '/inheritable_attribute_test_2.phpx');
     parse_and_eval(dirname(__FILE__) . '/inheritable_attribute_test_3.phpx');
     $i1 = new IAT1Test1();
     assert_equal(1, $i1->get_static('a'));
     assert_equal(1, $i1->get_static('b'));
     assert_equal(1, $i1->get_static('c'));
     assert_equal(array('a' => 1, 'b' => 1, 'c' => 1), $i1->get_static('d'));
     $i2 = new IAT1Test2();
     assert_equal(1, $i2->get_static('a'));
     assert_equal(2, $i2->get_static('b'));
     assert_equal(2, $i2->get_static('c'));
     assert_equal(array('a' => 1, 'b' => 2, 'c' => 2), $i2->get_static('d'));
     $i3 = new IAT1Test3();
     assert_equal(1, $i3->get_static('a'));
     assert_equal(2, $i3->get_static('b'));
     assert_equal(3, $i3->get_static('c'));
     assert_equal(array('a' => 1, 'b' => 2, 'c' => 3), $i3->get_static('d'));
 }