这是我的问题:我收到此错误:
未捕获的TypeError:对象原型可能只是一个Object或null:undefined
export abstract class AbstractLogicExpression {
protected _logicChildExpressions: AbstractLogicExpression[] = Array();
protected _precedence = 0;
protected _parsed = false;
protected _expressionType = "";
protected rightAssociative = false;
public toDNF() {
for (let i = 0; i < this.logicChildExpressions.length; i++) {
let actualLogicExpression: AbstractLogicExpression = this.logicChildExpressions[i];
if (actualLogicExpression._expressionType == "~") {
let logicConjunction = actualLogicExpression.logicChildExpressions[0];
let var1 = logicConjunction.logicChildExpressions[0];
let var2 = logicConjunction.logicChildExpressions[1];
if (logicConjunction._expressionType == "*") {
actualLogicExpression.logicChildExpressions[0] = new LogicOr();
//actualLogicExpression.logicChildExpressions[0].add(new LogicNeg(var1));
//actualLogicExpression.logicChildExpressions[0].add(new LogicNeg(var2));
}
}
}
} …Run Code Online (Sandbox Code Playgroud) 我开始在这个项目中使用单元和功能测试,因此我有一些问题:
我正在使用symfony php框架.我有像LDAP ORM服务这样的学说.
此外,我有一个用户存储库(作为服务),它依赖于LDAP ORM服务,记录器和验证服务.
现在我想为UserRepo的addUser函数编写单元测试.它将在内部调用:getNewUidNumber,userToEntities,doUserExist和getUserByUid.
我的问题是:我是否应该模拟所有这些内部函数来测试addUser函数?这是否违背了单元测试的想法(只是测试API).
或者我应该只是模拟LDAP ORM服务,Logger和验证服务,以便该类调用所有内部函数?但是这会导致巨大的测试功能,并且需要进行大量的模拟,因为我必须模拟所有内部存储库调用的存储库.
或者我应该启动symfony内核并使用ServiceContainer将ORM LDAP服务与真实的测试数据库一起使用.但这不是功能测试而不是单元测试吗?我听说在测试中有这么多依赖项是不好的.所以我认为使用整个serviceContainer会很糟糕.
添加用户:
public function addUser(User $user)
{
$pbnlAccount = $this->userToEntities($user);
if(!$this->doesUserExist($user)) {
$pbnlAccount->setUidNumber($this->getNewUidNumber());
$this->ldapEntityManager->persist($pbnlAccount);
$this->ldapEntityManager->flush();
}
else {
throw new UserAlreadyExistException("The user ".$user->getUid()." already exists.");
}
return $this->getUserByUid($user->getUid());
}
Run Code Online (Sandbox Code Playgroud)
有关更多代码,例如内部函数:https: //gist.github.com/NKPmedia/4a6ee55b6bb96e8af409debd98950678
谢谢保罗
我有一个基于 Symfony 框架的网络应用程序。
我有一个 php-fpm 图像,其中包含所有 php 和 asset 文件。
现在我想通过 nginx 容器提供文件。php部分很简单。但是我如何提供 php-fpm 图像中包含的静态文件呢?
我尝试创建一个由两个容器安装的卷。但是,在首次启动后,docker 将文件从映像复制到卷中后,在我更新映像后,文件不再更新。
我可以在容器启动后将文件从第二个目录复制到卷中以解决此问题,但我不希望产生这种开销。
有谁知道我可以共享静态文件,以便它们可以直接由 nginx 容器提供服务吗?
我的码头工人组成:
version: '3'
services:
nginx:
image: nginx:1.15-alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./data/nginx:/etc/nginx/conf.d
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
- static-content:/var/www/app/web
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
php:
image: pbnl/scotoobo-php:dev
volumes:
- static-content:/var/www/app/web
environment:
- database_host=db
volumes:
static-content:
Run Code Online (Sandbox Code Playgroud)
我的 Dockerfile
FROM php:7.1-fpm
RUN usermod -u …Run Code Online (Sandbox Code Playgroud) php ×2
docker ×1
javascript ×1
ldap ×1
nginx ×1
phpunit ×1
static-files ×1
symfony ×1
typescript ×1
unit-testing ×1