Skip to content

Commit db37bf0

Browse files
Extend relation-type list to include morphedByMany
1 parent abb0138 commit db37bf0

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

src/Models/ForeignRelationship.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ForeignRelationship implements JsonWriter
2929
'morphMany',
3030
'morphOne',
3131
'morphToMany',
32+
'morphedByMany'
3233
];
3334

3435
/**

tests/ResourceFileCreateCommandTest.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ class ResourceFileCreateCommandTest extends TestCase
1515
{
1616
public function testCreateResourceFileWithBigIntField()
1717
{
18-
//first, mock out the file system so we don't accidentally scribble on something
19-
File::shouldReceive('exists')->andReturnNull();
20-
File::shouldReceive('put')->andReturnNull();
21-
File::shouldReceive('isDirectory')->andReturn(false);
22-
File::shouldReceive('makeDirectory')->andReturnNull();
18+
$this->mockOutFileSystem();
2319

2420
// arguments we're passing in
2521
$fieldString = 'name:foo_count;data-type:bigint';
@@ -32,11 +28,7 @@ public function testCreateResourceFileWithBigIntField()
3228

3329
public function testCreateResourceFileWithBigIntegerField()
3430
{
35-
//first, mock out the file system so we don't accidentally scribble on something
36-
File::shouldReceive('exists')->andReturnNull();
37-
File::shouldReceive('put')->andReturnNull();
38-
File::shouldReceive('isDirectory')->andReturn(false);
39-
File::shouldReceive('makeDirectory')->andReturnNull();
31+
$this->mockOutFileSystem();
4032

4133
// arguments we're passing in
4234
$fieldString = 'name:foo_count;data-type:biginteger';
@@ -46,4 +38,30 @@ public function testCreateResourceFileWithBigIntegerField()
4638
// Vacuous assertion to give PHPUnit something to do instead of complaining about a risky test
4739
$this->assertTrue(true);
4840
}
41+
42+
public function testCreateResourceFileWithMorphedByManyRelation()
43+
{
44+
$this->mockOutFileSystem();
45+
46+
// arguments we're passing in
47+
$relString = 'name:foo;type:morphedByMany;params:App\Foo|fooable';
48+
49+
// now call Artisan
50+
Artisan::call('resource-file:create', ['model-name' => 'TestModel', '--relations' => $relString]);
51+
// Vacuous assertion to give PHPUnit something to do instead of complaining about a risky test
52+
$this->assertTrue(true);
53+
}
54+
55+
/**
56+
* Mock out the file system so we don't accidentally scribble on something
57+
*
58+
* @return void
59+
*/
60+
private function mockOutFileSystem()
61+
{
62+
File::shouldReceive('exists')->andReturnNull();
63+
File::shouldReceive('put')->andReturnNull();
64+
File::shouldReceive('isDirectory')->andReturn(false);
65+
File::shouldReceive('makeDirectory')->andReturnNull();
66+
}
4967
}

0 commit comments

Comments
 (0)