mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
feat(expect): updates test suite to use expectation api
This commit is contained in:
@ -7,5 +7,5 @@ it('gets file name from called file', function () {
|
||||
return Backtrace::file();
|
||||
};
|
||||
|
||||
assertEquals(__FILE__, $a());
|
||||
expect($a())->toBe(__FILE__);
|
||||
});
|
||||
|
||||
@ -15,32 +15,32 @@ it('exists')
|
||||
|
||||
it('gets an instance', function () {
|
||||
$this->container->add(Container::class, $this->container);
|
||||
assertSame($this->container, $this->container->get(Container::class));
|
||||
expect($this->container->get(Container::class))->toBe($this->container);
|
||||
});
|
||||
|
||||
test('autowire', function () {
|
||||
assertInstanceOf(Container::class, $this->container->get(Container::class));
|
||||
expect($this->container->get(Container::class))->toBeInstanceOf(Container::class);
|
||||
});
|
||||
|
||||
it('creates an instance and resolves parameters', function () {
|
||||
$this->container->add(Container::class, $this->container);
|
||||
$instance = $this->container->get(ClassWithDependency::class);
|
||||
|
||||
assertInstanceOf(ClassWithDependency::class, $instance);
|
||||
expect($instance)->toBeInstanceOf(ClassWithDependency::class);
|
||||
});
|
||||
|
||||
it('creates an instance and resolves also sub parameters', function () {
|
||||
$this->container->add(Container::class, $this->container);
|
||||
$instance = $this->container->get(ClassWithSubDependency::class);
|
||||
|
||||
assertInstanceOf(ClassWithSubDependency::class, $instance);
|
||||
expect($instance)->toBeInstanceOf(ClassWithSubDependency::class);
|
||||
});
|
||||
|
||||
it('can resolve builtin value types', function () {
|
||||
$this->container->add('rootPath', getcwd());
|
||||
|
||||
$instance = $this->container->get(TestSuite::class);
|
||||
assertInstanceOf(TestSuite::class, $instance);
|
||||
expect($instance)->toBeInstanceOf(TestSuite::class);
|
||||
});
|
||||
|
||||
it('cannot resolve a parameter without type', function () {
|
||||
|
||||
@ -3,9 +3,10 @@
|
||||
use Pest\Support\Reflection;
|
||||
|
||||
it('gets file name from closure', function () {
|
||||
$fileName = Reflection::getFileNameFromClosure(function () {});
|
||||
$fileName = Reflection::getFileNameFromClosure(function () {
|
||||
});
|
||||
|
||||
assertEquals(__FILE__, $fileName);
|
||||
expect($fileName)->toBe(__FILE__);
|
||||
});
|
||||
|
||||
it('gets property values', function () {
|
||||
@ -15,5 +16,5 @@ it('gets property values', function () {
|
||||
|
||||
$value = Reflection::getPropertyValue($class, 'foo');
|
||||
|
||||
assertEquals('bar', $value);
|
||||
expect($value)->toBe('bar');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user