Skip to content

Commit

Permalink
Static assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Majkl578 committed Mar 5, 2018
1 parent 800030c commit 724e1e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public function testFromNonExistingTypeWithNonExistingClass() : void
$className = self::class . str_replace('.', '', uniqid('', true));
$exception = InvalidArgumentException::fromNonExistingClass($className);

$this->assertInstanceOf(InvalidArgumentException::class, $exception);
$this->assertSame('The provided class "' . $className . '" does not exist', $exception->getMessage());
self::assertInstanceOf(InvalidArgumentException::class, $exception);
self::assertSame('The provided class "' . $className . '" does not exist', $exception->getMessage());
}

public function testFromNonExistingTypeWithTrait() : void
{
$exception = InvalidArgumentException::fromNonExistingClass(SimpleTraitAsset::class);

$this->assertSame(
self::assertSame(
sprintf('The provided type "%s" is a trait, and can not be instantiated', SimpleTraitAsset::class),
$exception->getMessage()
);
Expand All @@ -42,7 +42,7 @@ public function testFromNonExistingTypeWithInterface() : void
{
$exception = InvalidArgumentException::fromNonExistingClass(InstantiatorInterface::class);

$this->assertSame(
self::assertSame(
sprintf(
'The provided type "%s" is an interface, and can not be instantiated',
InstantiatorInterface::class
Expand All @@ -56,7 +56,7 @@ public function testFromAbstractClass() : void
$reflection = new ReflectionClass(AbstractClassAsset::class);
$exception = InvalidArgumentException::fromAbstractClass($reflection);

$this->assertSame(
self::assertSame(
sprintf(
'The provided class "%s" is abstract, and can not be instantiated',
AbstractClassAsset::class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public function testFromSerializationTriggeredException() : void
$previous = new Exception();
$exception = UnexpectedValueException::fromSerializationTriggeredException($reflectionClass, $previous);

$this->assertInstanceOf(UnexpectedValueException::class, $exception);
$this->assertSame($previous, $exception->getPrevious());
$this->assertSame(
self::assertInstanceOf(UnexpectedValueException::class, $exception);
self::assertSame($previous, $exception->getPrevious());
self::assertSame(
'An exception was raised while trying to instantiate an instance of "'
. self::class . '" via un-serialization',
$exception->getMessage()
Expand All @@ -36,8 +36,8 @@ public function testFromUncleanUnSerialization() : void
$reflection = new ReflectionClass(AbstractClassAsset::class);
$exception = UnexpectedValueException::fromUncleanUnSerialization($reflection, 'foo', 123, 'bar', 456);

$this->assertInstanceOf(UnexpectedValueException::class, $exception);
$this->assertSame(
self::assertInstanceOf(UnexpectedValueException::class, $exception);
self::assertSame(
sprintf(
'Could not produce an instance of "%s" '
. 'via un-serialization, since an error was triggered in file "bar" at line "456"',
Expand All @@ -48,8 +48,8 @@ public function testFromUncleanUnSerialization() : void

$previous = $exception->getPrevious();

$this->assertInstanceOf(\Exception::class, $previous);
$this->assertSame('foo', $previous->getMessage());
$this->assertSame(123, $previous->getCode());
self::assertInstanceOf(\Exception::class, $previous);
self::assertSame('foo', $previous->getMessage());
self::assertSame(123, $previous->getCode());
}
}
8 changes: 4 additions & 4 deletions tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function setUp() : void
*/
public function testCanInstantiate(string $className) : void
{
$this->assertInstanceOf($className, $this->instantiator->instantiate($className));
self::assertInstanceOf($className, $this->instantiator->instantiate($className));
}

/**
Expand All @@ -64,8 +64,8 @@ public function testInstantiatesSeparateInstances(string $className) : void
$instance1 = $this->instantiator->instantiate($className);
$instance2 = $this->instantiator->instantiate($className);

$this->assertEquals($instance1, $instance2);
$this->assertNotSame($instance1, $instance2);
self::assertEquals($instance1, $instance2);
self::assertNotSame($instance1, $instance2);
}

public function testExceptionOnUnSerializationException() : void
Expand Down Expand Up @@ -104,7 +104,7 @@ public function testInstancesAreNotCloned() : void

$instance2 = $this->instantiator->instantiate(__NAMESPACE__ . '\\' . $className);

$this->assertObjectNotHasAttribute('foo', $instance2);
self::assertObjectNotHasAttribute('foo', $instance2);
}

/**
Expand Down

0 comments on commit 724e1e7

Please sign in to comment.