コード例 #1
0
 public function testBasicFunctionality()
 {
     $registry = new Registry();
     // Adding yields ID 1
     $this->assertEquals(1, $registry->append('test'));
     // Repetition yields the same ID
     $this->assertEquals(1, $registry->append('test'));
     // Checking the ID another way
     $this->assertEquals(1, $registry->bit('test'));
     // Testing whether test exists
     $this->assertTrue($registry->exists('test'));
     // Adding a few more items
     $this->assertEquals(2, $registry->append('test2'));
     $this->assertEquals(4, $registry->append('test3'));
     $this->assertEquals(8, $registry->append('test4'));
     $this->assertEquals(8, $registry->bit('test4'));
     $this->assertFalse($registry->exists('test5'));
 }
コード例 #2
0
ファイル: Navigator.php プロジェクト: daviddeutsch/saltwater
 /**
  * Generic call for a type of provider
  *
  * @param string $type
  * @param string $caller Caller module name
  *
  * @return Provider
  */
 public function provider($type, $caller = null)
 {
     $salt = 'provider.' . $type;
     if (!($bit = $this->registry->bit($salt))) {
         S::halt(500, 'provider does not exist: ' . $type);
     }
     if (empty($caller)) {
         $caller = $this->modules->finder->find(Backtrace::lastCaller(), $salt);
     }
     return $this->modules->finder->provider($bit, $caller, $type);
 }