Finding patterns of failure in a Unit Test

I'm new to Unit Testing, and I'm only getting into the routine of building test suites. I have what is going to be a rather large project that I want to build tests for from the start. I'm trying to figure out general strategies and patterns for building test suites. When you look at a class, many tests come to you obviously due to the nature of the class. Say for a "user ac

在单元测试中查找失败模式

我是单元测试新手,我只是进入构建测试套件的例程。 我有什么是一个很大的项目,我想从一开始就构建测试。 我试图找出构建测试套件的一般策略和模式。 当你看一堂课时,显然由于课堂的性质,很多考试都会出现在你面前。 对于具有基本CRUD操作的“用户帐户”类,与数据库表相关,我们将要测试 - CRUD。 创建一个对象并查看它是否存在 查询其属性 改变一些属性 将某些属性更改为不正确的值 并再次删除它。 至于如

Obscuring database id's

I have a table with a primary key that is auto increment. I want to have an image associated with the primary key but I don't want the primary key to be revealed. Would naming the images something like: $filename = md5($primarykey + $secret_string) . '.jpg'; be a good solution? I am worried that there could be a collision and a file be over written. The other option of course is to ge

模糊数据库ID

我有一个主键是自动增量的表。 我想要一个与主键关联的图像,但我不希望显示主键。 将图像命名为: $filename = md5($primarykey + $secret_string) . '.jpg'; 是一个好的解决方案? 我担心可能会发生碰撞,文件被覆盖。 另一个选项当然是生成一个随机字符串,检查它不存在作为一个文件,并将其存储在数据库中...但是,如果不需要,它不希望存储额外的数据。 另一个选项是逻辑转换youtube url风格,例如1 = a 2 = b但

Array to string conversion error in Magento logs

My Magento system.log is full with this error: Notice: Array to string conversion in /app/code/core/Mage/Core/Block/Abstract.php on line 1232. I've added the code here: (rule 1232 is $key = implode('|', $key);) /** * Get Key for caching block content * * @return string */ public function getCacheKey() { if ($this->hasData('cache_key'

数组到字符串转换错误在Magento日志中

我的Magento system.log充满了这个错误:注意:数组到字符串转换在1232行/app/code/core/Mage/Core/Block/Abstract.php。 我在这里添加了代码:(规则1232是$ key = implode('|',$ key);) /** * Get Key for caching block content * * @return string */ public function getCacheKey() { if ($this->hasData('cache_key')) { return $this->g

Setting a Cookie on Login

Say my domain was www.example.com and I was setting a user's login cookie if their login credentials are correct. How would I set the cookie? I've done the same thing with sessions and cookies on my localhost and worked perfectly fine. But when I uploaded my files on to a web server with an actual domain, it doesn't seem to work? Cookie path: "/" Cookie domain: "

在登录时设置Cookie

假设我的域名是www.example.com,并且如果他们的登录凭据是正确的,我将设置用户的登录Cookie。 我将如何设置cookie? 我使用本地主机上的会话和cookie完成了相同的事情,并且工作得很好。 但是当我将文件上传到具有实际域的Web服务器时,它似乎不起作用? Cookie路径:“/” Cookie域:“.example.com” 谢谢,

About PHP prepared statement

I'm working around for an easy function to execute prepared statement. Now I get a problem: class mysqli_extend extends mysqli{ function pquery(){ $input = func_get_args(); if ($stmt = parent::prepare($input[0])){ $input = array_slice($input,1); $index = count($input); if ($index){ //non-0 == true, 0 == false $typestr = ''; while (

关于PHP准备的声明

我正在寻找一个简单的函数来执行准备好的语句。 现在我遇到了一个问题: class mysqli_extend extends mysqli{ function pquery(){ $input = func_get_args(); if ($stmt = parent::prepare($input[0])){ $input = array_slice($input,1); $index = count($input); if ($index){ //non-0 == true, 0 == false $typestr = ''; while ($ele = current($input)){

mySQLi prepared statement unable to get

I am totally confused by mySQLi. Although I have been using procedural mysql calls for years, I want to get used to making prepared statements for the db security/mySQL injection protection it offers. I am trying to write a simple select statement (yes I know making a procedural call for this offers performance enhancement). When run, I get all the echoes until I hit the $result = $stmt->ge

mySQLi准备好的语句无法获取

我完全被mySQLi搞糊涂了。 虽然我多年来一直在使用过程式mysql调用,但我想习惯为它提供的db安全/ mySQL注入保护做准备语句。 我正在尝试编写一个简单的select语句(是的,我知道为提高性能而进行过程调用)。 运行时,我得到所有的回声,直到我点击$result = $stmt->get_result(); 零件。 这对我来说似乎相当简单,但是我在mySQLi上阅读几个小时的手册后却感到茫然。 任何想法,为什么这将失败? *注意:这是一个测

Need some explanation about prepared statements in PHP

Reading this page http://www.php.net/manual/en/mysqli-stmt.bind-result.php I got some questions about PS In examples i don't see $stmt = $db->stmt_init(); Is it required to create new instance ( add $stmt=$db->stmt_init() line) at the beginning of the every statement and $stmt->close at the end or it doesn't matter at all: I can start from $stmt = $mysqli->prepare(".

在PHP中需要一些关于准备语句的解释

阅读本页http://www.php.net/manual/en/mysqli-stmt.bind-result.php 我有一些关于PS的问题 在例子中,我没有看到$stmt = $db->stmt_init(); 是否需要在每个语句的开始处创建新实例(在$stmt=$db->stmt_init()行中添加$stmt=$db->stmt_init()行)并且$ stmt-> close在结尾或完全没有关系:我可以从$stmt = $mysqli->prepare("... ?? 我可以在代码的开头创建语句对象1次并使用它全部代码长吗? 由于

PHP: Getting insert confirmation on prepared statement

I am a newbie to prepared statements and trying to get something simple to work. This is my DB table: `unblocker_users` ( `uno` bigint(20) NOT NULL AUTO_INCREMENT, `user_email` varchar(210) DEFAULT NULL, `pw_hash` varchar(30) DEFAULT NULL, `email_confirmed` tinyint(4) DEFAULT NULL, `total_requests` bigint(20) DEFAULT NULL, `today_date` date DEFAULT NULL, `accessed_today` tinyint(

PHP:在准备好的语句上获取插入确认

我是一位准备好陈述并尝试简单工作的新手。 这是我的数据库表格: `unblocker_users` ( `uno` bigint(20) NOT NULL AUTO_INCREMENT, `user_email` varchar(210) DEFAULT NULL, `pw_hash` varchar(30) DEFAULT NULL, `email_confirmed` tinyint(4) DEFAULT NULL, `total_requests` bigint(20) DEFAULT NULL, `today_date` date DEFAULT NULL, `accessed_today` tinyint(4) DEFAULT NULL,) 这是我的功能插入一些

How to print out the real sql, not just the prepared statement?

We're using Doctrine, a PHP ORM. I am creating a query like this: $q = Doctrine_Query::create()->select('id')->from('MyTable'); and then in the function I'm adding in various where clauses and things as appropriate, like this $q->where('normalisedname = ? OR name = ?', array($string, $originalString)); Later on, before execute() -ing that query object, I want to print out th

如何打印出真正的SQL,而不仅仅是准备好的声明?

我们正在使用一种PHP ORM Doctrine。 我正在创建一个像这样的查询: $q = Doctrine_Query::create()->select('id')->from('MyTable'); 然后在函数中添加各种where子句和适当的东西,就像这样 $q->where('normalisedname = ? OR name = ?', array($string, $originalString)); 之后,在execute()该查询对象之前,我想打印出原始SQL以检查它,并执行以下操作: $q->getSQLQuery(); 但是,只打印准备好的语句,

Ajax push system

In my own system, I have a PHP page which displays all the goods I have sold through my online webshops, from the latest transaction to the first. I would like this page to automatically update, whenever people buy something from me. I could make AJAX call every 5 seconds to check the orders in my databases, but that seems 1980? or is it that way people do it? How can I go about pushing a

Ajax推送系统

在我自己的系统中,我有一个PHP页面,显示通过我的在线网上商店销售的所有商品,从最新的交易到第一个。 我希望这个页面自动更新,每当有人从我那里买东西时。 我可以每5秒钟进行一次AJAX调用来检查我的数据库中的订单,但似乎是1980年? 或者人们是这样做的吗? 当我的php newOrder()函数(可以称之为)被调用时,我该如何去推送一个通知到我的php页面? 您可以在PHP中实现推送,但它不会是最有效的解决方案,因为实