Skip to content

Commit

Permalink
failing test for #68
Browse files Browse the repository at this point in the history
  • Loading branch information
koenpunt committed Dec 7, 2014
1 parent 6309d9e commit 7eb7e99
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/HasManyThroughTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,41 @@ public function test_gh107_has_many_though_include_eager_with_namespace()
$this->assert_equals(1, $user->id);
$this->assert_equals(1, $user->newsletters[0]->id);
}

public function test_gh68_has_many_through_with_missing_associations()
{
Property::$has_many = array(
array('amenities', 'through' => 'property_amenities')
);
Amenity::$has_many = array(
array('properties', 'through' => 'property_amenities')
);

$property = Property::find('first');
try{
$property->amenities;
$this->fail('Should trigger exception');
}catch(ActiveRecord\HasManyThroughAssociationException $e){
$this->assertEquals('Could not find the association property_amenities in model Property', $e->getMessage());
}
}

public function test_gh68_has_many_through_with_missing_association()
{
Property::$has_many = array(
'property_amenities',
array('amenities', 'through' => 'property_amenities')
);
Amenity::$has_many = array(
array('properties', 'through' => 'property_amenities')
);

$amenity = Amenity::find('first');
try{
$amenity->properties;
$this->fail('Should trigger exception');
}catch(ActiveRecord\HasManyThroughAssociationException $e){
$this->assertEquals('Could not find the association property_amenities in model Amenity', $e->getMessage());
}
}
}
8 changes: 8 additions & 0 deletions test/RelationshipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ public function test_has_many_through()

public function test_gh27_has_many_through_with_explicit_keys()
{
Property::$has_many = array(
'property_amenities',
array('amenities', 'through' => 'property_amenities')
);
Amenity::$has_many = array(
'property_amenities'
);

$property = Property::first();

$this->assert_equals(1, $property->amenities[0]->amenity_id);
Expand Down

0 comments on commit 7eb7e99

Please sign in to comment.