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
Petr Knap
committed
Sep 19, 2016
1 parent
bfc8cb2
commit 8222deb
Showing
5 changed files
with
61 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/.idea/ | ||
/vendor/ | ||
/tests/phpunit.log | ||
/composer.lock |
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,10 @@ | ||
<phpunit bootstrap="./vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<logging> | ||
<log type="testdox-text" target="./tests/phpunit.log"/> | ||
</logging> | ||
</phpunit> |
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 |
---|---|---|
@@ -1,6 +1,39 @@ | ||
<?php | ||
|
||
class ProfilerTest | ||
namespace Netpromotion\Profiler\Test; | ||
|
||
use Netpromotion\Profiler\Profiler; | ||
use PetrKnap\Php\Profiler\Profile; | ||
|
||
class ProfilerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
// TODO test multiple hooks support, check that postProcessor with id NULL is called at the end | ||
public function testMultipleHooksWorks() | ||
{ | ||
$order = []; | ||
Profiler::setPostProcessor(function(Profile $profile) use (&$order) { | ||
$order[] = 1; | ||
return $profile; | ||
}); | ||
|
||
Profiler::setPostProcessor(function(Profile $profile) use (&$order) { | ||
$order[] = 2; | ||
return $profile; | ||
}); | ||
|
||
Profiler::setPostProcessor(function(Profile $profile) use (&$order) { | ||
$order[] = 3; | ||
return $profile; | ||
}, "B"); | ||
|
||
Profiler::setPostProcessor(function(Profile $profile) use (&$order) { | ||
$order[] = 4; | ||
return $profile; | ||
}, "A"); | ||
|
||
Profiler::enable(); | ||
Profiler::start(); | ||
Profiler::finish(); | ||
|
||
$this->assertEquals([3, 4, 2], $order); | ||
} | ||
} |