Skip to content

Commit

Permalink
Update End to End tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
f2prateek committed Sep 10, 2018
1 parent 06faddf commit 66ba3da
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 183 deletions.
13 changes: 13 additions & 0 deletions .buildscript/e2e.sh
@@ -0,0 +1,13 @@
#!/bin/sh

set -ex

if [ "$RUN_E2E_TESTS" != "true" ]; then
echo "Skipping end to end tests."
else
echo "Running end to end tests..."
wget https://github.com/segmentio/library-e2e-tester/releases/download/0.2.1/tester_linux_amd64 -O tester
chmod +x tester
./tester -path='./bin/analytics'
echo "End to end tests completed!"
fi
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -14,6 +14,7 @@ matrix:
script:
- 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
- phpunit
- .buildscript/e2e.sh

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
50 changes: 20 additions & 30 deletions bin/analytics
Expand Up @@ -10,20 +10,23 @@ if (in_array('--help', $argv)) {

date_default_timezone_set('UTC');

$options = getopt('', [
$options = getopt('', array(
'writeKey::',
'type:', // T I P G A
'event::', // x
'userId::', // x x x x x
'groupId::', // x
'previousId::', // x
'anonymousId::', // x x x x x
'properties::', // x x
'name::', // x
'traits::', // x x
'context::', // x x x x x
'timestamp::' // x x x x x
]);
'type:',

'userId::',

'event::',
'properties::',

'name::',

'traits::',

'groupId::',

'previousId::'
));

if (empty($options['writeKey'])) {
error('writeKey flag required');
Expand All @@ -35,44 +38,31 @@ switch ($options['type']) {
case 'track':
Segment::track(array(
'userId' => $options['userId'],
'anonymousId' => $options['anonymousId'],
'event' => $options['event'],
'properties' => parse_json($options['properties']),
'timestamp' => parse_timestamp($options['timestamp']),
'context' => parse_json($options['context'])
'properties' => parse_json($options['properties'])
));
break;

case 'identify':
Segment::identify(array(
'userId' => $options['userId'],
'anonymousId' => $options['anonymousId'],
'traits' => parse_json($options['traits']),
'timestamp' => parse_timestamp($options['timestamp']),
'context' => parse_json($options['context'])
'traits' => parse_json($options['traits'])
));
break;

case 'page':
Segment::page(array(
'userId' => $options['userId'],
'anonymousId' => $options['anonymousId'],
'name' => $options['name'],
'category' => $options['category'],
'properties' => parse_json($options['properties']),
'timestamp' => parse_timestamp($options['timestamp']),
'context' => parse_json($options['context'])
'properties' => parse_json($options['properties'])
));
break;

case 'group':
Segment::identify(array(
'userId' => $options['userId'],
'anonymousId' => $options['anonymousId'],
'groupId' => $options['groupId'],
'traits' => parse_json($options['traits']),
'timestamp' => parse_timestamp($options['timestamp']),
'context' => parse_json($options['context'])
'traits' => parse_json($options['traits'])
));
break;

Expand Down
152 changes: 0 additions & 152 deletions test/AnalyticsE2ETest.php

This file was deleted.

0 comments on commit 66ba3da

Please sign in to comment.