1
0
Fork 0
mirror of https://github.com/archtechx/helpers.git synced 2025-12-12 04:04:04 +00:00
This commit is contained in:
Samuel Štancl 2021-10-28 19:37:04 +02:00
parent 2945c59e92
commit 0d63a5b79c
12 changed files with 97 additions and 109 deletions

View file

@ -11,7 +11,7 @@
|
*/
uses(ArchTech\REPLACE\Tests\TestCase::class)->in('Pest');
uses(ArchTech\Helpers\Tests\TestCase::class)->in('Pest');
/*
|--------------------------------------------------------------------------

View file

@ -1,9 +0,0 @@
<?php
it('succeeds', function () {
expect(true)->toBeTrue();
});
it('fails', function () {
expect(false)->toBeTrue();
});

View file

@ -0,0 +1,15 @@
<?php
test("arrays containing multiple items aren't simple arrays")
->expect(is_simple_array(['foo', 'bar']))->toBeFalse()
->expect(is_simple_array([['foo'], ['bar']]))->toBeFalse();
test("arrays containing a non-array aren't simple arrays")
->expect(
is_simple_array(['foo'])
)->toBeFalse();
test("arrays containing a single array are simple arrays")
->expect(
is_simple_array([['foo', 'bar']])
)->toBeTrue();

View file

@ -0,0 +1,29 @@
<?php
it('checks for the presence of a trait', function () {
expect(uses_trait(Foo::class, FirstTrait::class))->toBeTrue();
expect(uses_trait(Foo::class, SecondTrait::class))->toBeFalse();
});
it('checks recursively', function () {
expect(uses_trait(Bar::class, FirstTrait::class))->toBeTrue(); // inherited
expect(uses_trait(Bar::class, SecondTrait::class))->toBeTrue();
});
it('accepts both objects and classes', function () {
expect(uses_trait(new Foo, FirstTrait::class))->toBeTrue();
expect(uses_trait(new Foo, SecondTrait::class))->toBeFalse();
});
trait FirstTrait {}
trait SecondTrait {}
class Foo
{
use FirstTrait;
}
class Bar extends Foo
{
use SecondTrait;
}

View file

@ -0,0 +1,11 @@
<?php
it('returns the inner array if a simple array is supplied')
->expect(
variadic_array([['foo', 'bar']])
)->toBe(['foo', 'bar']);
it('returns the array if a non-simple array is supplied')
->expect(
variadic_array(['foo', 'bar'])
)->toBe(['foo', 'bar']);

View file

@ -1,16 +1,9 @@
<?php
namespace ArchTech\REPLACE\Tests;
namespace ArchTech\Helpers\Tests;
use Orchestra\Testbench\TestCase as TestbenchTestCase;
use ArchTech\REPLACE\REPLACEServiceProvider;
class TestCase extends TestbenchTestCase
{
protected function getPackageProviders($app)
{
return [
REPLACEServiceProvider::class,
];
}
}