我知道如何用PHPUnit库测试php输出,使用expectOutputString()或expectOutputString().现在我需要确保输出不包含给定的字符串.我可以使用输出缓冲和搜索内部字符串来做到这一点,但可能更好的方法是使用expectOutputString()正确的表达式.
该表达式应该如何构建?
我正在尝试一些代码从URL通过post方法和搜索数据库表获取该值以获取该值并从数据库获取信息并将其编码为JSON响应.
这是我的代码:
<?php
//open connection to mysql db
$connection = mysqli_connect("localhost","root","","json") or die("Error " . mysqli_error($connection));
if (isset($_POST['empid'])) {
$k = $_POST['empid'];
//fetch table rows from mysql db
$sql = "select `salary` from tbl_employee where `employee_id` = $k ";
} else {
//fetch table rows from mysql db
$sql = "select `salary` from tbl_employee";
}
//fetch table rows from mysql db
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray = array();
while($row =mysqli_fetch_assoc($result)) …Run Code Online (Sandbox Code Playgroud) 我需要将path生成的非转义URL放入input元素.
使用routing.yml
profile_delete:
pattern: /student_usun/{id}
defaults: { _controller: YyyXXXBundle:Profile:delete }
Run Code Online (Sandbox Code Playgroud)
list.html.twig
<input id="deleteUrl" value="{{ path('profile_delete', {id: '$'}) }}"/>
Run Code Online (Sandbox Code Playgroud)
结果是:
<input id="deleteUrl" value="/student_usun/%24"/>
Run Code Online (Sandbox Code Playgroud)
我尝试|raw过滤器,并在{% autoescape false %}标签之间放置twig代码,结果仍然相同.
我需要保留Profile的更改的数据库历史记录.除了配置文件数据,我必须保存时间戳和user_id.查询以创建新的历史记录很简单:
INSERT INTO history_profile
SELECT NULL, CURRENT_TIMESTAMP(), p.* FROM profile p WHERE p.profile_id=?
Run Code Online (Sandbox Code Playgroud)
放这个查询的地方?我不能使用触发器.我有几个想法:
在提交表单中调用的控制器中
$em = $this->getEntityManager();
$conn = $em->getConnection();
if (!is_null($profile->getProfileId()))
{
$conn->executeQuery('INSERT INTO history_profile SELECT NULL, CURRENT_TIMESTAMP(), p.* FROM profile p WHERE p.profile_id=?', array($profile->getProfileId()));
}
$em->persist($profile);
$em->flush();
Run Code Online (Sandbox Code Playgroud)
但即使没有对配置文件的更新,也会在每次提交时执行此查询.
在实体中,作为preUpdate的事件监听器
class Profile {
/**
* @ORM\preUpdate
* @ORM\prePersist
*/
public function onPrePersist()
{
}
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何获得教条的连接对象
编辑 - EntityAudit试用版
这个捆绑看起来很有希望,但我无法配置它.我正确安装它,当我添加到config.yml时:
simple_things_entity_audit:
audited_entities:
- AldenXyzBundle\Entity\Profile
Run Code Online (Sandbox Code Playgroud)
然后看了一下查询
php ./app/console doctrine:schema:update --dump-sql
Run Code Online (Sandbox Code Playgroud)
但是只有SQL用于创建表修订:
CREATE TABLE revisions (id INT AUTO_INCREMENT NOT NULL, …Run Code Online (Sandbox Code Playgroud) 这是show-data组件:
@Component({
selector: 'show-data',
template: `yes! Now showing the show-data directive template !`
})
export class ShowData {}
Run Code Online (Sandbox Code Playgroud)
而它的父母:
@Component({
selector: 'my-app',
template: `
The 'shouldShow' boolean value is: {{shouldShow}}
<show-data *ngIf="shouldShow"></show-data>
<div *ngIf="!shouldShow">NOT showing the show-data directive template</div>
`,
directives: [ShowData]
})
export class App {
shouldShow:boolean = false;
constructor(){
console.log("shouldShow value before timeout",this.shouldShow);
window.setTimeout(function(){
this.shouldShow = true;
console.log("shouldShow value after timeout",this.shouldShow);
}, 1000);
}
}
Run Code Online (Sandbox Code Playgroud)
最初,该shouldShow变量设置为false,并且show-data不显示指令模板.精细.
shouldShow 然后由父组件构造函数在一秒后设置为"true".
为什么不在shouldShow父组件视图中更新值?
这是一个傻瓜
我可以使用什么命令从测试套件中启动特定的e2e测试用例?
如果无法做到这一点-运行特定的测试套件可能是一些解决方法。
我使用茉莉,因果和量角器。我用命令开始测试
npm run e2e
Run Code Online (Sandbox Code Playgroud)
在中定义 package.json
"e2e": "protractor protractor.config.js"
Run Code Online (Sandbox Code Playgroud)
我可以重新定义此任务(或创建新任务)
"e2e-s": "protractor protractor.config.js --specs ./app/dashboard/e2e-spec.js"
Run Code Online (Sandbox Code Playgroud)
但我想从命令行执行此操作。
我目前正在尝试使用 Mocked Provider 测试样式组件,如下所示:
import React from "react";
import TestResults from "./TestResults";
import {
render,
cleanup,
findByTestId,
findByText,
waitForElement,
} from "@testing-library/react";
import { MockedProvider } from "@apollo/react-testing";
describe("TestResultsComponent", () => {
describe("Overall", () => {
it("should render successfully - base", async () => {
const { getByText } = render(
<MockedProvider>
<TestResults />
</MockedProvider>
);
expect(getByText("Preview")).toBeInTheDocument();
});
});
});
Run Code Online (Sandbox Code Playgroud)
我在 TestResults 文件中使用 makeStyles 钩子
当我运行我的测试时,我收到以下错误:
TypeError: theme.spacing is not a function
Material-UI: the `styles` argument provided is invalid.
You …Run Code Online (Sandbox Code Playgroud) unit-testing reactjs react-apollo apollo-client react-testing-library
为了共享到WiFi设备的互联网连接,我使用了命令行或非常容易设置和使用程序Virtual Route Manager v1.0.但它使用5GHz频段(频道36)创建网络.现在我的Android设备无法在此范围内工作.
我已经尝试了所有7种方式来共享以太网.没有建议如何设置频段和频道.
如何连接到2.4GHz频段?
我有实体User与字段userName(与appriopriate getter和setter)映射到user_name表中的字段users.在UserRepository我从数据库中获取一条记录,我有$user类User.我怎样才能找到表格和字段名称$user->userName?我需要以某种方式从注释中获取信息.我发现这个信息在Doctrine2缓存中,我找到了类ClassMetadataInfo文档,但我不知道如何将它放在一起.
我想以字符串或(首选)字符串数组的形式返回 DOM 元素的类名。
cy.get(selector).?
我不想使用
cy.get(selector).should('have.class', 'abc')
因为我需要在测试中进一步使用类名。
symfony ×3
angular ×2
doctrine-orm ×2
cypress ×1
jasmine ×1
json ×1
karma-runner ×1
mysql ×1
php ×1
phpunit ×1
post ×1
protractor ×1
react-apollo ×1
reactjs ×1
share ×1
twig ×1
typescript ×1
unit-testing ×1
wifi ×1