unit testing admin password
The password is … password. You can see that in includes/install.php: wp_install( WP_TESTS_TITLE, ‘admin’, WP_TESTS_EMAIL, true, null, ‘password’ ); The last parameter is the admin password.
The password is … password. You can see that in includes/install.php: wp_install( WP_TESTS_TITLE, ‘admin’, WP_TESTS_EMAIL, true, null, ‘password’ ); The last parameter is the admin password.
The problem is not that the factory class is unavailable, because if that were so you would be getting a fatal “class not found” error. The problem is that you aren’t using your test case properly. This code (and similar) is what is causing the problem: /** * Testing that timeline_express_get_announcement_date() returns what we expect … Read more
I used WP_Mock for a long time, until I built Brain Monkey to overcome some problems I found working with it. Using Brain Monkey you can: use Brain\Monkey\Functions; Functions::when(‘get_adjacent_post’)->alias(function() { // mock here… }); or Functions::expect(‘get_adjacent_post’) ->atLeast() ->once() ->with( true, ”, true, ‘topic’ ) ->andReturnUsing(function( $in_same_term, $excluded_terms, $previous ) { // mock here }); This … Read more
I think the main problem here is that you are loading WordPress’s bootstrap too early. Changing to this should fix it (I’ve interspersed comments explaining why things are in the order they are in): // This file contains tests_add_filter(), so we need to load it // so that we can hook the _manually_load_plugin() function to … Read more
I have a setup similar to yours, with MAMP. I also have had this problem with PHPUnit. It seems that no matter what you do, PHPUnit does not recognize the include_path from MAMP. You have to add the correct path to the php.ini in /private/etc/.
Can’t get the phpunit core test for WordPress to work [closed]
Rather than worrying about the internal implementation of the menu code and the globals that it uses (there are several beside $menu), I’d use a function like menu_page_url() to check if the page exists. That function will return the URL if the menu is registered, or an empty string if it is not. So you … Read more
Call wp_set_current_user($id) to make a user ID the currently logged in user.
Your best bet to set up a reusable test environment on a Windows machine is to use Vagrant with a setup such as this. Vagrant will allow you to build portable, reusable virtual machines with a very simple interface which you can use across different operating systems and team members. To set it up, you … Read more
Just few notes: Looks like you’re doing functional/integration tests rather than unit tests in isolation. Here you’re creating a user, but not setting it as the current one: $user = $this->factory->user->create(); wp_set_current_user( 1 ); You probably want: $user_id = $this->factory->user->create(); wp_set_current_user( $user_id ); Note that cookies aren’t set here, because of: tests_add_filter( ‘send_auth_cookies’, ‘__return_false’ ); … Read more