You are here

class MatchObjectTest in Bibliography Module 7.2

Hierarchy

Expanded class hierarchy of MatchObjectTest

File

lib/msrc-authortool/tests/MatchObjectTest.php, line 5

View source
class MatchObjectTest extends PHPUnit_Framework_TestCase {

  // --------------------------------------------------------------
  public function testInstantiateAsObjectSucceeds() {
    $obj = new TestMatchObject();
    $this
      ->assertInstanceOf('\\Nametools\\MatchObject', $obj);
  }

  // --------------------------------------------------------------
  public function testSetPropertiesWorksForExistingProperties() {
    $obj = new TestMatchObject();
    $obj->name = "Bob";
    $this
      ->assertEquals("Bob", $obj->name);
  }

  // --------------------------------------------------------------
  public function testSetPropertiesFailsForNonexistentProperties() {
    $this
      ->setExpectedException("\\InvalidArgumentException");
    $obj = new TestMatchObject();
    $obj->doesNotExist = 'abc';
  }

  // --------------------------------------------------------------
  public function testCastAsStringReturnsJson() {
    $obj = new TestMatchObject();
    $obj->name = "Bob";
    $obj->email = "bob@example.com";
    $toMatch = '{"name":"Bob","email":"bob@example.com"}';
    $this
      ->assertEquals($toMatch, $obj);
  }

  // --------------------------------------------------------------
  public function testFactoryReturnsObject() {
    $obj = new TestMatchObject();
    $classname = get_class($obj);
    $newobj = $classname::factory();
    $this
      ->assertInstanceOf('TestMatchObject', $newobj);
  }

}

Members