コード例 #1
0
ファイル: AltrEgoTest.php プロジェクト: leedavis81/altr-ego
 public function testVariableIsNotSet()
 {
     $object = new Fixture\Foo();
     $alterEgo = AltrEgo::create($object);
     $this->assertFalse(isset($alterEgo->nonexistent));
 }
コード例 #2
0
ファイル: example.php プロジェクト: leedavis81/altr-ego
    private $privArray = array('private array entry');
    private function privFunc($value)
    {
        return $value;
    }
    private static function privStatFunc($value)
    {
        return $value;
    }
    public static function publStatFunc($value)
    {
        return self::privStatFunc($value);
    }
}
// First off; create an alter ego
$alterEgo = AltrEgo::create(new Foo());
// Right, now lets get a hook on those private bits
echo $alterEgo->priv . PHP_EOL;
// Woot, works, now lets set it to something else and see what happens
$alterEgo->priv = 'new private value';
echo $alterEgo->priv . PHP_EOL;
// This value remains on your object, even after retrieving it back with $alterEgo->getObject(), now lets try some method calls
echo $alterEgo->privFunc('Private call') . PHP_EOL;
// You can pass in an array of parameters if you wish
var_dump($alterEgo->privFunc('Private', 'call'));
// Now then, onto arrays; You can push values straight into them using standard PHP array syntax. But be aware, the array will be converted (and maintained) as an ArrayObject
$alterEgo->privArray[] = 'new value';
var_dump($alterEgo->privArray);
// You can add associative array values and unset them as you normally would in PHP
$alterEgo->privArray['assoc_key'] = 'private key value entry';
var_dump($alterEgo->privArray);
コード例 #3
0
ファイル: ExposeFieldsTest.php プロジェクト: jdrich/drest
 /**
  * @expectedException \Drest\Query\InvalidExposeFieldsException
  */
 public function testParseExposeStringInvalidString()
 {
     $aeExpose = AltrEgo::create(ExposeFields::create(new RouteMetaData()));
     $exposeString = 'username|profile&';
     $aeExpose->parseExposeString($exposeString);
 }