Exemplo n.º 1
0
 public function testDefaultValues()
 {
     $facet = new AfsFacet('foo');
     $this->assertTrue($facet->get_id() == 'foo');
     $this->assertEquals(AfsFacetType::UNKNOWN_TYPE, $facet->get_type());
     $this->assertEquals(AfsFacetLayout::TREE, $facet->get_layout());
     $this->assertEquals(AfsFacetMode::UNSPECIFIED_MODE, $facet->get_mode());
     $this->assertFalse($facet->has_or_mode());
     $this->assertFalse($facet->has_and_mode());
     $this->assertFalse($facet->has_single_mode());
 }
Exemplo n.º 2
0
 /** @brief Checks whether provided facet is similar to current instance.
  *
  * Two instances are considered similar when following values are equals:
  * - facet identifier,
  * - facet type (or one is of unknown type),
  * - facet layout (or one is of unknown layout).
  * Other facet parameters are not taken into account.
  *
  * @param $other [in] instance to compare with.
  * @return @c True when both instances are similar, @c false otherwise.
  */
 public function is_similar_to(AfsFacet $other)
 {
     if ($this->id == $other->get_id() && ($this->type == $other->get_type() || $this->type == AfsFacetType::UNKNOWN_TYPE || $other->get_type() == AfsFacetType::UNKNOWN_TYPE) && ($this->layout == $other->get_layout() || $this->type == AfsFacetLayout::UNKNOWN || $other->get_layout() == AfsFacetLayout::UNKNOWN)) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
 /** @brief Checks whether provided facet exists and has right parameters.
  *
  * Currently configured facet is updated with parameters of the given facet
  * when it is necessary (update facet mode, facet type...)
  *
  * @param $facet [in] Facet to test.
  * @exception AfsUndefinedFacetException provided facet is not currently
  *            managed.
  * @exception AfsInvalidFacetParameterException provided facet does not
  *            match currently defined parameters.
  */
 public function check_facet(AfsFacet $facet)
 {
     if (!$this->has_facet($facet->get_id())) {
         throw new AfsUndefinedFacetException('No facet with id \'' . $facet->get_id() . '\' currently managed');
     }
     $configured = $this->get_facet($facet->get_id());
     if (!$configured->update($facet)) {
         throw new AfsInvalidFacetParameterException('Provided facet is not ' . 'similar to registered one: ' . $facet . ' =/= ' . $configured);
     }
 }