protected function setUp() { parent::setUp(); $_SESSION = array(); Stats::reset(); FrontController::$requestId = null; }
public function poll() { Stats::reset(); session_write_close(); $stop = Clock::now()->plusSeconds(self::TIMEOUT); while (true) { if (!$stop->isAfter(Clock::now()) || connection_aborted()) { $this->layout->renderAjax("[]"); return; } session_start(); $events = Event::loadNew(); session_write_close(); if ($events) { $this->layout->renderAjax(Json::encode(Arrays::map($events, function (Event $event) { return $event->toJsonArray(); }))); return; } Stats::reset(); usleep(100 * 1000); } }
/** * @test */ public function shouldFetchIteratorAndFetchRelationsInBatches() { //given Product::create(array('name' => '1', 'id_category' => Category::create(array('name' => 'cat1'))->getId())); Product::create(array('name' => '2', 'id_category' => Category::create(array('name' => 'cat2'))->getId())); Product::create(array('name' => '3', 'id_category' => Category::create(array('name' => 'cat3'))->getId())); Stats::reset(); //when $results = Product::where()->with('category')->fetchIterator(2); //then Assert::thatArray(iterator_to_array($results))->extracting('name')->containsExactly('1', '2', '3'); $this->assertEquals(3, Stats::getNumberOfQueries()); }