Skip to content

Commit

Permalink
Rig MetadataTrait tests to indicate access violations
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberiaResurrection committed Sep 20, 2017
1 parent 4381fdd commit af0d2fd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/unit/Models/MetadataTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public function setUp()
{
parent::setUp();
$this->object = $this->getMockForTrait('\AlgoWeb\PODataLaravel\Models\MetadataTrait');
$msg = 'Simple metadata provider cannot be called from metadata trait';
$meta = m::mock(SimpleMetadataProvider::class);
$meta->shouldReceive('resolveResourceProperty')->andThrow(new \Exception($msg))->never();
$meta->shouldReceive('addEntityType')->andThrow(new \Exception($msg))->never();
$meta->shouldReceive('addKeyProperty')->andThrow(new \Exception($msg))->never();
$meta->shouldReceive('addPrimitiveProperty')->andThrow(new \Exception($msg))->never();
$meta->shouldReceive('addResourceReferenceProperty')->andThrow(new \Exception($msg))->never();
$meta->shouldReceive('addResourceSetReferenceProperty')->andThrow(new \Exception($msg))->never();
App::instance('metadata', $meta);
}

/**
Expand Down Expand Up @@ -411,7 +420,6 @@ public function testHookUpRelationshipsHasOnlyHasOneRelations()
$meta = m::mock(SimpleMetadataProvider::class);
$meta->shouldReceive('addResourceReferenceProperty')->withAnyArgs()->andReturnNull()->once();
$meta->shouldReceive('addResourceSetReferenceProperty')->withAnyArgs()->andReturnNull()->never();
App::instance('metadata', $meta);

$foo = m::mock(TestModel::class)->makePartial()->shouldAllowMockingProtectedMethods();
$fooName = get_class($foo);
Expand Down Expand Up @@ -439,7 +447,6 @@ public function testHookUpRelationshipsHasOnlyHasManyRelations()
$meta = m::mock(SimpleMetadataProvider::class);
$meta->shouldReceive('addResourceReferenceProperty')->withAnyArgs()->andReturnNull()->never();
$meta->shouldReceive('addResourceSetReferenceProperty')->withAnyArgs()->andReturnNull()->once();
App::instance('metadata', $meta);

$foo = m::mock(TestModel::class)->makePartial()->shouldAllowMockingProtectedMethods();
$fooName = get_class($foo);
Expand Down Expand Up @@ -640,7 +647,6 @@ public function testGetXmlSchemaOnUnknownSideOfPolymorphic()
$metaProv->shouldReceive('resolveResourceType')->andReturn($entity)->never();
$metaProv->shouldReceive('addEntityType')->andReturn($base);

App::instance('metadata', $metaProv);

//$foo = new TestMorphOneSource($meta);
$foo = m::mock(TestMorphOneSource::class)->makePartial();
Expand Down

0 comments on commit af0d2fd

Please sign in to comment.