-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,20 +109,45 @@ public function testCanOpenCSV() | |
|
||
// Test an openable CSV | ||
$expected = "resource"; | ||
$actual = $seeder->openCSV(__DIR__.'/csvs/test.csv'); | ||
$actual = $seeder->openCSV(__DIR__.'/csvs/users.csv'); | ||
$this->assertInternalType($expected, $actual); | ||
|
||
// Test a non-openable CSV | ||
$expected = FALSE; | ||
$actual = $seeder->openCSV(__DIR__.'/csvs/test_that_does_not_exist.csv'); | ||
$actual = $seeder->openCSV(__DIR__.'/csvs/csv_that_does_not_exist.csv'); | ||
$this->assertEquals($expected, $actual); | ||
} | ||
|
||
public function testImport() | ||
{ | ||
$seeder = new \Flynsarmy\CsvSeeder\CsvSeeder; | ||
$seeder->table = 'users'; | ||
$seeder->filename = __DIR__.'/csvs/test.csv'; | ||
$seeder->filename = __DIR__.'/csvs/users.csv'; | ||
$seeder->hashable = ''; | ||
$seeder->run(); | ||
|
||
// Make sure the rows imported | ||
$this->seeInDatabase('users', [ | ||
'id' => 1, | ||
'first_name' => 'Abe', | ||
'last_name' => 'Abeson', | ||
'email' => '[email protected]', | ||
'age' => 50, | ||
]); | ||
$this->seeInDatabase('users', [ | ||
'id' => 3, | ||
'first_name' => 'Charly', | ||
'last_name' => 'Charlyson', | ||
'email' => '[email protected]', | ||
'age' => 52, | ||
]); | ||
} | ||
|
||
public function testIgnoredColumnImport() | ||
{ | ||
$seeder = new \Flynsarmy\CsvSeeder\CsvSeeder; | ||
$seeder->table = 'users'; | ||
$seeder->filename = __DIR__.'/csvs/users_with_ignored_column.csv'; | ||
$seeder->hashable = ''; | ||
$seeder->run(); | ||
|
||
|
@@ -147,7 +172,7 @@ public function testHash() | |
{ | ||
$seeder = new \Flynsarmy\CsvSeeder\CsvSeeder; | ||
$seeder->table = 'users'; | ||
$seeder->filename = __DIR__.'/csvs/test.csv'; | ||
$seeder->filename = __DIR__.'/csvs/users.csv'; | ||
|
||
// Assert unhashed passwords | ||
$seeder->hashable = ''; | ||
|
@@ -178,7 +203,7 @@ public function testOffset() | |
{ | ||
$seeder = new \Flynsarmy\CsvSeeder\CsvSeeder; | ||
$seeder->table = 'users'; | ||
$seeder->filename = __DIR__.'/csvs/test.csv'; | ||
$seeder->filename = __DIR__.'/csvs/users.csv'; | ||
$seeder->hashable = ''; | ||
$seeder->offset_rows = 4; | ||
$seeder->mapping = [ | ||
|
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,10 @@ | ||
# Tests | ||
|
||
TO test, open *phpunit.xml* in your laravel installations root directory | ||
and add to the `testsuites` section: | ||
|
||
<testsuite name="Application Test Suite"> | ||
<directory>./vendor/flynsarmy/csv-seeder/tests/</directory> | ||
</testsuite> | ||
|
||
Then run `phpunit` |
File renamed without changes.
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,6 @@ | ||
id,first_name,last_name,email,password,address,age,foo | ||
1,Abe,Abeson,[email protected],abeabeson,123 Abe street,50,abelony | ||
2,Betty,Bettyson,[email protected],bettybettyson,123 Betty street,51,bettlelony | ||
3,Charly,Charlyson,[email protected],charlycharlyson,123 Charly street,52,charlelony | ||
4,Delta,Deltason,[email protected],deltadeltason,123 Delta street,53,deltalony | ||
5,Echo,Echoson,[email protected],echoechoson,123 Echo street,54,echolony |