public function testSave() { $data = file_get_contents('tests/fixtures/results.json'); $profiles = $this->getMockBuilder('Xhgui_Profiles')->disableOriginalConstructor()->getMock(); $profiles->expects($this->once())->method('insert')->with($this->equalTo($data)); $saver = new Xhgui_Saver_Mongo($profiles); $saver->save($data); }
/** * {@inheritDoc} */ public function save_run($xhprof_data, $type, $run_id = null) { if (!class_exists('\\Xhgui_Profiles') || !class_exists('\\Xhgui_Saver_Mongo')) { throw new \Exception('composer require perftools/xhgui dev-master'); } $data = $this->prepareForSave($xhprof_data); $dbname = $this->documentManager->getConfiguration()->getDefaultDB(); $mongo = $this->documentManager->getConnection()->getMongoClient()->selectDB($dbname); $profiles = new \Xhgui_Profiles($mongo); $saver = new \Xhgui_Saver_Mongo($profiles); try { $saver->save($data); $run_id = (string) $data['_id']; } catch (\Exception $e) { error_log($e->getMessage()); } return $run_id; }