suin/xoopsunit

该包已被弃用,不再维护。作者建议使用xoopsunit包代替。
该包的最新版本(1.3)没有可用的许可证信息。

XoopsUnit是PHPUnit的扩展。您可以使用XoopsUnit编写更简单的测试代码。

1.3 2012-08-22 17:56 UTC

This package is auto-updated.

Last update: 2022-02-01 12:21:03 UTC


README

  • master : 构建状态
  • develop : 构建状态

XoopsUnit是PHPUnit的扩展。您可以使用XoopsUnit编写更简单的测试代码。

特性

  • 揭示对象隐私
  • 自动报告未测试的方法

要求

  • PHP 5.3.0 或更高版本

安装

前往您的项目目录(将有htmlxoops_trust_path

$ cd /path/to/your/xoops

然后运行这个

$ curl https://raw.github.com/gist/3116932/9577749ed6532d3ff6de9b9d1ea3f961ffa55dc7/xoopsunit-install.php -s -o xoopsunit-install.php && php xoopsunit-install.php && \rm xoopsunit-install.php

参考

揭示隐私

您可以使用reveal()简单地操作方法的受保护/私有属性。

<?php

class RevealingSample1
{
	protected $bar = 'the best word is BAR';

	public function getBar()
	{
		return $this->bar;
	}

	protected function _foo()
	{
		return 'Is it possible to call me?';
	}
}

class RevealingSample1Test extends \XoopsUnit\TestCase
{
	public function testGetBar()
	{
		$foo = new RevealingSample1();
		$this->reveal($foo)->attr('bar', 'the best word is FOO'); // Simple to manipulate!!
		$this->assertSame('the best word is FOO', $foo->getBar());
	}

	public function test_foo()
	{
		$foo = new RevealingSample1();
		$actual = $this->reveal($foo)->call('_foo'); // Simple to call!!
		$this->assertSame('Is it possible to call me?', $actual);
	}
}

API