public function testCustomAdapterMixedValue()
 {
     $data = Util::loadData('mixed');
     $obj = GraphMixed::map($data);
     $this->assertInstanceOf('stdClass', $obj->mixedStandard);
     $this->assertSame(1, $obj->mixedStandard->property);
     $this->assertSame(2, $obj->mixedStandard->otherProperty);
     $this->assertArrayHasKey('mixedStandard', $obj->mixedCustom);
     $this->assertArrayHasKey('objectNest', $obj->mixedCustom);
     $this->assertArrayHasKey('base', $obj->mixedCustom['objectNest']);
     $this->assertArrayHasKey('simple', $obj->mixedCustom);
     $this->assertArrayHasKey('mixedCustom', $obj->mixedCustom);
     $this->assertArrayHasKey('nest', $obj->mixedCustom);
     $this->assertArrayHasKey('mixedCustom2', $obj->mixedCustom['nest']);
     $base = GraphObjectBase::map($obj->mixedCustom['objectNest']['base']);
     $this->assertSame('astringvalue', $base->aString);
     $this->assertSame(5, $base->anInteger);
     $this->assertSame(false, $base->aBoolean);
     $this->assertTrue(Util::arrays_are_similar(array('a', 'b', 'c', 'd'), $base->flatArray));
     $this->assertSame(5.5, $base->aDouble);
     $this->assertInstanceOf('Nuad\\Graph\\Test\\GraphObjectBase', $base);
     $simple = GraphSimple::map($obj->mixedCustom['simple']);
     $this->assertSame(5, $simple->simpleInteger);
     $this->assertSame('a sample string', $simple->simpleString);
     $this->assertSame('123', $simple->simpleMixed);
     $this->assertInstanceOf('Nuad\\Graph\\Test\\GraphSimple', $simple);
     $this->assertArrayHasKey('base', $obj->mixedCustomProperties);
     $this->assertArrayHasKey('simple', $obj->mixedCustomProperties);
     $this->assertArrayHasKey('mixedCustom', $obj->mixedCustomProperties);
     $this->assertArrayHasKey('mixedCustom2', $obj->mixedCustomProperties);
     $this->assertInstanceOf('Nuad\\Graph\\Test\\GraphObjectBase', $obj->mixedCustomProperties['base']);
     $this->assertSame('astringvalue', $obj->mixedCustomProperties['base']->aString);
     $this->assertSame(5, $obj->mixedCustomProperties['base']->anInteger);
     $this->assertSame(false, $obj->mixedCustomProperties['base']->aBoolean);
     $this->assertTrue(Util::arrays_are_similar(array('a', 'b', 'c', 'd'), $obj->mixedCustomProperties['base']->flatArray));
     $this->assertSame(5.5, $obj->mixedCustomProperties['base']->aDouble);
     $this->assertInstanceOf('Nuad\\Graph\\Test\\GraphSimple', $obj->mixedCustomProperties['simple']);
     $this->assertSame(5, $obj->mixedCustomProperties['simple']->simpleInteger);
     $this->assertSame('a sample string', $obj->mixedCustomProperties['simple']->simpleString);
     $this->assertSame('123', $obj->mixedCustomProperties['simple']->simpleMixed);
     $this->assertSame('avalue', $obj->mixedCustomProperties['mixedCustom']);
     $this->assertSame('anotherValue', $obj->mixedCustomProperties['mixedCustom2']);
 }
예제 #2
0
 private function newSubmissions()
 {
     /* Grab an instance of Statistics. */
     $statistics = new Statistics($this->_siteID);
     $RS = $statistics->getSubmissionsByPeriod(TIME_PERIOD_LASTTWOWEEKS);
     // FIXME: Factor out these calculations? Common to most of these graphs.
     $firstDay = mktime(0, 0, 0, DateUtility::getAdjustedDate('m'), DateUtility::getAdjustedDate('d') - DateUtility::getAdjustedDate('w') - 7, DateUtility::getAdjustedDate('Y'));
     $y = array();
     for ($i = 0; $i < 14; $i++) {
         $thisDay = mktime(0, 0, 0, date('m', $firstDay), date('d', $firstDay) + $i, date('Y', $firstDay));
         $y[] = date('d', $thisDay);
     }
     /* Get values. */
     $x = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
     foreach ($RS as $lineRS) {
         $thisDay = mktime(0, 0, 0, $lineRS['month'], $lineRS['day'], $lineRS['year']);
         $dayOfWeek = (int) date('w', $thisDay);
         if (DateUtility::getWeekNumber($thisDay) != DateUtility::getWeekNumber()) {
             $x[$dayOfWeek]++;
         } else {
             $x[$dayOfWeek + 7]++;
         }
     }
     $graph = new GraphSimple($y, $x, 'Orange', 'New Submissions', $this->width, $this->height);
     if (!eval(Hooks::get('GRAPH_NEW_SUBMISSIONS'))) {
         return;
     }
     $graph->draw();
     die;
 }