Skip to content

Commit

Permalink
Merge pull request #31 from pmatseykanets/support-laravel6
Browse files Browse the repository at this point in the history
Support Laravel 6
  • Loading branch information
pmatseykanets authored Sep 19, 2019
2 parents 104fa78 + b373a25 commit 3dadccc
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 90 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
composer.lock
.phpunit.result.cache
composer.lock
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.1
- 7.2
- 7.3

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [6.0.0](https://github.com/pmatseykanets/laravel-scout-postgres/releases/tag/v6.0.0) - 2019-09-19

### Added

- Added support for Laravel 6

## [5.0.0](https://github.com/pmatseykanets/laravel-scout-postgres/releases/tag/v5.0.0) - 2019-03-13

### Added
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
}
],
"require": {
"php": ">=7.0",
"illuminate/contracts": "~5.4",
"illuminate/database": "~5.4",
"illuminate/support": "~5.4",
"php": "^7.2",
"illuminate/contracts": "~5.4|~6.0",
"illuminate/database": "~5.4|~6.0",
"illuminate/support": "~5.4|~6.0",
"laravel/scout": "~7.0"
},
"require-dev": {
"phpunit/phpunit": "~6.0",
"mockery/mockery": "~1.0"
"phpunit/phpunit": "^8.3",
"mockery/mockery": "^1.2.3"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 4 additions & 3 deletions src/PostgresEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ScoutEngines\Postgres;

use Laravel\Scout\Builder;
use Illuminate\Support\Arr;
use Laravel\Scout\Engines\Engine;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
Expand Down Expand Up @@ -200,7 +201,7 @@ public function getTotalCount($results)
return 0;
}

return (int) array_first($results)
return (int) Arr::first($results)
->total_count;
}

Expand Down Expand Up @@ -497,7 +498,7 @@ protected function option(Model $model, $key, $default = null)

$options = $model->searchableOptions() ?: [];

return array_get($options, $key, $default);
return Arr::get($options, $key, $default);
}

/**
Expand All @@ -509,7 +510,7 @@ protected function option(Model $model, $key, $default = null)
*/
protected function config($key, $default = null)
{
return array_get($this->config, $key, $default);
return Arr::get($this->config, $key, $default);
}

/**
Expand Down
62 changes: 0 additions & 62 deletions tests/PostgresEngineServiceProviderTest.php

This file was deleted.

32 changes: 16 additions & 16 deletions tests/PostgresEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class PostgresEngineTest extends TestCase
{
public function test_it_can_be_instantiated()
{
list($engine) = $this->getEngine();
[$engine] = $this->getEngine();

$this->assertInstanceOf(PostgresEngine::class, $engine);
}

public function test_update_adds_object_to_index()
{
list($engine, $db) = $this->getEngine();
[$engine, $db] = $this->getEngine();

$db->shouldReceive('query')
->andReturn($query = Mockery::mock('stdClass'));
Expand Down Expand Up @@ -50,14 +50,14 @@ public function test_update_adds_object_to_index()

public function test_update_do_nothing_if_index_maintenance_turned_off_globally()
{
list($engine) = $this->getEngine(['maintain_index' => false]);
[$engine] = $this->getEngine(['maintain_index' => false]);

$engine->update(Collection::make([new TestModel()]));
}

public function test_delete_removes_object_from_index()
{
list($engine, $db) = $this->getEngine();
[$engine, $db] = $this->getEngine();

$db->shouldReceive('table')
->andReturn($table = Mockery::mock('stdClass'));
Expand All @@ -72,7 +72,7 @@ public function test_delete_removes_object_from_index()

public function test_delete_do_nothing_if_index_maintenance_turned_off_globally()
{
list($engine, $db) = $this->getEngine(['maintain_index' => false]);
[$engine, $db] = $this->getEngine(['maintain_index' => false]);

$db->shouldNotReceive('table');

Expand All @@ -81,7 +81,7 @@ public function test_delete_do_nothing_if_index_maintenance_turned_off_globally(

public function test_flush_removes_all_objects_from_index()
{
list($engine, $db) = $this->getEngine();
[$engine, $db] = $this->getEngine();

$db->shouldReceive('table')
->once()
Expand All @@ -95,7 +95,7 @@ public function test_flush_removes_all_objects_from_index()

public function test_flush_does_nothing_if_index_maintenance_turned_off_globally()
{
list($engine, $db) = $this->getEngine(['maintain_index' => false]);
[$engine, $db] = $this->getEngine(['maintain_index' => false]);

$db->shouldNotReceive('table');

Expand All @@ -104,7 +104,7 @@ public function test_flush_does_nothing_if_index_maintenance_turned_off_globally

public function test_search()
{
list($engine, $db) = $this->getEngine();
[$engine, $db] = $this->getEngine();

$skip = 0;
$limit = 5;
Expand All @@ -129,7 +129,7 @@ public function test_search()

public function test_search_with_order_by()
{
list($engine, $db) = $this->getEngine();
[$engine, $db] = $this->getEngine();

$table = $this->setDbExpectations($db, false);

Expand All @@ -149,7 +149,7 @@ public function test_search_with_order_by()

public function test_search_with_global_config()
{
list($engine, $db) = $this->getEngine(['config' => 'simple']);
[$engine, $db] = $this->getEngine(['config' => 'simple']);

$skip = 0;
$limit = 5;
Expand All @@ -170,7 +170,7 @@ public function test_search_with_global_config()

public function test_search_with_model_config()
{
list($engine, $db) = $this->getEngine(['config' => 'simple']);
[$engine, $db] = $this->getEngine(['config' => 'simple']);

$skip = 0;
$limit = 5;
Expand All @@ -194,7 +194,7 @@ public function test_search_with_model_config()

public function test_search_with_soft_deletes()
{
list($engine, $db) = $this->getEngine();
[$engine, $db] = $this->getEngine();

$table = $this->setDbExpectations($db);

Expand All @@ -214,7 +214,7 @@ public function test_search_with_soft_deletes()

public function test_maps_results_to_models()
{
list($engine) = $this->getEngine();
[$engine] = $this->getEngine();

$model = Mockery::mock('StdClass');
$model->shouldReceive('getKeyName')->andReturn('id');
Expand All @@ -232,7 +232,7 @@ public function test_maps_results_to_models()

public function test_map_filters_out_no_longer_existing_models()
{
list($engine) = $this->getEngine();
[$engine] = $this->getEngine();

$model = Mockery::mock('StdClass');
$model->shouldReceive('getKeyName')->andReturn('id');
Expand All @@ -255,7 +255,7 @@ public function test_map_filters_out_no_longer_existing_models()

public function test_it_returns_total_count()
{
list($engine) = $this->getEngine();
[$engine] = $this->getEngine();

$count = $engine->getTotalCount(
json_decode('[{"id": 1, "tsrank": 0.33, "total_count": 100}]')
Expand All @@ -266,7 +266,7 @@ public function test_it_returns_total_count()

public function test_map_ids_returns_right_key()
{
list($engine, $db) = $this->getEngine();
[$engine, $db] = $this->getEngine();

$table = $this->setDbExpectations($db);
$table->shouldReceive('getBindings')->andReturn([null, 'foo']);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

abstract class TestCase extends BaseTestCase
{
public function tearDown()
public function tearDown(): void
{
// Prevent PHPUnit complaining about risky tests
// because Mockery expectations are not counted towards assertions
Expand Down

0 comments on commit 3dadccc

Please sign in to comment.