prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
class ViewCompilerEngineTest extends TestCase
{
public function testViewsMayBeRecompiledAndRendered()
{
$engine = $this->getEngine();
$engine->getCompiler()->shouldReceive('getCompiledPath')->with(__DIR__.'/fixtures/foo.php')->andReturn(__DIR__.'/fixtures/basic.php');
$engine->getCompil... | gine();
$engine->getCompiler()->shouldReceive('getCompiledPath')->with(__DIR__.'/fixtures/foo.php')->andReturn(__DIR__.'/fixtures/basic.php');
$engine->getCompiler()->shouldReceive('isExpired')->once()->andReturn(false);
$engine->ge | );
$results = $engine->get(__DIR__.'/fixtures/foo.php');
$this->assertSame('Hello World
', $results);
}
public function testViewsAreNotRecompiledIfTheyAreNotExpired()
{
$engine = $this->getEn | {
"filepath": "tests/View/ViewCompilerEngineTest.php",
"language": "php",
"file_size": 9570,
"cut_index": 921,
"middle_length": 229
} |
view->getEngine());
$this->assertSame($_SERVER['__test.view'], $view);
unset($_SERVER['__test.view']);
}
public function testExistsPassesAndFailsViews()
{
$factory = $this->getFactory();
$factory->getFinder()->shouldReceive('find')->once()->with('foo')->andThrow(InvalidArgu... | nce('foo');
$this->assertTrue($factory->hasRenderedOnce('foo'));
$factory->flushState();
$this->assertFalse($factory->hasRenderedOnce('foo'));
}
public function testFirstCreatesNewViewInstanceWithProperPath()
{
| sertTrue($factory->exists('bar'));
}
public function testRenderingOnceChecks()
{
$factory = $this->getFactory();
$this->assertFalse($factory->hasRenderedOnce('foo'));
$factory->markAsRenderedO | {
"filepath": "tests/View/ViewFactoryTest.php",
"language": "php",
"file_size": 38988,
"cut_index": 2151,
"middle_length": 229
} |
ViewTest extends TestCase
{
public function testDataCanBeSetOnView()
{
$view = $this->getView();
$view->with('foo', 'bar');
$view->with(['baz' => 'boom']);
$this->assertEquals(['foo' => 'bar', 'baz' => 'boom'], $view->getData());
$view = $this->getView();
$view-... | etFactory()->shouldReceive('getShared')->once()->andReturn(['shared' => 'foo']);
$view->getEngine()->shouldReceive('get')->once()->with('path', ['foo' => 'bar', 'shared' => 'foo'])->andReturn('contents');
$view->getFactory()->shouldReceive( | ew = $this->getView(['foo' => 'bar']);
$view->getFactory()->shouldReceive('incrementRender')->once()->ordered();
$view->getFactory()->shouldReceive('callComposer')->once()->ordered()->with($view);
$view->g | {
"filepath": "tests/View/ViewTest.php",
"language": "php",
"file_size": 9458,
"cut_index": 921,
"middle_length": 229
} |
= $this->compiler()->compileSlots('<x-slot :name="$foo->name">
</x-slot>');
$this->assertSame(
"@slot(\$foo->name, null, []) \n".' @endslot',
str_replace("\r\n", "\n", trim($result))
);
}
public function testSlotsWithAttributesCanBeCompiled()
{
$this->mockVi... | mpiler()->compileSlots('<x-slot:foo class="font-bold">
</x-slot>');
$this->assertSame(
"@slot('foo', null, ['class' => 'font-bold']) \n".' @endslot',
str_replace("\r\n", "\n", trim($result))
);
}
public fun | -bold']) \n".' @endslot',
str_replace("\r\n", "\n", trim($result))
);
}
public function testInlineSlotsWithAttributesCanBeCompiled()
{
$this->mockViewFactory();
$result = $this->co | {
"filepath": "tests/View/Blade/BladeComponentTagCompilerTest.php",
"language": "php",
"file_size": 51706,
"cut_index": 2151,
"middle_length": 229
} |
$this->assertSame('<?php if($test): ?> <?php @show(\'test\'); ?> <?php endif; ?>', $this->compiler->compileString("@if(\$test) <?php @show('test'); ?> @endif"));
}
public function testMixingYieldAndEcho()
{
$this->assertSame('<?php echo $__env->yieldContent(\'title\'); ?> - <?php echo e(Config::get... |
$this->assertCount(0, $this->compiler->getCustomDirectives());
$this->compiler->directive('customControl', function ($expression) {
return "<?php echo custom_control({$expression}); ?>";
});
$this->assertCount(1 | mpiler->extend(function ($value) {
return str_replace('foo', 'bar', $value);
});
$this->assertSame('bar', $this->compiler->compileString('foo'));
}
public function testCustomStatements()
{ | {
"filepath": "tests/View/Blade/BladeCustomTest.php",
"language": "php",
"file_size": 8304,
"cut_index": 716,
"middle_length": 229
} |
public function testEchosAreCompiled()
{
$this->assertSame('<?php echo $name; ?>', $this->compiler->compileString('{!!$name!!}'));
$this->assertSame('<?php echo $name; ?>', $this->compiler->compileString('{!! $name !!}'));
$this->assertSame('<?php echo $name; ?>', $this->compiler->compileSt... | leString('{{
$name
}}'));
$this->assertSame("<?php echo e(\$name); ?>\n\n", $this->compiler->compileString("{{ \$name }}\n"));
$this->assertSame("<?php echo e(\$name); ?>\r\n\r\n", $this->compiler->compileString("{{ \$na | ; ?>', $this->compiler->compileString('{{$name}}'));
$this->assertSame('<?php echo e($name); ?>', $this->compiler->compileString('{{ $name }}'));
$this->assertSame('<?php echo e($name); ?>', $this->compiler->compi | {
"filepath": "tests/View/Blade/BladeEchoTest.php",
"language": "php",
"file_size": 3313,
"cut_index": 614,
"middle_length": 229
} |
pace Illuminate\Tests\View\Blade;
class BladeEnvironmentStatementsTest extends AbstractBladeTestCase
{
public function testEnvStatementsAreCompiled()
{
$string = "@env('staging')
breeze
@else
boom
@endenv";
$expected = "<?php if(app()->environment('staging')): ?>
breeze
<?php else: ?>
boom
<?ph... | , $this->compiler->compileString($string));
}
public function testEnvStatementsWithArrayParamAreCompiled()
{
$string = "@env(['staging', 'production'])
breeze
@else
boom
@endenv";
$expected = "<?php if(app()->environment(['stag | string = "@env('staging', 'production')
breeze
@else
boom
@endenv";
$expected = "<?php if(app()->environment('staging', 'production')): ?>
breeze
<?php else: ?>
boom
<?php endif; ?>";
$this->assertEquals($expected | {
"filepath": "tests/View/Blade/BladeEnvironmentStatementsTest.php",
"language": "php",
"file_size": 1500,
"cut_index": 524,
"middle_length": 229
} |
s BladeExtendsTest extends AbstractBladeTestCase
{
public function testExtendsAreCompiled()
{
$string = "@extends('foo')\ntest";
$expected = "test\n".'<?php echo $__env->make(\'foo\', array_diff_key(get_defined_vars(), [\'__data\' => 1, \'__path\' => 1]))->render(); ?>';
$this->assertEqu... | $string = "@extends('foo')\ntest";
$expected = "test\n".'<?php echo $__env->make(\'foo\', array_diff_key(get_defined_vars(), [\'__data\' => 1, \'__path\' => 1]))->render(); ?>';
$this->assertEquals($expected, $this->compiler->compileString( | et_defined_vars(), [\'__data\' => 1, \'__path\' => 1]))->render(); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testSequentialCompileStringCalls()
{
| {
"filepath": "tests/View/Blade/BladeExtendsTest.php",
"language": "php",
"file_size": 2139,
"cut_index": 563,
"middle_length": 229
} |
Each(\'foo\', \'bar\'); ?>', $this->compiler->compileString('@each(\'foo\', \'bar\')'));
$this->assertSame('<?php echo $__env->renderEach(\'foo\', \'(bar))\'); ?>', $this->compiler->compileString('@each(\'foo\', \'(bar))\')'));
$this->assertSame('<?php echo $__env->renderEach(name(foo)); ?>', $this->com... | => 1, \'__path\' => 1]))->render(); ?>', $this->compiler->compileString('@include(\'foo\', [\'((\'])'));
$this->assertSame('<?php echo $__env->make(\'foo\', [\'((a)\' => \'((a)\'], array_diff_key(get_defined_vars(), [\'__data\' => 1, \'__path\' => | s(), [\'__data\' => 1, \'__path\' => 1]))->render(); ?>', $this->compiler->compileString('@include(\'foo\')'));
$this->assertSame('<?php echo $__env->make(\'foo\', [\'((\'], array_diff_key(get_defined_vars(), [\'__data\' | {
"filepath": "tests/View/Blade/BladeIncludesTest.php",
"language": "php",
"file_size": 5501,
"cut_index": 716,
"middle_length": 229
} |
his->assertSame('font-bold', (string) $bag->whereStartsWith('class')->first());
$this->assertSame('name="test"', (string) $bag->whereDoesntStartWith('class'));
$this->assertSame('test', (string) $bag->whereDoesntStartWith('class')->first());
$this->assertSame('class="mt-4 font-bold" name="test"'... | sertSame('class="mt-4 font-bold"', (string) $bag->only('class')->merge(['class' => 'mt-4']));
$this->assertSame('name="test" class="font-bold"', (string) $bag->merge(['name' => 'default']));
$this->assertSame('class="font-bold" name="test"' | Same('class="mt-4 font-bold" id="bar" name="test"', (string) $bag->merge(['class' => 'mt-4', 'id' => 'bar']));
$this->assertSame('class="mt-4 font-bold" name="test"', (string) $bag(['class' => 'mt-4']));
$this->as | {
"filepath": "tests/View/ViewComponentAttributeBagTest.php",
"language": "php",
"file_size": 16488,
"cut_index": 921,
"middle_length": 229
} |
te\Tests\View\Blade;
class BladeBreakStatementsTest extends AbstractBladeTestCase
{
public function testBreakStatementsAreCompiled()
{
$string = '@for ($i = 0; $i < 10; $i++)
test
@break
@endfor';
$expected = '<?php for($i = 0; $i < 10; $i++): ?>
test
<?php break; ?>
<?php endfor; ?>';
... | }
public function testBreakStatementsWithArgumentAreCompiled()
{
$string = '@for ($i = 0; $i < 10; $i++)
test
@break(2)
@endfor';
$expected = '<?php for($i = 0; $i < 10; $i++): ?>
test
<?php break 2; ?>
<?php endfor; ?>';
$ | 0; $i++)
test
@break(TRUE)
@endfor';
$expected = '<?php for($i = 0; $i < 10; $i++): ?>
test
<?php if(TRUE) break; ?>
<?php endfor; ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
| {
"filepath": "tests/View/Blade/BladeBreakStatementsTest.php",
"language": "php",
"file_size": 1781,
"cut_index": 537,
"middle_length": 229
} |
iew\Blade;
class BladeExpressionTest extends AbstractBladeTestCase
{
public function testExpressionsOnTheSameLine()
{
$this->assertSame('<?php echo app(\'translator\')->get(foo(bar(baz(qux(breeze()))))); ?> space () <?php echo app(\'translator\')->get(foo(bar)); ?>', $this->compiler->compileString('@la... | this->assertSame('<html<?php echo e($foo); ?>>', $this->compiler->compileString('<html{{ $foo }}>'));
$this->assertSame('<html <?php echo e($foo); ?> <?php echo app(\'translator\')->get(\'foo\'); ?>>', $this->compiler->compileString('<html {{ $foo | iler->compileString('<html {{ $foo }}>'));
$ | {
"filepath": "tests/View/Blade/BladeExpressionTest.php",
"language": "php",
"file_size": 886,
"cut_index": 547,
"middle_length": 52
} |
eTestCase
{
public function testForeachStatementsAreCompiled()
{
$string = '@foreach ($this->getUsers() as $user)
test
@endforeach';
$expected = '<?php $__currentLoopData = $this->getUsers(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(... | (); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
test
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>';
$this->assertEquals($expe | ));
}
public function testForeachStatementsAreCompileWithUppercaseSyntax()
{
$string = '@foreach ($this->getUsers() AS $user)
test
@endforeach';
$expected = '<?php $__currentLoopData = $this->getUsers | {
"filepath": "tests/View/Blade/BladeForeachStatementsTest.php",
"language": "php",
"file_size": 5757,
"cut_index": 716,
"middle_length": 229
} |
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\View\Compilers\BladeCompiler;
use Illuminate\View\Component;
use Mockery as m;
use PHPUnit\Framework\TestCase;
abstract class AbstractBladeTestCase extends TestCase
{
/**
* @var \Illuminate\View\Compilers\BladeCompiler
... | ::setInstance(null);
Component::flushCache();
Component::forgetComponentsResolver();
Component::forgetFactory();
parent::tearDown();
}
protected function getFiles()
{
return m::mock(Filesystem::class);
| ed function tearDown(): void
{
Container | {
"filepath": "tests/View/Blade/AbstractBladeTestCase.php",
"language": "php",
"file_size": 875,
"cut_index": 559,
"middle_length": 52
} |
s BladeHelpersTest extends AbstractBladeTestCase
{
public function testEchosAreCompiled()
{
$this->assertSame('<?php echo csrf_field(); ?>', $this->compiler->compileString('@csrf'));
$this->assertSame('<?php echo method_field(\'patch\'); ?>', $this->compiler->compileString("@method('patch')"));
... | mpileString('@vite'));
$this->assertSame('<?php echo app(\'Illuminate\Foundation\Vite\')(); ?>', $this->compiler->compileString('@vite()'));
$this->assertSame('<?php echo app(\'Illuminate\Foundation\Vite\')(\'resources/js/app.js\'); ?>', $t | 1, $var2)'));
$this->assertSame('<?php dump($var1, $var2); ?>', $this->compiler->compileString('@dump($var1, $var2)'));
$this->assertSame('<?php echo app(\'Illuminate\Foundation\Vite\')(); ?>', $this->compiler->co | {
"filepath": "tests/View/Blade/BladeHelpersTest.php",
"language": "php",
"file_size": 2065,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\View\Blade;
class BladeContinueStatementsTest extends AbstractBladeTestCase
{
public function testContinueStatementsAreCompiled()
{
$string = '@for ($i = 0; $i < 10; $i++)
test
@continue
@endfor';
$expected = '<?php for($i = 0; $i < 10; $i++): ?>
test
<?php continue; ?>
<?php endfor; ?... | tring($string));
}
public function testContinueStatementsWithArgumentAreCompiled()
{
$string = '@for ($i = 0; $i < 10; $i++)
test
@continue(2)
@endfor';
$expected = '<?php for($i = 0; $i < 10; $i++): ?>
test
<?php continue 2; ? | ($i = 0; $i < 10; $i++)
test
@continue(TRUE)
@endfor';
$expected = '<?php for($i = 0; $i < 10; $i++): ?>
test
<?php if(TRUE) continue; ?>
<?php endfor; ?>';
$this->assertEquals($expected, $this->compiler->compileS | {
"filepath": "tests/View/Blade/BladeContinueStatementsTest.php",
"language": "php",
"file_size": 1829,
"cut_index": 537,
"middle_length": 229
} |
use Illuminate\Routing\CallableDispatcher;
use Illuminate\Routing\Contracts\CallableDispatcher as CallableDispatcherContract;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Routing\Router;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
include_once 'Enums.php';
class AuthorizeMi... | return $this->user;
});
});
$this->router = new Router(new Dispatcher, $this->container);
$this->container->bind(CallableDispatcherContract::class, fn ($app) => new CallableDispatcher($app));
$this->containe | = new stdClass;
Container::setInstance($this->container = new Container);
$this->container->singleton(GateContract::class, function () {
return new Gate($this->container, function () {
| {
"filepath": "tests/Auth/AuthorizeMiddlewareTest.php",
"language": "php",
"file_size": 10650,
"cut_index": 921,
"middle_length": 229
} |
Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
include_once 'Enums.php';
class ValidationArrayRuleTest extends TestCase
{
public function testItCorrectlyFormatsAStringVersionOfTheRule()... | ring) $rule);
$rule = Rule::array(collect(['key_1', 'key_2', 'key_3']));
$this->assertSame('array:key_1,key_2,key_3', (string) $rule);
$rule = Rule::array([ArrayKeys::key_1, ArrayKeys::key_2, ArrayKeys::key_3]);
$this->a | = Rule::array('key_1', 'key_2', 'key_3');
$this->assertSame('array:key_1,key_2,key_3', (string) $rule);
$rule = Rule::array(['key_1', 'key_2', 'key_3']);
$this->assertSame('array:key_1,key_2,key_3', (st | {
"filepath": "tests/Validation/ValidationArrayRuleTest.php",
"language": "php",
"file_size": 2760,
"cut_index": 563,
"middle_length": 229
} |
('foo');
$this->assertNotSame('foo', $encrypted);
$this->assertSame('foo', $e->decrypt($encrypted));
$encrypted = $e->encrypt('');
$this->assertSame('', $e->decrypt($encrypted));
$longString = str_repeat('a', 1000);
$encrypted = $e->encrypt($longString);
$this->... | $this->assertNotSame('foo', $encrypted);
$this->assertSame('foo', $e->decryptString($encrypted));
}
public function testRawStringEncryptionWithPreviousKeys()
{
$previous = new Encrypter(str_repeat('b', 16));
$pre | dArray);
$this->assertSame($data, $e->decrypt($encryptedArray));
}
public function testRawStringEncryption()
{
$e = new Encrypter(str_repeat('a', 16));
$encrypted = $e->encryptString('foo');
| {
"filepath": "tests/Encryption/EncrypterTest.php",
"language": "php",
"file_size": 11488,
"cut_index": 921,
"middle_length": 229
} |
adcaster;
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Throwable;
class BroadcastEventTest extends TestCase
{
public function testBasicEventBroadcastParameterFormatting()
{
$broadcaster = m::mock(Broadcaster::class);
... | castEvent($event))->handle($manager);
}
public function testManualParameterSpecification()
{
$broadcaster = m::mock(Broadcaster::class);
$broadcaster->shouldReceive('broadcast')->once()->with(
['test-channel'], Tes | bar']]
);
$manager = m::mock(BroadcastingFactory::class);
$manager->shouldReceive('connection')->once()->with(null)->andReturn($broadcaster);
$event = new TestBroadcastEvent;
(new Broad | {
"filepath": "tests/Broadcasting/BroadcastEventTest.php",
"language": "php",
"file_size": 5203,
"cut_index": 716,
"middle_length": 229
} |
ttp\Request;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class RedisBroadcasterTest extends TestCase
{
/**
* @var \Illuminate\Broadcasting\Broadcasters\RedisBroadcaster
*/
public $broadcaster;
protected function setUp():... | aster->channel('test', function () {
return true;
});
$this->broadcaster->shouldReceive('validAuthenticationResponse')
->once();
$this->broadcaster->auth(
$this->getMockRequestWithUserForChannel | ner->singleton('config', function () {
return $this->createConfig();
});
}
public function testAuthCallValidAuthenticationResponseWithPrivateChannelWhenCallbackReturnTrue()
{
$this->broadc | {
"filepath": "tests/Broadcasting/RedisBroadcasterTest.php",
"language": "php",
"file_size": 5600,
"cut_index": 716,
"middle_length": 229
} |
use Illuminate\Broadcasting\Broadcasters\UsePusherChannelConventions;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class UsePusherChannelsNamesTest extends TestCase
{
#[DataProvider('channelsProvider')]
public function testChannelNameNormalization($requestChannelName, $normal... | -123',
$broadcaster->normalizeChannelName('private-encrypted-private-123')
);
}
public function testChannelNamePatternMatching()
{
$broadcaster = new FakeBroadcasterUsingPusherChannelsNames;
$this->assertEq | lName($requestChannelName)
);
}
public function testChannelNameNormalizationSpecialCase()
{
$broadcaster = new FakeBroadcasterUsingPusherChannelsNames;
$this->assertSame(
'private | {
"filepath": "tests/Broadcasting/UsePusherChannelsNamesTest.php",
"language": "php",
"file_size": 3458,
"cut_index": 614,
"middle_length": 229
} |
pace Illuminate\Tests\Queue;
use Illuminate\Container\Container;
use Illuminate\Queue\Jobs\RedisJob;
use Illuminate\Queue\RedisQueue;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class QueueRedisJobTest extends TestCase
{
public function testFireProperlyCallsTheJobHandler()
{
$job =... | th('default', $job);
$job->delete();
}
public function testReleaseProperlyReleasesJobOntoRedis()
{
$job = $this->getJob();
$job->getRedisQueue()->shouldReceive('deleteAndRelease')->once()
->with('default', | h($job, ['data']);
$job->fire();
}
public function testDeleteRemovesTheJobFromRedis()
{
$job = $this->getJob();
$job->getRedisQueue()->shouldReceive('deleteReserved')->once()
->wi | {
"filepath": "tests/Queue/QueueRedisJobTest.php",
"language": "php",
"file_size": 1431,
"cut_index": 524,
"middle_length": 229
} |
inate\Foundation\Queue\Queueable;
use Illuminate\Queue\QueueRoutes;
use PHPUnit\Framework\TestCase;
class QueueRoutesTest extends TestCase
{
public function testSet()
{
$defaults = new QueueRoutes();
$defaults->set(QueueRoutes::class, 'some-queue');
$defaults->set(BaseNotification::cla... | ([
QueueRoutes::class => 'queue-many',
BaseNotification::class => ['some-connection', 'some-queue'],
SomeJob::class => 'important',
], $defaults->all()
);
}
public function testGetQueue()
{
| e'],
], $defaults->all());
// Ensure same class overrides
$defaults->set([
QueueRoutes::class => 'queue-many',
SomeJob::class => 'important',
]);
$this->assertSame | {
"filepath": "tests/Queue/QueueRoutesTest.php",
"language": "php",
"file_size": 2843,
"cut_index": 563,
"middle_length": 229
} |
protected $secret;
protected $service;
protected $region;
protected $account;
protected $queueName;
protected $baseUrl;
protected $releaseDelay;
protected $queueUrl;
protected $mockedSqsClient;
protected $mockedContainer;
protected $mockedJob;
protected $mockedData;
... | $this->baseUrl = 'https://sqs.someregion.amazonaws.com';
$this->releaseDelay = 0;
// This is how the modified getQueue builds the queueUrl
$this->queueUrl = $this->baseUrl.'/'.$this->account.'/'.$this->queueName;
// Ge | AZONSQSKEY';
$this->secret = 'AmAz0n+SqSsEcReT+aLpHaNuM3R1CsTr1nG';
$this->service = 'sqs';
$this->region = 'someregion';
$this->account = '1234567891011';
$this->queueName = 'emails';
| {
"filepath": "tests/Queue/QueueSqsJobTest.php",
"language": "php",
"file_size": 9274,
"cut_index": 921,
"middle_length": 229
} |
minate\Queue\Worker;
use Illuminate\Queue\WorkerOptions;
use Illuminate\Queue\WorkerStopReason;
use Illuminate\Support\Carbon;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use RuntimeException;
class QueueWorkerTest extends TestCase
{
public $events;
public $exceptionHandler;
public $maintenanceFlags;... |
Carbon::setTestNow();
Container::setInstance();
parent::tearDown();
}
public function testJobCanBeFired()
{
$worker = $this->getWorker('default', ['queue' => [$job = new WorkerFakeJob]]);
$worker->run | ce($container = new Container);
$container->instance(Dispatcher::class, $this->events);
$container->instance(ExceptionHandler::class, $this->exceptionHandler);
}
protected function tearDown(): void
{ | {
"filepath": "tests/Queue/QueueWorkerTest.php",
"language": "php",
"file_size": 28282,
"cut_index": 1331,
"middle_length": 229
} |
erythingStatically']);
$this->assertTrue($gate->check('anything'));
}
public function testBeforeCanAllowGuests()
{
$gate = new Gate(new Container, function () {
//
});
$gate->before(function (?stdClass $user) {
return true;
});
$thi... | tainer, function () {
//
});
$gate->define('foo', function (?stdClass $user) {
return true;
});
$gate->define('bar', function (stdClass $user) {
return false;
});
$this- | ate->after(function (?stdClass $user) {
return true;
});
$this->assertTrue($gate->check('anything'));
}
public function testClosuresCanAllowGuestUsers()
{
$gate = new Gate(new Con | {
"filepath": "tests/Auth/AuthAccessGateTest.php",
"language": "php",
"file_size": 44164,
"cut_index": 2151,
"middle_length": 229
} |
ase
{
public function testAllowMethod()
{
$response = Response::allow('some message', 'some_code');
$this->assertTrue($response->allowed());
$this->assertFalse($response->denied());
$this->assertSame('some message', $response->message());
$this->assertSame('some_code', $... | l()
{
$response = Response::deny();
$this->assertNull($response->message());
}
public function testItSetsEmptyStatusOnExceptionWhenAuthorizing()
{
try {
Response::deny('foo', 3)->authorize();
| this->assertFalse($response->allowed());
$this->assertSame('some message', $response->message());
$this->assertSame('some_code', $response->code());
}
public function testDenyMethodWithNoMessageReturnsNul | {
"filepath": "tests/Auth/AuthAccessResponseTest.php",
"language": "php",
"file_size": 5832,
"cut_index": 716,
"middle_length": 229
} |
ublic function testRetrieveByIDReturnsUserWhenUserIsFound()
{
$conn = m::mock(Connection::class);
$conn->shouldReceive('table')->once()->with('foo')->andReturn($conn);
$conn->shouldReceive('find')->once()->with(1)->andReturn(['id' => 1, 'name' => 'Dayle']);
$hasher = m::mock(Hasher::... | $conn->shouldReceive('table')->once()->with('foo')->andReturn($conn);
$conn->shouldReceive('find')->once()->with(1)->andReturn(null);
$hasher = m::mock(Hasher::class);
$provider = new DatabaseUserProvider($conn, $hasher, 'foo');
| his->assertSame(1, $user->getAuthIdentifier());
$this->assertSame('Dayle', $user->name);
}
public function testRetrieveByIDReturnsNullWhenUserIsNotFound()
{
$conn = m::mock(Connection::class);
| {
"filepath": "tests/Auth/AuthDatabaseUserProviderTest.php",
"language": "php",
"file_size": 9544,
"cut_index": 921,
"middle_length": 229
} |
nate\Auth\Access\HandlesAuthorization;
use PHPUnit\Framework\TestCase;
class AuthHandlesAuthorizationTest extends TestCase
{
use HandlesAuthorization;
public function testAllowMethod()
{
$response = $this->allow('some message', 'some_code');
$this->assertTrue($response->allowed());
... | response->message());
$this->assertSame('some_code', $response->code());
}
public function testDenyHasNullStatus()
{
$class = new class()
{
use HandlesAuthorization;
public function __invoke()
| n testDenyMethod()
{
$response = $this->deny('some message', 'some_code');
$this->assertTrue($response->denied());
$this->assertFalse($response->allowed());
$this->assertSame('some message', $ | {
"filepath": "tests/Auth/AuthHandlesAuthorizationTest.php",
"language": "php",
"file_size": 3775,
"cut_index": 614,
"middle_length": 229
} |
te\Tests\Auth;
use Illuminate\Auth\Passwords\PasswordBroker;
use Illuminate\Auth\Passwords\PasswordBrokerManager;
use Illuminate\Config\Repository as Config;
use Illuminate\Container\Container;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class AuthPasswordBrokerManagerTest extends TestCase
{
public function... | >broker('users');
$this->assertSame($broker, $result1);
$this->assertSame($result1, $result2);
}
public function testSetDefaultDriverAcceptsBackedEnum(): void
{
$app = $this->getApp();
$manager = new PasswordB | ])->makePartial()->shouldAllowMockingProtectedMethods();
$manager->shouldReceive('resolve')->with('users')->andReturn($broker);
$result1 = $manager->broker(PasswordBrokerName::Users);
$result2 = $manager- | {
"filepath": "tests/Auth/AuthPasswordBrokerManagerTest.php",
"language": "php",
"file_size": 1826,
"cut_index": 537,
"middle_length": 229
} |
uthTokenGuardTest extends TestCase
{
public function testUserCanBeRetrievedByQueryStringVariable()
{
$provider = m::mock(UserProvider::class);
$user = new AuthTokenGuardTestUser;
$user->id = 1;
$provider->shouldReceive('retrieveByCredentials')->once()->with(['api_token' => 'foo']... | provider = m::mock(UserProvider::class);
$user = new AuthTokenGuardTestUser;
$user->id = 1;
$provider->shouldReceive('retrieveByCredentials')->once()->with(['api_token' => hash('sha256', 'foo')])->andReturn($user);
$request | his->assertSame(1, $user->id);
$this->assertTrue($guard->check());
$this->assertFalse($guard->guest());
$this->assertSame(1, $guard->id());
}
public function testTokenCanBeHashed()
{
$ | {
"filepath": "tests/Auth/AuthTokenGuardTest.php",
"language": "php",
"file_size": 7883,
"cut_index": 716,
"middle_length": 229
} |
;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use Illuminate\Auth\RequestGuard;
use Illuminate\Config\Repository;
use Illuminate\Config\Repository as Config;
use Illuminate\Container\Container;
use Illuminate\Http\Request;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class Authenticate... | arent::tearDown();
}
public function testItCanGenerateDefinitionViaStaticMethod()
{
$signature = Authenticate::using('foo');
$this->assertSame('Illuminate\Auth\Middleware\Authenticate:foo', $signature);
$signature = Au | nager($container);
$container->singleton('config', function () {
return $this->createConfig();
});
}
protected function tearDown(): void
{
Container::setInstance(null);
p | {
"filepath": "tests/Auth/AuthenticateMiddlewareTest.php",
"language": "php",
"file_size": 8344,
"cut_index": 716,
"middle_length": 229
} |
\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Routing\Router;
use PHPUnit\Framework\TestCase;
class AuthorizesResourcesTest extends TestCase
{
public function testCreateMethod()
{
$controller = new AuthorizesResourcesControlle... | e,App\User');
$controller = new AuthorizesResourcesWithArrayController;
$this->assertHasMiddleware($controller, 'store', 'can:create,App\User,App\Post');
}
public function testShowMethod()
{
$controller = new Authoriz | ntroller, 'create', 'can:create,App\User,App\Post');
}
public function testStoreMethod()
{
$controller = new AuthorizesResourcesController;
$this->assertHasMiddleware($controller, 'store', 'can:creat | {
"filepath": "tests/Auth/AuthorizesResourcesTest.php",
"language": "php",
"file_size": 4567,
"cut_index": 614,
"middle_length": 229
} |
se Symfony\Component\HttpKernel\Exception\HttpException;
class BroadcasterTest extends TestCase
{
/**
* @var \Illuminate\Tests\Broadcasting\FakeBroadcaster
*/
public $broadcaster;
protected function setUp(): void
{
parent::setUp();
$this->broadcaster = new FakeBroadcaster;
... | mething', $callback);
$this->assertEquals(['model.1.instance', 'something'], $parameters);
$callback = function ($user, BroadcasterTestEloquentModelStub $model, BroadcasterTestEloquentModelStub $model2, $something) {
//
| cess()
{
$callback = function ($user, BroadcasterTestEloquentModelStub $model, $nonModel) {
//
};
$parameters = $this->broadcaster->extractAuthParameters('asd.{model}.{nonModel}', 'asd.1.so | {
"filepath": "tests/Broadcasting/BroadcasterTest.php",
"language": "php",
"file_size": 13453,
"cut_index": 921,
"middle_length": 229
} |
pace Illuminate\Tests\Validation;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationAddFailureTest extends TestCase
{
/**
* Making Validator using ValidationValidatorTest.
*
* @return \Illuminate\Validation\Validator
*/
public function makeValidator()
... | tor, $method_name));
$this->assertIsCallable([$validator, $method_name]);
}
public function testAddFailureIsFunctional()
{
$attribute = 'Eugene';
$validator = $this->makeValidator();
$validator->addFailure($attr | , ['foo.bar.baz' => 'sometimes|required']);
}
public function testAddFailureExists()
{
$validator = $this->makeValidator();
$method_name = 'addFailure';
$this->assertTrue(method_exists($valida | {
"filepath": "tests/Validation/ValidationAddFailureTest.php",
"language": "php",
"file_size": 1323,
"cut_index": 524,
"middle_length": 229
} |
domId'])->setConstructorArgs([$redis = m::mock(Factory::class), 'default'])->getMock();
$queue->expects($this->once())->method('getRandomId')->willReturn('foo');
$queue->setContainer($container = m::spy(Container::class));
$redis->shouldReceive('connection')->atLeast()->once()->andReturn($redis)... | d' => 'foo', 'attempts' => 0, 'delay' => null]));
$id = $queue->push('foo', ['data']);
$this->assertSame('foo', $id);
$container->shouldHaveReceived('bound')->with('events')->twice();
Carbon::setTestNow();
Str::cre | e(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'failOnTimeout' => false, 'backoff' => null, 'timeout' => null, 'data' => ['data'], 'createdAt' => $time->getTimestamp(), 'i | {
"filepath": "tests/Queue/QueueRedisQueueTest.php",
"language": "php",
"file_size": 19238,
"cut_index": 1331,
"middle_length": 229
} |
7891011';
$this->queueName = 'emails';
$this->fifoQueueName = 'emails.fifo';
$this->baseUrl = 'https://sqs.someregion.amazonaws.com';
// This is how the modified getQueue builds the queueUrl
$this->prefix = $this->baseUrl.'/'.$this->account.'/';
$this->queueUrl = $this->... | s->mockedMessageId = 'e3cd03ee-59a3-4ad8-b0aa-ee2e3808ac81';
$this->mockedReceiptHandle = '0NNAq8PwvXuWv5gMtS9DJ8qEdyiUwbAjpp45w2m6M4SJ1Y+PxCh7R930NRB8ylSacEmoSnW18bgd4nK\/O6ctE+VFVul4eD23mA07vVoSnPI4F\/voI1eNCp6Iax0ktGmhlNVzBwaZHEr91BRtqTRM3QKd2AS | = json_encode(['job' => $this->mockedJob, 'data' => $this->mockedData]);
$this->mockedDelay = 10;
$this->mockedMessageGroupId = 'group-1';
$this->mockedDeduplicationId = 'deduplication-id-1';
$thi | {
"filepath": "tests/Queue/QueueSqsQueueTest.php",
"language": "php",
"file_size": 47829,
"cut_index": 2151,
"middle_length": 229
} |
base\Connection;
use Illuminate\Support\Carbon;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class AuthDatabaseTokenRepositoryTest extends TestCase
{
public function testCreateInsertsNewRecordIntoTable()
{
$repo = $this->getRepo();
$repo->getHasher()->shouldReceive('make')->o... | Receive('getEmailForPasswordReset')->times(2)->andReturn('email');
$results = $repo->create($user);
$this->assertIsString($results);
$this->assertGreaterThan(1, strlen($results));
}
public function testExistReturnsFalseIf | where')->once()->with('email', 'email')->andReturn($query);
$query->shouldReceive('delete')->once();
$query->shouldReceive('insert')->once();
$user = m::mock(CanResetPassword::class);
$user->should | {
"filepath": "tests/Auth/AuthDatabaseTokenRepositoryTest.php",
"language": "php",
"file_size": 7450,
"cut_index": 716,
"middle_length": 229
} |
::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn('bar');
... | m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
| ion testRetrieveByTokenReturnsUser()
{
$mockUser = m::mock(stdClass::class);
$mockUser->shouldReceive('getRememberToken')->once()->andReturn('a');
$provider = $this->getProviderMock();
$mock = | {
"filepath": "tests/Auth/AuthEloquentUserProviderTest.php",
"language": "php",
"file_size": 9519,
"cut_index": 921,
"middle_length": 229
} |
te\Tests\Auth;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class AuthListenersSendEmailVerificationNotificationHandleFunctio... |
}
/**
* @return void
*/
public function testUserIsNotInstanceOfMustVerifyEmail()
{
$user = m::mock(User::class);
$user->shouldNotReceive('sendEmailVerificationNotification');
$listener = new SendEmailVer | erifiedEmail')->willReturn(false);
$user->expects($this->once())->method('sendEmailVerificationNotification');
$listener = new SendEmailVerificationNotification;
$listener->handle(new Registered($user)); | {
"filepath": "tests/Auth/AuthListenersSendEmailVerificationNotificationHandleFunctionTest.php",
"language": "php",
"file_size": 1518,
"cut_index": 537,
"middle_length": 229
} |
racts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
use Illuminate\Database\DatabaseTransactionsManager;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Jobs\SyncJob;
use Illuminate\Queue\SyncQueue;
use LogicException;
use Mockery ... | sync->push(SyncQueueTestHandler::class, ['foo' => 'bar']);
$this->assertInstanceOf(SyncJob::class, $_SERVER['__sync.test'][0]);
$this->assertEquals(['foo' => 'bar'], $_SERVER['__sync.test'][1]);
}
public function testFailedJobGetsH | ();
}
public function testPushShouldFireJobInstantly()
{
unset($_SERVER['__sync.test']);
$sync = new SyncQueue;
$container = new Container;
$sync->setContainer($container);
$ | {
"filepath": "tests/Queue/QueueSyncQueueTest.php",
"language": "php",
"file_size": 8219,
"cut_index": 716,
"middle_length": 229
} |
Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\RequiredUnless;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationRequiredUnlessRuleTest extends TestCase
{
protected Translator $translator;... | ;
}
public function testBooleanConditionFalse()
{
$rule = Rule::requiredUnless(false);
$this->assertSame('required', (string) $rule);
}
public function testBooleanConditionNull()
{
$rule = Rule::requiredUnl | $this->assertInstanceOf(RequiredUnless::class, Rule::requiredUnless(true));
}
public function testBooleanConditionTrue()
{
$rule = Rule::requiredUnless(true);
$this->assertSame('', (string) $rule) | {
"filepath": "tests/Validation/ValidationRequiredUnlessRuleTest.php",
"language": "php",
"file_size": 2371,
"cut_index": 563,
"middle_length": 229
} |
er\Container;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Support\Facades\Facade;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rules\Can;
use Illuminate\Validation\ValidationServiceProvider;
use Illuminate\Validation\Validator;
us... | turn new Gate($this->container, function () {
return $this->user;
});
});
$this->container->bind('translator', function () {
return new Translator(
new ArrayLoader, 'en'
) | ): void
{
parent::setUp();
$this->user = new stdClass;
Container::setInstance($this->container = new Container);
$this->container->singleton(GateContract::class, function () {
re | {
"filepath": "tests/Validation/ValidationRuleCanTest.php",
"language": "php",
"file_size": 3600,
"cut_index": 614,
"middle_length": 229
} |
Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
include_once 'Enums.php';
class ValidationRuleContainsTest extends TestCase
{
public function testItCorrectlyFormatsAStringVersionOfTheRule()
{
$rule = Rule::contains('Taylor');... | ns:"Taylor","Abigail"', (string) $rule);
$rule = Rule::contains([ArrayKeys::key_1, ArrayKeys::key_2]);
$this->assertSame('contains:"key_1","key_2"', (string) $rule);
$rule = Rule::contains([ArrayKeysBacked::key_1, ArrayKeysBacked: |
$rule = Rule::contains(['Taylor', 'Abigail']);
$this->assertSame('contains:"Taylor","Abigail"', (string) $rule);
$rule = Rule::contains(collect(['Taylor', 'Abigail']));
$this->assertSame('contai | {
"filepath": "tests/Validation/ValidationRuleContainsTest.php",
"language": "php",
"file_size": 3807,
"cut_index": 614,
"middle_length": 229
} |
Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
include_once 'Enums.php';
class ValidationRuleDoesntContainTest extends TestCase
{
public function testItCorrectlyFormatsAStringVersionOfTheRule()
{
$rule = Rule::doesntContain(... | gail']));
$this->assertSame('doesnt_contain:"Taylor","Abigail"', (string) $rule);
$rule = Rule::doesntContain([ArrayKeys::key_1, ArrayKeys::key_2]);
$this->assertSame('doesnt_contain:"key_1","key_2"', (string) $rule);
$rul | Abigail"', (string) $rule);
$rule = Rule::doesntContain(['Taylor', 'Abigail']);
$this->assertSame('doesnt_contain:"Taylor","Abigail"', (string) $rule);
$rule = Rule::doesntContain(collect(['Taylor', 'Abi | {
"filepath": "tests/Validation/ValidationRuleDoesntContainTest.php",
"language": "php",
"file_size": 3944,
"cut_index": 614,
"middle_length": 229
} |
'name' => Rule::when($isAdmin, ['required', 'min:2']),
'email' => Rule::unless($isAdmin, ['required', 'min:2']),
'password' => Rule::when($isAdmin, 'required|min:2'),
'username' => ['required', Rule::when($isAdmin, ['min:2'])],
'address' => ['required', Rule:... | })],
'when_cb_true' => Rule::when(fn () => true, ['required'], ['nullable']),
'when_cb_false' => Rule::when(fn () => false, ['required'], ['nullable']),
'unless_cb_true' => Rule::unless(fn () => true, ['required'], ['nu | ed', Rule::when($isAdmin, function (Fluent $input) {
return 'min:2';
})],
'zip' => ['required', Rule::when($isAdmin, function (Fluent $input) {
return ['min:2'];
| {
"filepath": "tests/Validation/ValidationRuleParserTest.php",
"language": "php",
"file_size": 15472,
"cut_index": 921,
"middle_length": 229
} |
e Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationStringRuleTest extends TestCase
{
public function testDefaultStringRule()
{
$rule = Rule::string();
$this->assertSame('string', (string) $rule);
$rule = new StringRule();
$this->assertSame('strin... | $this->assertSame('string|between:3,255', (string) $rule);
}
public function testExactlyRule()
{
$rule = Rule::string()->exactly(10);
$this->assertSame('string|size:10', (string) $rule);
}
public function testAlpha | n testMaxRule()
{
$rule = Rule::string()->max(255);
$this->assertSame('string|max:255', (string) $rule);
}
public function testBetweenRule()
{
$rule = Rule::string()->between(3, 255);
| {
"filepath": "tests/Validation/ValidationStringRuleTest.php",
"language": "php",
"file_size": 6428,
"cut_index": 716,
"middle_length": 229
} |
TestCase;
class ValidationUniqueRuleTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$this->createSchema();
}
public fu... | bleName::class);
$rule->where('foo', 'bar');
$this->assertSame('unique:no_table_names,NULL,NULL,id,foo,"bar"', (string) $rule);
$rule = new Unique('Illuminate\Tests\Validation\NoTableName');
$rule->where('foo', 'bar');
| bar"', (string) $rule);
$rule = new Unique(EloquentModelStub::class);
$rule->where('foo', 'bar');
$this->assertSame('unique:table,NULL,NULL,id,foo,"bar"', (string) $rule);
$rule = new Unique(NoTa | {
"filepath": "tests/Validation/ValidationUniqueRuleTest.php",
"language": "php",
"file_size": 9225,
"cut_index": 921,
"middle_length": 229
} |
Rules\Date;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationDateRuleTest extends TestCase
{
public function testDefaultDateRule()
{
$rule = Rule::date();
$this->assertSame('date', (string) $rule);
$rule = new Date;
$this->assertSame('date', ... | |after_or_equal:today', (string) $rule);
}
public function testBeforeTodayRule()
{
$rule = Rule::date()->beforeToday();
$this->assertSame('date|before:today', (string) $rule);
$rule = Rule::date()->todayOrBefore();
| public function testAfterTodayRule()
{
$rule = Rule::date()->afterToday();
$this->assertSame('date|after:today', (string) $rule);
$rule = Rule::date()->todayOrAfter();
$this->assertSame('date | {
"filepath": "tests/Validation/ValidationDateRuleTest.php",
"language": "php",
"file_size": 5359,
"cut_index": 716,
"middle_length": 229
} |
ation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Dimensions;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationDimensionsRuleTest extends TestCase
{
public function testItCorrectlyFormatsAStringVersionOfTheR... | ame('dimensions:max_width=1000,max_height=500,ratio=1.5', (string) $rule);
$rule = new Dimensions(['ratio' => '2/3']);
$this->assertSame('dimensions:ratio=2/3', (string) $rule);
$rule = Rule::dimensions()->minWidth(300)->minHeigh | ule::dimensions()->width(200)->height(100);
$this->assertSame('dimensions:width=200,height=100', (string) $rule);
$rule = Rule::dimensions()->maxWidth(1000)->maxHeight(500)->ratio(3 / 2);
$this->assertS | {
"filepath": "tests/Validation/ValidationDimensionsRuleTest.php",
"language": "php",
"file_size": 4012,
"cut_index": 614,
"middle_length": 229
} |
ator;
use PHPUnit\Framework\TestCase;
class ValidationExceptionTest extends TestCase
{
public function testExceptionSummarizesZeroErrors()
{
$exception = $this->getException([], []);
$this->assertSame('The given data was invalid.', $exception->getMessage());
}
public function testExce... | essage());
}
public function testExceptionSummarizesThreeOrMoreErrors()
{
$exception = $this->getException([], [
'foo' => 'required',
'bar' => 'required',
'baz' => 'required',
]);
$t | lic function testExceptionSummarizesTwoErrors()
{
$exception = $this->getException([], ['foo' => 'required', 'bar' => 'required']);
$this->assertSame('validation.required (and 1 more error)', $exception->getM | {
"filepath": "tests/Validation/ValidationExceptionTest.php",
"language": "php",
"file_size": 5943,
"cut_index": 716,
"middle_length": 229
} |
Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\ExcludeUnless;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationExcludeUnlessRuleTest extends TestCase
{
protected Translator $translator;
... | }
public function testBooleanConditionFalse()
{
$rule = Rule::excludeUnless(false);
$this->assertSame('exclude', (string) $rule);
}
public function testClosureConditionTrue()
{
$rule = Rule::excludeUnless(fn ( | $this->assertInstanceOf(ExcludeUnless::class, Rule::excludeUnless(true));
}
public function testBooleanConditionTrue()
{
$rule = Rule::excludeUnless(true);
$this->assertSame('', (string) $rule);
| {
"filepath": "tests/Validation/ValidationExcludeUnlessRuleTest.php",
"language": "php",
"file_size": 2377,
"cut_index": 563,
"middle_length": 229
} |
\Validation\PresenceVerifierInterface;
use Illuminate\Validation\Validator;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class ValidationFactoryTest extends TestCase
{
public function testMakeMethodCreatesValidValidator()
{
$translator = m::mock(TranslatorInterface::class);
$factory = new ... | };
$noop2 = function () {
//
};
$noop3 = function () {
//
};
$factory->extend('foo', $noop1);
$factory->extendImplicit('implicit', $noop2);
$factory->extendDependent('d | ls(['foo' => 'bar'], $validator->getData());
$this->assertEquals(['baz' => ['boom']], $validator->getRules());
$presence = m::mock(PresenceVerifierInterface::class);
$noop1 = function () {
//
| {
"filepath": "tests/Validation/ValidationFactoryTest.php",
"language": "php",
"file_size": 6204,
"cut_index": 716,
"middle_length": 229
} |
Contains duplicate ID.
['discounts' => [['id' => 1], ['id' => 1], ['id' => 2]]],
['discounts' => [['id' => 1], ['id' => 2]]],
],
];
$rules = [
'items.*' => Rule::forEach(function () {
return ['discounts.*.id' => 'distinct'];
... | acksCanBeRecursivelyNested()
{
$data = [
'items' => [
// Contains duplicate ID.
['discounts' => [['id' => 1], ['id' => 1], ['id' => 2]]],
['discounts' => [['id' => 1], ['id' => 2]]],
| ertEquals([
'items.0.discounts.0.id' => ['validation.distinct'],
'items.0.discounts.1.id' => ['validation.distinct'],
], $v->getMessageBag()->toArray());
}
public function testForEachCallb | {
"filepath": "tests/Validation/ValidationForEachTest.php",
"language": "php",
"file_size": 11419,
"cut_index": 921,
"middle_length": 229
} |
Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationInArrayKeysTest extends TestCase
{
public function testInArrayKeysValidation()
{
$trans = $this->getIlluminateArrayTranslator();
// Te... | rray_keys:first_key,second_key']);
$this->assertTrue($v->passes());
// Test fails when array doesn't have any of the specified keys
$v = new Validator($trans, ['foo' => ['first_key' => 'bar', 'second_key' => 'baz']], ['foo' => 'in_ | d_key']);
$this->assertTrue($v->passes());
// Test passes when array has multiple of the specified keys
$v = new Validator($trans, ['foo' => ['first_key' => 'bar', 'second_key' => 'baz']], ['foo' => 'in_a | {
"filepath": "tests/Validation/ValidationInArrayKeysTest.php",
"language": "php",
"file_size": 3039,
"cut_index": 563,
"middle_length": 229
} |
ss ValidationInvokableRuleTest extends TestCase
{
public function testItCanPass()
{
$trans = $this->getIlluminateArrayTranslator();
$rule = new class() implements ValidationRule
{
public function validate($attribute, $value, $fail): void
{
//
... | te($attribute, $value, $fail): void
{
$fail("The {$attribute} attribute is not 'foo'. Got '{$value}' instead.");
}
};
$validator = new Validator($trans, ['foo' => 'bar'], ['foo' => $rule]);
| >messages()->messages());
}
public function testItCanFail()
{
$trans = $this->getIlluminateArrayTranslator();
$rule = new class() implements ValidationRule
{
public function valida | {
"filepath": "tests/Validation/ValidationInvokableRuleTest.php",
"language": "php",
"file_size": 13372,
"cut_index": 921,
"middle_length": 229
} |
Illuminate\Tests\Validation\fixtures\Values;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\NotIn;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
include_once 'Enums.php';
class ValidationNotInRuleTes... | 1, 2, 3, 4]));
$this->assertSame('not_in:"1","2","3","4"', (string) $rule);
$rule = Rule::notIn(collect([1, 2, 3, 4]));
$this->assertSame('not_in:"1","2","3","4"', (string) $rule);
$rule = Rule::notIn([1, 2, 3, 4]);
| aravel","Framework","PHP"', (string) $rule);
$rule = new NotIn(collect(['Taylor', 'Michael', 'Tim']));
$this->assertSame('not_in:"Taylor","Michael","Tim"', (string) $rule);
$rule = Rule::notIn(collect([ | {
"filepath": "tests/Validation/ValidationNotInRuleTest.php",
"language": "php",
"file_size": 2697,
"cut_index": 563,
"middle_length": 229
} |
$this->assertSame('numeric', (string) $rule);
$rule = new Numeric();
$this->assertSame('numeric', (string) $rule);
}
public function testBetweenRule()
{
$rule = Rule::numeric()->between(1, 10);
$this->assertSame('numeric|between:1,10', (string) $rule);
$rule = R... | tRule()
{
$rule = Rule::numeric()->different('some_field');
$this->assertSame('numeric|different:some_field', (string) $rule);
}
public function testDigitsRule()
{
$rule = Rule::numeric()->digits(10);
$this- | ecimal(2, 4);
$this->assertSame('numeric|decimal:2,4', (string) $rule);
$rule = Rule::numeric()->decimal(2);
$this->assertSame('numeric|decimal:2', (string) $rule);
}
public function testDifferen | {
"filepath": "tests/Validation/ValidationNumericRuleTest.php",
"language": "php",
"file_size": 10184,
"cut_index": 921,
"middle_length": 229
} |
ork\TestCase;
class ValidationPasswordRuleTest extends TestCase
{
public function testString()
{
$this->fails(Password::min(3), [['foo' => 'bar'], ['foo']], [
'validation.string',
'validation.min.string',
]);
$this->fails(Password::min(3), [1234567, 545], [
... | ', 'abcd']);
$this->passes(new Password(8), ['88888888']);
}
public function testMax()
{
$this->fails(Password::min(2)->max(4), ['aaaaa', '11111111'], [
'validation.max.string',
]);
$this->passes(Pa | ), ['a', 'ff', '12'], [
'validation.min.string',
]);
$this->fails(Password::min(3), ['a', 'ff', '12'], [
'validation.min.string',
]);
$this->passes(Password::min(3), ['333 | {
"filepath": "tests/Validation/ValidationPasswordRuleTest.php",
"language": "php",
"file_size": 17260,
"cut_index": 921,
"middle_length": 229
} |
Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\ProhibitedUnless;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationProhibitedUnlessRuleTest extends TestCase
{
protected Translator $transla... | ng) $rule);
}
public function testBooleanConditionFalse()
{
$rule = Rule::prohibitedUnless(false);
$this->assertSame('prohibited', (string) $rule);
}
public function testClosureConditionTrue()
{
$rule = Rul | $this->assertInstanceOf(ProhibitedUnless::class, Rule::prohibitedUnless(true));
}
public function testBooleanConditionTrue()
{
$rule = Rule::prohibitedUnless(true);
$this->assertSame('', (stri | {
"filepath": "tests/Validation/ValidationProhibitedUnlessRuleTest.php",
"language": "php",
"file_size": 2265,
"cut_index": 563,
"middle_length": 229
} |
pace Illuminate\Tests\Queue\Fixtures;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
class FakeSqsJobWithDeduplication implements ShouldQueue
{
use Queueable;
protected static $deduplicationIdFactory;
public function handle(): void
{
//
}
/**
... | /**
* Set the callable that will be used to generate deduplication IDs.
*
* @param callable|null $factory
* @return void
*/
public static function createDeduplicationIdsUsing(?callable $factory = null)
{
stati | ad, $queue): string
{
return static::$deduplicationIdFactory
? (string) call_user_func(static::$deduplicationIdFactory, $payload, $queue)
: hash('sha256', json_encode(func_get_args()));
}
| {
"filepath": "tests/Queue/Fixtures/FakeSqsJobWithDeduplication.php",
"language": "php",
"file_size": 1318,
"cut_index": 524,
"middle_length": 229
} |
authorizedHttpException;
class AuthGuardTest extends TestCase
{
public function testBasicReturnsNullOnValidAttempt()
{
[$session, $provider, $request, $cookie] = $this->getMocks();
$guard = m::mock(SessionGuard::class.'[check,attempt]', ['default', $provider, $session]);
$guard->shouldR... | oggedIn()
{
[$session, $provider, $request, $cookie] = $this->getMocks();
$guard = m::mock(SessionGuard::class.'[check]', ['default', $provider, $session]);
$guard->shouldReceive('check')->once()->andReturn(true);
$guard | st::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$guard->setRequest($request);
$guard->basic('email');
}
public function testBasicReturnsNullWhenAlreadyL | {
"filepath": "tests/Auth/AuthGuardTest.php",
"language": "php",
"file_size": 33746,
"cut_index": 1331,
"middle_length": 229
} |
asters\AblyBroadcaster;
use Illuminate\Http\Request;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class AblyBroadcasterTest extends TestCase
{
/**
* @var \Illuminate\Broadcasting\Broadcasters\AblyBroadcaster
*/
public $broadca... | {
return true;
});
$this->broadcaster->shouldReceive('validAuthenticationResponse')
->once();
$this->broadcaster->auth(
$this->getMockRequestWithUserForChannel('private-test')
);
}
| ock(AblyBroadcaster::class, [$this->ably])->makePartial();
}
public function testAuthCallValidAuthenticationResponseWithPrivateChannelWhenCallbackReturnTrue()
{
$this->broadcaster->channel('test', function () | {
"filepath": "tests/Broadcasting/AblyBroadcasterTest.php",
"language": "php",
"file_size": 4290,
"cut_index": 614,
"middle_length": 229
} |
EMAIL = 'email';
case URL = 'url';
}
class ValidationAnyOfRuleTest extends TestCase
{
private array $taggedUnionRules;
private array $dotNotationNestedRules;
private array $nestedRules;
public function testBasicValidation()
{
$rule = Rule::anyOf([
['required', 'uuid:4'],
... | passes());
$validator = new Validator(resolve('translator'), [], $requiredIdRule);
$this->assertFalse($validator->passes());
$validator = new Validator(resolve('translator'), [
'id' => '3c8ff5cb-4bc1-457b-a477-1833c477 | '), [
'id' => 'taylor@laravel.com',
], $idRule);
$this->assertTrue($validator->passes());
$validator = new Validator(resolve('translator'), [], $idRule);
$this->assertTrue($validator-> | {
"filepath": "tests/Validation/ValidationAnyOfRuleTest.php",
"language": "php",
"file_size": 12921,
"cut_index": 921,
"middle_length": 229
} |
must be a valid email address.']
);
$this->fails(
Rule::email(),
'foo',
['The '.self::ATTRIBUTE_REPLACED.' must be a valid email address.']
);
$this->fails(
Email::default(),
12345,
['The '.self::ATTRIBUTE_REPLACE... | es(
Rule::email(),
['taylor@laravel.com'],
);
$this->passes(
Email::default(),
['taylor@laravel.com'],
);
$this->passes(Email::default(), null);
$this->passes(Rule:: | s.']
);
$this->passes(
Email::default(),
'taylor@laravel.com'
);
$this->passes(
Rule::email(),
'taylor@laravel.com'
);
$this->pass | {
"filepath": "tests/Validation/ValidationEmailRuleTest.php",
"language": "php",
"file_size": 32025,
"cut_index": 1331,
"middle_length": 229
} |
Exception;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rules\ExcludeIf;
use Illuminate\Validation\Validator;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use stdClass;
class ValidationExcludeIfTest extends TestCase
{
public function test... | new ExcludeIf(false);
$this->assertSame('', (string) $rule);
}
public function testItValidatesCallableAndBooleanAreAcceptableArguments()
{
new ExcludeIf(false);
new ExcludeIf(true);
new ExcludeIf(fn () => true | ule = new ExcludeIf(function () {
return false;
});
$this->assertSame('', (string) $rule);
$rule = new ExcludeIf(true);
$this->assertSame('exclude', (string) $rule);
$rule = | {
"filepath": "tests/Validation/ValidationExcludeIfTest.php",
"language": "php",
"file_size": 2724,
"cut_index": 563,
"middle_length": 229
} |
on\Validator;
use PHPUnit\Framework\TestCase;
class ValidationFileRuleTest extends TestCase
{
public function testBasic()
{
$this->fails(
File::default(),
'foo',
['validation.file'],
);
$this->passes(
File::default(),
Uploaded... | ew Validator(
resolve('translator'),
['my_file' => $value],
['my_file' => is_object($rule) ? clone $rule : $rule]
);
$this->assertSame($result, $v->passes());
$this->asse | ules($rule, $values, false, $messages);
}
protected function assertValidationRules($rule, $values, $result, $messages)
{
$values = Arr::wrap($values);
foreach ($values as $value) {
$v = n | {
"filepath": "tests/Validation/ValidationFileRuleTest.php",
"language": "php",
"file_size": 15080,
"cut_index": 921,
"middle_length": 229
} |
Illuminate\Tests\Validation\fixtures\Values;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\In;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
include_once 'Enums.php';
class ValidationInRuleTest exte... | g', 'this is a "quote"']);
$this->assertSame('in:"Life, the Universe and Everything","this is a ""quote"""', (string) $rule);
$rule = Rule::in(collect([1, 2, 3, 4]));
$this->assertSame('in:"1","2","3","4"', (string) $rule);
| ework","PHP"', (string) $rule);
$rule = new In(collect(['Taylor', 'Michael', 'Tim']));
$this->assertSame('in:"Taylor","Michael","Tim"', (string) $rule);
$rule = new In(['Life, the Universe and Everythin | {
"filepath": "tests/Validation/ValidationInRuleTest.php",
"language": "php",
"file_size": 2777,
"cut_index": 563,
"middle_length": 229
} |
?php
namespace Illuminate\Tests\Validation;
use Illuminate\Validation\Rule;
use PHPUnit\Framework\TestCase;
class ValidationMacroTest extends TestCase
{
public function testMacroable()
{
// Define a phone validation macro
Rule::macro('phone', function () {
return 'regex:/^([0-9\s\... | tMacroDefaultArguments()
{
Rule::macro('maxLength', function ($length = 255) {
return "max:{$length}";
});
$actualRule = Rule::maxLength(); // No argument provided, should use default value
$this->assertSam | Rule::macro('maxLength', function (int $length) {
return "max:{$length}";
});
$actualRule = Rule::maxLength(10);
$this->assertSame('max:10', $actualRule);
}
public function tes | {
"filepath": "tests/Validation/ValidationMacroTest.php",
"language": "php",
"file_size": 1033,
"cut_index": 513,
"middle_length": 229
} |
Exception;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rules\RequiredIf;
use Illuminate\Validation\Validator;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
class ValidationRequiredIfTest extends TestCase
{
public function testItClosureRet... | e = new RequiredIf(false);
$this->assertSame('', (string) $rule);
}
public function testItOnlyCallableAndBooleanAreAcceptableArgumentsOfTheRule()
{
$rule = new RequiredIf(false);
$rule = new RequiredIf(true);
| ule = new RequiredIf(function () {
return false;
});
$this->assertSame('', (string) $rule);
$rule = new RequiredIf(true);
$this->assertSame('required', (string) $rule);
$rul | {
"filepath": "tests/Validation/ValidationRequiredIfTest.php",
"language": "php",
"file_size": 2314,
"cut_index": 563,
"middle_length": 229
} |
e\Contracts\Auth\PasswordBroker as PasswordBrokerContract;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Support\Arr;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use UnexpectedValueException;
class AuthPasswordBrokerTest extends TestCase
{
public function testIfUserIsNotFoundErrorRedirectIsRetur... | oker = m::mock(PasswordBroker::class, array_values($mocks))->makePartial();
$mocks['users']->shouldReceive('retrieveByCredentials')->once()->with(['foo'])->andReturn($user = m::mock(CanResetPassword::class));
$mocks['tokens']->shouldReceive | urnNull();
$this->assertSame(PasswordBrokerContract::INVALID_USER, $broker->sendResetLink(['credentials']));
}
public function testIfTokenIsRecentlyCreated()
{
$mocks = $this->getMocks();
$br | {
"filepath": "tests/Auth/AuthPasswordBrokerTest.php",
"language": "php",
"file_size": 6076,
"cut_index": 716,
"middle_length": 229
} |
onent\HttpKernel\Exception\AccessDeniedHttpException;
class PusherBroadcasterTest extends TestCase
{
/**
* @var \Illuminate\Broadcasting\Broadcasters\PusherBroadcaster
*/
public $broadcaster;
public $pusher;
protected function setUp(): void
{
parent::setUp();
$this->pus... | ->once();
$this->broadcaster->auth(
$this->getMockRequestWithUserForChannel('private-test')
);
}
public function testAuthThrowAccessDeniedHttpExceptionWithPrivateChannelWhenCallbackReturnFalse()
{
$this- | seWithPrivateChannelWhenCallbackReturnTrue()
{
$this->broadcaster->channel('test', function () {
return true;
});
$this->broadcaster->shouldReceive('validAuthenticationResponse')
| {
"filepath": "tests/Broadcasting/PusherBroadcasterTest.php",
"language": "php",
"file_size": 6383,
"cut_index": 716,
"middle_length": 229
} |
viceProvider;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
include_once 'Enums.php';
class ValidationEnumRuleTest extends TestCase
{
public function testValidationPassesWhenPassingCorrectEnum()
{
$v = new Validator(
res... | new Validator(
resolve('translator'),
[
'status' => StringStatus::done,
],
[
'status' => new Enum(StringStatus::class),
]
);
$this->assertFalse($v- | s),
'int_status' => new Enum(IntegerStatus::class),
]
);
$this->assertFalse($v->fails());
}
public function testValidationPassesWhenPassingInstanceOfEnum()
{
$v = | {
"filepath": "tests/Validation/ValidationEnumRuleTest.php",
"language": "php",
"file_size": 9856,
"cut_index": 921,
"middle_length": 229
} |
lation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\File;
use Illuminate\Validation\ValidationServiceProvider;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidationImageFileRuleTest extends TestCase
{
public func... | );
}
public function testDimensionsWithCustomImageSizeMethod()
{
$this->fails(
File::image()->dimensions(Rule::dimensions()->width(100)->height(100)),
new UploadedFileWithCustomImageSizeMethod(stream_get_meta | 1),
['validation.dimensions'],
);
$this->passes(
File::image()->dimensions(Rule::dimensions()->width(100)->height(100)),
UploadedFile::fake()->image('foo.png', 100, 100),
| {
"filepath": "tests/Validation/ValidationImageFileRuleTest.php",
"language": "php",
"file_size": 5458,
"cut_index": 716,
"middle_length": 229
} |
nt\Factory as HttpFactory;
use Illuminate\Http\Client\Response;
use Illuminate\Validation\NotPwnedVerifier;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class ValidationNotPwnedVerifierTest extends TestCase
{
protected function tearDown(): void
{
Container::setInstance(null);
parent::tear... | {
$httpFactory = m::mock(HttpFactory::class);
$response = m::mock(Response::class);
$httpFactory = m::mock(HttpFactory::class);
$httpFactory
->shouldReceive('withHeaders')
->once()
-> | lse, 0] as $password) {
$this->assertFalse($verifier->verify([
'value' => $password,
'threshold' => 0,
]));
}
}
public function testApiResponseGoesWrong()
| {
"filepath": "tests/Validation/ValidationNotPwnedVerifierTest.php",
"language": "php",
"file_size": 5346,
"cut_index": 716,
"middle_length": 229
} |
Exception;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rules\ProhibitedIf;
use Illuminate\Validation\Validator;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use stdClass;
class ValidationProhibitedIfTest extends TestCase
{
public functio... | le);
$rule = new ProhibitedIf(false);
$this->assertSame('', (string) $rule);
}
public function testItValidatesCallableAndBooleanAreAcceptableArguments()
{
new ProhibitedIf(false);
new ProhibitedIf(true);
|
$rule = new ProhibitedIf(function () {
return false;
});
$this->assertSame('', (string) $rule);
$rule = new ProhibitedIf(true);
$this->assertSame('prohibited', (string) $ru | {
"filepath": "tests/Validation/ValidationProhibitedIfTest.php",
"language": "php",
"file_size": 2532,
"cut_index": 563,
"middle_length": 229
} |
Interface;
use Illuminate\Validation\DatabasePresenceVerifier;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class ValidationDatabasePresenceVerifierTest extends TestCase
{
public function testBasicCount()
{
$verifier = new DatabasePresenceVerifier($db = m::mock(ConnectionResolverInte... | , '=', 'value')->andReturn($builder);
$extra = ['foo' => 'NULL', 'bar' => 'NOT_NULL', 'baz' => 'taylor', 'faz' => true, 'not' => '!admin'];
$builder->shouldReceive('whereNull')->with('foo');
$builder->shouldReceive('whereNotNull')-> | ->shouldReceive('table')->once()->with('table')->andReturn($builder = m::mock(stdClass::class));
$builder->shouldReceive('useWritePdo')->once()->andReturn($builder);
$builder->shouldReceive('where')->with('column' | {
"filepath": "tests/Validation/ValidationDatabasePresenceVerifierTest.php",
"language": "php",
"file_size": 3889,
"cut_index": 614,
"middle_length": 229
} |
te\Tests\Cache;
use BadMethodCallException;
use Illuminate\Cache\ArrayStore;
use Illuminate\Cache\MemoizedStore;
use Illuminate\Cache\NullStore;
use Illuminate\Cache\Repository;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Support\Carbon;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class CacheMemoizedSt... | cksCanBeFlushedWhenUnderlyingStoreSupportsIt(): void
{
$store = new MemoizedStore('test', new Repository(new ArrayStore));
$this->assertTrue($store->flushLocks());
}
public function testFlushLocksThrowsWhenUnderlyingStoreDoesNo | Carbon::now());
$store->put('foo', 'bar', 30);
$store->touch('foo', 60);
Carbon::setTestNow($now->addSeconds(45));
$this->assertSame('bar', $store->get('foo'));
}
public function testLo | {
"filepath": "tests/Cache/CacheMemoizedStoreTest.php",
"language": "php",
"file_size": 1702,
"cut_index": 537,
"middle_length": 229
} |
public static function segmentsProvider()
{
return [
['', []],
['foo/bar', ['foo', 'bar']],
['foo/bar//baz', ['foo', 'bar', 'baz']],
['foo/0/bar', ['foo', '0', 'bar']],
];
}
public function testUrlMethod()
{
$request = Request::cr... | /bar?name=taylor', $request->fullUrl());
$request = Request::create('https://foo.com');
$this->assertSame('https://foo.com', $request->fullUrl());
$request = Request::create('https://foo.com');
$this->assertSame('https://f | ->assertSame('http://foo.com/foo/bar', $request->url());
}
public function testFullUrlMethod()
{
$request = Request::create('http://foo.com/foo/bar?name=taylor');
$this->assertSame('http://foo.com/foo | {
"filepath": "tests/Http/HttpRequestTest.php",
"language": "php",
"file_size": 79884,
"cut_index": 3790,
"middle_length": 229
} |
ag;
use Illuminate\Support\ViewErrorBag;
use JsonSerializable;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
class HttpResponseTest extends TestCase
{
public func... | son', $response->headers->get('Content-Type'));
$response = new Response(new ArrayableAndJsonableStub);
$this->assertSame('{"foo":"bar"}', $response->getContent());
$this->assertSame('application/json', $response->headers->get('Con | is->assertSame('application/json', $response->headers->get('Content-Type'));
$response = new Response(new JsonableStub);
$this->assertSame('foo', $response->getContent());
$this->assertSame('application/j | {
"filepath": "tests/Http/HttpResponseTest.php",
"language": "php",
"file_size": 10600,
"cut_index": 921,
"middle_length": 229
} |
k\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
/**
* @link https://www.php.net/manual/en/function.gd-info.php
*/
#[RequiresPhpExtension('gd')]
class HttpTestingFileFactoryTest extends TestCase
{
public function testImagePng()
{
if (! ... | if (! $this->isGDSupported('JPEG Support')) {
$this->markTestSkipped('Requires JPEG support.');
}
$jpeg = (new FileFactory)->image('test.jpeg', 15, 20);
$jpg = (new FileFactory)->image('test.jpg');
$info = ge | etimagesize($image->getRealPath());
$this->assertSame('image/png', $info['mime']);
$this->assertSame(15, $info[0]);
$this->assertSame(20, $info[1]);
}
public function testImageJpeg()
{
| {
"filepath": "tests/Http/HttpTestingFileFactoryTest.php",
"language": "php",
"file_size": 4281,
"cut_index": 614,
"middle_length": 229
} |
ase;
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
class HttpUploadedFileTest extends TestCase
{
public function testUploadedFileCanRetrieveContentsFromTextFile()
{
$file = new UploadedFile(
__DIR__.'/fixtures/test.txt',
'test.txt',
n... | this->assertSame('', $symfonyFile->getClientOriginalPath());
$file = UploadedFile::createFromBase($symfonyFile);
$this->assertSame('', $file->getClientOriginalName());
$this->assertSame('', $file->getClientOriginalPath());
| }
public function testUploadedFileInRequestContainsOriginalPathAndName()
{
$symfonyFile = new SymfonyUploadedFile(__FILE__, '');
$this->assertSame('', $symfonyFile->getClientOriginalName());
$ | {
"filepath": "tests/Http/HttpUploadedFileTest.php",
"language": "php",
"file_size": 3332,
"cut_index": 614,
"middle_length": 229
} |
nate\Database\Eloquent\Model;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\MissingValue;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class JsonResourceTest extends TestCase
{
public function testJsonResourceNullAttributes()
{
$model = new class extends Model {
... | lation'));
$this->assertNotInstanceOf(MissingValue::class, $resource->whenExistsLoaded('relation'));
$this->assertNull($resource->whenAggregated('relation', 'column', 'sum'));
$this->assertNull($resource->whenCounted('relation'));
| urce = new JsonResource($model);
$this->assertNotInstanceOf(MissingValue::class, $resource->whenAggregated('relation', 'column', 'sum'));
$this->assertNotInstanceOf(MissingValue::class, $resource->whenCounted('re | {
"filepath": "tests/Http/JsonResourceTest.php",
"language": "php",
"file_size": 2635,
"cut_index": 563,
"middle_length": 229
} |
nvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
class CacheTest extends TestCase
{
public function testItCanGenerateDefinitionViaStaticMethod()
{
$signature = (string) Cache::using('... | 'max_age=120',
'no-transform',
's_maxage=60',
'etag' => true,
]);
$this->assertSame('Illuminate\Http\Middleware\SetCacheHeaders:max_age=120;no-transform;s_maxage=60;etag', $signature);
$s | g) Cache::using('max_age=120;no-transform;s_maxage=60');
$this->assertSame('Illuminate\Http\Middleware\SetCacheHeaders:max_age=120;no-transform;s_maxage=60', $signature);
$signature = (string) Cache::using([
| {
"filepath": "tests/Http/Middleware/CacheTest.php",
"language": "php",
"file_size": 6307,
"cut_index": 716,
"middle_length": 229
} |
esponse;
class PrefersJsonResponsesTest extends TestCase
{
public function testItRewritesMissingAcceptHeader()
{
$request = Request::create('/', 'GET');
$request->headers->remove('Accept');
$this->runMiddleware($request);
$this->assertSame('application/json', $request->headers... | on/json', $request->headers->get('Accept'));
}
public function testItRewritesStarSlashStarAcceptHeader()
{
$request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => '*/*']);
$this->runMiddleware($request);
|
}
public function testItRewritesEmptyAcceptHeader()
{
$request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => '']);
$this->runMiddleware($request);
$this->assertSame('applicati | {
"filepath": "tests/Http/Middleware/PrefersJsonResponsesTest.php",
"language": "php",
"file_size": 7170,
"cut_index": 716,
"middle_length": 229
} |
Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Session\Session;
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
use Illuminate\Http\Exceptions\OriginMismatchException;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Session\TokenMismatchException;
use M... | $response = $middleware->handle($request, fn () => new Response('OK'));
$this->assertSame('OK', $response->getContent());
}
public function test_same_site_header_rejected_by_default()
{
$middleware = $this->createMiddleware | parent::tearDown();
}
public function test_same_origin_header_passes()
{
$middleware = $this->createMiddleware();
$request = $this->createRequest(['HTTP_SEC_FETCH_SITE' => 'same-origin']);
| {
"filepath": "tests/Http/Middleware/PreventRequestForgeryTest.php",
"language": "php",
"file_size": 4825,
"cut_index": 614,
"middle_length": 229
} |
ase
{
/**
* Test no zero-width space character returns the same string.
*/
public function test_no_zero_width_space_character_returns_the_same_string()
{
$request = new Request;
$request->merge([
'title' => 'This title does not contain any zero-width space',
])... | est->merge([
'title' => 'This title contains a zero-width space at the beginning',
]);
$middleware = new TrimStrings;
$middleware->handle($request, function ($req) {
$this->assertSame('This title contains | );
});
}
/**
* Test leading zero-width space character is trimmed [ZWSP].
*/
public function test_leading_zero_width_space_character_is_trimmed()
{
$request = new Request;
$requ | {
"filepath": "tests/Http/Middleware/TrimStringsTest.php",
"language": "php",
"file_size": 9165,
"cut_index": 716,
"middle_length": 229
} |
st()
{
$req = $this->createProxiedRequest();
$this->assertSame('192.168.10.10', $req->getClientIp(), 'Assert untrusted proxy x-forwarded-for header not used');
$this->assertSame('http', $req->getScheme(), 'Assert untrusted proxy x-forwarded-proto header not used');
$this->assertSame... | roxies.
*
* Again, this re-tests Symfony's Request class.
*/
public function test_does_trust_trusted_proxy()
{
$req = $this->createProxiedRequest();
$req::setTrustedProxies(['192.168.10.10'], $this->headerAll);
| t used');
$this->assertSame('', $req->getBaseUrl(), 'Assert untrusted proxy x-forwarded-prefix header not used');
}
/**
* Test that Symfony DOES indeed trust X-Forwarded-*
* headers when given trusted p | {
"filepath": "tests/Http/Middleware/TrustProxiesTest.php",
"language": "php",
"file_size": 19067,
"cut_index": 1331,
"middle_length": 229
} |
\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Facade;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class VitePreloadingTest extends TestCase
{
protected function tearDown(): void
{
Facade::setFacadeApplication(null);
... | Request, function () {
return new Response('Hello Laravel');
});
$this->assertNull($response->headers->get('Link'));
}
public function testItAddsPreloadLinkHeader()
{
$app = new Container;
$app->ins | >instance(Vite::class, new class extends Vite
{
protected $preloadedAssets = [];
});
Facade::setFacadeApplication($app);
$response = (new AddLinkHeadersForPreloadedAssets)->handle(new | {
"filepath": "tests/Http/Middleware/VitePreloadingTest.php",
"language": "php",
"file_size": 8135,
"cut_index": 716,
"middle_length": 229
} |
te\Tests\Http\Resources\JsonApi;
use BadMethodCallException;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\JsonApi\JsonApiResource;
use PHPUnit\Framework\TestCase;
class JsonApiResourceTest extends TestCase
{
protected function tearDown(): void
{
JsonResource::flushSta... | \Http\Resources\JsonApi\JsonApiResource::wrap() method is not allowed.');
JsonApiResource::wrap('laravel');
}
public function testUnableToUnsetWrapper()
{
$this->expectException(BadMethodCallException::class);
$this->e | $this->assertSame('data', JsonApiResource::$wrap);
}
public function testUnableToSetWrapper()
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('Using Illuminate | {
"filepath": "tests/Http/Resources/JsonApi/JsonApiResourceTest.php",
"language": "php",
"file_size": 1588,
"cut_index": 537,
"middle_length": 229
} |
$this->repository = new Repository($this->config = [
'foo' => 'bar',
'bar' => 'baz',
'baz' => 'bat',
'null' => null,
'boolean' => true,
'integer' => 1,
'float' => 1.1,
'associate' => [
'x' => 'xxx',
... | 'c', $this->repository->get('a.b')
);
$this->assertNull(
$this->repository->get('a.b.c')
);
$this->assertNull($this->repository->get('x.y.z'));
$this->assertNull($this->repository->get('.'));
}
| 'a.b' => 'c',
'a' => [
'b.c' => 'd',
],
]);
parent::setUp();
}
public function testGetValueWhenKeyContainDot()
{
$this->assertSame(
| {
"filepath": "tests/Config/RepositoryTest.php",
"language": "php",
"file_size": 10770,
"cut_index": 921,
"middle_length": 229
} |
nection;
use Illuminate\Redis\Connections\PredisConnection;
use Illuminate\Redis\Limiters\ConcurrencyLimiter;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class ConcurrencyLimiterTest extends TestCase
{
public function testAcquireUsesHashTagsOnPhpRedisClusterConnection()
{
$connection = m::mock(Ph... | && $args[1][1] === '{test-limiter}2'
&& $args[1][2] === '{test-limiter}3'
&& $args[1][3] === '{test-limiter}'; // ARGV[1] = hash-tagged prefix
}))->andReturn('{test-limiter}1');
// release() also calls eval | ion->shouldReceive('command')->once()->with('eval', m::on(function ($args) {
return str_contains($args[0], 'mget')
&& $args[2] === 3
&& $args[1][0] === '{test-limiter}1'
| {
"filepath": "tests/Redis/ConcurrencyLimiterTest.php",
"language": "php",
"file_size": 8539,
"cut_index": 716,
"middle_length": 229
} |
ption;
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
use Illuminate\Redis\Limiters\ConcurrencyLimiter;
use PHPUnit\Framework\TestCase;
use Throwable;
class ConcurrentLimiterTest extends TestCase
{
use InteractsWithRedis;
protected function setUp(): void
{
parent::setUp();
... | = $i;
});
}
try {
(new ConcurrencyLimiterMockThatDoesntRelease($this->redis(), 'key', 2, 5))->block(0, function () use (&$store) {
$store[] = 3;
});
} catch (Throwable $e) {
| ilable()
{
$store = [];
foreach (range(1, 2) as $i) {
(new ConcurrencyLimiterMockThatDoesntRelease($this->redis(), 'key', 2, 5))->block(2, function () use (&$store, $i) {
$store[] | {
"filepath": "tests/Redis/ConcurrentLimiterTest.php",
"language": "php",
"file_size": 4384,
"cut_index": 614,
"middle_length": 229
} |
Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
use Illuminate\Redis\Limiters\DurationLimiter;
use PHPUnit\Framework\TestCase;
use Throwable;
class DurationLimiterTest extends TestCase
{
use InteractsWithRedis;
protected function setUp(): void
{
parent::setUp();
$this->setUpRed... | ction () use (&$store) {
$store[] = 2;
});
try {
(new DurationLimiter($this->redis(), 'key', 2, 2))->block(0, function () use (&$store) {
$store[] = 3;
});
} catch (Throwable $e) | $store = [];
(new DurationLimiter($this->redis(), 'key', 2, 2))->block(0, function () use (&$store) {
$store[] = 1;
});
(new DurationLimiter($this->redis(), 'key', 2, 2))->block(0, fun | {
"filepath": "tests/Redis/DurationLimiterTest.php",
"language": "php",
"file_size": 4954,
"cut_index": 614,
"middle_length": 229
} |
r_name' => false,
]);
$this->assertSame([
'stream' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
], $result);
}
public function testNormalizeContextConvertsSslKeyToStream()
{
$connector = new TestablePhp... | lizeContextPassesThroughStreamKey()
{
$connector = new TestablePhpRedisConnector;
$context = [
'stream' => [
'verify_peer' => false,
],
];
$result = $connector->testNormalizeCont | ],
]);
$this->assertSame([
'stream' => [
'verify_peer' => false,
'cafile' => '/path/to/ca.pem',
],
], $result);
}
public function testNorma | {
"filepath": "tests/Redis/PhpRedisConnectorTest.php",
"language": "php",
"file_size": 9431,
"cut_index": 921,
"middle_length": 229
} |
inate\Redis\Connectors\PredisConnector;
use PHPUnit\Framework\TestCase;
class PredisConnectorTest extends TestCase
{
public function testFormatHostLeavesConfigUnchangedWhenHostIsMissing()
{
$connector = new TestablePredisConnector;
$config = ['scheme' => 'tls'];
$this->assertSame($con... | ctor = new TestablePredisConnector;
$this->assertSame([
'host' => '127.0.0.1',
'scheme' => 'tls',
], $connector->testFormatHost([
'host' => 'tls://127.0.0.1',
]));
}
public function test | $config = ['host' => '127.0.0.1', 'scheme' => 'tls'];
$this->assertSame($config, $connector->testFormatHost($config));
}
public function testFormatHostUsesHostSchemeWhenSchemeNotConfigured()
{
$conne | {
"filepath": "tests/Redis/PredisConnectorTest.php",
"language": "php",
"file_size": 2346,
"cut_index": 563,
"middle_length": 229
} |
>set('one', 'mohamed', 'EX', 5, 'NX');
$this->assertSame('mohamed', $redis->get('one'));
$this->assertNotEquals(-1, $redis->ttl('one'));
// It doesn't override when NX mode
$redis->set('one', 'taylor', 'EX', 5, 'NX');
$this->assertSame('mohamed', $redis->get(... | ertSame('mohamed', $redis->get('three'));
$this->assertNotEquals(-1, $redis->ttl('three'));
$this->assertNotEquals(-1, $redis->pttl('three'));
$redis->flushall();
}
}
public function testItDeletesKeys() | s if XX mode is on and key doesn't exist
$redis->set('two', 'taylor', 'PX', 5, 'XX');
$this->assertNull($redis->get('two'));
$redis->set('three', 'mohamed', 'PX', 5000);
$this->ass | {
"filepath": "tests/Redis/RedisConnectionTest.php",
"language": "php",
"file_size": 32951,
"cut_index": 1331,
"middle_length": 229
} |
cted function tearDown(): void
{
$this->tearDownRedis();
parent::tearDown();
}
public function testDefaultConfiguration()
{
$host = env('REDIS_HOST', '127.0.0.1');
$port = env('REDIS_PORT', 6379);
$predisClient = $this->redis['predis']->connection()->client();
... | Client->getPort());
$this->assertSame('default', $phpRedisClient->client('GETNAME'));
}
public function testUrl()
{
$host = env('REDIS_HOST', '127.0.0.1');
$port = env('REDIS_PORT', 6379);
$predis = new RedisMa | is->assertEquals($port, $parameters->port);
$phpRedisClient = $this->redis['phpredis']->connection()->client();
$this->assertEquals($host, $phpRedisClient->getHost());
$this->assertEquals($port, $phpRedis | {
"filepath": "tests/Redis/RedisConnectorTest.php",
"language": "php",
"file_size": 10514,
"cut_index": 921,
"middle_length": 229
} |
se Illuminate\Redis\Connections\PhpRedisConnection;
use Illuminate\Redis\Events\CommandExecuted;
use Illuminate\Redis\Events\CommandFailed;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Redis;
class RedisEventsTest extends TestCase
{
public function testCommandFailedEventIsDispatched()
{
$excep... | ent->parameters === ['key']
&& $event->exception === $exception;
}));
$connection = new PhpRedisConnection($client);
$connection->setEventDispatcher($events);
$this->expectException(Exception::class);
| r::class);
$events->shouldReceive('dispatch')->once()->with(m::on(function ($event) use ($exception) {
return $event instanceof CommandFailed
&& $event->command === 'get'
&& $ev | {
"filepath": "tests/Redis/RedisEventsTest.php",
"language": "php",
"file_size": 3193,
"cut_index": 614,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.