Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This Symfony5 bundle provides the integration of [Symfony validation component](
- [PhoneMobile](/src/Doctrine/DBAL/Types/PhoneMobileType.php)
- [Phone](/src/Doctrine/DBAL/Types/PhoneType.php)
- [Postal](/src/Doctrine/DBAL/Types/PostalType.php)
- [SpanishNifType](/src/Doctrine/DBAL/Types/SpanishNifType.php)
- [Timezone](/src/Doctrine/DBAL/Types/TimezoneType.php)

It also supports nullable and non-nullable fields.
21 changes: 21 additions & 0 deletions src/Doctrine/DBAL/Types/SpanishNifType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace AssoConnect\DoctrineTypesBundle\Doctrine\DBAL\Types;

class SpanishNifType extends AbstractFixedLengthStringType
{
public const NAME = 'spanishNif';
public const LENGTH = 9;

public function getName(): string
{
return self::NAME;
}

protected function getLength(): int
{
return self::LENGTH;
}
}
31 changes: 31 additions & 0 deletions tests/Doctrine/DBAL/Types/SpanishNifTypeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace AssoConnect\DoctrineTypesBundle\Tests\Doctrine\DBAL\Types;

use AssoConnect\DoctrineTypesBundle\Doctrine\DBAL\Types\SpanishNifType;
use AssoConnect\DoctrineTypesBundle\Tests\TypeTestCase;

class SpanishNifTypeTest extends TypeTestCase
{
protected function getClass(): string
{
return SpanishNifType::class;
}

public function testGetName(): void
{
self::assertSame(SpanishNifType::NAME, $this->type->getName());
}

public function testGetSQLDeclaration(): void
{
$this->abstractPlatform
->method('getVarcharTypeDeclarationSQL')
->with(['length' => SpanishNifType::LENGTH])
->willReturn('VARCHAR');

self::assertSame('VARCHAR', $this->type->getSQLDeclaration([], $this->abstractPlatform));
}
}
Loading