小编Tea*_*Pow的帖子

PHPUnit:在<ClassNameTest> .php中找不到类<ClassName>

我的智慧结束了.我必须阅读关于同一主题的每一个SO问题,但没有快乐.

我无法让phpUnit正常工作.我已经使用PEAR成功安装了phpUnit及其依赖项.我还修改了我的php.ini文件并将路径添加到包含路径的phpUnit :(".:/ php/includes:usr/lib/php/pear").

为了测试phpunit是否有效,我已经复制了这个简单的类,所以MyClassTest.php如下:

class MyClassTest extends PHPUnit_Framework_TestCase
{
    public function testCalculate()
    {
        $this->assertEquals(2, 1 + 1);
    }
}
Run Code Online (Sandbox Code Playgroud)

运行"phpunit MyClassTest"会产生以下输出:(运行"phpunit MyTestClass MyTestClass.php"产生相同的结果);

class MyClassTest extends PHPUnit_Framework_TestCase
{
    public function testCalculate()
    {
        $this->assertEquals(2, 1 + 1);
    }
}
PHPUnit 3.7.13 by Sebastian Bergmann.

Class 'MyClassTest' could not be found in 'MyClassTest.php'.
Run Code Online (Sandbox Code Playgroud)

我想不出什么是错的.我已经尝试卸载并重新安装phpunit/PHPUnit,但没有快乐.你能辨别出什么是错的吗?如果您需要更多信息,请告诉我,我将编辑此帖子.提前致谢.

  • PHP 5.3.15
  • PHPUnit 3.7.13
  • OSX 10.8.2

php phpunit unit-testing

9
推荐指数
1
解决办法
4814
查看次数

UITableViewCell重用:单元格显示不正确 - 未按预期重复使用

我创建了一个多选列表,允许选择多种成分.

在我的tableview中,可以根据Ingredient的list属性启用或禁用单元格.如果设置了Ingredient的list属性,则将禁用该单元格.

但是,当重新使用单元格时,它不会像我期望的那样显示.下面的图片比我能更有效地解释问题.

(不应该启用的成分是:蛋糕糖霜,炼乳和Cournflour.)

  1. 第一张图显示了三种成分已禁用并按预期注释.

  2. 但是,在第二个图像中,向下滚动显示某些成分显示为禁用(但您可以选择它们,并且它们具有完全交互).

  3. 第三个图像在向上滚动到顶部后显示列表.一些成分已经变灰,并注意到Cornflour显示为已启用,即使您无法进行交互/选择.

问题与细胞重用有关.似乎在重复使用时,单元格没有被"重置",因此保留了一些"旧"外观.

下面是代码cellForRowAtIndexPath:,因为我确定这是问题所在(尽管我看不出有什么问题).

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }    

    // Fetches the corresponding Ingredient from the ingredientArray
    Ingredient *ingredient = [self.ingredientArray objectAtIndex:indexPath.row];

    if ([ingredient.list isEqualToString:@"Lardr"])
    {
        cell.userInteractionEnabled = NO;
        cell.detailTextLabel.text = @"   Already in your Lardr";
    }
    else if ([ingredient.list isEqualToString:@"Shopping List"])
    {
        cell.userInteractionEnabled = NO;
        cell.detailTextLabel.text = @" …
Run Code Online (Sandbox Code Playgroud)

iphone xcode uitableview ios

7
推荐指数
1
解决办法
6833
查看次数

标签 统计

ios ×1

iphone ×1

php ×1

phpunit ×1

uitableview ×1

unit-testing ×1

xcode ×1