Skip to content

Commit

Permalink
Merge branch '5.6' of github.com:laravel/framework into 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 29, 2018
2 parents 5695acb + e30cba0 commit 4204c8a
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 10 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG-5.5.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Release Notes for 5.5.x

## [Unreleased]

### Added
- Added `notExists()` method to query builder ([#22836](https://github.com/laravel/framework/pull/22836), [9d2a7ca](https://github.com/laravel/framework/commit/9d2a7ca049e71d39e453ba8c34addb657b71b237))
- Added `assertHeaderMissing()` assertion ([#22849](https://github.com/laravel/framework/pull/22849), [#22866](https://github.com/laravel/framework/pull/22866))
- Added support for higher order unique ([#22851](https://github.com/laravel/framework/pull/22851))
- Added boolean toggle to `withTrashed()` ([#22888](https://github.com/laravel/framework/pull/22888))

### Changed
- Support Mix HMR with different host/port ([#22826](https://github.com/laravel/framework/pull/22826), [24897d6](https://github.com/laravel/framework/commit/24897d6afbfed70a7383561f31c01bc48927cbda))
- Make route filtering by method case-insensitive ([#22856](https://github.com/laravel/framework/pull/22856))
- Added missing PostgreSQL operator for array overlap ([#22903](https://github.com/laravel/framework/pull/22903))


## v5.5.32 (2018-01-18)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected function getPayload($key)
{
$path = $this->path($key);

// If the file doesn't exists, we obviously can't return the cache so we will
// If the file doesn't exist, we obviously cannot return the cache so we will
// just return null. Otherwise, we'll get the contents of the file and get
// the expiration UNIX timestamps from the start of the file's contents.
try {
Expand Down
6 changes: 5 additions & 1 deletion src/Illuminate/Database/Eloquent/SoftDeletingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ protected function addRestore(Builder $builder)
*/
protected function addWithTrashed(Builder $builder)
{
$builder->macro('withTrashed', function (Builder $builder) {
$builder->macro('withTrashed', function (Builder $builder, $withTrashed = true) {
if (! $withTrashed) {
return $builder->withoutTrashed();
}

return $builder->withoutGlobalScope($this);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PostgresGrammar extends Grammar
'=', '<', '>', '<=', '>=', '<>', '!=',
'like', 'not like', 'ilike',
'&', '|', '#', '<<', '>>', '>>=', '=<<',
'@>', '<@', '?', '?|', '?&', '||', '-', '-', '#-',
'&&', '@>', '<@', '?', '?|', '?&', '||', '-', '-', '#-',
];

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ public function testWithTrashedReturnsAllRecords()
$this->assertInstanceOf(Eloquent::class, SoftDeletesTestUser::withTrashed()->find(1));
}

public function testWithTrashedAcceptsAnArgument()
{
$this->createUsers();

$this->assertCount(1, SoftDeletesTestUser::withTrashed(false)->get());
$this->assertCount(2, SoftDeletesTestUser::withTrashed(true)->get());
}

public function testDeleteSetsDeletedColumn()
{
$this->createUsers();
Expand Down
105 changes: 102 additions & 3 deletions tests/Filesystem/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@
use League\Flysystem\Adapter\Local;
use Illuminate\Filesystem\FilesystemAdapter;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Illuminate\Contracts\Filesystem\FileNotFoundException;

class FilesystemAdapterTest extends TestCase
{
private $tempDir;
private $filesystem;

public function setUp()
{
$this->filesystem = new Filesystem(new Local(__DIR__.'/tmp'));
$this->tempDir = __DIR__.'/tmp';
$this->filesystem = new Filesystem(new Local($this->tempDir));
}

public function tearDown()
{
$filesystem = new Filesystem(new Local(__DIR__));
$filesystem->deleteDir('tmp');
$filesystem = new Filesystem(new Local(dirname($this->tempDir)));
$filesystem->deleteDir(basename($this->tempDir));
}

public function testResponse()
Expand All @@ -46,4 +49,100 @@ public function testDownload()
$this->assertInstanceOf(StreamedResponse::class, $response);
$this->assertEquals('attachment; filename="hello.txt"', $response->headers->get('content-disposition'));
}

public function testExists()
{
$this->filesystem->write('file.txt', 'Hello World');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$this->assertTrue($filesystemAdapter->exists('file.txt'));
}

public function testPath()
{
$this->filesystem->write('file.txt', 'Hello World');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$this->assertEquals($this->tempDir.'/file.txt', $filesystemAdapter->path('file.txt'));
}

public function testGet()
{
$this->filesystem->write('file.txt', 'Hello World');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$this->assertEquals('Hello World', $filesystemAdapter->get('file.txt'));
}

public function testGetFileNotFound()
{
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$this->expectException(FileNotFoundException::class);
$filesystemAdapter->get('file.txt');
}

public function testPut()
{
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$filesystemAdapter->put('file.txt', 'Something inside');
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Something inside');
}

public function testPrepend()
{
file_put_contents($this->tempDir.'/file.txt', 'World');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$filesystemAdapter->prepend('file.txt', 'Hello ');
$this->assertStringEqualsFile($this->tempDir.'/file.txt', "Hello \nWorld");
}

public function testAppend()
{
file_put_contents($this->tempDir.'/file.txt', 'Hello ');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$filesystemAdapter->append('file.txt', 'Moon');
$this->assertStringEqualsFile($this->tempDir.'/file.txt', "Hello \nMoon");
}

public function testDelete()
{
file_put_contents($this->tempDir.'/file.txt', 'Hello World');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$this->assertTrue($filesystemAdapter->delete('file.txt'));
$this->assertFalse(file_exists($this->tempDir.'/file.txt'));
}

public function testDeleteReturnsFalseWhenFileNotFound()
{
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$this->assertFalse($filesystemAdapter->delete('file.txt'));
}

public function testCopy()
{
$data = '33232';
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/foo.txt', $data);

$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$filesystemAdapter->copy('/foo/foo.txt', '/foo/foo2.txt');

$this->assertFileExists($this->tempDir.'/foo/foo.txt');
$this->assertEquals($data, file_get_contents($this->tempDir.'/foo/foo.txt'));

$this->assertFileExists($this->tempDir.'/foo/foo2.txt');
$this->assertEquals($data, file_get_contents($this->tempDir.'/foo/foo2.txt'));
}

public function testMove()
{
$data = '33232';
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/foo.txt', $data);

$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$filesystemAdapter->move('/foo/foo.txt', '/foo/foo2.txt');

$this->assertFileNotExists($this->tempDir.'/foo/foo.txt');

$this->assertFileExists($this->tempDir.'/foo/foo2.txt');
$this->assertEquals($data, file_get_contents($this->tempDir.'/foo/foo2.txt'));
}
}
36 changes: 36 additions & 0 deletions tests/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Filesystem;

use Mockery as m;
use PHPUnit\Framework\TestCase;
use League\Flysystem\Adapter\Ftp;
use Illuminate\Filesystem\Filesystem;
Expand All @@ -20,6 +21,8 @@ public function setUp()

public function tearDown()
{
m::close();

$files = new Filesystem;
$files->deleteDirectory($this->tempDir);
}
Expand Down Expand Up @@ -97,6 +100,14 @@ public function testDeleteDirectory()
$this->assertFileNotExists($this->tempDir.'/foo/file.txt');
}

public function testDeleteDirectoryReturnFalseWhenNotADirectory()
{
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/file.txt', 'Hello World');
$files = new Filesystem;
$this->assertFalse($files->deleteDirectory($this->tempDir.'/foo/file.txt'));
}

public function testCleanDirectory()
{
mkdir($this->tempDir.'/foo');
Expand Down Expand Up @@ -195,6 +206,17 @@ public function testMoveDirectoryMovesEntireDirectoryAndOverwrites()
$this->assertDirectoryNotExists($this->tempDir.'/tmp');
}

public function testMoveDirectoryReturnsFalseWhileOverwritingAndUnableToDeleteDestinationDirectory()
{
mkdir($this->tempDir.'/tmp', 0777, true);
file_put_contents($this->tempDir.'/tmp/foo.txt', '');
mkdir($this->tempDir.'/tmp2', 0777, true);

$files = m::mock(Filesystem::class)->makePartial();
$files->shouldReceive('deleteDirectory')->once()->andReturn(false);
$this->assertFalse($files->moveDirectory($this->tempDir.'/tmp', $this->tempDir.'/tmp2', true));
}

/**
* @expectedException \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
Expand Down Expand Up @@ -239,6 +261,13 @@ public function testMoveMovesFiles()
$this->assertFileNotExists($this->tempDir.'/foo.txt');
}

public function testNameReturnsName()
{
file_put_contents($this->tempDir.'/foobar.txt', 'foo');
$filesystem = new Filesystem;
$this->assertEquals('foobar', $filesystem->name($this->tempDir.'/foobar.txt'));
}

public function testExtensionReturnsExtension()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
Expand Down Expand Up @@ -462,4 +491,11 @@ public function testCreateFtpDriver()
$this->assertEquals('ftp.example.com', $adapter->getHost());
$this->assertEquals('admin', $adapter->getUsername());
}

public function testHash()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
$filesystem = new Filesystem;
$this->assertEquals('acbd18db4cc2f85cedef654fccc4a4d8', $filesystem->hash($this->tempDir.'/foo.txt'));
}
}
9 changes: 7 additions & 2 deletions tests/Foundation/FoundationTestResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ public function testAssertJsonCount()
$response->assertJsonCount(3, 'bars');

// With nested key
$response->assertJsonCount(2, 'baz.*.bar');
$response->assertJsonCount(1, 'barfoo.0.bar');
$response->assertJsonCount(3, 'barfoo.2.bar');

// Without structure
$response = TestResponse::fromBaseResponse(new Response(new JsonSerializableSingleResourceStub));

$response->assertJsonCount(4);
}

Expand Down Expand Up @@ -266,6 +266,11 @@ public function jsonSerialize()
['foo' => 'bar 0', 'bar' => ['foo' => 'bar 0', 'bar' => 'foo 0']],
['foo' => 'bar 1', 'bar' => ['foo' => 'bar 1', 'bar' => 'foo 1']],
],
'barfoo' => [
['bar' => ['bar' => 'foo 0']],
['bar' => ['bar' => 'foo 0', 'bar' => 'foo 0']],
['bar' => ['foo' => 'bar 0', 'bar' => 'foo 0', 'rab' => 'rab 0']],
],
];
}
}
Expand Down
29 changes: 29 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,12 @@ public function testExcept()
$this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->except('last')->all());
}

public function testExceptSelf()
{
$data = new Collection(['first' => 'Taylor', 'last' => 'Otwell']);
$this->assertEquals(['first' => 'Taylor', 'last' => 'Otwell'], $data->except($data)->all());
}

public function testPluckWithArrayAndObjectValues()
{
$data = new Collection([(object) ['name' => 'taylor', 'email' => 'foo'], ['name' => 'dayle', 'email' => 'bar']]);
Expand All @@ -1018,6 +1024,15 @@ public function testPluckWithArrayAccessValues()
$this->assertEquals(['foo', 'bar'], $data->pluck('email')->all());
}

public function testHas()
{
$data = new Collection(['id' => 1, 'first' => 'Hello', 'second' => 'World']);
$this->assertTrue($data->has('first'));
$this->assertFalse($data->has('third'));
$this->assertTrue($data->has(['first', 'second']));
$this->assertFalse($data->has(['third', 'first']));
}

public function testImplode()
{
$data = new Collection([['name' => 'taylor', 'email' => 'foo'], ['name' => 'dayle', 'email' => 'bar']]);
Expand All @@ -1036,6 +1051,20 @@ public function testTake()
$this->assertEquals(['taylor', 'dayle'], $data->all());
}

public function testPut()
{
$data = new Collection(['name' => 'taylor', 'email' => 'foo']);
$data = $data->put('name', 'dayle');
$this->assertEquals(['name' => 'dayle', 'email' => 'foo'], $data->all());
}

public function testPutWithNoKey()
{
$data = new Collection(['taylor', 'shawn']);
$data = $data->put(null, 'dayle');
$this->assertEquals(['taylor', 'shawn', 'dayle'], $data->all());
}

public function testRandom()
{
$data = new Collection([1, 2, 3, 4, 5, 6]);
Expand Down
Loading

0 comments on commit 4204c8a

Please sign in to comment.