Skip to content

Commit

Permalink
Adds unit tests for contact schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobemerick committed Aug 28, 2016
1 parent b8d3299 commit 0dc719a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="unit">
<directory>tests</directory>
<directory>tests/unit</directory>
</testsuite>
</testsuites>
<logging>
Expand Down
76 changes: 76 additions & 0 deletions tests/unit/src/Schema/ContactTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace AvalancheDevelopment\Approach\Schema;

use AvalancheDevelopment\Approach\TestHelper\SetPropertyTrait;
use PHPUnit_Framework_TestCase;
use ReflectionClass;

class ContactTest extends PHPUnit_Framework_TestCase
{

use SetPropertyTrait;

public function testGetNameReturnsName()
{
$name = 'Jack Black';

$contact = new Contact();
$this->setProperty($contact, 'name', $name);
$result = $contact->getName();

$this->assertEquals($name, $result);
}

public function testSetNameSetsName()
{
$name = 'Jane Black';

$contact = new Contact();
$contact->setName($name);

$this->assertAttributeEquals($name, 'name', $contact);
}

public function testGetUrlReturnsUrl()
{
$url = 'http://black.tld/jack';

$contact = new Contact();
$this->setProperty($contact, 'url', $url);
$result = $contact->getUrl();

$this->assertEquals($url, $result);
}

public function testSetUrlSetsUrl()
{
$url = 'http://black.tld/jane';

$contact = new Contact();
$contact->setUrl($url);

$this->assertAttributeEquals($url, 'url', $contact);
}

public function testGetEmailReturnsEmail()
{
$email = 'jack@black.tld';

$contact = new Contact();
$this->setProperty($contact, 'email', $email);
$result = $contact->getEmail();

$this->assertEquals($email, $result);
}

public function testSetEmailsSetsEmail()
{
$email = 'jane@black.tld';

$contact = new Contact();
$contact->setEmail($email);

$this->assertAttributeEquals($email, 'email', $contact);
}
}

0 comments on commit 0dc719a

Please sign in to comment.