/**
  * Helper method
  * @param   string name
  * @param   lang.XPClass class
  * @throws  unittest.AssertionFailedError
  */
 protected function defineInterface($name, $parents, $bytes)
 {
     if (interface_exists(\xp::reflect($name), false)) {
         $this->fail('Interface "' . $name . '" may not exist!');
     }
     return \lang\ClassLoader::defineInterface($name, $parents, $bytes);
 }
Exemplo n.º 2
0
 public function allowDoubledInterfaceMethod()
 {
     $this->proxyInstanceFor([$this->iteratorClass, ClassLoader::defineInterface('util.NewIterator', XPIterator::class)]);
 }
 /**
  * This `define()` implementation creates interfaces
  *
  * @param   [:var] $decl
  * @param   var $def
  * @return  lang.XPClass
  */
 protected function define(array $decl = [], $def = null)
 {
     return $this->defineType(array_key_exists('annotations', $decl) ? $decl['annotations'] : '', array_key_exists('name', $decl) ? $decl['name'] : '', function ($spec) use($decl, $def) {
         return ClassLoader::defineInterface($spec, array_key_exists('parents', $decl) ? $decl['parents'] : [], $def);
     });
 }
 public function defined_interface_exists()
 {
     ClassLoader::defineInterface('net.xp_framework.unittest.core.NamespaceAliasInterfaceFixture', [], '{}');
     $this->assertTrue(interface_exists('net\\xp_framework\\unittest\\core\\NamespaceAliasInterfaceFixture', false));
 }
Exemplo n.º 5
0
 public function module_implementation()
 {
     $cl = ClassLoader::defineInterface('net.xp_framework.unittest.reflection.IModule', []);
     $this->register(new LoaderProviding(['module.xp' => '<?php module xp-framework/impl implements net\\xp_framework\\unittest\\reflection\\IModule { }']));
     $this->assertTrue(in_array($cl, Module::forName('xp-framework/impl')->getClass()->getInterfaces()));
 }
 public function namespaced_parameters_handled_correctly()
 {
     $class = $this->proxyClassFor([\lang\ClassLoader::defineInterface('net.xp_framework.unittest.test.mock.NSInterface', [], '{
   public function fixture(\\lang\\types\\Long $param);
 }')]);
     $this->assertEquals(\lang\XPClass::forName('lang.types.Long'), $class->getMethod('fixture')->getParameters()[0]->getType());
 }
Exemplo n.º 7
0
 public function allowDoubledInterfaceMethod()
 {
     $newIteratorClass = ClassLoader::defineInterface('util.NewIterator', 'util.XPIterator');
     $this->proxyInstanceFor(array(XPClass::forName('util.XPIterator'), XPClass::forName('util.NewIterator')));
 }