Exemplo n.º 1
0
 public function testGetLinkedProducts()
 {
     $product = $this->getMock('\\Magento\\Catalog\\Model\\Product', [], [], '', false);
     $expected = [$product];
     $product->expects($this->once())->method('getRelatedProducts')->will($this->returnValue($expected));
     $model = new Related();
     $this->assertEquals($expected, $model->getLinkedProducts($product));
 }
 public function testRelations()
 {
     $related = Related::model()->with("parent:leaf")->findByPk(1);
     $this->assertNotNull($related);
     $this->assertNotNull($related->parent);
     $this->assertFalse($related->parent->isLeaf());
     $related = Related::model()->with("parent:leaf")->findByPk(2);
     $this->assertNotNull($related);
     $this->assertNotNull($related->parent);
     $this->assertTrue($related->parent->isLeaf());
 }
Exemplo n.º 3
0
    $app->redirect($url, 302);
    die;
}
$systemInfo = $mdb->findDoc('information', ['cacheTime' => 3600, 'type' => 'solarSystemID', 'id' => $systemID]);
$systemName = $systemInfo['name'];
$regionInfo = $mdb->findDoc('information', ['cacheTime' => 3600, 'type' => 'regionID', 'id' => $systemInfo['regionID']]);
$regionName = $regionInfo['name'];
$unixTime = strtotime($relatedTime);
$time = date('Y-m-d H:i', $unixTime);
$exHours = 1;
if ((int) $exHours < 1 || (int) $exHours > 12) {
    $exHours = 1;
}
$key = md5("br:{$systemID}:{$relatedTime}:{$exHours}:" . json_encode($json_options) . (isset($battleID) ? ":{$battleID}" : ""));
$mc = RedisCache::get($key);
if ($mc == null) {
    $parameters = array('solarSystemID' => $systemID, 'relatedTime' => $relatedTime, 'exHours' => $exHours, 'nolimit' => true);
    $kills = Kills::getKills($parameters);
    $summary = Related::buildSummary($kills, $json_options);
    $mc = array('summary' => $summary, 'systemName' => $systemName, 'regionName' => $regionName, 'time' => $time, 'exHours' => $exHours, 'solarSystemID' => $systemID, 'relatedTime' => $relatedTime, 'options' => json_encode($json_options));
    if (isset($battleID) && $battleID > 0) {
        $teamA = $summary['teamA']['totals'];
        $teamB = $summary['teamB']['totals'];
        unset($teamA['groupIDs']);
        unset($teamB['groupIDs']);
        $mdb->set("battles", ['battleID' => $battleID], ['teamA' => $teamA]);
        $mdb->set("battles", ['battleID' => $battleID], ['teamB' => $teamB]);
    }
    RedisCache::set($key, $mc, 300);
}
$app->render('related.html', $mc);