Пример #1
0
 public function testRun()
 {
     $client = new Client();
     $called = false;
     $client->queue('http://localhost/', function ($response, $client) use(&$called) {
         $this->assertInstanceOf('Fetcher\\Response', $response);
         $this->assertInstanceOf('Fetcher\\Client', $client);
         $called = true;
     });
     $client->run();
     $this->assertTrue($called);
 }
Пример #2
0
 public function testRun()
 {
     $called = 0;
     $one = new Client();
     $one->queue('http://localhost/one', function ($response, $client, $master) use($one, &$called) {
         $this->assertEquals($one, $client);
         $this->assertInstanceOf('Fetcher\\Response', $response);
         $called++;
     });
     $two = new Client();
     $two->queue('http://localhost/two.1', function ($response, $two, $master) use(&$called) {
         $called++;
         $two->queue('http://localhost/two.2', function () use(&$called) {
             $called++;
         });
         $master->createClient()->queue('http://localhost/master', function () use(&$called) {
             $called++;
         });
     });
     $master = new Parallel();
     $master->run(array($one, $two));
     $this->assertEquals(4, $called);
 }