Comments (6)
See PR#30 for fix
from wp-browser.
I've closed the PR not out of spite but to open one that deals with my code only and not the one that's in src/includes
.
Could you paste a piece of the code you are testing to have a context?
from wp-browser.
This is a case I often have because I like regrouping all my exception/error handling for a given case in a single test. Arguably not the best practice but usually they look something like this:
public function testExperimentSaveFailures()
{
global $experiments_model;
$testExperiment = $experiments_model->createPendingExperimentModel('SaveAjaxTest', $this->validAccountId, $this->validPropertyId, $this->validViewId);
try
{
// No experiment Id
$this->_handleAjax('save_experiment');
}
catch(WPAjaxDieContinueException $e)
{
$response = json_decode($this->_last_response);
$this->assertNotNull($response);
$this->assertNotEmpty($response->error);
}
$_POST['experimentId'] = $testExperiment->getDBId();
try
{
// No name
$this->_last_response = NULL;
$this->_handleAjax('save_experiment');
}
catch(WPAjaxDieContinueException $e)
{
$response = json_decode($this->_last_response);
$this->assertNotNull($response);
$this->assertNotEmpty($response->error);
}
...
from wp-browser.
These should be, in strict TDD terms, all be different test cases.
If one of the tests is not throwing the test will pass; I'd separate them and use $this->setExpectedException
in each. This way you are making sure an exception is thrown when you expect it to. Something like this:
public function testExperimentSaveFailsWithNoID() {
global $experiments_model;
$testExperiment = $experiments_model->createPendingExperimentModel('SaveAjaxTest', $this->validAccountId, $this->validPropertyId, $this->validViewId);
$this->setExpectedException('WPAjaxDieContinueException');
$this->_handleAjax('save_experiment');
$response = json_decode($this->_last_response);
$this->assertNotNull($response);
$this->assertNotEmpty($response->error);
}
and replicate for each.
I'm not keen on introducing such a method but I'm open to a contextualised and well done PR.
from wp-browser.
Sure this is another approach but it's besides the point. I see no reason why a functional test should not have multiple Ajax calls in a single test.
I can just create my own helper to fix this simple problem but others might also want it...
from wp-browser.
I'm not keen on introducing such a method but I'm open to a contextualised and well done PR.
Well: make it and open a PR!
from wp-browser.
Related Issues (20)
- grabWordPressAuthCookie pattern in HTTPS HOT 5
- amOnAdminAjaxPage isn't working as expected ! HOT 4
- [SETUP ISSUE] Suite cannot be identified from the debug backtrace. HOT 1
- [SETUP ISSUE] wp-browser v4 wp-config file parsing issue HOT 5
- [DOC REQUEST] v4 migration guide HOT 4
- [BUG] Invalid Chrome binary: not executable or not existing on init command HOT 5
- [BUG] Could not parse the wp-config.php file HOT 5
- [BUG] Unknown operation: MODIFY on woocommerce activation HOT 9
- [FEATURE REQUEST] Implement wp-test-utils for unit and integration tests HOT 3
- [BUG] @testdox annotation not working for test descriptions HOT 3
- [BUG] Default integration test suite fails with Class "lucatume\WPBrowser\Process\SerializableThrowable" not found error HOT 1
- [BUG] ChromeDriver binary "\vendor\bin\chromedriver" does not exist on Windows HOT 2
- [BUG] Invalid database name on Windows when using SQLite HOT 2
- [BUG] Git Hub Pages are Down? HOT 1
- [BUG] "Could not find a WordPress installation" error when initialising a plugin HOT 1
- [BUG] `amEditingUserWithId()` method missing from v4 HOT 1
- [BUG] Ajax tests fail HOT 2
- [BUG] Tests fail when being run from phpstorm HOT 3
- https://wpbrowser.wptestkit.dev/ not working HOT 1
- [FEATURE REQUEST] Add (grab|see)TransientInDatabase methods to WPDb
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-browser.