Skip to content

Commit 24c9091

Browse files
authored
Merge pull request #26 from jhoff/add_tests
Adds tests for traits and default filenames
2 parents dea29dd + d45775f commit 24c9091

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ env:
99
- COMPOSER_FLAGS="--prefer-lowest"
1010
- COMPOSER_FLAGS=""
1111

12+
before_install:
13+
- sudo apt-get update
14+
- sudo apt-get install -y graphviz
15+
1216
before_script:
1317
- travis_retry composer self-update
1418
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

tests/GenerationTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,16 @@ public function it_generated_graphviz_for_test_models_with_db_columns()
4646

4747
$this->assertMatchesSnapshot(Artisan::output());
4848
}
49+
50+
/** @test */
51+
public function it_generated_graphviz_in_jpeg_format()
52+
{
53+
$this->app['config']->set('erd-generator.directories', [__DIR__.'/Models']);
54+
55+
Artisan::call('generate:erd', [
56+
'--format' => 'jpeg'
57+
]);
58+
59+
$this->assertContains('Wrote diagram to graph.jpeg', Artisan::output());
60+
}
4961
}

tests/Models/Post.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
namespace BeyondCode\ErdGenerator\Tests\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use BeyondCode\ErdGenerator\Tests\Traits\HasComments;
67

78
class Post extends Model
89
{
10+
use HasComments;
911

1012
public function user()
1113
{
1214
return $this->belongsTo(User::class);
1315
}
1416

15-
public function comments()
16-
{
17-
return $this->hasMany(Comment::class);
18-
}
19-
20-
}
17+
}

tests/Traits/HasComments.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace BeyondCode\ErdGenerator\Tests\Traits;
4+
5+
use BeyondCode\ErdGenerator\Tests\Models\Comment;
6+
7+
trait HasComments
8+
{
9+
10+
public function comments()
11+
{
12+
return $this->hasMany(Comment::class);
13+
}
14+
15+
}

0 commit comments

Comments
 (0)