assertSame('read', $annotation->getReadOperationName(), 'A new annotation must return read'); $annotation->read = 'overwritten'; $this->assertSame('overwritten', $annotation->getReadOperationName()); $annotation->prefix = 'prefix'; $this->assertSame('prefix.overwritten', $annotation->getReadOperationName()); } public function testGetEditOperation(): void { $annotation = new ColumnSecurity(); $this->assertSame('edit', $annotation->getEditOperationName(), 'A new annotation must return read'); $annotation->edit = 'overwritten'; $this->assertSame('overwritten', $annotation->getEditOperationName()); $annotation->prefix = 'prefix'; $this->assertSame('prefix.overwritten', $annotation->getEditOperationName()); } public function placeholderScalarDataProvider(): array { return [ ['string', '???'], ['integer', 0], ['int', 0], ['float', 0.0], ['object', null], ['bool', false], ['boolean', false], //['datetime', (new \DateTime())->setTimestamp(0)] ]; } /** * @dataProvider placeholderScalarDataProvider * * @param $expected_value */ public function testGetPlaceholderScalar(string $type, $expected_value): void { $annotation = new ColumnSecurity(); $annotation->type = $type; $this->assertSame($expected_value, $annotation->getPlaceholder()); } public function testGetPlaceholderSpecifiedValue(): void { $annotation = new ColumnSecurity(); $annotation->placeholder = 3434; $this->assertSame(3434, $annotation->getPlaceholder()); $annotation->placeholder = [323]; $this->assertCount(1, $annotation->getPlaceholder()); //If a placeholder is specified we allow every type $annotation->type = 'type2'; $annotation->placeholder = 'invalid'; $this->assertSame('invalid', $annotation->getPlaceholder()); } public function testGetPlaceholderDBElement(): void { $annotation = new ColumnSecurity(); $annotation->type = AttachmentType::class; /** @var AttachmentType $placeholder */ $placeholder = $annotation->getPlaceholder(); $this->assertInstanceOf(AttachmentType::class, $placeholder); $this->assertSame('???', $placeholder->getName()); $annotation->placeholder = 'test'; $placeholder = $annotation->getPlaceholder(); $this->assertInstanceOf(AttachmentType::class, $placeholder); $this->assertSame('test', $placeholder->getName()); } }