Skip to content
This repository has been archived by the owner on Apr 24, 2018. It is now read-only.

Commit

Permalink
✅ Add tests for VisitorMany and VisitorBase
Browse files Browse the repository at this point in the history
  • Loading branch information
hansott committed Sep 18, 2017
1 parent 77679d1 commit b0b79e9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/Query/TraverserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,20 @@ public function test_it_traverses_a_query_document()
array($this->equalTo($document))
);

$traverser = new Traverser($visitor);
$countingVisitor = new VisitorCounting;
$visitors = new VisitorMany(
array(
$countingVisitor,
$visitor,
)
);

$traverser = new Traverser($visitors);
$traverser->traverse($document);

$this->assertEquals(
21,
$countingVisitor->getCount()
);
}
}
18 changes: 18 additions & 0 deletions tests/Query/VisitorCounting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace HansOtt\GraphQL\Query;

final class VisitorCounting extends VisitorBase
{
private $count = 0;

public function getCount()
{
return $this->count;
}

public function enterNode(Node $node)
{
$this->count++;
}
}

0 comments on commit b0b79e9

Please sign in to comment.