Inheritance: extends Bar
示例#1
0
 public function testSpy()
 {
     $dependency = $this->prophesize(\Foo\DependencyInterface::class);
     $foo = new Foo($dependency->reveal());
     $foo->baz();
     $dependency->boolGenerator(1)->shouldHaveBeenCalled();
 }
示例#2
0
 public function testMockedMethodIsProxiedToOriginalMethod()
 {
     $proxy = $this->getMockBuilder('Bar')->enableProxyingToOriginalMethods()->getMock();
     $proxy->expects($this->once())->method('doSomethingElse');
     $foo = new Foo();
     $this->assertEquals('result', $foo->doSomething($proxy));
 }
示例#3
0
function main()
{
    $f = new Foo();
    var_dump($f->getter());
    $f->heh();
    var_dump($f->getter());
}
示例#4
0
 /**
  * @expectedException Fliglio\Web\ValidationException
  */
 public function testValidationError()
 {
     // given
     $expectedFoo = new Foo("invalid");
     // when
     $expectedFoo->validate();
 }
示例#5
0
 public function testLoadConfigFromFile()
 {
     $file = __DIR__ . '/fixtures/configurabletrait-test.php';
     $foo = new Foo();
     $foo->loadConfigFromFile($file);
     $this->assertTrue(in_array($file, get_included_files()));
 }
示例#6
0
 function baa(Foo $param)
 {
     if ($param->valid()) {
         echo 'valid';
     } else {
         echo 'invalid';
     }
 }
示例#7
0
 /**
  * This test function contains a code which will
  * create a php warning to happen. This eample show 
  * that in phpunit it will treated as an exception and 
  * it could be catched by 'expectedException' tag and 
  * exception name would be 'PHPUnit_Framework_Error'
  * 
  * @expectedException PHPUnit_Framework_Error
  */
 public function testPhpError()
 {
     $foo_obj = new Foo();
     # Line below will throw an exception here only
     $foo_obj->bar();
     # Code execution will never reach this point
     $this->assertTrue(true);
 }
示例#8
0
function test_dynamic_new()
{
    $f = new Foo();
    $f->bar();
    $k = "Foo";
    $g = new $k();
    $g->bar();
}
示例#9
0
 public function testActionKnown()
 {
     try {
         $foo = new Foo(new \Glossary\View());
         $foo->action('baz', array());
     } catch (Exception $e) {
         $this->fail();
     }
 }
示例#10
0
function main()
{
    $a = new Foo();
    $a->identity(232);
    $a->identity(42);
    $a->identity(0);
    add(1, 1);
    add(0, 0);
}
示例#11
0
function test()
{
    $e = new Foo();
    try {
        throw new Exception("ops 2");
    } catch (Exception $e) {
        echo $e->getMessage() . "\n";
    }
}
示例#12
0
function main()
{
    // just checking it can be default-constructed...
    var_dump((new Foo())->getMessage());
    $junk = new Exception();
    $foo = new Foo('hello, world', 1337, $junk);
    var_dump($foo->getMessage());
    var_dump($foo->getCode());
    var_dump($foo->getPrevious() === $junk);
}
 public function testDeleteAllMethod()
 {
     $foo = new Foo();
     $foo->setProperty(array('foo' => 'boo', 'bar' => 'moo'));
     $this->assertEquals(array('foo' => 'boo', 'bar' => 'moo'), $foo->getProperty());
     $foo->deleteProperty();
     $this->assertEquals(array(), $foo->getProperty());
     $this->assertFalse($foo->hasPropertyKey('foo'));
     $this->assertCount(0, $foo->getProperty());
 }
 /**
  * Returns a collection of Foo instances according to
  * the configuration section.
  */
 public function &process(__ConfigurationSection &$section)
 {
     $return_value = array();
     $foobars = $section->getSections();
     foreach ($foobars as &$foobar) {
         $foo = new Foo();
         $foo->setBar($foobar->getAttribute('bar'));
         $return_value[] = $foo;
     }
     return $return_value;
 }
示例#15
0
 public function testContainersPersistBetweenInstances()
 {
     $foo1 = new Foo();
     $foo1->append('Foo');
     $foo1->setSeparator(' - ');
     $foo2 = new Foo();
     $foo2->append('Bar');
     $test = $foo1->toString();
     $this->assertContains('Foo', $test);
     $this->assertContains(' - ', $test);
     $this->assertContains('Bar', $test);
 }
示例#16
0
 public function testStaticApiMapper()
 {
     // given
     $entity = new Foo("foo");
     $vo = ["myProp" => "foo"];
     // when
     $foundVo = $entity->marshal();
     $foundEntity = Foo::unmarshal($vo);
     // then
     $this->assertEquals($entity, $foundEntity);
     $this->assertEquals($vo, $foundVo);
 }
示例#17
0
 public function __construct()
 {
     parent::__construct();
     echo "From ", __METHOD__, ":", "\n";
     echo parent::self, "\n";
     echo parent::parent, "\n";
 }
 public function __construct()
 {
     parent::__construct();
     echo "From ", __METHOD__, ":", PHP_EOL;
     echo parent::self, PHP_EOL;
     echo parent::parent, PHP_EOL;
 }
示例#19
0
 protected function eraseData()
 {
     Foo::truncate();
     Bar::truncate();
     Baz::truncate();
     Bom::truncate();
 }
示例#20
0
 function __destruct()
 {
     $this->orStatus(2);
     if (method_exists(parent, "__destruct")) {
         parent::__destruct();
     }
 }
示例#21
0
 function go()
 {
     $y = Foo::fun();
     var_dump($y);
     $y = Foo::fun();
     var_dump($y);
 }
示例#22
0
 public function test_kissmock_usage()
 {
     $bar = new BarMock();
     $bar->_mock->setMethodReturnValue('methodBar', 'a', 1);
     $bar->_mock->setMethodReturnValue('methodBar', 'b', 2);
     $foo = new Foo($bar);
     $ret1 = $foo->methodFoo();
     $ret2 = $foo->methodFoo();
     $this->assertEqual($ret1, 'a');
     $this->assertEqual($ret2, 'b');
     $callCount = $bar->_mock->getMethodCallCount('methodBar');
     $this->assertEqual($callCount, 2);
     $args1 = $bar->_mock->getMethodArgs('methodBar', 1);
     $args2 = $bar->_mock->getMethodArgs('methodBar', 2);
     $this->assertEqual($args1[0], 1);
     $this->assertEqual($args1[1], 'two');
     $this->assertEqual($args2[0], 1);
     $this->assertEqual($args2[1], 'two');
 }
 public static function invoke(Foo $instance)
 {
     // Same class, other instance, direct call.
     $instance->call();
     // Same class, other instance, indirect call.
     $foo = new Foo();
     $foo->call();
     // Same class, other instance, indirect call.
     $x = new Foo();
     $y = $x;
     $z = $y;
     $z->call();
     // Same class, other instance, direct call.
     (new Foo())->call();
     // Other class, other instance, indirect call.
     $bar = new Bar();
     $bar->call();
     // Other class, other instance, direct call.
     (new Bar())->call();
 }
示例#24
0
文件: setter.php 项目: badlamer/hhvm
function main()
{
    $k = new Foo("something");
    echo $k->getX();
    echo "\n";
    $k->setX("foo");
    echo $k->getX();
    echo "\n";
    $k->setXVerified("string");
    echo $k->getX();
    echo "\n";
    $k->setY(new Bar());
}
示例#25
0
文件: ObjectTest.php 项目: jyxo/php
 /**
  * Runs the whole test.
  */
 public function test()
 {
     require_once DIR_FILES . '/spl/Foo.php';
     $foo = new \Foo();
     // Right class name
     $this->assertEquals('Foo', $foo->getClass());
     // Setting parameter values
     $foo->x = 1;
     $foo->y = true;
     // Setting a non-existent parameter value
     $foo->z = 'test';
     // Fetching parameter values
     $this->assertSame(1, $foo->x);
     $this->assertTrue($foo->y);
     // Fetching value of a non-existent parameter
     $this->assertNull($foo->z);
     // Testing parameter existence
     $this->assertTrue(isset($foo->x));
     $this->assertTrue(isset($foo->y));
     $this->assertFalse(isset($foo->z));
     // Testing toArray conversion
     $array = ['x' => 1, 'y' => true];
     $this->assertEquals($array, $foo->toArray());
 }
示例#26
0
 /**
  * Gets the 'foo_with_inline' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \Foo A Foo instance.
  */
 protected function getFooWithInlineService()
 {
     $this->services['foo_with_inline'] = $instance = new \Foo();
     $instance->setBar($this->get('inlined'));
     return $instance;
 }
示例#27
0
<?php

/**
 * Another file used for testing
 */
require_once "newfolder/subdir/things.php";
$b = Foo::bar();
示例#28
0
文件: lvalue.php 项目: Halfnhav4/pfff
function foo()
{
    //Foo::foo(1, 2);
    Foo::foo(1, 2)->foobar();
}
function testChainedPropertyAssignmentExpressionHasExpectedEndLine()
{
    Foo::bar(__FUNCTION__)->baz(__FILE__)->value = 'FOOBAR';
}
示例#30
0
文件: 2085.php 项目: badlamer/hhvm
<?php

trait Too
{
    function bar()
    {
        $abc = 123;
        $a = function ($x) use($abc) {
            $n = func_num_args();
            $args = func_get_args();
            var_dump($n, $args);
        };
        return $a;
    }
    function baz($obj)
    {
        $abc = 456;
        $obj(789);
    }
}
class Foo
{
    use Too;
}
$a = Foo::bar();
Foo::baz($a);