language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | laravel | framework | f3894d09f6ed1fea4e97f6c4e4b11e0b2fdbd8d9.json | Use packages file to cache package providers | tests/Foundation/fixtures/vendor/package_c/package_b/composer.json | @@ -1,8 +0,0 @@
-{
- "extra": {
- "providers": [
- "bar",
- "baz"
- ]
- }
-} | true |
Other | laravel | framework | 92ffcb35f2e863984aff235f7d094f8b5ae1a3af.json | Apply fixes from StyleCI (#19398) | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -102,7 +102,7 @@ public function get($path)
*/
public function put($path, $contents, $options = [])
{
- $options = is_string($options)
+ $options = is_string($options)
? ['visibility' => $options]
: (array) $options;
| false |
Other | laravel | framework | 1509e58ad15fc1a59b44d7804f29be00024e3eff.json | Return entire string if search is not found. | src/Illuminate/Support/Str.php | @@ -39,7 +39,7 @@ class Str
public static function after($subject, $search)
{
if (! static::contains($subject, $search)) {
- return '';
+ return $subject;
}
$searchEndPos = strpos($subject, $search) + static::length($search); | true |
Other | laravel | framework | 1509e58ad15fc1a59b44d7804f29be00024e3eff.json | Return entire string if search is not found. | tests/Support/SupportHelpersTest.php | @@ -256,7 +256,7 @@ public function testStrAfter()
{
$this->assertEquals('nah', str_after('hannah', 'han'));
$this->assertEquals('nah', str_after('hannah', 'n'));
- $this->assertEmpty(str_after('hannah', 'xxxx'));
+ $this->assertEquals('hannah', str_after('hannah', 'xxxx'));
}
public function testStrContains() | true |
Other | laravel | framework | 1509e58ad15fc1a59b44d7804f29be00024e3eff.json | Return entire string if search is not found. | tests/Support/SupportStrTest.php | @@ -80,7 +80,7 @@ public function testStrAfter()
{
$this->assertEquals('nah', Str::after('hannah', 'han'));
$this->assertEquals('nah', Str::after('hannah', 'n'));
- $this->assertEmpty(Str::after('hannah', 'xxxx'));
+ $this->assertEquals('hannah', Str::after('hannah', 'xxxx'));
}
public function testStrContains() | true |
Other | laravel | framework | 4c4810a4192d764cea26f150b49d2a1c828488dd.json | Return entire string if search is not found. | src/Illuminate/Support/Str.php | @@ -39,7 +39,7 @@ class Str
public static function after($subject, $search)
{
if (! static::contains($subject, $search)) {
- return '';
+ return $subject;
}
$searchEndPos = strpos($subject, $search) + static::length($search); | true |
Other | laravel | framework | 4c4810a4192d764cea26f150b49d2a1c828488dd.json | Return entire string if search is not found. | tests/Support/SupportHelpersTest.php | @@ -256,7 +256,7 @@ public function testStrAfter()
{
$this->assertEquals('nah', str_after('hannah', 'han'));
$this->assertEquals('nah', str_after('hannah', 'n'));
- $this->assertEmpty(str_after('hannah', 'xxxx'));
+ $this->assertEquals('hannah', str_after('hannah', 'xxxx'));
}
public function testStrContains() | true |
Other | laravel | framework | 4c4810a4192d764cea26f150b49d2a1c828488dd.json | Return entire string if search is not found. | tests/Support/SupportStrTest.php | @@ -80,7 +80,7 @@ public function testStrAfter()
{
$this->assertEquals('nah', Str::after('hannah', 'han'));
$this->assertEquals('nah', Str::after('hannah', 'n'));
- $this->assertEmpty(Str::after('hannah', 'xxxx'));
+ $this->assertEquals('hannah', Str::after('hannah', 'xxxx'));
}
public function testStrContains() | true |
Other | laravel | framework | bec5df0410516ceb62d5d4acd7db6927dbdca675.json | Add hasAny() method to Request (#19367) | src/Illuminate/Http/Concerns/InteractsWithInput.php | @@ -91,6 +91,25 @@ public function has($key)
return true;
}
+ /**
+ * Determine if the request contains any of the given inputs.
+ *
+ * @param dynamic $key
+ * @return bool
+ */
+ public function hasAny(...$keys)
+ {
+ $input = $this->all();
+
+ foreach ($keys as $key) {
+ if (Arr::has($input, $key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Determine if the request contains a non-empty value for an input item.
* | true |
Other | laravel | framework | bec5df0410516ceb62d5d4acd7db6927dbdca675.json | Add hasAny() method to Request (#19367) | tests/Http/HttpRequestTest.php | @@ -233,6 +233,25 @@ public function testHasMethod()
$this->assertTrue($request->has('foo.baz'));
}
+ public function testHasAnyMethod()
+ {
+ $request = Request::create('/', 'GET', ['name' => 'Taylor', 'age' => '', 'city' => null]);
+ $this->assertTrue($request->hasAny('name'));
+ $this->assertTrue($request->hasAny('age'));
+ $this->assertTrue($request->hasAny('city'));
+ $this->assertFalse($request->hasAny('foo'));
+ $this->assertTrue($request->hasAny('name', 'email'));
+
+ $request = Request::create('/', 'GET', ['name' => 'Taylor', 'email' => 'foo']);
+ $this->assertTrue($request->hasAny('name', 'email'));
+ $this->assertFalse($request->hasAny('surname', 'password'));
+
+ $request = Request::create('/', 'GET', ['foo' => ['bar' => null, 'baz' => '']]);
+ $this->assertTrue($request->hasAny('foo.bar'));
+ $this->assertTrue($request->hasAny('foo.baz'));
+ $this->assertFalse($request->hasAny('foo.bax'));
+ }
+
public function testFilledMethod()
{
$request = Request::create('/', 'GET', ['name' => 'Taylor', 'age' => '', 'city' => null]); | true |
Other | laravel | framework | eee8c84f5d8be26d7acef2292a97ff391e2de320.json | Apply fixes from StyleCI (#19355) | tests/Integration/Notifications/SendingMailNotificationsTest.php | @@ -4,8 +4,8 @@
use Orchestra\Testbench\TestCase;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Mail\Mailable;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Channels\MailChannel; | false |
Other | laravel | framework | 653dc3db32a09797797e788d879367f9de67d52d.json | Fix method description leftovers (#19348) | src/Illuminate/Validation/Factory.php | @@ -211,7 +211,7 @@ public function extendImplicit($rule, $extension, $message = null)
}
/**
- * Register a custom implicit validator extension.
+ * Register a custom dependent validator extension.
*
* @param string $rule
* @param \Closure|string $extension
@@ -228,7 +228,7 @@ public function extendDependent($rule, $extension, $message = null)
}
/**
- * Register a custom implicit validator message replacer.
+ * Register a custom validator message replacer.
*
* @param string $rule
* @param \Closure|string $replacer | false |
Other | laravel | framework | 0f5337f854ecdd722e7e289ff58cc252337e7a9d.json | specify method. rename conjoin | src/Illuminate/Support/Collection.php | @@ -181,23 +181,6 @@ public function collapse()
return new static(Arr::collapse($this->items));
}
- /**
- * Conjoin all values of a collection with those of another, regardless of keys.
- *
- * @param \Traversable $source
- * @return self
- */
- public function conjoin($source)
- {
- $joinedCollection = new static($this);
-
- foreach ($source as $item) {
- $joinedCollection->push($item);
- }
-
- return $joinedCollection;
- }
-
/**
* Determine if an item exists in the collection.
*
@@ -1008,6 +991,23 @@ public function push($value)
return $this;
}
+ /**
+ * Push all of the given items onto the collection.
+ *
+ * @param \Traversable $source
+ * @return self
+ */
+ public function concat($source)
+ {
+ $result = new static($this);
+
+ foreach ($source as $item) {
+ $result->push($item);
+ }
+
+ return $result;
+ }
+
/**
* Get and remove an item from the collection.
* | true |
Other | laravel | framework | 0f5337f854ecdd722e7e289ff58cc252337e7a9d.json | specify method. rename conjoin | tests/Database/DatabaseEloquentHasOneTest.php | @@ -76,7 +76,7 @@ public function testHasOneWithArrayDefault()
public function testMakeMethodDoesNotSaveNewModel()
{
$relation = $this->getRelation();
- $instance = $this->getMockBuilder('Illuminate\Database\Eloquent\Model')->setMethods(['newInstance', 'setAttribute'])->getMock();
+ $instance = $this->getMockBuilder('Illuminate\Database\Eloquent\Model')->setMethods(['save', 'newInstance', 'setAttribute'])->getMock();
$relation->getRelated()->shouldReceive('newInstance')->with(['name' => 'taylor'])->andReturn($instance);
$instance->expects($this->once())->method('setAttribute')->with('foreign_key', 1);
$instance->expects($this->never())->method('save'); | true |
Other | laravel | framework | 0f5337f854ecdd722e7e289ff58cc252337e7a9d.json | specify method. rename conjoin | tests/Support/SupportCollectionTest.php | @@ -1722,7 +1722,7 @@ public function testCombineWithCollection()
$this->assertSame($expected, $actual);
}
- public function testConJoinWithArray()
+ public function testConcatWithArray()
{
$expected = [
0 => 4,
@@ -1740,14 +1740,14 @@ public function testConJoinWithArray()
];
$collection = new Collection([4, 5, 6]);
- $collection = $collection->conjoin(['a', 'b', 'c']);
- $collection = $collection->conjoin(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe']);
- $actual = $collection->conjoin(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe'])->toArray();
+ $collection = $collection->concat(['a', 'b', 'c']);
+ $collection = $collection->concat(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe']);
+ $actual = $collection->concat(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe'])->toArray();
$this->assertSame($expected, $actual);
}
- public function testConJoinWithCollection()
+ public function testConcatWithCollection()
{
$expected = [
0 => 4,
@@ -1767,9 +1767,9 @@ public function testConJoinWithCollection()
$firstCollection = new Collection([4, 5, 6]);
$secondCollection = new Collection(['a', 'b', 'c']);
$thirdCollection = new Collection(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe']);
- $firstCollection = $firstCollection->conjoin($secondCollection);
- $firstCollection = $firstCollection->conjoin($thirdCollection);
- $actual = $firstCollection->conjoin($thirdCollection)->toArray();
+ $firstCollection = $firstCollection->concat($secondCollection);
+ $firstCollection = $firstCollection->concat($thirdCollection);
+ $actual = $firstCollection->concat($thirdCollection)->toArray();
$this->assertSame($expected, $actual);
} | true |
Other | laravel | framework | 85fed0e37227f4fe85c362e7535455e461d0757b.json | Resolve paginators from the container (#19328) | src/Illuminate/Database/Concerns/BuildsQueries.php | @@ -2,6 +2,10 @@
namespace Illuminate\Database\Concerns;
+use Illuminate\Container\Container;
+use Illuminate\Pagination\Paginator;
+use Illuminate\Pagination\LengthAwarePaginator;
+
trait BuildsQueries
{
/**
@@ -89,4 +93,38 @@ public function when($value, $callback, $default = null)
return $this;
}
+
+ /**
+ * Create a new length-aware paginator instance.
+ *
+ * @param \Illuminate\Support\Collection $items
+ * @param int $total
+ * @param int $perPage
+ * @param int $currentPage
+ * @param array $options
+ * @return \Illuminate\Pagination\LengthAwarePaginator
+ */
+ protected function paginator($items, $total, $perPage, $currentPage, $options)
+ {
+ return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact(
+ 'items', 'total', 'perPage', 'currentPage', 'options'
+ ));
+ }
+
+ /**
+ * Create a new simple paginator instance.
+ *
+ * @param \Illuminate\Support\Collection $items
+ * @param int $total
+ * @param int $perPage
+ * @param int $currentPage
+ * @param array $options
+ * @return \Illuminate\Pagination\Paginator
+ */
+ protected function simplePaginator($items, $perPage, $currentPage, $options)
+ {
+ return Container::getInstance()->makeWith(Paginator::class, compact(
+ 'items', 'perPage', 'currentPage', 'options'
+ ));
+ }
} | true |
Other | laravel | framework | 85fed0e37227f4fe85c362e7535455e461d0757b.json | Resolve paginators from the container (#19328) | src/Illuminate/Database/Eloquent/Builder.php | @@ -9,7 +9,6 @@
use Illuminate\Pagination\Paginator;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\Concerns\BuildsQueries;
-use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Builder as QueryBuilder;
@@ -691,7 +690,7 @@ public function paginate($perPage = null, $columns = ['*'], $pageName = 'page',
? $this->forPage($page, $perPage)->get($columns)
: $this->model->newCollection();
- return new LengthAwarePaginator($results, $total, $perPage, $page, [
+ return $this->paginator($results, $total, $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]);
@@ -717,7 +716,7 @@ public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'p
// paginator instances for these results with the given page and per page.
$this->skip(($page - 1) * $perPage)->take($perPage + 1);
- return new Paginator($this->get($columns), $perPage, $page, [
+ return $this->simplePaginator($this->get($columns), $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]); | true |
Other | laravel | framework | 85fed0e37227f4fe85c362e7535455e461d0757b.json | Resolve paginators from the container (#19328) | src/Illuminate/Database/Query/Builder.php | @@ -15,7 +15,6 @@
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Concerns\BuildsQueries;
use Illuminate\Database\Query\Grammars\Grammar;
-use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Database\Query\Processors\Processor;
class Builder
@@ -1729,7 +1728,7 @@ public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $p
$results = $total ? $this->forPage($page, $perPage)->get($columns) : collect();
- return new LengthAwarePaginator($results, $total, $perPage, $page, [
+ return $this->paginator($results, $total, $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]);
@@ -1752,7 +1751,7 @@ public function simplePaginate($perPage = 15, $columns = ['*'], $pageName = 'pag
$this->skip(($page - 1) * $perPage)->take($perPage + 1);
- return new Paginator($this->get($columns), $perPage, $page, [
+ return $this->simplePaginator($this->get($columns), $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]); | true |
Other | laravel | framework | ccb64d163da0af16774e710b5218b0846d0b8e4a.json | Ignore jetbrains IDE folder (#19323) | .gitignore | @@ -4,4 +4,5 @@ composer.lock
.php_cs.cache
.DS_Store
Thumbs.db
-/phpunit.xml
\ No newline at end of file
+/phpunit.xml
+/.idea | false |
Other | laravel | framework | 5b6ba5acb3961b809148fca234f0285d4cb22891.json | Add new `conJoin()` method to collection | src/Illuminate/Support/Collection.php | @@ -181,6 +181,21 @@ public function collapse()
return new static(Arr::collapse($this->items));
}
+ /**
+ * Conjoin all values of a collection with those of another, regardless of keys.
+ *
+ * @param \Traversable $source
+ * @return self
+ */
+ public function conJoin($source)
+ {
+ foreach ($source as $item) {
+ $this->push($item);
+ }
+
+ return $this;
+ }
+
/**
* Determine if an item exists in the collection.
* | true |
Other | laravel | framework | 5b6ba5acb3961b809148fca234f0285d4cb22891.json | Add new `conJoin()` method to collection | tests/Support/SupportCollectionTest.php | @@ -1722,6 +1722,41 @@ public function testCombineWithCollection()
$this->assertSame($expected, $actual);
}
+ public function testConJoinWithArray()
+ {
+ $expected = [
+ 0 => 4,
+ 1 => 5,
+ 2 => 6,
+ 3 => 'a',
+ 4 => 'b',
+ 5 => 'c',
+ ];
+
+ $collection = new Collection([4, 5, 6]);
+ $actual = $collection->conJoin(['a', 'b', 'c'])->toArray();
+
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testConJoinWithCollection()
+ {
+ $expected = [
+ 0 => 4,
+ 1 => 5,
+ 2 => 6,
+ 3 => 'a',
+ 4 => 'b',
+ 5 => 'c',
+ ];
+
+ $firstCollection = new Collection([4, 5, 6]);
+ $secondCollection = new Collection(['a', 'b', 'c']);
+ $actual = $firstCollection->conJoin($secondCollection)->toArray();
+
+ $this->assertSame($expected, $actual);
+ }
+
public function testReduce()
{
$data = new Collection([1, 2, 3]); | true |
Other | laravel | framework | 9abdb287ba4a577c53fe8fccdf2305ce45fbdb81.json | Apply fixes from StyleCI (#19305) | src/Illuminate/Support/Collection.php | @@ -659,7 +659,7 @@ public function intersect($items)
}
/**
- * Intersect the collection with the given items by key
+ * Intersect the collection with the given items by key.
*
* @param mixed $items
* @return static | false |
Other | laravel | framework | 4fc0ea5389424876bdbd858bbb3df97e9adc0b28.json | add intersect by keys method to collections | src/Illuminate/Support/Collection.php | @@ -658,6 +658,17 @@ public function intersect($items)
return new static(array_intersect($this->items, $this->getArrayableItems($items)));
}
+ /**
+ * Intersect the collection with the given items by key
+ *
+ * @param mixed $items
+ * @return static
+ */
+ public function intersectByKeys($items)
+ {
+ return new static(array_intersect_key($this->items, $this->getArrayableItems($items)));
+ }
+
/**
* Determine if the collection is empty or not.
* | true |
Other | laravel | framework | 4fc0ea5389424876bdbd858bbb3df97e9adc0b28.json | add intersect by keys method to collections | tests/Support/SupportCollectionTest.php | @@ -570,6 +570,18 @@ public function testIntersectCollection()
$this->assertEquals(['first_word' => 'Hello'], $c->intersect(new Collection(['first_world' => 'Hello', 'last_word' => 'World']))->all());
}
+ public function testIntersectByKeysNull()
+ {
+ $c = new Collection(['name' => 'Mateus', 'age' => 18]);
+ $this->assertEquals([], $c->intersectByKeys(null)->all());
+ }
+
+ public function testIntersectByKeys()
+ {
+ $c = new Collection(['name' => 'Mateus', 'age' => 18]);
+ $this->assertEquals(['name' => 'Mateus'], $c->intersectByKeys(new Collection(['name' => 'Mateus', 'surname' => 'Guimaraes']))->all());
+ }
+
public function testUnique()
{
$c = new Collection(['Hello', 'World', 'World']); | true |
Other | laravel | framework | 3429b61dbed141e8b22542f4babd26372a52dee0.json | add assertViewIs() to TestResponse (#19291) | src/Illuminate/Foundation/Testing/TestResponse.php | @@ -405,6 +405,21 @@ public function json()
return $this->decodeResponseJson();
}
+ /**
+ * Assert that the response view equals the given value.
+ *
+ * @param string $value
+ * @return $this
+ */
+ public function assertViewIs($value)
+ {
+ $this->ensureResponseHasView();
+
+ PHPUnit::assertEquals($value, $this->original->getName());
+
+ return $this;
+ }
+
/**
* Assert that the response view has a given piece of bound data.
* | true |
Other | laravel | framework | 3429b61dbed141e8b22542f4babd26372a52dee0.json | add assertViewIs() to TestResponse (#19291) | tests/Foundation/FoundationTestResponseTest.php | @@ -12,6 +12,21 @@
class FoundationTestResponseTest extends TestCase
{
+ public function testAssertViewIs()
+ {
+ $baseResponse = tap(new Response, function ($response) {
+ $response->setContent(\Mockery::mock(View::class, [
+ 'render' => 'hello world',
+ 'getData' => ['foo' => 'bar'],
+ 'getName' => 'dir.my-view',
+ ]));
+ });
+
+ $response = TestResponse::fromBaseResponse($baseResponse);
+
+ $response->assertViewIs('dir.my-view');
+ }
+
public function testAssertViewHas()
{
$baseResponse = tap(new Response, function ($response) { | true |
Other | laravel | framework | 88ecd387f62bd8a083ec1998d39d9b5d881e2b35.json | Use blade comments (#19289) | src/Illuminate/Notifications/resources/views/email.blade.php | @@ -41,14 +41,14 @@
@endforeach
-<!-- Salutation -->
+{{-- Salutation --}}
@if (! empty($salutation))
{{ $salutation }}
@else
Regards,<br>{{ config('app.name') }}
@endif
-<!-- Subcopy -->
+{{-- Subcopy --}}
@isset($actionText)
@component('mail::subcopy')
If you’re having trouble clicking the "{{ $actionText }}" button, copy and paste the URL below | false |
Other | laravel | framework | 650f74cf5e5c0e3b1d85ce3315eb0496bc2560a1.json | Fix Timeoutless Job (#19266) | src/Illuminate/Queue/Worker.php | @@ -131,15 +131,17 @@ public function daemon($connectionName, $queue, WorkerOptions $options)
*/
protected function registerTimeoutHandler($job, WorkerOptions $options)
{
- if ($options->timeout > 0 && $this->supportsAsyncSignals()) {
+ $timeout = $this->timeoutForJob($job, $options);
+
+ if ($timeout > 0 && $this->supportsAsyncSignals()) {
// We will register a signal handler for the alarm signal so that we can kill this
// process if it is running too long because it has frozen. This uses the async
// signals supported in recent versions of PHP to accomplish it conveniently.
pcntl_signal(SIGALRM, function () {
$this->kill(1);
});
- pcntl_alarm($this->timeoutForJob($job, $options) + $options->sleep);
+ pcntl_alarm($timeout + $options->sleep);
}
}
| false |
Other | laravel | framework | 872be61fb64b5d63da92134b216cdf36657e860f.json | Use assertCount assertion (#19284) | tests/Database/DatabaseEloquentBelongsToManyTest.php | @@ -357,7 +357,7 @@ public function testFindManyMethod()
$result = $relation->findMany(['foo', 'bar']);
- $this->assertEquals(2, count($result));
+ $this->assertCount(2, $result);
$this->assertInstanceOf(StdClass::class, $result->first());
}
| true |
Other | laravel | framework | 872be61fb64b5d63da92134b216cdf36657e860f.json | Use assertCount assertion (#19284) | tests/Database/DatabaseEloquentIntegrationTest.php | @@ -479,7 +479,7 @@ public function testHasOnSelfReferencingBelongsToManyRelationship()
$results = EloquentTestUser::has('friends')->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('taylorotwell@gmail.com', $results->first()->email);
}
@@ -492,7 +492,7 @@ public function testWhereHasOnSelfReferencingBelongsToManyRelationship()
$query->where('email', 'abigailotwell@gmail.com');
})->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('taylorotwell@gmail.com', $results->first()->email);
}
@@ -504,7 +504,7 @@ public function testHasOnNestedSelfReferencingBelongsToManyRelationship()
$results = EloquentTestUser::has('friends.friends')->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('taylorotwell@gmail.com', $results->first()->email);
}
@@ -518,7 +518,7 @@ public function testWhereHasOnNestedSelfReferencingBelongsToManyRelationship()
$query->where('email', 'foo@gmail.com');
})->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('taylorotwell@gmail.com', $results->first()->email);
}
@@ -529,7 +529,7 @@ public function testHasOnSelfReferencingBelongsToManyRelationshipWithWherePivot(
$results = EloquentTestUser::has('friendsOne')->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('taylorotwell@gmail.com', $results->first()->email);
}
@@ -541,7 +541,7 @@ public function testHasOnNestedSelfReferencingBelongsToManyRelationshipWithWhere
$results = EloquentTestUser::has('friendsOne.friendsTwo')->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('taylorotwell@gmail.com', $results->first()->email);
}
@@ -552,7 +552,7 @@ public function testHasOnSelfReferencingBelongsToRelationship()
$results = EloquentTestPost::has('parentPost')->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('Child Post', $results->first()->name);
}
@@ -574,7 +574,7 @@ public function testWhereHasOnSelfReferencingBelongsToRelationship()
$query->where('name', 'Parent Post');
})->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('Child Post', $results->first()->name);
}
@@ -586,7 +586,7 @@ public function testHasOnNestedSelfReferencingBelongsToRelationship()
$results = EloquentTestPost::has('parentPost.parentPost')->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('Child Post', $results->first()->name);
}
@@ -600,7 +600,7 @@ public function testWhereHasOnNestedSelfReferencingBelongsToRelationship()
$query->where('name', 'Grandparent Post');
})->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('Child Post', $results->first()->name);
}
@@ -611,7 +611,7 @@ public function testHasOnSelfReferencingHasManyRelationship()
$results = EloquentTestPost::has('childPosts')->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('Parent Post', $results->first()->name);
}
@@ -624,7 +624,7 @@ public function testWhereHasOnSelfReferencingHasManyRelationship()
$query->where('name', 'Child Post');
})->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('Parent Post', $results->first()->name);
}
@@ -636,7 +636,7 @@ public function testHasOnNestedSelfReferencingHasManyRelationship()
$results = EloquentTestPost::has('childPosts.childPosts')->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('Grandparent Post', $results->first()->name);
}
@@ -650,7 +650,7 @@ public function testWhereHasOnNestedSelfReferencingHasManyRelationship()
$query->where('name', 'Child Post');
})->get();
- $this->assertEquals(1, count($results));
+ $this->assertCount(1, $results);
$this->assertEquals('Grandparent Post', $results->first()->name);
}
| true |
Other | laravel | framework | 872be61fb64b5d63da92134b216cdf36657e860f.json | Use assertCount assertion (#19284) | tests/Database/DatabaseEloquentModelTest.php | @@ -617,7 +617,7 @@ public function testPushManyRelation()
$this->assertTrue($model->push());
$this->assertEquals(1, $model->id);
$this->assertTrue($model->exists);
- $this->assertEquals(2, count($model->relationMany));
+ $this->assertCount(2, $model->relationMany);
$this->assertEquals([2, 3], $model->relationMany->pluck('id')->all());
}
| true |
Other | laravel | framework | 872be61fb64b5d63da92134b216cdf36657e860f.json | Use assertCount assertion (#19284) | tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php | @@ -395,34 +395,34 @@ public function testWhereHasWithDeletedRelationship()
$post = $abigail->posts()->create(['title' => 'First Title']);
$users = SoftDeletesTestUser::where('email', 'taylorotwell@gmail.com')->has('posts')->get();
- $this->assertEquals(0, count($users));
+ $this->assertCount(0, $users);
$users = SoftDeletesTestUser::where('email', 'abigailotwell@gmail.com')->has('posts')->get();
- $this->assertEquals(1, count($users));
+ $this->assertCount(1, $users);
$users = SoftDeletesTestUser::where('email', 'doesnt@exist.com')->orHas('posts')->get();
- $this->assertEquals(1, count($users));
+ $this->assertCount(1, $users);
$users = SoftDeletesTestUser::whereHas('posts', function ($query) {
$query->where('title', 'First Title');
})->get();
- $this->assertEquals(1, count($users));
+ $this->assertCount(1, $users);
$users = SoftDeletesTestUser::whereHas('posts', function ($query) {
$query->where('title', 'Another Title');
})->get();
- $this->assertEquals(0, count($users));
+ $this->assertCount(0, $users);
$users = SoftDeletesTestUser::where('email', 'doesnt@exist.com')->orWhereHas('posts', function ($query) {
$query->where('title', 'First Title');
})->get();
- $this->assertEquals(1, count($users));
+ $this->assertCount(1, $users);
// With Post Deleted...
$post->delete();
$users = SoftDeletesTestUser::has('posts')->get();
- $this->assertEquals(0, count($users));
+ $this->assertCount(0, $users);
}
/**
@@ -437,17 +437,17 @@ public function testWhereHasWithNestedDeletedRelationshipAndOnlyTrashedCondition
$post->delete();
$users = SoftDeletesTestUser::has('posts')->get();
- $this->assertEquals(0, count($users));
+ $this->assertCount(0, $users);
$users = SoftDeletesTestUser::whereHas('posts', function ($q) {
$q->onlyTrashed();
})->get();
- $this->assertEquals(1, count($users));
+ $this->assertCount(1, $users);
$users = SoftDeletesTestUser::whereHas('posts', function ($q) {
$q->withTrashed();
})->get();
- $this->assertEquals(1, count($users));
+ $this->assertCount(1, $users);
}
/**
@@ -463,10 +463,10 @@ public function testWhereHasWithNestedDeletedRelationship()
$comment->delete();
$users = SoftDeletesTestUser::has('posts.comments')->get();
- $this->assertEquals(0, count($users));
+ $this->assertCount(0, $users);
$users = SoftDeletesTestUser::doesntHave('posts.comments')->get();
- $this->assertEquals(1, count($users));
+ $this->assertCount(1, $users);
}
/**
@@ -481,7 +481,7 @@ public function testWhereHasWithNestedDeletedRelationshipAndWithTrashedCondition
$post->delete();
$users = SoftDeletesTestUserWithTrashedPosts::has('posts')->get();
- $this->assertEquals(1, count($users));
+ $this->assertCount(1, $users);
}
/** | true |
Other | laravel | framework | 872be61fb64b5d63da92134b216cdf36657e860f.json | Use assertCount assertion (#19284) | tests/Database/DatabaseMySqlSchemaGrammarTest.php | @@ -27,7 +27,7 @@ public function testBasicCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate utf8_unicode_ci', $statements[0]);
$blueprint = new Blueprint('users');
@@ -39,7 +39,7 @@ public function testBasicCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `id` int unsigned not null auto_increment primary key, add `email` varchar(255) not null', $statements[0]);
}
@@ -57,7 +57,7 @@ public function testEngineCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate utf8_unicode_ci engine = InnoDB', $statements[0]);
$blueprint = new Blueprint('users');
@@ -72,7 +72,7 @@ public function testEngineCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate utf8_unicode_ci engine = InnoDB', $statements[0]);
}
@@ -90,7 +90,7 @@ public function testCharsetCollationCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8mb4 collate utf8mb4_unicode_ci', $statements[0]);
$blueprint = new Blueprint('users');
@@ -105,7 +105,7 @@ public function testCharsetCollationCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci not null) default character set utf8 collate utf8_unicode_ci', $statements[0]);
}
@@ -123,7 +123,7 @@ public function testBasicCreateTableWithPrefix()
$statements = $blueprint->toSql($conn, $grammar);
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table `prefix_users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null)', $statements[0]);
}
@@ -133,7 +133,7 @@ public function testDropTable()
$blueprint->drop();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop table `users`', $statements[0]);
}
@@ -143,7 +143,7 @@ public function testDropTableIfExists()
$blueprint->dropIfExists();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop table if exists `users`', $statements[0]);
}
@@ -153,21 +153,21 @@ public function testDropColumn()
$blueprint->dropColumn('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop `foo`', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->dropColumn(['foo', 'bar']);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop `foo`, drop `bar`', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->dropColumn('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop `foo`, drop `bar`', $statements[0]);
}
@@ -177,7 +177,7 @@ public function testDropPrimary()
$blueprint->dropPrimary();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop primary key', $statements[0]);
}
@@ -187,7 +187,7 @@ public function testDropUnique()
$blueprint->dropUnique('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop index `foo`', $statements[0]);
}
@@ -197,7 +197,7 @@ public function testDropIndex()
$blueprint->dropIndex('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop index `foo`', $statements[0]);
}
@@ -207,7 +207,7 @@ public function testDropForeign()
$blueprint->dropForeign('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop foreign key `foo`', $statements[0]);
}
@@ -217,7 +217,7 @@ public function testDropTimestamps()
$blueprint->dropTimestamps();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop `created_at`, drop `updated_at`', $statements[0]);
}
@@ -227,7 +227,7 @@ public function testDropTimestampsTz()
$blueprint->dropTimestampsTz();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` drop `created_at`, drop `updated_at`', $statements[0]);
}
@@ -237,7 +237,7 @@ public function testRenameTable()
$blueprint->rename('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('rename table `users` to `foo`', $statements[0]);
}
@@ -247,7 +247,7 @@ public function testAddingPrimaryKey()
$blueprint->primary('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add primary key `bar`(`foo`)', $statements[0]);
}
@@ -257,7 +257,7 @@ public function testAddingPrimaryKeyWithAlgorithm()
$blueprint->primary('foo', 'bar', 'hash');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add primary key `bar` using hash(`foo`)', $statements[0]);
}
@@ -267,7 +267,7 @@ public function testAddingUniqueKey()
$blueprint->unique('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add unique `bar`(`foo`)', $statements[0]);
}
@@ -277,7 +277,7 @@ public function testAddingIndex()
$blueprint->index(['foo', 'bar'], 'baz');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add index `baz`(`foo`, `bar`)', $statements[0]);
}
@@ -287,7 +287,7 @@ public function testAddingIndexWithAlgorithm()
$blueprint->index(['foo', 'bar'], 'baz', 'hash');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add index `baz` using hash(`foo`, `bar`)', $statements[0]);
}
@@ -297,7 +297,7 @@ public function testAddingForeignKey()
$blueprint->foreign('foo_id')->references('id')->on('orders');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add constraint `users_foo_id_foreign` foreign key (`foo_id`) references `orders` (`id`)', $statements[0]);
}
@@ -307,7 +307,7 @@ public function testAddingIncrementingID()
$blueprint->increments('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `id` int unsigned not null auto_increment primary key', $statements[0]);
}
@@ -317,7 +317,7 @@ public function testAddingSmallIncrementingID()
$blueprint->smallIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `id` smallint unsigned not null auto_increment primary key', $statements[0]);
}
@@ -327,7 +327,7 @@ public function testAddingBigIncrementingID()
$blueprint->bigIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `id` bigint unsigned not null auto_increment primary key', $statements[0]);
}
@@ -337,7 +337,7 @@ public function testAddingColumnInTableFirst()
$blueprint->string('name')->first();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `name` varchar(255) not null first', $statements[0]);
}
@@ -347,7 +347,7 @@ public function testAddingColumnAfterAnotherColumn()
$blueprint->string('name')->after('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `name` varchar(255) not null after `foo`', $statements[0]);
}
@@ -359,7 +359,7 @@ public function testAddingGeneratedColumn()
$blueprint->integer('discounted_stored')->storedAs('price - 5');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `products` add `price` int not null, add `discounted_virtual` int as (price - 5), add `discounted_stored` int as (price - 5) stored', $statements[0]);
}
@@ -369,28 +369,28 @@ public function testAddingString()
$blueprint->string('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` varchar(255) not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` varchar(100) not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100)->nullable()->default('bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` varchar(100) null default \'bar\'', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100)->nullable()->default(new \Illuminate\Database\Query\Expression('CURRENT TIMESTAMP'));
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` varchar(100) null default CURRENT TIMESTAMP', $statements[0]);
}
@@ -400,7 +400,7 @@ public function testAddingText()
$blueprint->text('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` text not null', $statements[0]);
}
@@ -410,14 +410,14 @@ public function testAddingBigInteger()
$blueprint->bigInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` bigint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->bigInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` bigint not null auto_increment primary key', $statements[0]);
}
@@ -427,14 +427,14 @@ public function testAddingInteger()
$blueprint->integer('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` int not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->integer('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` int not null auto_increment primary key', $statements[0]);
}
@@ -444,14 +444,14 @@ public function testAddingMediumInteger()
$blueprint->mediumInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` mediumint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->mediumInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` mediumint not null auto_increment primary key', $statements[0]);
}
@@ -461,14 +461,14 @@ public function testAddingSmallInteger()
$blueprint->smallInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` smallint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->smallInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` smallint not null auto_increment primary key', $statements[0]);
}
@@ -478,14 +478,14 @@ public function testAddingTinyInteger()
$blueprint->tinyInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` tinyint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->tinyInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` tinyint not null auto_increment primary key', $statements[0]);
}
@@ -495,7 +495,7 @@ public function testAddingFloat()
$blueprint->float('foo', 5, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` double(5, 2) not null', $statements[0]);
}
@@ -505,7 +505,7 @@ public function testAddingDouble()
$blueprint->double('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` double not null', $statements[0]);
}
@@ -515,7 +515,7 @@ public function testAddingDoubleSpecifyingPrecision()
$blueprint->double('foo', 15, 8);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` double(15, 8) not null', $statements[0]);
}
@@ -525,7 +525,7 @@ public function testAddingDecimal()
$blueprint->decimal('foo', 5, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` decimal(5, 2) not null', $statements[0]);
}
@@ -535,7 +535,7 @@ public function testAddingBoolean()
$blueprint->boolean('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` tinyint(1) not null', $statements[0]);
}
@@ -545,7 +545,7 @@ public function testAddingEnum()
$blueprint->enum('foo', ['bar', 'baz']);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` enum(\'bar\', \'baz\') not null', $statements[0]);
}
@@ -555,7 +555,7 @@ public function testAddingJson()
$blueprint->json('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` json not null', $statements[0]);
}
@@ -565,7 +565,7 @@ public function testAddingJsonb()
$blueprint->jsonb('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` json not null', $statements[0]);
}
@@ -575,7 +575,7 @@ public function testAddingDate()
$blueprint->date('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` date not null', $statements[0]);
}
@@ -585,7 +585,7 @@ public function testAddingDateTime()
$blueprint->dateTime('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` datetime(0) not null', $statements[0]);
}
@@ -595,7 +595,7 @@ public function testAddingDateTimeTz()
$blueprint->dateTimeTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` datetime(0) not null', $statements[0]);
}
@@ -605,7 +605,7 @@ public function testAddingTime()
$blueprint->time('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` time not null', $statements[0]);
}
@@ -615,7 +615,7 @@ public function testAddingTimeTz()
$blueprint->timeTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` time not null', $statements[0]);
}
@@ -625,7 +625,7 @@ public function testAddingTimeStamp()
$blueprint->timestamp('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` timestamp(0) not null', $statements[0]);
}
@@ -635,7 +635,7 @@ public function testAddingTimeStampWithDefault()
$blueprint->timestamp('foo')->default('2015-07-22 11:43:17');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` timestamp(0) not null default \'2015-07-22 11:43:17\'', $statements[0]);
}
@@ -645,7 +645,7 @@ public function testAddingTimeStampTz()
$blueprint->timestampTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` timestamp(0) not null', $statements[0]);
}
@@ -655,7 +655,7 @@ public function testAddingTimeStampTzWithDefault()
$blueprint->timestampTz('foo')->default('2015-07-22 11:43:17');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` timestamp(0) not null default \'2015-07-22 11:43:17\'', $statements[0]);
}
@@ -665,7 +665,7 @@ public function testAddingTimeStamps()
$blueprint->timestamps();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `created_at` timestamp(0) null, add `updated_at` timestamp(0) null', $statements[0]);
}
@@ -675,7 +675,7 @@ public function testAddingTimeStampsTz()
$blueprint->timestampsTz();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `created_at` timestamp(0) null, add `updated_at` timestamp(0) null', $statements[0]);
}
@@ -685,7 +685,7 @@ public function testAddingRememberToken()
$blueprint->rememberToken();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `remember_token` varchar(100) null', $statements[0]);
}
@@ -695,7 +695,7 @@ public function testAddingBinary()
$blueprint->binary('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` blob not null', $statements[0]);
}
@@ -705,7 +705,7 @@ public function testAddingUuid()
$blueprint->uuid('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` char(36) not null', $statements[0]);
}
@@ -715,7 +715,7 @@ public function testAddingIpAddress()
$blueprint->ipAddress('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` varchar(45) not null', $statements[0]);
}
@@ -725,7 +725,7 @@ public function testAddingMacAddress()
$blueprint->macAddress('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `foo` varchar(17) not null', $statements[0]);
}
| true |
Other | laravel | framework | 872be61fb64b5d63da92134b216cdf36657e860f.json | Use assertCount assertion (#19284) | tests/Database/DatabasePostgresSchemaGrammarTest.php | @@ -21,15 +21,15 @@ public function testBasicCreateTable()
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table "users" ("id" serial primary key not null, "email" varchar(255) not null)', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->increments('id');
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" serial primary key not null, add column "email" varchar(255) not null', $statements[0]);
}
@@ -39,7 +39,7 @@ public function testDropTable()
$blueprint->drop();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop table "users"', $statements[0]);
}
@@ -49,7 +49,7 @@ public function testDropTableIfExists()
$blueprint->dropIfExists();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop table if exists "users"', $statements[0]);
}
@@ -59,21 +59,21 @@ public function testDropColumn()
$blueprint->dropColumn('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "foo"', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->dropColumn(['foo', 'bar']);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "foo", drop column "bar"', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->dropColumn('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "foo", drop column "bar"', $statements[0]);
}
@@ -83,7 +83,7 @@ public function testDropPrimary()
$blueprint->dropPrimary();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop constraint "users_pkey"', $statements[0]);
}
@@ -93,7 +93,7 @@ public function testDropUnique()
$blueprint->dropUnique('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop constraint "foo"', $statements[0]);
}
@@ -103,7 +103,7 @@ public function testDropIndex()
$blueprint->dropIndex('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop index "foo"', $statements[0]);
}
@@ -113,7 +113,7 @@ public function testDropForeign()
$blueprint->dropForeign('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop constraint "foo"', $statements[0]);
}
@@ -123,7 +123,7 @@ public function testDropTimestamps()
$blueprint->dropTimestamps();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "created_at", drop column "updated_at"', $statements[0]);
}
@@ -133,7 +133,7 @@ public function testDropTimestampsTz()
$blueprint->dropTimestampsTz();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "created_at", drop column "updated_at"', $statements[0]);
}
@@ -143,7 +143,7 @@ public function testRenameTable()
$blueprint->rename('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" rename to "foo"', $statements[0]);
}
@@ -153,7 +153,7 @@ public function testAddingPrimaryKey()
$blueprint->primary('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add primary key ("foo")', $statements[0]);
}
@@ -163,7 +163,7 @@ public function testAddingUniqueKey()
$blueprint->unique('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add constraint "bar" unique ("foo")', $statements[0]);
}
@@ -173,7 +173,7 @@ public function testAddingIndex()
$blueprint->index(['foo', 'bar'], 'baz');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create index "baz" on "users" ("foo", "bar")', $statements[0]);
}
@@ -183,7 +183,7 @@ public function testAddingIndexWithAlgorithm()
$blueprint->index(['foo', 'bar'], 'baz', 'hash');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create index "baz" on "users" using hash ("foo", "bar")', $statements[0]);
}
@@ -193,7 +193,7 @@ public function testAddingIncrementingID()
$blueprint->increments('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" serial primary key not null', $statements[0]);
}
@@ -203,7 +203,7 @@ public function testAddingSmallIncrementingID()
$blueprint->smallIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" smallserial primary key not null', $statements[0]);
}
@@ -213,7 +213,7 @@ public function testAddingMediumIncrementingID()
$blueprint->mediumIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" serial primary key not null', $statements[0]);
}
@@ -223,7 +223,7 @@ public function testAddingBigIncrementingID()
$blueprint->bigIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" bigserial primary key not null', $statements[0]);
}
@@ -233,21 +233,21 @@ public function testAddingString()
$blueprint->string('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar(255) not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar(100) not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100)->nullable()->default('bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar(100) null default \'bar\'', $statements[0]);
}
@@ -257,7 +257,7 @@ public function testAddingText()
$blueprint->text('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" text not null', $statements[0]);
}
@@ -267,14 +267,14 @@ public function testAddingBigInteger()
$blueprint->bigInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" bigint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->bigInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" bigserial primary key not null', $statements[0]);
}
@@ -284,14 +284,14 @@ public function testAddingInteger()
$blueprint->integer('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->integer('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" serial primary key not null', $statements[0]);
}
@@ -301,14 +301,14 @@ public function testAddingMediumInteger()
$blueprint->mediumInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->mediumInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" serial primary key not null', $statements[0]);
}
@@ -318,14 +318,14 @@ public function testAddingTinyInteger()
$blueprint->tinyInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" smallint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->tinyInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" smallserial primary key not null', $statements[0]);
}
@@ -335,14 +335,14 @@ public function testAddingSmallInteger()
$blueprint->smallInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" smallint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->smallInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" smallserial primary key not null', $statements[0]);
}
@@ -352,7 +352,7 @@ public function testAddingFloat()
$blueprint->float('foo', 5, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" double precision not null', $statements[0]);
}
@@ -362,7 +362,7 @@ public function testAddingDouble()
$blueprint->double('foo', 15, 8);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" double precision not null', $statements[0]);
}
@@ -372,7 +372,7 @@ public function testAddingDecimal()
$blueprint->decimal('foo', 5, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" decimal(5, 2) not null', $statements[0]);
}
@@ -382,7 +382,7 @@ public function testAddingBoolean()
$blueprint->boolean('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" boolean not null', $statements[0]);
}
@@ -392,7 +392,7 @@ public function testAddingEnum()
$blueprint->enum('foo', ['bar', 'baz']);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar(255) check ("foo" in (\'bar\', \'baz\')) not null', $statements[0]);
}
@@ -402,7 +402,7 @@ public function testAddingDate()
$blueprint->date('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" date not null', $statements[0]);
}
@@ -412,7 +412,7 @@ public function testAddingJson()
$blueprint->json('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" json not null', $statements[0]);
}
@@ -422,7 +422,7 @@ public function testAddingJsonb()
$blueprint->jsonb('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" jsonb not null', $statements[0]);
}
@@ -432,7 +432,7 @@ public function testAddingDateTime()
$blueprint->dateTime('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" timestamp(0) without time zone not null', $statements[0]);
}
@@ -442,7 +442,7 @@ public function testAddingDateTimeTz()
$blueprint->dateTimeTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" timestamp(0) with time zone not null', $statements[0]);
}
@@ -452,7 +452,7 @@ public function testAddingTime()
$blueprint->time('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" time(0) without time zone not null', $statements[0]);
}
@@ -462,7 +462,7 @@ public function testAddingTimeTz()
$blueprint->timeTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" time(0) with time zone not null', $statements[0]);
}
@@ -472,7 +472,7 @@ public function testAddingTimeStamp()
$blueprint->timestamp('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" timestamp(0) without time zone not null', $statements[0]);
}
@@ -482,7 +482,7 @@ public function testAddingTimeStampTz()
$blueprint->timestampTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" timestamp(0) with time zone not null', $statements[0]);
}
@@ -492,7 +492,7 @@ public function testAddingTimeStamps()
$blueprint->timestamps();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "created_at" timestamp(0) without time zone null, add column "updated_at" timestamp(0) without time zone null', $statements[0]);
}
@@ -502,7 +502,7 @@ public function testAddingTimeStampsTz()
$blueprint->timestampsTz();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "created_at" timestamp(0) with time zone null, add column "updated_at" timestamp(0) with time zone null', $statements[0]);
}
@@ -512,7 +512,7 @@ public function testAddingBinary()
$blueprint->binary('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" bytea not null', $statements[0]);
}
@@ -522,7 +522,7 @@ public function testAddingUuid()
$blueprint->uuid('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" uuid not null', $statements[0]);
}
@@ -532,7 +532,7 @@ public function testAddingIpAddress()
$blueprint->ipAddress('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" inet not null', $statements[0]);
}
@@ -542,7 +542,7 @@ public function testAddingMacAddress()
$blueprint->macAddress('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" macaddr not null', $statements[0]);
}
| true |
Other | laravel | framework | 872be61fb64b5d63da92134b216cdf36657e860f.json | Use assertCount assertion (#19284) | tests/Database/DatabaseSQLiteSchemaGrammarTest.php | @@ -21,15 +21,15 @@ public function testBasicCreateTable()
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table "users" ("id" integer not null primary key autoincrement, "email" varchar not null)', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->increments('id');
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(2, count($statements));
+ $this->assertCount(2, $statements);
$expected = [
'alter table "users" add column "id" integer not null primary key autoincrement',
'alter table "users" add column "email" varchar not null',
@@ -43,7 +43,7 @@ public function testDropTable()
$blueprint->drop();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop table "users"', $statements[0]);
}
@@ -53,7 +53,7 @@ public function testDropTableIfExists()
$blueprint->dropIfExists();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop table if exists "users"', $statements[0]);
}
@@ -63,7 +63,7 @@ public function testDropUnique()
$blueprint->dropUnique('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop index "foo"', $statements[0]);
}
@@ -73,7 +73,7 @@ public function testDropIndex()
$blueprint->dropIndex('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop index "foo"', $statements[0]);
}
@@ -83,7 +83,7 @@ public function testRenameTable()
$blueprint->rename('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" rename to "foo"', $statements[0]);
}
@@ -94,7 +94,7 @@ public function testAddingPrimaryKey()
$blueprint->string('foo')->primary();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table "users" ("foo" varchar not null, primary key ("foo"))', $statements[0]);
}
@@ -107,7 +107,7 @@ public function testAddingForeignKey()
$blueprint->foreign('order_id')->references('id')->on('orders');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table "users" ("foo" varchar not null, "order_id" varchar not null, foreign key("order_id") references "orders"("id"), primary key ("foo"))', $statements[0]);
}
@@ -117,7 +117,7 @@ public function testAddingUniqueKey()
$blueprint->unique('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create unique index "bar" on "users" ("foo")', $statements[0]);
}
@@ -127,7 +127,7 @@ public function testAddingIndex()
$blueprint->index(['foo', 'bar'], 'baz');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create index "baz" on "users" ("foo", "bar")', $statements[0]);
}
@@ -137,7 +137,7 @@ public function testAddingIncrementingID()
$blueprint->increments('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" integer not null primary key autoincrement', $statements[0]);
}
@@ -147,7 +147,7 @@ public function testAddingSmallIncrementingID()
$blueprint->smallIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" integer not null primary key autoincrement', $statements[0]);
}
@@ -157,7 +157,7 @@ public function testAddingMediumIncrementingID()
$blueprint->mediumIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" integer not null primary key autoincrement', $statements[0]);
}
@@ -167,7 +167,7 @@ public function testAddingBigIncrementingID()
$blueprint->bigIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" integer not null primary key autoincrement', $statements[0]);
}
@@ -177,21 +177,21 @@ public function testAddingString()
$blueprint->string('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100)->nullable()->default('bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar null default \'bar\'', $statements[0]);
}
@@ -201,7 +201,7 @@ public function testAddingText()
$blueprint->text('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" text not null', $statements[0]);
}
@@ -211,14 +211,14 @@ public function testAddingBigInteger()
$blueprint->bigInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->bigInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null primary key autoincrement', $statements[0]);
}
@@ -228,14 +228,14 @@ public function testAddingInteger()
$blueprint->integer('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->integer('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null primary key autoincrement', $statements[0]);
}
@@ -245,14 +245,14 @@ public function testAddingMediumInteger()
$blueprint->mediumInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->mediumInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null primary key autoincrement', $statements[0]);
}
@@ -262,14 +262,14 @@ public function testAddingTinyInteger()
$blueprint->tinyInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->tinyInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null primary key autoincrement', $statements[0]);
}
@@ -279,14 +279,14 @@ public function testAddingSmallInteger()
$blueprint->smallInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->smallInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer not null primary key autoincrement', $statements[0]);
}
@@ -296,7 +296,7 @@ public function testAddingFloat()
$blueprint->float('foo', 5, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" float not null', $statements[0]);
}
@@ -306,7 +306,7 @@ public function testAddingDouble()
$blueprint->double('foo', 15, 8);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" float not null', $statements[0]);
}
@@ -316,7 +316,7 @@ public function testAddingDecimal()
$blueprint->decimal('foo', 5, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" numeric not null', $statements[0]);
}
@@ -326,7 +326,7 @@ public function testAddingBoolean()
$blueprint->boolean('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" tinyint(1) not null', $statements[0]);
}
@@ -336,7 +336,7 @@ public function testAddingEnum()
$blueprint->enum('foo', ['bar', 'baz']);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar not null', $statements[0]);
}
@@ -346,7 +346,7 @@ public function testAddingJson()
$blueprint->json('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" text not null', $statements[0]);
}
@@ -356,7 +356,7 @@ public function testAddingJsonb()
$blueprint->jsonb('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" text not null', $statements[0]);
}
@@ -366,7 +366,7 @@ public function testAddingDate()
$blueprint->date('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" date not null', $statements[0]);
}
@@ -376,7 +376,7 @@ public function testAddingDateTime()
$blueprint->dateTime('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" datetime not null', $statements[0]);
}
@@ -386,7 +386,7 @@ public function testAddingDateTimeTz()
$blueprint->dateTimeTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" datetime not null', $statements[0]);
}
@@ -396,7 +396,7 @@ public function testAddingTime()
$blueprint->time('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" time not null', $statements[0]);
}
@@ -406,7 +406,7 @@ public function testAddingTimeTz()
$blueprint->timeTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" time not null', $statements[0]);
}
@@ -416,7 +416,7 @@ public function testAddingTimeStamp()
$blueprint->timestamp('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" datetime not null', $statements[0]);
}
@@ -426,7 +426,7 @@ public function testAddingTimeStampTz()
$blueprint->timestampTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" datetime not null', $statements[0]);
}
@@ -436,7 +436,7 @@ public function testAddingTimeStamps()
$blueprint->timestamps();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(2, count($statements));
+ $this->assertCount(2, $statements);
$expected = [
'alter table "users" add column "created_at" datetime null',
'alter table "users" add column "updated_at" datetime null',
@@ -450,7 +450,7 @@ public function testAddingTimeStampsTz()
$blueprint->timestampsTz();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(2, count($statements));
+ $this->assertCount(2, $statements);
$expected = [
'alter table "users" add column "created_at" datetime null',
'alter table "users" add column "updated_at" datetime null',
@@ -464,7 +464,7 @@ public function testAddingRememberToken()
$blueprint->rememberToken();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "remember_token" varchar null', $statements[0]);
}
@@ -474,7 +474,7 @@ public function testAddingBinary()
$blueprint->binary('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" blob not null', $statements[0]);
}
@@ -484,7 +484,7 @@ public function testAddingUuid()
$blueprint->uuid('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar not null', $statements[0]);
}
@@ -494,7 +494,7 @@ public function testAddingIpAddress()
$blueprint->ipAddress('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar not null', $statements[0]);
}
@@ -504,7 +504,7 @@ public function testAddingMacAddress()
$blueprint->macAddress('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" varchar not null', $statements[0]);
}
| true |
Other | laravel | framework | 872be61fb64b5d63da92134b216cdf36657e860f.json | Use assertCount assertion (#19284) | tests/Database/DatabaseSqlServerSchemaGrammarTest.php | @@ -21,15 +21,15 @@ public function testBasicCreateTable()
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table "users" ("id" int identity primary key not null, "email" nvarchar(255) not null)', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->increments('id');
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "id" int identity primary key not null, "email" nvarchar(255) not null', $statements[0]);
$blueprint = new Blueprint('users');
@@ -38,7 +38,7 @@ public function testBasicCreateTable()
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()->setTablePrefix('prefix_'));
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create table "prefix_users" ("id" int identity primary key not null, "email" nvarchar(255) not null)', $statements[0]);
}
@@ -48,14 +48,14 @@ public function testDropTable()
$blueprint->drop();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop table "users"', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->drop();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()->setTablePrefix('prefix_'));
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop table "prefix_users"', $statements[0]);
}
@@ -65,14 +65,14 @@ public function testDropTableIfExists()
$blueprint->dropIfExists();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = \'users\') drop table "users"', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->dropIfExists();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()->setTablePrefix('prefix_'));
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = \'prefix_users\') drop table "prefix_users"', $statements[0]);
}
@@ -82,21 +82,21 @@ public function testDropColumn()
$blueprint->dropColumn('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "foo"', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->dropColumn(['foo', 'bar']);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "foo", "bar"', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->dropColumn('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "foo", "bar"', $statements[0]);
}
@@ -106,7 +106,7 @@ public function testDropPrimary()
$blueprint->dropPrimary('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop constraint "foo"', $statements[0]);
}
@@ -116,7 +116,7 @@ public function testDropUnique()
$blueprint->dropUnique('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop index "foo" on "users"', $statements[0]);
}
@@ -126,7 +126,7 @@ public function testDropIndex()
$blueprint->dropIndex('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('drop index "foo" on "users"', $statements[0]);
}
@@ -136,7 +136,7 @@ public function testDropForeign()
$blueprint->dropForeign('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop constraint "foo"', $statements[0]);
}
@@ -146,7 +146,7 @@ public function testDropTimestamps()
$blueprint->dropTimestamps();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "created_at", "updated_at"', $statements[0]);
}
@@ -156,7 +156,7 @@ public function testDropTimestampsTz()
$blueprint->dropTimestampsTz();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" drop column "created_at", "updated_at"', $statements[0]);
}
@@ -166,7 +166,7 @@ public function testRenameTable()
$blueprint->rename('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('sp_rename "users", "foo"', $statements[0]);
}
@@ -176,7 +176,7 @@ public function testAddingPrimaryKey()
$blueprint->primary('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add constraint "bar" primary key ("foo")', $statements[0]);
}
@@ -186,7 +186,7 @@ public function testAddingUniqueKey()
$blueprint->unique('foo', 'bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create unique index "bar" on "users" ("foo")', $statements[0]);
}
@@ -196,7 +196,7 @@ public function testAddingIndex()
$blueprint->index(['foo', 'bar'], 'baz');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('create index "baz" on "users" ("foo", "bar")', $statements[0]);
}
@@ -206,7 +206,7 @@ public function testAddingIncrementingID()
$blueprint->increments('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "id" int identity primary key not null', $statements[0]);
}
@@ -216,7 +216,7 @@ public function testAddingSmallIncrementingID()
$blueprint->smallIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "id" smallint identity primary key not null', $statements[0]);
}
@@ -226,7 +226,7 @@ public function testAddingMediumIncrementingID()
$blueprint->mediumIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "id" int identity primary key not null', $statements[0]);
}
@@ -236,7 +236,7 @@ public function testAddingBigIncrementingID()
$blueprint->bigIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "id" bigint identity primary key not null', $statements[0]);
}
@@ -246,21 +246,21 @@ public function testAddingString()
$blueprint->string('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(255) not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(100) not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->string('foo', 100)->nullable()->default('bar');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(100) null default \'bar\'', $statements[0]);
}
@@ -270,7 +270,7 @@ public function testAddingText()
$blueprint->text('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(max) not null', $statements[0]);
}
@@ -280,14 +280,14 @@ public function testAddingBigInteger()
$blueprint->bigInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" bigint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->bigInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" bigint identity primary key not null', $statements[0]);
}
@@ -297,14 +297,14 @@ public function testAddingInteger()
$blueprint->integer('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" int not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->integer('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" int identity primary key not null', $statements[0]);
}
@@ -314,14 +314,14 @@ public function testAddingMediumInteger()
$blueprint->mediumInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" int not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->mediumInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" int identity primary key not null', $statements[0]);
}
@@ -331,14 +331,14 @@ public function testAddingTinyInteger()
$blueprint->tinyInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" tinyint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->tinyInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" tinyint identity primary key not null', $statements[0]);
}
@@ -348,14 +348,14 @@ public function testAddingSmallInteger()
$blueprint->smallInteger('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" smallint not null', $statements[0]);
$blueprint = new Blueprint('users');
$blueprint->smallInteger('foo', true);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" smallint identity primary key not null', $statements[0]);
}
@@ -365,7 +365,7 @@ public function testAddingFloat()
$blueprint->float('foo', 5, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" float not null', $statements[0]);
}
@@ -375,7 +375,7 @@ public function testAddingDouble()
$blueprint->double('foo', 15, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" float not null', $statements[0]);
}
@@ -385,7 +385,7 @@ public function testAddingDecimal()
$blueprint->decimal('foo', 5, 2);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" decimal(5, 2) not null', $statements[0]);
}
@@ -395,7 +395,7 @@ public function testAddingBoolean()
$blueprint->boolean('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" bit not null', $statements[0]);
}
@@ -405,7 +405,7 @@ public function testAddingEnum()
$blueprint->enum('foo', ['bar', 'baz']);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(255) not null', $statements[0]);
}
@@ -415,7 +415,7 @@ public function testAddingJson()
$blueprint->json('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(max) not null', $statements[0]);
}
@@ -425,7 +425,7 @@ public function testAddingJsonb()
$blueprint->jsonb('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(max) not null', $statements[0]);
}
@@ -435,7 +435,7 @@ public function testAddingDate()
$blueprint->date('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" date not null', $statements[0]);
}
@@ -445,7 +445,7 @@ public function testAddingDateTime()
$blueprint->dateTime('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" datetime2(0) not null', $statements[0]);
}
@@ -455,7 +455,7 @@ public function testAddingDateTimeTz()
$blueprint->dateTimeTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" datetimeoffset(0) not null', $statements[0]);
}
@@ -465,7 +465,7 @@ public function testAddingTime()
$blueprint->time('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" time not null', $statements[0]);
}
@@ -475,7 +475,7 @@ public function testAddingTimeTz()
$blueprint->timeTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" time not null', $statements[0]);
}
@@ -485,7 +485,7 @@ public function testAddingTimeStamp()
$blueprint->timestamp('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" datetime2(0) not null', $statements[0]);
}
@@ -495,7 +495,7 @@ public function testAddingTimeStampTz()
$blueprint->timestampTz('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" datetimeoffset(0) not null', $statements[0]);
}
@@ -505,7 +505,7 @@ public function testAddingTimeStamps()
$blueprint->timestamps();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "created_at" datetime2(0) null, "updated_at" datetime2(0) null', $statements[0]);
}
@@ -515,7 +515,7 @@ public function testAddingTimeStampsTz()
$blueprint->timestampsTz();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "created_at" datetimeoffset(0) null, "updated_at" datetimeoffset(0) null', $statements[0]);
}
@@ -525,7 +525,7 @@ public function testAddingRememberToken()
$blueprint->rememberToken();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "remember_token" nvarchar(100) null', $statements[0]);
}
@@ -535,7 +535,7 @@ public function testAddingBinary()
$blueprint->binary('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" varbinary(max) not null', $statements[0]);
}
@@ -545,7 +545,7 @@ public function testAddingUuid()
$blueprint->uuid('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" uniqueidentifier not null', $statements[0]);
}
@@ -555,7 +555,7 @@ public function testAddingIpAddress()
$blueprint->ipAddress('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(45) not null', $statements[0]);
}
@@ -565,7 +565,7 @@ public function testAddingMacAddress()
$blueprint->macAddress('foo');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
- $this->assertEquals(1, count($statements));
+ $this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "foo" nvarchar(17) not null', $statements[0]);
}
| true |
Other | laravel | framework | f09fa862dc5b1ff37fc856782141e543962ebf8e.json | Add brackets again, no passing tests without it | src/Illuminate/Http/Request.php | @@ -199,7 +199,7 @@ public function is()
*/
public function routeIs()
{
- if (! $route = $this->route() || ! $routeName = $route->getName()) {
+ if (! ($route = $this->route()) || ! $routeName = $route->getName()) {
return false;
}
| false |
Other | laravel | framework | 57a6c06ade7bc329316c44c3938888936018a5bb.json | Remove extra brackets | src/Illuminate/Http/Request.php | @@ -199,7 +199,7 @@ public function is()
*/
public function routeIs()
{
- if ((! $route = $this->route()) || ! $routeName = $route->getName()) {
+ if (! $route = $this->route() || ! $routeName = $route->getName()) {
return false;
}
| false |
Other | laravel | framework | 315f43b55c3f9cb7f33e0b421493b519e117fc8b.json | Add patterns to routeIs method | src/Illuminate/Http/Request.php | @@ -193,14 +193,23 @@ public function is()
}
/**
- * Check if the route name matches the given string.
+ * Determine if the route name matches a pattern.
*
- * @param string $name
* @return bool
*/
- public function routeIs($name)
+ public function routeIs()
{
- return $this->route() && $this->route()->named($name);
+ if ((! $route = $this->route()) || ! $routeName = $route->getName()) {
+ return false;
+ }
+
+ foreach (func_get_args() as $pattern) {
+ if (Str::is($pattern, $routeName)) {
+ return true;
+ }
+ }
+
+ return false;
}
/** | true |
Other | laravel | framework | 315f43b55c3f9cb7f33e0b421493b519e117fc8b.json | Add patterns to routeIs method | tests/Http/HttpRequestTest.php | @@ -169,6 +169,7 @@ public function testRouteIsMethod()
});
$this->assertTrue($request->routeIs('foo.bar'));
+ $this->assertTrue($request->routeIs('foo*', '*bar'));
$this->assertFalse($request->routeIs('foo.foo'));
}
| true |
Other | laravel | framework | b880ad19282db768718cfd1629ebbc41054daadc.json | keep chain going on explicit delete. add tests. | src/Illuminate/Queue/CallQueuedHandler.php | @@ -42,9 +42,11 @@ public function call(Job $job, array $data)
$command, $handler = $this->resolveHandler($job, $command)
);
- if (! $job->isDeletedOrReleased()) {
- $this->ensureNextJobIsChainIsDispatched($command);
+ if (! $job->hasFailed() && ! $job->isReleased()) {
+ $this->ensureNextJobInChainIsDispatched($command);
+ }
+ if (! $job->isDeletedOrReleased()) {
$job->delete();
}
}
@@ -89,7 +91,7 @@ protected function setJobInstanceIfNecessary(Job $job, $instance)
* @param mixed $command
* @return void
*/
- protected function ensureNextJobIsChainIsDispatched($command)
+ protected function ensureNextJobInChainIsDispatched($command)
{
if (method_exists($command, 'dispatchNextJobInChain')) {
$command->dispatchNextJobInChain(); | true |
Other | laravel | framework | b880ad19282db768718cfd1629ebbc41054daadc.json | keep chain going on explicit delete. add tests. | tests/Integration/Queue/JobChainingTest.php | @@ -29,6 +29,16 @@ public function test_jobs_can_be_chained_on_success()
$this->assertTrue(JobChainingTestSecondJob::$ran);
}
+ public function test_jobs_chained_on_explicit_delete()
+ {
+ JobChainingTestDeletingJob::dispatch()->chain([
+ new JobChainingTestSecondJob,
+ ]);
+
+ $this->assertTrue(JobChainingTestDeletingJob::$ran);
+ $this->assertTrue(JobChainingTestSecondJob::$ran);
+ }
+
public function test_jobs_can_be_chained_on_success_with_several_jobs()
{
JobChainingTestFirstJob::dispatch()->chain([
@@ -61,7 +71,7 @@ public function test_jobs_can_be_chained_via_queue()
$this->assertTrue(JobChainingTestSecondJob::$ran);
}
- public function test_second_job_is_not_fired_if_first_was_already_deleted()
+ public function test_second_job_is_not_fired_if_first_failed()
{
Queue::connection('sync')->push((new JobChainingTestFailingJob)->chain([
new JobChainingTestSecondJob,
@@ -70,6 +80,15 @@ public function test_second_job_is_not_fired_if_first_was_already_deleted()
$this->assertFalse(JobChainingTestSecondJob::$ran);
}
+ public function test_second_job_is_not_fired_if_first_released()
+ {
+ Queue::connection('sync')->push((new JobChainingTestReleasingJob)->chain([
+ new JobChainingTestSecondJob,
+ ]));
+
+ $this->assertFalse(JobChainingTestSecondJob::$ran);
+ }
+
public function test_third_job_is_not_fired_if_second_fails()
{
Queue::connection('sync')->push((new JobChainingTestFirstJob)->chain([
@@ -118,6 +137,29 @@ public function handle()
}
}
+class JobChainingTestDeletingJob implements ShouldQueue
+{
+ use Dispatchable, InteractsWithQueue, Queueable;
+
+ public static $ran = false;
+
+ public function handle()
+ {
+ static::$ran = true;
+ $this->delete();
+ }
+}
+
+class JobChainingTestReleasingJob implements ShouldQueue
+{
+ use Dispatchable, InteractsWithQueue, Queueable;
+
+ public function handle()
+ {
+ $this->release(30);
+ }
+}
+
class JobChainingTestFailingJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable; | true |
Other | laravel | framework | bba04a1598c44a892e918c4f308407b0d297f217.json | fix formattting and make getter | src/Illuminate/Routing/Route.php | @@ -523,27 +523,31 @@ public function secure()
}
/**
- * Get the domain defined for the route.
+ * Get or set the domain for the route.
*
- * @return string|null
+ * @param string|null $domain
+ * @return $this
*/
- public function getDomain()
+ public function domain($domain = null)
{
- return isset($this->action['domain'])
- ? str_replace(['http://', 'https://'], '', $this->action['domain']) : null;
+ if (is_null($domain)) {
+ return $this->getDomain();
+ }
+
+ $this->action['domain'] = $domain;
+
+ return $this;
}
/**
- * Add a domain to the route URI.
+ * Get the domain defined for the route.
*
- * @param string $domain
- * @return $this
+ * @return string|null
*/
- public function domain($domain)
+ public function getDomain()
{
- $this->action['domain'] = $domain;
-
- return $this;
+ return isset($this->action['domain'])
+ ? str_replace(['http://', 'https://'], '', $this->action['domain']) : null;
}
/** | false |
Other | laravel | framework | 72ef859df410d685101c8389eebb0cb8940ebbcd.json | add another test | tests/Integration/Queue/JobChainingTest.php | @@ -69,6 +69,17 @@ public function test_second_job_is_not_fired_if_first_was_already_deleted()
$this->assertFalse(JobChainingTestSecondJob::$ran);
}
+
+ public function test_third_job_is_not_fired_if_second_fails()
+ {
+ Queue::connection('sync')->push((new JobChainingTestFirstJob)->chain([
+ new JobChainingTestFailingJob,
+ new JobChainingTestThirdJob,
+ ]));
+
+ $this->assertTrue(JobChainingTestFirstJob::$ran);
+ $this->assertFalse(JobChainingTestThirdJob::$ran);
+ }
}
class JobChainingTestFirstJob implements ShouldQueue | false |
Other | laravel | framework | 434245f73e694f90476437da8554b58d54ced25c.json | fix bug with chaining | src/Illuminate/Bus/Queueable.php | @@ -94,7 +94,9 @@ public function chain($chain)
public function dispatchNextJobInChain()
{
if (! empty($this->chained)) {
- dispatch(unserialize(array_shift($this->chained))->chain($this->chained));
+ dispatch(tap(unserialize(array_shift($this->chained)), function ($next) {
+ $next->chained = $this->chained;
+ }));
}
}
} | true |
Other | laravel | framework | 434245f73e694f90476437da8554b58d54ced25c.json | fix bug with chaining | tests/Integration/Queue/JobChainingTest.php | @@ -16,6 +16,7 @@ public function tearDown()
{
JobChainingTestFirstJob::$ran = false;
JobChainingTestSecondJob::$ran = false;
+ JobChainingTestThirdJob::$ran = false;
}
public function test_jobs_can_be_chained_on_success()
@@ -28,6 +29,18 @@ public function test_jobs_can_be_chained_on_success()
$this->assertTrue(JobChainingTestSecondJob::$ran);
}
+ public function test_jobs_can_be_chained_on_success_with_several_jobs()
+ {
+ JobChainingTestFirstJob::dispatch()->chain([
+ new JobChainingTestSecondJob,
+ new JobChainingTestThirdJob,
+ ]);
+
+ $this->assertTrue(JobChainingTestFirstJob::$ran);
+ $this->assertTrue(JobChainingTestSecondJob::$ran);
+ $this->assertTrue(JobChainingTestThirdJob::$ran);
+ }
+
public function test_jobs_can_be_chained_on_success_using_helper()
{
dispatch(new JobChainingTestFirstJob)->chain([
@@ -82,6 +95,18 @@ public function handle()
}
}
+class JobChainingTestThirdJob implements ShouldQueue
+{
+ use Dispatchable, Queueable;
+
+ public static $ran = false;
+
+ public function handle()
+ {
+ static::$ran = true;
+ }
+}
+
class JobChainingTestFailingJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable; | true |
Other | laravel | framework | 4eb16f030d00f34d5086aac4a6f42d00f035b5e5.json | Create a new "crossJoin" method (#19236) | src/Illuminate/Support/Arr.php | @@ -60,6 +60,23 @@ public static function collapse($array)
return $results;
}
+ /**
+ * Cross join the given arrays, returning all possible permutations.
+ *
+ * @param array ...$arrays
+ * @return array
+ */
+ public static function crossJoin(...$arrays)
+ {
+ return array_reduce($arrays, function ($results, $array) {
+ return static::collapse(array_map(function ($parent) use ($array) {
+ return array_map(function ($item) use ($parent) {
+ return array_merge($parent, [$item]);
+ }, $array);
+ }, $results));
+ }, [[]]);
+ }
+
/**
* Divide an array into two arrays. One with keys and the other with values.
* | true |
Other | laravel | framework | 4eb16f030d00f34d5086aac4a6f42d00f035b5e5.json | Create a new "crossJoin" method (#19236) | src/Illuminate/Support/Collection.php | @@ -226,6 +226,19 @@ public function containsStrict($key, $value = null)
return in_array($key, $this->items, true);
}
+ /**
+ * Cross join with the given lists, returning all possible permutations.
+ *
+ * @param mixed ...$lists
+ * @return static
+ */
+ public function crossJoin(...$lists)
+ {
+ return new static(Arr::crossJoin(
+ $this->items, ...array_map([$this, 'getArrayableItems'], $lists)
+ ));
+ }
+
/**
* Get the items in the collection that are not present in the given items.
* | true |
Other | laravel | framework | 4eb16f030d00f34d5086aac4a6f42d00f035b5e5.json | Create a new "crossJoin" method (#19236) | tests/Support/SupportArrTest.php | @@ -35,6 +35,41 @@ public function testCollapse()
$this->assertEquals(['foo', 'bar', 'baz'], Arr::collapse($data));
}
+ public function testCrossJoin()
+ {
+ // Single dimension
+ $this->assertEquals(
+ [[1, 'a'], [1, 'b'], [1, 'c']],
+ Arr::crossJoin([1], ['a', 'b', 'c'])
+ );
+
+ // Square matrix
+ $this->assertEquals(
+ [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']],
+ Arr::crossJoin([1, 2], ['a', 'b'])
+ );
+
+ // Rectangular matrix
+ $this->assertEquals(
+ [[1, 'a'], [1, 'b'], [1, 'c'], [2, 'a'], [2, 'b'], [2, 'c']],
+ Arr::crossJoin([1, 2], ['a', 'b', 'c'])
+ );
+
+ // 3D matrix
+ $this->assertEquals(
+ [
+ [1, 'a', 'I'], [1, 'a', 'II'], [1, 'a', 'III'],
+ [1, 'b', 'I'], [1, 'b', 'II'], [1, 'b', 'III'],
+ [2, 'a', 'I'], [2, 'a', 'II'], [2, 'a', 'III'],
+ [2, 'b', 'I'], [2, 'b', 'II'], [2, 'b', 'III'],
+ ],
+ Arr::crossJoin([1, 2], ['a', 'b'], ['I', 'II', 'III'])
+ );
+
+ // With 1 empty dimension
+ $this->assertEquals([], Arr::crossJoin([1, 2], [], ['I', 'II', 'III']));
+ }
+
public function testDivide()
{
list($keys, $values) = Arr::divide(['name' => 'Desk']); | true |
Other | laravel | framework | 4eb16f030d00f34d5086aac4a6f42d00f035b5e5.json | Create a new "crossJoin" method (#19236) | tests/Support/SupportCollectionTest.php | @@ -665,6 +665,35 @@ public function testCollapseWithNestedCollactions()
$this->assertEquals([1, 2, 3, 4, 5, 6], $data->collapse()->all());
}
+ public function testCrossJoin()
+ {
+ // Cross join with an array
+ $this->assertEquals(
+ [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']],
+ (new Collection([1, 2]))->crossJoin(['a', 'b'])->all()
+ );
+
+ // Cross join with a collection
+ $this->assertEquals(
+ [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']],
+ (new Collection([1, 2]))->crossJoin(new Collection(['a', 'b']))->all()
+ );
+
+ // Cross join with 2 collections
+ $this->assertEquals(
+ [
+ [1, 'a', 'I'], [1, 'a', 'II'],
+ [1, 'b', 'I'], [1, 'b', 'II'],
+ [2, 'a', 'I'], [2, 'a', 'II'],
+ [2, 'b', 'I'], [2, 'b', 'II'],
+ ],
+ (new Collection([1, 2]))->crossJoin(
+ new Collection(['a', 'b']),
+ new Collection(['I', 'II'])
+ )->all()
+ );
+ }
+
public function testSort()
{
$data = (new Collection([5, 3, 1, 2, 4]))->sort(); | true |
Other | laravel | framework | f4a509a38edbbe6908685ee22e06b9d2159fb3f5.json | Use Str:: class. (#19221) | src/Illuminate/Console/GeneratorCommand.php | @@ -123,7 +123,7 @@ protected function alreadyExists($rawName)
*/
protected function getPath($name)
{
- $name = str_replace_first($this->rootNamespace(), '', $name);
+ $name = Str::replaceFirst($this->rootNamespace(), '', $name);
return $this->laravel['path'].'/'.str_replace('\\', '/', $name).'.php';
} | true |
Other | laravel | framework | f4a509a38edbbe6908685ee22e06b9d2159fb3f5.json | Use Str:: class. (#19221) | src/Illuminate/Routing/ImplicitRouteBinding.php | @@ -2,6 +2,7 @@
namespace Illuminate\Routing;
+use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
class ImplicitRouteBinding
@@ -49,9 +50,7 @@ protected static function getParameterName($name, $parameters)
return $name;
}
- $snakedName = snake_case($name);
-
- if (array_key_exists($snakedName, $parameters)) {
+ if (array_key_exists($snakedName = Str::snake($name), $parameters)) {
return $snakedName;
}
} | true |
Other | laravel | framework | f4a509a38edbbe6908685ee22e06b9d2159fb3f5.json | Use Str:: class. (#19221) | tests/Database/DatabaseMigratorIntegrationTest.php | @@ -2,6 +2,7 @@
namespace Illuminate\Tests\Database;
+use Illuminate\Support\Str;
use PHPUnit\Framework\TestCase;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Database\Migrations\Migrator;
@@ -56,8 +57,8 @@ public function testBasicMigrationOfSingleFolder()
$this->assertTrue($this->db->schema()->hasTable('users'));
$this->assertTrue($this->db->schema()->hasTable('password_resets'));
- $this->assertTrue(str_contains($ran[0], 'users'));
- $this->assertTrue(str_contains($ran[1], 'password_resets'));
+ $this->assertTrue(Str::contains($ran[0], 'users'));
+ $this->assertTrue(Str::contains($ran[1], 'password_resets'));
}
public function testMigrationsCanBeRolledBack()
@@ -69,8 +70,8 @@ public function testMigrationsCanBeRolledBack()
$this->assertFalse($this->db->schema()->hasTable('users'));
$this->assertFalse($this->db->schema()->hasTable('password_resets'));
- $this->assertTrue(str_contains($rolledBack[0], 'password_resets'));
- $this->assertTrue(str_contains($rolledBack[1], 'users'));
+ $this->assertTrue(Str::contains($rolledBack[0], 'password_resets'));
+ $this->assertTrue(Str::contains($rolledBack[1], 'users'));
}
public function testMigrationsCanBeReset()
@@ -82,8 +83,8 @@ public function testMigrationsCanBeReset()
$this->assertFalse($this->db->schema()->hasTable('users'));
$this->assertFalse($this->db->schema()->hasTable('password_resets'));
- $this->assertTrue(str_contains($rolledBack[0], 'password_resets'));
- $this->assertTrue(str_contains($rolledBack[1], 'users'));
+ $this->assertTrue(Str::contains($rolledBack[0], 'password_resets'));
+ $this->assertTrue(Str::contains($rolledBack[1], 'users'));
}
public function testNoErrorIsThrownWhenNoOutstandingMigrationsExist() | true |
Other | laravel | framework | f4a509a38edbbe6908685ee22e06b9d2159fb3f5.json | Use Str:: class. (#19221) | tests/Mail/MailSesTransportTest.php | @@ -3,6 +3,7 @@
namespace Illuminate\Tests\Mail;
use Aws\Ses\SesClient;
+use Illuminate\Support\Str;
use PHPUnit\Framework\TestCase;
use Illuminate\Support\Collection;
use Illuminate\Mail\TransportManager;
@@ -50,7 +51,7 @@ public function testSend()
// Generate a messageId for our mock to return to ensure that the post-sent message
// has X-SES-Message-ID in its headers
- $messageId = str_random(32);
+ $messageId = Str::random(32);
$sendRawEmailMock = new sendRawEmailMock($messageId);
$client->expects($this->once())
->method('sendRawEmail') | true |
Other | laravel | framework | f4a509a38edbbe6908685ee22e06b9d2159fb3f5.json | Use Str:: class. (#19221) | tests/Routing/RoutingRouteTest.php | @@ -3,6 +3,7 @@
namespace Illuminate\Tests\Routing;
use stdClass;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use UnexpectedValueException;
@@ -408,37 +409,37 @@ public function testControllerCallActionMethodParameters()
// Has one argument but receives two
unset($_SERVER['__test.controller_callAction_parameters']);
- $router->get(($str = str_random()).'/{one}/{two}', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@oneArgument');
+ $router->get(($str = Str::random()).'/{one}/{two}', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@oneArgument');
$router->dispatch(Request::create($str.'/one/two', 'GET'));
$this->assertEquals(['one' => 'one', 'two' => 'two'], $_SERVER['__test.controller_callAction_parameters']);
// Has two arguments and receives two
unset($_SERVER['__test.controller_callAction_parameters']);
- $router->get(($str = str_random()).'/{one}/{two}', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@twoArguments');
+ $router->get(($str = Str::random()).'/{one}/{two}', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@twoArguments');
$router->dispatch(Request::create($str.'/one/two', 'GET'));
$this->assertEquals(['one' => 'one', 'two' => 'two'], $_SERVER['__test.controller_callAction_parameters']);
// Has two arguments but with different names from the ones passed from the route
unset($_SERVER['__test.controller_callAction_parameters']);
- $router->get(($str = str_random()).'/{one}/{two}', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@differentArgumentNames');
+ $router->get(($str = Str::random()).'/{one}/{two}', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@differentArgumentNames');
$router->dispatch(Request::create($str.'/one/two', 'GET'));
$this->assertEquals(['one' => 'one', 'two' => 'two'], $_SERVER['__test.controller_callAction_parameters']);
// Has two arguments with same name but argument order is reversed
unset($_SERVER['__test.controller_callAction_parameters']);
- $router->get(($str = str_random()).'/{one}/{two}', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@reversedArguments');
+ $router->get(($str = Str::random()).'/{one}/{two}', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@reversedArguments');
$router->dispatch(Request::create($str.'/one/two', 'GET'));
$this->assertEquals(['one' => 'one', 'two' => 'two'], $_SERVER['__test.controller_callAction_parameters']);
// No route parameters while method has parameters
unset($_SERVER['__test.controller_callAction_parameters']);
- $router->get(($str = str_random()).'', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@oneArgument');
+ $router->get(($str = Str::random()).'', 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@oneArgument');
$router->dispatch(Request::create($str, 'GET'));
$this->assertEquals([], $_SERVER['__test.controller_callAction_parameters']);
// With model bindings
unset($_SERVER['__test.controller_callAction_parameters']);
- $router->get(($str = str_random()).'/{user}/{defaultNull?}/{team?}', [
+ $router->get(($str = Str::random()).'/{user}/{defaultNull?}/{team?}', [
'middleware' => SubstituteBindings::class,
'uses' => 'Illuminate\Tests\Routing\RouteTestAnotherControllerWithParameterStub@withModels',
]); | true |
Other | laravel | framework | f4a509a38edbbe6908685ee22e06b9d2159fb3f5.json | Use Str:: class. (#19221) | tests/Support/SupportHelpersTest.php | @@ -290,11 +290,11 @@ public function testStrLimit()
public function testCamelCase()
{
- $this->assertEquals('fooBar', camel_case('FooBar'));
- $this->assertEquals('fooBar', camel_case('foo_bar'));
- $this->assertEquals('fooBar', camel_case('foo_bar')); // test cache
- $this->assertEquals('fooBarBaz', camel_case('Foo-barBaz'));
- $this->assertEquals('fooBarBaz', camel_case('foo-bar_baz'));
+ $this->assertEquals('fooBar', Str::camel('FooBar'));
+ $this->assertEquals('fooBar', Str::camel('foo_bar'));
+ $this->assertEquals('fooBar', Str::camel('foo_bar')); // test cache
+ $this->assertEquals('fooBarBaz', Str::camel('Foo-barBaz'));
+ $this->assertEquals('fooBarBaz', Str::camel('foo-bar_baz'));
}
public function testStudlyCase() | true |
Other | laravel | framework | bdf5e28af01cd974bce37e73bcbf8c0244373e2c.json | use ruby coc | CODE_OF_CONDUCT.md | @@ -1,74 +1,9 @@
-# Contributor Covenant Code of Conduct
+The Laravel code of conduct is derived from the Ruby code of conduct. Any violations of the code of conduct may be reported to Taylor Otwell (taylor@laravel.com).
-## Our Pledge
+- Participants will be tolerant of opposing views.
-In the interest of fostering an open and welcoming environment, we as
-contributors and maintainers pledge to making participation in our project and
-our community a harassment-free experience for everyone, regardless of age, body
-size, disability, ethnicity, gender identity and expression, level of experience,
-nationality, personal appearance, race, religion, or sexual identity and
-orientation.
+- Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
-## Our Standards
+- When interpreting the words and actions of others, participants should always assume good intentions.
-Examples of behavior that contributes to creating a positive environment
-include:
-
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery and unwelcome sexual attention or
-advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
-
-## Our Responsibilities
-
-Project maintainers are responsible for clarifying the standards of acceptable
-behavior and are expected to take appropriate and fair corrective action in
-response to any instances of unacceptable behavior.
-
-Project maintainers have the right and responsibility to remove, edit, or
-reject comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct, or to ban temporarily or
-permanently any contributor for other behaviors that they deem inappropriate,
-threatening, offensive, or harmful.
-
-## Scope
-
-This Code of Conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community. Examples of
-representing a project or community include using an official project e-mail
-address, posting via an official social media account, or acting as an appointed
-representative at an online or offline event. Representation of a project may be
-further defined and clarified by project maintainers.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by contacting the Taylor Otwell at taylor@laravel.com. All
-complaints will be reviewed and investigated and will result in a response that
-is deemed necessary and appropriate to the circumstances. The project team is
-obligated to maintain confidentiality with regard to the reporter of an incident.
-Further details of specific enforcement policies may be posted separately.
-
-Project maintainers who do not follow or enforce the Code of Conduct in good
-faith may face temporary or permanent repercussions as determined by other
-members of the project's leadership.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
-available at [http://contributor-covenant.org/version/1/4][version]
-
-[homepage]: http://contributor-covenant.org
-[version]: http://contributor-covenant.org/version/1/4/
+- Behavior which can be reasonably considered harassment will not be tolerated. | false |
Other | laravel | framework | 8a66ecab0c45700140fffe26640bcc03119e34c6.json | Add link to COC in Readme.md | README.md | @@ -32,6 +32,10 @@ If you're not in the mood to read, [Laracasts](https://laracasts.com) contains o
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions).
+## Code of Conduct
+
+In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](CODE_OF_CONDUCT.md).
+
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. | false |
Other | laravel | framework | 0fd48de10a7d6b9c35d9710fffa1d52166d96862.json | Add Contributor Covenant Code of Conduct. | CODE_OF_CONDUCT.md | @@ -0,0 +1,74 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, gender identity and expression, level of experience,
+nationality, personal appearance, race, religion, or sexual identity and
+orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or
+advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at taylor@laravel.com. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/ | false |
Other | laravel | framework | d36101c68f43e22fbe69e61eb2d9b68d9d698d15.json | Add a PasswordReset event. (#19188) | src/Illuminate/Auth/Events/PasswordReset.php | @@ -0,0 +1,28 @@
+<?php
+
+namespace Illuminate\Auth\Events;
+
+use Illuminate\Queue\SerializesModels;
+
+class PasswordReset
+{
+ use SerializesModels;
+
+ /**
+ * The user.
+ *
+ * @var \Illuminate\Contracts\Auth\Authenticatable
+ */
+ public $user;
+
+ /**
+ * Create a new event instance.
+ *
+ * @param \Illuminate\Contracts\Auth\Authenticatable $user
+ * @return void
+ */
+ public function __construct($user)
+ {
+ $this->user = $user;
+ }
+} | true |
Other | laravel | framework | d36101c68f43e22fbe69e61eb2d9b68d9d698d15.json | Add a PasswordReset event. (#19188) | src/Illuminate/Foundation/Auth/ResetsPasswords.php | @@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Password;
+use Illuminate\Auth\Events\PasswordReset;
trait ResetsPasswords
{
@@ -106,6 +107,8 @@ protected function resetPassword($user, $password)
$user->save();
+ event(new PasswordReset($user));
+
$this->guard()->login($user);
}
| true |
Other | laravel | framework | dbc13686fcdcab624dcef057c455ab37e1258990.json | Fix typo in pagination (#19205) | src/Illuminate/Pagination/AbstractPaginator.php | @@ -60,7 +60,7 @@ abstract class AbstractPaginator implements Htmlable
protected $pageName = 'page';
/**
- * The current page resolver callback.
+ * The current path resolver callback.
*
* @var \Closure
*/ | false |
Other | laravel | framework | 4287ebc76025cd31e0ba6730481a95aeb471e305.json | add method for easier error bag checking | src/Illuminate/Foundation/Testing/TestResponse.php | @@ -550,6 +550,19 @@ public function assertSessionHasErrors($keys = [], $format = null, $errorBag = '
return $this;
}
+ /**
+ * Assert that the session has the given errors.
+ *
+ * @param string $errorBag
+ * @param string|array $keys
+ * @param mixed $format
+ * @return $this
+ */
+ public function assertSessionHasErrorsIn($errorBag, $keys = [], $format = null)
+ {
+ return $this->assertSessionHasErrors($keys, $format, $errorBag);
+ }
+
/**
* Assert that the session does not have a given key.
* | false |
Other | laravel | framework | f7fa463291a72f69aba8c03123078fddd5d039d1.json | add `abilities` method to Gate contract (#19173) | src/Illuminate/Contracts/Auth/Access/Gate.php | @@ -101,4 +101,11 @@ public function getPolicyFor($class);
* @return static
*/
public function forUser($user);
+
+ /**
+ * Get all of the defined abilities.
+ *
+ * @return array
+ */
+ public function abilities();
} | false |
Other | laravel | framework | b787ac38e70b33e567bd82dd8c086f203141f89d.json | Apply fixes from StyleCI (#19170) | src/Illuminate/Routing/Controller.php | @@ -3,7 +3,6 @@
namespace Illuminate\Routing;
use BadMethodCallException;
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
abstract class Controller
{ | false |
Other | laravel | framework | bf5d221037d9857a74020f2623839e282035a420.json | remove old missingMethod action | src/Illuminate/Routing/Controller.php | @@ -55,19 +55,6 @@ public function callAction($method, $parameters)
return call_user_func_array([$this, $method], $parameters);
}
- /**
- * Handle calls to missing methods on the controller.
- *
- * @param array $parameters
- * @return mixed
- *
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
- */
- public function missingMethod($parameters = [])
- {
- throw new NotFoundHttpException('Controller method not found.');
- }
-
/**
* Handle calls to missing methods on the controller.
* | false |
Other | laravel | framework | 0b934bc68237a208534d1480cdb268f53ef99c42.json | fix container build and add tests | src/Illuminate/Container/Container.php | @@ -715,7 +715,7 @@ public function build($concrete)
// hand back the results of the functions, which allows functions to be
// used as resolvers for more fine-tuned resolution of these objects.
if ($concrete instanceof Closure) {
- return $concrete($this, end($this->with));
+ return $concrete($this, $this->getLastParameterOverride());
}
$reflector = new ReflectionClass($concrete);
@@ -793,7 +793,7 @@ protected function resolveDependencies(array $dependencies)
*/
protected function hasParameterOverride($dependency)
{
- return array_key_exists($dependency->name, end($this->with));
+ return array_key_exists($dependency->name, $this->getLastParameterOverride());
}
/**
@@ -804,7 +804,17 @@ protected function hasParameterOverride($dependency)
*/
protected function getParameterOverride($dependency)
{
- return end($this->with)[$dependency->name];
+ return $this->getLastParameterOverride()[$dependency->name];
+ }
+
+ /**
+ * Get the last parameter override.
+ *
+ * @return array
+ */
+ protected function getLastParameterOverride()
+ {
+ return count($this->with) ? end($this->with) : [];
}
/** | true |
Other | laravel | framework | 0b934bc68237a208534d1480cdb268f53ef99c42.json | fix container build and add tests | tests/Container/ContainerTest.php | @@ -838,6 +838,19 @@ public function testSingletonBindingsNotRespectedWithMakeParameters()
$this->assertEquals(['name' => 'taylor'], $container->makeWith('foo', ['name' => 'taylor']));
$this->assertEquals(['name' => 'abigail'], $container->makeWith('foo', ['name' => 'abigail']));
}
+
+ public function testCanBuildWithoutParameterStackWithNoConstructors()
+ {
+ $container = new Container;
+ $this->assertInstanceOf(ContainerConcreteStub::class, $container->build(ContainerConcreteStub::class));
+ }
+
+ public function testCanBuildWithoutParameterStackWithConstructors()
+ {
+ $container = new Container;
+ $container->bind('Illuminate\Tests\Container\IContainerContractStub', 'Illuminate\Tests\Container\ContainerImplementationStub');
+ $this->assertInstanceOf(ContainerDependentStub::class, $container->build(ContainerDependentStub::class));
+ }
}
class ContainerConcreteStub | true |
Other | laravel | framework | 418137f61e5a57d122145c301224564f7f5a4727.json | Send optional fields to unfurl links and media | src/Illuminate/Notifications/Channels/SlackWebhookChannel.php | @@ -59,6 +59,8 @@ protected function buildJsonPayload(SlackMessage $message)
'icon_emoji' => data_get($message, 'icon'),
'icon_url' => data_get($message, 'image'),
'link_names' => data_get($message, 'linkNames'),
+ 'unfurl_links' => data_get($message, 'unfurlLinks'),
+ 'unfurl_media' => data_get($message, 'unfurlMedia'),
'username' => data_get($message, 'username'),
]);
| false |
Other | laravel | framework | d923504dc66a3f88759cab2023abfaf715596d28.json | Add methods to change unfurl options | src/Illuminate/Notifications/Messages/SlackMessage.php | @@ -55,6 +55,20 @@ class SlackMessage
*/
public $linkNames = 0;
+ /**
+ * Indicates if you want a preview of links inlined in the message.
+ *
+ * @var bool
+ */
+ public $unfurlLinks = true;
+
+ /**
+ * Indicates if you want a preview of links to media inlined in the message.
+ *
+ * @var bool
+ */
+ public $unfurlMedia = true;
+
/**
* The message's attachments.
*
@@ -206,6 +220,30 @@ public function linkNames()
return $this;
}
+ /**
+ * Find and link channel names and usernames.
+ *
+ * @return $this
+ */
+ public function unfurlLinks($unfurl = true)
+ {
+ $this->unfurlLinks = $unfurl;
+
+ return $this;
+ }
+
+ /**
+ * Find and link channel names and usernames.
+ *
+ * @return $this
+ */
+ public function unfurlMedia($unfurl = true)
+ {
+ $this->unfurlMedia = $unfurl;
+
+ return $this;
+ }
+
/**
* Set additional request options for the Guzzle HTTP client.
* | false |
Other | laravel | framework | 8f1a966925e28cf32274727013c7efa72868c96a.json | Move empty key detection above starts_with check | src/Illuminate/Encryption/EncryptionServiceProvider.php | @@ -18,19 +18,21 @@ public function register()
$this->app->singleton('encrypter', function ($app) {
$config = $app->make('config')->get('app');
- // If the key starts with "base64:", we will need to decode the key before handing
- // it off to the encrypter. Keys may be base-64 encoded for presentation and we
- // want to make sure to convert them back to the raw bytes before encrypting.
- if (Str::startsWith($key = $config['key'], 'base64:')) {
- $key = base64_decode(substr($key, 7));
- }
+ $key = $config['key'];
if (is_null($key) || $key === '') {
throw new RuntimeException(
'The application encryption key is missing. Run php artisan key:generate to generate it.'
);
}
+ // If the key starts with "base64:", we will need to decode the key before handing
+ // it off to the encrypter. Keys may be base-64 encoded for presentation and we
+ // want to make sure to convert them back to the raw bytes before encrypting.
+ if (Str::startsWith($key, 'base64:')) {
+ $key = base64_decode(substr($key, 7));
+ }
+
return new Encrypter($key, $config['cipher']);
});
} | false |
Other | laravel | framework | 3a4fdd041c226c0299f0de8047d23ac3d1fbe675.json | Add better error message for missing app key | src/Illuminate/Encryption/EncryptionServiceProvider.php | @@ -2,6 +2,7 @@
namespace Illuminate\Encryption;
+use RuntimeException;
use Illuminate\Support\Str;
use Illuminate\Support\ServiceProvider;
@@ -24,6 +25,12 @@ public function register()
$key = base64_decode(substr($key, 7));
}
+ if (is_null($key) || $key === '') {
+ throw new RuntimeException(
+ 'The application encryption key is missing. Run php artisan key:generate to generate it.'
+ );
+ }
+
return new Encrypter($key, $config['cipher']);
});
} | false |
Other | laravel | framework | 452d7e0afb5740d204b6e078a24a14fb7270c4f3.json | Update FilesystemAdapter.php (#19131)
putFile-method accepts both \Illuminate\Http\File and \Illuminate\Http\UploadedFile | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -123,7 +123,7 @@ public function put($path, $contents, $options = [])
* Store the uploaded file on the disk.
*
* @param string $path
- * @param \Illuminate\Http\UploadedFile $file
+ * @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile $file
* @param array $options
* @return string|false
*/ | false |
Other | laravel | framework | 79c28d6aaedda60b8ecf69ca71763f4239c4b789.json | add tests for default and custom resource gates | tests/Auth/AuthAccessGateTest.php | @@ -35,6 +35,35 @@ public function test_basic_closures_can_be_defined()
$this->assertFalse($gate->check('bar'));
}
+ public function test_resource_gates_can_be_defined()
+ {
+ $gate = $this->getBasicGate();
+
+ $gate->resource('test', AccessGateTestResource::class);
+
+ $dummy = new AccessGateTestDummy;
+
+ $this->assertTrue($gate->check('test.view'));
+ $this->assertTrue($gate->check('test.create'));
+ $this->assertTrue($gate->check('test.update', $dummy));
+ $this->assertTrue($gate->check('test.delete', $dummy));
+ }
+
+ public function test_custom_resource_gates_can_be_defined()
+ {
+ $gate = $this->getBasicGate();
+
+ $abilities = [
+ 'ability1' => 'foo',
+ 'ability2' => 'bar',
+ ];
+
+ $gate->resource('test', AccessGateTestCustomResource::class, $abilities);
+
+ $this->assertTrue($gate->check('test.ability1'));
+ $this->assertTrue($gate->check('test.ability2'));
+ }
+
public function test_before_callbacks_can_override_result_if_necessary()
{
$gate = $this->getBasicGate();
@@ -343,3 +372,39 @@ public function update($user, AccessGateTestDummy $dummy)
return false;
}
}
+
+class AccessGateTestResource
+{
+ public function view($user)
+ {
+ return true;
+ }
+
+ public function create($user)
+ {
+ return true;
+ }
+
+ public function update($user, AccessGateTestDummy $dummy)
+ {
+ return true;
+ }
+
+ public function delete($user, AccessGateTestDummy $dummy)
+ {
+ return true;
+ }
+}
+
+class AccessGateTestCustomResource
+{
+ public function foo($user)
+ {
+ return true;
+ }
+
+ public function bar($user)
+ {
+ return true;
+ }
+} | false |
Other | laravel | framework | a6ff272c54677a9f52718292fc0938ffb1871832.json | make request helper and __get consistent | src/Illuminate/Foundation/helpers.php | @@ -695,7 +695,9 @@ function request($key = null, $default = null)
return app('request')->only($key);
}
- return data_get(app('request')->all(), $key, $default);
+ $value = app('request')->__get($key);
+
+ return is_null($value) ? value($default) : $value;
}
}
| true |
Other | laravel | framework | a6ff272c54677a9f52718292fc0938ffb1871832.json | make request helper and __get consistent | src/Illuminate/Http/Request.php | @@ -530,7 +530,9 @@ public function toArray()
*/
public function offsetExists($offset)
{
- return array_key_exists($offset, $this->all());
+ return array_key_exists(
+ $offset, $this->all() + $this->route()->parameters()
+ );
}
/**
@@ -541,7 +543,7 @@ public function offsetExists($offset)
*/
public function offsetGet($offset)
{
- return data_get($this->all(), $offset);
+ return $this->__get($offset);
}
/**
@@ -586,8 +588,8 @@ public function __isset($key)
*/
public function __get($key)
{
- if ($this->offsetExists($key)) {
- return $this->offsetGet($key);
+ if (array_key_exists($key, $this->all())) {
+ return data_get($this->all(), $key);
}
return $this->route($key); | true |
Other | laravel | framework | a6ff272c54677a9f52718292fc0938ffb1871832.json | make request helper and __get consistent | tests/Http/HttpRequestTest.php | @@ -693,8 +693,8 @@ public function testMagicMethods()
// Parameter 'empty' is '', then it ISSET and is EMPTY.
$this->assertEquals($request->empty, '');
- $this->assertEquals(isset($request->empty), true);
- $this->assertEquals(empty($request->empty), true);
+ $this->assertTrue(isset($request->empty));
+ $this->assertTrue(empty($request->empty));
// Parameter 'undefined' is undefined/null, then it NOT ISSET and is EMPTY.
$this->assertEquals($request->undefined, null);
@@ -711,7 +711,8 @@ public function testMagicMethods()
});
// Router parameter 'foo' is 'bar', then it ISSET and is NOT EMPTY.
- $this->assertEquals($request->foo, 'bar');
+ $this->assertEquals('bar', $request->foo);
+ $this->assertEquals('bar', $request['foo']);
$this->assertEquals(isset($request->foo), true);
$this->assertEquals(empty($request->foo), false);
| true |
Other | laravel | framework | 0eb361727446990d437d538c6a908574a4019fe7.json | prevent policies from being too greedy
- return `false` on `resolvePolicyCallback` if the ability/method is
not callable
- if no policy callback is found, allow the gate to try and resolve the
ability before defaulting to `false`.
- add test to make sure policies defer to the gate if method does not
exist on policy
- minor rename to other test to explicitly state the policy defaults to
false if the method does not exists **AND** the gate does not exist. | src/Illuminate/Auth/Access/Gate.php | @@ -332,7 +332,9 @@ protected function resolveAuthCallback($user, $ability, array $arguments)
{
if (isset($arguments[0])) {
if (! is_null($policy = $this->getPolicyFor($arguments[0]))) {
- return $this->resolvePolicyCallback($user, $ability, $arguments, $policy);
+ if ($policyCallback = $this->resolvePolicyCallback($user, $ability, $arguments, $policy)) {
+ return $policyCallback;
+ }
}
}
@@ -390,10 +392,15 @@ public function resolvePolicy($class)
* @param string $ability
* @param array $arguments
* @param mixed $policy
- * @return callable
+ * @return bool|callable
*/
protected function resolvePolicyCallback($user, $ability, array $arguments, $policy)
{
+ // Check the method exists on the policy before we try to resolve it.
+ if (! is_callable([$policy, $this->formatAbilityToMethod($ability)])) {
+ return false;
+ }
+
return function () use ($user, $ability, $arguments, $policy) {
// This callback will be responsible for calling the policy's before method and
// running this policy method if necessary. This is used to when objects are | true |
Other | laravel | framework | 0eb361727446990d437d538c6a908574a4019fe7.json | prevent policies from being too greedy
- return `false` on `resolvePolicyCallback` if the ability/method is
not callable
- if no policy callback is found, allow the gate to try and resolve the
ability before defaulting to `false`.
- add test to make sure policies defer to the gate if method does not
exist on policy
- minor rename to other test to explicitly state the policy defaults to
false if the method does not exists **AND** the gate does not exist. | tests/Auth/AuthAccessGateTest.php | @@ -178,7 +178,7 @@ public function test_policy_converts_dash_to_camel()
$this->assertTrue($gate->check('update-dash', new AccessGateTestDummy));
}
- public function test_policy_default_to_false_if_method_does_not_exist()
+ public function test_policy_default_to_false_if_method_does_not_exist_and_gate_does_not_exist()
{
$gate = $this->getBasicGate();
@@ -218,6 +218,19 @@ public function test_policies_always_override_closures_with_same_name()
$this->assertTrue($gate->check('update', new AccessGateTestDummy));
}
+ public function test_policies_defer_to_gates_if_method_does_not_exist()
+ {
+ $gate = $this->getBasicGate();
+
+ $gate->define('nonexistent_method', function ($user) {
+ return true;
+ });
+
+ $gate->policy(AccessGateTestDummy::class, AccessGateTestPolicy::class);
+
+ $this->assertTrue($gate->check('nonexistent_method', new AccessGateTestDummy));
+ }
+
public function test_for_user_method_attaches_a_new_user_to_a_new_gate_instance()
{
$gate = $this->getBasicGate(); | true |
Other | laravel | framework | eb02670211fb8eec7aaf84679301565089cbd95f.json | Add a "validated" method to the form request | src/Illuminate/Foundation/Http/FormRequest.php | @@ -102,6 +102,16 @@ protected function createDefaultValidator(ValidationFactory $factory)
);
}
+ /**
+ * Get the validated data from the request.
+ *
+ * @return array
+ */
+ public function validated()
+ {
+ return $this->only(array_keys($this->container->call([$this, 'rules'])));
+ }
+
/**
* Get data to be validated from the request.
* | true |
Other | laravel | framework | eb02670211fb8eec7aaf84679301565089cbd95f.json | Add a "validated" method to the form request | tests/Foundation/FoundationFormRequestTest.php | @@ -26,6 +26,15 @@ public function tearDown()
$this->mocks = [];
}
+ public function test_validated_method_returns_the_validated_data()
+ {
+ $request = $this->createRequest(['name' => 'specified', 'with' => 'extras']);
+
+ $request->validate();
+
+ $this->assertEquals(['name' => 'specified'], $request->validated());
+ }
+
/**
* @expectedException \Illuminate\Validation\ValidationException
*/ | true |
Other | laravel | framework | 757be73cafd0d9afc86143db3241495bd5517d82.json | Add a second local key to HasManyThrough (#19114) | src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php | @@ -236,9 +236,10 @@ public function hasMany($related, $foreignKey = null, $localKey = null)
* @param string|null $firstKey
* @param string|null $secondKey
* @param string|null $localKey
+ * @param string|null $secondLocalKey
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
*/
- public function hasManyThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null)
+ public function hasManyThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
{
$through = new $through;
@@ -248,9 +249,11 @@ public function hasManyThrough($related, $through, $firstKey = null, $secondKey
$localKey = $localKey ?: $this->getKeyName();
+ $secondLocalKey = $secondLocalKey ?: $through->getKeyName();
+
$instance = $this->newRelatedInstance($related);
- return new HasManyThrough($instance->newQuery(), $this, $through, $firstKey, $secondKey, $localKey);
+ return new HasManyThrough($instance->newQuery(), $this, $through, $firstKey, $secondKey, $localKey, $secondLocalKey);
}
/** | true |
Other | laravel | framework | 757be73cafd0d9afc86143db3241495bd5517d82.json | Add a second local key to HasManyThrough (#19114) | src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php | @@ -45,6 +45,13 @@ class HasManyThrough extends Relation
*/
protected $localKey;
+ /**
+ * The local key on the intermediary model.
+ *
+ * @var string
+ */
+ protected $secondLocalKey;
+
/**
* Create a new has many through relationship instance.
*
@@ -54,15 +61,17 @@ class HasManyThrough extends Relation
* @param string $firstKey
* @param string $secondKey
* @param string $localKey
+ * @param string $secondLocalKey
* @return void
*/
- public function __construct(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey)
+ public function __construct(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey)
{
$this->localKey = $localKey;
$this->firstKey = $firstKey;
$this->secondKey = $secondKey;
$this->farParent = $farParent;
$this->throughParent = $throughParent;
+ $this->secondLocalKey = $secondLocalKey;
parent::__construct($query, $throughParent);
}
@@ -102,6 +111,16 @@ protected function performJoin(Builder $query = null)
}
}
+ /**
+ * Get the fully qualified parent key name.
+ *
+ * @return string
+ */
+ public function getQualifiedParentKeyName()
+ {
+ return $this->parent->getTable().'.'.$this->secondLocalKey;
+ }
+
/**
* Determine whether "through" parent of the relation uses Soft Deletes.
* | true |
Other | laravel | framework | 757be73cafd0d9afc86143db3241495bd5517d82.json | Add a second local key to HasManyThrough (#19114) | tests/Database/DatabaseEloquentHasManyThroughIntegrationTest.php | @@ -0,0 +1,413 @@
+<?php
+
+namespace Illuminate\Tests\Database;
+
+use PHPUnit\Framework\TestCase;
+use Illuminate\Database\Connection;
+use Illuminate\Database\Eloquent\SoftDeletes;
+use Illuminate\Database\Capsule\Manager as DB;
+use Illuminate\Database\Eloquent\Model as Eloquent;
+
+class DatabaseEloquentHasManyThroughIntegrationTest extends TestCase
+{
+ public function setUp()
+ {
+ $db = new DB;
+
+ $db->addConnection([
+ 'driver' => 'sqlite',
+ 'database' => ':memory:',
+ ]);
+
+ $db->bootEloquent();
+ $db->setAsGlobal();
+
+ $this->createSchema();
+ }
+
+ /**
+ * Setup the database schema.
+ *
+ * @return void
+ */
+ public function createSchema()
+ {
+ $this->schema()->create('users', function ($table) {
+ $table->increments('id');
+ $table->string('email')->unique();
+ $table->unsignedInteger('country_id');
+ $table->string('country_short');
+ $table->timestamps();
+ $table->softDeletes();
+ });
+
+ $this->schema()->create('posts', function ($table) {
+ $table->increments('id');
+ $table->integer('user_id');
+ $table->string('title');
+ $table->text('body');
+ $table->string('email');
+ $table->timestamps();
+ });
+
+ $this->schema()->create('countries', function ($table) {
+ $table->increments('id');
+ $table->string('name');
+ $table->string('shortname');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Tear down the database schema.
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ $this->schema()->drop('users');
+ $this->schema()->drop('posts');
+ $this->schema()->drop('countries');
+ }
+
+ public function testItLoadsAHasManyThroughRelationWithCustomKeys()
+ {
+ $this->seedData();
+ $posts = HasManyThroughTestCountry::first()->posts;
+
+ $this->assertEquals('A title', $posts[0]->title);
+ $this->assertCount(2, $posts);
+ }
+
+ public function testItLoadsADefaultHasManyThroughRelation()
+ {
+ $this->migrateDefault();
+ $this->seedDefaultData();
+
+ $posts = HasManyThroughDefaultTestCountry::first()->posts;
+ $this->assertEquals('A title', $posts[0]->title);
+ $this->assertCount(2, $posts);
+
+ $this->resetDefault();
+ }
+
+ public function testItLoadsARelationWithCustomIntermediateAndLocalKey()
+ {
+ $this->seedData();
+ $posts = HasManyThroughIntermediateTestCountry::first()->posts;
+
+ $this->assertEquals('A title', $posts[0]->title);
+ $this->assertCount(2, $posts);
+ }
+
+ /**
+ * @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
+ */
+ public function testFirstOrFailThrowsAnException()
+ {
+ HasManyThroughTestCountry::create(['id' => 1, 'name' => 'United States of America', 'shortname' => 'us'])
+ ->users()->create(['id' => 1, 'email' => 'taylorotwell@gmail.com', 'country_short' => 'us']);
+
+ HasManyThroughTestCountry::first()->posts()->firstOrFail();
+ }
+
+ /**
+ * @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
+ */
+ public function testFindOrFailThrowsAnException()
+ {
+ HasManyThroughTestCountry::create(['id' => 1, 'name' => 'United States of America', 'shortname' => 'us'])
+ ->users()->create(['id' => 1, 'email' => 'taylorotwell@gmail.com', 'country_short' => 'us']);
+
+ HasManyThroughTestCountry::first()->posts()->findOrFail(1);
+ }
+
+ public function testFirstRetrievesFirstRecord()
+ {
+ $this->seedData();
+ $post = HasManyThroughTestCountry::first()->posts()->first();
+
+ $this->assertNotNull($post);
+ $this->assertEquals('A title', $post->title);
+ }
+
+ public function testAllColumnsAreRetrievedByDefault()
+ {
+ $this->seedData();
+ $post = HasManyThroughTestCountry::first()->posts()->first();
+
+ $this->assertEquals([
+ 'id',
+ 'user_id',
+ 'title',
+ 'body',
+ 'email',
+ 'created_at',
+ 'updated_at',
+ 'country_id',
+ ], array_keys($post->getAttributes()));
+ }
+
+ public function testOnlyProperColumnsAreSelectedIfProvided()
+ {
+ $this->seedData();
+ $post = HasManyThroughTestCountry::first()->posts()->first(['title', 'body']);
+
+ $this->assertEquals([
+ 'title',
+ 'body',
+ 'country_id',
+ ], array_keys($post->getAttributes()));
+ }
+
+ public function testIntermediateSoftDeletesAreIgnored()
+ {
+ $this->seedData();
+ HasManyThroughSoftDeletesTestUser::first()->delete();
+
+ $posts = HasManyThroughSoftDeletesTestCountry::first()->posts;
+
+ $this->assertEquals('A title', $posts[0]->title);
+ $this->assertCount(2, $posts);
+ }
+
+ public function testEagerLoadingLoadsRelatedModelsCorrectly()
+ {
+ $this->seedData();
+ $country = HasManyThroughSoftDeletesTestCountry::with('posts')->first();
+
+ $this->assertEquals('us', $country->shortname);
+ $this->assertEquals('A title', $country->posts[0]->title);
+ $this->assertCount(2, $country->posts);
+ }
+
+ /**
+ * Helpers...
+ */
+ protected function seedData()
+ {
+ HasManyThroughTestCountry::create(['id' => 1, 'name' => 'United States of America', 'shortname' => 'us'])
+ ->users()->create(['id' => 1, 'email' => 'taylorotwell@gmail.com', 'country_short' => 'us'])
+ ->posts()->createMany([
+ ['title' => 'A title', 'body' => 'A body', 'email' => 'taylorotwell@gmail.com'],
+ ['title' => 'Another title', 'body' => 'Another body', 'email' => 'taylorotwell@gmail.com'],
+ ]);
+ }
+
+ /**
+ * Seed data for a default HasManyThrough setup.
+ */
+ protected function seedDefaultData()
+ {
+ HasManyThroughDefaultTestCountry::create(['id' => 1, 'name' => 'United States of America'])
+ ->users()->create(['id' => 1, 'email' => 'taylorotwell@gmail.com'])
+ ->posts()->createMany([
+ ['title' => 'A title', 'body' => 'A body'],
+ ['title' => 'Another title', 'body' => 'Another body'],
+ ]);
+ }
+
+ /**
+ * Drop the default tables.
+ */
+ protected function resetDefault()
+ {
+ $this->schema()->drop('users_default');
+ $this->schema()->drop('posts_default');
+ $this->schema()->drop('countries_default');
+ }
+
+ /**
+ * Migrate tables for classes with a Laravel "default" HasManyThrough setup.
+ */
+ protected function migrateDefault()
+ {
+ $this->schema()->create('users_default', function ($table) {
+ $table->increments('id');
+ $table->string('email')->unique();
+ $table->unsignedInteger('has_many_through_default_test_country_id');
+ $table->timestamps();
+ });
+
+ $this->schema()->create('posts_default', function ($table) {
+ $table->increments('id');
+ $table->integer('has_many_through_default_test_user_id');
+ $table->string('title');
+ $table->text('body');
+ $table->timestamps();
+ });
+
+ $this->schema()->create('countries_default', function ($table) {
+ $table->increments('id');
+ $table->string('name');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Get a database connection instance.
+ *
+ * @return Connection
+ */
+ protected function connection()
+ {
+ return Eloquent::getConnectionResolver()->connection();
+ }
+
+ /**
+ * Get a schema builder instance.
+ *
+ * @return Schema\Builder
+ */
+ protected function schema()
+ {
+ return $this->connection()->getSchemaBuilder();
+ }
+}
+
+/**
+ * Eloquent Models...
+ */
+class HasManyThroughTestUser extends Eloquent
+{
+ protected $table = 'users';
+ protected $guarded = [];
+
+ public function posts()
+ {
+ return $this->hasMany(HasManyThroughTestPost::class, 'user_id');
+ }
+}
+
+/**
+ * Eloquent Models...
+ */
+class HasManyThroughTestPost extends Eloquent
+{
+ protected $table = 'posts';
+ protected $guarded = [];
+
+ public function owner()
+ {
+ return $this->belongsTo(HasManyThroughTestUser::class, 'user_id');
+ }
+}
+
+class HasManyThroughTestCountry extends Eloquent
+{
+ protected $table = 'countries';
+ protected $guarded = [];
+
+ public function posts()
+ {
+ return $this->hasManyThrough(HasManyThroughTestPost::class, HasManyThroughTestUser::class, 'country_id', 'user_id');
+ }
+
+ public function users()
+ {
+ return $this->hasMany(HasManyThroughTestUser::class, 'country_id');
+ }
+}
+
+/**
+ * Eloquent Models...
+ */
+class HasManyThroughDefaultTestUser extends Eloquent
+{
+ protected $table = 'users_default';
+ protected $guarded = [];
+
+ public function posts()
+ {
+ return $this->hasMany(HasManyThroughDefaultTestPost::class);
+ }
+}
+
+/**
+ * Eloquent Models...
+ */
+class HasManyThroughDefaultTestPost extends Eloquent
+{
+ protected $table = 'posts_default';
+ protected $guarded = [];
+
+ public function owner()
+ {
+ return $this->belongsTo(HasManyThroughDefaultTestUser::class);
+ }
+}
+
+class HasManyThroughDefaultTestCountry extends Eloquent
+{
+ protected $table = 'countries_default';
+ protected $guarded = [];
+
+ public function posts()
+ {
+ return $this->hasManyThrough(HasManyThroughDefaultTestPost::class, HasManyThroughDefaultTestUser::class);
+ }
+
+ public function users()
+ {
+ return $this->hasMany(HasManyThroughDefaultTestUser::class);
+ }
+}
+
+class HasManyThroughIntermediateTestCountry extends Eloquent
+{
+ protected $table = 'countries';
+ protected $guarded = [];
+
+ public function posts()
+ {
+ return $this->hasManyThrough(HasManyThroughTestPost::class, HasManyThroughTestUser::class, 'country_short', 'email', 'shortname', 'email');
+ }
+
+ public function users()
+ {
+ return $this->hasMany(HasManyThroughTestUser::class, 'country_id');
+ }
+}
+
+class HasManyThroughSoftDeletesTestUser extends Eloquent
+{
+ use SoftDeletes;
+
+ protected $table = 'users';
+ protected $guarded = [];
+
+ public function posts()
+ {
+ return $this->hasMany(HasManyThroughSoftDeletesTestPost::class, 'user_id');
+ }
+}
+
+/**
+ * Eloquent Models...
+ */
+class HasManyThroughSoftDeletesTestPost extends Eloquent
+{
+ protected $table = 'posts';
+ protected $guarded = [];
+
+ public function owner()
+ {
+ return $this->belongsTo(HasManyThroughSoftDeletesTestUser::class, 'user_id');
+ }
+}
+
+class HasManyThroughSoftDeletesTestCountry extends Eloquent
+{
+ protected $table = 'countries';
+ protected $guarded = [];
+
+ public function posts()
+ {
+ return $this->hasManyThrough(HasManyThroughSoftDeletesTestPost::class, HasManyThroughTestUser::class, 'country_id', 'user_id');
+ }
+
+ public function users()
+ {
+ return $this->hasMany(HasManyThroughSoftDeletesTestUser::class, 'country_id');
+ }
+} | true |
Other | laravel | framework | 757be73cafd0d9afc86143db3241495bd5517d82.json | Add a second local key to HasManyThrough (#19114) | tests/Database/DatabaseEloquentHasManyThroughTest.php | @@ -1,326 +0,0 @@
-<?php
-
-namespace Illuminate\Tests\Database;
-
-use stdClass;
-use Mockery as m;
-use PHPUnit\Framework\TestCase;
-use Illuminate\Database\Eloquent\Collection;
-use Illuminate\Database\Eloquent\SoftDeletes;
-use Illuminate\Database\Eloquent\Relations\HasManyThrough;
-
-class DatabaseEloquentHasManyThroughTest extends TestCase
-{
- public function tearDown()
- {
- m::close();
- }
-
- public function testRelationIsProperlyInitialized()
- {
- $relation = $this->getRelation();
- $model = m::mock('Illuminate\Database\Eloquent\Model');
- $relation->getRelated()->shouldReceive('newCollection')->andReturnUsing(function ($array = []) {
- return new Collection($array);
- });
- $model->shouldReceive('setRelation')->once()->with('foo', m::type('Illuminate\Database\Eloquent\Collection'));
- $models = $relation->initRelation([$model], 'foo');
-
- $this->assertEquals([$model], $models);
- }
-
- public function testEagerConstraintsAreProperlyAdded()
- {
- $relation = $this->getRelation();
- $relation->getQuery()->shouldReceive('whereIn')->once()->with('users.country_id', [1, 2]);
- $model1 = new EloquentHasManyThroughModelStub;
- $model1->id = 1;
- $model2 = new EloquentHasManyThroughModelStub;
- $model2->id = 2;
- $relation->addEagerConstraints([$model1, $model2]);
- }
-
- public function testEagerConstraintsAreProperlyAddedWithCustomKey()
- {
- $builder = m::mock('Illuminate\Database\Eloquent\Builder');
- $builder->shouldReceive('join')->once()->with('users', 'users.id', '=', 'posts.user_id');
- $builder->shouldReceive('where')->with('users.country_id', '=', 1);
-
- $country = m::mock('Illuminate\Database\Eloquent\Model');
- $country->shouldReceive('getKeyName')->andReturn('id');
- $country->shouldReceive('offsetGet')->andReturn(1);
- $country->shouldReceive('getForeignKey')->andReturn('country_id');
-
- $user = m::mock('Illuminate\Database\Eloquent\Model');
- $user->shouldReceive('getTable')->andReturn('users');
- $user->shouldReceive('getQualifiedKeyName')->andReturn('users.id');
- $post = m::mock('Illuminate\Database\Eloquent\Model');
- $post->shouldReceive('getTable')->andReturn('posts');
-
- $builder->shouldReceive('getModel')->andReturn($post);
-
- $relation = new HasManyThrough($builder, $country, $user, 'country_id', 'user_id', 'not_id');
- $relation->getQuery()->shouldReceive('whereIn')->once()->with('users.country_id', [3, 4]);
- $model1 = new EloquentHasManyThroughModelStub;
- $model1->id = 1;
- $model1->not_id = 3;
- $model2 = new EloquentHasManyThroughModelStub;
- $model2->id = 2;
- $model2->not_id = 4;
- $relation->addEagerConstraints([$model1, $model2]);
- }
-
- public function testModelsAreProperlyMatchedToParents()
- {
- $relation = $this->getRelation();
-
- $result1 = new EloquentHasManyThroughModelStub;
- $result1->country_id = 1;
- $result2 = new EloquentHasManyThroughModelStub;
- $result2->country_id = 2;
- $result3 = new EloquentHasManyThroughModelStub;
- $result3->country_id = 2;
-
- $model1 = new EloquentHasManyThroughModelStub;
- $model1->id = 1;
- $model2 = new EloquentHasManyThroughModelStub;
- $model2->id = 2;
- $model3 = new EloquentHasManyThroughModelStub;
- $model3->id = 3;
-
- $relation->getRelated()->shouldReceive('newCollection')->andReturnUsing(function ($array) {
- return new Collection($array);
- });
- $models = $relation->match([$model1, $model2, $model3], new Collection([$result1, $result2, $result3]), 'foo');
-
- $this->assertEquals(1, $models[0]->foo[0]->country_id);
- $this->assertEquals(1, count($models[0]->foo));
- $this->assertEquals(2, $models[1]->foo[0]->country_id);
- $this->assertEquals(2, $models[1]->foo[1]->country_id);
- $this->assertEquals(2, count($models[1]->foo));
- $this->assertEquals(0, count($models[2]->foo));
- }
-
- public function testModelsAreProperlyMatchedToParentsWithNonPrimaryKey()
- {
- $relation = $this->getRelationForNonPrimaryKey();
-
- $result1 = new EloquentHasManyThroughModelStub;
- $result1->country_id = 1;
- $result2 = new EloquentHasManyThroughModelStub;
- $result2->country_id = 2;
- $result3 = new EloquentHasManyThroughModelStub;
- $result3->country_id = 2;
-
- $model1 = new EloquentHasManyThroughModelStub;
- $model1->id = 1;
- $model2 = new EloquentHasManyThroughModelStub;
- $model2->id = 2;
- $model3 = new EloquentHasManyThroughModelStub;
- $model3->id = 3;
-
- $relation->getRelated()->shouldReceive('newCollection')->andReturnUsing(function ($array) {
- return new Collection($array);
- });
- $models = $relation->match([$model1, $model2, $model3], new Collection([$result1, $result2, $result3]), 'foo');
-
- $this->assertEquals(1, $models[0]->foo[0]->country_id);
- $this->assertEquals(1, count($models[0]->foo));
- $this->assertEquals(2, $models[1]->foo[0]->country_id);
- $this->assertEquals(2, $models[1]->foo[1]->country_id);
- $this->assertEquals(2, count($models[1]->foo));
- $this->assertEquals(0, count($models[2]->foo));
- }
-
- public function testAllColumnsAreSelectedByDefault()
- {
- $select = ['posts.*', 'users.country_id'];
-
- $baseBuilder = m::mock('Illuminate\Database\Query\Builder');
-
- $relation = $this->getRelation();
- $relation->getRelated()->shouldReceive('newCollection')->once();
-
- $builder = $relation->getQuery();
- $builder->shouldReceive('applyScopes')->andReturnSelf();
- $builder->shouldReceive('getQuery')->andReturn($baseBuilder);
- $builder->shouldReceive('addSelect')->once()->with($select)->andReturn($builder);
- $builder->shouldReceive('getModels')->once()->andReturn([]);
-
- $relation->get();
- }
-
- public function testOnlyProperColumnsAreSelectedIfProvided()
- {
- $select = ['users.country_id'];
-
- $baseBuilder = m::mock('Illuminate\Database\Query\Builder');
- $baseBuilder->columns = ['foo', 'bar'];
-
- $relation = $this->getRelation();
- $relation->getRelated()->shouldReceive('newCollection')->once();
-
- $builder = $relation->getQuery();
- $builder->shouldReceive('applyScopes')->andReturnSelf();
- $builder->shouldReceive('getQuery')->andReturn($baseBuilder);
- $builder->shouldReceive('addSelect')->once()->with($select)->andReturn($builder);
- $builder->shouldReceive('getModels')->once()->andReturn([]);
-
- $relation->get();
- }
-
- public function testFirstMethod()
- {
- $relation = m::mock('Illuminate\Database\Eloquent\Relations\HasManyThrough[get]', $this->getRelationArguments());
- $relation->shouldReceive('get')->once()->andReturn(new \Illuminate\Database\Eloquent\Collection(['first', 'second']));
- $relation->shouldReceive('take')->with(1)->once()->andReturn($relation);
-
- $this->assertEquals('first', $relation->first());
- }
-
- /**
- * @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
- */
- public function testFindOrFailThrowsException()
- {
- $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\HasManyThrough')->setMethods(['find'])->setConstructorArgs($this->getRelationArguments())->getMock();
- $relation->expects($this->once())->method('find')->with('foo')->will($this->returnValue(null));
-
- try {
- $relation->findOrFail('foo');
- } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
- $this->assertNotEmpty($e->getModel());
-
- throw $e;
- }
- }
-
- /**
- * @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
- */
- public function testFirstOrFailThrowsException()
- {
- $relation = $this->getMockBuilder('Illuminate\Database\Eloquent\Relations\HasManyThrough')->setMethods(['first'])->setConstructorArgs($this->getRelationArguments())->getMock();
- $relation->expects($this->once())->method('first')->with(['id' => 'foo'])->will($this->returnValue(null));
-
- try {
- $relation->firstOrFail(['id' => 'foo']);
- } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
- $this->assertNotEmpty($e->getModel());
-
- throw $e;
- }
- }
-
- public function testFindMethod()
- {
- $returnValue = new StdClass;
-
- $relation = m::mock('Illuminate\Database\Eloquent\Relations\HasManyThrough[first]', $this->getRelationArguments());
- $relation->shouldReceive('where')->with('posts.id', '=', 'foo')->once()->andReturn($relation);
- $relation->shouldReceive('first')->once()->andReturn($returnValue);
-
- $related = $relation->getRelated();
- $related->shouldReceive('getQualifiedKeyName')->once()->andReturn('posts.id');
-
- $this->assertEquals($returnValue, $relation->find('foo'));
- }
-
- public function testFindManyMethod()
- {
- $returnValue = new \Illuminate\Database\Eloquent\Collection(['first', 'second']);
-
- $relation = m::mock('Illuminate\Database\Eloquent\Relations\HasManyThrough[get]', $this->getRelationArguments());
- $relation->shouldReceive('get')->once()->andReturn($returnValue);
- $relation->shouldReceive('whereIn')->with('posts.id', ['foo', 'bar'])->once()->andReturn($relation);
-
- $related = $relation->getRelated();
- $related->shouldReceive('getQualifiedKeyName')->once()->andReturn('posts.id');
-
- $this->assertEquals($returnValue, $relation->findMany(['foo', 'bar']));
- }
-
- public function testIgnoreSoftDeletingParent()
- {
- list($builder, $country, , $firstKey, $secondKey) = $this->getRelationArguments();
- $user = new EloquentHasManyThroughSoftDeletingModelStub;
-
- $builder->shouldReceive('whereNull')->with('users.deleted_at')->once()->andReturn($builder);
-
- $relation = new HasManyThrough($builder, $country, $user, $firstKey, $secondKey, 'id');
- }
-
- protected function getRelation()
- {
- list($builder, $country, $user, $firstKey, $secondKey, $overrideKey) = $this->getRelationArguments();
-
- return new HasManyThrough($builder, $country, $user, $firstKey, $secondKey, $overrideKey);
- }
-
- protected function getRelationForNonPrimaryKey()
- {
- list($builder, $country, $user, $firstKey, $secondKey, $overrideKey) = $this->getRelationArgumentsForNonPrimaryKey();
-
- return new HasManyThrough($builder, $country, $user, $firstKey, $secondKey, $overrideKey);
- }
-
- protected function getRelationArguments()
- {
- $builder = m::mock('Illuminate\Database\Eloquent\Builder');
- $builder->shouldReceive('join')->once()->with('users', 'users.id', '=', 'posts.user_id');
- $builder->shouldReceive('where')->with('users.country_id', '=', 1);
-
- $country = m::mock('Illuminate\Database\Eloquent\Model');
- $country->shouldReceive('getKeyName')->andReturn('id');
- $country->shouldReceive('offsetGet')->andReturn(1);
- $country->shouldReceive('getForeignKey')->andReturn('country_id');
- $user = m::mock('Illuminate\Database\Eloquent\Model');
- $user->shouldReceive('getTable')->andReturn('users');
- $user->shouldReceive('getQualifiedKeyName')->andReturn('users.id');
- $post = m::mock('Illuminate\Database\Eloquent\Model');
- $post->shouldReceive('getTable')->andReturn('posts');
-
- $builder->shouldReceive('getModel')->andReturn($post);
-
- $user->shouldReceive('getKey')->andReturn(1);
- $user->shouldReceive('getCreatedAtColumn')->andReturn('created_at');
- $user->shouldReceive('getUpdatedAtColumn')->andReturn('updated_at');
-
- return [$builder, $country, $user, 'country_id', 'user_id', $country->getKeyName()];
- }
-
- protected function getRelationArgumentsForNonPrimaryKey()
- {
- $builder = m::mock('Illuminate\Database\Eloquent\Builder');
- $builder->shouldReceive('join')->once()->with('users', 'users.id', '=', 'posts.user_id');
- $builder->shouldReceive('where')->with('users.country_id', '=', 1);
-
- $country = m::mock('Illuminate\Database\Eloquent\Model');
- $country->shouldReceive('offsetGet')->andReturn(1);
- $country->shouldReceive('getForeignKey')->andReturn('country_id');
- $user = m::mock('Illuminate\Database\Eloquent\Model');
- $user->shouldReceive('getTable')->andReturn('users');
- $user->shouldReceive('getQualifiedKeyName')->andReturn('users.id');
- $post = m::mock('Illuminate\Database\Eloquent\Model');
- $post->shouldReceive('getTable')->andReturn('posts');
-
- $builder->shouldReceive('getModel')->andReturn($post);
-
- $user->shouldReceive('getKey')->andReturn(1);
- $user->shouldReceive('getCreatedAtColumn')->andReturn('created_at');
- $user->shouldReceive('getUpdatedAtColumn')->andReturn('updated_at');
-
- return [$builder, $country, $user, 'country_id', 'user_id', 'other_id'];
- }
-}
-
-class EloquentHasManyThroughModelStub extends \Illuminate\Database\Eloquent\Model
-{
- public $country_id = 'foreign.value';
-}
-
-class EloquentHasManyThroughSoftDeletingModelStub extends \Illuminate\Database\Eloquent\Model
-{
- use SoftDeletes;
- public $table = 'users';
-} | true |
Other | laravel | framework | 841b36cc005ee5c400f1276175db9e2692d1e167.json | move exceptions into internal array | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -41,6 +41,21 @@ class Handler implements ExceptionHandlerContract
*/
protected $dontReport = [];
+ /**
+ * A list of the internal exception types that should not be reported.
+ *
+ * @var array
+ */
+ protected $internalDontReport = [
+ \Illuminate\Auth\AuthenticationException::class,
+ \Illuminate\Auth\Access\AuthorizationException::class,
+ \Symfony\Component\HttpKernel\Exception\HttpException::class,
+ HttpResponseException::class,
+ \Illuminate\Database\Eloquent\ModelNotFoundException::class,
+ \Illuminate\Session\TokenMismatchException::class,
+ \Illuminate\Validation\ValidationException::class,
+ ];
+
/**
* Create a new exception handler instance.
*
@@ -98,7 +113,7 @@ public function shouldReport(Exception $e)
*/
protected function shouldntReport(Exception $e)
{
- $dontReport = array_merge($this->dontReport, [HttpResponseException::class]);
+ $dontReport = array_merge($this->dontReport, $this->internalDontReport);
return ! is_null(collect($dontReport)->first(function ($type) use ($e) {
return $e instanceof $type; | false |
Other | laravel | framework | d44c091acf6c01dbd202e39a21a8a2f2724b2441.json | Avoid unneeded function call (#19079) | src/Illuminate/Support/Str.php | @@ -152,7 +152,11 @@ public static function kebab($value)
*/
public static function length($value, $encoding = null)
{
- return mb_strlen($value, $encoding ?: mb_internal_encoding());
+ if ($encoding) {
+ return mb_strlen($value, $encoding);
+ }
+
+ return mb_strlen($value);
}
/** | false |
Other | laravel | framework | 5b7d0373d379634bdf1662d4c9313072d1c5231b.json | Add a validate method onto the request (#19063) | src/Illuminate/Foundation/Providers/FoundationServiceProvider.php | @@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Providers;
+use Illuminate\Http\Request;
use Illuminate\Support\AggregateServiceProvider;
class FoundationServiceProvider extends AggregateServiceProvider
@@ -14,4 +15,30 @@ class FoundationServiceProvider extends AggregateServiceProvider
protected $providers = [
FormRequestServiceProvider::class,
];
+
+ /**
+ * Register the service provider.
+ *
+ * @return void
+ */
+ public function register()
+ {
+ parent::register();
+
+ $this->registerRequestValidate();
+ }
+
+ /**
+ * Register the "validate" macro on the request.
+ *
+ * @return void
+ */
+ public function registerRequestValidate()
+ {
+ Request::macro('validate', function (array $rules, ...$params) {
+ validator()->validate($this->all(), $rules, ...$params);
+
+ return $this->only(array_keys($rules));
+ });
+ }
} | false |
Other | laravel | framework | 0e16770a54e63541dcd9686f4f7fa23edc1b4d95.json | Apply fixes from StyleCI (#19017) | tests/Database/DatabaseEloquentBuilderTest.php | @@ -647,7 +647,8 @@ public function testWithCountAndGlobalScope()
$builder = $model->select('id')->withCount(['foo']);
// Remove the global scope so it doesn't interfere with any other tests
- EloquentBuilderTestModelCloseRelatedStub::addGlobalScope('withCount', function ($query) {});
+ EloquentBuilderTestModelCloseRelatedStub::addGlobalScope('withCount', function ($query) {
+ });
$this->assertEquals('select "id", (select count(*) from "eloquent_builder_test_model_close_related_stubs" where "eloquent_builder_test_model_parent_stubs"."foo_id" = "eloquent_builder_test_model_close_related_stubs"."id") as "foo_count" from "eloquent_builder_test_model_parent_stubs"', $builder->toSql());
} | false |
Other | laravel | framework | deefa1f96df1f21de36e40ebe1ef61b997d8e098.json | Add language to str_slug helper (#19011) | src/Illuminate/Support/helpers.php | @@ -845,11 +845,12 @@ function str_singular($value)
*
* @param string $title
* @param string $separator
+ * @param string $language
* @return string
*/
- function str_slug($title, $separator = '-')
+ function str_slug($title, $separator = '-', $language = 'en')
{
- return Str::slug($title, $separator);
+ return Str::slug($title, $separator, $language);
}
}
| false |
Other | laravel | framework | 64d335590debd0a79ff2d30ecaea4883ea86f527.json | Apply fixes from StyleCI (#18988) | tests/Queue/QueueManagerTest.php | @@ -4,7 +4,6 @@
use Mockery as m;
use PHPUnit\Framework\TestCase;
-use Illuminate\Config\Repository;
use Illuminate\Queue\QueueManager;
class QueueManagerTest extends TestCase | false |
Other | laravel | framework | 7a871be756f4e3aee28109fbafe6edfe31bcf052.json | Return null if cache value is not found (#18984) | src/Illuminate/Cache/RedisStore.php | @@ -73,7 +73,7 @@ public function many(array $keys)
}, $keys));
foreach ($values as $index => $value) {
- $results[$keys[$index]] = $this->unserialize($value);
+ $results[$keys[$index]] = ! is_null($value) ? $this->unserialize($value) : null;
}
return $results; | true |
Other | laravel | framework | 7a871be756f4e3aee28109fbafe6edfe31bcf052.json | Return null if cache value is not found (#18984) | tests/Cache/CacheRedisStoreTest.php | @@ -32,19 +32,20 @@ public function testRedisMultipleValuesAreReturned()
{
$redis = $this->getRedis();
$redis->getRedis()->shouldReceive('connection')->once()->with('default')->andReturn($redis->getRedis());
- $redis->getRedis()->shouldReceive('mget')->once()->with(['prefix:foo', 'prefix:fizz', 'prefix:norf'])
+ $redis->getRedis()->shouldReceive('mget')->once()->with(['prefix:foo', 'prefix:fizz', 'prefix:norf', 'prefix:null'])
->andReturn([
serialize('bar'),
serialize('buzz'),
serialize('quz'),
+ null,
]);
- $this->assertEquals([
- 'foo' => 'bar',
- 'fizz' => 'buzz',
- 'norf' => 'quz',
- ], $redis->many([
- 'foo', 'fizz', 'norf',
- ]));
+
+ $results = $redis->many(['foo', 'fizz', 'norf', 'null']);
+
+ $this->assertEquals('bar', $results['foo']);
+ $this->assertEquals('buzz', $results['fizz']);
+ $this->assertEquals('quz', $results['norf']);
+ $this->assertNull($results['null']);
}
public function testRedisValueIsReturnedForNumerics() | true |
Other | laravel | framework | d1ea2e232299eba8572c213091772190be129b18.json | Create a mapToGroups method (#18949) | src/Illuminate/Support/Collection.php | @@ -704,6 +704,25 @@ public function map(callable $callback)
return new static(array_combine($keys, $items));
}
+ /**
+ * Run a grouping map over the items.
+ *
+ * The callback should return an associative array with a single key/value pair.
+ *
+ * @param callable $callback
+ * @return static
+ */
+ public function mapToGroups(callable $callback)
+ {
+ $groups = $this->map($callback)->reduce(function ($groups, $pair) {
+ $groups[key($pair)][] = reset($pair);
+
+ return $groups;
+ }, []);
+
+ return (new static($groups))->map([$this, 'make']);
+ }
+
/**
* Run an associative map over each of the items.
* | true |
Other | laravel | framework | d1ea2e232299eba8572c213091772190be129b18.json | Create a mapToGroups method (#18949) | tests/Support/SupportCollectionTest.php | @@ -1049,6 +1049,35 @@ public function testFlatMap()
$this->assertEquals(['programming', 'basketball', 'music', 'powerlifting'], $data->all());
}
+ public function testMapToGroups()
+ {
+ $data = new Collection([
+ ['id' => 1, 'name' => 'A'],
+ ['id' => 2, 'name' => 'B'],
+ ['id' => 3, 'name' => 'C'],
+ ['id' => 4, 'name' => 'B'],
+ ]);
+
+ $groups = $data->mapToGroups(function ($item, $key) {
+ return [$item['name'] => $item['id']];
+ });
+
+ $this->assertInstanceOf(Collection::class, $groups);
+ $this->assertEquals(['A' => [1], 'B' => [2, 4], 'C' => [3]], $groups->toArray());
+ $this->assertInstanceOf(Collection::class, $groups['A']);
+ }
+
+ public function testMapToGroupsWithNumericKeys()
+ {
+ $data = new Collection([1, 2, 3, 2, 1]);
+
+ $groups = $data->mapToGroups(function ($item, $key) {
+ return [$item => $key];
+ });
+
+ $this->assertEquals([1 => [0, 4], 2 => [1, 3], 3 => [2]], $groups->toArray());
+ }
+
public function testMapWithKeys()
{
$data = new Collection([ | true |
Other | laravel | framework | f74b33a7e2983778f8855449f390d829d123dc24.json | add name to home route (#18942) | src/Illuminate/Auth/Console/stubs/make/routes.stub | @@ -1,4 +1,4 @@
Auth::routes();
-Route::get('/home', 'HomeController@index');
+Route::get('/home', 'HomeController@index')->name('home'); | false |
Other | laravel | framework | befcfbcf1b0ed79e5d585b443fa06b88686d782a.json | Apply fixes from StyleCI (#18900) | tests/Validation/ValidationValidatorTest.php | @@ -432,7 +432,7 @@ public function testDisplayableAttributesAreReplacedInCustomReplacers()
$v->addExtension('alliteration', function ($attribute, $value, $parameters, $validator) {
$other = array_get($validator->getData(), $parameters[0]);
- return $value{0} == $other{0};
+ return $value[0] == $other[0];
});
$v->addReplacer('alliteration', function ($message, $attribute, $rule, $parameters, $validator) {
return str_replace(':other', $validator->getDisplayableAttribute($parameters[0]), $message);
@@ -449,7 +449,7 @@ public function testDisplayableAttributesAreReplacedInCustomReplacers()
$v->addExtension('alliteration', function ($attribute, $value, $parameters, $validator) {
$other = array_get($validator->getData(), $parameters[0]);
- return $value{0} == $other{0};
+ return $value[0] == $other[0];
});
$v->addReplacer('alliteration', function ($message, $attribute, $rule, $parameters, $validator) {
return str_replace(':other', $validator->getDisplayableAttribute($parameters[0]), $message); | false |
Other | laravel | framework | 1c40e8f5289ee46edb8ca1a1c6ff488d53e3d8ec.json | revert new methods on contract
it was pointed out to me that we can’t change contracts on 5.4, so
we’ll set it back to the original here.
these 2 methods can be targeted to 5.5, however. | src/Illuminate/Contracts/Queue/Queue.php | @@ -96,19 +96,4 @@ public function getConnectionName();
* @return $this
*/
public function setConnectionName($name);
-
- /**
- * Set the queue prefix.
- *
- * @param string $prefix
- * @return $this
- */
- public function setQueuePrefix($prefix = null);
-
- /**
- * Get the queue prefix.
- *
- * @return string
- */
- public function getQueuePrefix();
} | false |
Other | laravel | framework | 206aae2a7a5c97a7e0af3bed8e842635504de306.json | add tests, update changelog, increase readability | CHANGELOG-5.5.md | @@ -53,6 +53,9 @@
### Events
- ⚠️ Removed calling queue method on handlers ([0360cb1](https://github.com/laravel/framework/commit/0360cb1c6b71ec89d406517b19d1508511e98fb5), [ec96979](https://github.com/laravel/framework/commit/ec969797878f2c731034455af2397110732d14c4), [d9be4bf](https://github.com/laravel/framework/commit/d9be4bfe0367a8e07eed4931bdabf135292abb1b))
+### Filesystem
+- ⚠️ Made `Storage::files()` work like `Storage::allFiles()` ([#18874](https://github.com/laravel/framework/pull/18874))
+
### Helpers
- Added `throw_if()` and `throw_unless()` helpers ([18bb4df](https://github.com/laravel/framework/commit/18bb4dfc77c7c289e9b40c4096816ebeff1cd843))
- Added `dispatch_now()` helper function ([#18668](https://github.com/laravel/framework/pull/18668), [61f2e7b](https://github.com/laravel/framework/commit/61f2e7b4106f8eb0b79603d9792426f7c6a6d273)) | true |
Other | laravel | framework | 206aae2a7a5c97a7e0af3bed8e842635504de306.json | add tests, update changelog, increase readability | src/Illuminate/Filesystem/Filesystem.php | @@ -370,23 +370,30 @@ public function glob($pattern, $flags = 0)
* Get an array of all files in a directory.
*
* @param string $directory
+ * @param bool $ignoreDotFiles
* @return array
*/
- public function files($directory, $hidden = false)
+ public function files($directory, $ignoreDotFiles = false)
{
- return iterator_to_array(Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->depth(0), false);
+ return iterator_to_array(
+ Finder::create()->files()->ignoreDotFiles(! $ignoreDotFiles)->in($directory)->depth(0),
+ false
+ );
}
/**
* Get all of the files from the given directory (recursive).
*
* @param string $directory
- * @param bool $hidden
+ * @param bool $ignoreDotFiles
* @return array
*/
- public function allFiles($directory, $hidden = false)
+ public function allFiles($directory, $ignoreDotFiles = false)
{
- return iterator_to_array(Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory), false);
+ return iterator_to_array(
+ Finder::create()->files()->ignoreDotFiles(! $ignoreDotFiles)->in($directory),
+ false
+ );
}
/** | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.