## Testing (Deprecated)

This document outlines how to run the automated tests for the Google Analytics Importer plugin - GA3(Universal Analytics).

## System Test

At the moment there is only one test that tests the entire importing process. The test is in `./tests/System/ImportTest.php`.

Before running, the following environment variables must be set:

Note: The below details might not work in your local env when you test with CI=0, to fix that ask Matthieu to give your user a view access to http://matthieu.net/blog GA account and replace the view and property id accordingly
``` 
$ export PIWIK_TEST_GA_VIEW_ID=2352671
$ export GA_PROPERTY_ID=UA-95026-4
$ export CI=1
```

You must also provide credentials to the test GA site in some way. There are two ways to do this:

**Method 1:** Specify account credentials via environment variables. The following environment variables must be set:
**PIWIK_TEST_GA_ACCESS_TOKEN** **PIWIK_TEST_GA_CLIENT_CONFIG**.

**Method 2:** Configure your local test instance through the UI. The automated test will pick up these credentials and use them.

Note: the test site is the GA account for `http://matthieu.net/blog`.

## UI Test

There is a UI test that is used to test the admin UI and the entire workflow for the plugin (except oauth configuration). Unlike
the system test it does not use the real Google Analytics API. Instead it uses the responses stored in `tests/resources/capturedresponses.log`.

The `capturedresponses.log` file is generated by running the system test with the **MATOMO_TEST_CAPTURE_GA_RESPONSES** environment variable. It will have to be
regenerated if the import process changes and new requests to GA are made or some requests are removed.