For questions regarding automated Drupal tests (Simpletest). These include questions regarding DrupalWebTestCase, DrupalUnitTestCase, WebTestBase and UnitTestBase.

learn more… | top users | synonyms

0
votes
0answers
16 views

Running PHPUnit test from CLI and debug in PhpStorm: Remote file path '/directory/path/-' is not mapped to any file in project

I'm trying to execute a PHPUnit test via the CLI to debug in via PhpStorm, being on a Ubuntu 16.04 operating system. It's a KernelTestBase unit test for Drupal 8. The normal execution of the test - ...
0
votes
1answer
20 views

Dependency Injection while Unit Testing

Normally with Drupal 8 I can use dependency injection like this: <?php class ExampleController extends ControllerBase { private $http_client; public function __construct(HttpClient $...
0
votes
1answer
16 views

feeds_ex module tests returns me fatal error

When I am running feeds_ex test i got an error that says: PHP Fatal error: Class 'TUnit' not found in /sites/all/modules/contrib/feeds_ex/src/Tests/FeedsExUnitTests.test on line 11 I am looking ...
0
votes
0answers
28 views

Debugging JavaScript tests

Recently started working on some JavaScript tests by extending JavascriptTestBase in drupal 8.2 and the biggest problem currently is debugging. Phantomjs is installed and i have no problem running ...
0
votes
0answers
21 views

Running tests on fresh 8.2.x install throws “Permission Denied” for Kernel tests

Under a fresh install of 8.2.x, when I run tests, only Kernel tests seem to fail with this message from the testing UI: (path/to/test/Kernel/test.php) ... Permission denied Pretty much any Kernel ...
0
votes
1answer
18 views

Running module unit tests from CLI: “Class '..' could not be found”

I am trying to run module-provided PhpUnit tests from the CLI. Following these instructions, so my core/phpunit.xml should be correct now. Using this command: cd core ../vendor/bin/phpunit modules/...
0
votes
1answer
20 views

PluginNotFoundException: The “user” entity type does not exist

I am trying to return the common parent of 2 entities from their revision graph. For ex: 1->2->3->4->5 is a linear graph with 1 as original node and rest all are revisions. So, I wrote a function to ...
2
votes
1answer
39 views

Why am i getting PDO exception while running the following test from console?

I am writing a module to return common parent of 2 revision in a linear entity. For example : After editing a node 5 times, we get a graph similar to 1->2->3->4->5 where 1 is the actual node and 5 is ...
0
votes
0answers
46 views

How can I debug Simpletests for a custom module?

I am struggling to debug PHPUnit Tests (with xdebug) in a custom D8 Module from PHPStorm or via the command line. Is it possible to do this? I'm running an Acquia Bolt generated site on a Drupal-VM ...
0
votes
1answer
31 views

Drupal 7, login, “form_build_id” not used?

I write some functional tests for my website. I have this test : go to login page post username/pass/form_build_id check if the user is connected In the test script, my form-build-id is "hardcoded"...
0
votes
1answer
36 views

Testing an update hook that updates fields?

I wrote an update hook for a site that moves data from one field to another. It looks a lot like this gist: foreach ($node_ids as $node_id) { try { $node_wrapper = entity_metadata_wrapper(...
3
votes
1answer
47 views

How to inject a fake class into container when running WebTestBase tests?

I've got a form class, and I'm injecting my custom functionality class into it via constructor. That class is added to the container via the services.yml file defined in my custom module. I'd like to ...
1
vote
1answer
40 views

How to see if the test works?

There is a way to see if the Drupal tests are working? I wanted to test the FileSystemTest, but when I type phpunit command on the test folder this error appears: 1) Drupal\Tests\Core\File\...
1
vote
1answer
88 views

Why is my unit test not detected?

I have a custom Drupal 8 module for which I'm trying to create unit tests by following the instructions at https://www.drupal.org/phpunit. The path of my module is: /modules/custom/dev_module The ...
0
votes
1answer
27 views

Error executing PHPUnit

I was trying to write PHPUnit test in D8, but am blocked due to a weird issue which I am not able to track. The module for which I am writing the test is at https://github.com/ajitdev/phpunit_d8 I ...
1
vote
0answers
75 views

How to unit test custom console ContainerAwareCommand in Drupal 8

I have a custom console command that extends Drupal\Console\Command\ContainerAwareCommand. Inside the command I need to access the container to fetch a service. But now I'm struggling with figuring ...
0
votes
1answer
18 views

With the core testing, how do I set a database variable?

I am trying to establish a test suite for my project using the core testing module. But I can't get past such a trivial thing as setting a database variable. A lot of tutorials on the web tell you to ...
1
vote
1answer
30 views

Proper directory layout for tests

I'm coming across what seems to be contradictory information, and I'm hoping someone here can clarify. The basic question is "what is the correct folder structure for PSR-4 style auto-discovery of ...
1
vote
1answer
23 views

Is it possible to write test against the current database?

I'm building some modules onto an existing and somewhat active site. From my understanding, SimpleTest creates a new, temporary database and effectively reinstalls a copy of Drupal. However, I'd ...
1
vote
0answers
31 views

Selenium IDE for testing Drupal 7 with Media and Paragraphs

I'm writing Selenium IDE tests for my Drupal 7 site and it's great. The issue is recording/writing tests for actions that aren't simple "clicks". I have instructions for using the RunScript action to ...
0
votes
0answers
31 views

Using variable_get from DrupalWebTestCase

I would like to pull certain configuration items from settings.php from a DrupalWebTestCase in order to test my module (in this case, a SFTP module). I want to do it this way so that I don't hardcode ...
0
votes
0answers
20 views

How can i import views in drupal web testcases?

I have created a view by using the views bulk operations module and wrote the code for when bulk operations are done through view mails are sent to users,this code wrote in custom module. Now i have ...
0
votes
2answers
94 views

How do I inspect mail messages in Behat tests?

I am writing a Behat Scenario that checks that an email generated by the Drupal system under test is sent to the correct recipient but I [could not] capture the mail messages from test_mail_collector....
1
vote
2answers
79 views

Run Simpletest tests on Jenkins

I am trying to run a group of tests(Simpletest) for my custom modules through Jenkins. Firstly I tried drush test-run (...) which has been removed from drush. Then I tried php scripts/run-tests.sh --...
1
vote
1answer
46 views

Should QA engineers directly update Drupal database tables via SQL?

Is it generally accepted that it's ok in the Drupal community for QA testers to directly update and delete data in Drupal core tables via SQL? Or is it considered a bad practice? I'm talking about non-...
1
vote
1answer
151 views

Can the Devel Generate module generate content for all possible permutations and combinations?

I love the Devel Generate module as it helps me to create test content very quickly. Random content that the module generates is sufficient most of the times. But at times I would like to have ...
1
vote
1answer
93 views

How to add a view dependency to a Drupal 8 functional test

I'm working on a contrib module port to Drupal 8 and am currently adding additional test coverage (#2586125). The module provides both a field formatter and a views style plugin. I have good working ...
0
votes
0answers
11 views

How to refresh a drupalGet() request in a test case?

My test case checks a particular page (/filter/tips, specifically) both before and after changing the site configuration. If I comment out the first drupalGet() call, it works. If the page in ...
0
votes
0answers
29 views

How to run web test cases in Drupal Console

Whenever I attempt to run a test class extending WebTestBase from the Drupal console (via console test:run --url <Url> <ClassName>), the test case fails to create some site folders (...
0
votes
0answers
19 views

Is there a way to test instantiating a service in an isolated unit test?

I have the a service definition in a custom Drupal 8 module which I would like to test. I've managed to test everything else in my module with unit tests, so my whole suite runs in a fraction of a ...
0
votes
1answer
61 views

adding a contrib dependency to simpletest

Is it possible? I am trying to contribute to a drupal module (first time) and I have uploaded a patch. But the test keeps failing because of an unmet dependency on the libraries API. I have added the ...
1
vote
1answer
32 views

Create a mock Form for WebTestBase?

Is there a way in the testing framework to define a generic form intended only when tests run? I have created some custom form item Element classes. I have working Unit tests with them, but I would ...
1
vote
1answer
132 views

Error running a PHPUnit test only under run-tests.sh

I'm working on an 8.x module that uses PHPUnit tests. I've been running these from the command line using the embedded phpunit script that's installed with Drupal 8: ../vendor/bin/phpunit PATH/TO/MY/...
2
votes
1answer
413 views

Which version of Behat (Guzzle) would be okay to use on a RHEL server with PHP 5.4?

On a Red Hat Enterprise Linux Server release 7.1 (Maipo) development server using [Behat Drupal Extension][1], a RHEL 7 / PHP 5.4 installation. When I try to run behat from the command line on a dev ...
0
votes
1answer
82 views

Debugging your code under SimpleTest when the behavior is different

I'm dealing with a weird problem where a few of my tests are dying from exceptions when run inside of SimpleTest, but I'm unable to reproduce the problem outside of the SimpleTest environment. In ...
0
votes
0answers
16 views

Simpletest drupalGetMails()

I am testing my cusom module and sending two Emails in one function. Emails are being send and I can see them in xampp/mailoutput but $this->drupalGetMails() returns an empty array. The Emails are ...
0
votes
0answers
56 views

Attempt to create an instance of a field field_image that doesn't exist or is currently inactive

I am having a custom module with hook_install(), custom content types and fields are created. When I try to add instance of a field_image to my custom content type, I get the error message: ...
0
votes
1answer
45 views

Update custom fields on hook_user_login

I have implemented hook_user_login(&$edit, $account) and some of custom fields from $account should be updated. I am doing this with user_save(). These changes are not visible in Simpletest. I ...
0
votes
1answer
89 views

How can I write users table data in custom file?

I have a number of users in my site,I have developed custom module for drupal mail functionality. But I want to write test cases for custom module. then here is the problem is how can I get the (...
3
votes
1answer
52 views

How to test Drupal distributions and see examples

Is there a way to see Drupal distributions already installed for testing as demo sites? I was searching drupal.org, where I only found 'case studies'. Sites there are sorted only by categories, not by ...
0
votes
1answer
93 views

How to write a simple test case for users by using drupal_mail() function?

I have written a custom module for sending email to registered users. And I want simple test case for that users email module. In this module I am taking a user from database and selected users ...
1
vote
1answer
23 views

Are tests built into contrib modules a reliable way of testing the success of a module upgrade?

I have been updating some modules including Views and Feeds. Given these modules are quite complex, I thought a good method of testing whether the update was successful or not was to run the tests ...
1
vote
1answer
31 views

module_load_include fails on WebTestCase post

I am writing test cases for my website using SimpleTest module. One of my test cases uses the following sequence $this->drupalGet( "myurl" array('query' => $params)); $this->...
0
votes
1answer
69 views

Unit testing on windows

I hope this question is not very naive, the problem is that in Drupal 8 there are several unit tests written for modules and I want to test them. But since I am on windows os I am not able to figure ...
0
votes
1answer
108 views

PHPUnit with custom/contrib and submodules structure

I am starting to write our tests with PHPUnit on Drupal 8, and I am not sure about the best practices with the phpunit.xml.dist file. We separates the custom and the contrib modules using two ...
0
votes
1answer
123 views

Functional testing without using simpletest

I have recently joined a Drupal project at work that is approx 50% finished. Functional testing was never part of the project. The site has about 8 custom modules and they are not going to be used ...
1
vote
0answers
41 views

Fatal Error while sending a multipart POST request to a image upload created using Field API

While testing a site i created using "Acunetix" web vulnerability scanner, it posted a multipart request to a image upload field created using Field API. The test manipulated a POST statement and ...
0
votes
2answers
39 views

Is there an efficient easy way to test Drupal code while developing it?

While writing code making sure, for example, I'm access the correct array property I keep refreshing the browser.(Or, that I didn't make a semantic mistake like that last sentence but in code) Is ...
1
vote
1answer
18 views

How do I run Drupal SimpleTest example from Examples for Developers from the CLI?

I've been running tests from a helper_module_preprocess_html function that I trigger on reload. I think I need to level up with testing. I have a vanilla installation of Drupal, downloaded and enabled ...
0
votes
1answer
22 views

Different page appear when testing

What I want to do is checking whether a link is exist on frontpage. I've set up a content with with node id 5 as my frontpage. But when testing it, and see the verbose message (http://screencast....