Skip to content

Running Functional Tests

Caitlin Bales (MSFT) edited this page Jan 11, 2018 · 2 revisions

Running Functional Tests

What they do

The functional tests are written to hit the API service directly, instead of mocking responses with Guzzle. This allows us to verify that a workload (Outlook, Excel, etc.) can perform its key scenarios successfully using the PHP SDK.

When to run them

To contribute general improvements to the SDK, it is not necessary to run the functional tests. Currently, these tests are ignored by CI. However, if you are making large changes or are contributing helper methods to a specific workload, you can run these to ensure live calls continue to work as expected.

How to run the tests

The functional tests use the resource-owner credential flow to authorize a user. This flow has been deprecated in the v2 auth portal (apps.dev.microsoft.com). You must instead register an application through the v1 AAD auth portal (portal.azure.com).

  1. Create a demo tenant to use for the tests (Highly Recommended)
    • The tests require an O365 tenant and have a few instances where they do not clean up after themselves completely
    • You can get a free O365 developer tenant by registering at dev.office.com
  2. Register a new application on your tenant
    • Follow advice listed here
    • Select "Native Application". The redirect URI will not be used
    • Assign access to Graph by clicking "Settings > Required permissions > Microsoft Graph". You will need access to most of the privileges listed, so select all delegated permissions. Then click "Grant Permissions" in the Required permissions blade to consent.
  3. Set three environment variables on your machine:
    • client_id: the app ID you received upon app registration
    • test_username: a valid email address to access the tenant
    • test_password: the corresponding password for the provided username
  4. Run vendor/bin/phpunit --group functional
    • There are a few known issues that may cause a handful of tests to fail