让我们假设我有一个文件 /var/www/project/calculator.class.php
这是班级
namespace App/Module/Calculator;
abstract class calculator{
static property $add;
static property $result;
function add($val_a, $val_b){
return $a + $b;
}
}
Run Code Online (Sandbox Code Playgroud)
我想为上面的类创建一个测试用例,但似乎无法测试它.我陷入了最基本的阶段.
require '/var/www/project/calculator.class.php';
class CalculatorTest extends \PHPUnit_Framework_TestCase {
public function testAbstactDatabaseClassExists()
{
$this->assertEquals(is_object('Database'), 1);
$this->assertEquals(true, in_array('Calculator', get_declared_classes()));
}
}
Run Code Online (Sandbox Code Playgroud)
无论我做什么,似乎没有办法测试,课程和它的内容.
任何人有任何想法?
让我解释一下,我想合并两个具有相同名称的git存储库,但不同的远程.
也就是说,我有一个repit_name托管在git中,分支名称为repo_name_a,我在分支名称下添加了另一个分支到git:repo_name_b
现在,为了合并这些,我该怎么办?
每次我用PHP创建网站或应用程序时,我必须使用header()函数将人们从一个页面重定向到另一个页面,但由于在我发现自己必须使用减慢页面速度的输出缓冲功能之前,几乎总是发送典型的标题.它要么是抑制"已发送标头"错误.我真的找不到任何可以在PHP中构建应用程序而不必违反这两者的示例.
我试图了解更多,关于如何在不使用输出缓冲的情况下重定向到页面.
这就是一些人认为是可能的.
<?php
$stack_errors = NULL;
if($_POST && isset($_POST['username']) && isset($_POST['password'])){
$stmt = $pdo->prepare('SELECT * FROM users where username = ? AND password = ?');
$stmt->execute(array($_POST['username'], $_POST['password']);
if($stmt->rowCount() == 0){
$stack_errors = 'error, username or password is incorrect';
}else{
$stack_errors = false;
}
}else{
$stack_errors = 'please enter username and password to log in';
}
if(false === $stack_errors){
header('Location: /success.php');
exit;
}
?>
<html>
<head></head>
<body>
<form>
<input ...>
<input ...>
<?php if($stack_errors){
echo $stack_errors;
} …Run Code Online (Sandbox Code Playgroud)