Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Growing the PHP core - One Test at a Time @LaraconEU 2021

Growing the PHP core - One Test at a Time @LaraconEU 2021

I am a PHP core contributor and you can be too! You think you need to create a RFC for this or write and maintain a PHP extension or even write C code? Fear no more!
In this talk you will learn how you can become a PHP core contributor and give something back to the community by writing tests for PHP core without writing a single line of C code.

Want to know more? https://dev.to/realflowcontrol/growing-the-php-core-one-test-at-a-time-4g4k

8b8824ec70715f8599896375626c20d9?s=128

Florian Engelhardt

January 19, 2021
Tweet

Transcript

  1. @realFlowControl GROWING THE PHP CORE - ONE TEST AT A

    TIME -
  2. FLORIAN ENGELHARDT FLORIAN ENGELHARDT FLORIAN ENGELHARDT FLORIAN ENGELHARDT FLORIAN ENGELHARDT

  3. HUSBAND AND DAD HUSBAND AND DAD HUSBAND AND DAD HUSBAND

    AND DAD HUSBAND AND DAD
  4. If I have seen further it is only by standing

    on the shoulders of giants — Sir Isaac Newton
  5. PHP TestFest 2017

  6. COMPILING PHP FROM SOURCE COMPILING PHP FROM SOURCE COMPILING PHP

    FROM SOURCE COMPILING PHP FROM SOURCE COMPILING PHP FROM SOURCE * fork before cloning git clone git@github.com:php/php-src.git cd php-src ./buildconf ./configure make -j `nproc` ./sapi/cli/php -v
  7. RUN THE TESTS RUN THE TESTS RUN THE TESTS RUN

    THE TESTS RUN THE TESTS make TEST_PHP_ARGS=-j`nproc` test
  8. BASIC TEST BASIC TEST BASIC TEST BASIC TEST BASIC TEST

    --TEST-- strlen() function --SKIPIF-- <?php if (!extension_loaded('core')) echo 'skip'; ?> --FILE-- <?php var_dump(strlen('Hello World!')); ?> --EXPECT-- int(12) --CLEAN-- <?php unlink(__DIR__.'/file.tmp'); ?>
  9. WHAT TO TEST? WHAT TO TEST? WHAT TO TEST? WHAT

    TO TEST? WHAT TO TEST? nd latest scheduled build select Code Coverage section Azure Pipelines
  10. FIND SOMETHING RED FIND SOMETHING RED FIND SOMETHING RED FIND

    SOMETHING RED FIND SOMETHING RED ext/zlib/zlib.c in PHP 7.1
  11. WRITE A TEST WRITE A TEST WRITE A TEST WRITE

    A TEST WRITE A TEST the absence of the Accept-Encoding header the Accept-Encoding being gzip the Accept-Encoding being deflate the Accept-Encoding being anything else
  12. DEMO TIME! DEMO TIME! DEMO TIME! DEMO TIME! DEMO TIME!

  13. TIME FOR THE SOURCE! TIME FOR THE SOURCE! TIME FOR

    THE SOURCE! TIME FOR THE SOURCE! TIME FOR THE SOURCE! or ask the nice fellows over at the source phpc.chat
  14. --TEST-- zlib_get_coding_type() with gzip encoding --SKIPIF-- <?php if (!extension_loaded("zlib")) print

    "skip"; ?> --ENV-- HTTP_ACCEPT_ENCODING=gzip --FILE-- <?php ini_set('zlib.output_compression', 'Off'); $off = zlib_get_coding_type(); ini_set('zlib.output_compression', 'On'); $on = zlib_get_coding_type(); ini_set('zlib.output_compression', 'Off'); var_dump($off); var_dump($on); ?> --EXPECT-- bool(false) string(4) "gzip"
  15. ext/zlib/zlib.c in PHP 7.3

  16. WHAT HAVE WE LEARNED WHAT HAVE WE LEARNED WHAT HAVE

    WE LEARNED WHAT HAVE WE LEARNED WHAT HAVE WE LEARNED what looks simple, might be complex super globals are copy-on-write there are modify handlers for ini settings
  17. WHAT DO YOU GAIN? WHAT DO YOU GAIN? WHAT DO

    YOU GAIN? WHAT DO YOU GAIN? WHAT DO YOU GAIN? PHP will be more stable and reliable deeper understanding of how PHP works internaly phpt test format can be used in PHPUnit
  18. YOU CAN CALL YOURSELF A PHP CORE CONTRIBUTOR! YOU CAN

    CALL YOURSELF A PHP CORE CONTRIBUTOR! YOU CAN CALL YOURSELF A PHP CORE CONTRIBUTOR! YOU CAN CALL YOURSELF A PHP CORE CONTRIBUTOR! YOU CAN CALL YOURSELF A PHP CORE CONTRIBUTOR!
  19. None
  20. FURHTER READINGS FURHTER READINGS FURHTER READINGS FURHTER READINGS FURHTER READINGS

    phptestfest.org qa.php.net dotbox.org