Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
What Is Snapshot Testing, and Is It Viable in PHP?
Jun 21, 2017 @ 17:28:01

On the SitePoint PHP blog they've posted another article from author Christopher Pitt. This time he talks about snapshot testing and if it's a viable way to evaluate code in PHP applications.

Ah-ha moments are beautiful and rare in programming. Every so often, we’re fortunate enough to discover some trick or facet of a system that forever changes how we think of it. For me, that’s what snapshot testing is.

You probably write a lot of PHP code, but today I want to talk about something I learned in JavaScript. We’ll learn about what snapshot testing is and then see how it can help us write better PHP applications.

He starts with a brief introduction to the technology to be used (React in Javascript) and how it could be recreated in PHP. He then covers testing interfaces, evaluating the correct functionality of frontends via various testing tools. He includes some examples of this kind of testing and how it can help a developer mentally break up functionality into components. From there he switches over to the PHP side, introducing the spatie/phpunit-snapshot-assertions package and showing how to use it to check the make up of a snapshot and test several assertions that should exist.

tagged: snapshot testing viable javascript frontend assertion tutorial

Link: https://www.sitepoint.com/snapshot-testing-viable-php/

Medium.com:
A Package for Snapshot Testing in PHPUnit
Mar 29, 2017 @ 17:05:03

In this post on Medium.com Sebastian De Deyne shares a package from Spatie that makes it simpler to perform "snapshot testing" in your PHP applications.

The gist of snapshot testing is asserting that a set of data hasn’t changed compared to a previous version, which is a snapshot of the data, to prevent regressions. The difference between a classic assertEquals and an assertMatchesSnapshot is that you don't write the expectation yourself when snapshot testing. When a snapshot assertion happens for the first time, it creates a snapshot file with the actual output, and marks the test as incomplete. Every subsequent run will compare the output with the existing snapshot file to check for regressions.

Snapshot testing is most useful larger datasets that can change over time, like serializing an object for an XML export or a JSON API endpoint.

Our package, which exposes a trait to add snapshot testing capabilities to your tests, can be installed via composer and is available on GitHub.

He starts with a basic example, checking to verify that a string hasn't changed between test runs. The first run creates the snapshot (marking the test as incomplete) and then following runs verify - one passing (no change) and one failing (changing of the return string). He also includes examples of tests on objects, mentions where the snapshot files are stored and how to add drivers for additional snapshot storage types.

tagged: snapshot testing phpunit package tutorial

Link: https://medium.com/@sebdedeyne/a-package-for-snapshot-testing-in-phpunit-2e4558c07fe3

Brian Swan's Blog:
SQL Server Driver for PHP Connection Options: Snapshot Isolation
Sep 15, 2010 @ 17:21:54

Following up on his previous post about transaction-level isolation with the SQL Server driver, Brian Swan has this new look at an additional option - snapshot isolation.

I’ll cover the snapshot isolation level in this post, and (as in my earlier post) I'll look at what happens at the database level when using a particular isolation level (rather than concentrating on PHP data access code).

He introduces snapshots for those not familiar with them - the idea of making a set of data available to other users without having to lock the database in a certain state (also called row versioning). He shows how to turn on the isolation functionality and set it to work with a transaction. With the snapshot created, he shows the SQL needed to fetch the snapshot of data and, of course, how to read it in PHP with the help of the SQL Server driver.

tagged: sqlserver driver isolation snapshot tutorial

Link:

Johannes Schluter's Blog:
Features in PHP trunk: Array dereferencing
Aug 02, 2010 @ 15:41:09

In a recent post to his blog Johannes Schluter talks about a new feature that's just been added to the PHP project's trunk - array dereferencing.

Now you might wonder what this typical short entry means. when doing OO-style PHP you might make use of a syntax feature which one might call "object dereferencing". [...] So one can chain method calls or property access. Now for a long time people requested the same thing for array offset access. This was often rejected due to uncertainties about memory issues, as we don't like memory leaks. But after proper evaluation Felipe committed the patch.

This new feature allows you to return an array from a method and reference it in a new way outside the call - foo()[2] - where the array is like "array(1,2,3)". Johannes includes a few other examples, including how to set the information in an array (using referneces) inside a method.

tagged: array dereference trunk patch snapshot

Link:

Daniel Cousineau's Blog:
PHP 5.3 and Closures
Jul 21, 2008 @ 21:02:46

Daniel Cousineau has posted briefly about a relatively new addition to the feature set of the upcoming PHP 5.3 release - closures.

I'm fairly excited because as of only a week or so ago I found the closures rfc, and not only did I find that the rfc has a working patch, apparently it's already in PHP 5.3. You see, apparently it's not good enough that we get name spaces and late static binding, oh no, we get closures too!

He downloaded a snapshot and gave it a try - code examples are included with his post.

tagged: closure php5 snapshot namespace win32

Link:

Johannes Schluter's Blog:
Easter - Don't just look for eggs but also for bugs
Mar 21, 2008 @ 16:29:41

Johannes Schluter recommends that, this Easter, you not only enjoy the holiday and hunt some eggs but also do a little bug hunting at the same time:

Around Easter there are different holidays, in Germany for instance Friday and Monday are holidays. This gives you some time without annoying customers and colleagues asking you to do stuff. So what could you PHP geeks do when getting bored? - A good idea is to test PHP development snapshots.

The PHP group has put out the second release candidate for PHP 5.2.6 and is looking for a few good testers to help them find whatever issues may lie deep in its code. Accoring to Johannes, though, not much should be broken this time. It's PHP 5.3 everyone should really watch out for...

So grab a snapshot and get testing!

tagged: egg hunt bug snapshot php5 easter releasecandidate

Link:

Antony Dovgal's Blog:
5.3 snapshots are available
Feb 28, 2008 @ 15:33:00

Antony Dovgal points out that Derick Rethans has added the snapshots for PHP 5.3 to the snaps.php.net website.

Short list of what you can find there: Namespaces, __callstatic() magic method, accessing static members through $foo::myFunc(), fully rewritten ini-parser with .htaccess-like user defined ini files for CGI/FastCGI, improved OpenSSL extension, PCRE 7.4, and other fixes and improvements that will never get into 5_2 branch.

He recommends teching throughly before the major release to find all of the bug before the general public does. Builds for both source and Windows systems have been posted.

tagged: php5 snapshot snaps namespace latestaticbinding static pcre openssl

Link:

Padraic Brady's Blog:
PHPSpec Reporting Gets A Needed Boost
Nov 14, 2007 @ 20:25:00

Padraic Brady has made a few updates to the PHPSpec software he's developed in preparation for the first stable release - additions to the reporting functionality to give as much information as possible.

PHPSpec is closing in on its first stable release, so the time had finally come to spruce up its output! No more the simple reporting of failed specs - now you get a few more details in a readable format, exceptions and errors even come with traces. In addition, I've implemented specdoc output as an option (using "-s") so you can get a list of specs in their plain text form.

He's also included an example of the new output in the post as well, showing the results of both successful and errored responses. You can check out the actual spec files on the googlecode repository for the project and get more details on the project itself (including the latest development snapshots) on the project's website.

tagged: phpspec reporting stable release spec snapshot phpspec reporting stable release spec snapshot

Link:

Padraic Brady's Blog:
PHPSpec Reporting Gets A Needed Boost
Nov 14, 2007 @ 20:25:00

Padraic Brady has made a few updates to the PHPSpec software he's developed in preparation for the first stable release - additions to the reporting functionality to give as much information as possible.

PHPSpec is closing in on its first stable release, so the time had finally come to spruce up its output! No more the simple reporting of failed specs - now you get a few more details in a readable format, exceptions and errors even come with traces. In addition, I've implemented specdoc output as an option (using "-s") so you can get a list of specs in their plain text form.

He's also included an example of the new output in the post as well, showing the results of both successful and errored responses. You can check out the actual spec files on the googlecode repository for the project and get more details on the project itself (including the latest development snapshots) on the project's website.

tagged: phpspec reporting stable release spec snapshot phpspec reporting stable release spec snapshot

Link:

Antony Dovgal's Blog:
5.3 snapshots are avilable
Oct 16, 2007 @ 15:24:00

Antony Dovgal has pointed out the updated packages that have been released to the snaps.php.net website by Derick Rethans.

He also includes a list of things that will be included in this upcoming release like:

  • Namespaces
  • Late static binding
  • Accessing static members through $foo::myFunc()
  • Improved OpenSSL extension
  • PCRE 7.4

Grab your copy of these latest snapshots from the snaps website and get to testing them on your system to see what happens before the release.

tagged: snapshot php5 release snapsphpnet snapshot php5 release snapsphpnet

Link:


Trending Topics: