/** * @depends testBlocked */ public function testBlock() { $this->mockGoodReferer(); ob_start(); $goodReferer = \Nabble\Semalt::block(); $output = ob_get_clean(); $this->assertNull($goodReferer, 'Shouldn\'t return anything'); $this->assertEmpty($output, 'Shouldn\'t output anything'); $this->mockBadReferer(); ob_start(); $withoutAction = \Nabble\Semalt::block(); $output = ob_get_clean(); $explodedExplanation = explode('%s', \Nabble\Semalt::$explanation); $this->assertNull($withoutAction, 'Shouldn\'t return anything'); $this->assertNotNull($output, 'Output shouldn\'t be null'); $this->assertContains($explodedExplanation[0], $output, 'Should contain explanation'); ob_start(); $withMessage = \Nabble\Semalt::block('TEST_MESSAGE'); $output = ob_get_clean(); $this->assertNull($withMessage, 'Shouldn\'t return anything'); $this->assertNotNull($output, 'Output shouldn\'t be null'); $this->assertContains('TEST_MESSAGE', $output, 'Should contain test message'); // @todo test headers }
<?php require '../vendor/autoload.php'; \Nabble\Semalt::block(); ?> <html> <head> <title>semalt-blocker debug console</title> <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"> <style> section { margin: 100px 0; } form { margin: 0 0 50px; } input, button { padding: 10px; font-size: 18px; max-width: 100%; } input[name=url] { width: 30em; } .progress { width: 50%; display: inline-block; } .table { width: auto; margin: 0 auto;
public function testDeprecatedBlock() { $this->mockBadReferer(); ob_start(); \Nabble\Semalt::block('TEST_MESSAGE'); $output = ob_get_clean(); $this->assertNotNull($output, 'Output shouldn\'t be null'); $this->assertContains('TEST_MESSAGE', $output, 'Should contain test message'); }