prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
\Support\Carbon;
use PHPUnit\Framework\TestCase;
use SessionHandlerInterface;
class ArraySessionHandlerTest extends TestCase
{
protected function tearDown(): void
{
Carbon::setTestNow();
parent::tearDown();
}
public function test_it_implements_the_session_handler_interface()
{
... |
public function test_it_reads_data_from_the_session()
{
$handler = new ArraySessionHandler(10);
$handler->write('foo', 'bar');
$this->assertSame('bar', $handler->read('foo'));
}
public function test_it_reads_data | nHandler(10);
$this->assertTrue($handler->open('', ''));
}
public function test_it_closes_the_session()
{
$handler = new ArraySessionHandler(10);
$this->assertTrue($handler->close());
}
| {
"filepath": "tests/Session/ArraySessionHandlerTest.php",
"language": "php",
"file_size": 3241,
"cut_index": 614,
"middle_length": 229
} |
uminate\Contracts\Cache\Repository as CacheContract;
use Illuminate\Session\CacheBasedSessionHandler;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class CacheBasedSessionHandlerTest extends TestCase
{
protected $cacheMock;
protected $sessionHandler;
protected function setUp(): void
{
par... | $this->assertTrue($result);
}
public function test_read_returns_data_from_cache()
{
$this->cacheMock->shouldReceive('get')->once()->with('session_id', '')->andReturn('session_data');
$data = $this->sessionHandler->read( | nction test_open()
{
$result = $this->sessionHandler->open('path', 'session_name');
$this->assertTrue($result);
}
public function test_close()
{
$result = $this->sessionHandler->close();
| {
"filepath": "tests/Session/CacheBasedSessionHandlerTest.php",
"language": "php",
"file_size": 2393,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Session;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Session\EncryptedStore;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use SessionHandlerInterface;
class EncryptedSessionStoreTest extends TestCase
{
public function testSessionIsProperlyEncrypted()
{
... | '_token' => $session->token(),
'foo' => 'bar',
'baz' => 'boom',
'_flash' => [
'new' => [],
'old' => ['baz'],
],
]);
$session->getEncrypter()->shouldRecei | eive('read')->once()->andReturn(serialize([]));
$session->start();
$session->put('foo', 'bar');
$session->flash('baz', 'boom');
$session->now('qux', 'norf');
$serialized = serialize([
| {
"filepath": "tests/Session/EncryptedSessionStoreTest.php",
"language": "php",
"file_size": 1907,
"cut_index": 537,
"middle_length": 229
} |
on\FileSessionHandler;
use Illuminate\Support\Carbon;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use function Illuminate\Filesystem\join_paths;
class FileSessionHandlerTest extends TestCase
{
protected $files;
protected $sessionHandler;
protected function setUp(): void
{
// Create a m... | se()
{
$this->assertTrue($this->sessionHandler->close());
}
public function test_read_returns_data_when_file_exists_and_is_valid()
{
$sessionId = 'session_id';
$path = '/path/to/sessions/'.$sessionId;
Carbon | eSessionHandler($this->files, '/path/to/sessions', 30);
}
public function test_open()
{
$this->assertTrue($this->sessionHandler->open('/path/to/sessions', 'session_name'));
}
public function test_clo | {
"filepath": "tests/Session/FileSessionHandlerTest.php",
"language": "php",
"file_size": 4367,
"cut_index": 614,
"middle_length": 229
} |
->assertSame('bax', $session->get('123'));
$this->assertSame('baz', $session->get('bar', 'baz'));
$this->assertTrue($session->has('foo'));
$this->assertTrue($session->has('123'));
$this->assertFalse($session->has('bar'));
$this->assertTrue($session->isStarted());
$sessio... | $oldId = $session->getId();
$session->getHandler()->shouldReceive('destroy')->once()->with($oldId);
$this->assertTrue($session->migrate(true));
$this->assertNotEquals($oldId, $session->getId());
}
public function test | n->getId();
$session->getHandler()->shouldReceive('destroy')->never();
$this->assertTrue($session->migrate());
$this->assertNotEquals($oldId, $session->getId());
$session = $this->getSession();
| {
"filepath": "tests/Session/SessionStoreTest.php",
"language": "php",
"file_size": 29177,
"cut_index": 1331,
"middle_length": 229
} |
SessionTest extends TestCase
{
public function test_handle_without_session()
{
$request = new Request;
$next = fn () => 'next-1';
$authFactory = m::mock(AuthFactory::class);
$authFactory->shouldReceive('viaRemember')->never();
$middleware = new AuthenticateSession($auth... | ceive('viaRemember')->never();
$next = fn () => 'next-2';
$middleware = new AuthenticateSession($authFactory);
$response = $middleware->handle($request, $next);
$this->assertSame('next-2', $response);
}
public func | {
$request = new Request;
// set session:
$request->setLaravelSession(new Store('name', new ArraySessionHandler(1)));
$authFactory = m::mock(AuthFactory::class);
$authFactory->shouldRe | {
"filepath": "tests/Session/Middleware/AuthenticateSessionTest.php",
"language": "php",
"file_size": 14223,
"cut_index": 921,
"middle_length": 229
} |
te\Tests\Testing;
use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Controller;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\Facades\Facade;
use Orchestra\Testbench\TestCase;
class AssertRedirectToActionTest extends TestCase
{
/**
* @var \... | return new RedirectResponse($this->urlGenerator->action([TestActionController::class, 'index']));
});
$router->get('redirect-to-show', function () {
return new RedirectResponse($this->urlGenerator->action([TestActionContr | $router->get('controller/index', [TestActionController::class, 'index']);
$router->get('controller/show/{id}', [TestActionController::class, 'show']);
$router->get('redirect-to-index', function () {
| {
"filepath": "tests/Testing/AssertRedirectToActionTest.php",
"language": "php",
"file_size": 1875,
"cut_index": 537,
"middle_length": 229
} |
uminate\Contracts\Routing\Registrar;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\Facades\Facade;
use Orchestra\Testbench\TestCase;
class AssertRedirectToRouteTest extends TestCase
{
/**
* @var \Illuminate\Contracts\Routing\Registrar
*/
private $ro... | e-with-param');
$this->router
->get('')
->name('route-with-empty-uri');
$this->urlGenerator = $this->app->make(UrlGenerator::class);
}
public function testAssertRedirectToRouteWithRouteName(): void
{
| is->app->make(Registrar::class);
$this->router
->get('named-route')
->name('named-route');
$this->router
->get('named-route-with-param/{param}')
->name('named-rout | {
"filepath": "tests/Testing/AssertRedirectToRouteTest.php",
"language": "php",
"file_size": 2655,
"cut_index": 563,
"middle_length": 229
} |
\Http\RedirectResponse;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\Facades\Facade;
use Orchestra\Testbench\TestCase;
class AssertRedirectToSignedRouteTest extends TestCase
{
/**
* @var \Illuminate\Contracts\Routing\Registrar
*/
private $router;
/**
* @var \Illuminate\Routin... | tor = $this->app->make(UrlGenerator::class);
}
protected function defineEnvironment($app): void
{
$app['config']->set(['app.key' => 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF']);
}
public function testAssertRedirectToSignedRouteWithout | is->router
->get('signed-route')
->name('signed-route');
$this->router
->get('signed-route-with-param/{param}')
->name('signed-route-with-param');
$this->urlGenera | {
"filepath": "tests/Testing/AssertRedirectToSignedRouteTest.php",
"language": "php",
"file_size": 3075,
"cut_index": 614,
"middle_length": 229
} |
uminate\Testing\Assert;
use Illuminate\Testing\Exceptions\InvalidArgumentException;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;
use stdClass;
class AssertTest extends TestCase
{
public function testArraySubset()
{
Assert::assertArraySubset([
'string' =>... | => new stdClass(),
], [
'int' => 1,
'string' => 'string',
'object' => new stdClass(),
]);
}
public function testArraySubsetWithStrict(): void
{
Assert::assertArraySubset([
| function testArraySubsetMayFail(): void
{
$this->expectException(ExpectationFailedException::class);
Assert::assertArraySubset([
'int' => 2,
'string' => 'string',
'object' | {
"filepath": "tests/Testing/AssertTest.php",
"language": "php",
"file_size": 2531,
"cut_index": 563,
"middle_length": 229
} |
\ParallelTesting;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class ParallelTestingTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
Container::setInstance(new Container);
$_SERVER['LARAVEL_PARALLEL_TESTING'] = 1;
}
... | ) {
if (in_array($callback, ['setUpTestCase', 'tearDownTestCase'])) {
$this->assertSame($this, $testCase);
} else {
$this->assertNull($testCase);
}
$this->assertSame('1', (str | t($callback).'Callbacks';
$state = false;
$parallelTesting->{$caller}($this);
$this->assertFalse($state);
$parallelTesting->{$callback}(function ($token, $testCase = null) use ($callback, &$state | {
"filepath": "tests/Testing/ParallelTestingTest.php",
"language": "php",
"file_size": 3071,
"cut_index": 614,
"middle_length": 229
} |
uminate\Testing\Constraints\SeeInHtml;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class SeeInHtmlTest extends TestCase
{
public function testCollapsesUnicodeWhitespaceFromHtmlEntities()
{
$constraint = new SeeInHtml('Hello World');
$this->assertTrue($constra... | constraint->matches(["<p>Hello{$whitespace}World</p>"]));
}
public static function unicodeWhitespaceCharacters(): array
{
return [
'no-break space (U+00A0)' => ["\u{00A0}"],
'en space (U+2002)' => ["\u{2002}"],
| d</p>']));
}
#[DataProvider('unicodeWhitespaceCharacters')]
public function testCollapsesRawUnicodeWhitespace(string $whitespace)
{
$constraint = new SeeInHtml('Hello World');
$this->assertTrue($ | {
"filepath": "tests/Testing/SeeInHtmlTest.php",
"language": "php",
"file_size": 2471,
"cut_index": 563,
"middle_length": 229
} |
'foo' => [
'nested' => 'bar',
],
],
]);
$response->assertViewHas('foo.nested', 'bar');
}
public function testAssertViewHasEloquentCollection(): void
{
$collection = new EloquentCollection([
new TestModel(['id'... | ew EloquentCollection([
new TestModel(['id' => 3]),
new TestModel(['id' => 2]),
new TestModel(['id' => 1]),
]);
$response = $this->makeMockResponse([
'render' => 'hello world',
'g | 'gatherData' => ['foos' => $collection],
]);
$response->assertViewHas('foos', $collection);
}
public function testAssertViewHasEloquentCollectionRespectsOrder(): void
{
$collection = n | {
"filepath": "tests/Testing/TestResponseTest.php",
"language": "php",
"file_size": 110552,
"cut_index": 3790,
"middle_length": 229
} |
use Illuminate\Foundation\Console\ConfigShowCommand;
use Orchestra\Testbench\TestCase;
class ConfigShowCommandTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
putenv('COLUMNS=64');
}
public function testDisplayConfig()
{
config()->set('test', [
... | st'])
->assertSuccessful()
->expectsOutput(' test ....................................................... ')
->expectsOutput(' string ................................................ Test ')
->expectsOutp | owCommand::class,
],
'empty_array' => [],
'assoc_array' => ['foo' => 'bar'],
'class' => new \stdClass,
]);
$this->artisan(ConfigShowCommand::class, ['config' => 'te | {
"filepath": "tests/Testing/Console/ConfigShowCommandTest.php",
"language": "php",
"file_size": 2762,
"cut_index": 563,
"middle_length": 229
} |
\WithConfig;
use Orchestra\Testbench\TestCase;
#[WithConfig('filesystems.disks.local.serve', false)]
class RouteListCommandTest extends TestCase
{
use InteractsWithDeprecationHandling;
/**
* @var \Illuminate\Contracts\Routing\Registrar
*/
private $router;
/**
* @var \Illuminate\Routing... | erminalWidthUsing(fn () => 200);
$closureLine = __LINE__ + 1;
$this->router->get('/', function () {
//
});
$this->router->get('closure', function () {
return new RedirectResponse($this->urlGenerator | eListCommand::resolveTerminalWidthUsing(function () {
return 70;
});
}
public function testDisplayRoutesForCli()
{
$this->withoutMockingConsoleOutput();
RouteListCommand::resolveT | {
"filepath": "tests/Testing/Console/RouteListCommandTest.php",
"language": "php",
"file_size": 9685,
"cut_index": 921,
"middle_length": 229
} |
e\Database\Query\Expression;
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Facade;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class InteractsWithDatabaseTest extends TestCase
{
protected function setUp(): void
{
... | ct(['foo', 'bar']), $grammar)
);
$this->assertEquals(<<<'TEXT'
'{"foo":"bar"}'
TEXT,
$this->castAsJson((object) ['foo' => 'bar'], $grammar)
);
}
public function testCastToJsonPostgres()
{
| s(<<<'TEXT'
'["foo","bar"]'
TEXT,
$this->castAsJson(['foo', 'bar'], $grammar)
);
$this->assertEquals(<<<'TEXT'
'["foo","bar"]'
TEXT,
$this->castAsJson(colle | {
"filepath": "tests/Testing/Concerns/InteractsWithDatabaseTest.php",
"language": "php",
"file_size": 4166,
"cut_index": 614,
"middle_length": 229
} |
pace Illuminate\Tests\Testing\Concerns;
use ErrorException;
use Illuminate\Foundation\Bootstrap\HandleExceptions;
use Illuminate\Foundation\Testing\Concerns\InteractsWithDeprecationHandling;
use PHPUnit\Framework\TestCase;
class InteractsWithDeprecationHandlingTest extends TestCase
{
use InteractsWithDeprecationH... | on testWithDeprecationHandling()
{
$this->withDeprecationHandling();
trigger_error('Something is deprecated', E_USER_DEPRECATED);
$this->assertTrue($this->deprecationsFound);
}
public function testWithoutDeprecationHa | sFound = true;
});
}
protected function tearDown(): void
{
$this->deprecationsFound = false;
HandleExceptions::flushHandlersState($this);
parent::tearDown();
}
public functi | {
"filepath": "tests/Testing/Concerns/InteractsWithDeprecationHandlingTest.php",
"language": "php",
"file_size": 1269,
"cut_index": 524,
"middle_length": 229
} |
pport\Facades\ParallelTesting as ParallelTestingFacade;
use Illuminate\Testing\Concerns\TestCaches;
use Illuminate\Testing\ParallelTesting;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
use ReflectionProperty;
class TestCachesTest extends TestCase
{
protected ... |
$_SERVER['LARAVEL_PARALLEL_TESTING'] = 1;
}
protected function tearDown(): void
{
Container::setInstance(null);
ParallelTestingFacade::clearResolvedInstance();
Facade::setFacadeApplication(null);
unse | eton('config', fn () => new Config([
'cache' => [
'prefix' => 'myapp_cache_',
],
]));
$container->singleton(ParallelTesting::class, fn ($app) => new ParallelTesting($app)); | {
"filepath": "tests/Testing/Concerns/TestCachesTest.php",
"language": "php",
"file_size": 5741,
"cut_index": 716,
"middle_length": 229
} |
lluminate\Container\Container;
use Illuminate\Support\Facades\DB;
use Illuminate\Testing\Concerns\TestDatabases;
use Mockery as m;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
class TestDatabasesTest extends TestCase
{
protected function setUp(): void
{
... | 1;
}
public function testSwitchToDatabaseWithoutUrl()
{
DB::shouldReceive('purge')->once();
config()->shouldReceive('get')
->once()
->with('database.connections.mysql.url', false)
->andRetur | ->shouldReceive('get')
->once()
->with('database.default', null)
->andReturn('mysql')
->getMock();
});
$_SERVER['LARAVEL_PARALLEL_TESTING'] = | {
"filepath": "tests/Testing/Concerns/TestDatabasesTest.php",
"language": "php",
"file_size": 3059,
"cut_index": 614,
"middle_length": 229
} |
cade;
use Illuminate\Support\Facades\ParallelTesting as ParallelTestingFacade;
use Illuminate\Testing\Concerns\TestViews;
use Illuminate\Testing\ParallelTesting;
use Illuminate\View\Compilers\BladeCompiler;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
use ReflectionProperty;
class TestViewsT... | ::class, fn ($app) => new ParallelTesting($app));
$_SERVER['LARAVEL_PARALLEL_TESTING'] = 1;
}
protected function tearDown(): void
{
Container::setInstance(null);
ParallelTestingFacade::clearResolvedInstance();
| ontainer);
$container->singleton('config', fn () => new Config([
'view' => [
'compiled' => '/path/to/compiled/views',
],
]));
$container->singleton(ParallelTesting | {
"filepath": "tests/Testing/Concerns/TestViewsTest.php",
"language": "php",
"file_size": 5133,
"cut_index": 716,
"middle_length": 229
} |
mple',
'prop' => 'value',
],
]);
$assert->has('bar', 2);
}
public function testAssertHasCountFailsWhenAmountOfItemsDoesNotMatch()
{
$assert = AssertableJson::fromArray([
'bar' => [
'baz' => 'example',
'prop' =>... | p' => 'value',
],
]);
$this->expectException(AssertionFailedError::class);
$this->expectExceptionMessage('Property [baz] does not exist.');
$assert->has('baz', 1);
}
public function testAssertHasFailsW | $assert->has('bar', 1);
}
public function testAssertHasCountFailsWhenPropMissing()
{
$assert = AssertableJson::fromArray([
'bar' => [
'baz' => 'example',
'pro | {
"filepath": "tests/Testing/Fluent/AssertTest.php",
"language": "php",
"file_size": 45798,
"cut_index": 2151,
"middle_length": 229
} |
pace Illuminate\Tests\View;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Console\ViewClearCommand;
use Mockery as m;
use Orchestra\Testbench\TestCase;
class ClearCommandTest extends TestCase
{
private $files;
protected function setUp(): void
{
... | '/views/cache/path/filehash123.php',
'/views/cache/path/test_33',
];
$this->files->shouldReceive('glob')->once()->andReturn($globResult);
$this->files->shouldReceive('isDirectory')->once()->with($globResult[0])->andre | ction tearDown(): void
{
Container::setInstance(null);
parent::tearDown();
}
public function test_clear_view_command_should_remove_parallel_test_directories()
{
$globResult = [
| {
"filepath": "tests/View/ClearCommandTest.php",
"language": "php",
"file_size": 1342,
"cut_index": 524,
"middle_length": 229
} |
luminate\View\ComponentSlot;
use Illuminate\View\Factory;
use Illuminate\View\View;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class ComponentTest extends TestCase
{
protected $viewFactory;
protected $config;
protected function setUp(): void
{
parent::setUp();
$this->config = ... | n(): void
{
Facade::clearResolvedInstances();
Facade::setFacadeApplication(null);
Container::setInstance(null);
Component::flushCache();
Component::forgetFactory();
parent::tearDown();
}
public | r->alias('view', FactoryContract::class);
$container->instance('config', $this->config);
Container::setInstance($container);
Facade::setFacadeApplication($container);
}
protected function tearDow | {
"filepath": "tests/View/ComponentTest.php",
"language": "php",
"file_size": 15576,
"cut_index": 921,
"middle_length": 229
} |
, $key, $chunk) {
return $current === $chunk->last();
});
});
$this->assertEnumeratesCollection($collection, 3, function ($collection) {
$collection->chunkWhile(function ($current, $key, $chunk) {
return $current === $chunk->last();
})... | [7, 8, 9],
]);
$this->assertDoesNotEnumerateCollection($collection, function ($collection) {
$collection->collapse();
});
$this->assertEnumeratesCollection($collection, 1, function ($collection) {
| return $current === $chunk->last();
})->all();
});
}
public function testCollapseIsLazy()
{
$collection = LazyCollection::make([
[1, 2, 3],
[4, 5, 6],
| {
"filepath": "tests/Support/SupportLazyCollectionIsLazyTest.php",
"language": "php",
"file_size": 51728,
"cut_index": 2151,
"middle_length": 229
} |
$macroable;
protected function setUp(): void
{
$this->macroable = $this->createObjectForTrait();
}
private function createObjectForTrait()
{
return new EmptyMacroable;
}
public function testRegisterMacro()
{
$macroable = $this->macroable;
$macroable::ma... |
}
public function testRegisterMacroAndCallWithoutStatic()
{
$macroable = $this->macroable;
$macroable::macro(__CLASS__, function () {
return 'Taylor';
});
$this->assertSame('Taylor', $macroable->{__ | acroable = $this->macroable;
$macroable::macro('foo', function () {
return 'Taylor';
});
$this->assertTrue($macroable::hasMacro('foo'));
$this->assertFalse($macroable::hasMacro('bar')); | {
"filepath": "tests/Support/SupportMacroableTest.php",
"language": "php",
"file_size": 6074,
"cut_index": 716,
"middle_length": 229
} |
espace Illuminate\Tests\Support;
use Illuminate\Contracts\Foundation\MaintenanceMode as MaintenanceModeContract;
use Illuminate\Support\Facades\MaintenanceMode;
use Orchestra\Testbench\TestCase;
class SupportMaintenanceModeTest extends TestCase
{
public function testExtends()
{
MaintenanceMode::extend... | }
}
class TestMaintenanceMode implements MaintenanceModeContract
{
public function activate(array $payload): void
{
}
public function deactivate(): void
{
}
public function active(): bool
{
}
public function d | anceMode());
| {
"filepath": "tests/Support/SupportMaintenanceModeTest.php",
"language": "php",
"file_size": 819,
"cut_index": 522,
"middle_length": 14
} |
his->assertEquals(['bar'], $messages['foo']);
}
public function testMessagesAreAdded()
{
$container = new MessageBag;
$container->setFormat(':message');
$container->add('foo', 'bar');
$container->add('foo', 'baz');
$container->add('boom', 'bust');
$messages =... | 'foo', 'boom'], $container->keys());
}
public function testMessagesMayBeMerged()
{
$container = new MessageBag(['username' => ['foo']]);
$container->merge(['username' => ['bar']]);
$this->assertEquals(['username' => ['f |
$container = new MessageBag;
$container->setFormat(':message');
$container->add('foo', 'bar');
$container->add('foo', 'baz');
$container->add('boom', 'bust');
$this->assertEquals([ | {
"filepath": "tests/Support/SupportMessageBagTest.php",
"language": "php",
"file_size": 12470,
"cut_index": 921,
"middle_length": 229
} |
vents\MessageLogged;
use Illuminate\Log\Logger;
use Mockery as m;
use Monolog\Handler\TestHandler;
use Monolog\Level;
use Monolog\Logger as Monolog;
use PHPUnit\Framework\TestCase;
use RuntimeException;
class LogLoggerTest extends TestCase
{
public function testMethodsPassErrorAdditionsToMonolog()
{
$w... |
$monolog->shouldReceive('isHandling')->with('error')->andReturn(true);
$monolog->shouldReceive('error')->once()->with('foo', ['bar' => 'baz']);
$writer->error('foo');
}
public function testContextIsFlushed()
{
| oo', []);
$writer->error('foo');
}
public function testContextIsAddedToAllSubsequentLogs()
{
$writer = new Logger($monolog = m::mock(Monolog::class));
$writer->withContext(['bar' => 'baz']);
| {
"filepath": "tests/Log/LogLoggerTest.php",
"language": "php",
"file_size": 5618,
"cut_index": 716,
"middle_length": 229
} |
pace Illuminate\Tests\Support;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use function Illuminate\Support\enum_value;
include_once 'Enums.php';
class SupportEnumValueFunctionTest extends TestCase
{
#[DataProvider('scalarDataProvider')]
public function test_it_can_handle_e... | yield [TestBackedEnum::A, 1];
yield [TestBackedEnum::B, 2];
yield [TestStringBackedEnum::A, 'A'];
yield [TestStringBackedEnum::B, 'B'];
yield [null, null];
yield [0, 0];
yield ['0', '0'];
yield | is->assertSame('laravel', enum_value(null, 'laravel'));
$this->assertSame('laravel', enum_value(null, fn () => 'laravel'));
}
public static function scalarDataProvider()
{
yield [TestEnum::A, 'A'];
| {
"filepath": "tests/Support/SupportEnumValueFunctionTest.php",
"language": "php",
"file_size": 1325,
"cut_index": 524,
"middle_length": 229
} |
ents\CacheFlushed;
use Illuminate\Cache\Events\CacheFlushing;
use Illuminate\Cache\Events\CacheLocksFlushed;
use Illuminate\Cache\Events\CacheLocksFlushing;
use Illuminate\Cache\Events\CacheMissed;
use Illuminate\Cache\Events\RetrievingKey;
use Illuminate\Config\Repository as ConfigRepository;
use Illuminate\Container\... | vate $events;
protected function setUp(): void
{
parent::setUp();
$this->events = m::mock(Dispatcher::class);
$container = new Container;
$container->instance('events', $this->events);
$container->alias('e | Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Testing\Fakes\EventFake;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class SupportFacadesEventTest extends TestCase
{
pri | {
"filepath": "tests/Support/SupportFacadesEventTest.php",
"language": "php",
"file_size": 3852,
"cut_index": 614,
"middle_length": 229
} |
torGivenstdClass()
{
$array = ['name' => 'Taylor', 'age' => 25];
$fluent = new Fluent((object) $array);
$refl = new ReflectionObject($fluent);
$attributes = $refl->getProperty('attributes');
$this->assertEquals($array, $attributes->getValue($fluent));
$this->assertE... | $this->assertEquals($array, $fluent->getAttributes());
}
public function testGetMethodReturnsAttribute()
{
$fluent = new Fluent(['name' => 'Taylor']);
$this->assertSame('Taylor', $fluent->get('name'));
$this->a | ent = new Fluent(new FluentArrayIteratorStub($array));
$refl = new ReflectionObject($fluent);
$attributes = $refl->getProperty('attributes');
$this->assertEquals($array, $attributes->getValue($fluent));
| {
"filepath": "tests/Support/SupportFluentTest.php",
"language": "php",
"file_size": 19413,
"cut_index": 1331,
"middle_length": 229
} |
uminate\Bus\Queueable;
use Illuminate\Container\Container;
use Illuminate\Contracts\Queue\Factory as QueueContract;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Testing\Fakes\QueueFake;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class SupportFacadesQueueTes... | void
{
Queue::clearResolvedInstance();
Queue::setFacadeApplication(null);
parent::tearDown();
}
public function testFakeFor()
{
Queue::fakeFor(function () {
(new QueueForStub)->pushJob();
| = new Container;
$container->instance('queue', $this->queueManager);
$container->alias('queue', QueueContract::class);
Facade::setFacadeApplication($container);
}
protected function tearDown(): | {
"filepath": "tests/Support/SupportFacadesQueueTest.php",
"language": "php",
"file_size": 2884,
"cut_index": 563,
"middle_length": 229
} |
;
class SupportPluralizerTest extends TestCase
{
public function testBasicSingular()
{
$this->assertSame('child', Str::singular('children'));
}
public function testBasicPlural()
{
$this->assertSame('children', Str::plural('child'));
$this->assertSame('cod', Str::plural('cod... | SensitiveSingularPlural()
{
$this->assertSame('Children', Str::plural('Child'));
$this->assertSame('CHILDREN', Str::plural('CHILD'));
$this->assertSame('Tests', Str::plural('Test'));
$this->assertSame('children', Str::pl | ()
{
$this->assertSame('Child', Str::singular('Children'));
$this->assertSame('CHILD', Str::singular('CHILDREN'));
$this->assertSame('Test', Str::singular('Tests'));
}
public function testCase | {
"filepath": "tests/Support/SupportPluralizerTest.php",
"language": "php",
"file_size": 4433,
"cut_index": 614,
"middle_length": 229
} |
ServiceProvider::$publishes = [];
ServiceProvider::$publishGroups = [];
$this->app = $app = m::mock(Application::class)->makePartial();
$config = m::mock(Config::class)->makePartial();
$config = new Config();
$app->instance('config', $config);
$config->set('databas... | ction testPublishableServiceProviders()
{
$toPublish = ServiceProvider::publishableProviders();
$expected = [
ServiceProviderForTestingOne::class,
ServiceProviderForTestingTwo::class,
];
$this->as | boot();
}
protected function tearDown(): void
{
if (isset($this->tempFile) && file_exists($this->tempFile)) {
@unlink($this->tempFile);
}
parent::tearDown();
}
public fun | {
"filepath": "tests/Support/SupportServiceProviderTest.php",
"language": "php",
"file_size": 12334,
"cut_index": 921,
"middle_length": 229
} |
ue($this->stringable('Hello, Laravel!')->isMatch('/^.*$(.*)/'));
$this->assertTrue($this->stringable('Hello, Laravel!')->isMatch('/laravel/i'));
$this->assertTrue($this->stringable('Hello, Laravel!')->isMatch('/^(.*(.*(.*)))/'));
$this->assertFalse($this->stringable('Hello, Laravel!')->isMatch(... | tringable('Hello, Laravel!')->isMatch(['/^laravel!/i', '/^.*$(.*)/']));
$this->assertTrue($this->stringable('Hello, Laravel!')->isMatch(['/laravel/i', '/laravel!(.*)/']));
$this->assertTrue($this->stringable('Hello, Laravel!')->isMatch(['/^ | );
$this->assertFalse($this->stringable('Hello, Laravel!')->isMatch('/^[a-zA-Z,!]+$/'));
$this->assertTrue($this->stringable('Hello, Laravel!')->isMatch(['/.*,.*!/', '/H.o/']));
$this->assertTrue($this->s | {
"filepath": "tests/Support/SupportStringableTest.php",
"language": "php",
"file_size": 81443,
"cut_index": 3790,
"middle_length": 229
} |
dispatch(new BusJobStub);
$this->fake->assertDispatched(BusJobStub::class);
}
public function testAssertDispatchedWithClosure()
{
$this->fake->dispatch(new BusJobStub);
$this->fake->assertDispatched(function (BusJobStub $job) {
return true;
});
}
publi... | dispatchAfterResponse(new BusJobStub);
$this->fake->assertDispatchedAfterResponse(BusJobStub::class);
}
public function testAssertDispatchedAfterResponseClosure()
{
try {
$this->fake->assertDispatchedAfterResponse( | ationFailedException $e) {
$this->assertStringContainsString('The expected [Illuminate\Tests\Support\BusJobStub] job was not dispatched after sending the response.', $e->getMessage());
}
$this->fake-> | {
"filepath": "tests/Support/SupportTestingBusFakeTest.php",
"language": "php",
"file_size": 37560,
"cut_index": 2151,
"middle_length": 229
} |
use PHPUnit\Framework\TestCase;
class SupportTestingEventFakeTest extends TestCase
{
protected $fake;
protected function setUp(): void
{
parent::setUp();
$this->fake = new EventFake(m::mock(Dispatcher::class));
}
public function testAssertDispatched()
{
try {
... | tAssertDispatchedWithClosure()
{
$this->fake->dispatch(new EventStub);
$this->fake->assertDispatched(function (EventStub $event) {
return true;
});
}
public function testAssertListening()
{
$lis | luminate\Tests\Support\EventStub] event was not dispatched.', $e->getMessage());
}
$this->fake->dispatch(EventStub::class);
$this->fake->assertDispatched(EventStub::class);
}
public function tes | {
"filepath": "tests/Support/SupportTestingEventFakeTest.php",
"language": "php",
"file_size": 5415,
"cut_index": 716,
"middle_length": 229
} |
ssertPushed()
{
try {
$this->fake->assertPushed(JobStub::class);
$this->fail();
} catch (ExpectationFailedException $e) {
$this->assertStringContainsString('The expected [Illuminate\Tests\Support\JobStub] job was not pushed.', $e->getMessage());
}
... | $this->assertSame(['foo' => 'bar'], $data);
}
public function testAssertPushedWithIgnore()
{
$job = new JobStub;
$manager = m::mock(QueueManager::class);
$manager->shouldReceive('push')->once()->withArgs(function ($p | ake->push(JobStub::class, ['foo' => 'bar'], 'redis');
$this->fake->assertPushed(JobStub::class, function ($job, $queue, $jobData) use (&$data) {
$data = $jobData;
return true;
});
| {
"filepath": "tests/Support/SupportTestingQueueFakeTest.php",
"language": "php",
"file_size": 19532,
"cut_index": 1331,
"middle_length": 229
} |
uminate\Support\HtmlString;
use PHPUnit\Framework\TestCase;
class SupportHtmlStringTest extends TestCase
{
public function testToHtml(): void
{
// Check if HtmlString correctly converts a basic HTML string
$str = '<h1>foo</h1>';
$html = new HtmlString('<h1>foo</h1>');
$this->ass... | ankSpaces = '<h1>foo </h1> ';
$html = new HtmlString('<h1>foo </h1> ');
$this->assertEquals($endsWithBlankSpaces, $html->toHtml());
// Check if HtmlString correctly handles an empty string
$emptyHtml = new H | html = new HtmlString(' <h1> foo</h1>');
$this->assertEquals($startWithBlankSpaces, $html->toHtml());
// Check if HtmlString correctly preserves trailing blank spaces in the HTML string
$endsWithBl | {
"filepath": "tests/Support/SupportHtmlStringTest.php",
"language": "php",
"file_size": 2351,
"cut_index": 563,
"middle_length": 229
} |
tion testCanCreateEmptyCollection()
{
$this->assertSame([], LazyCollection::make()->all());
$this->assertSame([], LazyCollection::empty()->all());
}
public function testCanCreateCollectionFromArray()
{
$array = [1, 2, 3];
$data = LazyCollection::make($array);
$... | 'a' => 1, 'b' => 2, 'c' => 3];
$data = LazyCollection::make(Collection::make($array));
$this->assertSame($array, $data->all());
}
public function testCanCreateCollectionFromGeneratorFunction()
{
$data = LazyCollection |
public function testCanCreateCollectionFromArrayable()
{
$array = [1, 2, 3];
$data = LazyCollection::make(Collection::make($array));
$this->assertSame($array, $data->all());
$array = [ | {
"filepath": "tests/Support/SupportLazyCollectionTest.php",
"language": "php",
"file_size": 15381,
"cut_index": 921,
"middle_length": 229
} |
hp
namespace Illuminate\Tests\Support;
use Illuminate\Mail\Mailable;
use Illuminate\Support\Facades\Mail;
use Orchestra\Testbench\TestCase;
class SupportMailTest extends TestCase
{
public function testItRegisterAndCallMacros()
{
Mail::macro('test', fn (string $str) => $str === 'foo'
? 'it... | tEmailSent()
{
Mail::fake();
Mail::assertNothingSent();
Mail::to('hello@laravel.com')->send(new TestMail());
Mail::assertSent(TestMail::class);
}
}
class TestMail extends Mailable
{
/**
* Build the messag | ::macro('test', fn (string $str) => $str === 'foo'
? 'it works!'
: 'it failed.',
);
Mail::fake();
$this->assertSame('it works!', Mail::test('foo'));
}
public function tes | {
"filepath": "tests/Support/SupportMailTest.php",
"language": "php",
"file_size": 1117,
"cut_index": 515,
"middle_length": 229
} |
namespace Illuminate\Tests\Console\Fixtures;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\PromptsForMissingInput;
use Laravel\Prompts\Prompt;
use Laravel\Prompts\TextPrompt;
use Symfony\Component\Console\Input\InputInterface;
class FakeCommandWithInputPrompting extends Command implements Prompts... | mpt::interactive(true);
Prompt::fallbackWhen(true);
TextPrompt::fallbackUsing(function () {
$this->prompted = true;
return 'foo';
});
}
public function handle(): int
{
return self::SUCC | {
Pro | {
"filepath": "tests/Console/Fixtures/FakeCommandWithInputPrompting.php",
"language": "php",
"file_size": 800,
"cut_index": 517,
"middle_length": 14
} |
e Mockery as m;
use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use stdClass;
class SupportFacadeTest extends TestCase
{
protected function setUp(): void
{
Facade::clearResolvedInstances();
FacadeStub::setFacadeApplication(null);
}
public function testFacadeCallsUnderlyingAp... | ibutes(['foo' => new stdClass]);
FacadeStub::setFacadeApplication($app);
$this->assertInstanceOf(MockInterface::class, $mock = FacadeStub::shouldReceive('foo')->once()->with('bar')->andReturn('baz')->getMock());
$this->assertSame(' | FacadeStub::setFacadeApplication($app);
$this->assertSame('baz', FacadeStub::bar());
}
public function testShouldReceiveReturnsAMockeryMock()
{
$app = new ApplicationStub;
$app->setAttr | {
"filepath": "tests/Support/SupportFacadeTest.php",
"language": "php",
"file_size": 4835,
"cut_index": 614,
"middle_length": 229
} |
use Illuminate\Support\Testing\Fakes\MailFake;
use Illuminate\Support\Testing\Fakes\PendingMailFake;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
class SupportReflectorTest extends TestCase
{
public function testGetClassName()
{
$method = (new ReflectionClass(PendingMailFake::class))->getMethod... | w ReflectionClass(BusFake::class))->getMethod('dispatchedAfterResponse');
$this->assertNull(Reflector::getParameterClassName($method->getParameters()[0]));
}
public function testSelfClassName()
{
$method = (new ReflectionClass | ew ReflectionClass(MailFake::class))->getMethod('assertSent');
$this->assertNull(Reflector::getParameterClassName($method->getParameters()[0]));
}
public function testStringTypeName()
{
$method = (ne | {
"filepath": "tests/Support/SupportReflectorTest.php",
"language": "php",
"file_size": 6786,
"cut_index": 716,
"middle_length": 229
} |
t\Framework\TestCase;
use RuntimeException;
class SupportReflectsClosuresTest extends TestCase
{
public function testReflectsClosures()
{
$this->assertParameterTypes([ExampleParameter::class], function (ExampleParameter $one) {
// assert the Closure isn't actually executed
throw... | , function (string $one, ?ExampleParameter $two) {
//
});
// Because the parameter is variadic, the closure will always receive an array.
$this->assertParameterTypes([null], function (ExampleParameter ...$vars) {
| //
});
$this->assertParameterTypes([null, ExampleParameter::class], function ($one, ?ExampleParameter $two = null) {
//
});
$this->assertParameterTypes([null, ExampleParameter::class] | {
"filepath": "tests/Support/SupportReflectsClosuresTest.php",
"language": "php",
"file_size": 3540,
"cut_index": 614,
"middle_length": 229
} |
/**
* @var \Mockery
*/
private $mailManager;
/**
* @var \Illuminate\Support\Testing\Fakes\MailFake
*/
private $fake;
/**
* @var \Illuminate\Tests\Support\MailableStub
*/
private $mailable;
protected function setUp(): void
{
parent::setUp();
... | } catch (ExpectationFailedException $e) {
$this->assertStringContainsString('The expected [Illuminate\Tests\Support\MailableStub] mailable was not sent.', $e->getMessage());
}
$this->fake->to('taylor@laravel.com')->send | = new MailFake($this->mailManager);
$this->mailable = new MailableStub;
}
public function testAssertSent()
{
try {
$this->fake->assertSent(MailableStub::class);
$this->fail();
| {
"filepath": "tests/Support/SupportTestingMailFakeTest.php",
"language": "php",
"file_size": 16034,
"cut_index": 921,
"middle_length": 229
} |
Illuminate\Tests\Support\Fixtures\IntBackedEnum;
use Illuminate\Tests\Support\Fixtures\StringBackedEnum;
use JsonSerializable;
use PHPUnit\Framework\TestCase;
class SupportJsTest extends TestCase
{
public function testScalars()
{
$this->assertSame('false', (string) Js::from(false));
$this->ass... | his->assertSame("'Hèlló world'", (string) Js::from('Hèlló world'));
$this->assertSame(
"'\\u003Cdiv class=\\u0022foo\\u0022\\u003E\\u0027quoted html\\u0027\\u003C\\/div\\u003E'",
(string) Js::from('<div class="foo">\'quoted | g) Js::from([]));
$this->assertSame('[]', (string) Js::from(collect()));
$this->assertSame('null', (string) Js::from(null));
$this->assertSame("'Hello world'", (string) Js::from('Hello world'));
$t | {
"filepath": "tests/Support/SupportJsTest.php",
"language": "php",
"file_size": 6379,
"cut_index": 716,
"middle_length": 229
} |
pace Illuminate\Tests\Support;
use Illuminate\Support\NamespacedItemResolver;
use PHPUnit\Framework\TestCase;
class SupportNamespacedItemResolverTest extends TestCase
{
public function testResolution()
{
$r = new NamespacedItemResolver;
$this->assertEquals(['foo', 'bar', 'baz'], $r->parseKey(... | egments'])->getMock();
$r->setParsedKey('foo.bar', ['foo']);
$r->expects($this->never())->method('parseBasicSegments');
$r->expects($this->never())->method('parseNamespacedSegments');
$this->assertEquals(['foo'], $r->parseK | Equals([null, 'bar', null], $r->parseKey('bar'));
}
public function testParsedItemsAreCached()
{
$r = $this->getMockBuilder(NamespacedItemResolver::class)->onlyMethods(['parseBasicSegments', 'parseNamespacedS | {
"filepath": "tests/Support/SupportNamespacedItemResolverTest.php",
"language": "php",
"file_size": 1467,
"cut_index": 524,
"middle_length": 229
} |
uminate\Container\Container;
use Illuminate\Http\Client\Factory;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Http;
use PHPUnit\Framework\TestCase;
class SupportFacadesHttpTest extends TestCase
{
protected $app;
protected function setUp(): void
{
$this->app = new Container... | tory::class);
$this->assertSame('OK!', $factory->get('https://laravel.com')->body());
}
public function testFacadeRootIsSharedWhenFakedWithSequence(): void
{
Http::fakeSequence('laravel.com/*')->push('OK!');
$factory = | make(Factory::class));
}
public function testFacadeRootIsSharedWhenFaked(): void
{
Http::fake([
'https://laravel.com' => Http::response('OK!'),
]);
$factory = $this->app->make(Fac | {
"filepath": "tests/Support/SupportFacadesHttpTest.php",
"language": "php",
"file_size": 2374,
"cut_index": 563,
"middle_length": 229
} |
Foo Bar', Str::headline('fooBar'));
$this->assertSame('Foo Bar', Str::headline('foo_bar'));
$this->assertSame('Foo Bar Baz', Str::headline('foo-barBaz'));
$this->assertSame('Foo Bar Baz', Str::headline('foo-bar_baz'));
$this->assertSame('Öffentliche Überraschungen', Str::headline('öffen... | well 1984', Str::headline('orwell 1984'));
$this->assertSame('Orwell 1984', Str::headline('orwell 1984'));
$this->assertSame('Orwell 1984', Str::headline('-orwell-1984 -'));
$this->assertSame('Orwell 1984', Str::headline(' orwell_ | :headline('-öffentliche überraschungen'));
$this->assertSame('Sind Öde Und So', Str::headline('sindÖdeUndSo'));
$this->assertSame('❤ Multi Byte ☆', Str::headline('❤_multiByte-☆'));
$this->assertSame('Or | {
"filepath": "tests/Support/SupportStrTest.php",
"language": "php",
"file_size": 97401,
"cut_index": 3790,
"middle_length": 229
} |
e\Foundation\Auth\User;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Collection;
use Illuminate\Support\Testing\Fakes\NotificationFake;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;
class SupportTestingNotificati... | e;
$this->notification = new NotificationStub;
$this->user = new UserStub;
}
public function testAssertSentTo()
{
try {
$this->fake->assertSentTo($this->user, NotificationStub::class);
$this->fai | */
private $notification;
/**
* @var \Illuminate\Tests\Support\UserStub
*/
private $user;
protected function setUp(): void
{
parent::setUp();
$this->fake = new NotificationFak | {
"filepath": "tests/Support/SupportTestingNotificationFakeTest.php",
"language": "php",
"file_size": 8399,
"cut_index": 716,
"middle_length": 229
} |
uminate\Support\Optional;
use PHPUnit\Framework\TestCase;
use stdClass;
class SupportOptionalTest extends TestCase
{
public function testGetExistItemOnObject()
{
$expected = 'test';
$targetObj = new stdClass;
$targetObj->item = $expected;
$optional = new Optional($targetObj);
... | ;
$this->assertTrue(isset($optional->item));
}
public function testIssetNotExistItemOnObject()
{
$targetObj = new stdClass;
$optional = new Optional($targetObj);
$this->assertFalse(isset($optional->item));
| argetObj);
$this->assertNull($optional->item);
}
public function testIssetExistItemOnObject()
{
$targetObj = new stdClass;
$targetObj->item = '';
$optional = new Optional($targetObj) | {
"filepath": "tests/Support/SupportOptionalTest.php",
"language": "php",
"file_size": 2202,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Support;
use Illuminate\Support\Traits\Tappable;
use PHPUnit\Framework\TestCase;
class SupportTappableTest extends TestCase
{
public function testTappableClassWithCallback()
{
$name = TappableClass::make()->tap(function ($tappable) {
$tappable->setName('MyName');
})->getNa... | thNoneInvokableClass()
{
$this->expectException('Error');
$name = TappableClass::make()->tap(new class
{
public function setName($tappable)
{
$tappable->setName('MyName');
}
| public function __invoke($tappable)
{
$tappable->setName('MyName');
}
})->getName();
$this->assertSame('MyName', $name);
}
public function testTappableClassWi | {
"filepath": "tests/Support/SupportTappableTest.php",
"language": "php",
"file_size": 1571,
"cut_index": 537,
"middle_length": 229
} |
));
$this->assertSame('100', Number::format(100));
$this->assertSame('100,000', Number::format(100000));
$this->assertSame('100,000.00', Number::format(100000, precision: 2));
$this->assertSame('100,000.12', Number::format(100000.123, precision: 2));
$this->assertSame('100,000.12... | 0.2));
$this->assertSame('0.20', Number::format(0.2, precision: 2));
$this->assertSame('0.123', Number::format(0.1234, maxPrecision: 3));
$this->assertSame('1.23', Number::format(1.23));
$this->assertSame('-1.23', Number::fo | at(123456789));
$this->assertSame('-1', Number::format(-1));
$this->assertSame('-10', Number::format(-10));
$this->assertSame('-25', Number::format(-25));
$this->assertSame('0.2', Number::format( | {
"filepath": "tests/Support/SupportNumberTest.php",
"language": "php",
"file_size": 19423,
"cut_index": 1331,
"middle_length": 229
} |
piler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('exists')->once()->with(__DIR__.'/'.hash('xxh128', 'v2foo').'.php')->andReturn(false);
$this->assertTrue($compiler->isExpired('foo'));
}
public function testCannotConstructWithBadCachePath()
{
$this->expectException(I... | p')->andReturn(true);
$files->shouldReceive('lastModified')->once()->with('foo')->andReturn(100);
$files->shouldReceive('lastModified')->once()->with(__DIR__.'/'.hash('xxh128', 'v2foo').'.php')->andReturn(0);
$this->assertTrue($comp | stIsExpiredReturnsTrueWhenModificationTimesWarrant()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('exists')->once()->with(__DIR__.'/'.hash('xxh128', 'v2foo').'.ph | {
"filepath": "tests/View/ViewBladeCompilerTest.php",
"language": "php",
"file_size": 14672,
"cut_index": 921,
"middle_length": 229
} |
hp
namespace Illuminate\Tests\View\Blade;
class BladeJsTest extends AbstractBladeTestCase
{
public function testStatementIsCompiledWithoutAnyOptions()
{
$string = '<div x-data="@js($data)"></div>';
$expected = '<div x-data="<?php echo \Illuminate\Support\Js::from($data)->toHtml() ?>"></div>';
... |
public function testEncodingDepthCanBeSet()
{
$string = '<div x-data="@js($data, JSON_FORCE_OBJECT, 256)"></div>';
$expected = '<div x-data="<?php echo \Illuminate\Support\Js::from($data, JSON_FORCE_OBJECT, 256)->toHtml() ?>"></di | _OBJECT)"></div>';
$expected = '<div x-data="<?php echo \Illuminate\Support\Js::from($data, JSON_FORCE_OBJECT)->toHtml() ?>"></div>';
$this->assertEquals($expected, $this->compiler->compileString($string));
} | {
"filepath": "tests/View/Blade/BladeJsTest.php",
"language": "php",
"file_size": 1095,
"cut_index": 515,
"middle_length": 229
} |
set = true)';
$expected = '<?php ($set = true); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testStringWithParenthesisWithEndPHP()
{
$string = "@php(\$data = ['related_to' => 'issue#45388'];) {{ \$data }} @endphp";
$expected... | xpected = '<?php echo e("Ignore: @php"); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testPhpStatementsDontParseBladeCode()
{
$string = '@php echo "{{ This is a blade tag }}" @ | mentsWithoutExpressionAreIgnored()
{
$string = '@php';
$expected = '@php';
$this->assertEquals($expected, $this->compiler->compileString($string));
$string = '{{ "Ignore: @php" }}';
$e | {
"filepath": "tests/View/Blade/BladePhpStatementsTest.php",
"language": "php",
"file_size": 8712,
"cut_index": 716,
"middle_length": 229
} |
pace Illuminate\Tests\View\Blade;
use Illuminate\Support\Str;
class BladePrependTest extends AbstractBladeTestCase
{
public function testPrependIsCompiled()
{
$string = '@prepend(\'foo\')
bar
@endprepend';
$expected = '<?php $__env->startPrepend(\'foo\'); ?>
bar
<?php $__env->stopPrepend(); ?>... | assertEquals($expected, $this->compiler->compileString($string));
}
public function testPrependOnceIsCompiledWhenIdIsMissing()
{
Str::createUuidsUsing(fn () => 'e60e8f77-9ac3-4f71-9f8e-a044ef481d7f');
$string = '@prependOnce(\ | \')
test
@endPrependOnce';
$expected = '<?php if (! $__env->hasRenderedOnce(\'bar\')): $__env->markAsRenderedOnce(\'bar\');
$__env->startPrepend(\'foo\'); ?>
test
<?php $__env->stopPrepend(); endif; ?>';
$this-> | {
"filepath": "tests/View/Blade/BladePrependTest.php",
"language": "php",
"file_size": 1382,
"cut_index": 524,
"middle_length": 229
} |
Illuminate\View\ComponentAttributeBag;
class BladePropsTest extends AbstractBladeTestCase
{
public function testPropsAreCompiled()
{
$this->assertSame('<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;
$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extrac... | , \'two\' => \'string\']), \'is_string\', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
$$__key = $$__key ?? $__value;
}
$__defined_vars = get_defined_vars();
foreach ($attributes->all() as $__key => $__value) {
if (array_key_exists($__key, $__d | } else {
$__newAttributes[$__key] = $__value;
}
}
$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);
unset($__propNames);
unset($__newAttributes);
foreach (array_filter(([\'one\' => true | {
"filepath": "tests/View/Blade/BladePropsTest.php",
"language": "php",
"file_size": 2027,
"cut_index": 563,
"middle_length": 229
} |
s AbstractBladeTestCase
{
public function testPushIsCompiled()
{
$string = '@push(\'foo\')
test
@endpush';
$expected = '<?php $__env->startPush(\'foo\'); ?>
test
<?php $__env->stopPush(); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public func... | ed = '<?php if (! $__env->hasRenderedOnce(\'bar\')): $__env->markAsRenderedOnce(\'bar\');
$__env->startPush(\'foo\'); ?>
test
<?php $__env->stopPush(); endif; ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
| ; ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testPushOnceIsCompiled()
{
$string = '@pushOnce(\'foo\', \'bar\')
test
@endPushOnce';
$expect | {
"filepath": "tests/View/Blade/BladePushTest.php",
"language": "php",
"file_size": 3273,
"cut_index": 614,
"middle_length": 229
} |
php
namespace Illuminate\Tests\View\Blade;
class BladeSessionTest extends AbstractBladeTestCase
{
public function testSessionsAreCompiled()
{
$string = '
@session(\'status\')
<span>{{ $value }}</span>
@endsession';
$expected = '
<?php $__sessionArgs = [\'status\'];
if (session()->has($__se... | $value = array_pop($__sessionPrevious); }
if (isset($__sessionPrevious) && empty($__sessionPrevious)) { unset($__sessionPrevious); }
endif;
unset($__sessionArgs); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
| __sessionPrevious) && !empty($__sessionPrevious)) { | {
"filepath": "tests/View/Blade/BladeSessionTest.php",
"language": "php",
"file_size": 824,
"cut_index": 514,
"middle_length": 52
} |
\SomeClass as Foo; ?> bar";
$string = "Foo @use('SomeNamespace\SomeClass', 'Foo') bar";
$this->assertEquals($expected, $this->compiler->compileString($string));
$string = "Foo @use(SomeNamespace\SomeClass, Foo) bar";
$this->assertEquals($expected, $this->compiler->compileString($string... | string));
}
public function testUseStatementsWithBackslashAtBeginningAreCompiled()
{
$expected = "Foo <?php use \SomeNamespace\SomeClass; ?> bar";
$string = "Foo @use('\SomeNamespace\SomeClass') bar";
$this->assertEqua | omeClass') bar";
$this->assertEquals($expected, $this->compiler->compileString($string));
$string = "Foo @use(SomeNamespace\SomeClass) bar";
$this->assertEquals($expected, $this->compiler->compileString($ | {
"filepath": "tests/View/Blade/BladeUseTest.php",
"language": "php",
"file_size": 5677,
"cut_index": 716,
"middle_length": 229
} |
public function testVerbatimBlocksAreCompiled()
{
$string = '@verbatim {{ $a }} @if($b) {{ $b }} @endif @endverbatim';
$expected = ' {{ $a }} @if($b) {{ $b }} @endif ';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testVerbatimBlocks... | }} @endverbatim {{ $b }} @verbatim {{ $c }} @endverbatim';
$expected = ' {{ $a }} <?php echo e($b); ?> {{ $c }} ';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testRawBlocksAreRendere | @if($b)
{{ $b }}
@endif
';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testMultipleVerbatimBlocksAreCompiled()
{
$string = '@verbatim {{ $a | {
"filepath": "tests/View/Blade/BladeVerbatimTest.php",
"language": "php",
"file_size": 3105,
"cut_index": 614,
"middle_length": 229
} |
;
use Illuminate\View\Concerns\ManagesStacks;
use PHPUnit\Framework\TestCase;
class ManagesStacksTest extends TestCase
{
public function testStackIsEmpty()
{
$this->assertTrue((new FakeViewFactory)->isStackEmpty('my-stack'));
}
public function testStackIsNotEmptyWithPushedContent()
{
... | $object = new FakeViewFactory;
$object->startPrepend('my-stack', 'some prepended content');
$this->assertFalse($object->isStackEmpty('my-stack'));
}
}
class FakeViewFactory
{
use ManagesStacks;
protected int $renderCount = 0 | tStackIsNotEmptyWithPrependedContent()
{
| {
"filepath": "tests/View/Concerns/ManagesStacksTest.php",
"language": "php",
"file_size": 871,
"cut_index": 559,
"middle_length": 52
} |
er->addPath(__DIR__.'/another');
$files->shouldReceive('exists')->once()->with(__DIR__.'/en/messages.php')->andReturn(true);
$files->shouldReceive('getRequire')->once()->with(__DIR__.'/en/messages.php')->andReturn(['foo' => 'bar']);
$files->shouldReceive('exists')->once()->with(__DIR__.'/anoth... | ileLoader($files, __DIR__);
$loader->addPath(__DIR__.'/missing');
$files->shouldReceive('exists')->once()->with(__DIR__.'/en/messages.php')->andReturn(true);
$files->shouldReceive('getRequire')->once()->with(__DIR__.'/en/messages.p | ertEquals(['foo' => 'bar', 'baz' => 'backagesplash'], $loader->load('en', 'messages'));
}
public function testLoadMethodHandlesMissingAddedPath()
{
$files = m::mock(Filesystem::class);
$loader = new F | {
"filepath": "tests/Translation/TranslationFileLoaderTest.php",
"language": "php",
"file_size": 12775,
"cut_index": 921,
"middle_length": 229
} |
t\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class TranslationMessageSelectorTest extends TestCase
{
#[DataProvider('chooseTestData')]
public function testChoose($expected, $id, $number)
{
$selector = new MessageSelector;
$this->assertEquals($expected, $selector->ch... | , 0.5, 'en'));
}
public static function chooseTestData()
{
return [
['first', 'first', 1],
['first', 'first', 10],
['first', 'first|second', 1],
['second', 'first|second', 10],
| ->choose('{0} zero|{1} one|[2,*] many', 2.75, 'pl'));
}
public function testChoosePluralizesFloats()
{
$selector = new MessageSelector;
$this->assertSame('plural', $selector->choose('singular|plural' | {
"filepath": "tests/Translation/TranslationMessageSelectorTest.php",
"language": "php",
"file_size": 4164,
"cut_index": 614,
"middle_length": 229
} |
$this->assertFalse($t->has('foo', 'bar'));
$t = $this->getMockBuilder(Translator::class)->onlyMethods(['get'])->setConstructorArgs([$this->getLoader(), 'en', 'sp'])->getMock();
$t->expects($this->once())->method('get')->with('foo', [], 'bar')->willReturn('bar');
$this->assertTrue($t->has('... | oader(), 'en'])->getMock();
$t->expects($this->once())->method('get')->with('foo', [], 'bar', false)->willReturn('foo');
$this->assertFalse($t->hasForLocale('foo', 'bar'));
$t = new Translator($this->getLoader(), 'en');
$t- | od('get')->with('foo', [], 'bar', false)->willReturn('bar');
$this->assertTrue($t->hasForLocale('foo', 'bar'));
$t = $this->getMockBuilder(Translator::class)->onlyMethods(['get'])->setConstructorArgs([$this->getL | {
"filepath": "tests/Translation/TranslationTranslatorTest.php",
"language": "php",
"file_size": 19182,
"cut_index": 1331,
"middle_length": 229
} |
inate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use PHPUnit\Framework\TestCase;
class BeforeCommitContractTest extends TestCase
{
public function testJobWithoutContractRespectsBeforeCommit()
{
... | {
use Dispatchable, InteractsWithQueue, Queueable;
public function afterCommit()
{
$this->afterCommit = true;
return $this;
}
};
$job->afterCommit();
|
return $this;
}
};
$this->assertFalse($this->shouldDispatchAfterCommit($job));
}
public function testJobWithoutContractRespectsAfterCommit()
{
$job = new class
| {
"filepath": "tests/Queue/BeforeCommitContractTest.php",
"language": "php",
"file_size": 2663,
"cut_index": 563,
"middle_length": 229
} |
protected $db;
protected $provider;
protected function setUp(): void
{
parent::setUp();
$this->createDatabaseWithFailedJobTable()
->createProvider();
}
public function testCanGetAllFailedJobIds()
{
$this->assertEmpty($this->provider->ids());
arra... | ));
$this->assertSame(3, $this->provider->all()[1]->id);
$this->assertSame('default', $this->provider->all()[1]->queue);
}
public function testCanRetrieveFailedJobsById()
{
array_map(fn () => $this->createFailedJobsReco | public function testCanGetAllFailedJobs()
{
$this->assertEmpty($this->provider->all());
array_map(fn () => $this->createFailedJobsRecord(), range(1, 4));
$this->assertCount(4, $this->provider->all( | {
"filepath": "tests/Queue/DatabaseFailedJobProviderTest.php",
"language": "php",
"file_size": 9660,
"cut_index": 921,
"middle_length": 229
} |
\Support\Carbon;
use Illuminate\Support\Str;
use PHPUnit\Framework\TestCase;
use RuntimeException;
class DatabaseUuidFailedJobProviderTest extends TestCase
{
public function testGettingIdsOfAllFailedJobs()
{
$provider = $this->getFailedJobProvider();
$provider->log('connection-1', 'queue-1', j... | d-1', 'uuid-2', 'uuid-3', 'uuid-4'], $provider->ids());
$this->assertSame(['uuid-1', 'uuid-2'], $provider->ids('queue-1'));
$this->assertSame(['uuid-3', 'uuid-4'], $provider->ids('queue-2'));
}
public function testGettingAllFailedJ | 'connection-2', 'queue-2', json_encode(['uuid' => 'uuid-3']), new RuntimeException());
$provider->log('connection-2', 'queue-2', json_encode(['uuid' => 'uuid-4']), new RuntimeException());
$this->assertSame(['uui | {
"filepath": "tests/Queue/DatabaseUuidFailedJobProviderTest.php",
"language": "php",
"file_size": 8602,
"cut_index": 716,
"middle_length": 229
} |
minate\Support\Carbon;
use Illuminate\Support\Str;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class DynamoDbFailedJobProviderTest extends TestCase
{
public function testCanProperlyLogFailedJob()
{
$uuid = Str::orderedUuid();
Str::createUuidsUsing(function () use ($uuid) {
re... | 'connection' => ['S' => 'connection'],
'queue' => ['S' => 'queue'],
'payload' => ['S' => json_encode(['uuid' => (string) $uuid])],
'exception' => ['S' => (string) $exception],
' | $dynamoDbClient->shouldReceive('putItem')->once()->with([
'TableName' => 'table',
'Item' => [
'application' => ['S' => 'application'],
'uuid' => ['S' => (string) $uuid],
| {
"filepath": "tests/Queue/DynamoDbFailedJobProviderTest.php",
"language": "php",
"file_size": 5684,
"cut_index": 716,
"middle_length": 229
} |
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\CallQueuedHandler;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Jobs\FakeJob;
use Illuminate\Queue\Middleware\FailOnException;
use InvalidArgumentException;
use LogicException;
use Orchestra\Te... | ublic static function middlewareDataProvider(): array
{
return [
'exception is in list' => [
InvalidArgumentException::class,
new FailOnException([InvalidArgumentException::class]),
tr | function setUp(): void
{
parent::setUp();
FailOnExceptionMiddlewareTestJob::$_middleware = [];
}
/**
* @return array<string, array{class-string<\Throwable>, FailOnException, bool}>
*/
p | {
"filepath": "tests/Queue/FailOnExceptionMiddlewareTest.php",
"language": "php",
"file_size": 3446,
"cut_index": 614,
"middle_length": 229
} |
namespace Illuminate\Tests\Queue;
use Illuminate\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Queue\FailoverQueue;
use Illuminate\Queue\QueueManager;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class FailoverQueueTest extends TestCase
{
protected function tearDown(): void... | ('stdClass'),
);
$queue->shouldReceive('connection')->once()->with('sync')->andReturn(
$sync = m::mock('stdClass'),
);
$events->shouldReceive('dispatch')->once();
$redis->shouldReceive('push')->once()- | :mock(QueueManager::class), $events = m::mock(Dispatcher::class), [
'redis',
'sync',
]);
$queue->shouldReceive('connection')->once()->with('redis')->andReturn(
$redis = m::mock | {
"filepath": "tests/Queue/FailoverQueueTest.php",
"language": "php",
"file_size": 1175,
"cut_index": 518,
"middle_length": 229
} |
s FileFailedJobProviderTest extends TestCase
{
protected $path;
protected $provider;
protected function setUp(): void
{
$this->path = @tempnam('tmp', 'file_failed_job_provider_test');
$this->provider = new FileFailedJobProvider($this->path);
}
public function testCanLogFailedJ... |
'failed_at' => $failedJobs[0]->failed_at,
'failed_at_timestamp' => $failedJobs[0]->failed_at_timestamp,
],
], $failedJobs);
}
public function testCanRetrieveAllFailedJobs()
{
try {
| uid,
'connection' => 'connection',
'queue' => 'queue',
'payload' => json_encode(['uuid' => $uuid]),
'exception' => (string) mb_convert_encoding($exception, 'UTF-8'), | {
"filepath": "tests/Queue/FileFailedJobProviderTest.php",
"language": "php",
"file_size": 7405,
"cut_index": 716,
"middle_length": 229
} |
inate\Foundation\Application;
use Illuminate\Queue\Console\ListFailedCommand;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
class ListFailedCommandTest extends TestCase
{
protected function tearDown(): void
... | (object) [
'id' => 'failed-job-id',
'connection' => 'redis',
'queue' => 'default',
'payload' => json_encode([
'job' => 'Illuminate\Queue\CallQueuedHandler@call',
| ue]);
$this->assertJson($output);
$this->assertJsonStringEqualsJsonString('[]', $output);
}
public function testItDisplaysFailedJobsAsJson()
{
$output = $this->runCommandWithFailedJobs([
| {
"filepath": "tests/Queue/ListFailedCommandTest.php",
"language": "php",
"file_size": 2267,
"cut_index": 563,
"middle_length": 229
} |
pace Illuminate\Tests\Queue;
use Illuminate\Bus\BatchRepository;
use Illuminate\Bus\DatabaseBatchRepository;
use Illuminate\Foundation\Application;
use Illuminate\Queue\Console\PruneBatchesCommand;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\C... | => 0]), new NullOutput());
$repo->shouldHaveReceived('pruneUnfinished')->once();
}
public function testAllowPruningAllCancelledBatches()
{
$container = new Application;
$container->instance(BatchRepository::class, $re | ainer->instance(BatchRepository::class, $repo = m::spy(DatabaseBatchRepository::class));
$command = new PruneBatchesCommand;
$command->setLaravel($container);
$command->run(new ArrayInput(['--unfinished' | {
"filepath": "tests/Queue/PruneBatchesCommandTest.php",
"language": "php",
"file_size": 1292,
"cut_index": 524,
"middle_length": 229
} |
te\Tests\Queue;
use Illuminate\Queue\Attributes\Connection;
use Illuminate\Queue\Attributes\Queue;
use PHPUnit\Framework\TestCase;
class QueueAttributesTest extends TestCase
{
public function test_queue_attribute_normalizes_backed_enum_to_string()
{
$attribute = new Queue(QueueAttributeBackedEnum::DEF... | , $attribute->queue);
}
public function test_connection_attribute_normalizes_backed_enum_to_string()
{
$attribute = new Connection(ConnectionAttributeBackedEnum::REDIS);
$this->assertSame('redis', $attribute->connection);
| ibuteUnitEnum::High);
$this->assertSame('High', $attribute->queue);
}
public function test_queue_attribute_keeps_string_as_string()
{
$attribute = new Queue('high');
$this->assertSame('high' | {
"filepath": "tests/Queue/QueueAttributesTest.php",
"language": "php",
"file_size": 1770,
"cut_index": 537,
"middle_length": 229
} |
inate\Contracts\Events\Dispatcher;
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Queue\Jobs\BeanstalkdJob;
use Illuminate\Queue\Jobs\Job;
use Mockery as m;
use Pheanstalk\Contract\JobIdInterface;
use Pheanstalk\Contract\PheanstalkManagerInterface;
use Pheanstalk\Contract\PheanstalkPublisherInterface;
use Pheans... | >shouldReceive('make')->once()->with('foo')->andReturn($handler = m::mock(stdClass::class));
$handler->shouldReceive('fire')->once()->with($job, ['data']);
$job->fire();
}
public function testFailProperlyCallsTheJobHandler()
{ | ireProperlyCallsTheJobHandler()
{
$job = $this->getJob();
$job->getPheanstalkJob()->shouldReceive('getData')->once()->andReturn(json_encode(['job' => 'foo', 'data' => ['data']]));
$job->getContainer()- | {
"filepath": "tests/Queue/QueueBeanstalkdJobTest.php",
"language": "php",
"file_size": 3134,
"cut_index": 614,
"middle_length": 229
} |
upport\Str;
use Mockery as m;
use Pheanstalk\Contract\JobIdInterface;
use Pheanstalk\Contract\PheanstalkManagerInterface;
use Pheanstalk\Contract\PheanstalkPublisherInterface;
use Pheanstalk\Contract\PheanstalkSubscriberInterface;
use Pheanstalk\Pheanstalk;
use Pheanstalk\Values\Job;
use Pheanstalk\Values\TubeList;
use... | uuid();
$time = Carbon::now();
Carbon::setTestNow($time);
Str::createUuidsUsing(function () use ($uuid) {
return $uuid;
});
$this->setQueue('default', 60);
$pheanstalk = $this->queue->getPheans | ;
/**
* @var \Illuminate\Container\Container|\Mockery\LegacyMockInterface|\Mockery\MockInterface
*/
private $container;
public function testPushProperlyPushesJobOntoBeanstalkd()
{
$uuid = Str:: | {
"filepath": "tests/Queue/QueueBeanstalkdQueueTest.php",
"language": "php",
"file_size": 5563,
"cut_index": 716,
"middle_length": 229
} |
ema\Blueprint;
use Illuminate\Events\Dispatcher;
use Illuminate\Queue\DatabaseQueue;
use Illuminate\Queue\Events\JobQueued;
use Illuminate\Queue\Events\JobQueueing;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use PHPUnit\Framework\TestCase;
class QueueDatabaseQueueIntegrationTest extends TestCase
{
... | );
$db->bootEloquent();
$db->setAsGlobal();
$this->table = 'jobs';
$this->queue = new DatabaseQueue($this->connection(), $this->table);
$this->container = new Container;
$this->container->instance('even | ntainer\Container
*/
protected $container;
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
] | {
"filepath": "tests/Queue/QueueDatabaseQueueIntegrationTest.php",
"language": "php",
"file_size": 8431,
"cut_index": 716,
"middle_length": 229
} |
ds(['currentTime'])->setConstructorArgs([$database = m::mock(Connection::class), 'table', 'default'])->getMock();
$queue->method('currentTime')->willReturn('time');
$queue->setContainer($container = m::spy(Container::class));
$database->shouldReceive('table')->with('table')->andReturn($query = m... | ring($jobStartsWith, $payload['job']);
$this->assertSame('default', $array['queue']);
$this->assertEquals(0, $array['attempts']);
$this->assertNull($array['reserved_at']);
$this->assertIsInt($array['availabl | on_decode($array['payload'], true);
$this->assertSame($uuid, $payload['uuid']);
$this->assertStringContainsString($displayNameStartsWith, $payload['displayName']);
$this->assertStringContainsSt | {
"filepath": "tests/Queue/QueueDatabaseQueueUnitTest.php",
"language": "php",
"file_size": 18104,
"cut_index": 1331,
"middle_length": 229
} |
;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Queue;
use Orchestra\Testbench\TestCase;
class QueueDelayTest extends TestCase
{
public function test_queue_delay()
{
Queue::fake();
$job = new TestJob;
dispatch($job);
$this->assertEquals(60, $job->... | ng_dispatch_without_delay()
{
Queue::fake();
$job = new TestJob;
dispatch($job)->withoutDelay();
$this->assertEquals(0, $job->delay);
}
}
class TestJob implements ShouldQueue
{
use Queueable;
public func | $job->delay);
}
public function test_pendi | {
"filepath": "tests/Queue/QueueDelayTest.php",
"language": "php",
"file_size": 949,
"cut_index": 582,
"middle_length": 52
} |
?php
namespace Illuminate\Tests\Queue;
use Illuminate\Queue\Jobs\RedisJob;
use Illuminate\Queue\MaxAttemptsExceededException;
use Illuminate\Queue\TimeoutExceededException;
use PHPUnit\Framework\TestCase;
class QueueExceptionTest extends TestCase
{
public function test_it_can_create_timeout_exception_for_job()
... | lyingJob has been attempted too many times.', $e->getMessage());
$this->assertSame($job, $e->job);
}
}
class MyFakeRedisJob extends RedisJob
{
public function __construct()
{
//
}
public function resolveName()
{
| ame($job, $e->job);
}
public function test_it_can_create_max_attempts_exception_for_job()
{
$e = MaxAttemptsExceededException::forJob($job = new MyFakeRedisJob());
$this->assertSame('App\\Jobs\\Under | {
"filepath": "tests/Queue/QueueExceptionTest.php",
"language": "php",
"file_size": 1047,
"cut_index": 513,
"middle_length": 229
} |
Options;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;
use function Illuminate\Support\artisan_binary;
use function Illuminate\Support\php_binary;
class QueueListenerTest extends TestCase
{
public function testRunProcessCallsProcess()
{
$process = m::mock(Pro... | houldReceive('run')->once();
$listener = m::mock(Listener::class)->makePartial();
$listener->shouldReceive('memoryExceeded')->once()->with(1)->andReturn(true);
$listener->shouldReceive('stop')->once();
$listener->runProcess | ce()->with(1)->andReturn(false);
$listener->runProcess($process, 1);
}
public function testListenerStopsWhenMemoryIsExceeded()
{
$process = m::mock(Process::class)->makePartial();
$process->s | {
"filepath": "tests/Queue/QueueListenerTest.php",
"language": "php",
"file_size": 4674,
"cut_index": 614,
"middle_length": 229
} |
gerTest extends TestCase
{
public function testDefaultConnectionCanBeResolved()
{
$app = [
'config' => [
'queue.default' => 'sync',
'queue.connections.sync' => ['driver' => 'sync'],
],
'encrypter' => $encrypter = m::mock(Encrypter::clas... | return $connector;
});
$queue->shouldReceive('setContainer')->once()->with($app);
$this->assertSame($queue, $manager->connection('sync'));
}
public function testOtherConnectionCanBeResolved()
{
$app = [
| nName')->once()->with('sync')->andReturnSelf();
$connector->shouldReceive('connect')->once()->with(['driver' => 'sync'])->andReturn($queue);
$manager->addConnector('sync', function () use ($connector) {
| {
"filepath": "tests/Queue/QueueManagerTest.php",
"language": "php",
"file_size": 5234,
"cut_index": 716,
"middle_length": 229
} |
ate\Queue\Events\QueuePaused;
use Illuminate\Queue\Events\QueueResumed;
use Illuminate\Queue\QueueManager;
use Illuminate\Support\Carbon;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class QueuePauseResumeTest extends TestCase
{
protected $manager;
protected $cache;
protected function setUp(): void
... | 'queue.connections.database' => ['driver' => 'database'],
],
'cache' => $cacheMock,
'events' => new Dispatcher(),
];
$this->manager = new QueueManager($app);
}
public function testPauseQueueW | cacheMock->shouldReceive('store')->andReturn($this->cache);
$app = [
'config' => [
'queue.default' => 'redis',
'queue.connections.redis' => ['driver' => 'redis'],
| {
"filepath": "tests/Queue/QueuePauseResumeTest.php",
"language": "php",
"file_size": 6420,
"cut_index": 716,
"middle_length": 229
} |
class ViewComponentTest extends TestCase
{
public function testDataExposure()
{
$component = new TestViewComponent;
$variables = $component->data();
$this->assertEquals(10, $variables['votes']);
$this->assertSame('world', $variables['hello']());
$this->assertSame('tayl... | public function goodbye()
{
return 'goodbye';
}
};
$data = $component->data();
$this->assertArrayHasKey('hello', $data);
$this->assertArrayNotHasKey('goodbye', $data);
| ed $except = ['goodbye'];
public function render()
{
return 'test';
}
public function hello()
{
return 'hello world';
}
| {
"filepath": "tests/View/ViewComponentTest.php",
"language": "php",
"file_size": 6967,
"cut_index": 716,
"middle_length": 229
} |
ider;
use PHPUnit\Framework\TestCase;
class ViewFileViewFinderTest extends TestCase
{
public function testBasicViewFinding()
{
$finder = $this->getFinder();
$finder->getFilesystem()->shouldReceive('exists')->once()->with(__DIR__.'/foo.blade.php')->andReturn(true);
$this->assertEquals(_... | $finder->find('foo'));
}
public function testDirectoryCascadingFileLoading()
{
$finder = $this->getFinder();
$finder->addLocation(__DIR__.'/nested');
$finder->getFilesystem()->shouldReceive('exists')->once()->with(__DI | e('exists')->once()->with(__DIR__.'/foo.blade.php')->andReturn(false);
$finder->getFilesystem()->shouldReceive('exists')->once()->with(__DIR__.'/foo.php')->andReturn(true);
$this->assertEquals(__DIR__.'/foo.php', | {
"filepath": "tests/View/ViewFileViewFinderTest.php",
"language": "php",
"file_size": 6405,
"cut_index": 716,
"middle_length": 229
} |
s BladeBoolTest extends AbstractBladeTestCase
{
public function testBool()
{
// For Javascript object{'isBool' : true}
$string = "{'isBool' : @bool(true)}";
$expected = "{'isBool' : <?php echo ((true) ? 'true' : 'false'); ?>}";
$this->assertEquals($expected, $this->compiler->comp... | 'text' x-show='<?php echo ((true) ? 'true' : 'false'); ?>' />";
$this->assertEquals($expected, $this->compiler->compileString($string));
// For Alpine.js x-show attribute
$string = "<input type='text' x-show='@bool(false)' />";
| ; ?>}";
$this->assertEquals($expected, $this->compiler->compileString($string));
// For Alpine.js x-show attribute
$string = "<input type='text' x-show='@bool(true)' />";
$expected = "<input type= | {
"filepath": "tests/View/Blade/BladeBoolTest.php",
"language": "php",
"file_size": 2309,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\View\Blade;
class BladeCheckedStatementsTest extends AbstractBladeTestCase
{
public function testSelectedStatementsAreCompiled()
{
$string = '<input @selected(name(foo(bar)))/>';
$expected = "<input <?php if(name(foo(bar))): echo 'selected'; endif; ?>/>";
$this->assertEquals($... | ring = '<button @disabled(name(foo(bar)))>Foo</button>';
$expected = "<button <?php if(name(foo(bar))): echo 'disabled'; endif; ?>>Foo</button>";
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public fu | = "<input <?php if(name(foo(bar))): echo 'checked'; endif; ?>/>";
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testDisabledStatementsAreCompiled()
{
$st | {
"filepath": "tests/View/Blade/BladeCheckedStatementsTest.php",
"language": "php",
"file_size": 1594,
"cut_index": 537,
"middle_length": 229
} |
onentAttributeBag;
use Mockery as m;
class BladeComponentsTest extends AbstractBladeTestCase
{
public function testComponentsAreCompiled()
{
$this->assertSame('<?php $__env->startComponent(\'foo\', ["foo" => "bar"]); ?>', $this->compiler->compileString('@component(\'foo\', ["foo" => "bar"])'));
... | 84e87f = $attributes; } ?>
<?php $component = Illuminate\Tests\View\Blade\ComponentStub::class::resolve(["foo" => "bar"] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component- | $this->assertSame(str_replace("\r\n", "\n", '<?php if (isset($component)) { $__componentOriginal2dda3d2f2f9b76bd400bf03f0b84e87f = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal2dda3d2f2f9b76bd400bf03f0b | {
"filepath": "tests/View/Blade/BladeComponentsTest.php",
"language": "php",
"file_size": 3644,
"cut_index": 614,
"middle_length": 229
} |
espace Illuminate\Tests\View\Blade;
class BladeContextTest extends AbstractBladeTestCase
{
public function testContextsAreCompiled()
{
$string = '
@context(\'foo\')
<span>{{ $value }}</span>
@endcontext';
$expected = '
<?php $__contextArgs = [\'foo\'];
if (context()->has($__contextArgs[0]))... | ($__contextPrevious)) { $value = array_pop($__contextPrevious); }
if (isset($__contextPrevious) && empty($__contextPrevious)) { unset($__contextPrevious); }
endif;
unset($__contextArgs); ?>';
$this->assertEquals($expected, $this->compiler->compile | ous) && !empty | {
"filepath": "tests/View/Blade/BladeContextTest.php",
"language": "php",
"file_size": 818,
"cut_index": 522,
"middle_length": 14
} |
inate\Support\Stringable;
use PHPUnit\Framework\Attributes\DataProvider;
class BladeEchoHandlerTest extends AbstractBladeTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->compiler->stringable(function (Fluent $object) {
return 'Hello World';
});
}
... | ?php \$__bladeCompiler = app('blade.compiler'); ?><?php echo \$__bladeCompiler->applyEchoHandler(\$exampleObject); ?>",
$this->compiler->compileString('{!!$exampleObject!!}')
);
}
public function testBladeHandlerCanInterceptEsc | pplyEchoHandler(\$exampleObject)); ?>",
$this->compiler->compileString('{{$exampleObject}}')
);
}
public function testBladeHandlerCanInterceptRawEchos()
{
$this->assertSame(
"< | {
"filepath": "tests/View/Blade/BladeEchoHandlerTest.php",
"language": "php",
"file_size": 4034,
"cut_index": 614,
"middle_length": 229
} |
Illuminate\Tests\View\Blade;
class BladeElseAuthStatementsTest extends AbstractBladeTestCase
{
public function testElseAuthStatementsAreCompiled()
{
$string = '@auth("api")
breeze
@elseauth("standard")
wheeze
@endauth';
$expected = '<?php if(auth()->guard("api")->check()): ?>
breeze
<?php elsei... | th("api")
breeze
@elseauth
wheeze
@endauth';
$expected = '<?php if(auth()->guard("api")->check()): ?>
breeze
<?php elseif(auth()->guard()->check()): ?>
wheeze
<?php endif; ?>';
$this->assertEquals($expected, $this->compiler->compileString($ | StatementsAreCompiled()
{
$string = '@au | {
"filepath": "tests/View/Blade/BladeElseAuthStatementsTest.php",
"language": "php",
"file_size": 855,
"cut_index": 529,
"middle_length": 52
} |
pace Illuminate\Tests\View\Blade;
class BladeErrorTest extends AbstractBladeTestCase
{
public function testErrorsAreCompiled()
{
$string = '
@error(\'email\')
<span>{{ $message }}</span>
@enderror';
$expected = '
<?php $__errorArgs = [\'email\'];
$__bag = $errors->getBag($__errorArgs[1] ?? ... | blic function testErrorsWithBagsAreCompiled()
{
$string = '
@error(\'email\', \'customBag\')
<span>{{ $message }}</span>
@enderror';
$expected = '
<?php $__errorArgs = [\'email\', \'customBag\'];
$__bag = $errors->getBag($__errorArg | an>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
pu | {
"filepath": "tests/View/Blade/BladeErrorTest.php",
"language": "php",
"file_size": 1432,
"cut_index": 524,
"middle_length": 229
} |
pace Illuminate\Tests\View\Blade;
class BladeEscapedTest extends AbstractBladeTestCase
{
public function testEscapedWithAtDirectivesAreCompiled()
{
$this->assertSame('@foreach', $this->compiler->compileString('@@foreach'));
$this->assertSame('@verbatim @continue @endverbatim', $this->compiler->... | blic function testNestedEscapes()
{
$template = '
@foreach($cols as $col)
@@foreach($issues as $issue_45915)
👋 سلام 👋
@@endforeach
@endforeach';
$compiled = '
<?php $__currentLoopData = $cols; $__env->addLoop($__currentL | nue @break', $this->compiler->compileString('@@continue @@break'));
$this->assertSame('@foreach(
$i as $x
)', $this->compiler->compileString('@@foreach(
$i as $x
)'));
}
pu | {
"filepath": "tests/View/Blade/BladeEscapedTest.php",
"language": "php",
"file_size": 1375,
"cut_index": 524,
"middle_length": 229
} |
?php
namespace Illuminate\Tests\View\Blade;
class BladeForStatementsTest extends AbstractBladeTestCase
{
public function testForStatementsAreCompiled()
{
$string = '@for ($i = 0; $i < 10; $i++)
test
@endfor';
$expected = '<?php for($i = 0; $i < 10; $i++): ?>
test
<?php endfor; ?>';
$th... | 20; $j++)
test
@endfor
@endfor';
$expected = '<?php for($i = 0; $i < 10; $i++): ?>
<?php for($j = 0; $j < 20; $j++): ?>
test
<?php endfor; ?>
<?php endfor; ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
} | ($j = 0; $j < | {
"filepath": "tests/View/Blade/BladeForStatementsTest.php",
"language": "php",
"file_size": 786,
"cut_index": 513,
"middle_length": 14
} |
use PHPUnit\Framework\Attributes\DataProvider;
class BladeForelseStatementsTest extends AbstractBladeTestCase
{
public function testForelseStatementsAreCompiled()
{
$string = '@forelse ($this->getUsers() as $user)
breeze
@empty
empty
@endforelse';
$expected = '<?php $__empty_1 = true; $__curre... | estForelseStatementsAreCompiledWithUppercaseSyntax()
{
$string = '@forelse ($this->getUsers() AS $user)
breeze
@empty
empty
@endforelse';
$expected = '<?php $__empty_1 = true; $__currentLoopData = $this->getUsers(); $__env->addLoop($__c |
breeze
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
empty
<?php endif; ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function t | {
"filepath": "tests/View/Blade/BladeForelseStatementsTest.php",
"language": "php",
"file_size": 3827,
"cut_index": 614,
"middle_length": 229
} |
Illuminate\Tests\View\Blade;
class BladeIfStatementsTest extends AbstractBladeTestCase
{
public function testIfStatementsAreCompiled()
{
$string = '@if (name(foo(bar)))
breeze
@endif';
$expected = '<?php if(name(foo(bar))): ?>
breeze
<?php endif; ?>';
$this->assertEquals($expected, $thi... | $expected = '<?php switch(true):
case (1): ?>
foo
<?php case (2): ?>
bar
<?php endswitch; ?>
foo
<?php switch(true):
case (1): ?>
foo
<?php case (2): ?>
bar
<?php endswitch; ?>';
$this->assertEquals($expected, $this->compiler->compileString($st | ue)
@case(1)
foo
@case(2)
bar
@endswitch';
| {
"filepath": "tests/View/Blade/BladeIfStatementsTest.php",
"language": "php",
"file_size": 853,
"cut_index": 529,
"middle_length": 52
} |
pace Illuminate\Tests\View\Blade;
class BladeInjectTest extends AbstractBladeTestCase
{
public function testDependenciesInjectedAsStringsAreCompiled()
{
$string = "Foo @inject('baz', 'SomeNamespace\SomeClass') bar";
$expected = "Foo <?php \$baz = app('SomeNamespace\SomeClass'); ?> bar";
... | public function testDependenciesAreCompiled()
{
$string = "Foo @inject('baz', SomeNamespace\SomeClass::class) bar";
$expected = "Foo <?php \$baz = app(SomeNamespace\SomeClass::class); ?> bar";
$this->assertEquals($expected, $ | tring = 'Foo @inject("baz", "SomeNamespace\SomeClass") bar';
$expected = 'Foo <?php $baz = app("SomeNamespace\SomeClass"); ?> bar';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
| {
"filepath": "tests/View/Blade/BladeInjectTest.php",
"language": "php",
"file_size": 1379,
"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.