示例#1
0
文件: Firebug.php 项目: rexmac/zf2
 /**
  * Intercept the query end and log the profiling data.
  *
  * @param  integer $queryId
  * @throws \Zend\Db\Profiler\Exception
  * @return void
  */
 public function queryEnd($queryId)
 {
     $state = parent::queryEnd($queryId);
     if (!$this->getEnabled() || $state == self::IGNORED) {
         return;
     }
     $this->_message->setDestroy(false);
     $profile = $this->getQueryProfile($queryId);
     $this->_totalElapsedTime += $profile->getElapsedSecs();
     $this->_message->addRow(array((string) round($profile->getElapsedSecs(), 5), $profile->getQuery(), ($params = $profile->getQueryParams()) ? $params : null));
     $this->updateMessageLabel();
 }
示例#2
0
    /**
     * @group ZF-5742
     */
    public function testTableMessage()
    {
        $table = new FirePhp\TableMessage('TestMessage');

        $this->assertEquals($table->getLabel(), 'TestMessage');

        try {
            $table->getLastRow();
            $this->fail('Should throw exception when no rows exist');
        } catch (\Exception $e) {
            // success
        }

        $row = array('col1','col2');

        $this->assertEquals($table->getRowCount(), 0);

        try {
            $table->getRowAt(1);
            $this->fail('Should throw exception as no rows present');
        } catch (\Exception $e) {
            // success
        }

        try {
            $table->setRowAt(1,array());
            $this->fail('Should throw exception as no rows present');
        } catch (\Exception $e) {
            // success
        }

        $table->addRow($row);

        $this->assertEquals($table->getMessage(), array($row));
        $this->assertEquals($table->getLastRow(), $row);

        $this->assertEquals($table->getRowCount(), 1);

        $table->addRow($row);

        $this->assertEquals($table->getMessage(), array($row,
                                                        $row));

        $this->assertEquals($table->getRowCount(), 2);
        $this->assertEquals($table->getLastRow(), $row);

        try {
            $table->getRowAt(2);
            $this->fail('Should throw exception as index is out of bounds');
        } catch (\Exception $e) {
            // success
        }

        try {
            $table->setRowAt(2,array());
            $this->fail('Should throw exception as index is out of bounds');
        } catch (\Exception $e) {
            // success
        }

        $rowOld = $table->getRowAt(1);
        $this->assertEquals($rowOld, $row);

        $rowOld[1] = 'Column2';
        $table->setRowAt(1, $rowOld);

        $this->assertEquals($table->getRowAt(1), $rowOld);
        $this->assertEquals($table->getLastRow(), $rowOld);

        $this->assertEquals($table->getMessage(), array($row,
                                                        $rowOld));

        $header = array('hc1', 'hc2');
        $table->setHeader($header);

        $this->assertEquals($table->getMessage(), array($header,
                                                        $row,
                                                        $rowOld));
    }