-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nathan Salter
committed
Jan 25, 2016
1 parent
695ec35
commit dd2050b
Showing
9 changed files
with
325 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
use Verona\Item\ItemFactoryEvent; | ||
use Verona\Item\ItemInterface; | ||
|
||
/** | ||
* Created by PhpStorm. | ||
* User: Nathan | ||
* Date: 25/01/2016 | ||
* Time: 10:36 | ||
*/ | ||
class ItemFactoryEventTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testGettersAndSetters() | ||
{ | ||
|
||
$event = new ItemFactoryEvent(); | ||
|
||
$expectedItem = $this->getMock(ItemInterface::class); | ||
$this->assertFalse($event->hasItem()); | ||
$this->assertInstanceOf(ItemFactoryEvent::class, $event->setItem($expectedItem)); | ||
$this->assertTrue($event->hasItem()); | ||
$this->assertEquals($expectedItem, $event->getItem()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
use Verona\Item\Type\PermissionItem; | ||
use Verona\Item\Type\UserGroupItem; | ||
|
||
/** | ||
* Created by PhpStorm. | ||
* User: Nathan | ||
* Date: 25/01/2016 | ||
* Time: 10:15 | ||
*/ | ||
class PermissionItemTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
|
||
/** | ||
* @return PermissionItem | ||
*/ | ||
public function testGettersAndSetters() | ||
{ | ||
|
||
$permission = new PermissionItem(); | ||
|
||
$expectedItem = new PermissionItem(); | ||
$this->assertFalse($permission->hasItemId()); | ||
$this->assertInstanceOf(PermissionItem::class, $permission->setItem($expectedItem)); | ||
$this->assertEquals($expectedItem->getId(), $permission->getItemId()); | ||
$this->assertTrue($permission->hasItemId()); | ||
$this->assertInstanceOf(PermissionItem::class, $permission->setItemId($expectedItem->getId())); | ||
$this->assertEquals($expectedItem->getId(), $permission->getItemId()); | ||
|
||
$expectedUserGroup = new UserGroupItem(); | ||
$this->assertFalse($permission->hasUserGroupId()); | ||
$this->assertInstanceOf(PermissionItem::class, $permission->setUserGroup($expectedUserGroup)); | ||
$this->assertEquals($expectedUserGroup->getId(), $permission->getUserGroupId()); | ||
$this->assertTrue($permission->hasUserGroupId()); | ||
$this->assertInstanceOf(PermissionItem::class, $permission->setUserGroupId($expectedUserGroup->getId())); | ||
$this->assertEquals($expectedUserGroup->getId(), $permission->getUserGroupId()); | ||
|
||
$expectedAllowed = true; | ||
$this->assertFalse($permission->isAllowed()); | ||
$this->assertInstanceOf(PermissionItem::class, $permission->setAllowed($expectedAllowed)); | ||
$this->assertEquals($expectedAllowed, $permission->isAllowed()); | ||
|
||
return $permission; | ||
|
||
} | ||
|
||
/** | ||
* @param PermissionItem $item | ||
* @depends testGettersAndSetters | ||
*/ | ||
public function testExchangeable(PermissionItem $item) | ||
{ | ||
|
||
$conf = $item->toArray(); | ||
|
||
$newItem = new PermissionItem(); | ||
$newItem->fromArray($conf); | ||
|
||
$this->assertEquals($item, $newItem); | ||
|
||
$newConf = $newItem->toArray(); | ||
|
||
$this->assertEquals($conf, $newConf); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
use Verona\Item\Type\UserGroupItem; | ||
|
||
/** | ||
* Created by PhpStorm. | ||
* User: Nathan | ||
* Date: 25/01/2016 | ||
* Time: 10:23 | ||
*/ | ||
class UserGroupItemTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* @return UserGroupItem | ||
*/ | ||
public function testGettersAndSetters() | ||
{ | ||
|
||
$userGroup = new UserGroupItem(); | ||
|
||
$expectedName = 'rawrderawr'; | ||
$this->assertInstanceOf(UserGroupItem::class, $userGroup->setName($expectedName)); | ||
$this->assertEquals($expectedName, $userGroup->getName()); | ||
|
||
return $userGroup; | ||
|
||
} | ||
|
||
|
||
/** | ||
* @param UserGroupItem $userGroup | ||
* @depends testGettersAndSetters | ||
*/ | ||
public function testExchangeable(UserGroupItem $userGroup) | ||
{ | ||
|
||
$conf = $userGroup->toArray(); | ||
|
||
$newUserGroup = new UserGroupItem(); | ||
$newUserGroup->fromArray($conf); | ||
|
||
$this->assertEquals($userGroup, $newUserGroup); | ||
|
||
$newConf = $newUserGroup->toArray(); | ||
|
||
$this->assertEquals($conf, $newConf); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
use Verona\Item\Type\UserGroupItem; | ||
use Verona\Item\Type\UserItem; | ||
|
||
/** | ||
* Created by PhpStorm. | ||
* User: Nathan | ||
* Date: 25/01/2016 | ||
* Time: 10:27 | ||
*/ | ||
class UserItemTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* @return UserItem | ||
*/ | ||
public function testGettersAndSetters() | ||
{ | ||
|
||
$user = new UserItem(); | ||
|
||
$expectedUserGroup = new UserGroupItem(); | ||
$this->assertFalse($user->hasUserGroupId()); | ||
$this->assertInstanceOf(UserItem::class, $user->setUserGroup($expectedUserGroup)); | ||
$this->assertTrue($user->hasUserGroupId()); | ||
$this->assertEquals($expectedUserGroup->getId(), $user->getUserGroupId()); | ||
$this->assertInstanceOf(UserItem::class, $user->setUserGroupId($expectedUserGroup->getId())); | ||
$this->assertEquals($expectedUserGroup->getId(), $user->getUserGroupId()); | ||
|
||
$expectedName = 'Great'; | ||
$this->assertFalse($user->hasFirstName()); | ||
$this->assertInstanceOf(UserItem::class, $user->setFirstName($expectedName)); | ||
$this->assertTrue($user->hasFirstName()); | ||
$this->assertEquals($expectedName, $user->getFirstName()); | ||
|
||
$expectedSurname = 'Scott!'; | ||
$this->assertFalse($user->hasSurname()); | ||
$this->assertInstanceOf(UserItem::class, $user->setSurname($expectedSurname)); | ||
$this->assertTrue($user->hasSurname()); | ||
$this->assertEquals($expectedSurname, $user->getSurname()); | ||
|
||
return $user; | ||
|
||
} | ||
|
||
/** | ||
* @param UserItem $user | ||
* @depends testGettersAndSetters | ||
*/ | ||
public function testExchangeable(UserItem $user) | ||
{ | ||
|
||
$conf = $user->toArray(); | ||
|
||
$newUser = new UserItem(); | ||
$newUser->fromArray($conf); | ||
|
||
$this->assertEquals($user, $newUser); | ||
|
||
$newConf = $newUser->toArray(); | ||
|
||
$this->assertEquals($conf, $newConf); | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
use Verona\Timetable\TimetableManagerEvent; | ||
|
||
/** | ||
* Created by PhpStorm. | ||
* User: Nathan | ||
* Date: 25/01/2016 | ||
* Time: 10:59 | ||
*/ | ||
class TimetableManagerEventTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testGettersAndSetters() | ||
{ | ||
|
||
$event = new TimetableManagerEvent(); | ||
|
||
$expectedPointInTime = new DateTime(); | ||
$this->assertFalse($event->hasPointInTime()); | ||
$this->assertInstanceOf(TimetableManagerEvent::class, $event->setPointInTime($expectedPointInTime)); | ||
$this->assertTrue($event->hasPointInTime()); | ||
$this->assertEquals($expectedPointInTime, $event->getPointInTime()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
use Verona\Value\AbstractEnumValue; | ||
|
||
/** | ||
* Created by PhpStorm. | ||
* User: Nathan | ||
* Date: 25/01/2016 | ||
* Time: 10:42 | ||
*/ | ||
class AbstractEnumValueTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testWithConstants() | ||
{ | ||
|
||
$expectedA = 'A'; | ||
$expectedB = 'B'; | ||
|
||
/** @var AbstractEnumValue $class */ | ||
$class = (new class($expectedB) extends AbstractEnumValue { | ||
const A = 'A'; | ||
const B = 'B'; | ||
}); | ||
|
||
$this->assertEquals($expectedB, $class->get()); | ||
|
||
try { | ||
$class->set('FAIL'); | ||
$this->fail('Should not have reached this expression'); | ||
} catch (Exception $e) {} | ||
|
||
$this->assertEquals([$expectedA, $expectedB], $class->getOptions()); | ||
|
||
$class->set($expectedA); | ||
$this->assertEquals($expectedA, $class->get()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
use Verona\Value\DateValue; | ||
|
||
/** | ||
* Created by PhpStorm. | ||
* User: Nathan | ||
* Date: 25/01/2016 | ||
* Time: 10:55 | ||
*/ | ||
class DateValueTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
|
||
public function testOnlyDate() | ||
{ | ||
|
||
$exampleOne = new DateValue('2015-01-01 10:15:32'); | ||
$exampleTwo = new DateValue('2015-01-01 15:15:15'); | ||
|
||
$this->assertEquals($exampleOne, $exampleTwo); | ||
|
||
} | ||
} |