You are here

class TagadelicTagMethodsTest in Tagadelic 7.2

Class TagadelicTagMethodsTest

Test-group for testing the output-method __ToString from TagadelicTagTest. This is a functional group, with lots of duplication, hence it is extracted to its own Test.

Hierarchy

Expanded class hierarchy of TagadelicTagMethodsTest

File

tests/TagadelicTagMethodsTest.php, line 13

View source
class TagadelicTagMethodsTest extends TagadelicTagTest {

  /**
   * @covers TagadelicTag::get_id
   */
  public function testGet_id() {
    $this
      ->assertSame(42, $this->object
      ->get_id());
  }

  /**
   * @covers TagadelicTag::get_name
   */
  public function testGet_name() {
    $this
      ->assertSame("blackbeard", $this->object
      ->get_name());
  }

  /**
   * @covers TagadelicTag::get_description
   */
  public function testGet_description() {
    $this->object
      ->set_description("Foo Bar");
    $this
      ->assertSame("Foo Bar", $this->object
      ->get_description());
  }

  /**
   * @covers TagadelicTag::get_weight
   */
  public function testGet_weight() {
    $this->object
      ->set_weight(123);
    $this
      ->assertSame(123, $this->object
      ->get_weight());
  }

  /**
   * @covers TagadelicTag::get_weight
   */
  public function testGet_count() {
    $this
      ->assertSame(2, $this->object
      ->get_count());
  }

  /**
   * @covers TagadelicTag::set_weight
   */
  public function testSet_weight() {
    $this->object
      ->set_weight(123);
    $this
      ->assertAttributeSame(123, "weight", $this->object);
  }

  /**
   * @covers TagadelicTag::set_drupal
   */
  public function testSet_drupal() {
    $drupal = $this
      ->getMock("TagaDelicDrupalWrapper");
    $this->object
      ->set_drupal($drupal);
    $this
      ->assertAttributeSame($drupal, "drupal", $this->object);
  }

  /**
   * @covers TagadelicTag::drupal
   */
  public function testDrupal() {
    $drupal = $this
      ->getMock("TagaDelicDrupalWrapper");
    $this->object
      ->set_drupal($drupal);
    $this
      ->assertSame($this->object
      ->drupal(), $drupal);
  }

  /**
   * @covers TagadelicTag::drupal
   */
  public function testDrupalInstatiatesNewWrapper() {
    $this->object
      ->set_drupal(NULL);
    $this
      ->assertInstanceOf("TagaDelicDrupalWrapper", $this->object
      ->drupal());
  }

  /**
   * @covers TagadelicTag::set_description
   */
  public function testSet_description() {
    $this->object
      ->set_description("Foo Bar");
    $this
      ->assertAttributeSame("Foo Bar", "description", $this->object);
  }

  /**
   * @covers TagadelicTag::set_link
   */
  public function testSet_link() {
    $this->object
      ->set_link("tag/blackbeard");
    $this
      ->assertAttributeSame("tag/blackbeard", "link", $this->object);
  }

  /**
   * @covers TagadelicTag::force_dirty
   */
  public function testForce_dirty() {
    $this->object
      ->force_dirty();
    $this
      ->assertAttributeSame(TRUE, "dirty", $this->object);
  }

  /**
   * @covers TagadelicTag::force_clean
   */
  public function testForce_clean() {
    $this->object
      ->force_clean();
    $this
      ->assertAttributeSame(FALSE, "dirty", $this->object);
  }

  /**
   * @covers TagadelicTag::clean()
   */
  public function testCleansWhenDirty() {
    $drupal = $this
      ->getMock("TagaDelicDrupalWrapper");
    $drupal
      ->expects($this
      ->exactly(2))
      ->method("check_plain");
    $this->object
      ->set_drupal($drupal);
    $this->object
      ->force_dirty();
    $this->object
      ->get_name();
    $this->object
      ->get_description();
  }

  /**
   * @covers TagadelicTag::clean()
   */
  public function testSkipsCleanWhenClean() {
    $drupal = $this
      ->getMock("TagaDelicDrupalWrapper");
    $drupal
      ->expects($this
      ->never())
      ->method("check_plain");
    $this->object
      ->set_drupal($drupal);
    $this->object
      ->force_clean();
    $this->object
      ->get_name();
    $this->object
      ->get_description();
  }

  /**
   * @covers TagadelicTag::distributed
   */
  public function testDistributed() {
    $this
      ->assertSame(log(2), $this->object
      ->distributed());
  }

  /**
   * @covers TagadelicTag::distributed
   */
  public function testDistributed_NotInfinite() {
    $this->object = new TagadelicTag(24, "redhair", 0);
    $this
      ->assertFalse(is_infinite($this->object
      ->distributed()));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TagadelicTagMethodsTest::testCleansWhenDirty public function @covers TagadelicTag::clean()
TagadelicTagMethodsTest::testDistributed public function @covers TagadelicTag::distributed
TagadelicTagMethodsTest::testDistributed_NotInfinite public function @covers TagadelicTag::distributed
TagadelicTagMethodsTest::testDrupal public function @covers TagadelicTag::drupal
TagadelicTagMethodsTest::testDrupalInstatiatesNewWrapper public function @covers TagadelicTag::drupal
TagadelicTagMethodsTest::testForce_clean public function @covers TagadelicTag::force_clean
TagadelicTagMethodsTest::testForce_dirty public function @covers TagadelicTag::force_dirty
TagadelicTagMethodsTest::testGet_count public function @covers TagadelicTag::get_weight
TagadelicTagMethodsTest::testGet_description public function @covers TagadelicTag::get_description
TagadelicTagMethodsTest::testGet_id public function @covers TagadelicTag::get_id
TagadelicTagMethodsTest::testGet_name public function @covers TagadelicTag::get_name
TagadelicTagMethodsTest::testGet_weight public function @covers TagadelicTag::get_weight
TagadelicTagMethodsTest::testSet_description public function @covers TagadelicTag::set_description
TagadelicTagMethodsTest::testSet_drupal public function @covers TagadelicTag::set_drupal
TagadelicTagMethodsTest::testSet_link public function @covers TagadelicTag::set_link
TagadelicTagMethodsTest::testSet_weight public function @covers TagadelicTag::set_weight
TagadelicTagMethodsTest::testSkipsCleanWhenClean public function @covers TagadelicTag::clean()
TagadelicTagTest::$object protected property
TagadelicTagTest::setUp protected function Sets up the fixture, for example, opens a network connection. This method is called before a test is executed. 1
TagadelicTagTest::tearDown protected function Tears down the fixture, for example, closes a network connection. This method is called after a test is executed.