The
resolve
function resolves a given class or interface name to an instance using the service container:<?php $api = resolve('HelpSpot\API');
<?php $this->withoutVite();
$instance = $this->withVite();
$this->assertSame($handler, resolve(Vite::class));
$this->assertSame($this, $instance);
}
<?php $this->withoutMix();
$instance = $this->withMix();
$this->assertSame($handler, resolve(Mix::class));
$this->assertSame($this, $instance);
}
<?php public function testValidationPassesWhenPassingCorrectEnum()
{
$v = new Validator(
resolve('translator'),
[
'status' => 'pending',
'int_status' => 1,
<?php public function testValidationPassesWhenPassingInstanceOfEnum()
{
$v = new Validator(
resolve('translator'),
[
'status' => StringStatus::done,
],
<?php public function testValidationPassesWhenPassingInstanceOfPureEnum()
{
$v = new Validator(
resolve('translator'),
[
'status' => PureEnum::one,
],
<?php public function testValidationFailsWhenProvidingNoExistingCases()
{
$v = new Validator(
resolve('translator'),
[
'status' => 'finished',
],
<?php public function testValidationPassesForAllCasesUntilEitherOnlyOrExceptIsPassed()
{
$v = new Validator(
resolve('translator'),
[
'status_1' => PureEnum::one,
'status_2' => PureEnum::two,
<?php bool $expected
) {
$v = new Validator(
resolve('translator'),
[
'status' => $enum,
],
<?php bool $expected
) {
$v = new Validator(
resolve('translator'),
[
'status' => $enum,
],
<?php public function testOnlyHasHigherOrderThanExcept()
{
$v = new Validator(
resolve('translator'),
[
'status' => PureEnum::one,
],
<?php public function testValidationFailsWhenProvidingDifferentType()
{
$v = new Validator(
resolve('translator'),
[
'status' => 10,
],
<?php public function testValidationPassesWhenProvidingDifferentTypeThatIsCastableToTheEnumType()
{
$v = new Validator(
resolve('translator'),
[
'status' => '1',
],
<?php public function testValidationFailsWhenProvidingNull()
{
$v = new Validator(
resolve('translator'),
[
'status' => null,
],
<?php public function testValidationPassesWhenProvidingNullButTheFieldIsNullable()
{
$v = new Validator(
resolve('translator'),
[
'status' => null,
],
<?php public function testValidationFailsOnPureEnum()
{
$v = new Validator(
resolve('translator'),
[
'status' => 'one',
],