-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectSchemaTest.php
More file actions
30 lines (25 loc) · 1.09 KB
/
ObjectSchemaTest.php
File metadata and controls
30 lines (25 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace Webdevcave\SchemaValidator\Tests\Schemas;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use stdClass;
use Webdevcave\SchemaValidator\Schemas\ArraySchema;
use Webdevcave\SchemaValidator\Schemas\BaseSchema;
use Webdevcave\SchemaValidator\Schemas\ObjectSchema;
use Webdevcave\SchemaValidator\Validator;
#[CoversClass(ObjectSchema::class)]
#[CoversClass(ArraySchema::class)]
#[CoversClass(BaseSchema::class)]
#[CoversClass(Validator::class)]
class ObjectSchemaTest extends TestCase
{
public function testTypeCheck(): void
{
$schema = Validator::object();
$this->assertFalse($schema->validate(1), 'Array schema should not validate integers');
$this->assertFalse($schema->validate(1.1), 'Array schema should not validate floats');
$this->assertFalse($schema->validate('str'), 'Array schema should not validate strings');
$this->assertFalse($schema->validate([1, 2, 3]), 'Array schema should not validate arrays');
$this->assertTrue($schema->validate(new stdClass()), 'Array schema should validate object');
}
}