Download & Extend

Write a meaningful test for filetransfer

Project:Drupal core
Version:7.x-dev
Component:other
Category:task
Priority:normal
Assigned:chx
Status:active

Issue Summary

We discussed with snufkin how to test the IRC bot and he indeed writen a client-server pair of simpletest using the existing CLI running script which forks. So we can take that, http://www.rawseo.com/tools.html nanoftp and cook up a test that actually connects to FTP and uploads files.

AttachmentSizeStatusTest resultOperations
nanoftpd-0.0.2.tar_.gz21.8 KBIgnored: Check issue status.NoneNone

Comments

#1

I don't think this is useful. Testing if FTP works (generally as a protocol) is outside the purview of Drupal. If our code is small enough and clear enough, we should be able to isolate calls to ftp, and mock up the ones we cannot isolate.

This is a tenet of unit testing I think is very useful: The ability to separate what the code does from what other code (an FTP server) might be doing or the conditions where the test is run.

A unit test forces you to write code which can be broken down into component pieces, each of which can be validated independently. Look into Mock classes for ways to simulate activities with a server if absolutely needed.

#2

However, if we do a functional testing then we test the actual class instead of a mock class. Even with runkit you cant simulate the wrapper for example... so i believe writing this test is quite meaningful.

nobody click here