Skip to content

Commit

Permalink
Use "::class" in the Pimple test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Mar 14, 2024
1 parent fae9421 commit 3819b14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
13 changes: 7 additions & 6 deletions tests/PimpleCopy/Pimple/PimpleServiceProviderInterfaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

use PHPUnit\Framework\TestCase;
use PimpleCopy\Pimple\Container;
use tests\PimpleCopy\Pimple\Fixtures\Service;

/**
* @author Dominik Zogg <[email protected]>
Expand All @@ -44,13 +45,13 @@ public function testProvider()
$pimple_service_provider->register($pimple);

$this->assertEquals('value', $pimple['param']);
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $pimple['service']);
$this->assertInstanceOf(Service::class, $pimple['service']);

$service_one = $pimple['factory'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_one);
$this->assertInstanceOf(Service::class, $service_one);

$service_two = $pimple['factory'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_two);
$this->assertInstanceOf(Service::class, $service_two);

$this->assertNotSame($service_one, $service_two);
}
Expand All @@ -66,13 +67,13 @@ public function testProviderWithRegisterMethod()
$this->assertEquals('value', $pimple['param']);
$this->assertEquals('anotherValue', $pimple['anotherParameter']);

$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $pimple['service']);
$this->assertInstanceOf(Service::class, $pimple['service']);

$service_one = $pimple['factory'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_one);
$this->assertInstanceOf(Service::class, $service_one);

$service_two = $pimple['factory'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_two);
$this->assertInstanceOf(Service::class, $service_two);

$this->assertNotSame($service_one, $service_two);
}
Expand Down
27 changes: 15 additions & 12 deletions tests/PimpleCopy/Pimple/PimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
use PHPUnit\Framework\TestCase;
use PimpleCopy\Pimple\Container;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use tests\PimpleCopy\Pimple\Fixtures\Service;
use PimpleCopy\Pimple\ServiceProviderInterface;
use tests\PimpleCopy\Pimple\Fixtures\NonInvokable;

/**
* @author Igor Wiedler <[email protected]>
Expand All @@ -54,7 +57,7 @@ public function testWithClosure()
return new Fixtures\Service();
};

$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $pimple['service']);
$this->assertInstanceOf(Service::class, $pimple['service']);
}

public function testServicesShouldBeDifferent()
Expand All @@ -65,10 +68,10 @@ public function testServicesShouldBeDifferent()
});

$service_one = $pimple['service'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_one);
$this->assertInstanceOf(Service::class, $service_one);

$service_two = $pimple['service'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_two);
$this->assertInstanceOf(Service::class, $service_two);

$this->assertNotSame($service_one, $service_two);
}
Expand Down Expand Up @@ -149,10 +152,10 @@ public function testShare($service)
$pimple['shared_service'] = $service;

$service_one = $pimple['shared_service'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_one);
$this->assertInstanceOf(Service::class, $service_one);

$service_two = $pimple['shared_service'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_two);
$this->assertInstanceOf(Service::class, $service_two);

$this->assertSame($service_one, $service_two);
}
Expand Down Expand Up @@ -194,7 +197,7 @@ public function testRawHonorsNullValues()
public function testFluentRegister()
{
$pimple = new Container();
$serviceProviderMock = m::mock('PimpleCopy\Pimple\ServiceProviderInterface');
$serviceProviderMock = m::mock(ServiceProviderInterface::class);
$serviceProviderMock->shouldReceive('register');

$this->assertSame($pimple, $pimple->register($serviceProviderMock));
Expand Down Expand Up @@ -224,17 +227,17 @@ public function testExtend($service)

$pimple->extend('shared_service', $service);
$service_one = $pimple['shared_service'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_one);
$this->assertInstanceOf(Service::class, $service_one);
$service_two = $pimple['shared_service'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_two);
$this->assertInstanceOf(Service::class, $service_two);
$this->assertSame($service_one, $service_two);
$this->assertSame($service_one->value, $service_two->value);

$pimple->extend('factory_service', $service);
$service_one = $pimple['factory_service'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_one);
$this->assertInstanceOf(Service::class, $service_one);
$service_two = $pimple['factory_service'];
$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $service_two);
$this->assertInstanceOf(Service::class, $service_two);
$this->assertNotSame($service_one, $service_two);
$this->assertNotSame($service_one->value, $service_two->value);
}
Expand Down Expand Up @@ -288,7 +291,7 @@ public function settingAnInvokableObjectShouldTreatItAsFactory()
$pimple = new Container();
$pimple['invokable'] = new Fixtures\Invokable();

$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\Service', $pimple['invokable']);
$this->assertInstanceOf(Service::class, $pimple['invokable']);
}

/** @test */
Expand All @@ -297,7 +300,7 @@ public function settingNonInvokableObjectShouldTreatItAsParameter()
$pimple = new Container();
$pimple['non_invokable'] = new Fixtures\NonInvokable();

$this->assertInstanceOf('tests\PimpleCopy\Pimple\Fixtures\NonInvokable', $pimple['non_invokable']);
$this->assertInstanceOf(NonInvokable::class, $pimple['non_invokable']);
}

/**
Expand Down

0 comments on commit 3819b14

Please sign in to comment.