Skip to content

Commit 025a233

Browse files
committed
Bump to Laravel 12
1 parent 852b0f5 commit 025a233

File tree

8 files changed

+86
-72
lines changed

8 files changed

+86
-72
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^7.2|^8.0.2",
22-
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0"
21+
"php": "^7.2|^8.0.2|^8.3",
22+
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0"
2323
},
2424
"require-dev": {
2525
"mockery/mockery": "^1.0.0",
26-
"illuminate/filesystem": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
27-
"laravel/framework": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
26+
"illuminate/filesystem": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
27+
"laravel/framework": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
2828
"phpunit/phpunit": "^8.0"
2929
},
3030
"autoload": {

src/Commands/IseedCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Cheesegrits\Iseed\Commands;
44

55
use Illuminate\Console\Command;
6-
use src\TableNotFoundException;
6+
use Cheesegrits\Iseed\Exceptions\TableNotFoundException;
77
use Symfony\Component\Console\Input\InputArgument;
88
use Symfony\Component\Console\Input\InputOption;
99
//use function Cheesegrits\Iseed\app;

src/Exceptions/Exceptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Exceptions;
3+
namespace Cheesegrits\Iseed\Exceptions;
44

55
class TableNotFoundException extends \RuntimeException
66
{

src/Iseed.php

Lines changed: 57 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Cheesegrits\Iseed;
44

5+
use Cheesegrits\Iseed\Exceptions\TableNotFoundException;
56
use Illuminate\Filesystem\Filesystem;
67
use Illuminate\Support\Composer;
7-
use src\TableNotFoundException;
88

99
class Iseed
1010
{
@@ -39,13 +39,15 @@ class Iseed
3939
*/
4040
private $composer;
4141

42+
private $files;
43+
4244
/**
4345
* Constructs a new instance.
4446
*
4547
* @param \Illuminate\Filesystem\Filesystem|bool $filesystem Filesystem
46-
* @param \Illuminate\Support\Composer|bool $composer Composer
48+
* @param \Illuminate\Support\Composer|bool $composer Composer
4749
*/
48-
public function __construct(Filesystem $filesystem=null, Composer $composer=null)
50+
public function __construct(Filesystem $filesystem = null, Composer $composer = null)
4951
{
5052
$this->files = $filesystem ?: new Filesystem;
5153
$this->composer = $composer ?: new Composer($this->files);
@@ -67,39 +69,40 @@ public function readStubFile($file)
6769
/**
6870
* Generates a seed file.
6971
*
70-
* @param string $table Table name
71-
* @param string $prefix Seeder class prefix
72-
* @param string $suffix Seeder class suffix
73-
* @param string $database Database connection name
74-
* @param int $max Maximum seeded entries
75-
* @param int $chunkSize Size of data chunks
76-
* @param string $exclude Columns to exclude
77-
* @param string $prerunEvent Prerun event name
72+
* @param string $table Table name
73+
* @param string $prefix Seeder class prefix
74+
* @param string $suffix Seeder class suffix
75+
* @param string $database Database connection name
76+
* @param int $max Maximum seeded entries
77+
* @param int $chunkSize Size of data chunks
78+
* @param string $exclude Columns to exclude
79+
* @param string $prerunEvent Prerun event name
7880
* @param string $postrunEvent Postrun event name
79-
* @param bool $dumpAuto Composer auto-dump
80-
* @param bool $indexed Indexed array
81-
* @param int $orderBy Column to order by
82-
* @param string $direction Default sort order
81+
* @param bool $dumpAuto Composer auto-dump
82+
* @param bool $indexed Indexed array
83+
* @param int $orderBy Column to order by
84+
* @param string $direction Default sort order
8385
*
86+
* @return void
8487
* @throws Cheesegrits\Iseed\TableNotFoundException
8588
*
86-
* @return void
8789
*/
8890
public function generateSeed(
8991
$table,
90-
$prefix=null,
91-
$suffix=null,
92-
$database=null,
93-
$max=0,
94-
$chunkSize=0,
95-
$exclude=null,
96-
$prerunEvent=null,
97-
$postrunEvent=null,
98-
$dumpAuto=true,
99-
$indexed=true,
100-
$orderBy=null,
101-
$direction='ASC'
102-
) {
92+
$prefix = null,
93+
$suffix = null,
94+
$database = null,
95+
$max = 0,
96+
$chunkSize = 0,
97+
$exclude = null,
98+
$prerunEvent = null,
99+
$postrunEvent = null,
100+
$dumpAuto = true,
101+
$indexed = true,
102+
$orderBy = null,
103+
$direction = 'ASC'
104+
)
105+
{
103106
if (!$database) {
104107
$database = config('database.default');
105108
}
@@ -125,8 +128,8 @@ public function generateSeed(
125128
\File::exists(
126129
config('iseed.stub_path')
127130
) ?
128-
config('iseed.stub_path') :
129-
$this->getStubPath() . '/seed.stub'
131+
config('iseed.stub_path') :
132+
$this->getStubPath() . '/seed.stub'
130133
);
131134

132135
// Get a seed folder path
@@ -172,15 +175,15 @@ public function getSeedPath()
172175
/**
173176
* Get the Data
174177
*
175-
* @param string $table Table name
176-
* @param int $max Maximum seeded entries
177-
* @param string $exclude Columns to exclude
178-
* @param int $orderBy Column to order by
178+
* @param string $table Table name
179+
* @param int $max Maximum seeded entries
180+
* @param string $exclude Columns to exclude
181+
* @param int $orderBy Column to order by
179182
* @param string $direction Default sort order
180183
*
181184
* @return array
182185
*/
183-
public function getData($table, $max, $exclude=null, $orderBy=null, $direction='ASC')
186+
public function getData($table, $max, $exclude = null, $orderBy = null, $direction = 'ASC')
184187
{
185188
$result = \DB::connection($this->databaseName)->table($table);
186189

@@ -242,13 +245,13 @@ public function hasTable($table)
242245
/**
243246
* Generates a seed class name (also used as a filename)
244247
*
245-
* @param string $table Table name
248+
* @param string $table Table name
246249
* @param string $prefix Seeder class prefix
247250
* @param string $suffix Seeder class suffix
248251
*
249252
* @return string
250253
*/
251-
public function generateClassName($table, $prefix=null, $suffix=null)
254+
public function generateClassName($table, $prefix = null, $suffix = null)
252255
{
253256
$tableString = '';
254257
$tableName = explode('_', $table);
@@ -271,14 +274,14 @@ public function getStubPath()
271274
/**
272275
* Populate the place-holders in the seed stub.
273276
*
274-
* @param string $class Class name
275-
* @param string $stub Stub name
276-
* @param string $table Table name
277-
* @param string $data Data object
278-
* @param int $chunkSize Size of data chunks
279-
* @param string $prerunEvent Prerun event name
277+
* @param string $class Class name
278+
* @param string $stub Stub name
279+
* @param string $table Table name
280+
* @param string $data Data object
281+
* @param int $chunkSize Size of data chunks
282+
* @param string $prerunEvent Prerun event name
280283
* @param string $postrunEvent Postrun event name
281-
* @param bool $indexed Indexed array
284+
* @param bool $indexed Indexed array
282285
*
283286
* @return string
284287
*/
@@ -291,7 +294,8 @@ public function populateStub(
291294
$prerunEvent = null,
292295
$postrunEvent = null,
293296
$indexed = true
294-
) {
297+
)
298+
{
295299
$chunkSize = $chunkSize ?: config('iseed.chunk_size');
296300

297301
$inserts = '';
@@ -307,7 +311,7 @@ public function populateStub(
307311
}
308312

309313
$namespace = implode('\\', array_filter(array_map('ucfirst', explode('/', config('iseed.path')))));
310-
$stub = str_replace('{{ namespace }}', $namespace, $stub);
314+
$stub = str_replace('{{ namespace }}', $namespace, $stub);
311315
$stub = str_replace('{{ class }}', $class, $stub);
312316

313317
$prerunEventInsert = '';
@@ -375,7 +379,7 @@ public function getPath($name, $path)
375379
*
376380
* @return string
377381
*/
378-
protected function prettifyArray($array, $indexed=true)
382+
protected function prettifyArray($array, $indexed = true)
379383
{
380384
$content = ($indexed)
381385
? var_export($array, true)
@@ -426,8 +430,8 @@ protected function prettifyArray($array, $indexed=true)
426430
/**
427431
* Adds new lines to the passed content variable reference.
428432
*
429-
* @param string $content Passed content
430-
* @param int $numberOfLines Number of new lines
433+
* @param string $content Passed content
434+
* @param int $numberOfLines Number of new lines
431435
*
432436
* @return void
433437
*/
@@ -442,8 +446,8 @@ private function addNewLines(&$content, $numberOfLines = 1)
442446
/**
443447
* Adds indentation to the passed content reference.
444448
*
445-
* @param string $content Passed content
446-
* @param int $numberOfIndents Number of indents
449+
* @param string $content Passed content
450+
* @param int $numberOfIndents Number of indents
447451
*
448452
* @return void
449453
*/
@@ -478,9 +482,9 @@ public function cleanSection()
478482
*
479483
* @param string $className Database seeder class name
480484
*
485+
* @return bool
481486
* @link https://github.com/JeffreyWay/Laravel-4-Generators Kudoz to this package
482487
*
483-
* @return bool
484488
*/
485489
public function updateDatabaseSeederRunMethod($className)
486490
{

tests/CreatesApplication.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,28 @@
66

77
trait CreatesApplication
88
{
9-
/**
10-
* Creates the application.
11-
*
12-
* @return \Illuminate\Foundation\Application
13-
*/
14-
public function createApplication()
9+
protected function getPackageProviders($app)
1510
{
16-
$app = require __DIR__.'/../bootstrap/app.php';
17-
18-
$app->make(Kernel::class)->bootstrap();
11+
return [
12+
];
13+
}
14+
15+
// /**
16+
// * Creates the application.
17+
// *
18+
// * @return \Illuminate\Foundation\Application
19+
// */
20+
// public function createApplication()
21+
// {
22+
// $app = require __DIR__.'/../bootstrap/app.php';
23+
//
24+
// $app->make(Kernel::class)->bootstrap();
25+
//
26+
// return $app;
27+
// }
1928

29+
public function getEnvironmentSetUp($app)
30+
{
2031
return $app;
2132
}
2233
}

tests/IseedTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
error_reporting(E_ALL);
33
ini_set('display_errors', 1);
44

5-
use Exceptions\TableNotFoundException;
5+
use Cheesegrits\Iseed\Exceptions\TableNotFoundException;
66
use Mockery as m;
7-
use PHPUnit\Framework\TestCase;
7+
use Cheesegrits\Iseed\Tests\TestCase;
88

99
class IseedTest extends TestCase
1010
{

tests/TestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Cheesegrits\Iseed\Tests;
44

55
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
6-
use Tests\CreatesApplication;
76

87
abstract class TestCase extends BaseTestCase
98
{

tests/Unit/IseedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ini_set('display_errors', 1);
77

88
use Cheesegrits;
9-
use Exceptions\TableNotFoundException;
9+
use Cheesegrits\Iseed\Exceptions\TableNotFoundException;
1010
use Mockery as m;
1111
use Cheesegrits\Iseed\Tests\TestCase;
1212

0 commit comments

Comments
 (0)