Skip to content
This repository was archived by the owner on Feb 17, 2022. It is now read-only.

Commit dcd1ca9

Browse files
Merge pull request #6 from DarkGhostHunter/master
Laravel 5.8 compatibility
2 parents 279707c + cf5ba08 commit dcd1ca9

File tree

10 files changed

+59
-56
lines changed

10 files changed

+59
-56
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ Keep your forms alive, avoid `TokenMismatchException` by gently poking your Lara
1212
## Requirements
1313

1414
* PHP >= 7.1.3
15-
* Laravel 5.7
15+
* Laravel 5.8
16+
17+
> Check older releases for older Laravel versions.
1618
1719
## Installation
1820

@@ -46,8 +48,8 @@ LARAPOKE_MODE=auto
4648

4749
Just install this package and *look at it go*. This will push a global middleware that will look into all your Responses content where:
4850

49-
a) an input where `csrf` token is present, or
50-
b) a header where `csrf-token` is present.
51+
* an input where `csrf` token is present, or
52+
* a header where `csrf-token` is present.
5153

5254
If there is any match, this will inject the Larapoke script, that will be in charge to keep the forms alive, just before the `</body>` tag.
5355

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "darkghosthunter/larapoke",
33
"description": "Keep your forms alive, avoid TokenMismatchException by gently poking your Laravel app",
4-
"minimum-stability": "stable",
4+
"minimum-stability": "dev",
5+
"prefer-stable": true,
56
"license": "MIT",
67
"authors": [
78
{
@@ -11,15 +12,14 @@
1112
],
1213
"require": {
1314
"php": ">=7.1.3",
14-
"illuminate/routing": "5.7.*",
15-
"illuminate/support": "5.7.*",
16-
"illuminate/view": "5.7.*",
17-
"illuminate/http": "5.7.*"
15+
"illuminate/routing": "5.8.*",
16+
"illuminate/support": "5.8.*",
17+
"illuminate/view": "5.8.*",
18+
"illuminate/http": "5.8.*"
1819
},
1920
"require-dev": {
2021
"mockery/mockery": "1.2.*",
21-
"orchestra/testbench": "3.7.*",
22-
"orchestra/testbench-dusk": "3.7.x@dev"
22+
"orchestra/testbench": "3.8.*"
2323
},
2424
"autoload-dev": {
2525
"psr-4": {

tests/Browser/BrowserScriptTest.php renamed to tests/Browser/BrowserScriptTest.php.skip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ protected function getPackageProviders($app)
1717

1818
protected function getEnvironmentSetUp($app)
1919
{
20-
2120
$this->app = $app;
2221

2322
$app['config']->set('session.lifetime', 1);
@@ -60,6 +59,8 @@ protected function recurseRmdir($dir) {
6059

6160
public function testPokeWorks()
6261
{
62+
$this->markTestSkipped('Until Orchestra Testbench for Laravel Dusk is updated, we cannot do browser tests');
63+
6364
$this->browse(function ($first, $second) {
6465
/** @var \Laravel\Dusk\Browser $first */
6566
$first->visit('/register')

tests/Unit/LarapokeServiceProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testLoadDefaultView()
8585
->render();
8686

8787
$this->assertIsString($script);
88-
$this->assertContains('larapoke_', $script);
88+
$this->assertStringContainsString('larapoke_', $script);
8989
}
9090

9191
public function testRegistersGlobalMiddleware()

tests/Unit/Modes/ModeAutoTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function getEnvironmentSetUp($app)
3131
$this->app = null;
3232
}
3333

34-
protected function setUp()
34+
protected function setUp() : void
3535
{
3636
parent::setUp();
3737

@@ -126,7 +126,7 @@ protected function viewWithNothing()
126126
');
127127
}
128128

129-
protected function tearDown()
129+
protected function tearDown() : void
130130
{
131131
parent::tearDown();
132132

@@ -145,37 +145,37 @@ protected function recurseRmdir($dir) {
145145
public function testDoesntInjectsOnJson()
146146
{
147147
$response = $this->get('/json');
148-
$this->assertNotContains('start-larapoke-script', $response->content());
149-
$this->assertNotContains('end-larapoke-script', $response->content());
148+
$this->assertStringNotContainsString('start-larapoke-script', $response->content());
149+
$this->assertStringNotContainsString('end-larapoke-script', $response->content());
150150
}
151151

152152
public function testInjectsScriptOnFormWithHeader()
153153
{
154154
$response = $this->get('/register');
155155

156-
$this->assertContains('start-larapoke-script', $response->content());
157-
$this->assertContains('end-larapoke-script', $response->content());
156+
$this->assertStringContainsString('start-larapoke-script', $response->content());
157+
$this->assertStringContainsString('end-larapoke-script', $response->content());
158158
}
159159

160160
public function testInjectsScriptOnForm()
161161
{
162162
$response = $this->get('/form-only');
163-
$this->assertContains('start-larapoke-script', $response->content());
164-
$this->assertContains('end-larapoke-script', $response->content());
163+
$this->assertStringContainsString('start-larapoke-script', $response->content());
164+
$this->assertStringContainsString('end-larapoke-script', $response->content());
165165
}
166166

167167
public function testInjectsScriptOnHeader()
168168
{
169169
$response = $this->get('/header-only');
170-
$this->assertContains('start-larapoke-script', $response->content());
171-
$this->assertContains('end-larapoke-script', $response->content());
170+
$this->assertStringContainsString('start-larapoke-script', $response->content());
171+
$this->assertStringContainsString('end-larapoke-script', $response->content());
172172
}
173173

174174
public function testInjectsScriptOnNothing()
175175
{
176176
$response = $this->get('/nothing');
177-
$this->assertNotContains('start-larapoke-script', $response->content());
178-
$this->assertNotContains('end-larapoke-script', $response->content());
177+
$this->assertStringNotContainsString('start-larapoke-script', $response->content());
178+
$this->assertStringNotContainsString('end-larapoke-script', $response->content());
179179
}
180180

181181
}

tests/Unit/Modes/ModeBladeTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function getEnvironmentSetUp($app)
2828
$this->app = null;
2929
}
3030

31-
protected function setUp()
31+
protected function setUp() : void
3232
{
3333
parent::setUp();
3434

@@ -125,7 +125,7 @@ protected function viewWithNothing()
125125
');
126126
}
127127

128-
protected function tearDown()
128+
protected function tearDown() : void
129129
{
130130
parent::tearDown();
131131

@@ -144,23 +144,23 @@ protected function recurseRmdir($dir) {
144144
public function testNoScriptOnRouteWithoutMiddleware()
145145
{
146146
$response = $this->get('/register');
147-
$this->assertNotContains('start-larapoke-script', $response->content());
148-
$this->assertNotContains('end-larapoke-script', $response->content());
147+
$this->assertStringNotContainsString('start-larapoke-script', $response->content());
148+
$this->assertStringNotContainsString('end-larapoke-script', $response->content());
149149
}
150150

151151
public function testInjectsScriptOnForm()
152152
{
153153
$response = $this->get('/form-only');
154-
$this->assertContains('start-larapoke-script', $response->content());
155-
$this->assertContains('end-larapoke-script', $response->content());
154+
$this->assertStringContainsString('start-larapoke-script', $response->content());
155+
$this->assertStringContainsString('end-larapoke-script', $response->content());
156156
}
157157

158158
public function testInjectsOnceOnMultipleForms()
159159
{
160160
$response = $this->get('/multiple-form');
161161

162-
$this->assertContains('start-larapoke-script', $response->content());
163-
$this->assertContains('end-larapoke-script', $response->content());
162+
$this->assertStringContainsString('start-larapoke-script', $response->content());
163+
$this->assertStringContainsString('end-larapoke-script', $response->content());
164164

165165
$this->assertTrue(substr_count($response->content(), 'start-larapoke-script') === 1);
166166
$this->assertTrue(substr_count($response->content(), 'end-larapoke-script') === 1);
@@ -170,8 +170,8 @@ public function testInjectsOnceOnMiddlewareAndMultipleForms()
170170
{
171171
$response = $this->get('/multiple-form-with-middleware');
172172

173-
$this->assertContains('start-larapoke-script', $response->content());
174-
$this->assertContains('end-larapoke-script', $response->content());
173+
$this->assertStringContainsString('start-larapoke-script', $response->content());
174+
$this->assertStringContainsString('end-larapoke-script', $response->content());
175175

176176
$this->assertTrue(substr_count($response->content(), 'start-larapoke-script') === 1);
177177
$this->assertTrue(substr_count($response->content(), 'end-larapoke-script') === 1);

tests/Unit/Modes/ModeMiddlewareTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function getEnvironmentSetUp($app)
3030
$this->app = null;
3131
}
3232

33-
protected function setUp()
33+
protected function setUp() : void
3434
{
3535
parent::setUp();
3636

@@ -129,7 +129,7 @@ protected function viewWithNothing()
129129
');
130130
}
131131

132-
protected function tearDown()
132+
protected function tearDown() : void
133133
{
134134
parent::tearDown();
135135

@@ -149,58 +149,58 @@ public function testDoesntInjectsOnJson()
149149
{
150150
$response = $this->get('/json');
151151

152-
$this->assertNotContains('start-larapoke-script', $response->content());
153-
$this->assertNotContains('end-larapoke-script', $response->content());
152+
$this->assertStringNotContainsString('start-larapoke-script', $response->content());
153+
$this->assertStringNotContainsString('end-larapoke-script', $response->content());
154154
}
155155

156156

157157
public function testNoScriptOnNoMiddleware()
158158
{
159159
$response = $this->get('/no-middleware');
160-
$this->assertNotContains('start-larapoke-script', $response->content());
161-
$this->assertNotContains('end-larapoke-script', $response->content());
160+
$this->assertStringNotContainsString('start-larapoke-script', $response->content());
161+
$this->assertStringNotContainsString('end-larapoke-script', $response->content());
162162
}
163163

164164
public function testDetectsHeaderOrForm()
165165
{
166166
$response = $this->get('/register');
167-
$this->assertContains('start-larapoke-script', $response->content());
168-
$this->assertContains('end-larapoke-script', $response->content());
167+
$this->assertStringContainsString('start-larapoke-script', $response->content());
168+
$this->assertStringContainsString('end-larapoke-script', $response->content());
169169
}
170170

171171
public function testDetectsHeader()
172172
{
173173
$response = $this->get('/header-only');
174-
$this->assertContains('start-larapoke-script', $response->content());
175-
$this->assertContains('end-larapoke-script', $response->content());
174+
$this->assertStringContainsString('start-larapoke-script', $response->content());
175+
$this->assertStringContainsString('end-larapoke-script', $response->content());
176176
}
177177

178178
public function testDetectsForm()
179179
{
180180
$response = $this->get('/form-only');
181-
$this->assertContains('start-larapoke-script', $response->content());
182-
$this->assertContains('end-larapoke-script', $response->content());
181+
$this->assertStringContainsString('start-larapoke-script', $response->content());
182+
$this->assertStringContainsString('end-larapoke-script', $response->content());
183183
}
184184

185185
public function testDetectsNothing()
186186
{
187187
$response = $this->get('/nothing');
188-
$this->assertNotContains('start-larapoke-script', $response->content());
189-
$this->assertNotContains('end-larapoke-script', $response->content());
188+
$this->assertStringNotContainsString('start-larapoke-script', $response->content());
189+
$this->assertStringNotContainsString('end-larapoke-script', $response->content());
190190
}
191191

192192
public function testInjectsForcefullyWithoutDetect()
193193
{
194194
$response = $this->get('/nothing-with-middleware');
195-
$this->assertContains('start-larapoke-script', $response->content());
196-
$this->assertContains('end-larapoke-script', $response->content());
195+
$this->assertStringContainsString('start-larapoke-script', $response->content());
196+
$this->assertStringContainsString('end-larapoke-script', $response->content());
197197

198198
LarapokeDirective::setWasRendered(false);
199199

200200
$response = $this->get('/login');
201201

202-
$this->assertContains('start-larapoke-script', $response->content());
203-
$this->assertContains('end-larapoke-script', $response->content());
202+
$this->assertStringContainsString('start-larapoke-script', $response->content());
203+
$this->assertStringContainsString('end-larapoke-script', $response->content());
204204
}
205205

206206
}

tests/Unit/Script/ScriptRouteTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function handle($request, $next)
5555
});
5656
}
5757

58-
protected function tearDown()
58+
protected function tearDown() : void
5959
{
6060
parent::tearDown();
6161

@@ -71,7 +71,7 @@ protected function recurseRmdir($dir) {
7171
return rmdir($dir);
7272
}
7373

74-
protected function setUp()
74+
protected function setUp() : void
7575
{
7676
parent::setUp();
7777

tests/Unit/Script/ScriptTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function getPackageProviders($app)
2424

2525
protected $times;
2626

27-
public function setUp()
27+
public function setUp() : void
2828
{
2929
$this->mockConfig = \Mockery::mock(\Illuminate\Config\Repository::class);
3030

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
require __DIR__ . '/../vendor/autoload.php';
44

5-
Orchestra\Testbench\Dusk\Options::withoutUI();
5+
// Orchestra\Testbench\Dusk\Options::withoutUI();

0 commit comments

Comments
 (0)