使用phpStorm IDE处理Symfony2项目,我添加了几个文件到git ignore但是一个文件尽管被添加到git ignore总是出现....我已经尝试了多次但它总是在那里
.gitignore文件:
/app/config/parameters.yml
/bin/
/build/
/composer.phar
/vendor/
/web/bundles/
/app/bootstrap.php.cache
/app/cache/*
!app/cache/.gitkeep
/app/config/parameters.yml
/app/logs/*
!app/logs/.gitkeep
/app/phpunit.xml
#IDE metadata
**.idea/**
#Bash files
run.sh
Run Code Online (Sandbox Code Playgroud)
并且git不会忽略的是.idea文件夹/文件:
On branch develop
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .idea/workspace.xml
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
知道为什么git不会忽略像我在gitignore中指定的整个目录......?
嘿,我正在尝试在 Docker php:5.6-fm 图像上安装 ldap 扩展,我的项目需要 ldap。
我厌倦了通过 Dockerfile 安装扩展,如下所示:
RUN apt-get install php5-ldap -y
Run Code Online (Sandbox Code Playgroud)
得到这个错误:
The LDAP PHP extension is not enabled.
Run Code Online (Sandbox Code Playgroud)
我还在网上找到了一些“建议” ,如下所示:
RUN \
apt-get update && \
apt-get install libldap2-dev -y && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
docker-php-ext-install ldap
Run Code Online (Sandbox Code Playgroud)
得到这个错误:
An exception occurred in driver: could not find driver
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么...?如何在 docker 映像中安装 ldap 以便我可以在我的项目中使用它......?
嘿所有在我的Symfony3项目中安装了PhpUnit,当我在我的终端bin/phpunit -c app中运行时,我收到此错误:
Could not load XML from empty string
Run Code Online (Sandbox Code Playgroud)
谷歌搜索它,结果我需要在我的app /目录中应用phpunit.xml文件,所以我做了,它看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "autoload.php" >
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests</directory>
<!--directory>../src/*/Bundle/*Bundle/Tests</directory-->
</testsuite>
</testsuites>
<!--
<php>
<server name="KERNEL_DIR" value="/path/to/your/app/" />
</php>
-->
<filter>
<whitelist>
<directory>../src</directory>
<exclude>
<directory>../src/*/*Bundle/Resources</directory>
<directory>../src/*/*Bundle/Tests</directory>
<!--directory>../src/*/Bundle/*Bundle/Resources</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory-->
</exclude>
</whitelist>
</filter>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
所以现在它工作正常,但我无法找到答案的问题是: …
我正在为我的班级写一个测试,但是我收到了这个错误:
PHPUnit_Framework_MockObject_Builder_InvocationMocker Object (...) does not match expected type "array".
Run Code Online (Sandbox Code Playgroud)
我的测试班:
<?php
namespace User\UserBundle\Tests\Dto\Template;
use User\UserBundle\Dto\Template\GenerateReportsTemplate;
use User\UserBundle\Doctrine\DatabaseRepository;
use User\UserBundle\Validation\ValidationClass;
class GenerateReportsTemplateTest extends \PHPUnit_Framework_TestCase
{
public static $reportData = array
(
'rowid' => '',
'emailaddress' => '',
'firstname' => '',
'surname' => '',
'contact_number' => '',
);
protected $object;
public $validate;
public $db;
protected function setUp()
{
$this->validate = $this->getMockBuilder('User\UserBundle\Validation\ValidationClass')
->disableOriginalConstructor()
->getMock();
$this->db = $this->getMockBuilder('User\UserBundle\UFODoctrine\DatabaseRepository')
->disableOriginalConstructor()
->getMock();
$this->object = $this->createGenerateReportsTemplateInstance();
}
public function createGenerateReportsTemplateInstance()
{
return new GenerateReportsTemplate
(
$this->validate, …Run Code Online (Sandbox Code Playgroud) 我正在尝试循环遍历数组 ob 对象并将数组的项目分组到具有匹配 id 的新数组中:
API示例:
api_array [
{id: 1, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 1, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 1, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 2, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 2, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 2, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 3, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 3, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 3, postcode: 'xxx', street: 'xxx', city: 'xxx'}, …Run Code Online (Sandbox Code Playgroud) 我正在尝试为表单上的验证编写 RTL 测试。我正在使用useFormhook 来Yup进行验证。
我想测试的场景是当用户单击Add提交的按钮而不填写所有必填字段(标题和描述)时。在这种情况下,一些错误消息将在 from 的空输入下弹出。我想测试的正是这些消息。
我已经编写了测试,在其中找到标题、描述和“添加”按钮,但是当我单击“添加”按钮并执行操作时,screen.debug()错误消息不存在。
表单输入被截断:
<div className="Form__title">
<label className="Form__title--label" htmlFor="title">
Title
</label>
<input
{...register("title")}
type="text"
placeholder="Title..."
data-testid="titleInput"
/>
{errors?.title && (
<p data-testid="titleError">{errors.title.message}</p>
)}
</div>
Run Code Online (Sandbox Code Playgroud)
我的测试:
test("throws title must be at least 1 characters", async () => {
renderWithProviders(<TileForm />);
const error = "title must be at least 1 characters";
const addNewIdeaButton = screen.getByText("Add New Idea");
await userEvent.click(addNewIdeaButton);
const descriptionInput = screen.getByTestId("descriptionInput");
await userEvent.type(descriptionInput, "foo");
const addButton = …Run Code Online (Sandbox Code Playgroud) 我正在使用Symfony2并尝试访问邮件服务,但不断收到此错误消息:
{"errors":{"code":500,"message":"错误:在非对象上调用成员函数get()"}}
我的代码:
<?php
namespace TestBundle\UserBundle\Utilities;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class EmailServiceClass extends Controller
{
public function sendEmail($subject, $to, $body)
{
$msg = \Swift_Message::newInstance();
$msg->setSubject($subject);
$msg->setTo($to);
$msg->setBody($body);
$msg->setContentType('text/html');
$msg->setCharset('utf-8');
$msg->setFrom('test@gmail.com');
$this->get('mailer')->send($msg);
}
}
Run Code Online (Sandbox Code Playgroud)
错误来自这一行: $this->get('mailer')->send($msg);
根据我的理解,当我扩展Controller调用时,我应该能够访问此服务而无需专门创建服务.
只是想学习js并编写一些迷你游戏逻辑,但我被困住了,因为contantley遇到此错误 Uncaught TypeError: roundScore is not a function
不知道为什么这是因为我确实有问题的功能:
var playerScore = 0;
var player = 0;
var roundScore = 0;
function rollDice() {
var dice;
dice = Math.floor((Math.random() * 6) + 1);
return dice;
}
function playerTurn() {
player === 0 ? player = 1 : player = 0;
}
function roundScore() {
rollDice() !== 1 ? roundScore += rollDice() : (playerTurn(), roundScore = 0);
return roundScore;
}
document.getElementById('rollDice').addEventListener('click', function () {
document.getElementById('round-score-' + player).innerHTML = roundScore();
});
Run Code Online (Sandbox Code Playgroud)
有人可以看到我为什么收到此错误的信息吗?谢谢
我正在尝试将两个对象合并为一个,但是我需要确保对象值和键的第一个数组成为另一个对象数组的键值,希望这是有道理的:
所以我有一个像这样的一些信息的dataConstant:
export const tileData = [
{
title: 'JS CONS',
skill: 40,
visitTitle: 'Visit JS',
visitUrl: 'https://www.google.co.uk'
},
{
title: 'JS CONS',
skill: 50,
visitTitle: 'Visit JS',
visitUrl: 'https://www.google.co.uk'
}
]
Run Code Online (Sandbox Code Playgroud)
我将此常量导入到我的React组件中。在同一个内部,我将导入多个图像,并将它们放入对象数组中,如下所示:
//the values of the objects keys are imported logos
getLogos(tileData) {
const logo = [{logo: js}, {logo: react}];
var combi = [...logo, ...i];
console.log(combi);
return combi;
}
Run Code Online (Sandbox Code Playgroud)
结果是:
0: {logo: "/static/media/js.a672e76f.png"}
1: {logo: "/static/media/react.5513eea1.png"}
2: {title: "JS CONS", skill: 40, visitTitle: "Visit JS", visitUrl: "https://www.google.co.uk"}
3: {title: …Run Code Online (Sandbox Code Playgroud)