Reworked Type tests

parent 8f25277f
...@@ -33,9 +33,6 @@ parameters: ...@@ -33,9 +33,6 @@ parameters:
# weird class name, represented in stubs as OCI_(Lob|Collection) # weird class name, represented in stubs as OCI_(Lob|Collection)
- '~unknown class OCI-(Lob|Collection)~' - '~unknown class OCI-(Lob|Collection)~'
# impossible inference for covariance
- '~^Property Doctrine\\Tests\\DBAL\\Types\\\S+Test::\$type \(Doctrine\\DBAL\\Types\\\S+Type\) does not accept Doctrine\\DBAL\\Types\\Type\.\z~'
# https://github.com/doctrine/dbal/pull/3582/files#r290847062 # https://github.com/doctrine/dbal/pull/3582/files#r290847062
- -
message: '~Parameter #3 \$type of method Doctrine\\DBAL\\Driver\\Statement::bindValue\(\) expects int, string given\.~' message: '~Parameter #3 \$type of method Doctrine\\DBAL\\Driver\\Statement::bindValue\(\) expects int, string given\.~'
......
...@@ -7,7 +7,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -7,7 +7,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ArrayType; use Doctrine\DBAL\Types\ArrayType;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use function serialize; use function serialize;
...@@ -23,7 +22,7 @@ class ArrayTest extends DbalTestCase ...@@ -23,7 +22,7 @@ class ArrayTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('array'); $this->type = new ArrayType();
} }
public function testArrayConvertsToDatabaseValue() : void public function testArrayConvertsToDatabaseValue() : void
......
...@@ -8,7 +8,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -8,7 +8,6 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BinaryType; use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -32,7 +31,7 @@ class BinaryTest extends DbalTestCase ...@@ -32,7 +31,7 @@ class BinaryTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('binary'); $this->type = new BinaryType();
} }
public function testReturnsBindingType() : void public function testReturnsBindingType() : void
......
...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -24,7 +23,7 @@ class BlobTest extends DbalTestCase ...@@ -24,7 +23,7 @@ class BlobTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('blob'); $this->type = new BlobType();
} }
public function testBlobNullConvertsToPHPValue() : void public function testBlobNullConvertsToPHPValue() : void
......
...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BooleanType; use Doctrine\DBAL\Types\BooleanType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -20,18 +19,28 @@ class BooleanTest extends DbalTestCase ...@@ -20,18 +19,28 @@ class BooleanTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('boolean'); $this->type = new BooleanType();
} }
public function testBooleanConvertsToDatabaseValue() : void public function testBooleanConvertsToDatabaseValue() : void
{ {
self::assertIsInt($this->type->convertToDatabaseValue(1, $this->platform)); $this->platform->expects($this->once())
->method('convertBooleansToDatabaseValue')
->with(true)
->willReturn(1);
self::assertSame(1, $this->type->convertToDatabaseValue(true, $this->platform));
} }
public function testBooleanConvertsToPHPValue() : void public function testBooleanConvertsToPHPValue() : void
{ {
self::assertIsBool($this->type->convertToPHPValue(0, $this->platform)); $this->platform->expects($this->once())
->method('convertFromBoolean')
->with(0)
->willReturn(false);
self::assertFalse($this->type->convertToPHPValue(0, $this->platform));
} }
public function testBooleanNullConvertsToPHPValue() : void public function testBooleanNullConvertsToPHPValue() : void
......
...@@ -10,7 +10,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -10,7 +10,6 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateImmutableType; use Doctrine\DBAL\Types\DateImmutableType;
use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function get_class; use function get_class;
...@@ -25,8 +24,8 @@ class DateImmutableTypeTest extends TestCase ...@@ -25,8 +24,8 @@ class DateImmutableTypeTest extends TestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->type = Type::getType('date_immutable');
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = new DateImmutableType();
} }
public function testFactoryCreatesCorrectType() : void public function testFactoryCreatesCorrectType() : void
......
...@@ -9,7 +9,6 @@ use DateTime; ...@@ -9,7 +9,6 @@ use DateTime;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateIntervalType; use Doctrine\DBAL\Types\DateIntervalType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use stdClass; use stdClass;
...@@ -28,9 +27,7 @@ final class DateIntervalTest extends DbalTestCase ...@@ -28,9 +27,7 @@ final class DateIntervalTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('dateinterval'); $this->type = new DateIntervalType();
self::assertInstanceOf(DateIntervalType::class, $this->type);
} }
public function testDateIntervalConvertsToDatabaseValue() : void public function testDateIntervalConvertsToDatabaseValue() : void
......
...@@ -6,7 +6,7 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,7 @@ namespace Doctrine\Tests\DBAL\Types;
use DateTime; use DateTime;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\DateType;
use function date_default_timezone_set; use function date_default_timezone_set;
class DateTest extends BaseDateTypeTestCase class DateTest extends BaseDateTypeTestCase
...@@ -16,7 +16,7 @@ class DateTest extends BaseDateTypeTestCase ...@@ -16,7 +16,7 @@ class DateTest extends BaseDateTypeTestCase
*/ */
protected function setUp() : void protected function setUp() : void
{ {
$this->type = Type::getType('date'); $this->type = new DateType();
parent::setUp(); parent::setUp();
} }
......
...@@ -10,7 +10,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -10,7 +10,6 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeImmutableType; use Doctrine\DBAL\Types\DateTimeImmutableType;
use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function get_class; use function get_class;
...@@ -25,8 +24,8 @@ class DateTimeImmutableTypeTest extends TestCase ...@@ -25,8 +24,8 @@ class DateTimeImmutableTypeTest extends TestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->type = Type::getType('datetime_immutable'); $this->platform = $this->createMock(AbstractPlatform::class);
$this->platform = $this->getMockBuilder(AbstractPlatform::class)->getMock(); $this->type = new DateTimeImmutableType();
} }
public function testFactoryCreatesCorrectType() : void public function testFactoryCreatesCorrectType() : void
...@@ -46,7 +45,7 @@ class DateTimeImmutableTypeTest extends TestCase ...@@ -46,7 +45,7 @@ class DateTimeImmutableTypeTest extends TestCase
public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void
{ {
$date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); $date = $this->createMock(DateTimeImmutable::class);
$this->platform->expects($this->once()) $this->platform->expects($this->once())
->method('getDateTimeFormatString') ->method('getDateTimeFormatString')
......
...@@ -6,7 +6,7 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,7 @@ namespace Doctrine\Tests\DBAL\Types;
use DateTime; use DateTime;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\DateTimeType;
class DateTimeTest extends BaseDateTypeTestCase class DateTimeTest extends BaseDateTypeTestCase
{ {
...@@ -15,7 +15,7 @@ class DateTimeTest extends BaseDateTypeTestCase ...@@ -15,7 +15,7 @@ class DateTimeTest extends BaseDateTypeTestCase
*/ */
protected function setUp() : void protected function setUp() : void
{ {
$this->type = Type::getType('datetime'); $this->type = new DateTimeType();
parent::setUp(); parent::setUp();
} }
......
...@@ -10,7 +10,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -10,7 +10,6 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeTzImmutableType; use Doctrine\DBAL\Types\DateTimeTzImmutableType;
use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function get_class; use function get_class;
...@@ -25,8 +24,8 @@ class DateTimeTzImmutableTypeTest extends TestCase ...@@ -25,8 +24,8 @@ class DateTimeTzImmutableTypeTest extends TestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->type = Type::getType('datetimetz_immutable');
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = new DateTimeTzImmutableType();
} }
public function testFactoryCreatesCorrectType() : void public function testFactoryCreatesCorrectType() : void
......
...@@ -6,7 +6,7 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,7 @@ namespace Doctrine\Tests\DBAL\Types;
use DateTime; use DateTime;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\DateTimeTzType;
class DateTimeTzTest extends BaseDateTypeTestCase class DateTimeTzTest extends BaseDateTypeTestCase
{ {
...@@ -15,7 +15,7 @@ class DateTimeTzTest extends BaseDateTypeTestCase ...@@ -15,7 +15,7 @@ class DateTimeTzTest extends BaseDateTypeTestCase
*/ */
protected function setUp() : void protected function setUp() : void
{ {
$this->type = Type::getType('datetimetz'); $this->type = new DateTimeTzType();
parent::setUp(); parent::setUp();
} }
......
...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\DecimalType; use Doctrine\DBAL\Types\DecimalType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -21,7 +20,7 @@ class DecimalTest extends DbalTestCase ...@@ -21,7 +20,7 @@ class DecimalTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('decimal'); $this->type = new DecimalType();
} }
public function testDecimalConvertsToPHPValue() : void public function testDecimalConvertsToPHPValue() : void
......
...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\FloatType; use Doctrine\DBAL\Types\FloatType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -21,7 +20,7 @@ class FloatTest extends DbalTestCase ...@@ -21,7 +20,7 @@ class FloatTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('float'); $this->type = new FloatType();
} }
public function testFloatConvertsToPHPValue() : void public function testFloatConvertsToPHPValue() : void
......
...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\GuidType; use Doctrine\DBAL\Types\GuidType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -21,7 +20,7 @@ class GuidTypeTest extends DbalTestCase ...@@ -21,7 +20,7 @@ class GuidTypeTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('guid'); $this->type = new GuidType();
} }
public function testConvertToPHPValue() : void public function testConvertToPHPValue() : void
......
...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -21,7 +20,7 @@ class IntegerTest extends DbalTestCase ...@@ -21,7 +20,7 @@ class IntegerTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('integer'); $this->type = new IntegerType();
} }
public function testIntegerConvertsToPHPValue() : void public function testIntegerConvertsToPHPValue() : void
......
...@@ -8,7 +8,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -8,7 +8,6 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\JsonType; use Doctrine\DBAL\Types\JsonType;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -29,7 +28,7 @@ class JsonTest extends DbalTestCase ...@@ -29,7 +28,7 @@ class JsonTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('json'); $this->type = new JsonType();
} }
public function testReturnsBindingType() : void public function testReturnsBindingType() : void
......
...@@ -7,7 +7,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -7,7 +7,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\ObjectType; use Doctrine\DBAL\Types\ObjectType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use stdClass; use stdClass;
...@@ -24,7 +23,7 @@ class ObjectTest extends DbalTestCase ...@@ -24,7 +23,7 @@ class ObjectTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('object'); $this->type = new ObjectType();
} }
public function testObjectConvertsToDatabaseValue() : void public function testObjectConvertsToDatabaseValue() : void
......
...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\SmallIntType; use Doctrine\DBAL\Types\SmallIntType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -21,7 +20,7 @@ class SmallIntTest extends DbalTestCase ...@@ -21,7 +20,7 @@ class SmallIntTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('smallint'); $this->type = new SmallIntType();
} }
public function testSmallIntConvertsToPHPValue() : void public function testSmallIntConvertsToPHPValue() : void
......
...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\StringType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -21,7 +20,7 @@ class StringTest extends DbalTestCase ...@@ -21,7 +20,7 @@ class StringTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->platform = $this->createMock(AbstractPlatform::class); $this->platform = $this->createMock(AbstractPlatform::class);
$this->type = Type::getType('string'); $this->type = new StringType();
} }
public function testReturnsSQLDeclaration() : void public function testReturnsSQLDeclaration() : void
......
...@@ -10,7 +10,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -10,7 +10,6 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\TimeImmutableType; use Doctrine\DBAL\Types\TimeImmutableType;
use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function get_class; use function get_class;
...@@ -25,8 +24,8 @@ class TimeImmutableTypeTest extends TestCase ...@@ -25,8 +24,8 @@ class TimeImmutableTypeTest extends TestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->type = Type::getType('time_immutable'); $this->platform = $this->createMock(AbstractPlatform::class);
$this->platform = $this->getMockBuilder(AbstractPlatform::class)->getMock(); $this->type = new TimeImmutableType();
} }
public function testFactoryCreatesCorrectType() : void public function testFactoryCreatesCorrectType() : void
...@@ -46,7 +45,7 @@ class TimeImmutableTypeTest extends TestCase ...@@ -46,7 +45,7 @@ class TimeImmutableTypeTest extends TestCase
public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void
{ {
$date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); $date = $this->createMock(DateTimeImmutable::class);
$this->platform->expects($this->once()) $this->platform->expects($this->once())
->method('getTimeFormatString') ->method('getTimeFormatString')
......
...@@ -5,7 +5,7 @@ declare(strict_types=1); ...@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Types; namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\TimeType;
class TimeTest extends BaseDateTypeTestCase class TimeTest extends BaseDateTypeTestCase
{ {
...@@ -14,7 +14,7 @@ class TimeTest extends BaseDateTypeTestCase ...@@ -14,7 +14,7 @@ class TimeTest extends BaseDateTypeTestCase
*/ */
protected function setUp() : void protected function setUp() : void
{ {
$this->type = Type::getType('time'); $this->type = new TimeType();
parent::setUp(); parent::setUp();
} }
......
...@@ -9,7 +9,6 @@ use DateTimeImmutable; ...@@ -9,7 +9,6 @@ use DateTimeImmutable;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\VarDateTimeImmutableType; use Doctrine\DBAL\Types\VarDateTimeImmutableType;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
...@@ -24,12 +23,8 @@ class VarDateTimeImmutableTypeTest extends TestCase ...@@ -24,12 +23,8 @@ class VarDateTimeImmutableTypeTest extends TestCase
protected function setUp() : void protected function setUp() : void
{ {
if (! Type::hasType('vardatetime_immutable')) { $this->platform = $this->createMock(AbstractPlatform::class);
Type::addType('vardatetime_immutable', VarDateTimeImmutableType::class); $this->type = new VarDateTimeImmutableType();
}
$this->type = Type::getType('vardatetime_immutable');
$this->platform = $this->getMockForAbstractClass(AbstractPlatform::class);
} }
public function testReturnsName() : void public function testReturnsName() : void
...@@ -44,7 +39,11 @@ class VarDateTimeImmutableTypeTest extends TestCase ...@@ -44,7 +39,11 @@ class VarDateTimeImmutableTypeTest extends TestCase
public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void
{ {
$date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); $this->platform->expects($this->any())
->method('getDateTimeFormatString')
->will($this->returnValue('Y-m-d H:i:s'));
$date = $this->createMock(DateTimeImmutable::class);
$date->expects($this->once()) $date->expects($this->once())
->method('format') ->method('format')
......
...@@ -7,7 +7,6 @@ namespace Doctrine\Tests\DBAL\Types; ...@@ -7,7 +7,6 @@ namespace Doctrine\Tests\DBAL\Types;
use DateTime; use DateTime;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\VarDateTimeType; use Doctrine\DBAL\Types\VarDateTimeType;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
...@@ -27,10 +26,7 @@ class VarDateTimeTest extends DbalTestCase ...@@ -27,10 +26,7 @@ class VarDateTimeTest extends DbalTestCase
->method('getDateTimeFormatString') ->method('getDateTimeFormatString')
->will($this->returnValue('U')); ->will($this->returnValue('U'));
if (! Type::hasType('vardatetime')) { $this->type = new VarDateTimeType();
Type::addType('vardatetime', VarDateTimeType::class);
}
$this->type = Type::getType('vardatetime');
} }
public function testDateTimeConvertsToDatabaseValue() : void public function testDateTimeConvertsToDatabaseValue() : void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment