Skip to content

Commit 7de7811

Browse files
authored
Merge pull request #523 from mstilkerich/fix_set_properties_with_groups
Fix setting properties with group assignment
2 parents 38bc2d2 + 31c9187 commit 7de7811

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/Component.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public function remove($item)
160160
return;
161161
}
162162
}
163-
}
164163

165-
throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component');
164+
throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component');
165+
}
166166
}
167167

168168
/**

tests/VObject/ComponentTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ public function testMagicGetGroups()
7272
$this->assertEquals(null, $email3[0]->group);
7373
}
7474

75+
public function testAddGroupProperties()
76+
{
77+
$comp = new VCard([
78+
'VERSION' => '3.0',
79+
'item2.X-ABLabel' => 'item2-Foo',
80+
]);
81+
82+
$comp->{'ITEM1.X-ABLabel'} = 'ITEM1-Foo';
83+
84+
foreach (['item2', 'ITEM1'] as $group) {
85+
$prop = $comp->{"$group.X-ABLabel"};
86+
$this->assertInstanceOf(Property::class, $prop);
87+
$this->assertSame("$group-Foo", (string) $prop);
88+
$this->assertSame($group, $prop->group);
89+
}
90+
}
91+
7592
public function testMagicIsset()
7693
{
7794
$comp = new VCalendar();

0 commit comments

Comments
 (0)