IsArrayTest.php 885 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace EasySwoole\Validate\tests;
  3. /**
  4. * @internal
  5. */
  6. class IsArrayTest extends BaseTestCase
  7. {
  8. public function testIsArray()
  9. {
  10. $this->validate->addColumn('test')->isArray();
  11. $this->assertEquals(false, $this->validate->validate(['test' => 1]));
  12. $this->assertEquals('test类型必须为数组', $this->validate->getError()->__toString());
  13. $this->freeValidate();
  14. $this->validate->addColumn('test')->isArray('传递错误');
  15. $this->assertEquals(false, $this->validate->validate(['test' => 1]));
  16. $this->assertEquals('传递错误', $this->validate->getError()->__toString());
  17. $this->freeValidate();
  18. $this->validate->addColumn('test')->isArray();
  19. $this->assertEquals(true, $this->validate->validate(['test' => []]));
  20. $this->assertEquals(null, $this->validate->getError());
  21. }
  22. }