blessing-skin-server/tests/ServicesTest/FilterTest.php

39 lines
1.0 KiB
PHP
Raw Normal View History

2019-08-10 12:16:24 +08:00
<?php
namespace Tests;
class FilterTest extends TestCase
{
public function testAddFilter()
{
$this->mock('eventy', function ($mock) {
$mock->shouldReceive('addFilter')
->withArgs(function ($hook, $callback) {
$this->assertEquals('my.hook', $hook);
$this->assertEquals('Filtered text', $callback('text'));
return true;
})
->once();
});
add_filter('my.hook', function ($value) {
return "Filtered $value";
});
}
public function testApplyFilters()
{
$this->mock('eventy', function ($mock) {
$mock->shouldReceive('filter')->withArgs(['my.hook', 'value'])->once();
});
apply_filters('my.hook', 'value');
}
public function testIntegration()
{
add_filter('hook.test', function ($value) {
return $value.'ed';
});
$this->assertEquals('tested', apply_filters('hook.test', 'test'));
}
}