Beispiel #1
0
 public function testOutputContent()
 {
     $obj = new _Json();
     $json_data = ['first_element' => 'test', 'second_element' => ['a' => 'test a', 'b' => 'test b']];
     $json_content = file_get_contents(TEST_FILES . 'test_output_pretty.json');
     $json_output = $obj->outputContent($json_data, false, true);
     $this->string($json_output)->isEqualTo($json_content);
     $json_content = file_get_contents(TEST_FILES . 'test_output.json');
     $json_output = $obj->outputContent($json_data, false, false);
     $this->string($json_output)->isEqualTo($json_content);
 }
namespace Webdashboard;

use Bugzilla\Bugzilla;
use Cache\Cache;
require_once __DIR__ . '/../config/init.php';
// Include all data about our locales
include __DIR__ . '/../data/locales.php';
$results = [];
$results['types']["Webbugs"] = ["pluralLabel" => "Webbugs"];
$results['properties']["total_webbugs"] = ["valueType" => "number"];
$results['properties']["missing_webbugs"] = ["valueType" => "number"];
// All opened bugs for a locale in the mozilla.org/l10n component
foreach ($locales as $locale) {
    $bugzilla_query = 'https://bugzilla.mozilla.org/buglist.cgi?' . 'f1=cf_locale' . '&o1=equals' . '&query_format=advanced' . '&v1=' . urlencode(Bugzilla::getBugzillaLocaleField($locale)) . '&o2=equals' . '&f2=component' . '&v2=L10N' . '&bug_status=UNCONFIRMED' . '&bug_status=NEW' . '&bug_status=ASSIGNED' . '&bug_status=REOPENED' . '&classification=Other' . '&product=www.mozilla.org';
    /* Check if there is a cached request for this element.
     * For this request I use a ttl of 6 hours instead of default (15 minutes),
     * since it requires a lot of time.
     */
    $cache_id = "bugs_mozillaorg_{$locale}";
    $bugs = Cache::getKey($cache_id, 6 * 60 * 60);
    if ($bugs === false) {
        $csv = file($bugzilla_query . '&ctype=csv');
        $bugs = Bugzilla::getBugsFromCSV($csv);
        Cache::setKey($cache_id, $bugs);
    }
    // Generate all the bugs
    $results['items'][] = ["type" => "Webbugs", "label" => $locale, "missing_webbugs" => count($bugs), "total_webbugs" => count($bugs)];
}
$json_data = new Json();
print $json_data->outputContent($results, false, true);