我无法通过PHPUnit中的测试解决问题。 这是我的代码,存在某些错误。 这是年度百分比率计算(https://en.wikipedia.org/wiki/Annual_percentage_rate)。 在cmd中:
C:\Users\Shambler\Downloads\test-taeg-senior\test-taeg>phpunit
PHP Warning: Module 'oci8' already loaded in Unknown on line 0
Warning: Module 'oci8' already loaded in Unknown on line 0
PHPUnit 3.7.21 by Sebastian Bergmann.
Configuration read from C:\Users\Shambler\Downloads\test-taeg-senior\test-taeg\phpunit.xml
Time: 74 ms, Memory: 2.00MB
No tests executed!
C:\Users\Shambler\Downloads\test-taeg-senior\test-taeg>
不要考虑Oracle模块,这是另一件事。 我在“ composer install”之后运行了“ phpunit”.
project/tests/test-general.php:
<?php
use MotorK\{ Rate, Tae, Taeg };
class TestTaeg extends \PHPUnit\Framework\TestCase {
/**
* Example from http://www.calcolatoremutui.it/tan-e-taeg/
*/
public function test_tae() {
$obj = Tae::init( 5, 12 );
$this->assertEquals( 5.116, round( $obj->calculate(), 3 ) );
$this->expectOutputString( '5.116 %' );
echo $obj;
}
/**
* Example from http://www.calcolatoremutui.it/tan-e-taeg/
*/
public function test_rate() {
$obj = Rate::init( 100000, 5, 12, 20 );
$this->assertEquals( 659.96, round( $obj->calculate(), 2 ) );
$this->expectOutputString( '659.96 €' );
echo $obj;
}
/**
* Example from http://www.calcolatoremutui.it/tan-e-taeg/
*/
public function test_taeg() {
$obj = Taeg::init( 99000, 5, 661.96, 12, 20 );
$this->assertEquals( 5.281, round( $obj->calculate(), 3 ) );
$this->expectOutputString( '5.281 %' );
echo $obj;
}
}
project/phpunit.xml
<phpunit
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuite name="Internal tests">
<directory prefix="test-" suffix=".php">./tests/</directory>
</testsuite>
<groups>
<include>
<group>default</group>
</include>
</groups>
<filter>
<whitelist>
<directory suffix=".php">./includes/</directory>
</whitelist>
</filter>
我尝试了很多次,但是仍然不能解决这个问题。