Skip to content

Commit d9d33ce

Browse files
committed
statement ids have to be UUIDs
1 parent 035be43 commit d9d33ce

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

Tests/Model/StatementTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testValidateMinimalStatement()
3131
public function testValidStatement()
3232
{
3333
$statement = new Statement();
34-
$statement->setId(md5(uniqid()));
34+
$statement->setId('12345678-1234-5678-8234-567812345678');
3535
$statement->setActor(new Agent());
3636
$statement->setVerb(new Verb());
3737
$statement->setObject(new Activity());
@@ -49,10 +49,21 @@ public function testWithoutId()
4949
$this->validateStatement($statement, 1);
5050
}
5151

52+
public function testNotUuidIdInvalidates()
53+
{
54+
$statement = new Statement();
55+
$statement->setId('foo');
56+
$statement->setActor(new Agent());
57+
$statement->setVerb(new Verb());
58+
$statement->setObject(new Activity());
59+
60+
$this->validateStatement($statement, 1);
61+
}
62+
5263
public function testWithoutActor()
5364
{
5465
$statement = new Statement();
55-
$statement->setId(md5(uniqid()));
66+
$statement->setId('12345678-1234-5678-8234-567812345678');
5667
$statement->setVerb(new Verb());
5768
$statement->setObject(new Activity());
5869

@@ -62,7 +73,7 @@ public function testWithoutActor()
6273
public function testWithoutVerb()
6374
{
6475
$statement = new Statement();
65-
$statement->setId(md5(uniqid()));
76+
$statement->setId('12345678-1234-5678-8234-567812345678');
6677
$statement->setActor(new Agent());
6778
$statement->setObject(new Activity());
6879

@@ -72,7 +83,7 @@ public function testWithoutVerb()
7283
public function testWithoutObject()
7384
{
7485
$statement = new Statement();
75-
$statement->setId(md5(uniqid()));
86+
$statement->setId('12345678-1234-5678-8234-567812345678');
7687
$statement->setActor(new Agent());
7788
$statement->setVerb(new Verb());
7889

Tests/Model/fixtures/minimal_statement.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "12345678-1234-5678-1234-567812345678",
2+
"id": "12345678-1234-5678-8234-567812345678",
33
"actor": {
44
"mbox": "mailto:[email protected]",
55
"objectType": "Agent"

Tests/Serializer/StatementSerializerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testDeserializeMinimalStatement()
4444
);
4545

4646
$this->assertEquals(
47-
'12345678-1234-5678-1234-567812345678',
47+
'12345678-1234-5678-8234-567812345678',
4848
$statement->getId()
4949
);
5050
$this->assertEquals(
@@ -157,7 +157,7 @@ public function testDeserializeWithResult()
157157
public function testSerializeMinimalStatement()
158158
{
159159
$statement = new Statement();
160-
$statement->setId('12345678-1234-5678-1234-567812345678');
160+
$statement->setId('12345678-1234-5678-8234-567812345678');
161161

162162
$actor = new Agent();
163163
$actor->setMbox('mailto:[email protected]');

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"php": ">=5.3.0",
1616
"jms/serializer": "~0.16",
1717
"symfony/config": "~2.2",
18-
"symfony/validator": "~2.2"
18+
"symfony/validator": "~2.5"
1919
},
2020
"require-dev": {
2121
"symfony/property-access": "~2.2"

metadata/validator/Statement.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<class name="Xabbuh\XApi\Common\Model\Statement">
88
<property name="id">
99
<constraint name="NotBlank" />
10+
<constraint name="Uuid" />
1011
</property>
1112
<property name="actor">
1213
<constraint name="NotBlank" />

0 commit comments

Comments
 (0)