2022 Developer Survey is open! Take survey.

Questions tagged [tests]

Questions related to checking things: unit tests, performance tests, A/B testing, etc.

Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

How to dump the db for running testing function

I want to set up the db for running testing function. I don't want to dump the whole db but just with the required table structure and records. Probably need to do it again if any new field has beed ...
user avatar
  • 27
0 votes
0 answers
9 views

Craft tests - FieldFixture - why does it manually adds and removes fields?

I was chcking out craft testing classes and notices that FieldFixture has custom load and uload methods that manually create and remove fields. Fixtures should add data and then remove it ...
user avatar
  • 1,185
0 votes
0 answers
8 views

Testing fixtures - grabFixture method returns null

I set up codeception tests and copied some fixtures from Craft repository. Within unit test class, i can access fixtures data of elements, for example for EntryFixture. I use this code, where entries ...
user avatar
  • 1,185
2 votes
1 answer
24 views

Plugins with extensive tests

What are Craft plugins with extensive (codeception) tests in their repositories? I want to look at working examples. I also know that Craft repo itself and Commerce have tests set up.
user avatar
  • 1,185
0 votes
0 answers
27 views

Testing adding fields to an entry type field layout

I'm writing unit tests for a plugin that reacts to adding fields to field layouts, I'm trying to add fields to a layout programmatically but can't get anywhere, In the example below (method ...
user avatar
  • 31
1 vote
1 answer
31 views

Install a plugin in a unit test

I'm writing some unit tests for a plugin I've made using codeception. I need to test the installation of another plugin during a test. Defining the plugin in codeception.yml doesn't work, the plugin ...
user avatar
  • 31
0 votes
0 answers
12 views

Why is $I->submitForm() always loading the homepage in functional tests?

For some reason whenever I try to use $I->submitForm() in functional tests for a form on the homepage, the homepage is loaded instead of the form action no matter what the form action is set to. I'...
user avatar
  • 1
3 votes
1 answer
183 views

How do you unit test plugins?

I have Codeception running on my local install without errors, but it's not yet actually doing anything. I am building several plugins and I can't figure out how you actually test a plugin? I have no ...
user avatar
1 vote
1 answer
83 views

How do you save custom fields on an EntryFixture?

I can't for the life of me figure out how to setup EntryFixtures in craft to populate with custom fields. I'm using the project config which already has the sections and fields defined in my tests. I'...
user avatar
1 vote
2 answers
237 views

Namespace error with fixture (solved)

I've set up a fixture, but Codeception can't find it. What am I missing or doing wrong? % php vendor/bin/codecept run functional ... ...
user avatar
  • 228
4 votes
0 answers
136 views

Testing / Fixtures: setup Entries in Structure

Background: I have experience with vanilla PHPUnit testing of projects, but this the first attempt at both testing a Craft project and using Codeception for testing. Case: I have a section of type ...
user avatar
  • 141
1 vote
0 answers
105 views

What the best strategy to test Craft template?

I would like to know if there is a way unit test templates using Craft 2.5? For example trying to prevent null pointers happening in production when an image is remove from the entry
user avatar
  • 231
2 votes
1 answer
344 views

Unit Testing with current version of Craft

Has Craft stopped shipping with unit tests? I'm trying to unit test a plugin and have noticed from several previous answers (e.g PHPUnit testing for Craft plugins or controllers) that it was possible ...
user avatar
  • 205
2 votes
2 answers
626 views

Stub out the global craft() object for PHPUnit tests

As best I can tell, the 'mockBuilder' function is exactly what I want, and based on other examples, should work. Am I missing something? How can I stub out the global craft() object? under test: &...
user avatar
  • 141