Drupal

PreviousNext: Testing CSV output in Drupal 8 with BrowserTestBase

Planet Drupal - 19 October 2017 - 2:39pm
Share:

In a recent project we were outputting CSV and wanted to test that the file contents were valid.

Read on for a quick tip on how to achieve this with Drupal 8's BrowserTestBase

by Lee Rowlands / 20 October 2017

Basically, the easiest way to validate and parse CSV in PHP is with the built in fgetcsv function.

So how do you go about using that inside a functional test - in that instance we're not dealing with a file so its not your ordinary approach for fgetcsv.

The answer is to create a stream wrapper in memory, and use fgetcsv on that.

The code looks something like this:

$response = $this->getSession() ->getDriver() ->getContent(); // Put contents into a memory stream and use fgetcsv to parse. $stream = fopen('php://memory', 'r+'); fwrite($stream, $response); rewind($stream); $records = []; // Get the header row. $header = fgetcsv($stream); while ($row = fgetcsv($stream)) { $records[] = $row; } fclose($stream);

There you have it, you now have the header in $header and the rows in $rows and can do any manner of asserts that you need to validate the CSV generation works as expected.

Tagged Drupal 8, Testing, Functional Testing

Posted by Lee Rowlands
Senior Drupal Developer

Dated 20 October 2017

Add new comment
Categories: Drupal

field entity dependency

New Drupal Modules - 19 October 2017 - 1:24pm

This module will provide a field type to manage hierarchical dependency between related Drupal 8 entities.
For now, it only works between content types but we have plans to support taxonomy vocabularies and bock types in near future.

How to use:

Go to Manage Fields on any content type and then press on Add field.
Now select the Dependency field type.
Once created, go to Manage form display, make sure that you have selected the Dependency select widget and in its settings, you must specify the entities to display on the field.

Categories: Drupal

reCAPTCHA Extra

New Drupal Modules - 19 October 2017 - 11:46am

Utility with minor tweaks for reCAPTCHA module.

Features:

- Loading on modal popup.

Categories: Drupal

Drupal Association blog: Drupal Association Board Meeting Summary - 28 September, 2017

Planet Drupal - 19 October 2017 - 11:38am

On 28 September 2017, the Drupal Association held its third open board meeting of the year where community members listened in via zoom and in person. You can find the meeting minutes, board materials, and meeting recording here.

The board meeting was kicked off by an update from Dries Buytaert, followed by an Executive update from Megan Sanicki, Executive Director, and a Drupal.org update from Tim Lehnen, Director of Engineering. We also thanked and celebrated Tiffany Farriss, Vesa Palmu, and Jeff Walpole whose terms on the board end in November.

Dries Buytaert moving from Chairman to Founding Director position

One of the key announcements made during the meeting came from Dries Buytaert, who announced that in response to the Community Discussions findings, he is stepping down from the Drupal Association Chairman position. He will remain on the board in the Founding Director position.  This will go into effect in November when board seats expire and Adam Goodman will step into the role as interim Chairman, which is also in response to the community’s request for a neutral, outside expert to lead the board. To learn more about the Community Discussions, go here.

Adam Goodman is a leadership professor from Northwest University in Chicago, Illinois, USA. He's advised the Drupal Association on and off for the past 8 years, helping us evolve from a volunteer board to a strategic board. In this role, Adam will further evolve the board so it can orient itself around a new chairman structure.

Since Adam is a paid consultant, the Drupal Association needs to change its bylaws to allow Adam to sit on the board and be paid for his service. In addition to this change, we are doing a general update of the bylaws to include:

  • Eliminate non-existent committees like the HR committee

  • Modernize the tools we can use for online voting. Today we can use teleconferencing, but we also need to be able to use video conferencing.

To learn more about this board meeting, please watch the recording and stay tuned for an update on other improvements we are making in response to the community’s input.

Categories: Drupal

Drupal Association blog: Status of Speaker Agreement Violation

Planet Drupal - 19 October 2017 - 10:36am

Our community does amazing things together and they deserve to have the best working environment for collaboration. At the Drupal Association, we strive to create these open and collaborative environments at DrupalCon and on Drupal.org.

We recently became aware that a community member violated our speaker agreement at DrupalCon. The Drupal Association removed the video from the DrupalCon event site and the Drupal Association YouTube channel and we are determining additional actions. The community member acknowledged that they broke the speaker agreement and is cooperating with the Drupal Association as we take action.

We apologize that this content was shared. It didn’t create the best environment for our community to thrive and we will do better. We are looking at ways to enhance our process to avoid situations like this from happening again.

We also heard from the community discussion findings that were provided this summer, that the community needs a better understanding of the roles and responsibilities for volunteers that work on Drupal Association programs. The Drupal Association is working to define what is expected of each role and policies for managing situations when expectations are not met. We are working on developing a clear outline of these and you can expect to see them finalized by February 2018.

Categories: Drupal

Redfin Solutions: Pulling Salesforce Data in as Taxonomy Terms in D7

Planet Drupal - 19 October 2017 - 9:27am
Pulling Salesforce Data in as Taxonomy Terms in D7

Salesforce Suite is a group of modules for Drupal that allows for pulling data from Salesforce into Drupal, as well as pushing data from Drupal to Salesforce. The module api provides some very useful hooks, including the _salesforce_pull_entity_presave hook implemented by the Salesforce Pull module. In this blog post, we’ll look at using that hook to pull three Salesforce custom fields (select lists) into Drupal as taxonomy terms in three vocabularies.

Christina October 19, 2017
Categories: Drupal

OpenAgenda connector

New Drupal Modules - 19 October 2017 - 8:09am

This module allow you to automatically publish, update or delete content on OpenAgenda through the OpenAgenda API.
OpenAgenda is a free service to reference and broadcast all your events.

Requirements

This module requires the following modules:
Rules
And you need an account on OpenAgenda where to push your events.

Categories: Drupal

EZProxy Stanza

New Drupal Modules - 19 October 2017 - 7:27am
Categories: Drupal

Mediacurrent: Announcing Mediacurrent Labs

Planet Drupal - 19 October 2017 - 6:55am

Mediacurrent’s commitment to innovation has been clear since our founding ten years ago.

Categories: Drupal

Content Notifications

New Drupal Modules - 19 October 2017 - 5:54am

Display unread contents to logged-in users

Categories: Drupal

Normalize Address

New Drupal Modules - 19 October 2017 - 5:33am
Categories: Drupal

CKEditor Line Height

New Drupal Modules - 19 October 2017 - 4:44am

Integrates CKEditor's Line Height plugin to Drupal's CKEditor integration adding a new button to modify the line height.

Categories: Drupal

Varnish ban URLs

New Drupal Modules - 19 October 2017 - 4:44am

This module uses the Varnish module to provide to the user the possibility of banning a list of URLs from the Varnish cache in any moment.

It creates a new entry in the menu

/admin/content/cache/varnish-ban-urls

Where you can enter a list of URLs that will be banned from the cache.

Categories: Drupal

Amazon Widget

New Drupal Modules - 19 October 2017 - 3:54am

A client side Amazon widget.
This widget will hide the amazon fields and show the relevant items for the country code detected.

Categories: Drupal

Flocon de toile | Freelance Drupal: Filter content by year with Views on Drupal 8

Planet Drupal - 19 October 2017 - 3:00am
It is not uncommon to propose to filter contents according to dates, and in particular depending on the year. How to filter content from a view based on years from a date field? We have an immediate solution using the Search API module coupled with Facets. This last module allows us very easily to add a facet, to a view, based on a date field of our content type, and to choose the granularity (year, month, day) that we wish to expose to the visitors. But if you do not have these two modules for other reasons, it may be a shame to install them just for that. We can get to our ends pretty quickly with a native Views option, the contextual filter. Let's discover in a few images how to get there.
Categories: Drupal

BugHerd API

New Drupal Modules - 19 October 2017 - 1:57am

Drupal integration for BugHerd.

BugHerd turns client feedback into actionable tasks.

Your clients report issues by making annotations right from the site being worked on.

BugHerd turns these into full bug reports with all the info you need to fix the problem.

For more info visit the official BugHerd website

-- SPONSOR --


Categories: Drupal

Visually Impaired Support (module)

New Drupal Modules - 18 October 2017 - 11:56pm
Synopsis

Module provides version for visually impaired people according to Russian legislation

Dependencies

Visually Impaired Theme

You can help!

Repository on GitHub

Donate

You can donate here

Categories: Drupal

Panopoly Media

New Drupal Modules - 18 October 2017 - 10:40pm

Comming soon!

In Panopoly 2.0 for Drupal 8, we're moving the Media configuration to a new Feature (rather than bundling it in with Panopoly Widgets).

Categories: Drupal

CiviMember Roles Sync

New Drupal Modules - 18 October 2017 - 3:57pm

Synchronize CiviCRM Contacts with Membership Status to a specified Drupal Role both automatically and manually.

Categories: Drupal

anonymize

New Drupal Modules - 18 October 2017 - 12:49pm

Anonymize any field with Faker data.

Categories: Drupal

Pages

Subscribe to As If Productions aggregator - Drupal