Beispiel #1
0
 public function testPerformanceMetrics()
 {
     $dal = new DalResolver();
     $this->assertFalse($dal->isCollectingPerformanceMetrics());
     $dal->enablePerformanceMetrics();
     $this->assertTrue($dal->isCollectingPerformanceMetrics());
     $dal->disablePerformanceMetrics();
     $this->assertFalse($dal->isCollectingPerformanceMetrics());
     $dal->enablePerformanceMetrics();
     $id = $dal->startPerformanceMetric('test', DalResolver::MODE_READ, 'SLEEP');
     sleep(1);
     $dal->closePerformanceMetric($id);
     $perfData = $dal->getPerformanceMetrics();
     $this->assertCount(1, $perfData);
     $perfData = reset($perfData);
     $this->assertEquals('test', $perfData['c']);
     $this->assertEquals('SLEEP', $perfData['q']);
     $this->assertEquals(DalResolver::MODE_READ, $perfData['m']);
     $this->assertGreaterThan(1000, $perfData['t']);
     $this->setExpectedException(DalException::class, "You cannot close performance metrics that are not open");
     $dal->closePerformanceMetric($id);
 }
Beispiel #2
0
 public function testLsd()
 {
     $datastore = new MockQlDataStore();
     $connection = new MockPdoConnection();
     $connection->config();
     $datastore->setConnection($connection);
     $connection->connect();
     $resolver = new DalResolver();
     $resolver->addDataStore('mockql', $datastore);
     $resolver->boot();
     $resolver->enablePerformanceMetrics();
     $connection->setResolver($resolver);
     $dao = new MockQlDao();
     $dao->username = time() . 'user';
     $dao->display = 'User ' . date("Y-m-d");
     $dao->boolTest = true;
     $datastore->save($dao);
     $dao->username = '******';
     $dao->display = 'Brooke';
     $dao->boolTest = false;
     $datastore->save($dao);
     $dao->username = '******';
     $datastore->load($dao);
     $this->assertEquals('test 1', $dao->username);
     $this->assertEquals(0, $dao->boolTest);
     $dao->display = 'Save 2';
     $datastore->save($dao);
     $staticLoad = MockQlDao::loadById($dao->id);
     $this->assertEquals($dao->username, $staticLoad->username);
     $datastore->delete($dao);
     $metrics = $resolver->getPerformanceMetrics();
     $resolver->disablePerformanceMetrics();
     $this->assertCount(6, $metrics);
     $resolver->shutdown();
 }