当前位置: 首页>>代码示例>>PHP>>正文


PHP Reference::isValidResults方法代码示例

本文整理汇总了PHP中Reference::isValidResults方法的典型用法代码示例。如果您正苦于以下问题:PHP Reference::isValidResults方法的具体用法?PHP Reference::isValidResults怎么用?PHP Reference::isValidResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reference的用法示例。


在下文中一共展示了Reference::isValidResults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: newReport

 public static function newReport($id, $sessionId, $referenceId)
 {
     if (false === Session::isValidSession($sessionId)) {
         throw new Exception('Session ID not valid');
     }
     if (false === Reference::isValidResults($referenceId)) {
         throw new Exception('Reference ID not valid');
     }
     if (!is_numeric($id)) {
         throw new Exception('Not a valid report ID');
     }
     if (ValidationReport::isValidValidationReport($id)) {
         throw new Exception('Report already exists');
     }
     $session = new Session($sessionId);
     $sessionResults = $session->getResults();
     $reference = new Reference($referenceId);
     $referenceResults = $reference->getResults();
     // Index the sessionResults so we can look them up
     $sessionResults['tests'] = array();
     foreach ($sessionResults['results'] as $test) {
         $result = new ResultSupport($test);
         $testName = $result->getTestName();
         if (!array_key_exists($testName, $sessionResults['tests'])) {
             $sessionResults['tests'][$testName] = array();
         }
         $testId = $test['id'];
         $sessionResults['tests'][$testName][$testId] = array();
         foreach ($test['subtests'] as $subtest) {
             $subtestName = ResultSupport::getSubtestName($subtest);
             // Update the results
             $sessionResults['tests'][$testName][$testId][$subtestName] = $subtest['status'];
         }
     }
     // Test statistics
     $testsNotRun = 0;
     $subtestsNotRun = 0;
     $testsFailed = 0;
     $subtestsFailed = 0;
     $log = array();
     // Work through each test
     foreach ($referenceResults['results'] as $test) {
         $result = new ResultSupport($test);
         $testName = $result->getTestName();
         if (!array_key_exists($testName, $sessionResults['tests'])) {
             array_push($log, array('type' => 'error', 'message' => 'FAILURE - TEST NOT RUN', 'test' => $testName, 'reference_test_id' => $test['id']));
             $testsNotRun++;
             continue;
         }
         if ('testharness' == $result->getTestType()) {
             // Counter to see if any of the subtests fail
             $failCheck = $subtestsFailed;
             foreach ($test['subtests'] as $subtest) {
                 $subtestName = ResultSupport::getSubtestName($subtest);
                 // Check the passed tests
                 if ($subtest['status'] === "PASS") {
                     $testRun = false;
                     foreach ($sessionResults['tests'][$testName] as $testId => $subtestList) {
                         if (array_key_exists($subtestName, $subtestList)) {
                             $testRun = $testId;
                             break;
                         }
                     }
                     if (false === $testRun) {
                         array_push($log, array('type' => 'error', 'message' => 'FAILURE - SUBTEST NOT RUN', 'test' => $testName, 'subtest' => $subtestName, 'reference_test_id' => $test['id'], 'test_ids' => array_keys($sessionResults['tests'][$testName])));
                         $subtestsNotRun++;
                         continue;
                     }
                     if ($sessionResults['tests'][$testName][$testRun][$subtestName] === "PASS") {
                         //fprintf(STDOUT, "  PASS: %s /  %s\n", $testName, $subtestName);
                     } else {
                         array_push($log, array('type' => 'error', 'message' => 'FAILURE - SUBTEST FAILED', 'test' => $testName, 'subtest' => $subtestName, 'reference_test_id' => $test['id'], 'test_id' => $testRun));
                         $subtestsFailed++;
                     }
                 }
             }
             // Check if any of the subtests failed
             if ($failCheck != $subtestsFailed) {
                 $testsFailed++;
             }
         } else {
         }
     }
     $status = array('session' => $sessionId, 'reference' => $referenceId, 'tests_not_run' => $testsNotRun, 'subtests_not_run' => $subtestsNotRun, 'tests_failed' => $testsFailed, 'subtests_failed' => $subtestsFailed, 'log_total' => count($log));
     $dir = VALIDATION_REPORT_DIR . '/' . $id;
     mkdir($dir);
     file_put_contents($dir . '/status', json_encode($status));
     file_put_contents($dir . '/report', json_encode($log));
     return new ValidationReport($id);
 }
开发者ID:jeremypoulter,项目名称:WPT_Results_Collection_Server,代码行数:90,代码来源:ValidationReport.php

示例2: Notify

            Notify(ADMIN_TOPIC, array('action' => 'result', 'session' => $session->getInfo(), 'result' => $result));
            $app->render(200, array());
        } else {
            $app->render(400, array('error' => true, 'msg' => 'Not JSON'));
        }
    });
    $app->options('/:param+', function ($param) use($app) {
        $app->render(200, array());
    });
});
$app->group('/references', function () use($app) {
    $app->get('/', function () use($app) {
        $references = array();
        if ($dh = opendir(REFERENCE_DIR)) {
            while (($file = readdir($dh)) !== false) {
                if (Reference::isValidResults($file)) {
                    $reference = new Reference($file);
                    $referenceInfo = $reference->getInfo();
                    $referenceInfo['href'] = $app->urlFor('references', array('id' => $file));
                    array_push($references, $referenceInfo);
                }
            }
            closedir($dh);
        }
        sort($references);
        $app->render(200, array('references' => $references));
    })->name('referenceIndex');
    $app->post('/', function () use($app) {
        global $status, $statusModified;
        // Create a new session
        $reference = Reference::createReference($status['reference'], $app->request()->params('sessions'), $app->request()->params('name'), $app->request()->params('minPass'));
开发者ID:jeremypoulter,项目名称:WPT_Results_Collection_Server,代码行数:31,代码来源:api.php


注:本文中的Reference::isValidResults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。