1.assertArrayHasKey()
用法:$this->assertArrayHasKey(‘foo’, [‘bar’ => ‘baz’]);
等同于array_key_exists(),查数组有木有某个键
2.assertClassHasAttribute()
用法:$this->assertClassHasAttribute(‘platform’, User::class);
查看某个类是否有某个变量
3.assertArraySubset()
用法:$this->assertArraySubset([‘config’ => [‘key-a’, ‘key-b’]], [‘config’ => [‘key-a’]]);//false
$this->assertClassHasAttribute([‘config’ => [‘key-a’]], [‘config’ => [‘key-a’, ‘key-b’]);//true
传入两个数组,判断第二个数组是否包含第一个数组
4.assertClassHasStaticAttribute()
用法:$this->assertClassHasStaticAttribute(‘foo’, User::class);//false
$this->assertClassHasStaticAttribute(‘platform’, User::class);//true
查看某个类是否有某个静态变量
$this->assertContains(4, [1, 2, 3]);//判断数组是否含有某个数字元素
$this->assertContains('foo', 'FooBar');//判断字符串是否含有某个字符串
$this->assertContains('foo', 'FooBar', '', true);//判断字符串是否含有某个字符串(大小写不敏感)
assertContainsOnly();//类似$this->assertArrayHasKey
$this->assertContainsOnlyInstancesOf(
Foo::class,
[new Foo, new Bar, new Foo]
);//判断类集合是否包含Foo::class
$this->assertCount(0, ['foo']);//判断数组长度是否为传入参数
$this->assertDirectoryExists('/path/to/directory');//判断指定的目录是否存在
$this->assertDirectoryIsReadable('/path/to/directory');//判断指定的目录是否存在和是否可读
$this->assertDirectoryIsWritable('/path/to/directory');//判断指定的目录是否存在和是否可写
$this->assertEmpty(['foo']);//判断是否为空
$this->assertNotEmpty(['foo']);//判断是否为空
$this->assertEqualXMLStructure($expected, $actual);//判断xml结构
$this->assertEquals('bar', 'baz');//判断是否相等(数字,字符串,数组,对象)
$this->assertEquals(1.0, 1.1, '', 0.2);//细化到float $this->assertFalse(true);//判断是否为false
$this->assertFileEquals('/home/sb/expected', '/home/sb/actual');//判断指定的文件是否相同
$this->assertFileExists('/path/to/file');//判断文件是否存在
$this->assertFileIsReadable('/path/to/file');//判断文件是否可读
$this->assertFileIsWritable('/path/to/file');//判断文件是否可写
$this->assertGreaterThan(2, 1);//当第2个的值 不大于 第1个的值时报告错误
$this->assertGreaterThanOrEqual(2, 1);//当第2个参数的值 不大于且不等于 第1个参数的值时报告错误
$this->assertInfinite(1);//判断int
$this->assertInstanceOf(RuntimeException::class, new Exception);//当参数二不是参数一的实例时报错
$this->assertInternalType('string', 42);//判断参数2类型是否正确
$this->assertIsReadable('/path/to/unreadable');//文件或目录不可读时报告错误
$this->assertIsWritable('/path/to/unwritable');//文件或目录不可写入时报告错误
$this->assertJsonFileEqualsJsonFile( 'path/to/fixture/file', 'path/to/actual/file');//文件或目录的值不匹配时报告错误
$this->assertJsonStringEqualsJsonFile( 'path/to/fixture/file', json_encode(['Mascot' => 'ux']) );//json或文件或目录的值不匹配时报告错误
$this->assertJsonStringEqualsJsonString( json_encode(['Mascot' => 'Tux']), json_encode(['Mascot' => 'ux']) );//两个json的值不匹配时报告错误
$this->assertLessThan(1, 2);//当参数2的值不小于参数1的值时报告错误
$this->assertLessThanOrEqual(1, 2);//当参数2的值不小于且不等于参数1的值时报告错误
$this->assertNan(1);//不是 NAN 时报告错误
$this->assertNull('foo');//不是 null 时报告错误
$this->assertObjectHasAttribute('foo', new stdClass);//new stdClass为$object当 $object->attributeName 不存在时报告错误
$this->assertRegExp('/foo/', 'bar');//不匹配于正则表达式时报告错误
$this->assertStringMatchesFormat('%i', 'foo');//不匹配于定义的格式时报告错误
$this->assertStringMatchesFormatFile('/path/to/expected.txt', 'foo');//不匹配于内容所定义的格式时报告错误
$this->assertSame('2204', 2204);//当两个变量的值与类型不完全相同时报告错误
$this->assertSame(new stdClass, new stdClass);//当两个变量不是指向同一个对象的引用时报告错误
$this->assertStringEndsWith('suffix', 'foo');//当参数2不以参数1结尾时报告错误
$this->assertStringEqualsFile('/home/sb/expected', 'actual');//当参数1(路径)所指定的文件其内容不是参数2时报告错误
$this->assertStringStartsWith('prefix', 'foo');//当参数2不以参数1开头时报告错误
$this->assertThat( $theBiscuit, $this->logicalNot( $this->equalTo($myBiscuit) ) );//当 $value(参数1) 不符合约束条件 $constraint(参数2) 时报告错