Welcome Guest, Not a member yet? Register   Sign In
Poll: Do you write test code for your CodeIgniter application?
You do not have permission to vote in this poll.
Yes
52.17%
12 52.17%
No
47.83%
11 47.83%
Total 23 vote(s) 100%
* You voted for this item. [Show Results]

CodeIgniter Testing Guide - A New Book for Automated Testing
#31

Hi kenjis,

Can you explain if or how unit testing works with active record. I've read a lot of stuff saying it is next to impossible doing unit tests with active record. Would love to hear your opinions on this.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#32

What do you mean by "active record"? And what do you want to test?
If you have sample code to test, show me, please.
Reply
#33

(This post was last modified: 10-28-2015, 03:30 PM by ignitedcms.)

Let me just first say, I have 0 zero experience in unit testing, so forgive me if I sound dumb.

It was more to do with searching and reading other stuff I noticed people bringing unit testing being a problem with active record.
For example:

Quote:In my experience unit testing Active Record entities is next to impossible

http://www.mehdi-khalili.com/orm-anti-pa...ve-record/

I don't fully understand what it means and whether or not it evens applies to codeigniter's active record.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#34

(This post was last modified: 10-28-2015, 06:41 PM by kenjis.)

Don't worry. This book is for you. ;-)

Quote:If one or more of the lines below sounds familiar, this book is perfect for you!
  • I have never written test code.
  • I want to write test code, but I don't know how.
  • I tried to write test code in the past, but I couldn't quite figure it out.

First of all, Active Record is a design pattern and the CodeIgniter 2.x's Active Record is not Active Record.
It is a Query Builder. So the Active Record was renamed to Query Builder in CodeIgniter 3.0.

Second, you don't have to worry about Active Record or not. And you don't have to stick to unit testing.
If unit testing is difficult, you could test with the database.

In the context of CodeIgniter 3.0, we can write unit tests for models. In other words, we can test models
without the database, using mock objects.

How to unit test models is explained in Chapter 6, which was released yesterday.

The answer to your question is like this:
  • It may be difficult to unit test Active Record entities, but is not impossible.
  • But I don't know unit testing them is useful or not. It depends on the code under test
Reply
#35

Hi everyone!

Don't you like command line?

If you don't like CLI or terminal, do you want to know how to use PHPUnit via your web browser?
Reply
#36

command line is fine.
It's faster than web browser.

By the way I don't have camera for photos.
perhaps you can get/buy photos here.
http://www.istockphoto.com/
Reply
#37

We have some candidates, but are still looking for a good photo for our book.

If anybody who knows about the book and finds a good photo for the cover image in the site like
http://www.istockphoto.com/ (it is needed that we can use the photo for our ebook cover
without copyright issues), let me know.
Reply
#38

(This post was last modified: 11-06-2015, 12:20 AM by kenjis.)

I will add additional explanation about how to run PHPUnit via web browser.
It is just addition and optional. If you like CLI, of course you don't need it.

I could release the update including it next week.

[Image: attachment.php?aid=396]

Attached Files Thumbnail(s)
   
Reply
#39

First off - that UI looks pretty nice. Looking forward to seeing it.

Second - I would love to see more info in the book about customizing the PHPUnit process itself. You've done a massive job of putting together elements in your CI PHPUnit Test, but more knowledge of what those files are, what they do, how to customize these things to our own process would be great.
Reply
#40

Thank you for your feedback.

> more knowledge of what those files are, what they do

It seems very advanced topic. It is not suited for the beginners guide.
So I will add an appendix to explain about ci-phpunit-test code.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB