/** * */ public function testFacets() { $ay = $this->getAYWithResultFile('facets-206.json'); $facets = $ay->fetchFacets(array(206)); $this->assertInternalType('array', $facets); $count = 0; foreach ($facets as $facet) { $this->assertInstanceOf('\\AboutYou\\SDK\\Model\\Facet', $facet); $this->assertInternalType('int', $facet->getId()); $this->assertInternalType('string', $facet->getName()); $this->assertInternalType('string', $facet->getValue()); $this->assertInternalType('int', $facet->getGroupId()); $this->assertInternalType('string', $facet->getGroupName()); $this->assertEquals('size_code', $facet->getGroupName()); $this->assertEquals(206, $facet->getGroupId()); if ($count++ > 2) { break; } // tree is enough } $facet = $facets[\AboutYou\SDK\Model\Facet::uniqueKey(206, 2353)]; $this->assertEquals($facet, reset($facets)); $this->assertEquals(2353, $facet->getId()); $this->assertEquals('01', $facet->getName()); }
public function getFacet($groupId, $facetId) { $key = Facet::uniqueKey($groupId, $facetId); return isset($this->factes[$key]) ? $this->factes[$key] : null; }
/** * @param $filename * @return array */ protected function getFacetList($filename) { $jsonObject = $this->getJsonObjectFromFile($filename); if (isset($jsonObject[0]->facets->facet)) { $jsonFacets = $jsonObject[0]->facets->facet; } else { $jsonFacets = $jsonObject[0]->facet; } $facets = array(); foreach ($jsonFacets as $jsonFacet) { $facet = Facet::createFromJson($jsonFacet); $facets[$facet->getUniqueKey()] = $facet; } return $facets; }
/** * @return string */ public function getGroupName() { return $this->facet->getGroupName(); }
/** * {@inheritdoc} */ public function getFacet($groupId, $id) { $lookupKey = Facet::uniqueKey($groupId, $id); return isset($this->facets[$lookupKey]) ? $this->facets[$lookupKey] : null; }
/** * {@inheritdoc} * * @return Model\Facet */ public function createInlineFacet(stdClass $jsonObject) { return Model\Facet::createFromFacetsJson($jsonObject); }
protected function getFacetManager($filename) { $jsonObject = $this->getJsonObject($filename); if (isset($jsonObject[0]->facets->facet)) { $jsonFacets = $jsonObject[0]->facets->facet; } else { $jsonFacets = $jsonObject[0]->facet; } $facets = array(); foreach ($jsonFacets as $jsonFacet) { $facet = Facet::createFromJson($jsonFacet); $facets[] = $facet; } $facetManager = new StaticFacetManager($facets); return $facetManager; }