Skip to content

Commit 66ba3da

Browse files
committed
Update End to End tests
Use library-e2e-tester instead of our handrolled solution. Updates the analytics binary to omit anonymousId and timestamp, and uses `array` instead of `[]` shorthand to work with PHP 5.3.
1 parent 06faddf commit 66ba3da

File tree

4 files changed

+35
-183
lines changed

4 files changed

+35
-183
lines changed

.buildscript/e2e.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
if [ "$RUN_E2E_TESTS" != "true" ]; then
6+
echo "Skipping end to end tests."
7+
else
8+
echo "Running end to end tests..."
9+
wget https://github.com/segmentio/library-e2e-tester/releases/download/0.2.1/tester_linux_amd64 -O tester
10+
chmod +x tester
11+
./tester -path='./bin/analytics'
12+
echo "End to end tests completed!"
13+
fi

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ matrix:
1414
script:
1515
- if [[ ! ${TRAVIS_PHP_VERSION:0:3} < "5.5" ]]; then composer require overtrue/phplint; composer require squizlabs/php_codesniffer; ./vendor/bin/phplint; ./vendor/bin/phpcs; fi
1616
- phpunit
17+
- .buildscript/e2e.sh
1718

1819
after_success:
19-
- bash <(curl -s https://codecov.io/bash)
20+
- bash <(curl -s https://codecov.io/bash)

bin/analytics

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ if (in_array('--help', $argv)) {
1010

1111
date_default_timezone_set('UTC');
1212

13-
$options = getopt('', [
13+
$options = getopt('', array(
1414
'writeKey::',
15-
'type:', // T I P G A
16-
'event::', // x
17-
'userId::', // x x x x x
18-
'groupId::', // x
19-
'previousId::', // x
20-
'anonymousId::', // x x x x x
21-
'properties::', // x x
22-
'name::', // x
23-
'traits::', // x x
24-
'context::', // x x x x x
25-
'timestamp::' // x x x x x
26-
]);
15+
'type:',
16+
17+
'userId::',
18+
19+
'event::',
20+
'properties::',
21+
22+
'name::',
23+
24+
'traits::',
25+
26+
'groupId::',
27+
28+
'previousId::'
29+
));
2730

2831
if (empty($options['writeKey'])) {
2932
error('writeKey flag required');
@@ -35,44 +38,31 @@ switch ($options['type']) {
3538
case 'track':
3639
Segment::track(array(
3740
'userId' => $options['userId'],
38-
'anonymousId' => $options['anonymousId'],
3941
'event' => $options['event'],
40-
'properties' => parse_json($options['properties']),
41-
'timestamp' => parse_timestamp($options['timestamp']),
42-
'context' => parse_json($options['context'])
42+
'properties' => parse_json($options['properties'])
4343
));
4444
break;
4545

4646
case 'identify':
4747
Segment::identify(array(
4848
'userId' => $options['userId'],
49-
'anonymousId' => $options['anonymousId'],
50-
'traits' => parse_json($options['traits']),
51-
'timestamp' => parse_timestamp($options['timestamp']),
52-
'context' => parse_json($options['context'])
49+
'traits' => parse_json($options['traits'])
5350
));
5451
break;
5552

5653
case 'page':
5754
Segment::page(array(
5855
'userId' => $options['userId'],
59-
'anonymousId' => $options['anonymousId'],
6056
'name' => $options['name'],
61-
'category' => $options['category'],
62-
'properties' => parse_json($options['properties']),
63-
'timestamp' => parse_timestamp($options['timestamp']),
64-
'context' => parse_json($options['context'])
57+
'properties' => parse_json($options['properties'])
6558
));
6659
break;
6760

6861
case 'group':
6962
Segment::identify(array(
7063
'userId' => $options['userId'],
71-
'anonymousId' => $options['anonymousId'],
7264
'groupId' => $options['groupId'],
73-
'traits' => parse_json($options['traits']),
74-
'timestamp' => parse_timestamp($options['timestamp']),
75-
'context' => parse_json($options['context'])
65+
'traits' => parse_json($options['traits'])
7666
));
7767
break;
7868

test/AnalyticsE2ETest.php

Lines changed: 0 additions & 152 deletions
This file was deleted.

0 commit comments

Comments
 (0)