How to run PHPUnit tests in a Drupal 8 environment for custom modulesPhp warning when running Silverstripe tests in web browser. “phpunit/scr/Framework/TestResult.php” failed to openHow to run single test method with phpunit?phpunit in symfony2 - No tests executedUnit testing in PHPUnit with Twig installedPHPUnit test…to run in verbose mode in SymfonyDrupal 8: Debugging tests with XDebug and PHPStorm - cennot step throughPHPUnit test error, cannot find classPHPUnit Error: Class not foundPHPUnit configuring and running a group test [Laravel 5.6]Not able to run Drupal::service() in phpunit

Are these reasonable traits for someone with autism?

How to patch glass cuts in a bicycle tire?

Make 24 using exactly three 3s

Would Jetfuel for a modern jet like an F-16 or a F-35 be producable in the WW2 era?

Grammar Question Regarding "Are the" or "Is the" When Referring to Something that May or May not be Plural

Caught 2 students cheating together on the final exam that I proctored

Alignment: "Breaking out" of environment (enumerate / minipage)

Where is the logic in castrating fighters?

Gladys goes shopping

Does Nitrogen inside commercial airliner wheels prevent blowouts on touchdown?

Should one buy new hardware after a system compromise?

Have 1.5% of all nuclear reactors ever built melted down?

Why would Ryanair allow me to book this journey through a third party, but not through their own website?

Python program to find the most frequent letter in a text

Boss wants me to falsify a report. How should I document this unethical demand?

Which melee weapons have the Two-Handed property, but lack Heavy and Special?

How to know if a folder is a symbolic link?

Is it true that cut time means "play twice as fast as written"?

Is the derivative with respect to a fermion field Grassmann-odd?

Installed Tankless Water Heater - Internet loss when active

Why were helmets and other body armour not commonplace in the 1800s?

Why didn't Thanos use the Time Stone to stop the Avengers' plan?

Is the field of q-series 'dead'?

number headings



How to run PHPUnit tests in a Drupal 8 environment for custom modules


Php warning when running Silverstripe tests in web browser. “phpunit/scr/Framework/TestResult.php” failed to openHow to run single test method with phpunit?phpunit in symfony2 - No tests executedUnit testing in PHPUnit with Twig installedPHPUnit test…to run in verbose mode in SymfonyDrupal 8: Debugging tests with XDebug and PHPStorm - cennot step throughPHPUnit test error, cannot find classPHPUnit Error: Class not foundPHPUnit configuring and running a group test [Laravel 5.6]Not able to run Drupal::service() in phpunit






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to create and run PHPUnit tests for Drupal 8. Here are the details:



My top-level directory, where composer.json is located.



Dockerfile bootstrap.php composer.lock phpunit-examples phpunit.xml.org web
Jenkinsfile checkstyle.xml config phpunit.xml scripts
LICENSE components drush phpunit.xml.dist sonar-project.properties
README.md composer.json patches phpunit.xml.dist.org vendor


./vendor/bin/phpunit --version
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.



phpunit.xml.dist



<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
verbose="true"
>
<testsuites>
<testsuite name="unit">
<file>./tests/TestSuites/UnitTestSuite.php</file>
</testsuite>
<testsuite name="kernel">
<file>./tests/TestSuites/KernelTestSuite.php</file>
</testsuite>
<testsuite name="functional">
<file>./tests/TestSuites/FunctionalTestSuite.php</file>
</testsuite>
<testsuite name="functional-javascript">
<file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
</testsuite>
</testsuites>
</phpunit>


phpunit.xml



<phpunit
bootstrap="bootstrap.php"
colors="true"
strict="true"
verbose="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
checkForUnintentionallyCoveredCode="false">

<testsuites>
<testsuit name="Simple Example Test Suite">
<directory>phpunit-examples/tests</directory>
</testsuit>
</testsuites>
<php>
<ini name="error_reporting" value="32767"/>
<ini name="memory_limit" value="-1"/>
<env name="SIMPLETEST_BASE_URL" value="http://drupal-8.localhost"/>
<env name="SIMPLETEST_DB" value="mysql://drupal-8:drupal-8@localhost/drupal-8"/>
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/sites/default/simpletest"/>
<includePath>phpunit-examples/src/</includePath>
</php>
</phpunit>


custom code to be tested:
web/modules/custom/benefit/src/BenefitListBuilder.php



test located at:
web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php



<?php declare(strict_types = 1);

namespace DrupalTestsbenefit;

use Mockery;
use MockeryMockInterface;
use PHPUnitFrameworkTestCase;
use DrupalbenefitBenefitListBuilder;

/**
* Test basic functionality of My Module.
*
* @group benefit
*/
class BenefitListBuilderTest extends UnitTestCase

/** @var BenefitListBuilder */
private $benefitListBuilder;

protected function setUp()

$a = "var_a";
$b = "var_b";
$this->benefitListBuilder = new BenefitListBuilder($a,$b);


public function testMissing()

$this->fail('Test not yet implemented');




Now, i try to run just this test:



$./vendor/bin/phpunit web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php
PHP Fatal error: Class 'DrupalTestsbenefitUnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15

Fatal error: Class 'DrupalTestsbenefitUnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15


i tried moving the test under web/modules/custom/benefit/tests/src/Unit/BenefitListBuilderTest.php , but got same error.
How do i get the test to recognize the Path for UnitTestCase?



Update:
I have setup the repository in PHPStorm, so now i am getting error:



Error : Class 'DrupalTestsBenefitListBuilder' not found









share|improve this question






























    0















    I am trying to create and run PHPUnit tests for Drupal 8. Here are the details:



    My top-level directory, where composer.json is located.



    Dockerfile bootstrap.php composer.lock phpunit-examples phpunit.xml.org web
    Jenkinsfile checkstyle.xml config phpunit.xml scripts
    LICENSE components drush phpunit.xml.dist sonar-project.properties
    README.md composer.json patches phpunit.xml.dist.org vendor


    ./vendor/bin/phpunit --version
    PHPUnit 6.5.14 by Sebastian Bergmann and contributors.



    phpunit.xml.dist



    <?xml version="1.0" encoding="UTF-8"?>

    <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
    backupGlobals="false"
    colors="true"
    bootstrap="vendor/autoload.php"
    verbose="true"
    >
    <testsuites>
    <testsuite name="unit">
    <file>./tests/TestSuites/UnitTestSuite.php</file>
    </testsuite>
    <testsuite name="kernel">
    <file>./tests/TestSuites/KernelTestSuite.php</file>
    </testsuite>
    <testsuite name="functional">
    <file>./tests/TestSuites/FunctionalTestSuite.php</file>
    </testsuite>
    <testsuite name="functional-javascript">
    <file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
    </testsuite>
    </testsuites>
    </phpunit>


    phpunit.xml



    <phpunit
    bootstrap="bootstrap.php"
    colors="true"
    strict="true"
    verbose="true"
    beStrictAboutTestsThatDoNotTestAnything="true"
    beStrictAboutOutputDuringTests="true"
    beStrictAboutChangesToGlobalState="true"
    checkForUnintentionallyCoveredCode="false">

    <testsuites>
    <testsuit name="Simple Example Test Suite">
    <directory>phpunit-examples/tests</directory>
    </testsuit>
    </testsuites>
    <php>
    <ini name="error_reporting" value="32767"/>
    <ini name="memory_limit" value="-1"/>
    <env name="SIMPLETEST_BASE_URL" value="http://drupal-8.localhost"/>
    <env name="SIMPLETEST_DB" value="mysql://drupal-8:drupal-8@localhost/drupal-8"/>
    <env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/sites/default/simpletest"/>
    <includePath>phpunit-examples/src/</includePath>
    </php>
    </phpunit>


    custom code to be tested:
    web/modules/custom/benefit/src/BenefitListBuilder.php



    test located at:
    web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php



    <?php declare(strict_types = 1);

    namespace DrupalTestsbenefit;

    use Mockery;
    use MockeryMockInterface;
    use PHPUnitFrameworkTestCase;
    use DrupalbenefitBenefitListBuilder;

    /**
    * Test basic functionality of My Module.
    *
    * @group benefit
    */
    class BenefitListBuilderTest extends UnitTestCase

    /** @var BenefitListBuilder */
    private $benefitListBuilder;

    protected function setUp()

    $a = "var_a";
    $b = "var_b";
    $this->benefitListBuilder = new BenefitListBuilder($a,$b);


    public function testMissing()

    $this->fail('Test not yet implemented');




    Now, i try to run just this test:



    $./vendor/bin/phpunit web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php
    PHP Fatal error: Class 'DrupalTestsbenefitUnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15

    Fatal error: Class 'DrupalTestsbenefitUnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15


    i tried moving the test under web/modules/custom/benefit/tests/src/Unit/BenefitListBuilderTest.php , but got same error.
    How do i get the test to recognize the Path for UnitTestCase?



    Update:
    I have setup the repository in PHPStorm, so now i am getting error:



    Error : Class 'DrupalTestsBenefitListBuilder' not found









    share|improve this question


























      0












      0








      0








      I am trying to create and run PHPUnit tests for Drupal 8. Here are the details:



      My top-level directory, where composer.json is located.



      Dockerfile bootstrap.php composer.lock phpunit-examples phpunit.xml.org web
      Jenkinsfile checkstyle.xml config phpunit.xml scripts
      LICENSE components drush phpunit.xml.dist sonar-project.properties
      README.md composer.json patches phpunit.xml.dist.org vendor


      ./vendor/bin/phpunit --version
      PHPUnit 6.5.14 by Sebastian Bergmann and contributors.



      phpunit.xml.dist



      <?xml version="1.0" encoding="UTF-8"?>

      <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
      backupGlobals="false"
      colors="true"
      bootstrap="vendor/autoload.php"
      verbose="true"
      >
      <testsuites>
      <testsuite name="unit">
      <file>./tests/TestSuites/UnitTestSuite.php</file>
      </testsuite>
      <testsuite name="kernel">
      <file>./tests/TestSuites/KernelTestSuite.php</file>
      </testsuite>
      <testsuite name="functional">
      <file>./tests/TestSuites/FunctionalTestSuite.php</file>
      </testsuite>
      <testsuite name="functional-javascript">
      <file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
      </testsuite>
      </testsuites>
      </phpunit>


      phpunit.xml



      <phpunit
      bootstrap="bootstrap.php"
      colors="true"
      strict="true"
      verbose="true"
      beStrictAboutTestsThatDoNotTestAnything="true"
      beStrictAboutOutputDuringTests="true"
      beStrictAboutChangesToGlobalState="true"
      checkForUnintentionallyCoveredCode="false">

      <testsuites>
      <testsuit name="Simple Example Test Suite">
      <directory>phpunit-examples/tests</directory>
      </testsuit>
      </testsuites>
      <php>
      <ini name="error_reporting" value="32767"/>
      <ini name="memory_limit" value="-1"/>
      <env name="SIMPLETEST_BASE_URL" value="http://drupal-8.localhost"/>
      <env name="SIMPLETEST_DB" value="mysql://drupal-8:drupal-8@localhost/drupal-8"/>
      <env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/sites/default/simpletest"/>
      <includePath>phpunit-examples/src/</includePath>
      </php>
      </phpunit>


      custom code to be tested:
      web/modules/custom/benefit/src/BenefitListBuilder.php



      test located at:
      web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php



      <?php declare(strict_types = 1);

      namespace DrupalTestsbenefit;

      use Mockery;
      use MockeryMockInterface;
      use PHPUnitFrameworkTestCase;
      use DrupalbenefitBenefitListBuilder;

      /**
      * Test basic functionality of My Module.
      *
      * @group benefit
      */
      class BenefitListBuilderTest extends UnitTestCase

      /** @var BenefitListBuilder */
      private $benefitListBuilder;

      protected function setUp()

      $a = "var_a";
      $b = "var_b";
      $this->benefitListBuilder = new BenefitListBuilder($a,$b);


      public function testMissing()

      $this->fail('Test not yet implemented');




      Now, i try to run just this test:



      $./vendor/bin/phpunit web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php
      PHP Fatal error: Class 'DrupalTestsbenefitUnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15

      Fatal error: Class 'DrupalTestsbenefitUnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15


      i tried moving the test under web/modules/custom/benefit/tests/src/Unit/BenefitListBuilderTest.php , but got same error.
      How do i get the test to recognize the Path for UnitTestCase?



      Update:
      I have setup the repository in PHPStorm, so now i am getting error:



      Error : Class 'DrupalTestsBenefitListBuilder' not found









      share|improve this question
















      I am trying to create and run PHPUnit tests for Drupal 8. Here are the details:



      My top-level directory, where composer.json is located.



      Dockerfile bootstrap.php composer.lock phpunit-examples phpunit.xml.org web
      Jenkinsfile checkstyle.xml config phpunit.xml scripts
      LICENSE components drush phpunit.xml.dist sonar-project.properties
      README.md composer.json patches phpunit.xml.dist.org vendor


      ./vendor/bin/phpunit --version
      PHPUnit 6.5.14 by Sebastian Bergmann and contributors.



      phpunit.xml.dist



      <?xml version="1.0" encoding="UTF-8"?>

      <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
      backupGlobals="false"
      colors="true"
      bootstrap="vendor/autoload.php"
      verbose="true"
      >
      <testsuites>
      <testsuite name="unit">
      <file>./tests/TestSuites/UnitTestSuite.php</file>
      </testsuite>
      <testsuite name="kernel">
      <file>./tests/TestSuites/KernelTestSuite.php</file>
      </testsuite>
      <testsuite name="functional">
      <file>./tests/TestSuites/FunctionalTestSuite.php</file>
      </testsuite>
      <testsuite name="functional-javascript">
      <file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
      </testsuite>
      </testsuites>
      </phpunit>


      phpunit.xml



      <phpunit
      bootstrap="bootstrap.php"
      colors="true"
      strict="true"
      verbose="true"
      beStrictAboutTestsThatDoNotTestAnything="true"
      beStrictAboutOutputDuringTests="true"
      beStrictAboutChangesToGlobalState="true"
      checkForUnintentionallyCoveredCode="false">

      <testsuites>
      <testsuit name="Simple Example Test Suite">
      <directory>phpunit-examples/tests</directory>
      </testsuit>
      </testsuites>
      <php>
      <ini name="error_reporting" value="32767"/>
      <ini name="memory_limit" value="-1"/>
      <env name="SIMPLETEST_BASE_URL" value="http://drupal-8.localhost"/>
      <env name="SIMPLETEST_DB" value="mysql://drupal-8:drupal-8@localhost/drupal-8"/>
      <env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/sites/default/simpletest"/>
      <includePath>phpunit-examples/src/</includePath>
      </php>
      </phpunit>


      custom code to be tested:
      web/modules/custom/benefit/src/BenefitListBuilder.php



      test located at:
      web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php



      <?php declare(strict_types = 1);

      namespace DrupalTestsbenefit;

      use Mockery;
      use MockeryMockInterface;
      use PHPUnitFrameworkTestCase;
      use DrupalbenefitBenefitListBuilder;

      /**
      * Test basic functionality of My Module.
      *
      * @group benefit
      */
      class BenefitListBuilderTest extends UnitTestCase

      /** @var BenefitListBuilder */
      private $benefitListBuilder;

      protected function setUp()

      $a = "var_a";
      $b = "var_b";
      $this->benefitListBuilder = new BenefitListBuilder($a,$b);


      public function testMissing()

      $this->fail('Test not yet implemented');




      Now, i try to run just this test:



      $./vendor/bin/phpunit web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php
      PHP Fatal error: Class 'DrupalTestsbenefitUnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15

      Fatal error: Class 'DrupalTestsbenefitUnitTestCase' not found in /Users/syedahmed/BG-REPOS/PHPUNITTEST-BenefitsAPI/BenefitsAPI/web/modules/custom/benefit/tests/src/BenefitListBuilderTest.php on line 15


      i tried moving the test under web/modules/custom/benefit/tests/src/Unit/BenefitListBuilderTest.php , but got same error.
      How do i get the test to recognize the Path for UnitTestCase?



      Update:
      I have setup the repository in PHPStorm, so now i am getting error:



      Error : Class 'DrupalTestsBenefitListBuilder' not found






      phpunit drupal-8






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 25 at 19:07







      kamal

















      asked Mar 24 at 3:57









      kamalkamal

      4,3192380129




      4,3192380129






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320597%2fhow-to-run-phpunit-tests-in-a-drupal-8-environment-for-custom-modules%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320597%2fhow-to-run-phpunit-tests-in-a-drupal-8-environment-for-custom-modules%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현