Closed (fixed)
Project:
Scheduler
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
16 Oct 2015 at 10:44 UTC
Updated:
24 Jul 2016 at 15:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
pfrenssenComment #4
pfrenssenGot them to show up in the Simpletest UI, but when I try to run them the test runner hangs.
Comment #5
jonathan1055 commentedHi Pieter,
You probably know this already, but it looks like we need to convert
scheduler_test.infotoscheduler_test.info.yml. The test log appears ok down to a pointI've only just now taken my first look at D8 code and testing, so please excuse me while I learn and catch up, and apologies if I say things you are already aware of.
Jonathan
Comment #6
jonathan1055 commentedNow, I think I am wrong. We only need a .info.yml file if the tests are contained in a separate 'testing' module. I will keep investigating.
Comment #7
jonathan1055 commentedPieter,
Are your commits above included in the latest -dev release from 14th Oct. I started looking at the test files but it seems not all of the changes are there, for example splitting the classes into different files.
No hurry for a reply as I won't be able to work on this over the weekend.
Jonathan
Comment #8
jonathan1055 commentedAh, I see that you made the commits in #2 on 16th October but the latest 8.x dev release on our project page is 14th October. I have not been keeping up with how you are running things - is there more than one branch on 8.x and your test changes are not available for download yet?
Comment #9
pfrenssen@jonathan1055 since I was working mostly alone on these issues I have been committing work in progress in feature branches. This code can be found in branch 2594615, so if you just check that out you should see it. The feature branch workflow works pretty good I found, one thing to keep in mind is to start each commit message with "Issue #123456: ..." so that the commits are included as comments in the issue.
If you prefer to post patches that perfectly fine too of course, the patch based workflow and feature branch workflow can work together.
Comment #10
hugronaphor commentedJust wanted to point to you guys that this test is blocking any other ticket as the tests are failing and the issue status is automatically changed to "Needs review" (as commits in drupal 7 are going after checking through 8.x version).
e.g: https://www.drupal.org/node/2597233
Comment #11
jonathan1055 commentedThanks hugronaphor. Yes, this is now a high priority I think.
By the way, did you know that you can refer to an issue using [# 2597233] to give #2597233: The FALSE value for #group FAPI property does not have expected behaviour which shows the title and status.
Pieter, you have plenty to do, and I am just starting on the 8.x issues, so I have assigned this to me. I need to work out how to work on that branch, not the head, but that's all part of the great git learning.
Comment #12
jonathan1055 commentedI've applied the patches to remove variable_set and variable_get from the new test files in branch 2594615. The test show up in the Simpletest list and they start running. However, I get a fatal error:
The above is for SchedulerDateCombinedFunctionalTest.php in line 56, but I also get the same error in SchedulerFunctionalTest.php.
Any suggestions or ideas would be welcome. I may commit the changes I've made so far, on this branch, as they are definitely required, even though the tests don't work yet. Is that OK?
Comment #13
joshi.rohit100@jonathan1055 - It seems like you are not enabling the node module, that's why this error is showing up.
Comment #14
jonathan1055 commentedThanks Joshi. Actually, it appears that I was not enabling any modules :-) I've just taken over this task from Pieter and I had not checked in detail how far he'd got on https://www.drupal.org/node/2166895 The files have been moved, split up and renamed, but the modules are no longer enabled by
but it is now
In D7 we did not explicitly enable the node module, but enabling 'node' in this way does remove the error. Thanks!
Attempting to enable scheduler gives errors in
views.view.scheduled_content:displaybut atleast we are now making progress.Comment #15
jonathan1055 commentedI had managed finally to remove all the fatal errors which prevented the tests from running, and got the tests to finish! (not all passes, but that's a separate issue). It involved:
I had wondered if the views problem was because I was on D8 beta-11 so decided to update to the latest rc-3. I did not know that this would require updating my PHP from 5.4 to 5.5, so that add a bit of delay. Then the issue of !message placeholders being invalid caused more trouble. At the moment I cannot run tests because the existing devel quite has ! errors, but the latest devel causes WSOD. I have never had a smooth D8 upgrade, it is always heart-bleedingly tedious with poor messages (or none) and lots of effort expended. I hope that now we are on RC3 it will be slightly more stable.
I am considering merging this work into the main 8.x so that we can see how D.O. tests cope with the changes. Many other issues will be easier to follow when we get testing running, so I do not think it need to be in a separate branch anymore, particularly as that involves re-applying patches and commits that have been done to master.
What does everyone else think about this?
Comment #16
pfrenssenI'm not sure if the DrupalCI test bots already test D8 code for contrib projects at the moment.
I've been following D8 development for a while now and I have very little problems. I seem to have settled in a good workflow, I guess it just takes a bit of time to get used to it. I'm not using devel a lot lately so I'm not aware of any issues with that. I tend to do a lot of reinstalls, and I make sure that my drush is updated weekly. Also make sure you put your installation into "development mode", by commenting out the
file_exists(__DIR__ . '/settings.local.php'))part in settings.php, and copying the example.settings.local.php file over.BTW I'm really interested to see the code! Could you for the moment push your work to the 2594615 branch so I can take a look before merging it into 8.x?
Comment #17
jonathan1055 commentedI've now realised I do not need to use Devel for testing (of course it is in core). I think I forgot because I saw that 'Testing' is in the 'Development' block on the main configuration page. Thanks for the hint about development mode, although I think I had many of those settings set anyway.
With my code changes so far:
I wil push the work to this branch, and try to do it in several commits, so that the changes can be noted. Some will be repeats of fixes done on the master branch, but I guess we can sort that out when we come to merge the branches.
I think they do, as I have seen it for other modules, but probably not for branches, only for the master. That's why it would be nice to get this branch merged in sometime soon.
Comment #18
jonathan1055 commentedArgHHHH!!! I tried to push my commits to this branch, but I think I have succeeded only in deleting the branch.
I used
which is wrong (I now know) and has deleted the branch. I don't know if it had deleted it on my copy only (I hope) or the remote one aswell.
Comment #19
jonathan1055 commentedI think I have deleted the remote branch, as trying to view the commit links by Pieter in #2 above give a blank. But my local files and changes are all intact, and it seems I still have branch 2594615 in my local repository. So the work is not lost. I added and committed changes to four files out of the nine, and I'm not sure where those changes have been stored. Any help would be very much appreciated in working out what to do next. Can we re-create the branch in remote repository, then I push these changes to it? (properly this time) and also re-do the changes made in #2.
Comment #21
jonathan1055 commentedPhew! Git is great. I've recovered the branch and it is showing on http://cgit.drupalcode.org/scheduler and the earlier commits have reappeared above, plus my new one. There will be a few more to follow.
Comment #22
pfrenssenWell done on recovering the branch!
Am looking at the work now. Amazing that they are running. If I run them through the CLI tool (run-tests.sh) I can get a full test run without any hangs. Everything fails though, but we get good reasons why. Check the help on how to run them:
If you run Debian or Ubuntu you can run them like this:
Going to hack on the branch for half an hour.
Comment #23
jonathan1055 commentedHi Pieter,
Good that they run for you now. Pleased I have finally made a contribution to 8.x development :-)
I made a couple of commits on my branch this morning, but had no internet connection (train wifi was not running). Are you ok if I push them to the remote branch? I don't want to clash with any progress you have made. They are needed to get the tests running via the actual D8 core testing interface.
I have not tried the script version yet.
Comment #25
jonathan1055 commentedI figured the above would be ok to push, so you can see what I needed to change. If you don't like any of it, that's fine, we can modify or fix it.
I also have the same fix which is needed in #2612326: Change ! placeholders in formatted messages. When we come to merge this branch into Master branch, I presume it wont make it harder if some of the changes are already done? I need the ! change to allow the tests to be run from within the site.
I have tried your tip about running via the script, but I get syntax errors, and I think that when I initiate php via the command line I am getting php 5.4 not 5.5 which my site is using. I'm not sure how to get them aligned.
Comment #26
pfrenssenI wanted to work on this yesterday during my lunch break but I didn't get around to it. So don't hesitate to pick this up if 30 minutes have passed, since my lunch break will be over and I will be doing my day job again :)
Going to have a look at the changes now.
Comment #27
joshi.rohit100It seems like that this issue is kind of blocker with very high priority. It also seems like that tests are now running but failing. So only needs to fix the failing tests. So i think it will be great if we go for this issue same as we go for others (mean patches) so that we have more eyes. It is because most of the time when people thinking to review something, they don't like cloning repo and then see the code.
Comment #29
pfrenssen@joshi.rohit100, this is at the moment the most important issue for me. If we can get the tests working then we can prove that the base functionality of Scheduler works and we can make an alpha release. I also keep an eye on the other issues but they seem to be progressing really well. All of the important issues are currently being worked on.
I had a look at the tests. Made some minor adjustments (coding standards + capitalization of the test group). I looked into the mystery of the langcode being required suddenly. The root of this failure lies in
SchemaCheckTrait::checkConfigSchema(). It adds the 'langcode' parameter to every config object before checking it. This causes the following failure:I dug a bit deeper and the langcode is actually required, regardless whether or not the config is actually language dependent. For more information see this change record: New config_object base type added, use for simple configuration.
@jonathan1055, I'm done working on it, it's all yours :D
Comment #30
jonathan1055 commentedGreat work Pieter, and thanks for the explanations.
I think what joshi.rohit100 was implying was that if this branch was merged back into the master branch, then (a) we could all see the current state of the tests without using the branch (b) we could see the results on D.O. (c) more eyes would be able to contribute to fixing the tests.
I have only just learned about branching and stashing and I find it very easy to work with, and quite like it. However, for this most important issue we are starting to get duplicates fixes e.g. #2418527: Replace variable_set() with config #2418523: Replace variable_get() with config and #2612326: Change ! placeholders in formatted messages which have to be fixed in both branches. I'm OK with doing that, but if others would see benefit in merging this branch in now, than that's ok too.
What do you think?
Comment #32
pfrenssenOK Jonathan, I agree. We can safely merge this, except for the removal of the Views config. I will rebase the branch to remove the commit that commented out the view now. This will cause all commits to reappear underneath this comment.
Comment #33
pfrenssen@jonathan1055 it seems like you are still working on this. When you are done, please assign it to me so I can rebase and merge without interfering with your work.
Comment #34
jonathan1055 commentedI am done now, just did those two small commits, and wanted to say I'd finished, but the train wifi stopped working again. Yes, OK you can reverse the view, and then we can work out why it causes the fatal error. Just for the record, here are the results so far:
SchedulerFunctionalTest
Back at #23 we had:
Now that form posting is fixed we have many more attempts, and hence more fails:
but when I run via the run-tests.script I get slightly different numbers - two passes are now fails and there is a huge increase in exceptions:
SchedulerApiTestCase
Because the module .info is not yet converted to .yml the tests do not get started:
SchedulerDateCombinedFunctionalTest
The full test run takes 4+ minutes which seems slower than expected, compared to D7.
Comment #35
jonathan1055 commentedReassigned as requested.
I have found some more places that need simple changes for D8 syntax, and these mean more tests run and we get more passes. I don't have the precise code details with me at the moment but from memory:
I suggest we wait until you have done the rebasing and merging, before making any more patches/commits.
Comment #36
pfrenssenOK going to do the rebase and merge now. This will make all commits reappear below this comment, that is normal, drupal.org interprets these as new commits.
After merging I'll work on it during my lunch break. Will reassign when I'm done.
@jonathan1055, if you are working on a particular test and want quick feedback, then a good trick is to rename the tests you're not working on. Only test methods that start with 'test...' will actually be executed. I always rename all others to '_test...' so they are skipped by the test runner.
Comment #40
pfrenssenWorked a bit on
SchedulerFunctionalTest::testScheduler(). The test gets past the first form submission now, but the node doesn't seem to get published after cron is run. That might be quite a critical bug if this is true :)@jonathan1055, since I have rebase the branch you might get some warnings from git that the upstream has changed. The easiest way to be 100% sure that you have the latest code exactly like it is on the git server is to do a hard reset of your branch:
Comment #41
jonathan1055 commentedThis is starting to look good. We now get tests running on D.O. (even though there are many failures).
Did you intend to make your three new commits to the branch? I thought that after you had merged we would be dropping the branch and then continue making the next changes directly in master, so that everyone gets the improvements immediately. Or maybe you had an alternative plan?
I can progress my next fixes locally anyway, and they can be applied later depending on your response to the above.
Comment #42
pfrenssenWe're not done converting the tests, so I figured to just continue here until we're done :)
Making changes directly on master is not really advisable, if we accidentally break something then it will directly affect people that are downloading the latest dev version.
Comment #43
jonathan1055 commentedOK. that's fine. I will push a few more commits to this branch - I am finding lots of things to fix, and the failure numbers are coming down :-)
Comment #44
jonathan1055 commentedOne the fails is
The scheduler table does not exist in D8. Should we go to the node_field_data table instead? Then check for any publish_on values, or specifically for a value for the node just created. Is that worth a test? It's kind of double checking that the core field functionality has worked, but I'm ok with doing that, providing it will give a consistent useful result.
Comment #45
pfrenssenI don't think it is strictly necessary to test the entity storage. Before when we were maintaining our own tables it made sense to test this, but entity storage is already tested adequately in core :)
Comment #47
jonathan1055 commentedThe commit in #46 matches the main branch commit in #2418523: Replace variable_get() with config #30 which is needed for the tests to run.
Comment #50
jonathan1055 commentedCommit in #49 matches #2621122: Use ->value for $node->unpublish_on which is vital for the tests to run without fatal errors.
Comment #52
jonathan1055 commentedI've been working on SchedulerFunctionalTest.php and schedulerTestBase.php, and have now got all the tests to run without any fatal errors. The breakdown of results at the moment is:
Overall 180 passes (up from 121 from last update), 22 fails (down from 89)
Total of 202 tests and 14 exceptions
Quick summary of changes to schedulerTestBase.php
Changes to SchedulerFunctionalTest.php
I have pushed the two changed files to this branch. The code includes several @TODO with questions, remarks and debug messages on the parts which still need attention.
Comment #54
jonathan1055 commentedOne of the problems hindering progress is the default timezone warning which also stops some of the pages being rendered. The warning was
Using date_default_timezone_set() did not remove the message, so I have now added a date.timezone setting to my php.ini file. This removed the warnings and allows the pages to be rendered properly.
Then the assertText checks had a chance of matching and I could see that the nodes were published and unpublished correctly but the randomString text used for detection was causing the jQuery not to match. Changing this to the more simpler randomMachineName() allowed the text to be found. We now have a full set of passes in the first test testScheduler() which is the first time we get all green.
Overall we now have results of
185 passes, 17 fails, 0 exceptionsComment #56
jonathan1055 commentedAdded tests to cover #2625572: Admin setting 'Enable content type for scheduler' is ignored
Overall for SchedulerFunctionalTest.php we now have:
Comment #57
pfrenssenGoing to work on the tests during my lunch break.
Comment #58
jonathan1055 commentedOK. I've been doing some investigation into testRevisioning and am part way through, so maybe if you want to start on any of the others, but not that one. I wouldn't want you to use your time repeating what I've done. I have not made any changes to any other tests since the push at #55.
Comment #60
pfrenssenHave worked a bit on
testSchedulerPastDates(). The test is correctly failing, the functionality is not there yet. From a quick scan of the issue queue it seems like we need #2490574: Validate that the publication date is in the future to fix this.I did some test-wide cleanups and improvements.
Comment #61
pfrenssenAssigning back to Jonathan to continue his amazing work :)
Comment #62
jonathan1055 commentedHey, I consider that you are doing all the clever work!
Thanks for the pushes. I was going to update this issue summary with the current state of tests and link to the separate issues that will fix them. Although in my work in testRevisioning it seems like it might be the fault of the test files not the main functions. I think I may need your expert assistance on object-oriented code and namespaces, entities, etc. I'll get some details up here tomorrow.
Comment #64
jonathan1055 commentedBasic conversion of scheduler_test module .info to .info.yml
Just wanted to get this change out of the way, but I am not working on those tests yet.
Comment #66
jonathan1055 commentedWhen working on testRevisioning I realised that revisions during cron work ok for real, but not in the tests.
Within testRevisioning() we have:
and this works OK, at least within this function. The value is set to TRUE if retrieved immediately here. But in _scheduler_publish() the retreived config value for 'publish_revision' is FALSE. If the value is forced to TRUE then a revision is created during the tests, so that part is working correctly. It is just the setting and retrieval of the thirdPartySetting which is not working. In fact none of the third party settings that are applied in the test files are available in the main functions. The values applied in setUp were not even available in the test cases
The array for [third_party_settings:protected] should have more here. Then I discovered it is not sufficient just to call
->setThirdPartySetting, you also need->save()for the values to be stored permanently. After I added the ->save() it produced lots of schema errors in the tests, which halt the test run:I tried several variations within scheduler.schema.yml and eventually discovered that instead of
node_type.third_party.scheduler:it should be
node.type.*.third_party.scheduler:I found that the config inspector module is extremely helpful https://www.drupal.org/project/config_inspector
Summary of changes in the three commits above:
SchedulerFunctionalTest.php
added node_type->save() or equivalent, in 10 places.fixed one button text 'save and keep published'
added positive text assertion as well as negative assertion in testScheduledNodeDelete()
tidied up some of my comments and debug
scheduler.schema.yml
changed to node.type.*.third_party.scheduler
added labels for all Scheduler main settings
added missing 'expand_fieldset' content-type setting
SchedulerTestBase.php
Remove debug
Remove unnecessary field from db_select
No material differences.
We should test the schema changes in the main branch and get that change applied there too. It seems that previously the settings were being stored from the content type form, even though the schema was not structured correctly. The testing checks the schema whereas using the real site does not.
All of the above gave us 5 more passes! (plus 2 new tests which pass). Yes, only 5 were fixed (4 in revisioning and 1 in pastDates) but it means that the settings are now being stored and made available in the real code, and without that we'd have no hope of correcting the remaining tests. I may change the summary of this issue to give a list of the tests status and links to the issues where the code can be corrected.
Comment #67
jonathan1055 commentedHere's the patch from the schema.yml changes if anyone would like to apply it and do further testing. The content-type specific settings seem to be working fine. If you use the Config Inspector module, you will probably see duplicate items, but after a clear cache and resave of the settings it seems to get sorted out. I noticed a problem with the content-type form (before this change) where the boolean values of TRUE get the correct radio button lit and showing, but if the stored setting is FALSE we get neither radio button lit. This needs a separate issue though.
For now we just need to check that my schema changes are OK. Certainly they are fine with all the automated tests so far, but I am aware that we need to do real testing too.
Comment #69
jonathan1055 commented#68 fixes testExtraFields() and this test is all green now. Needed slight changes to the xpath values, as classes and ids are different. Also the class 'collapsed' is no longer used, but a new value 'open' is present.
Out of the eight test classes we have four which fully pass.
Comment #71
jonathan1055 commentedI have fixed testRequiredScheduling(), which involved (a) correcting the array key names to get the intended values into nodes before testing the editing, (b) changing the value of publish_on to a timestamp number not formatted text, and (c) a change to the text of the validation message to check for. The rest of the changes are with debug calls.
All of the 60 tests in the class now pass. However there is still work to do because I do not know how to change the default status of a content type before the /node/add/page is called. This affects tests 1/2 and 6/7 so currently 1 & 2 are testing the same situation, as are 6 & 7. I've searched the API pages but so far have not found out how to set the default status before a node is added. I've added an assert(FALSE) which displays a TODO message to make sure we do not forget and let this go by unfixed.
Comment #73
jonathan1055 commentedAs the main SchedulerFunctionalTest is progressing nicely I thought I would do some work on SchedulerDateCombinedFunctionalTest.php. Here is a summary of the changes in #72:
Previously: 19 passes, 7 fails, 19 exceptions
Now: 37 passes, 6 fails and 0 exceptions
Comment #75
jonathan1055 commentedThe commit in #74 repliactes the commit in #2490584: Validate that unpublish date is entered if publish date is entered
This fixes the one failing test in testValidationDuringEdit. Thanks Joekers.
Comment #76
jonathan1055 commentedComment #77
pfrenssenGoing to work on this branch for a bit. I made some changes to files outside of the tests when I converted some deprecated functions to the new D8 counterparts. These are potentially conflicting with patches that are in the queue. I will see if there are any merge conflicts with the 8.x-1.x branch and solve them, so we can merge back the progress that has been made here to the main branch. We can then continue the work here.
I'll make sure to create separate issues whenever a change needs to be made to non-test code, so that these branches won't interfere with eachother.
Comment #78
pfrenssenThe merge went without problems. This is ready to be merged back to 8.x-1.x if @jonathan1055 agrees to do this.
I also reviewed the last commits by Jonathan, they all look good. I only saw a few small typos and a leftover debug statement. We can clean this up in a final stage once everything is green.
Let's make this a property on the base class, that's the cleanest solution. So we can address the bundle as
$this->testBundleand we can simply instantiate it like this:I personally don't think we need to test if Scheduling works on multiple entity types, we should trust in the API's provided for entities and fields in core. I'm pretty sure this is already tested in core :)
I personally prefer to use hard coded values in tests, since this will make it 100% certain that the test will fail. Imagine that some bug causes the default format to become empty, or "0", or defaulting to the wrong timezone, and then the test will not detect it because it will pass through the wrong data and everything will appear fine. Hard coding avoids this.
The confirmation form with the delete button still exists, it will be behind the link. This is done to be compliant with usability guidelines. So we need to click on the link to get the form.
There is indeed a better way to test this in Drupal 8. In Drupal 7 validation handlers only run on form submission, but in Drupal 8 they should run always when an entity is created or updated. So we can test this a lot smarter in D8. We can create a KernelTest (or hopefully even a unit test) with a dataprovider that provides a whole array of combinations of incorrect as well as correct data, and then check whether the validation handlers fire correctly. Let's keep this out of scope for this issue though. I'll create a new issue for this. Once we have this we can remove these unreliable "error message is absent" tests.
Yeah, just take this out of the SchedulerFunctionalTestCase and put it in a separate class. You can then provide your own
::setUp()method that creates the$this->adminUserwith the correct permissions.Comment #79
pfrenssenVery good find!!
Comment #80
jonathan1055 commentedThat's good news. I thought it would be a good time to try this, as at the moment it is clean. I had to adjust the last commit from the master branch to get it in to this branch, and there are plenty more waiting. Yes it will be good to merge it all back. I've not actually done a full branch merge, and I will not be able to make any changes for another 5 hours. So if you want to do this now, please go ahead. If you do, let me know what git commands you use, and I will do the next one. Or let me know what commands you used last time, and will do this merge tonight.
Thanks for all the great feedback and ideas in #78. I agree with all you've said. Now that you have checked, lets merge before we implement any of these tidy-ups and enhancements. Then I will address those points back on this branch after the merge.
Comment #81
pfrenssenI'll do the merge now. The command sequence for this, starting from the
2594615branch is very easy:The last line is to switch back to the
2594615branch, the '-' indicates the 'previous branch'.Comment #83
pfrenssenMerge is done and pushed.
Comment #84
jonathan1055 commentedExcellent. Thanks for doing that. Thanks also for the git commands, I will try the next one.
Comment #86
jonathan1055 commentedAdded the check on $node in helpTestScheduler to avoid a fatal error which stops the tests running. in #2490574: Validate that the publication date is in the future see comment #22 for details.
Comment #91
jonathan1055 commentedUpdate test results after adding the two new tests.
Added links to the corresponding issues.
Comment #94
jonathan1055 commented#92/93 fix #2630836: Default timezone vs User timezone in automated tests
Comment #96
jonathan1055 commentedIn #95 commited constraints from #2490576: Validate that the unpublish date is in the future to the testing branch, to keep things in line and allow the use of this branch when doing further work on tests. Updated the summary with new totals.
Comment #98
jonathan1055 commentedThe commit in #97 merged into the test branch the changes from #2490574: Validate that the publication date is in the future and #2490580: Validate that the unpublish date is later than the publish date.
Comment #99
jonathan1055 commentedI've been working on the problem of setting the default node status, which is needed in testRequiredScheduling. With the help of examples in core node/src/Tests/NodeFormButtonsTest.php it is now done. When checking the verbose page output you can tell the default node status has been changed because the default button text changes.
I am attaching the patch here, but I think the tests will actually run against 8.x-1.x master. At this time it is fine because the test branch does not have anything extra.
Comment #101
jonathan1055 commentedThings are getting better.
✓ - testRequiredSchedulingOverall 253 passes and 7 fails.
11 class passes and 5 fails.
Comment #104
jonathan1055 commentedThe commit in 102 fixes the problem from #71 above.
Merged into master branch too.
Comment #105
pfrenssenI think in this case it would be better to put the test in a separate class. We are not using the node type nor the user that are created in the setup.
Assigning to me, feeling like working on this for a bit this evening :)
Comment #106
jonathan1055 commentedYes, OK. I agree about the class change.
But I have actually been working on testNonEnabledNodeType() this evening too. [just got back to Drupal after being away over the holidays]. That is the only test which fails in that file, and the test needs a slight change in conjunction with the possible fix in scheduler_form_node_form_alter. Yes, please make the class change, but I don't want you to waste your time duplicating the fixes to the actual assertions that I have got in the pipeline.
Or if you'd like to start on the API tests (I think you wrote them in the first place in 7.x) that would be great too.
Comment #107
jonathan1055 commentedor I can just post here the changes to the actual assertions and you can incorporate them when you make the class changes, that would be fine too.
Comment #108
pfrenssenNo go ahead, I'll leave you to that. I hadn't yet started working on the test. I will instead work on getting #2597233: The FALSE value for #group FAPI property does not have expected behaviour in so we can see it turn green.
See also my comment #2625572-6: Admin setting 'Enable content type for scheduler' is ignored, the second part of the test now fails because the publishing fields are missing.
Comment #109
jonathan1055 commentedI have moved the tests for non-enabled content type to a new class, as you suggested, in
SchedulerNonEnabledTypeTest.php. The fix in #2597233: The FALSE value for #group FAPI property does not have expected behaviour does indeed correct the error of showing the date fields for non-enabled types. However, I have spotted another error with non-enabled types, which I have now added tests for. Because the base fields exist for all content types we should still check in scheduler.cron.inc that the node being processed is actually enabled for scheduler. We allow third-party modules to alter the list of nodes, and anything could set a publish_on date in the db table. We should prevent our cron processing from acting on any nodes which are not enabled.The attached patch removes the old test from
SchedulerFunctionalTest.phpand also makes one safety-check in scheduler.cron.inc to prevent cron failures. The new test class should pass for the form field checks but fail on allowing non-enabled types to be processed. Then I'll add a fix and post a second patch.I noticed that the fieldset tests may not pass anymore, so we might not get a full set of greens for the main test class. See #2645818: Date input fieldset expand/collapse is not working for details.
Comment #111
jonathan1055 commentedAs expected in #109 we get 6 fails on
checkNonEnabledTypes.Here is a patch which includes a check in scheduler.cron.inc to avoid processing non-enabled types.
Comment #113
jonathan1055 commentedThat's good, we have one extra class passing now.
We also now have our first green row in the console output. I think the fix to cron.inc should be committed against #2625572: Admin setting 'Enable content type for scheduler' is ignored as it is a correction to the main code base not the test. The new test class needs tidying up and debug removed, which I will do, then I would appreciate someones OO knowledge for a review, as there may be some things I could do differently.
Comment #114
jonathan1055 commentededit: removed the text from this comment as it now has a separate issue #2655666: API Testing module - conversion to 8.x and it would be confusing to get replies relating to the test module here.
Comment #115
joshi.rohit100Some unused / un-required use statments.
You can assign it to property so that it can be later used in testNonEnabledContentType, instead of loading there.
same as above.
You can create these two nodes (published / unpublished) in setup so you don't have to create these nodes multiple times in test method as currently.
Comment #116
jonathan1055 commentedHi Joshi,
Thank you for the review of SchedulerNonEnabledTypeTest.php
I'm not surprised as I was adding many statements in order to try out and develop the code. Which ones are not required?
drupalCreateContentType. I will try that, thankswhat exactly?
Thanks again. I will be good to get this test moved, and also the minor fixes to scheduler.cron.inc then we will have more green test passes.
Comment #117
jonathan1055 commentedHere's a re-roll for
SchedulerNonEnabledTypeTest. Changes since #111:usestatementsI've attached an interdiff so you can see exactly what is changed. I am going to commit this, but I'm ok if it needs minor tweaks later. There are several more test changes in the pipeline, and getting this done and merged into the main 8.x branch will be good progress.
Comment #121
jonathan1055 commentedI've added checks to the 'extraFields' test to check that the fieldset is expanded when publish-on or unpublish-on dates exist in the node being editted. These tests currently fail as the code for this was dropped (probably by accident) on converting from 7.x. See #2645818-8: Date input fieldset expand/collapse is not working for details.
Comment #127
jonathan1055 commentedTests added for user without permission, to cover #2651448: Publish and Unpublish fields are shown for users who do not have the permission
Comment #128
jonathan1055 commentedUpdated results (and restored some deleted text in the summary) after #2645818: Date input fieldset expand/collapse is not working http://cgit.drupalcode.org/scheduler/commit/?id=d3d0669
Comment #129
jonathan1055 commentedI've been working on the default date processing, and this allowed me to fix the date tests. The changes in this patch are:
$this->seconds = 23400instead of repeating the hard-coded numberDatetime::validateDatetimenot byscheduler_node_validate()$this->assertRawto$this->assertTextbecause the messages now contain markup and assertText strips this out$this->clickLink(t('Edit'));to$this->drupalGet('node/x/edit');because the edit link is not necessarily found, and the url is more robustThis patch may remove one failed test, but the default time functionality is not added yet. I will add that patch to #2644690: Include default time processing in datetime widget for 8.x when these test changes are committed.
Comment #130
joshi.rohit100use service (or todo for this)
Comment #131
jonathan1055 commentedHi Joshi,
Thanks for the feedback but can you be a bit more specific? Instead of pasting chunks of the patch if you put just the actual line of code it would be more obvious. If you mean the date, I already have
@todo Use \Drupal::service('date.formatter').Jonathan
[Also, something must be going on with the test servers, as this patch has been queued for four hours and not started yet.]
Comment #132
joshi.rohit100My point is that date formatter service should be used for format_date() or there should be a todo for this (I am guessing todo that you have mentioned is only for date() ?)
Comment #133
jonathan1055 commentedYes, I meant it as a generic todo for the whole file, but I note your point, thanks. I will address those things when the tests run cleanly.
Comment #135
jonathan1055 commentedTest failed to complete due to calling $node->id() when the node had not saved properly. This is easily avoided:
I also added 'and format_date()' on the @todo ;-)
Comment #139
jonathan1055 commentedGood. As expected we get one fewer fail because the 'edit' link is fixed - internally it is 37 passes and 5 fails. Commited this to testing branch and merged to main 8.x to allow testing on #2644690: Include default time processing in datetime widget for 8.x
Comment #148
jonathan1055 commentedUpdated results after fixing a problem in the date test, adding more assertions to the permissions test and starting work on API testing module conversion
#2655666: API Testing module - conversion to 8.x
Comment #149
pfrenssenNice to see the progress!
Comment #152
jonathan1055 commentedHere are some tests for the lightweight cron. This is just the test part of the patch in #2626480-15: scheduler/cron needs a route controller by polynya. Need to check these tests and commit separately first, so that we see the difference when the route is fixed.
Comment #154
joshi.rohit100I noticed that every test class is extending schedulertestbase and also defining scheduler module to be enabled. shouldn't scheduler module to be enabled in parent so no need to rewrite again ?
Comment #155
jonathan1055 commentedHi Joshi,
Yes I noticed that too. Currently schedulerTestBase does not have
public static $modules = ['scheduler'];but if that is added and the others are removed it all works just fine. Thanks for the prompt, I will make that commit now, before we introduce any more new test files. The patch in #152 needs to be worked on anyway.Jonathan
Comment #158
joshi.rohit100I don't see use of enabling locale in #152. Is any ?
Comment #159
jonathan1055 commentedNo it is not needed - see my comment on #2626480-18: scheduler/cron needs a route controller
I am going to use that issue for refining this new test file, given that that is where polynya first created the file.
Thanks for the hint about $modules in schedulerTestBase, that's worked nicely :-)
Comment #162
jonathan1055 commentedDuring work on #2625572: Admin setting 'Enable content type for scheduler' is ignored I realised that in SchedulerNonEnabledTypeTest we should delete each node after using it, otherwise the cron processing/exceptions affect the results of subsequent assertions. I also display the dblog after each cron to show what has happened and tidied up the comments.
Comment #166
jonathan1055 commentedUpdated summary and added details for LightweightCron tests.
Comment #167
jonathan1055 commentedI am going to split out the test in the large SchedulerFunctionalTests.php file into separate test files. Now that we have a few new test files, such as the lightweightCron and non-enabled nodetypes tests, it will make it consistent to have the others split. Smaller files in this instance are easier to maintain, and changes to one test patch will be less likely to clash with another. It makes re-testing easier (and hence quicker) when working on one part of the functionality. We will soon be expanding the test coverage so I want to get these files split now, to make that easier.
Also we have the setup function in SchedulerTestBase which was not used, and we had common code repeated in the other classes. This is now all in the testbase setup function.
I've only split out two test functions in this patch, just to see how it goes.
Comment #169
jonathan1055 commentedNeede to change API setup from protected to public to match ShedulerTestBase
Comment #175
jonathan1055 commentedLast of these commits coming up, then we should have a consistent set of twelve test classes.
The four helper functions in SchedulerTestBase were not actually common functions - each is only used in one test class, so I have moved them into the files that need them - keeping code only where it is needed instead of loading it unnecessarily. (1 into FunctionalTest and 3 into RevisioningTest)
Comment #178
jonathan1055 commentedUpdated summary to reflect new test cases.
Comment #181
jonathan1055 commentedUpdated after adding test for #2666832: Publish in the past sets date to 1970-01-01
Comment #184
jonathan1055 commentedUpdated summary after commits in #2666832: Publish in the past sets date to 1970-01-01 and #2655666: API Testing module - conversion to 8.x
Comment #185
jonathan1055 commentedNow that #2644690: Include default time processing in datetime widget for 8.x and #2651448: Publish and Unpublish fields are shown for users who do not have the permission have been committed we only have one failing test - the patch is on #2625572: Admin setting 'Enable content type for scheduler' is ignored for review.
I have also deleted the testing branch 2594615 as it has served it's purpose. All the tests have been running for several months now, and it was just an unnecessary overhead to keep both branhces in line, continually merging every commit from one branch into the other.
Comment #186
jonathan1055 commentedI have made some minor improvements to the test files, mainly in response to my testing of #2633870: Revisit defaults for third party settings which allowed me to see where the tests were passing due to luck and assumption, instead of testing the actual piece of code in question. Only minor changes, here is a summary:
Does not need a review, I am going to commit now, but for the record here is a patch, to show the test results.
Comment #190
jonathan1055 commented#2625572: Admin setting 'Enable content type for scheduler' is ignored is fixed.
Added new tests
SchedulerTokenReplaceTestandSchedulerMetaInformationTestAll tests pass :-)
Comment #191
jonathan1055 commentedAll tests have been passing since 9th March https://www.drupal.org/pift-ci-job/206819
Closing this issue now. Good work.
Alongside the 8.x work, I am also going through old issues and either responding or closing, as appropriate. My aim in the short term is to get the queue down to 50 or fewer, so that all issue are shown on one page. Currenlty we have 63 open issues, down from 67 yesterday. The project block is still a few days behind in the totals it shows, even though #2686419: Wrong count for 'open' issues in block on project page and #2394175: Remove or emphasise need to log in for search are closed.
Comment #192
pfrenssenThanks for your dedication and hard work!
Comment #193
joshi.rohit100Good to see this meta closed :)
Comment #195
jonathan1055 commentedUnassigning.