Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Codeception Reflection Asserts

This asserts module is prepared to test code generation tools to assert existing of classes, methods, properties.

Installation and configuration

Use composer to install:

composer require maslosoft/codeception-reflection-asserts --dev

Add to tests/unit.suite.yml:

actor: UnitTestersuite_namespace: Tests\Unitmodules:
enabled:
- \Maslosoft\Codeception\Module\ReflectionAsserts

Usage

Using in cest/cept

$I->assertMethodExists(Foo::class, 'bar');
$I->assertMethodIsPublic(Foo::class, 'bar');
$I->assertPropertyExists(Foo::class, 'baz');
$I->assertPropertyIsPrivate(Foo::class, 'baz');
$I->assertMethodHasParameter(
Foo::class,
'bar',
'limit',
type: 'int',
allowsNull: false,
optional: true
);

Using in unit test

<?php...class SomeTest extends Unit
{
useMaslosoft\Testing\Reflection\ReflectionAssertionsTrait;
functiontestMyReflection(): void
{
$this->assertClassExists(SomeService::class);
$this->assertMethodExists(SomeService::class, 'handle');
$this->assertMethodIsPublic(SomeService::class, 'handle');
$this->assertMethodHasParameter(
SomeService::class,
'handle',
'request',
type: Request::class,
allowsNull: false,
optional: false
);
$this->assertPropertyExists(SomeService::class, 'repository');
$this->assertPropertyIsPrivate(SomeService::class, 'repository');
}
}

About

Codeception Reflection Asserts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages