如何使用phpunit测试字符串

如何使用phpunit测试字符串,php,unit-testing,phpunit,Php,Unit Testing,Phpunit,我正在创建这个字符串 'Your maximum heart rate is ' . $int . ' Your body mass index is ' . $float . ' Your body fat percentage is ' . $float '%.' 还它 我的主张是 $stringFormat = 'Your maximum heart rate is %d. Your body mass index is %f. Your body fat percentage is

我正在创建这个字符串

'Your maximum heart rate is ' . $int . ' Your body mass index is ' . $float . ' Your body fat percentage is ' . $float '%.'
还它

我的主张是

$stringFormat = 'Your maximum heart rate is %d. Your body mass index is %f.  Your body fat percentage is %f%.';

        $this->assertStringMatchesFormat($stringFormat, $actualResultm, 'message');
当测试运行时,我得到了这个错误

FatControllerTest::testBodyInfo
message
Failed asserting that format description matches text.
--- Expected
+++ Actual
@@ @@
-Your maximum heart rate is %d. Your body mass index is %f.  Your body fat percentage is %f%.
+Your maximum heart rate is 193. Your body mass index is 43.181818181818. Your body fat percentage is 6.32302%.

现在我想这一定与我告诉它期望一个无符号int和两个浮点有关,它返回一个长字符串,但如果是这样的话,我该如何测试我列出的字符串,它将有3个区域随情况而变化?如果不是这样,那我做错了什么?

我想你有两倍的空间

$stringFormat = 'Your maximum heart rate is %d. Your body mass index is %f.  Your body fat percentage is %f%.';
                                                                            ^ extra space

我想你有双重空间

$stringFormat = 'Your maximum heart rate is %d. Your body mass index is %f.  Your body fat percentage is %f%.';
                                                                            ^ extra space