Skip to content

Commit c19e61b

Browse files
committed
Add unit test for limiting message size
1 parent fd8e533 commit c19e61b

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

test/ConsumerLibCurlTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,34 @@ function testAlias() {
6868
"userId" => "user-id"
6969
)));
7070
}
71+
72+
/**
73+
* @expectedException \RuntimeException
74+
*/
75+
function testLargeMessageSizeError () {
76+
$options = array(
77+
"debug" => true,
78+
"consumer" => "lib_curl"
79+
);
80+
81+
$client = new Segment_Client("testlargesize", $options);
82+
83+
$big_property = "";
84+
85+
for ($i = 0; $i < 32 * 1024; $i++) {
86+
$big_property .= "a";
87+
}
88+
89+
$this->assertTrue($client->track(array(
90+
"userId" => "some-user",
91+
"event" => "Super Large PHP Event",
92+
"properties" => array("big_property" => $big_property)
93+
)));
94+
95+
$client->__destruct();
96+
}
97+
98+
7199
}
72100

73101
?>

test/ConsumerSocketTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,32 @@ function testLargeMessage () {
135135
$client->__destruct();
136136
}
137137

138+
/**
139+
* @expectedException \RuntimeException
140+
*/
141+
function testLargeMessageSizeError () {
142+
$options = array(
143+
"debug" => true,
144+
"consumer" => "socket"
145+
);
146+
147+
$client = new Segment_Client("testlargesize", $options);
148+
149+
$big_property = "";
150+
151+
for ($i = 0; $i < 32 * 1024; $i++) {
152+
$big_property .= "a";
153+
}
154+
155+
$this->assertTrue($client->track(array(
156+
"userId" => "some-user",
157+
"event" => "Super Large PHP Event",
158+
"properties" => array("big_property" => $big_property)
159+
)));
160+
161+
$client->__destruct();
162+
}
163+
138164
/**
139165
* @expectedException \RuntimeException
140166
*/

0 commit comments

Comments
 (0)