Skip to content

Commit

Permalink
relocated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
esokullu committed Apr 29, 2017
1 parent 11b1034 commit 34d80ac
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions tests/SimpleTest.php → tests/Pho/Framework/SimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
* file that was distributed with this source code.
*/

// namespace Pho\Framework\Tests;
namespace Pho\Framework;

use Pho\Framework;
use Pho\Lib\Graph;

class SimpleTest extends \PHPUnit\Framework\TestCase
Expand All @@ -27,39 +26,39 @@ public function tearDown() {
}

public function testActor() {
$node = new Framework\Actor($this->graph);
$node = new Actor($this->graph);
$node_expected_to_be_identical = $this->graph->get($node->id());
$this->assertEquals($node->id(), $node_expected_to_be_identical->id());
}

public function testActorEdge() {
$actor = new Framework\Actor($this->graph);
$object = new Framework\Object($actor, $this->graph);
$actor = new Actor($this->graph);
$object = new Object($actor, $this->graph);
$edge = $actor->writes($object);
$this->assertInstanceOf(Framework\ActorOut\Writes::class, $edge);
$this->assertInstanceOf(ActorOut\Writes::class, $edge);
$this->assertInstanceOf(Graph\Predicate::class, $edge->predicate());
}

public function testActorPredicate() {
$actor = new Framework\Actor($this->graph);
$object = new Framework\Object($actor, $this->graph);
$actor = new Actor($this->graph);
$object = new Object($actor, $this->graph);
$edge = $actor->subscribes($object);
$this->assertInstanceOf(Framework\ActorOut\SubscribesPredicate::class, $edge->predicate());
$this->assertInstanceOf(ActorOut\SubscribesPredicate::class, $edge->predicate());
}

public function testObjectGetter() {
$actor = new Framework\Actor($this->graph);
$object = new Framework\Object($actor, $this->graph);
$actor = new Actor($this->graph);
$object = new Object($actor, $this->graph);
$edge = $actor->writes($object);
$this->assertInstanceOf(Framework\ActorOut\Writes::class, $object->getWriters()[0]);
$this->assertInstanceOf(ActorOut\Writes::class, $object->getWriters()[0]);
$this->assertCount(1, $object->getWriters());
$this->assertCount(1, $actor->getWrites());
$this->assertInstanceOf(Framework\ActorOut\Writes::class, $actor->getWrites()[0]);
$this->assertInstanceOf(ActorOut\Writes::class, $actor->getWrites()[0]);
}

public function testFiltering() {
$actor = new Framework\Actor($this->graph);
$object = new Framework\Object($actor, $this->graph);
$actor = new Actor($this->graph);
$object = new Object($actor, $this->graph);
$edge = $actor->writes($object);
$edge = $actor->reads($object);
$this->assertCount(1, $actor->getWrites());
Expand All @@ -69,8 +68,8 @@ public function testFiltering() {
* Since write extends subscribes
*/
public function testEdgeInheritance() {
$actor = new Framework\Actor($this->graph);
$object = new Framework\Object($actor, $this->graph);
$actor = new Actor($this->graph);
$object = new Object($actor, $this->graph);
$edge = $actor->writes($object);
$this->assertCount(1, $actor->getSubscriptions());
$this->assertCount(0, $actor->getReads());
Expand All @@ -80,24 +79,24 @@ public function testEdgeInheritance() {
* @expectedException Pho\Framework\Exceptions\InvalidEdgeHeadTypeException
*/
public function testImpossibleEdge() {
$actor1 = new Framework\Actor($this->graph);
$actor2 = new Framework\Actor($this->graph);
$actor1 = new Actor($this->graph);
$actor2 = new Actor($this->graph);
$edge = $actor1->writes($actor2);
}

public function testEdgeInvoke() {
$actor = new Framework\Actor($this->graph);
$object = new Framework\Object($actor, $this->graph);
$actor = new Actor($this->graph);
$object = new Object($actor, $this->graph);
$edge = $actor->writes($object);
$this->assertInstanceOf(Framework\Object::class, $edge());
$this->assertInstanceOf(Object::class, $edge());
$this->assertEquals($object->id(), $edge()->id());
}


public function testActorToArray() {
$actor = new Framework\Actor($this->graph);
$actor = new Actor($this->graph);
$array = $actor->toArray();
$faker = Faker\Factory::create();
$faker = \Faker\Factory::create();
$this->assertArrayHasKey("id", $array);
$this->assertArrayHasKey("attributes", $array);
$this->assertCount(0, $array["attributes"]);
Expand All @@ -111,9 +110,9 @@ public function testActorToArray() {
}

public function testFrameToArray() {
$faker = Faker\Factory::create();
$actor = new Framework\Actor($this->graph);
$frame = new Framework\Frame($actor, $this->graph);
$faker = \Faker\Factory::create();
$actor = new Actor($this->graph);
$frame = new Frame($actor, $this->graph);
$edge = $actor->writes($frame);
$array = $frame->toArray();
$this->assertArrayHasKey("id", $array);
Expand Down

0 comments on commit 34d80ac

Please sign in to comment.