prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
\InvokeSerializedClosureCommand;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\Artisan;
use Laravel\SerializableClosure\SerializableClosure;
use Orchestra\Testbench\TestCase;
use RuntimeException;
use Symfony\Component\Console\Output\BufferedOutput;
class CustomParameterException extends Runt... | mmand);
}
public function testItCanInvokeSerializedClosureFromArgument()
{
// Create a simple closure and serialize it
$closure = fn () => 'Hello, World!';
$serialized = serialize(new SerializableClosure($closure));
| mParam}");
}
}
class InvokeSerializedClosureCommandTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->app[Kernel::class]->registerCommand(new InvokeSerializedClosureCo | {
"filepath": "tests/Integration/Concurrency/Console/InvokeSerializedClosureCommandTest.php",
"language": "php",
"file_size": 4717,
"cut_index": 614,
"middle_length": 229
} |
te\Tests\Integration\Support;
use Illuminate\Auth\AuthManager;
use Illuminate\Foundation\Application;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Facade;
use Orchestra\Testbench\TestCase;
use ReflectionClass;
class FacadesTest extends TestCase
{
protected... | ('auth');
$this->assertTrue(isset($_SERVER['__laravel.authResolved']));
}
public function testFacadeResolvedCanResolveCallbackAfterAccessRootHasBeenResolved()
{
$this->app->make('auth');
$this->assertFalse(isset($_SER | Auth::resolved(function (AuthManager $auth, Application $app) {
$_SERVER['__laravel.authResolved'] = true;
});
$this->assertFalse(isset($_SERVER['__laravel.authResolved']));
$this->app->make | {
"filepath": "tests/Integration/Support/FacadesTest.php",
"language": "php",
"file_size": 1751,
"cut_index": 537,
"middle_length": 229
} |
uldReceive('exists')
->once()
->andReturn(false);
$this->artisan('env:encrypt', ['--cipher' => 'invalid'])
->expectsQuestion('What encryption key would you like to use?', 'generate')
->expectsOutputToContain('Unsupported cipher')
->assertExitCode(1);
... | ')
->assertExitCode(1);
}
public function testItGeneratesTheCorrectFileWhenUsingEnvironment(): void
{
$this->filesystem->shouldReceive('exists')
->once()
->andReturn(true)
->shouldReceive | ->shouldReceive('exists')
->once()
->andReturn(false);
$this->artisan('env:encrypt', ['--cipher' => 'aes-128-cbc', '--key' => 'invalid'])
->expectsOutputToContain('incorrect key length | {
"filepath": "tests/Integration/Console/EnvironmentEncryptCommandTest.php",
"language": "php",
"file_size": 17847,
"cut_index": 1331,
"middle_length": 229
} |
\Contracts\Console\Kernel;
use Orchestra\Testbench\TestCase;
use function Laravel\Prompts\text;
class PromptsValidationTest extends TestCase
{
protected function defineEnvironment($app)
{
$app[Kernel::class]->registerCommand(new DummyPromptsValidationCommand());
$app[Kernel::class]->registerCo... | lass)
->expectsQuestion('What is your name?', '')
->expectsOutputToContain('Required!');
}
public function testValidationWithLaravelRulesAndNoCustomization(): void
{
$this
->artisan(DummyPromptsWithL | isterCommand(new DummyPromptsWithLaravelRulesCommandWithInlineMessagesAndAttributesCommand());
}
public function testValidationForPrompts(): void
{
$this
->artisan(DummyPromptsValidationCommand::c | {
"filepath": "tests/Integration/Console/PromptsValidationTest.php",
"language": "php",
"file_size": 3332,
"cut_index": 614,
"middle_length": 229
} |
<?php
namespace Illuminate\Tests\Integration\Support;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks;
use Illuminate\Support\Facades\Route;
use Orchestra\Testbench\Attributes\WithCo... | TestSyncJob);
})->middleware(InvokeDeferredCallbacks::class);
$this->get('/test');
$this->assertTrue($executed);
}
}
class TestSyncJob implements ShouldQueue
{
use Dispatchable, Queueable;
public function handle(): | _sync_job()
{
$executed = false;
Route::get('/test', function () use (&$executed) {
defer(function () use (&$executed) {
$executed = true;
});
dispatch(new | {
"filepath": "tests/Integration/Support/DeferredCallbackTest.php",
"language": "php",
"file_size": 1027,
"cut_index": 512,
"middle_length": 229
} |
ate\Support\Str;
use Orchestra\Testbench\TestCase;
class PluralizerPortugueseTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
Pluralizer::useLanguage('portuguese');
}
protected function tearDown(): void
{
Pluralizer::useLanguage('english');
... | venda', Str::singular('vendas'));
$this->assertSame('usuário', Str::singular('usuários'));
$this->assertSame('comissão', Str::singular('comissões'));
}
public function testIrregulars()
{
$this->assertSame('males', Str:: | os'));
$this->assertSame('chafariz', Str::singular('chafarizes'));
$this->assertSame('colher', Str::singular('colheres'));
$this->assertSame('modelo', Str::singular('modelos'));
$this->assertSame(' | {
"filepath": "tests/Integration/Support/PluralizerPortugueseTest.php",
"language": "php",
"file_size": 3751,
"cut_index": 614,
"middle_length": 229
} |
le;
use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
class GeneratorCommandTest extends TestCase
{
use InteractsWithPublishedFiles;
protected $files = [
'app/Console/Commands/FooCommand.php',
'resour... | 'app/Console/Commands/FooCommand.php');
}
public function testItChopsPhpExtensionFromMakeViewCommands(): void
{
$this->artisan('make:view', ['name' => 'foo.php'])
->assertExitCode(0);
$this->assertFilenameExists(' | ' => 'FooCommand.php'])
->assertExitCode(0);
$this->assertFilenameExists('app/Console/Commands/FooCommand.php');
$this->assertFileContains([
'class FooCommand extends Command',
], | {
"filepath": "tests/Integration/Console/GeneratorCommandTest.php",
"language": "php",
"file_size": 2059,
"cut_index": 563,
"middle_length": 229
} |
inate\Foundation\Testing\Concerns\InteractsWithRedis;
use Illuminate\Redis\RedisManager;
use Illuminate\Support\Env;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Redis;
#[RequiresPhpExtension('red... | ted function tearDown(): void
{
$this->tearDownRedis();
parent::tearDown();
}
#[DataProvider('phpRedisBackoffAlgorithmsProvider')]
public function testPhpRedisBackoffAlgorithmParsing($friendlyAlgorithmName, $expectedAlgori | t = $this->redis['phpredis']->connection()->client();
if (! $client instanceof Redis) {
$this->markTestSkipped('Backoff option is only supported with phpredis in non-cluster mode');
}
}
protec | {
"filepath": "tests/Integration/Cache/PhpRedisBackoffTest.php",
"language": "php",
"file_size": 4055,
"cut_index": 614,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Cache;
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
use Illuminate\Support\Facades\Cache;
use Illuminate\Tests\Integration\Cache\Fixtures\Unserializable;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
class Psr6RedisTest extends Tes... | ationFails($redisClient): void
{
$this->app['config']['cache.default'] = 'redis';
$this->app['config']['database.redis.client'] = $redisClient;
$cache = $this->app->make('cache.psr6');
$item = $cache->getItem('foo');
| ->beforeApplicationDestroyed(function () {
$this->tearDownRedis();
});
parent::setUp();
}
#[DataProvider('redisClientDataProvider')]
public function testTransactionIsNotOpenedWhenSerializ | {
"filepath": "tests/Integration/Cache/Psr6RedisTest.php",
"language": "php",
"file_size": 1354,
"cut_index": 524,
"middle_length": 229
} |
bon;
use Mockery as m;
use Orchestra\Testbench\TestCase;
use RuntimeException;
class ThrottlesExceptionsTest extends TestCase
{
public function testCircuitIsOpenedForJobErrors()
{
$this->assertJobWasReleasedImmediately(CircuitBreakerTestJob::class);
$this->assertJobWasReleasedImmediately(Circui... | lic function testCircuitResetsAfterSuccess()
{
$this->assertJobWasReleasedImmediately(CircuitBreakerTestJob::class);
$this->assertJobRanSuccessfully(CircuitBreakerSuccessfulJob::class);
$this->assertJobWasReleasedImmediately(Cir | ssertJobRanSuccessfully(CircuitBreakerSuccessfulJob::class);
$this->assertJobRanSuccessfully(CircuitBreakerSuccessfulJob::class);
$this->assertJobRanSuccessfully(CircuitBreakerSuccessfulJob::class);
}
pub | {
"filepath": "tests/Integration/Queue/ThrottlesExceptionsTest.php",
"language": "php",
"file_size": 15351,
"cut_index": 921,
"middle_length": 229
} |
NotFoundException;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Queue;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Te... | $this->runQueueWorkerCommand(['--once' => true]);
Bus::assertDispatched(UniqueTestJob::class);
$this->assertFalse(
$this->app->get(Cache::class)->lock($this->getLockKey(UniqueTestJob::class), 10)->get()
);
| {
parent::defineEnvironment($app);
$app['config']->set('cache.default', 'database');
}
public function testUniqueJobsAreNotDispatched()
{
Bus::fake();
UniqueTestJob::dispatch();
| {
"filepath": "tests/Integration/Queue/UniqueJobTest.php",
"language": "php",
"file_size": 11501,
"cut_index": 921,
"middle_length": 229
} |
minate\Database\UniqueConstraintViolationException;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Queue\Worker;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Exceptions;
use Illuminate\Support\Faca... | false;
});
parent::setUp();
$this->markTestSkippedWhenUsingSyncQueueDriver();
}
public function testRunningOneJob()
{
Queue::push(new FirstJob);
Queue::push(new SecondJob);
$this->artisan('que | use DatabaseMigrations;
protected function setUp(): void
{
$this->beforeApplicationDestroyed(function () {
FirstJob::$ran = false;
SecondJob::$ran = false;
ThirdJob::$ran = | {
"filepath": "tests/Integration/Queue/WorkCommandTest.php",
"language": "php",
"file_size": 8648,
"cut_index": 716,
"middle_length": 229
} |
te\Tests\Integration\Auth;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresPhpExtension('pdo_mysql')]
class ApiAuthenticationWithEloquentTest extends TestCase
{
... | ->set('database.connections.testbench', [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'username' => 'root',
'password' => 'invalid-credentials',
'database' => 'forge',
| 'driver' => 'token',
'provider' => 'users',
'hash' => false,
]);
// Database configuration
$app['config']->set('database.default', 'testbench');
$app['config'] | {
"filepath": "tests/Integration/Auth/ApiAuthenticationWithEloquentTest.php",
"language": "php",
"file_size": 1771,
"cut_index": 537,
"middle_length": 229
} |
ate\Database\Schema\Blueprint;
use Illuminate\Events\Dispatcher;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use Illuminate\Support\Testing\Fakes\EventFake;
use Illuminate... | 'hashing.driver' => 'bcrypt',
]);
}
protected function defineRoutes($router)
{
$router->get('basic', function () {
return $this->app['auth']->guard()->basic()
?: $this->app['auth']->user()->t | ss AuthenticationTest extends TestCase
{
use RefreshDatabase;
protected function defineEnvironment($app)
{
$app['config']->set([
'auth.providers.users.model' => AuthenticationTestUser::class,
| {
"filepath": "tests/Integration/Auth/AuthenticationTest.php",
"language": "php",
"file_size": 11595,
"cut_index": 921,
"middle_length": 229
} |
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser;
use Orchestra\Testbench\Attribute... | ment($app)
{
$app['config']->set('app.key', Str::random(32));
$app['config']->set('auth.providers.users.model', AuthenticationTestUser::class);
}
protected function defineRoutes($router)
{
$router->get('custom/passw | eshDatabase;
protected function tearDown(): void
{
ResetPassword::$createUrlCallback = null;
ResetPassword::$toMailCallback = null;
parent::tearDown();
}
protected function defineEnviron | {
"filepath": "tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php",
"language": "php",
"file_size": 4089,
"cut_index": 614,
"middle_length": 229
} |
namespace Illuminate\Tests\Integration\Auth;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;
#[WithMigratio... | );
})->middleware(['web', 'auth']);
}
public function testItRehashThePasswordUsingLogoutOtherDevices()
{
$this->withoutExceptionHandling();
$user = UserFactory::new()->create();
$password = $user->password;
| se;
protected function defineRoutes($router)
{
$router->post('logout', function (Request $request) {
auth()->logoutOtherDevices($request->input('password'));
return response()->noContent( | {
"filepath": "tests/Integration/Auth/RehashOnLogoutOtherDevicesTest.php",
"language": "php",
"file_size": 1230,
"cut_index": 518,
"middle_length": 229
} |
el;
use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Http\Middleware\PrefersJsonResponses;
use Illuminate\Http\Response;
use Illuminate\Session\Middleware\StartSession;
use Orchestra\Testbench\TestCase;
class RequirePasswordTest extends TestCase
{
public fun... | ing) RequirePassword::using(passwordTimeoutSeconds: 100);
$this->assertSame('Illuminate\Auth\Middleware\RequirePassword:,100', $signature);
}
public function testUserSeesTheWantedPageIfThePasswordWasRecentlyConfirmed()
{
$this- | rd:route.name', $signature);
$signature = (string) RequirePassword::using('route.name', 100);
$this->assertSame('Illuminate\Auth\Middleware\RequirePassword:route.name,100', $signature);
$signature = (str | {
"filepath": "tests/Integration/Auth/Middleware/RequirePasswordTest.php",
"language": "php",
"file_size": 6246,
"cut_index": 716,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Validation;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Orchestra\Testbench\TestCase;
class RequestValidationTest extends TestCase
{
public function testValidateMacro(): void
{
$request = Request::create('/', 'GET', ['name' => 'Tayl... | ithBagMacro(): void
{
$request = Request::create('/', 'GET', ['name' => 'Taylor']);
$validated = $request->validateWithBag('some_bag', ['name' => 'string']);
$this->assertSame(['name' => 'Taylor'], $validated);
}
publ | void
{
$this->expectException(ValidationException::class);
$request = Request::create('/', 'GET', ['name' => null]);
$request->validate(['name' => 'string']);
}
public function testValidateW | {
"filepath": "tests/Integration/Validation/RequestValidationTest.php",
"language": "php",
"file_size": 1379,
"cut_index": 524,
"middle_length": 229
} |
\File;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\TestWith;
class FileValidationTest extends TestCase
{
#[TestWith(['0'])]
#[TestWith(['.'])]
#[TestWith(['*'])]
#[TestWith(['__asterisk__'])]
public function test_it_can_validate_attribute_as_array(string $attribute): void
... | ['*'])]
#[TestWith(['__asterisk__'])]
public function test_it_can_validate_attribute_as_array_when_validation_should_fails(string $attribute): void
{
$file = UploadedFile::fake()->create('laravel.php', 1, 'image/php');
$validat | ],
], [
'files.*' => ['required', File::types(['image/png', 'image/jpeg'])],
]);
$this->assertTrue($validator->passes());
}
#[TestWith(['0'])]
#[TestWith(['.'])]
#[TestWith( | {
"filepath": "tests/Integration/Validation/Rules/FileValidationTest.php",
"language": "php",
"file_size": 7197,
"cut_index": 716,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Validation\Rules;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rules\Password;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\TestWith;
class PasswordValidationTest extends TestCase
{
#[TestWith(['0'])]
#[TestWith(['.'])]
#[TestW... | estWith(['0'])]
#[TestWith(['.'])]
#[TestWith(['*'])]
#[TestWith(['__asterisk__'])]
public function test_it_can_validate_attribute_as_array_when_validation_should_fails(string $attribute): void
{
$validator = Validator::make([
| swords' => [
$attribute => 'secret',
],
], [
'passwords.*' => ['required', Password::default()->min(6)],
]);
$this->assertTrue($validator->passes());
}
#[T | {
"filepath": "tests/Integration/Validation/Rules/PasswordValidationTest.php",
"language": "php",
"file_size": 1438,
"cut_index": 524,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Validation\Rules;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rules\Email;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\TestWith;
class EmailValidationTest extends TestCase
{
#[TestWith(['0'])]
#[TestWith(['.'])]
#[TestWith(['... | #[TestWith(['0'])]
#[TestWith(['.'])]
#[TestWith(['*'])]
#[TestWith(['__asterisk__'])]
public function test_it_can_validate_attribute_as_array_when_validation_should_fails(string $attribute): void
{
$validator = Validator::mak | > [
$attribute => 'taylor@laravel.com',
],
], [
'emails.*' => ['required', Email::default()->rfcCompliant()],
]);
$this->assertTrue($validator->passes());
}
| {
"filepath": "tests/Integration/Validation/Rules/EmailValidationTest.php",
"language": "php",
"file_size": 1454,
"cut_index": 524,
"middle_length": 229
} |
te\Tests\Integration\Cache;
use Illuminate\Cache\Events\CacheFailedOver;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Event;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;
#[WithConfig('cache.default', 'failover')]
#[WithConfig('cache.stores.array.serialize', ... | 'cache.stores.failover.stores' => ['failing_array', 'array'],
]);
Event::fake();
Cache::put('irrelevant', new CantSerialize());
Event::assertDispatched(CacheFailedOver::class, function (CacheFailedOver $event) {
| public function testFailoverCacheDispatchesEventOnlyOnce()
{
config([
'cache.stores.failing_array' => array_merge(config('cache.stores.array'), ['serialize' => true]),
]);
config([
| {
"filepath": "tests/Integration/Cache/FailoverStoreTest.php",
"language": "php",
"file_size": 1904,
"cut_index": 537,
"middle_length": 229
} |
ion;
use Illuminate\Support\Facades\Cache;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresPhpExtension('memcached')]
class MemcachedCacheLockTestCase extends MemcachedIntegrationTestCase
{
public function testMemcachedLocksCanBeAcquiredAndReleased()
{
Cache::store('memcached')->lock('... | ('memcached')->lock('foo')->forceRelease();
}
public function testMemcachedLocksCanBlockForSeconds()
{
Cache::store('memcached')->lock('foo')->forceRelease();
$this->assertSame('taylor', Cache::store('memcached')->lock('foo', 1 | e::store('memcached')->lock('foo')->forceRelease();
$this->assertTrue(Cache::store('memcached')->lock('foo', 10)->get());
$this->assertFalse(Cache::store('memcached')->lock('foo', 10)->get());
Cache::store | {
"filepath": "tests/Integration/Cache/MemcachedCacheLockTestCase.php",
"language": "php",
"file_size": 4359,
"cut_index": 614,
"middle_length": 229
} |
;
use Illuminate\Support\Facades\Cache;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresPhpExtension('memcached')]
class MemcachedTaggedCacheTestCase extends MemcachedIntegrationTestCase
{
public function testMemcachedCanStoreAndRetrieveTaggedCacheItems()
{
$store = Cache::store('memc... | '])->put('Anne', 'qux');
$this->assertSame('baz', $store->tags(['people', 'artists'])->get('John'));
$this->assertSame('qux', $store->tags(['people', 'authors'])->get('Anne'));
$store->tags('authors')->flush();
$this->asse | (['people', 'artists'])->get('John'));
$this->assertSame('bar', $store->tags(['people', 'authors'])->get('Anne'));
$store->tags(['people', 'artists'])->put('John', 'baz');
$store->tags(['people', 'authors | {
"filepath": "tests/Integration/Cache/MemcachedTaggedCacheTestCase.php",
"language": "php",
"file_size": 2786,
"cut_index": 563,
"middle_length": 229
} |
upport\Facades\Cache;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;
#[WithConfig('cache.default', 'null')]
#[WithConfig('cache.stores.null', ['driver' => 'null'])]
class NoLockTest extends TestCase
{
public function testLocksCanAlwaysBeAcquiredAndReleased()
{
Cache::l... | ->release());
}
public function testLocksCanBlockForSeconds()
{
Cache::lock('foo')->forceRelease();
$this->assertSame('taylor', Cache::lock('foo', 10)->block(1, function () {
return 'taylor';
}));
C | e($lock->release());
$this->assertTrue($lock | {
"filepath": "tests/Integration/Cache/NoLockTest.php",
"language": "php",
"file_size": 994,
"cut_index": 582,
"middle_length": 52
} |
atabase\Eloquent\Collection;
use Illuminate\Queue\SerializesModels;
class TypedPropertyTestClass
{
use SerializesModels;
public ModelSerializationTestUser $user;
public ModelSerializationTestUser $uninitializedUser;
protected int $id;
private array $names;
public function __construct(Model... |
}
/**
* @return array
*/
public function getNames()
{
return $this->names;
}
}
class TypedPropertyCollectionTestClass
{
use SerializesModels;
public Collection $users;
public function __construct(Colle | lic function getId()
{
return $this->id; | {
"filepath": "tests/Integration/Queue/typed-properties.php",
"language": "php",
"file_size": 949,
"cut_index": 582,
"middle_length": 52
} |
Middleware;
use Illuminate\Encryption\Encrypter;
use Illuminate\Http\Request;
use Orchestra\Testbench\TestCase;
class PreventRequestForgeryExceptTest extends TestCase
{
private $stub;
private $request;
protected function setUp(): void
{
parent::setUp();
PreventRequestForgeryExceptStu... | ngExcept(['/bar/foo']);
}
public function testPathsCanBeGloballyIgnored()
{
$this->request = Request::create('http://example.com/globally/ignored', 'POST');
$this->assertMatchingExcept(['globally/ignored']);
}
public f | te('http://example.com/foo/bar', 'POST');
}
public function testItCanExceptPaths()
{
$this->assertMatchingExcept(['/foo/bar']);
$this->assertMatchingExcept(['foo/bar']);
$this->assertNonMatchi | {
"filepath": "tests/Integration/Http/Middleware/PreventRequestForgeryExceptTest.php",
"language": "php",
"file_size": 2174,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Integration\Http\Resources\Json;
use Illuminate\Foundation\Auth\User;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Fluent;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
class ResourceCollectionTest extends TestCa... | new Fluent(['id' => 2]),
new Fluent(['id' => 3]),
]),
[
['id' => 1],
['id' => 2],
['id' => 3],
],
];
yield [
(n | ;
$this->assertSame($expected, $collection->toArray($request));
}
public static function toArrayDataProvider()
{
yield [
new ResourceCollection([
new Fluent(['id' => 1]),
| {
"filepath": "tests/Integration/Http/Resources/Json/ResourceCollectionTest.php",
"language": "php",
"file_size": 1759,
"cut_index": 537,
"middle_length": 229
} |
es\Profile;
use Illuminate\Tests\Integration\Http\Resources\JsonApi\Fixtures\Team;
use Illuminate\Tests\Integration\Http\Resources\JsonApi\Fixtures\User;
class JsonApiCollectionTest extends TestCase
{
public function testItCanGenerateJsonApiResponse()
{
$users = User::factory()->times(5)->create();
... | ser->email,
],
])->all()
)->assertJsonMissing(['jsonapi', 'included']);
}
public function testItCanGenerateJsonApiResponseWithSparseFieldsets()
{
$users = User::factory()->times(5)->creat | ($user) => [
'id' => (string) $user->getKey(),
'type' => 'users',
'attributes' => [
'name' => $user->name,
'email' => $u | {
"filepath": "tests/Integration/Http/Resources/JsonApi/JsonApiCollectionTest.php",
"language": "php",
"file_size": 8414,
"cut_index": 716,
"middle_length": 229
} |
Resources\JsonApi;
use Illuminate\Http\Resources\JsonApi\JsonApiRequest;
use Illuminate\Http\Resources\JsonApi\JsonApiResource;
class JsonApiRequestTest extends TestCase
{
public function testItCanResolveSparseFields()
{
$request = JsonApiRequest::create(uri: '/?'.http_build_query([
'field... | Request::create(uri: '/');
$this->assertSame([], $request->sparseFields('users'));
$this->assertSame([], $request->sparseFields('teams'));
$this->assertSame([], $request->sparseFields('posts'));
}
public function testItCan | $this->assertSame(['name'], $request->sparseFields('teams'));
$this->assertSame([], $request->sparseFields('posts'));
}
public function testItCanResolveEmptySparseFields()
{
$request = JsonApi | {
"filepath": "tests/Integration/Http/Resources/JsonApi/JsonApiRequestTest.php",
"language": "php",
"file_size": 2750,
"cut_index": 563,
"middle_length": 229
} |
'id' => (string) $user->getKey(),
'type' => 'users',
'attributes' => [
'name' => $user->name,
'email' => $user->email,
],
],
])
->assertJsonMissing(['j... | ing) $user->getKey(),
'type' => 'users',
'attributes' => [
'name' => $user->name,
],
],
])
->assertJsonMissing(['jsonapi', 'included | >getKey()}?".http_build_query(['fields' => ['users' => 'name']]))
->assertHeader('Content-type', 'application/vnd.api+json')
->assertExactJson([
'data' => [
'id' => (str | {
"filepath": "tests/Integration/Http/Resources/JsonApi/JsonApiResourceTest.php",
"language": "php",
"file_size": 30150,
"cut_index": 1331,
"middle_length": 229
} |
Resources\JsonApi;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Tests\Integration\Http\Resources\JsonApi\Fixtures\ArrayBackedJsonApiResource;
use Illuminate\Tests\Integration\Http\Resources\JsonApi\Fixtures\Post;
use Illuminate\Tests\Integration\Http\R... | stra\Testbench\TestCase
{
use LazilyRefreshDatabase;
/** {@inheritdoc} */
#[\Override]
protected function setUp(): void
{
Model::shouldBeStrict(true);
parent::setUp();
}
/** {@inheritdoc} */
#[\Override]
| ationshipResource;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Attributes\WithMigration;
#[WithMigration]
#[WithConfig('auth.providers.users.model', User::class)]
abstract class TestCase extends \Orche | {
"filepath": "tests/Integration/Http/Resources/JsonApi/TestCase.php",
"language": "php",
"file_size": 3004,
"cut_index": 563,
"middle_length": 229
} |
hp
namespace Illuminate\Tests\Integration\Http\Resources\JsonApi\Fixtures;
use Illuminate\Database\Eloquent\Attributes\UseFactory;
use Illuminate\Database\Eloquent\Attributes\UseResource;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Orchestra\Testb... | perone('author');
}
public function comments()
{
return $this->hasMany(Comment::class);
}
public function teams()
{
return $this->belongsToMany(Team::class)
->withPivot('role')
->withTimesta |
return $this->hasOne(Profile::class);
}
public function posts()
{
return $this->hasMany(Post::class);
}
public function chaperonePosts()
{
return $this->hasMany(Post::class)->cha | {
"filepath": "tests/Integration/Http/Resources/JsonApi/Fixtures/User.php",
"language": "php",
"file_size": 1085,
"cut_index": 515,
"middle_length": 229
} |
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->index();
$table->string('title');
$table->text('content');
$table->timestamps();
});
Schema::create('profiles', functi... | e) {
$table->id();
$table->foreignId('team_id');
$table->foreignId('user_id');
$table->string('role')->nullable();
$table->timestamps();
$table->index(['team_id', 'user_id']);
});
Schema::create('comments', function (Blueprint $ta | eate('teams', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->index();
$table->string('name');
$table->boolean('personal_team');
});
Schema::create('team_user', function (Blueprint $tabl | {
"filepath": "tests/Integration/Http/Resources/JsonApi/Fixtures/migrations.php",
"language": "php",
"file_size": 1186,
"cut_index": 518,
"middle_length": 229
} |
* @var \Mockery\Mock
*/
private $output;
public $subject;
protected function setUp(): void
{
parent::setUp();
$this->output = m::mock(OutputInterface::class);
$this->subject = $this->app->make('migrator');
$this->subject->setOutput($this->output);
$this... | $this->expectTask('2016_10_04_000000_modify_people_table', 'DONE');
$this->expectTask('2017_10_04_000000_add_age_to_people', 'SKIPPED');
$this->output->shouldReceive('writeln')->once();
$this->subject->run([__DIR__.'/fixtu | ction testMigrate()
{
$this->expectInfo('Running migrations.');
$this->expectTask('2014_10_12_000000_create_people_table', 'DONE');
$this->expectTask('2015_10_04_000000_modify_people_table', 'DONE');
| {
"filepath": "tests/Integration/Migration/MigratorTest.php",
"language": "php",
"file_size": 12671,
"cut_index": 921,
"middle_length": 229
} |
nate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreatePeopleIsDynamicTable extends Migration
{
public function up()
{
Schema::create('people', function (Blueprint $table) {
$table->... | ble->timestamps();
});
DB::table('people')->insert([
['email' => 'jane@example.com', 'name' => 'Jane Doe', 'password' => 'secret'],
['email' => 'john@example.com', 'name' => 'John Doe', 'password' => 'secret'],
| $table->rememberToken();
$ta | {
"filepath": "tests/Integration/Migration/pretending/2014_10_12_000000_create_people_is_dynamic_table.php",
"language": "php",
"file_size": 853,
"cut_index": 529,
"middle_length": 52
} |
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreatePeopleNonDynamicTable extends Migration
{
public function up()
{
Schema::create('people', function (Blueprint $table) {
... | ble->timestamps();
});
DB::table('people')->insert([
['email' => 'jane@example.com', 'name' => 'Jane Doe', 'password' => 'secret'],
['email' => 'john@example.com', 'name' => 'John Doe', 'password' => 'secret'],
| $ta | {
"filepath": "tests/Integration/Migration/pretending/2014_10_12_000000_create_people_non_dynamic_table.php",
"language": "php",
"file_size": 803,
"cut_index": 517,
"middle_length": 14
} |
hp
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class DynamicContentIsShown extends Migration
{
public function up()
{
Schema::create('blogs', function (Blueprint $table) {
... | */
$tablesList = DB::withoutPretending(function () {
return DB::table('people')->get();
});
$tablesList->each(function ($person, $key) {
DB::table('blogs')->where('blog_id', '=', $person->blog_id)->insert([
| 'www.janedoe.com'],
['url' => 'www.johndoe.com'],
]);
DB::statement("ALTER TABLE 'pseudo_table_name' MODIFY 'column_name' VARCHAR(191)");
/** @var \Illuminate\Support\Collection $tablesList | {
"filepath": "tests/Integration/Migration/pretending/2023_10_17_000000_dynamic_content_is_shown.php",
"language": "php",
"file_size": 1120,
"cut_index": 515,
"middle_length": 229
} |
tabase\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class DynamicContentNotShown extends Migration
{
public function up()
{
Schema::create('blogs', function (Blueprint $table) {
$table->increments('id');
$table->string('url')->nulla... | _table_name' MODIFY 'column_name' VARCHAR(191)");
DB::table('people')->get()->each(function ($person, $key) {
DB::table('blogs')->where('blog_id', '=', $person->blog_id)->insert([
'id' => $key + 1,
'name | ]);
DB::statement("ALTER TABLE 'pseudo | {
"filepath": "tests/Integration/Migration/pretending/2023_10_17_000000_dynamic_content_not_shown.php",
"language": "php",
"file_size": 955,
"cut_index": 582,
"middle_length": 52
} |
pace Illuminate\Tests\Integration\Redis;
use Illuminate\Redis\Connections\PredisConnection;
use Illuminate\Redis\Events\CommandExecuted;
use Illuminate\Support\Facades\Event;
use Mockery as m;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;
use Predis\Client;
use Predis\Command\Argumen... | $command = 'ftSearch';
$parameters = ['test', '*', (new SearchArguments())->dialect('3')->withScores()];
$predis = new PredisConnection($client = m::mock(Client::class));
$predis->setEventDispatcher($event);
$client-> | )
{
if (! class_exists(SearchArguments::class)) {
return $this->markTestSkipped('Skipped tests on predis/predis dependency without '.SearchArguments::class);
}
$event = Event::fake();
| {
"filepath": "tests/Integration/Redis/PredisConnectionTest.php",
"language": "php",
"file_size": 1450,
"cut_index": 524,
"middle_length": 229
} |
tra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;
class CloudTest extends TestCase
{
#[WithConfig('database.connections.pgsql', ['host' => 'test-pooler.pg.laravel.cloud', 'username' => 'test-username', 'password' => 'test-password'])]
public function test_it_can_resolve_core_container_alia... | FIG'] = json_encode(
[
[
'disk' => 'test-disk',
'access_key_id' => 'test-access-key-id',
'access_key_secret' => 'test-access-key-secret',
'bucket' = | me',
'password' => 'test-password',
], $this->app['config']->get('database.connections.pgsql-unpooled'));
}
public function test_it_can_configure_disks()
{
$_SERVER['LARAVEL_CLOUD_DISK_CON | {
"filepath": "tests/Integration/Foundation/CloudTest.php",
"language": "php",
"file_size": 3591,
"cut_index": 614,
"middle_length": 229
} |
;
use Illuminate\Cache\RateLimiter;
use Illuminate\Cache\RedisStore;
use Illuminate\Cache\Repository;
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
#[RequiresPhpExtens... | testRedisCacheAddTwice($driver)
{
$store = new RedisStore($this->redis[$driver]);
$repository = new Repository($store);
$this->assertTrue($repository->add('k', 'v', 3600));
$this->assertFalse($repository->add('k', 'v', | }
protected function tearDown(): void
{
$this->tearDownRedis();
parent::tearDown();
}
/**
* @param string $driver
*/
#[DataProvider('redisDriverProvider')]
public function | {
"filepath": "tests/Integration/Cache/RedisCacheIntegrationTest.php",
"language": "php",
"file_size": 2591,
"cut_index": 563,
"middle_length": 229
} |
t\Framework\Attributes\TestWith;
use RuntimeException;
#[RequiresPhpExtension('redis')]
class RedisStoreTest extends TestCase
{
use InteractsWithRedis;
/** {@inheritdoc} */
#[\Override]
protected function setUp(): void
{
$this->afterApplicationCreated(function () {
$this->setUp... | , 1);
$putAt = microtime(true);
Sleep::for(600)->milliseconds();
$this->assertTrue((microtime(true) - $putAt) < 1);
$this->assertSame('world', $store->get('hello'));
// Although this key expires after exactly 1 sec | ): void
{
$store = Cache::store('redis');
$store->clear();
while ((microtime(true) - time()) > 0.5 && (microtime(true) - time()) < 0.6) {
//
}
$store->put('hello', 'world' | {
"filepath": "tests/Integration/Cache/RedisStoreTest.php",
"language": "php",
"file_size": 12758,
"cut_index": 921,
"middle_length": 229
} |
use Illuminate\Http\Client\Pool;
use Illuminate\Http\Client\Request;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Http;
use Orchestra\Testbench\TestCase;
use RuntimeException;
class H... | llection($event->request->header('User-Agent')))->contains('Facade/1.0');
});
}
public function testGlobalMiddlewarePersistsAfterFacadeFlush(): void
{
Http::macro('getGlobalMiddleware', fn () => $this->globalMiddleware);
| ddleware(fn ($request) => $request->withHeader('User-Agent', 'Facade/1.0'));
Http::get('laravel.com');
Event::assertDispatched(RequestSending::class, function (RequestSending $event) {
return (new Co | {
"filepath": "tests/Integration/Http/HttpClientTest.php",
"language": "php",
"file_size": 4804,
"cut_index": 614,
"middle_length": 229
} |
on;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Route;
use Orchestra\Testbench\TestCase;
class RequestDurationThresholdTest extends TestCase
{
public function testItCanHandleExceedingRequestDuration()
{
Route::get('test-route', fn () => 'ok');
$request = Request::creat... | ddMillisecond());
$kernel->terminate($request, $response);
$this->assertTrue($called);
}
public function testItDoesntCallWhenExactlyThresholdDuration()
{
Route::get('test-route', fn () => 'ok');
$request = Requ | rbonInterval::second(), function () use (&$called) {
$called = true;
});
Carbon::setTestNow(Carbon::now());
$kernel->handle($request);
Carbon::setTestNow(Carbon::now()->addSecond()->a | {
"filepath": "tests/Integration/Http/RequestDurationThresholdTest.php",
"language": "php",
"file_size": 6807,
"cut_index": 716,
"middle_length": 229
} |
ntegration\Http\Fixtures\PostResourceWithJsonOptions;
use Illuminate\Tests\Integration\Http\Fixtures\PostResourceWithJsonOptionsAndTypeHints;
use Illuminate\Tests\Integration\Http\Fixtures\PostResourceWithOptionalAppendedAttributes;
use Illuminate\Tests\Integration\Http\Fixtures\PostResourceWithOptionalAttributes;
use ... | uminate\Tests\Integration\Http\Fixtures\PostResourceWithOptionalRelationshipAggregates;
use Illuminate\Tests\Integration\Http\Fixtures\PostResourceWithOptionalRelationshipCounts;
use Illuminate\Tests\Integration\Http\Fixtures\PostResourceWithOptionalRelati | Http\Fixtures\PostResourceWithOptionalMerging;
use Illuminate\Tests\Integration\Http\Fixtures\PostResourceWithOptionalPivotRelationship;
use Illuminate\Tests\Integration\Http\Fixtures\PostResourceWithOptionalRelationship;
use Ill | {
"filepath": "tests/Integration/Http/ResourceTest.php",
"language": "php",
"file_size": 62319,
"cut_index": 2151,
"middle_length": 229
} |
minate\Foundation\Testing\Concerns\InteractsWithRedis;
use Illuminate\Http\Request;
use Illuminate\Routing\Middleware\ThrottleRequestsWithRedis;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\T... | })->middleware(ThrottleRequestsWithRedis::class.':2,1');
$response = $this->withoutExceptionHandling()->get('/');
$this->assertSame('yes', $response->getContent());
$this->assertEquals(2, $response->headers->get( | nsImmediatelyAfterDecay()
{
$this->ifRedisAvailable(function () {
$now = Carbon::now();
Carbon::setTestNow($now);
Route::get('/', function () {
return 'yes';
| {
"filepath": "tests/Integration/Http/ThrottleRequestsWithRedisTest.php",
"language": "php",
"file_size": 3972,
"cut_index": 614,
"middle_length": 229
} |
namespace Illuminate\Tests\Integration\Http\Fixtures;
use Illuminate\Http\Resources\Json\JsonResource;
class PostResourceWithOptionalAppendedAttributes extends JsonResource
{
public function toArray($request)
{
return [
'id' => $this->id,
'first' => $this->whenAppended('is_pu... | }),
'fourth' => $this->whenAppended('is_published', $this->is_published, 'default'),
'fifth' => $this->whenAppended('is_published', $this->is_published, function () {
return 'default';
}),
| ide value';
| {
"filepath": "tests/Integration/Http/Fixtures/PostResourceWithOptionalAppendedAttributes.php",
"language": "php",
"file_size": 801,
"cut_index": 517,
"middle_length": 14
} |
)
{
$app['config']['cors'] = [
'paths' => ['api/*'],
'supports_credentials' => false,
'allowed_origins' => ['http://localhost'],
'allowed_headers' => ['X-Custom-1', 'X-Custom-2'],
'allowed_methods' => ['GET', 'POST'],
'exposed_headers' ... | all('OPTIONS', 'api/ping', [], [], [], [
'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST',
]);
$this->assertSame('http://localhost', $crawler->headers->get('Access-Control-Allow-Origin'));
$this->assertEquals(204, $crawle | outer)
{
$this->addWebRoutes($router);
$this->addApiRoutes($router);
}
public function testShouldReturnHeaderAssessControlAllowOriginWhenDontHaveHttpOriginOnRequest()
{
$crawler = $this->c | {
"filepath": "tests/Integration/Http/Middleware/HandleCorsTest.php",
"language": "php",
"file_size": 10195,
"cut_index": 921,
"middle_length": 229
} |
use Illuminate\Auth\Access\Events\GateEvaluated;
use Illuminate\Database\Eloquent\Attributes\UsePolicy;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Gate;
use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser;
use Illuminate\Tests\Integra... | ');
Event::assertDispatched(GateEvaluated::class);
}
public function testPolicyCanBeGuessedUsingClassConventions()
{
$this->assertInstanceOf(
AuthenticationTestUserPolicy::class,
Gate::getPolicyFor(Auth | s\Policies\Nested\TopTestUserPolicy;
use Orchestra\Testbench\TestCase;
class GatePolicyResolutionTest extends TestCase
{
public function testGateEvaluationEventIsFired()
{
Event::fake();
Gate::check('foo | {
"filepath": "tests/Integration/Auth/GatePolicyResolutionTest.php",
"language": "php",
"file_size": 2849,
"cut_index": 563,
"middle_length": 229
} |
dcasting\ShouldBroadcastNow;
use Illuminate\Contracts\Broadcasting\ShouldRescue;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Queue;
use InvalidArgumentException;
use Orchestra\Testbench\TestCase;
use Psr... | Bus::fake();
Queue::fake();
Broadcast::queue(new TestEvent);
Bus::assertNotDispatched(BroadcastEvent::class);
Queue::assertPushed(BroadcastEvent::class);
}
public function testEventsCanBeBroadcastUsingQueueR | ue::fake();
Broadcast::queue(new TestEventNow);
Bus::assertDispatched(BroadcastEvent::class);
Queue::assertNotPushed(BroadcastEvent::class);
}
public function testEventsCanBeBroadcast()
{
| {
"filepath": "tests/Integration/Broadcasting/BroadcastManagerTest.php",
"language": "php",
"file_size": 11401,
"cut_index": 921,
"middle_length": 229
} |
Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\DatabasePresenceVerifier;
use Illuminate\Validati... | e(['uuid' => (string) Str::uuid(), 'first_name' => 'Jim']);
}
public function testExists(): void
{
$validator = $this->getValidator(['first_name' => ['John', 'Taylor']], ['first_name' => 'exists:users']);
$this->assertFalse($va |
$table->increments('id');
$table->string('uuid');
$table->string('first_name');
});
User::create(['uuid' => (string) Str::uuid(), 'first_name' => 'John']);
User::creat | {
"filepath": "tests/Integration/Validation/ValidatorTest.php",
"language": "php",
"file_size": 4161,
"cut_index": 614,
"middle_length": 229
} |
ption;
use Illuminate\Contracts\Cache\Repository;
use Orchestra\Testbench\TestCase;
use Throwable;
abstract class CacheFunnelTestCase extends TestCase
{
abstract protected function cache(): Repository;
protected function setUp(): void
{
parent::setUp();
try {
$this->releaseFun... | $i++) {
$result = $this->cache()->funnel('test')
->limit(1)
->releaseAfter(60)
->block(0)
->then(fn () => 'ok');
$this->assertSame('ok', $result);
}
}
| ->releaseAfter(60)
->block(0)
->then(fn () => 'hello');
$this->assertSame('hello', $result);
}
public function testFunnelReleasesLockAfterCallback()
{
for ($i = 0; $i < 5; | {
"filepath": "tests/Integration/Cache/CacheFunnelTestCase.php",
"language": "php",
"file_size": 3484,
"cut_index": 614,
"middle_length": 229
} |
on\AwsException;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Orchestra\Testbench\Attributes\RequiresEnv;
use Orchestra\Testbench\TestCase;
#[RequiresEnv('DYNAMODB_CACHE_TABLE')]
class DynamoDbStoreTest extends TestCase
{
public function testItems... | ertEquals([
'name' => 'Abigail',
'age' => 28,
'height' => null,
], Cache::driver('dynamodb')->many(['name', 'age', 'height']));
Cache::driver('dynamodb')->forget('name');
$this->assertNull(Cache: | r('dynamodb')->put(['name' => 'Abigail', 'age' => 28], 10);
$this->assertSame('Abigail', Cache::driver('dynamodb')->get('name'));
$this->assertEquals(28, Cache::driver('dynamodb')->get('age'));
$this->ass | {
"filepath": "tests/Integration/Cache/DynamoDbStoreTest.php",
"language": "php",
"file_size": 4032,
"cut_index": 614,
"middle_length": 229
} |
Case
{
use InteractsWithRedis;
protected function setUp(): void
{
parent::setUp();
$this->setUpRedis();
$connection = $this->app['redis']->connection();
$this->markTestSkippedUnless(
$connection instanceof PhpRedisConnection || $connection instanceof PhpRedisCl... | connection', 'default');
$this->app['config']->set('cache.stores.redis.lock_connection', 'default');
/** @var \Illuminate\Cache\RedisStore $store */
$store = Cache::store('redis');
/** @var \Redis $client */
$client | }
public function testRedisLockCanBeAcquiredAndReleasedWithoutSerializationAndCompression()
{
$this->app['config']->set('database.redis.client', 'phpredis');
$this->app['config']->set('cache.stores.redis. | {
"filepath": "tests/Integration/Cache/PhpRedisCacheLockTest.php",
"language": "php",
"file_size": 12623,
"cut_index": 921,
"middle_length": 229
} |
;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\DB;
use Orchestra\Testbench\Attributes\WithMigration;
#[WithMigr... | ingReleasesLockWhenJobIsReleasedByAMiddleware()
{
// Job that does not release and gets processed
UniqueTestJobThatDoesNotRelease::dispatch();
$lockKey = DB::table('cache_locks')->orderBy('id')->first()->key;
$this->asse | eEnvironment($app);
$app['config']->set('queue.default', 'database');
$app['config']->set('cache.default', 'database');
$this->driver = 'database';
}
public function testShouldBeUniqueUntilProcess | {
"filepath": "tests/Integration/Queue/UniqueUntilProcessingJobTest.php",
"language": "php",
"file_size": 2780,
"cut_index": 563,
"middle_length": 229
} |
ts\Queue\Job;
use Illuminate\Queue\CallQueuedHandler;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Mockery as m;
class WithoutOverlappingJobsTest extends QueueTestCase
{
public function testNonOverlappingJobsAreExecuted()
{
OverlappingTestJob::$handle... | nd' => serialize($command = new OverlappingTestJob),
]);
$lockKey = (new WithoutOverlapping)->getLockKey($command);
$this->assertTrue(OverlappingTestJob::$handled);
$this->assertTrue($this->app->get(Cache::class)->lock($lo | $job->shouldReceive('isReleased')->andReturn(false);
$job->shouldReceive('isDeletedOrReleased')->andReturn(false);
$job->shouldReceive('delete')->once();
$instance->call($job, [
'comma | {
"filepath": "tests/Integration/Queue/WithoutOverlappingJobsTest.php",
"language": "php",
"file_size": 7580,
"cut_index": 716,
"middle_length": 229
} |
use Exception;
use Illuminate\Http\StreamedEvent;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use Orchestra\Testbench\TestCase;
class EventStreamResponseTest extends TestCase
{
public function testEventStreamResponse()
{
Route::get('/stream', function () {
re... | esponse->assertOk();
$response->assertHeader('Content-Type', 'text/event-stream; charset=utf-8');
$response->assertHeader('X-Accel-Buffering', 'no');
$content = $response->streamedContent();
$this->assertStringContainsStri | yield new StreamedEvent(
event: 'update',
data: ['message' => 'world'],
);
});
});
$response = $this->get('/stream');
$r | {
"filepath": "tests/Integration/Http/EventStreamResponseTest.php",
"language": "php",
"file_size": 2892,
"cut_index": 563,
"middle_length": 229
} |
amespace Illuminate\Tests\Integration\Http;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Route;
use JsonSerializable;
use Orchestra\Testbench\TestCase;
class ResponseTest extends TestCase
{
public function testResponseWithInvalidJsonThrowsException()
{
$this->expectException('InvalidAr... | izable
{
public function jsonSerialize(): string
{
return "\xB1\x31";
}
});
});
$this->withoutExceptionHandling();
$this->get('/response') | ponse())->setContent(new class implements JsonSerial | {
"filepath": "tests/Integration/Http/ResponseTest.php",
"language": "php",
"file_size": 838,
"cut_index": 520,
"middle_length": 52
} |
on\JsonResource;
class PostResourceWithAnonymousResourceCollectionWithPaginationInformation extends JsonResource
{
public function toArray($request)
{
return ['id' => $this->id, 'title' => $this->title, 'custom' => true];
}
/**
* Create a new anonymous resource collection.
*
* @... | ctionWithPaginationInformation($resource, static::class), function ($collection) {
if (property_exists(static::class, 'preserveKeys')) {
$collection->preserveKeys = (new static([]))->preserveKeys === true;
}
|
{
return tap(new AnonymousResourceColle | {
"filepath": "tests/Integration/Http/Fixtures/PostResourceWithAnonymousResourceCollectionWithPaginationInformation.php",
"language": "php",
"file_size": 926,
"cut_index": 606,
"middle_length": 52
} |
t;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Support\Facades\Broadcast as BroadcastFacade;
use Illuminate\Support\Facades\Event as EventFacade;
use Orchestra\Testbench\TestCase;
use ReflectionClass;
class SendingBroadcastsViaAnonymousEventTest extends TestC... | $event->broadcastOn() === ['test-channel'] &&
$event->broadcastAs() === 'test-event' &&
$event->broadcastWith() === ['some' => 'data'];
});
}
public function testBroadcastIsSentNow()
{
EventFa | ent')
->send();
EventFacade::assertDispatched(AnonymousEvent::class, function ($event) {
return (new ReflectionClass($event))->getProperty('connection')->getValue($event) === null &&
| {
"filepath": "tests/Integration/Broadcasting/SendingBroadcastsViaAnonymousEventTest.php",
"language": "php",
"file_size": 4521,
"cut_index": 614,
"middle_length": 229
} |
Config('cache.default', 'redis')]
#[WithConfig('cache.prefix', 'laravel-cache-')]
class MemoizedStoreTest extends TestCase
{
use InteractsWithRedis;
/** {@inheritdoc} */
#[\Override]
protected function setUp(): void
{
$this->afterApplicationCreated(function () {
$this->setUpRedi... | Cache::put('name', 'Tim', 60);
$live = Cache::get('name');
$memoized = Cache::memo()->get('name');
$this->assertSame('Tim', $live);
$this->assertSame('Tim', $memoized);
Cache::put('name', 'Taylor', 60);
$ | });
$this->beforeApplicationDestroyed(function () {
$this->tearDownRedis();
});
parent::setUp();
}
public function test_it_can_memoize_when_retrieving_single_value()
{
| {
"filepath": "tests/Integration/Cache/MemoizedStoreTest.php",
"language": "php",
"file_size": 18817,
"cut_index": 1331,
"middle_length": 229
} |
Queue\Job;
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
use Illuminate\Queue\CallQueuedHandler;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Mockery as m;
use Orchestra\Testbench\Te... | ownRedis();
parent::tearDown();
}
public function testCircuitIsOpenedForJobErrors()
{
$this->assertJobWasReleasedImmediately(CircuitBreakerWithRedisTestJob::class, $key = Str::random());
$this->assertJobWasReleasedImme | tsWithRedis;
protected function setUp(): void
{
parent::setUp();
$this->setUpRedis();
Carbon::setTestNow(Carbon::now());
}
protected function tearDown(): void
{
$this->tearD | {
"filepath": "tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php",
"language": "php",
"file_size": 6821,
"cut_index": 716,
"middle_length": 229
} |
use LazilyRefreshDatabase;
public function testStaleWhileRevalidate(): void
{
Carbon::setTestNow('2000-01-01 00:00:00');
$cache = Cache::driver('array');
$count = 0;
// Cache is empty. The value should be populated...
$value = $cache->flexible('foo', [10, 20], funct... | function () use (&$count) {
return ++$count;
});
$this->assertSame(1, $value);
$this->assertCount(0, defer());
$this->assertSame(1, $cache->get('foo'));
$this->assertSame(946684800, $cache->get('illuminat |
$this->assertSame(946684800, $cache->get('illuminate:cache:flexible:created:foo'));
// Cache is fresh. The value should be retrieved from the cache and used...
$value = $cache->flexible('foo', [10, 20], | {
"filepath": "tests/Integration/Cache/RepositoryTest.php",
"language": "php",
"file_size": 13614,
"cut_index": 921,
"middle_length": 229
} |
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\T... | parent::tearDown();
}
protected function defineEnvironment($app)
{
$app['config']->set('app.key', Str::random(32));
$app['config']->set('auth.providers.users.model', AuthenticationTestUser::class);
}
protected fun | hMigration]
class ForgotPasswordTest extends TestCase
{
use RefreshDatabase;
protected function tearDown(): void
{
ResetPassword::$createUrlCallback = null;
ResetPassword::$toMailCallback = null;
| {
"filepath": "tests/Integration/Auth/ForgotPasswordTest.php",
"language": "php",
"file_size": 4601,
"cut_index": 614,
"middle_length": 229
} |
namespace Illuminate\Tests\Integration\Foundation\Configuration;
use Illuminate\Console\Scheduling\ScheduleListCommand;
use Illuminate\Foundation\Application;
use Illuminate\Support\Carbon;
use Orchestra\Testbench\TestCase;
class WithScheduleTest extends TestCase
{
protected function setUp(): void
{
... | ([__DIR__.'/stubs/console.php'])
->create();
}
public function testDisplaySchedule()
{
$this->artisan(ScheduleListCommand::class)
->assertSuccessful()
->expectsOutputToContain(' 0 * * * * php artis | return Application::configure(static::applicationBasePath())
->withSchedule(function ($schedule) {
$schedule->command('schedule:clear-cache')->everyMinute();
})
->withCommands | {
"filepath": "tests/Integration/Foundation/Configuration/WithScheduleTest.php",
"language": "php",
"file_size": 1190,
"cut_index": 518,
"middle_length": 229
} |
te\Tests\Integration\Notifications;
use Illuminate\Database\Eloquent\Casts\AsStringable;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Notification;... | eKey()
{
Notification::fake();
$user = UuidUserFactoryStub::new()->create();
$user->notify(new NotificationStub);
Notification::assertSentTo($user, NotificationStub::class, function ($notification, $channels, $notifia | 'laravel', 'notifications')]
class DatabaseNotificationTest extends TestCase
{
use RefreshDatabase;
#[DefineDatabase('defineDatabaseAndConvertUserIdToUuid')]
public function testAssertSentToWhenNotifiableHasStringabl | {
"filepath": "tests/Integration/Notifications/DatabaseNotificationTest.php",
"language": "php",
"file_size": 1993,
"cut_index": 537,
"middle_length": 229
} |
tions\Messages\MailMessage;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use Mockery as m;
use Orchestra\Testbench\TestCase;
class SendingMailNotificationsTest extends TestCase
{
public $mailFactory;
publi... | });
$app->extend(Mailer::class, function () {
return $this->mailer;
});
$app->extend(MailFactory::class, function () {
return $this->mailFactory;
});
$app['view']->addLocation(__DIR__.'/Fix |
$this->mailFactory->shouldReceive('mailer')->andReturn($this->mailer);
$this->markdown = m::mock(Markdown::class);
$app->extend(Markdown::class, function () {
return $this->markdown;
| {
"filepath": "tests/Integration/Notifications/SendingMailNotificationsTest.php",
"language": "php",
"file_size": 16019,
"cut_index": 921,
"middle_length": 229
} |
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Stringable;
use Orchestra\Test... | Database()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('email');
$table->string('name')->nullable();
});
}
protected function beforeRefres | er', 'array');
$app['config']->set('app.locale', 'en');
$app['config']->set('mail.markdown.theme', 'blank');
$app['view']->addLocation(__DIR__.'/Fixtures');
}
protected function afterRefreshing | {
"filepath": "tests/Integration/Notifications/SendingMailableNotificationsTest.php",
"language": "php",
"file_size": 3572,
"cut_index": 614,
"middle_length": 229
} |
ications;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Notification as NotificationFacade;
use Illuminate\Support\Testing\Fakes\NotificationFake;
use Orchestra\Testbench\TestCase;
class SendingNotificationsViaAnonymousNotifiableTest extend... | ], $_SERVER['__notifiable.route']);
}
public function testAnonymousNotifiableWithMultipleRoutes()
{
$_SERVER['__notifiable.route'] = [];
NotificationFacade::routes([
'testchannel' => 'enzo',
'anothertes | zo@deepblue.com');
NotificationFacade::send(
$notifiable,
new TestMailNotificationForAnonymousNotifiable
);
$this->assertEquals([
'enzo', 'enzo@deepblue.com',
| {
"filepath": "tests/Integration/Notifications/SendingNotificationsViaAnonymousNotifiableTest.php",
"language": "php",
"file_size": 2734,
"cut_index": 563,
"middle_length": 229
} |
e Illuminate\Foundation\Events\LocaleUpdated;
use Illuminate\Mail\Mailable;
use Illuminate\Notifications\Channels\MailChannel;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Carbon;
use Illuminate\Support\Faca... | >addLocation(__DIR__.'/Fixtures');
$app['translator']->setLoaded([
'*' => [
'*' => [
'en' => ['hi' => 'hello'],
'es' => ['hi' => 'hola'],
'fr' => ['hi' => 'bon | dingNotificationsWithLocaleTest extends TestCase
{
protected function defineEnvironment($app)
{
$app['config']->set('mail.driver', 'array');
$app['config']->set('app.locale', 'en');
$app['view']- | {
"filepath": "tests/Integration/Notifications/SendingNotificationsWithLocaleTest.php",
"language": "php",
"file_size": 8247,
"cut_index": 716,
"middle_length": 229
} |
HPUnit\Framework\TestCase;
class AfterResolvingAttributeCallbackTest extends TestCase
{
public function testCallbackIsCalledAfterDependencyResolutionWithAttribute()
{
$container = new Container();
$container->afterResolvingAttribute(ContainerTestOnTenant::class, function (ContainerTestOnTenant... | >make(ContainerTestHasTenantImplPropertyWithTenantB::class);
$this->assertInstanceOf(HasTenantImpl::class, $hasTenantB->property);
$this->assertEquals(Tenant::TenantB, $hasTenantB->property->tenant);
}
public function testCallbackI | sTenantImplPropertyWithTenantA::class);
$this->assertInstanceOf(HasTenantImpl::class, $hasTenantA->property);
$this->assertEquals(Tenant::TenantA, $hasTenantA->property->tenant);
$hasTenantB = $container- | {
"filepath": "tests/Container/AfterResolvingAttributeCallbackTest.php",
"language": "php",
"file_size": 4409,
"cut_index": 614,
"middle_length": 229
} |
this->expectExceptionMessage('Call to undefined function ContainerTestCallStub()');
$container = new Container;
$container->call('ContainerTestCallStub');
}
public function testCallWithAtSignBasedClassReferences()
{
$container = new Container;
$result = $container->call(Con... | ntainerTestCallStub::class.'@inject', ['default' => 'foo']);
$this->assertInstanceOf(ContainerCallConcreteStub::class, $result[0]);
$this->assertSame('foo', $result[1]);
$container = new Container;
$result = $container->cal | allStub::class.'@inject');
$this->assertInstanceOf(ContainerCallConcreteStub::class, $result[0]);
$this->assertSame('taylor', $result[1]);
$container = new Container;
$result = $container->call(Co | {
"filepath": "tests/Container/ContainerCallTest.php",
"language": "php",
"file_size": 10779,
"cut_index": 921,
"middle_length": 229
} |
edBindings()
{
$container = new Container;
$container['foo'] = 'foo';
$container->extend('foo', function ($old, $container) {
return $old.'bar';
});
$this->assertSame('foobar', $container->make('foo'));
$container = new Container;
$container->si... | '));
}
public function testExtendInstancesArePreserved()
{
$container = new Container;
$container->bind('foo', function () {
$obj = new stdClass;
$obj->foo = 'bar';
return $obj;
});
| return $old;
});
$result = $container->make('foo');
$this->assertSame('taylor', $result->name);
$this->assertEquals(26, $result->age);
$this->assertSame($result, $container->make('foo | {
"filepath": "tests/Container/ContainerExtendTest.php",
"language": "php",
"file_size": 7339,
"cut_index": 716,
"middle_length": 229
} |
te\Tests\Container;
use Illuminate\Container\Container;
use PHPUnit\Framework\TestCase;
class ContainerResolveNonInstantiableTest extends TestCase
{
public function testResolvingNonInstantiableWithDefaultRemovesWiths()
{
$container = new Container;
$object = $container->make(ParentClass::class... | {
$container = new Container;
$parent = $container->make(VariadicPrimitive::class);
$this->assertSame([], $parent->params);
}
}
interface TestInterface
{
}
class ParentClass
{
/**
* @var int
*/
public $i;
| $parent = $container->make(VariadicParentClass::class, ['i' => 42]);
$this->assertCount(0, $parent->child->objects);
$this->assertSame(42, $parent->i);
}
public function testResolveVariadicPrimitive()
| {
"filepath": "tests/Container/ContainerResolveNonInstantiableTest.php",
"language": "php",
"file_size": 1791,
"cut_index": 537,
"middle_length": 229
} |
k\TestCase;
class ContainerTaggingTest extends TestCase
{
public function testContainerTags()
{
$container = new Container;
$container->tag(ContainerImplementationTaggedStub::class, 'foo', 'bar');
$container->tag(ContainerImplementationTaggedStubTwo::class, ['foo']);
$this->ass... | , $fooResults[0]);
$this->assertInstanceOf(ContainerImplementationTaggedStub::class, $barResults[0]);
$this->assertInstanceOf(ContainerImplementationTaggedStubTwo::class, $fooResults[1]);
$container = new Container;
$contai | fooResults[] = $foo;
}
$barResults = [];
foreach ($container->tagged('bar') as $bar) {
$barResults[] = $bar;
}
$this->assertInstanceOf(ContainerImplementationTaggedStub::class | {
"filepath": "tests/Container/ContainerTaggingTest.php",
"language": "php",
"file_size": 3523,
"cut_index": 614,
"middle_length": 229
} |
leton(function (): ContainerConcreteStub {
return new ContainerConcreteStub;
});
$this->assertInstanceOf(
IContainerContractStub::class,
$container->make(IContainerContractStub::class)
);
$this->assertTrue($container->isShared(ContainerConcreteStub::... | IfServiceNotRegisteredYet()
{
$container = new Container;
$container->bind('surname', function () {
return 'Taylor';
});
$container->bindIf('name', function () {
return 'Dayle';
});
| turn 'Taylor';
});
$container->bindIf('name', function () {
return 'Dayle';
});
$this->assertSame('Taylor', $container->make('name'));
}
public function testBindIfDoesRegister | {
"filepath": "tests/Container/ContainerTest.php",
"language": "php",
"file_size": 38169,
"cut_index": 2151,
"middle_length": 229
} |
windableGenerator;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Guard as GuardContract;
use Illuminate\Contracts\Container\ContextualAttribute;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Database\Connection;
use Illuminate\Database\DatabaseM... | {
$container = new Container;
$container->bind(ContainerTestContract::class, fn (): ContainerTestImplB => new ContainerTestImplB);
$container->whenHasAttribute(ContainerTestAttributeThatResolvesContractImpl::class, function (Cont | nate\Log\LogManager;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
class ContextualAttributeBindingTest extends TestCase
{
public function testDependencyCanBeResolvedFromAttributeBinding()
| {
"filepath": "tests/Container/ContextualAttributeBindingTest.php",
"language": "php",
"file_size": 19600,
"cut_index": 1331,
"middle_length": 229
} |
ass);
$two = $container->make(ContainerTestContextInjectTwo::class);
$this->assertInstanceOf(ContainerContextImplementationStub::class, $one->impl);
$this->assertInstanceOf(ContainerContextImplementationStubTwo::class, $two->impl);
// Test With Closures
$container = new Contain... | return $container->make(ContainerContextImplementationStubTwo::class);
});
$one = $container->make(ContainerTestContextInjectOne::class);
$two = $container->make(ContainerTestContextInjectTwo::class);
$this->assertInstance | rContextContractStub::class)->give(ContainerContextImplementationStub::class);
$container->when(ContainerTestContextInjectTwo::class)->needs(IContainerContextContractStub::class)->give(function ($container) {
| {
"filepath": "tests/Container/ContextualBindingTest.php",
"language": "php",
"file_size": 24792,
"cut_index": 1331,
"middle_length": 229
} |
ontainer->bind('foo', function () {
return new stdClass;
});
$instance = $container->make('foo');
$this->assertSame('taylor', $instance->name);
}
public function testResolvingCallbacksAreCalledForType()
{
$container = new Container;
$container->resolving... | $container->alias(stdClass::class, 'std');
$container->resolving('std', function ($object) {
return $object->name = 'taylor';
});
$container->bind('foo', function () {
return new stdClass;
});
| $instance = $container->make('foo');
$this->assertSame('taylor', $instance->name);
}
public function testResolvingCallbacksShouldBeFiredWhenCalledWithAliases()
{
$container = new Container;
| {
"filepath": "tests/Container/ResolvingCallbackTest.php",
"language": "php",
"file_size": 18081,
"cut_index": 1331,
"middle_length": 229
} |
ontainer;
use Illuminate\Container\RewindableGenerator;
use PHPUnit\Framework\TestCase;
class RewindableGeneratorTest extends TestCase
{
public function testCountUsesProvidedValue()
{
$generator = new RewindableGenerator(function () {
yield 'foo';
}, 999);
$this->assertCou... | $called++;
return 500;
});
// the count callback is called lazily
$this->assertSame(0, $called);
$this->assertCount(500, $generator);
count($generator);
// the count callback is called | 'foo';
}, function () use (&$called) {
| {
"filepath": "tests/Container/RewindableGeneratorTest.php",
"language": "php",
"file_size": 913,
"cut_index": 547,
"middle_length": 52
} |
te\Tests\Container;
use Illuminate\Container\Util;
use PHPUnit\Framework\TestCase;
use ReflectionParameter;
use stdClass;
class UtilTest extends TestCase
{
public function testUnwrapIfClosure()
{
$this->assertSame('foo', Util::unwrapIfClosure('foo'));
$this->assertSame('foo', Util::unwrapIfClo... | assertSame([], Util::arrayWrap(null));
$this->assertEquals([null], Util::arrayWrap([null]));
$this->assertEquals([null, null], Util::arrayWrap([null, null]));
$this->assertEquals([''], Util::arrayWrap(''));
$this->assertEqua | $object->value = 'a';
$this->assertEquals(['a'], Util::arrayWrap($string));
$this->assertEquals($array, Util::arrayWrap($array));
$this->assertEquals([$object], Util::arrayWrap($object));
$this-> | {
"filepath": "tests/Container/UtilTest.php",
"language": "php",
"file_size": 1846,
"cut_index": 537,
"middle_length": 229
} |
\Testing\File;
use Illuminate\Mail\Attachment;
use Illuminate\Mail\Mailable;
use PHPUnit\Framework\TestCase;
class AttachableTest extends TestCase
{
public function testItCanHaveMacroConstructors(): void
{
Attachment::macro('fromInvoice', function ($name) {
return Attachment::fromData(fn ()... | ntent',
'name' => 'bar',
'options' => [
'mime' => 'image/jpeg',
],
], $mailable->rawAttachments[0]);
}
public function testItCanUtiliseExistingApisOnNonMailBasedResourcesWithPath(): void
| {
return Attachment::fromInvoice('foo')
->as('bar')
->withMime('image/jpeg');
}
});
$this->assertSame([
'data' => 'pdf co | {
"filepath": "tests/Mail/AttachableTest.php",
"language": "php",
"file_size": 4925,
"cut_index": 614,
"middle_length": 229
} |
use PHPUnit\Framework\TestCase;
class AttachmentTest extends TestCase
{
public function testFromUrlWithHttpScheme(): void
{
$attachment = Attachment::fromUrl('http://example.com/file.pdf');
$this->assertInstanceOf(Attachment::class, $attachment);
}
public function testFromUrlWithHttp... | 'ftp://example.com/file.pdf');
}
public function testFromUrlThrowsForFileScheme(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Attachment URLs must use the http or https scheme | stFromUrlThrowsForFtpScheme(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Attachment URLs must use the http or https scheme.');
Attachment::fromUrl( | {
"filepath": "tests/Mail/AttachmentTest.php",
"language": "php",
"file_size": 3537,
"cut_index": 614,
"middle_length": 229
} |
it\Framework\TestCase;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Component\Mailer\Exception\TransportException;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
class MailCloudflareTransportTest extends TestCase
{
publi... | $manager = new MailManager($container);
$transport = $manager->createSymfonyTransport(['transport' => 'cloudflare']);
$this->assertInstanceOf(CloudflareTransport::class, $transport);
$this->assertSame('cloudflare', (string) $ | es' => [
'cloudflare' => [
'account_id' => 'test-account-id',
'token' => 'test-token',
],
],
]);
});
| {
"filepath": "tests/Mail/MailCloudflareTransportTest.php",
"language": "php",
"file_size": 7293,
"cut_index": 716,
"middle_length": 229
} |
pace Illuminate\Tests\Mail;
use Orchestra\Testbench\TestCase;
use Symfony\Component\Mailer\Transport\FailoverTransport;
class MailFailoverTransportTest extends TestCase
{
public function testGetFailoverTransportWithConfiguredTransports(): void
{
$this->app['config']->set('mail.default', 'failover');
... | 'transport' => 'array',
],
]);
$transport = app('mailer')->getSymfonyTransport();
$this->assertInstanceOf(FailoverTransport::class, $transport);
}
public function testGetFailoverTransportWithLaravel6St | 'array',
],
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'array' => [
| {
"filepath": "tests/Mail/MailFailoverTransportTest.php",
"language": "php",
"file_size": 1434,
"cut_index": 524,
"middle_length": 229
} |
use Illuminate\Mail\Transport\LogTransport;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Orchestra\Testbench\TestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Mime\Email;
class MailLogTransportTest extends TestCase
{
public function testGetLogTransportWithConfigured... | logger = $transport->logger();
$this->assertInstanceOf(LoggerInterface::class, $logger);
$this->assertInstanceOf(Logger::class, $monolog = $logger->getLogger());
$this->assertCount(1, $handlers = $monolog->getHandlers());
$ | els.mail', [
'driver' => 'single',
'path' => 'mail.log',
]);
$transport = app('mailer')->getSymfonyTransport();
$this->assertInstanceOf(LogTransport::class, $transport);
$ | {
"filepath": "tests/Mail/MailLogTransportTest.php",
"language": "php",
"file_size": 4098,
"cut_index": 614,
"middle_length": 229
} |
public function testMailableAssertSeeInTextPassesWhenPresent(): void
{
$mailable = new MailableAssertionsStub;
$mailable->assertSeeInText('First Item');
}
public function testMailableAssertSeeInTextFailsWhenAbsent(): void
{
$mailable = new MailableAssertionsStub;
$this... | onsStub;
$this->expectException(AssertionFailedError::class);
$mailable->assertDontSeeInText('First Item');
}
public function testMailableAssertSeeInHtmlPassesWhenPresent(): void
{
$mailable = new MailableAssertionsSt | $mailable = new MailableAssertionsStub;
$mailable->assertDontSeeInText('Fourth Item');
}
public function testMailableAssertDontSeeInTextFailsWhenPresent(): void
{
$mailable = new MailableAsserti | {
"filepath": "tests/Mail/MailMailableAssertionsTest.php",
"language": "php",
"file_size": 8216,
"cut_index": 716,
"middle_length": 229
} |
<?php
namespace Illuminate\Tests\Mail;
use Illuminate\Mail\Mailable;
use PHPUnit\Framework\TestCase;
class MailMailableDataTest extends TestCase
{
public function testMailableDataIsNotLost(): void
{
$mailable = new MailableStub;
$testData = [
'first_name' => 'James',
... | $this->assertSame($testData, $mailable->buildViewData());
}
}
class MailableStub extends Mailable
{
/**
* Build the message.
*
* @return $this
*/
public function build($builder)
{
$builder($this);
}
}
| e($testData, $mailable->buildViewData());
$mailable = new MailableStub;
$mailable->build(function ($m) use ($testData) {
$m->view('view', $testData)
->text('text-view');
});
| {
"filepath": "tests/Mail/MailMailableDataTest.php",
"language": "php",
"file_size": 997,
"cut_index": 512,
"middle_length": 229
} |
?php
namespace Illuminate\Tests\Mail;
use Illuminate\Mail\Mailables\Headers;
use PHPUnit\Framework\TestCase;
class MailMailableHeadersTest extends TestCase
{
public function test(): void
{
$headers = new Headers(
'434571BC.8070702@example.net',
[
'<199805061920... | this->assertSame(
'<19980506192030.26456.qmail@cr.yp.to> <19980507220459.5655.qmail@warren.demon.co.uk> <19980508103652.B21462@iconnect.co.ke> <19980509035615.40087@rucus.ru.ac.za>',
$headers->referencesString(),
);
}
}
| cus.ru.ac.za>',
],
);
$ | {
"filepath": "tests/Mail/MailMailableHeadersTest.php",
"language": "php",
"file_size": 821,
"cut_index": 513,
"middle_length": 52
} |
To('taylor@laravel.com', 'Taylor Otwell');
$mailable->assertHasTo('taylor@laravel.com');
$mailable = new WelcomeMailableStub;
$mailable->to(['taylor@laravel.com']);
$this->assertEquals([['name' => null, 'address' => 'taylor@laravel.com']], $mailable->to);
$this->assertTrue($mail... | .\nExpected: [taylor@laravel.com (Taylor Otwell)]\nActual: [taylor@laravel.com]\nFailed asserting that false is true.", $e->getMessage());
}
$mailable = new WelcomeMailableStub;
$mailable->to([['name' => 'Taylor Otwell', 'email' => | $mailable->assertHasTo('taylor@laravel.com', 'Taylor Otwell');
$this->fail();
} catch (AssertionFailedError $e) {
$this->assertSame("Did not see expected recipient in email 'to' recipients | {
"filepath": "tests/Mail/MailMailableTest.php",
"language": "php",
"file_size": 56654,
"cut_index": 2151,
"middle_length": 229
} |
ework\TestCase;
use Symfony\Component\Mime\Address;
class MailMailerTest extends TestCase
{
protected function tearDown(): void
{
unset($_SERVER['__mailer.test']);
parent::tearDown();
}
public function testMailerSendSendsMessageWithProperViewContent(): void
{
$view = m::mo... | StringContainsString('rendered.view', $sentMessage->toString());
}
public function testMailerSendSendsMessageWithCcAndBccRecipients(): void
{
$view = m::mock(Factory::class);
$view->shouldReceive('make')->once()->andReturn($vie | rray', $view, new ArrayTransport);
$sentMessage = $mailer->send('foo', ['data'], function (Message $message) {
$message->to('taylor@laravel.com')->from('hello@laravel.com');
});
$this->assert | {
"filepath": "tests/Mail/MailMailerTest.php",
"language": "php",
"file_size": 14328,
"cut_index": 921,
"middle_length": 229
} |
ny\Component\Mailer\Transport\Smtp\EsmtpTransport;
class MailManagerTest extends TestCase
{
#[DataProvider('emptyTransportConfigDataProvider')]
public function testEmptyTransportConfig($transport): void
{
$this->app['config']->set('mail.mailers.custom_smtp', [
'transport' => $transport,... | estWith([null, 5876])]
#[TestWith([null, 465])]
#[TestWith(['smtp', 25])]
#[TestWith(['smtp', 2525])]
#[TestWith(['smtps', 465])]
#[TestWith(['smtp', 465])]
public function testMailUrlConfig($scheme, $port): void
{
$this | ]);
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("Unsupported mail transport [{$transport}]");
$this->app['mail.manager']->mailer('custom_smtp');
}
#[T | {
"filepath": "tests/Mail/MailManagerTest.php",
"language": "php",
"file_size": 6551,
"cut_index": 716,
"middle_length": 229
} |
unction setUp(): void
{
parent::setUp();
$this->message = new Message(new Email());
}
public function testFromMethod(): void
{
$this->assertSame($this->message, $this->message->from('foo@bar.baz', 'Foo'));
$this->assertEquals(new Address('foo@bar.baz', 'Foo'), $this->me... | e->returnPath('foo@bar.baz'));
$this->assertEquals(new Address('foo@bar.baz'), $this->message->getSymfonyMessage()->getReturnPath());
}
public function testToMethod(): void
{
$this->assertSame($this->message, $this->message->to | $this->assertEquals(new Address('foo@bar.baz', 'Foo'), $this->message->getSymfonyMessage()->getSender());
}
public function testReturnPathMethod(): void
{
$this->assertSame($this->message, $this->messag | {
"filepath": "tests/Mail/MailMessageTest.php",
"language": "php",
"file_size": 10160,
"cut_index": 921,
"middle_length": 229
} |
pace Illuminate\Tests\Mail;
use Orchestra\Testbench\TestCase;
use Symfony\Component\Mailer\Transport\RoundRobinTransport;
class MailRoundRobinTransportTest extends TestCase
{
public function testGetRoundRobinTransportWithConfiguredTransports(): void
{
$this->app['config']->set('mail.default', 'roundro... | => [
'transport' => 'array',
],
]);
$transport = app('mailer')->getSymfonyTransport();
$this->assertInstanceOf(RoundRobinTransport::class, $transport);
}
public function testGetRoundRobinTranspo | ail',
'array',
],
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'array' | {
"filepath": "tests/Mail/MailRoundRobinTransportTest.php",
"language": "php",
"file_size": 1454,
"cut_index": 524,
"middle_length": 229
} |
SesClient;
use Illuminate\Config\Repository;
use Illuminate\Container\Container;
use Illuminate\Mail\MailManager;
use Illuminate\Mail\Transport\SesTransport;
use Illuminate\View\Factory;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mailer\Exception\TransportException;
use Symfony\Component\Ma... | t' => 'bar',
'region' => 'us-east-1',
],
]);
});
$manager = new MailManager($container);
/** @var \Illuminate\Mail\Transport\SesTransport $transport */
$transport = $manager- | {
$container = new Container;
$container->singleton('config', function () {
return new Repository([
'services.ses' => [
'key' => 'foo',
'secre | {
"filepath": "tests/Mail/MailSesTransportTest.php",
"language": "php",
"file_size": 5016,
"cut_index": 614,
"middle_length": 229
} |
2\SesV2Client;
use Illuminate\Config\Repository;
use Illuminate\Container\Container;
use Illuminate\Mail\MailManager;
use Illuminate\Mail\Transport\SesV2Transport;
use Illuminate\View\Factory;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mailer\Exception\TransportException;
use Symfony\Compon... | 'secret' => 'bar',
'region' => 'us-east-1',
],
]);
});
$manager = new MailManager($container);
/** @var \Illuminate\Mail\Transport\SesV2Transport $transport */
$transport = | void
{
$container = new Container;
$container->singleton('config', function () {
return new Repository([
'services.ses' => [
'key' => 'foo',
| {
"filepath": "tests/Mail/MailSesV2TransportTest.php",
"language": "php",
"file_size": 5074,
"cut_index": 614,
"middle_length": 229
} |
ddress;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
class MailableAlternativeSyntaxTest extends TestCase
{
public function testBasicMailableInspection(): void
{
$mailable = new MailableWithAlternativeSyntax;
... | gail Otwell'));
$this->assertTrue($mailable->hasTo('taylor@laravel.com', 'Taylor Otwell'));
$this->assertTrue($mailable->hasSubject('Test Subject'));
$this->assertFalse($mailable->hasSubject('Wrong Subject'));
$this->assert |
$this->assertTrue($mailable->hasTo('taylor@laravel.com', 'Taylor Otwell'));
$this->assertFalse($mailable->hasTo('taylor@laravel.com', 'Wrong Name'));
$mailable->to(new Address('abigail@laravel.com', 'Abi | {
"filepath": "tests/Mail/MailableAlternativeSyntaxTest.php",
"language": "php",
"file_size": 3578,
"cut_index": 614,
"middle_length": 229
} |
ation\Testing\Concerns;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbenc... | tabase()
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('name', 'username');
});
Schema::table('users', function (Blueprint $table) {
$table->tinyInteger('is_active')->defaul | Environment($app)
{
$app['config']->set('auth.guards.api', [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
]);
}
protected function afterRefreshingDa | {
"filepath": "tests/Integration/Foundation/Testing/Concerns/InteractsWithAuthenticationTest.php",
"language": "php",
"file_size": 2977,
"cut_index": 563,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Http;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Route;
use JsonSerializable;
use Orchestra\Testbench\TestCase;
class JsonResponseTest extends TestCase
{
public function testResponseWithInvalidJsonThrowsException()
... | }
});
});
$this->withoutExceptionHandling();
$this->get('/response');
}
public function testResponseSetDataPassesWithPriorJsonErrors()
{
$response = new JsonResponse();
// Trigger | nse', function () {
return new JsonResponse(new class implements JsonSerializable
{
public function jsonSerialize(): string
{
return "\xB1\x31";
| {
"filepath": "tests/Integration/Http/JsonResponseTest.php",
"language": "php",
"file_size": 1349,
"cut_index": 524,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.