Esempio n. 1
0
 /**
  * @depends test_set
  * @depends test_exists
  */
 public function test_set_call()
 {
     $m = Manager::Create()->set('extension', function () {
         return true;
     });
     $this->assertEquals(true, $m->call(Expandable::create(), 'extension', []));
 }
Esempio n. 2
0
 public function test_create_manager()
 {
     $m = Manager::create()->set('extension', function () {
         return true;
     });
     $c = Unify::create($m);
     $this->assertEquals(true, $c instanceof Collection);
     $this->assertEquals(true, $c->extensions()->exists('extension'));
     $this->assertEquals(false, $c->extensions()->exists('extension2'));
 }
Esempio n. 3
0
 /**
  *  Create an unify collection with specified default packages of extensions
  *
  *  @return \Mecum\Component\Unify\Collection
  */
 public static function createWith(array $libraries)
 {
     $em = Manager::create();
     // add all library specified in the input array
     foreach ($libraries as $library) {
         switch (strtolower($library)) {
             case 'json':
                 $em->add(JsonLibrary::getAll());
                 break;
             case 'xml':
                 $em->add(XmlLibrary::getAll());
                 break;
             case 'yaml':
                 $em->add(YamlLibrary::getAll());
                 break;
             case 'operation':
                 $em->add(OperationLibrary::getAll());
                 break;
             case 'math':
                 $em->add(MathLibrary::getAll());
                 break;
             case 'debug':
                 $em->add(DebugLibrary::getAll());
                 break;
         }
     }
     return Collection::create($em);
 }
Esempio n. 4
0
 /**
  * @expectedException BadMethodCallException
  * @expectedExceptionCode 110
  */
 public function test_call()
 {
     $em = Manager::Create();
     $this->assertEquals(true, $em->call(Expandable::create(), 'extension', []));
 }