-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finetune Header and add HeaderTest.php.
- Loading branch information
Showing
2 changed files
with
106 additions
and
23 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
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,66 @@ | ||
<?php | ||
|
||
|
||
use PHPUnit\Framework\TestCase; | ||
use BFITech\ZapCore\Header; | ||
|
||
|
||
class HeaderPatched extends Header { | ||
public static function header($val) { | ||
echo "$val\n"; | ||
} | ||
public static function header_halt($str=null) { | ||
if ($str) | ||
echo $str; | ||
} | ||
} | ||
|
||
|
||
class HeaderTest extends TestCase { | ||
|
||
public function test_send_header() { | ||
ob_start(); | ||
HeaderPatched::send_header(false, 3600, false); | ||
$rv = ob_get_clean(); | ||
$this->assertNotEquals( | ||
strpos($rv, 'Cache-Control'), false); | ||
|
||
ob_start(); | ||
HeaderPatched::send_header(false, 0, false); | ||
$rv = ob_get_clean(); | ||
$this->assertNotEquals( | ||
strpos($rv, 'Pragma'), false); | ||
|
||
ob_start(); | ||
HeaderPatched::send_header( | ||
__FILE__, true, true, 302, 'test.php'); | ||
$rv = ob_get_clean(); | ||
$this->assertNotEquals( | ||
strpos($rv, 'Expire'), false); | ||
|
||
ob_start(); | ||
HeaderPatched::send_header( | ||
__FILE__, true, true, 200, 'test.php'); | ||
$rv = ob_get_clean(); | ||
$this->assertNotEquals( | ||
strpos($rv, file_get_contents(__FILE__)), false); | ||
} | ||
|
||
public function test_print_json() { | ||
ob_start(); | ||
HeaderPatched::print_json(); | ||
$rv = ob_get_clean(); | ||
$this->assertNotEquals( | ||
strpos($rv, '"errno":0'), false); | ||
} | ||
|
||
public function test_pj() { | ||
ob_start(); | ||
HeaderPatched::pj([1, 403]); | ||
$rv = ob_get_clean(); | ||
$this->assertNotEquals( | ||
strpos($rv, '"errno":1'), false); | ||
} | ||
|
||
} | ||
|