Skip to content

Commit

Permalink
Merge pull request #523 from mstilkerich/fix_set_properties_with_groups
Browse files Browse the repository at this point in the history
Fix setting properties with group assignment
  • Loading branch information
phil-davis authored Feb 12, 2021
2 parents 38bc2d2 + 31c9187 commit 7de7811
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ public function remove($item)
return;
}
}
}

throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component');
throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component');
}
}

/**
Expand Down
17 changes: 17 additions & 0 deletions tests/VObject/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ public function testMagicGetGroups()
$this->assertEquals(null, $email3[0]->group);
}

public function testAddGroupProperties()
{
$comp = new VCard([
'VERSION' => '3.0',
'item2.X-ABLabel' => 'item2-Foo',
]);

$comp->{'ITEM1.X-ABLabel'} = 'ITEM1-Foo';

foreach (['item2', 'ITEM1'] as $group) {
$prop = $comp->{"$group.X-ABLabel"};
$this->assertInstanceOf(Property::class, $prop);
$this->assertSame("$group-Foo", (string) $prop);
$this->assertSame($group, $prop->group);
}
}

public function testMagicIsset()
{
$comp = new VCalendar();
Expand Down

0 comments on commit 7de7811

Please sign in to comment.