Review main Merged

61518[TASK] Add tests for linkvalidator

Sybille Peters CR +2 V +2 Normal +97 −0 updated 08/27/19, 21:31

Commit message

Review

  • Code review CR +2 Done
    • Tymoteusz Motylewski +2
    • Oliver Klee +1
    • Jan Stockfisch +1
    • Andreas Kienast +1
  • Verified V +2 Done
    • Tymoteusz Motylewski +2
    • Jan Stockfisch +1
    • TYPO3com +1 CI

Issues 1

Files 1

Review log 3040

Show 1015 earlier messages
  1. Sybille Peters uploaded patch set 1 08/20/19, 12:17

  2. TYPO3com voted on patch set 1 V +1 08/20/19, 12:28 Completed build in 10m 53s on Tue, 20 Aug, 12:28 PM Test Summary: 47215 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35745

  3. Sybille Peters uploaded patch set 2 08/20/19, 12:57

  4. TYPO3com voted on patch set 2 V +1 08/20/19, 13:06 Completed build in 08m 55s on Tue, 20 Aug, 01:06 PM Test Summary: 47215 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35748

  5. Sybille Peters uploaded patch set 3 08/20/19, 13:33

  6. TYPO3com voted on patch set 3 V +1 08/20/19, 13:43 Completed build in 10m 44s on Tue, 20 Aug, 01:43 PM Test Summary: 47215 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35750

  7. Oliver Klee commented on patch set 3 08/20/19, 19:23

    ExternalLinktypeTest.php:36

    You can use "new" here in the tests instead of makeInstance (as long as you don't need dependency injection).

    ExternalLinktypeTest.php:45

    I propose dropping this comment and having a test name that reads like a sentence. Maybe this slide will help: https://speakerdeck.com/oliverklee/test-driven-development-with-phpunit-1?slide=49

    ExternalLinktypeTest.php:55

    I recommend using assertSame instead of assertEquals so the checks are as strict as possible.
  8. Sybille Peters uploaded patch set 4 08/21/19, 06:05

  9. TYPO3com voted on patch set 4 V -1 08/21/19, 06:05 Completed build in 12s on Wed, 21 Aug, 06:05 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35752

  10. Sybille Peters wrote 08/21/19, 06:05

    Description set to "Fixed issues raised for test"
  11. Sybille Peters uploaded patch set 5 08/21/19, 06:10

  12. Sybille Peters wrote 08/21/19, 06:10

    Description set to "Fix CGL issue"
  13. Sybille Peters commented on patch set 5 08/21/19, 06:11

    Thank you. That was very helpful. This is my first contribution to testing the core :)

    ExternalLinktypeTest.php:36 Reply

    Done

    ExternalLinktypeTest.php:45 Reply

    Done

    ExternalLinktypeTest.php:55 Reply

    Done
  14. TYPO3com voted on patch set 5 V +1 08/21/19, 06:22 Completed build in 11m 58s on Wed, 21 Aug, 06:22 AM Test Summary: 47215 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35753

  15. Oliver Klee commented on patch set 5 08/21/19, 08:56

    AbstractLinktype.php:86

    If I read the change description correctly, the change should only add tests. I'd prefer we keep it that way and move new functionality to a different changeset.

    AbstractLinktype.php:115

    $languageService is no boolean. So the check should be ($languageService !== null) instead.

    ExternalLinktype.php:121

    The second $this looks like it does not belong here.

    FileLinktype.php:59

    Why this change?

    ExternalLinktypeTest.php:35

    By convention, the instance of the tested class is named "subject". I hence recommend renaming it.

    ExternalLinktypeTest.php:47

    These should be two separate tests - one for checkLink and one for getErrorType. This will also make naming the tests easier and will make the different failure messages unnecessary.

    ExternalLinktypeTest.php:50

    I propose adding a verb to the method name: languageServiceProphecy An I recommend placing the helper methods between setUp/tearDown and the first test to make them easier findable.
  1. Sybille Peters commented on patch set 5 08/21/19, 09:06

    AbstractLinktype.php:86 Reply

    I understand. I started to change some of the API (e.g. LanguageService) as necessary for the test, but I can move everything that is not absolutely necessary for the test to a different changeset.
  2. Sybille Peters uploaded patch set 6 08/21/19, 09:24

  3. Sybille Peters wrote 08/21/19, 09:25

    Description set to "Remove changes not required for test."
  4. Sybille Peters uploaded patch set 7 08/21/19, 09:34

  5. Sybille Peters wrote 08/21/19, 09:34

    Description set to "Fix issues raised in review"
  6. Sybille Peters commented on patch set 7 08/21/19, 09:34

    AbstractLinktype.php:86 Reply

    Done

    AbstractLinktype.php:115 Reply

    Done

    ExternalLinktype.php:121 Reply

    Done

    FileLinktype.php:59 Reply

    Done

    ExternalLinktypeTest.php:35 Reply

    Done

    ExternalLinktypeTest.php:47 Reply

    Done

    ExternalLinktypeTest.php:50 Reply

    Done
  7. TYPO3com voted on patch set 6 V +1 08/21/19, 09:36 Completed build in 11m 52s on Wed, 21 Aug, 09:36 AM Test Summary: 47215 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35754

  8. Sybille Peters uploaded patch set 8 08/21/19, 09:38

  9. TYPO3com voted on patch set 7 V -1 08/21/19, 09:45 Completed build in 11m 30s on Wed, 21 Aug, 09:45 AM Test Summary: 1 of 47578 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35755

  10. TYPO3com voted on patch set 8 V +1 08/21/19, 09:47 Completed build in 09m 10s on Wed, 21 Aug, 09:47 AM Test Summary: 47219 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35756

  11. Oliver Klee commented on patch set 8 08/22/19, 10:54

    AbstractLinktype.php:36

    There should be spaces around the = sign. Also, if $languageService can be null, the more correct type would be the nullable one: ?LanguageService

    AbstractLinktype.php:104

    You can simplify the tests by setting $GLOBALS['LANG'] instead. Then you don't need to modify the classes.

    ExternalLinktypeTest.php:38

    I propose to rename this from get* to build* as this makes the behavior more explicit (it does not return an existing prophecy, but builds a new one).

    ExternalLinktypeTest.php:43

    Is the return value important? If not, you can use shouldBeCalled() instead.

    ExternalLinktypeTest.php:53

    I recommend using example.org (the official example domain for this kind of purpose) for all domains in URLs and email addresses where the actual domain is not important.

    ExternalLinktypeTest.php:55

    As we now have good, expressive test names, the messages in the asserts are not needed anymore.

    ExternalLinktypeTest.php:61

    I recommend not using "correct" in test names, but the actual expected behavior/value instead. This allows the reader to assess the behavior from reading the test name, and to compare it with the test code. In this case, I propose this: CorrectErrorType -> NotFoundErrorType

    ExternalLinktypeTest.php:64

    By the way, does the link validator actually access these URLs? If so, these tests should be functional tests. (And if not, they're perfectly fine as unit tests.)

    ExternalLinktypeTest.php:66

    By the way, you can make the structure of the test more explicit by adding a blank line between the sections: 1. setup ($url = etc.) 2. execution (checkLink call) 3. evaluation (asserts)
  12. Sybille Peters uploaded patch set 9 08/22/19, 15:33

  13. Sybille Peters commented on patch set 9 08/22/19, 15:33

    AbstractLinktype.php:36 Reply

    Done

    AbstractLinktype.php:104 Reply

    Done

    ExternalLinktypeTest.php:38 Reply

    Done

    ExternalLinktypeTest.php:43 Reply

    Done

    ExternalLinktypeTest.php:53 Reply Unresolved

    Done

    ExternalLinktypeTest.php:55 Reply

    Done

    ExternalLinktypeTest.php:61 Reply

    Done

    ExternalLinktypeTest.php:64 Reply Unresolved

    Yes, the URLs get accessed. If we don't want that, we can mock / prophecy the $requestFactory. But then we are not really testing much anymore. I read the section on Unit Tests in "TYPO3 Explained" (https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/Testing/WritingUnit.html). It discourages to just test glue code, which is probably what I would be doing. I was trying to avoid the functional tests for now because I think it may be a problem with the current functionality which may not be modular enough. I was hoping to add the functional tests together with some refactoring. What I could do now is try to create functional tests in a next patchset and see if this is easily doable and my concerns were premature. If this is possible we could decide if we keep the unit tests or throw them away. In any case, I got useful advice :)

    ExternalLinktypeTest.php:66 Reply

    Done
  14. Sybille Peters wrote 08/22/19, 15:33

    Description set to "Change with comments from review"
  15. TYPO3com voted on patch set 9 V +1 08/22/19, 15:43 Completed build in 10m 16s on Thu, 22 Aug, 03:43 PM Test Summary: 47219 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35772

  16. Sybille Peters uploaded patch set 10 08/22/19, 17:01

  17. Sybille Peters wrote 08/22/19, 17:02

    Description set to "prophesize RequestFactory"
  18. Sybille Peters commented on patch set 10 08/22/19, 17:02

    ExternalLinktypeTest.php:38 Reply

    Done
  19. TYPO3com voted on patch set 10 V +1 08/22/19, 17:12 Completed build in 10m 44s on Thu, 22 Aug, 05:12 PM Test Summary: 47219 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35774

  20. Oliver Klee commented on patch set 10 CR +1 08/25/19, 16:41

    Looks very good!
  21. Andreas Kienast voted on patch set 10 CR +1 08/26/19, 08:11

  22. Jan Stockfisch voted on patch set 10 CR +1 08/26/19, 15:18

  23. Jan Stockfisch voted on patch set 10 V +1 08/26/19, 15:24

  24. Tymoteusz Motylewski voted on patch set 10 V +2 CR +2 08/27/19, 21:30

  25. Tymoteusz Motylewski merged patch set 11 08/27/19, 21:31