This repository has been archived by the owner on Jul 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from algolia/5.4-compatibility
fix(5.4) : make compatible with Laravel 5.4
- Loading branch information
Showing
2 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace AlgoliaSearch\Tests; | ||
|
||
use AlgoliaSearch\Laravel\EloquentSubscriber; | ||
use AlgoliaSearch\Tests\Models\Model1; | ||
|
||
|
||
class EloquentSubscriberTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $modelHelper; | ||
|
||
/** | ||
* @var EloquentSubscriber | ||
*/ | ||
private $eloquentSubscriber; | ||
|
||
protected function setUp() | ||
{ | ||
$this->modelHelper = $this->getMockBuilder('AlgoliaSearch\Laravel\ModelHelper')->disableOriginalConstructor()->getMock(); | ||
$this->eloquentSubscriber = new EloquentSubscriber($this->modelHelper); | ||
} | ||
|
||
/** | ||
* @dataProvider listenerDataProvider | ||
*/ | ||
public function testSkipSyncOnSaveIfAutoSyncDisabled($eventName, $payload) | ||
{ | ||
$this->modelHelper->expects($this->once()) | ||
->method('isAutoIndex') | ||
->with(new Model1()) | ||
->willReturn(false); | ||
|
||
$this->eloquentSubscriber->saved($eventName, $payload); | ||
} | ||
|
||
/** | ||
* @dataProvider listenerDataProvider | ||
*/ | ||
public function testSkipSyncOnDeleteIfAutoSyncDisabled($eventName, $payload) | ||
{ | ||
$this->modelHelper->expects($this->once()) | ||
->method('isAutoDelete') | ||
->with(new Model1()) | ||
->willReturn(false); | ||
|
||
$this->eloquentSubscriber->deleted($eventName, $payload); | ||
} | ||
|
||
public function listenerDataProvider() | ||
{ | ||
return [ | ||
[new Model1(), null], // Laravel 5.3 | ||
['eloquent.event', [new Model1()]], // Laravel 5.4 | ||
]; | ||
} | ||
|
||
|
||
|
||
} |