0

In my phpunit test I require_once an api_key.php that of course I have in my .gitignore (it contains my own api keys).

<?php
namespace Domoticzapi;

use PHPUnit\Framework\TestCase;

require_once('api_key.php');

class ClientTest extends TestCase {
}

Scrutinizer complains with

PHP Warning:  require_once(api_key.php): failed to open stream: No such file or directory in /home/scrutinizer/build/tests/Domoticzapi/ClientTest.php on line 6

How can I exclude this check? Or is there a best approach (other than environment variables that I don't want use)?

sineverba
  • 5,059
  • 7
  • 39
  • 84
  • If you changed to an `include_once` it won't fail. (or won't fail because of the `require` if you still need something from there it will fail later) – user3783243 Jun 19 '18 at 20:47
  • I will try... Thank you, for the moment I did esclude entire /test folder – sineverba Jun 19 '18 at 20:48
  • Is there a specific reason why you have api keys required in your test cases? – Devon Bessemer Jun 19 '18 at 21:19
  • 1
    Test the code, without doing real calls, use fixtures, so you shouldn't need keys. – Lawrence Cherone Jun 19 '18 at 21:20
  • @Devon cause the api I'm consuming sometime are broken/changed. So test unit also to test if values are right. Another path in my mind. Is possible to serve to Scrutinizer different ClassTest ? Cannot find a clear docs.@LawrenceCherone – sineverba Jun 19 '18 at 21:37
  • The right path is write another test unit. But Scrutinizer want perform the test that I don't want. I did open a more precise question: https://stackoverflow.com/questions/50937828/scrutinizer-and-specific-test-from-phpunit – sineverba Jun 19 '18 at 22:44

1 Answers1

1

AFAIK, you need to set your test command on scrutinizer-ci config file to run just the suite test you need, or provide new phpunit config without the suite that contain those test that need api_key.php

refer to this: How to run a specific phpunit xml testsuite? https://scrutinizer-ci.com/docs/build/running_tests_in_parallel

Charis
  • 419
  • 5
  • 12
  • I did create another question, more precise, following your path. Cannot get my goal. Please, see: https://stackoverflow.com/questions/50937828/scrutinizer-and-specific-test-from-phpunit – sineverba Jun 19 '18 at 22:43