Example #1
0
         assert($test->peridotGetParentScope() === $this->scope, "should have set parent scope");
     });
 });
 describe('->peridotBindTo()', function () {
     it('should bind a Closure to the scope', function () {
         $callable = function () {
             return $this->name;
         };
         $scope = new TestScope();
         $bound = $scope->peridotBindTo($callable);
         $result = $bound();
         assert($result == "brian", "scope should have been bound to callable");
     });
     it('should return non closures', function () {
         $callable = 'strpos';
         $scope = new TestScope();
         $bound = $scope->peridotBindTo($callable);
         assert($bound === 'strpos');
     });
 });
 context("when calling a mixed in method", function () {
     it('should throw an exception when method not found', function () {
         $exception = null;
         try {
             $this->scope->nope();
         } catch (\Exception $e) {
             $exception = $e;
         }
         assert(!is_null($exception), 'exception should not be null');
     });
     context("and the desired method is on a child scope's child", function () {
Example #2
0
         assert($this->scope->removeChildScope('test') === false);
     });
 });
 describe('->bindTo()', function () {
     it('should bind a Closure to the scope', function () {
         $callable = function () {
             return $this->name;
         };
         $scope = new TestScope();
         $bound = $scope->bindTo($callable);
         $result = $bound();
         assert($result == "brian", "scope should have been bound to callable");
     });
     it('should return non closures', function () {
         $callable = 'strpos';
         $scope = new TestScope();
         $bound = $scope->bindTo($callable);
         assert($bound === 'strpos');
     });
 });
 context("when calling a mixed in method", function () {
     it('should throw an exception when method not found', function () {
         $exception = null;
         try {
             $this->scope->nope();
         } catch (\Exception $e) {
             $exception = $e;
         }
         assert(!is_null($exception), 'exception should not be null');
     });
     context('and the desired method is on a parent scope', function () {