-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathClassNameValidatorTest.php
More file actions
79 lines (69 loc) · 2.86 KB
/
Copy pathClassNameValidatorTest.php
File metadata and controls
79 lines (69 loc) · 2.86 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/*
* This file is part of the Silverback API Components Bundle Project
*
* (c) Daniel West <daniel@silverback.is>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Silverback\ApiComponentsBundle\Tests\Validator;
use PHPUnit\Framework\TestCase;
use Silverback\ApiComponentsBundle\Entity\Core\ComponentInterface;
use Silverback\ApiComponentsBundle\Exception\InvalidArgumentException;
use Silverback\ApiComponentsBundle\Tests\Functional\TestBundle\Entity\DummyComponent;
use Silverback\ApiComponentsBundle\Tests\Functional\TestBundle\Entity\User;
use Silverback\ApiComponentsBundle\Validator\ClassNameValidator;
use Symfony\Component\VarExporter\LazyObjectInterface;
class ClassNameValidatorTest extends TestCase
{
private DummyComponent $class;
// private LazyObjectInterface $proxy;
protected function setUp(): void
{
$this->class = new DummyComponent();
// $factory = new LazyLoadingValueHolderFactory(new Configuration());
// $this->proxy = $factory->createProxy(
// DummyComponent::class,
// static function (&$wrappedObject) {
// $wrappedObject = new DummyComponent();
// }
// );
}
/**
* @throws \ReflectionException
*/
public function test_validate(): void
{
// $this->assertTrue(ClassNameValidator::validate(ComponentInterface::class, [$this->class, $this->proxy]));
$this->assertTrue(ClassNameValidator::validate(ComponentInterface::class, [$this->class, 'NotAnObject']));
}
/**
* @throws \ReflectionException
*/
public function test_class_same_validation_success(): void
{
$this->assertFalse(ClassNameValidator::isClassSame(User::class, $this->class));
$this->assertTrue(ClassNameValidator::isClassSame(DummyComponent::class, $this->class));
// $this->assertTrue(ClassNameValidator::isClassSame(DummyComponent::class, $this->proxy));
$this->assertTrue(ClassNameValidator::isClassSame(ComponentInterface::class, $this->class));
}
/**
* @throws \ReflectionException
*/
public function test_class_same_validation_invalid_classname(): void
{
$this->expectException(InvalidArgumentException::class);
ClassNameValidator::isClassSame('NotAClass', $this->class);
}
/**
* Kills FalseValue (line 32): when no candidate matches, validate() must return false. A mutant
* flipping the fall-through to `true` would make every unrelated class validate as a form type.
*
* @throws \ReflectionException
*/
public function test_validate_returns_false_when_no_candidate_matches(): void
{
$this->assertFalse(ClassNameValidator::validate(User::class, [$this->class]));
}
}