Skip to content

Instantly share code, notes, and snippets.

@jeroenvdgulik
Last active February 18, 2017 12:10
Show Gist options
  • Select an option

  • Save jeroenvdgulik/c693d3f37b76efb66a55a2b50944c499 to your computer and use it in GitHub Desktop.

Select an option

Save jeroenvdgulik/c693d3f37b76efb66a55a2b50944c499 to your computer and use it in GitHub Desktop.

Revisions

  1. jeroenvdgulik revised this gist Feb 6, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion 3_hack_composer.php
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,9 @@ class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
    }


    // In your composer.json We can misuse composer autoloading. Add the following:
    // In your composer.json We can misuse composer autoloading.
    // much thanks to @WyriHaximus who pointed it out.
    // Add the following:

    "autoload-dev": {
    "files": [
  2. jeroenvdgulik renamed this gist Feb 6, 2017. 1 changed file with 9 additions and 7 deletions.
    16 changes: 9 additions & 7 deletions 3_hack_composer.json → 3_hack_composer.php
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,18 @@
    <?php

    // Create a file in /tests/alias.php at the root of your symfony project containing:

    if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
    }

    // We can also misuse composer autoloading

    // In your composer.json We can misuse composer autoloading. Add the following:

    "autoload-dev": {
    "files": [
    "tests/alias.php"
    ]
    },

    // Create a file in /tests/alias.php at the root of your symfony project containing:

    <?php

    if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
    }
  3. jeroenvdgulik revised this gist Feb 6, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions 3_hack_composer.json
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@

    // Create a file in /tests/alias.php at the root of your symfony project containing:

    <?php

    if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
    }
  4. jeroenvdgulik revised this gist Feb 6, 2017. 3 changed files with 16 additions and 1 deletion.
    File renamed without changes.
    3 changes: 2 additions & 1 deletion second_alternative.php → 2_alternative_bootstrap.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    <?php

    // Or alternatively if you use your own bootstrap file, just add this line
    // Alternatively if you use your own bootstrap file, just add this line:

    if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
    }
    14 changes: 14 additions & 0 deletions 3_hack_composer.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@

    // We can also misuse composer autoloading

    "autoload-dev": {
    "files": [
    "tests/alias.php"
    ]
    },

    // Create a file in /tests/alias.php at the root of your symfony project containing:

    if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
    }
  5. jeroenvdgulik revised this gist Feb 6, 2017. No changes.
  6. jeroenvdgulik renamed this gist Feb 6, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. jeroenvdgulik created this gist Feb 6, 2017.
    6 changes: 6 additions & 0 deletions alternative.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    <?php

    // Or alternatively if you use your own bootstrap file, just add this line
    if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
    }
    16 changes: 16 additions & 0 deletions bootstrap.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <?php

    // create a file in /tests/bootstrap.php at the root of your symfony project

    $loader = require(__DIR__ . '/../app/autoload.php'); // or whatever path your autoload.php is in
    if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
    class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
    }
    return $loader;

    // In your phpunit.xml or phpunit.xml.dist change:

    bootstrap="app/autoload.php"

    // to
    bootstrap="tests/bootstrap.php"