Skip to content
This repository was archived by the owner on Jul 31, 2018. It is now read-only.

Commit c359a99

Browse files
committed
test(5.3 compatibility) : test the compatibility with 5.3 and 5.4
1 parent e0c810e commit c359a99

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/EloquentSubscriberTest.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace AlgoliaSearch\Tests;
4+
5+
use AlgoliaSearch\Laravel\EloquentSubscriber;
6+
use AlgoliaSearch\Tests\Models\Model1;
7+
8+
9+
class EloquentSubscriberTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* @var \PHPUnit_Framework_MockObject_MockObject
13+
*/
14+
private $modelHelper;
15+
16+
/**
17+
* @var EloquentSubscriber
18+
*/
19+
private $eloquentSubscriber;
20+
21+
protected function setUp()
22+
{
23+
$this->modelHelper = $this->getMockBuilder('AlgoliaSearch\Laravel\ModelHelper')->disableOriginalConstructor()->getMock();
24+
$this->eloquentSubscriber = new EloquentSubscriber($this->modelHelper);
25+
}
26+
27+
/**
28+
* @dataProvider listenerDataProvider
29+
*/
30+
public function testSkipSyncOnSaveIfAutoSyncDisabled($eventName, $payload)
31+
{
32+
$this->modelHelper->expects($this->once())
33+
->method('isAutoIndex')
34+
->with(new Model1())
35+
->willReturn(false);
36+
37+
$this->eloquentSubscriber->saved($eventName, $payload);
38+
}
39+
40+
/**
41+
* @dataProvider listenerDataProvider
42+
*/
43+
public function testSkipSyncOnDeleteIfAutoSyncDisabled($eventName, $payload)
44+
{
45+
$this->modelHelper->expects($this->once())
46+
->method('isAutoDelete')
47+
->with(new Model1())
48+
->willReturn(false);
49+
50+
$this->eloquentSubscriber->deleted($eventName, $payload);
51+
}
52+
53+
public function listenerDataProvider()
54+
{
55+
return [
56+
[new Model1(), null], // Laravel 5.3
57+
['eloquent.event', [new Model1()]], // Laravel 5.4
58+
];
59+
}
60+
61+
62+
63+
}

0 commit comments

Comments
 (0)