Welcome Guest, Not a member yet? Register   Sign In
testing a function
#1

[eluser]SPeed_FANat1c[/eluser]
hello,

I have read little bit about unit testing and there are some testings for if function calculates the right value, if it returns the right type.

But I don't understand - how can I test, if my function do some database updates and email sendings the right way.

Ok, I will tell you what function I have.

I have a table, where I store the emails. Each email has its owner, has its creation date, recipient address, text, and sending time.


My function has to send no more than 90 emails per hour. (because of limits by the server or something like that, they told me that the limit is 90 per hour).

And also it is distributed in minutes, so for example it cannot be sent all 90 emails in first 20 minutes. So I will show how many it can be sent max:

first 20 minutes - max 10 emails,
first 30 minuts - max 20 emails,
first 40 minutes - max 50 emails,
and for left minutes in hour - max 90 emails.

And - the owners, who are going to send no more than 5 emails has the priority over those others. Also the sending priority is by the creation time - the older email is, the higher priority.

So thats the problem - I have writtter the script, how can I be sure that all those things I wrote here work in every posible scenario? Smile

I could post the code, but not sure is it worth, maybe some general ideas I need how others make sure similar scripts work well. And in my code there are many lithuanina words, so I then might need to explain, and also much commended lines, so its too unclean.
Ok I post it to pastebin, just in case someone will want to look and to have idea at least how the code looks: http://pastebin.com/qQhQxGvH

Oh, and didn't stay that this script will be executed with CRON, but probably you could guess that already.




Theme © iAndrew 2016 - Forum software by © MyBB