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 Feb 28, 2018
2 parents 816f893 + 9ac4664 commit 55e44f7
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 3 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG-5.6.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Release Notes for 5.6.x

## [Unreleased]

### Added
- Added SFTP filesystem driver ([#23308](https://github.com/laravel/framework/pull/23308))

### Fixed
- Fixed `PostgresGrammar::whereTime()` casting ([#23323](https://github.com/laravel/framework/pull/23323))
- Fixed `SQLiteGrammar::whereTime()` correct ([#23321](https://github.com/laravel/framework/pull/23321))


## v5.6.6 (2018-02-27)

### Added
- Added `sortKeys()` and `sortKeysDesc()` methods to `Collection` ([#23286](https://github.com/laravel/framework/pull/23286))

### Changed
- Return `null` from `optional()` helper if object property is undefined ([#23267](https://github.com/laravel/framework/pull/23267))
- Cache event wildcard listeners ([#23299](https://github.com/laravel/framework/pull/23299), [82099cb](https://github.com/laravel/framework/commit/82099cb3fdfe79f3f4f17008daf169f13fefffc0))
- Changed `morphs()` and `nullableMorphs()` to use `unsignedBigInteger()` ([#23320](https://github.com/laravel/framework/pull/23320))

### Fixed
- Prevent delayed jobs in v5.5 fail to run in v5.6 ([#23287](https://github.com/laravel/framework/pull/23287))
- `Queue::bulk()` fake now properly pushes expected jobs ([#23294](https://github.com/laravel/framework/pull/23294))
- Fixed the list of packages removed when the "none" preset is installed ([#23305](https://github.com/laravel/framework/pull/23305))
- Fixed an issue with `orHaving()` arguments ([e7f13be](https://github.com/laravel/framework/commit/e7f13be6a5dd8c348243a5f5dce488359160937c))


## v5.6.5 (2018-02-22)

### Added
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).",
"league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0).",
"league/flysystem-cached-adapter": "Required to use Flysystem caching (~1.0).",
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (~1.0).",
"nexmo/client": "Required to use the Nexmo transport (~1.0).",
"pda/pheanstalk": "Required to use the beanstalk queue driver (~3.0).",
"predis/predis": "Required to use the redis cache and queue drivers (~1.0).",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function getDefaultFor(Model $parent)
$instance = $this->newRelatedInstanceFor($parent);

if (is_callable($this->withDefault)) {
return call_user_func($this->withDefault, $instance) ?: $instance;
return call_user_func($this->withDefault, $instance, $parent) ?: $instance;
}

if (is_array($this->withDefault)) {
Expand Down
14 changes: 14 additions & 0 deletions src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ protected function whereDate(Builder $query, $where)
return $this->wrap($where['column']).'::date '.$where['operator'].' '.$value;
}

/**
* Compile a "where time" clause.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereTime(Builder $query, $where)
{
$value = $this->parameter($where['value']);

return $this->wrap($where['column']).'::time '.$where['operator'].' '.$value;
}

/**
* Compile a date based where clause.
*
Expand Down
12 changes: 12 additions & 0 deletions src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ protected function whereYear(Builder $query, $where)
return $this->dateBasedWhere('%Y', $query, $where);
}

/**
* Compile a "where time" clause.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereTime(Builder $query, $where)
{
return $this->dateBasedWhere('%H:%M:%S', $query, $where);
}

/**
* Compile a date based where clause.
*
Expand Down
14 changes: 14 additions & 0 deletions src/Illuminate/Filesystem/FilesystemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Arr;
use InvalidArgumentException;
use League\Flysystem\AdapterInterface;
use League\Flysystem\Sftp\SftpAdapter;
use League\Flysystem\FilesystemInterface;
use League\Flysystem\Cached\CachedAdapter;
use League\Flysystem\Filesystem as Flysystem;
Expand Down Expand Up @@ -176,6 +177,19 @@ public function createFtpDriver(array $config)
));
}

/**
* Create an instance of the sftp driver.
*
* @param array $config
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function createSftpDriver(array $config)
{
return $this->adapt($this->createFlysystem(
new SftpAdapter($config), $config
));
}

/**
* Create an instance of the Amazon S3 driver.
*
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Filesystem/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"suggest": {
"league/flysystem": "Required to use the Flysystem local and FTP drivers (~1.0).",
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).",
"league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0)."
"league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0).",
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (~1.0)."
},
"config": {
"sort-packages": true
Expand Down
20 changes: 20 additions & 0 deletions tests/Database/DatabaseEloquentHasOneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ public function testHasOneWithDynamicDefault()
$this->assertSame(1, $newModel->getAttribute('foreign_key'));
}

public function testHasOneWithDynamicDefaultUseParentModel()
{
$relation = $this->getRelation()->withDefault(function ($newModel, $parentModel) {
$newModel->username = $parentModel->username;
});

$this->builder->shouldReceive('first')->once()->andReturnNull();

$newModel = new EloquentHasOneModelStub;

$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);

$this->assertSame($newModel, $relation->getResults());

$this->assertSame('taylor', $newModel->username);

$this->assertSame(1, $newModel->getAttribute('foreign_key'));
}

public function testHasOneWithArrayDefault()
{
$attributes = ['username' => 'taylor'];
Expand Down Expand Up @@ -191,6 +210,7 @@ protected function getRelation()
$this->builder->shouldReceive('getModel')->andReturn($this->related);
$this->parent = m::mock('Illuminate\Database\Eloquent\Model');
$this->parent->shouldReceive('getAttribute')->with('id')->andReturn(1);
$this->parent->shouldReceive('getAttribute')->with('username')->andReturn('taylor');
$this->parent->shouldReceive('getCreatedAtColumn')->andReturn('created_at');
$this->parent->shouldReceive('getUpdatedAtColumn')->andReturn('updated_at');
$this->parent->shouldReceive('newQueryWithoutScopes')->andReturn($this->builder);
Expand Down
26 changes: 25 additions & 1 deletion tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,19 @@ public function testWhereTimeOperatorOptionalMySql()
$this->assertEquals([0 => '22:00'], $builder->getBindings());
}

public function testWhereTimePostgres()
{
$builder = $this->getPostgresBuilder();
$builder->select('*')->from('users')->whereTime('created_at', '>=', '22:00');
$this->assertEquals('select * from "users" where "created_at"::time >= ?', $builder->toSql());
$this->assertEquals([0 => '22:00'], $builder->getBindings());
}

public function testWhereTimeOperatorOptionalPostgres()
{
$builder = $this->getPostgresBuilder();
$builder->select('*')->from('users')->whereTime('created_at', '22:00');
$this->assertEquals('select * from "users" where extract(time from "created_at") = ?', $builder->toSql());
$this->assertEquals('select * from "users" where "created_at"::time = ?', $builder->toSql());
$this->assertEquals([0 => '22:00'], $builder->getBindings());
}

Expand Down Expand Up @@ -404,6 +412,22 @@ public function testWhereYearSqlite()
$this->assertEquals([0 => 2014], $builder->getBindings());
}

public function testWhereTimeSqlite()
{
$builder = $this->getSQLiteBuilder();
$builder->select('*')->from('users')->whereTime('created_at', '>=', '22:00');
$this->assertEquals('select * from "users" where strftime(\'%H:%M:%S\', "created_at") >= ?', $builder->toSql());
$this->assertEquals([0 => '22:00'], $builder->getBindings());
}

public function testWhereTimeOperatorOptionalSqlite()
{
$builder = $this->getSQLiteBuilder();
$builder->select('*')->from('users')->whereTime('created_at', '22:00');
$this->assertEquals('select * from "users" where strftime(\'%H:%M:%S\', "created_at") = ?', $builder->toSql());
$this->assertEquals([0 => '22:00'], $builder->getBindings());
}

public function testWhereDaySqlServer()
{
$builder = $this->getSqlServerBuilder();
Expand Down
10 changes: 10 additions & 0 deletions tests/Translation/TranslationTranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public function testGetMethodProperlyLoadsAndRetrievesItemWithLongestReplacement
$this->assertEquals('foo', $t->get('foo::bar.foo'));
}

public function testGetMethodProperlyLoadsAndRetrievesItemForFallback()
{
$t = new \Illuminate\Translation\Translator($this->getLoader(), 'en');
$t->setFallback('lv');
$t->getLoader()->shouldReceive('load')->once()->with('en', 'bar', 'foo')->andReturn([]);
$t->getLoader()->shouldReceive('load')->once()->with('lv', 'bar', 'foo')->andReturn(['foo' => 'foo', 'baz' => 'breeze :foo']);
$this->assertEquals('breeze bar', $t->get('foo::bar.baz', ['foo' => 'bar'], 'en'));
$this->assertEquals('foo', $t->get('foo::bar.foo'));
}

public function testGetMethodProperlyLoadsAndRetrievesItemForGlobalNamespace()
{
$t = new \Illuminate\Translation\Translator($this->getLoader(), 'en');
Expand Down

0 comments on commit 55e44f7

Please sign in to comment.