Updates from May, 2010 Toggle Comment Threads | Keyboard Shortcuts

  • danielsaidi 11:53 am on May 28, 2010 Permalink | Reply
    Tags: , jsunit, , ,   

    JsUnit vs. QUnit 

    I am rewriting an old JavaScript project and will apply TDD principles when developing the new version. When browsing for various JavaScript TDD frameworks, JsUnit and QUnit seem like the two most promising candidates.

    JsUnit uses a syntax that appeals to me, as an NUnit lover. However, since I am also a big fan of jQuery, QUnit could be a better alternative, although the framework seems quite small (yet, ok, equals and same are maybe sufficient?).

    Has anyone any experience of these two frameworks and could recommend either?

    • Raj 1:31 am on September 26, 2010 Permalink | Reply

      Hi Daniel
      I had the same question for my self. Which one is better? I haven’t tried JsUnit much but I have used QUnit. It seems to me that QUnit is easy to use than JSUnit. Please see the below post for some info.


      • danielsaidi 7:40 pm on October 3, 2010 Permalink | Reply

        Well, as I wrote, I think that the JsUnit syntax feels more “for real”, but I decided to go with QUnit and I have only had good experiences with it. I think that the ok key word – ok(shouldBeTrue) and ok(!shouldBeFalse) – is a bit cheesy, but it really does the job with minimum setup. Also, it makes testing async functionality really smooth. However, I decided to tweak QUnit a bit, so that it only displays failing tests…a loooong list with everything that went ok is really not that informative to me 🙂

      • danielsaidi 7:41 pm on October 3, 2010 Permalink | Reply

        By the way, what did you think of JsSpec? Have you had the time to try it out?

  • danielsaidi 7:03 am on May 26, 2010 Permalink | Reply
    Tags: dirname, , __file__   

    Include and require files within included files in PHP 

    Today, I noticed this nice piece of code within the SimpleTest autorun.php file.

       require_once dirname(__FILE__) . '/unit_tester.php';

    Finding the folder of the current file, and not the executing file, is extremely useful when including/requiring files within files that are included by another page.

    When using dirname(__FILE__), the require operation works relative autorun.php, even if the file is included by another page. If this would not have been used, the page would have tried to look for the unit_tester.php file relative the including file, which would not have worked.

    I have previously solved this kind of folder issues with an “application root” path, but this is also a very nice approach.

    Thank you SimpleTest.

  • danielsaidi 11:17 pm on May 24, 2010 Permalink | Reply
    Tags: multiple, mysql, mysql_connect   

    Multiple mySQL database connections in PHP 

    As I am working on my hobby project Wigbi, I am making it possible to create multiple instances of the DatabaseHandler class, to make it possible to work with multiple databases.

    However, as I shut down one connection, I noticed that all connections were closed. When I investigated the issue further, I realized that even though I created multiple connections, I only had one.

    So, why did I only receive one single connection, although I created multiple ones? The answer lies in the fourth parameter that is sent to the mysql_connect function. If this is not set to true, multiple connections will not be allowed.

    • Matt Smith 4:02 am on January 7, 2011 Permalink | Reply

      You’re right Daniel. Not a big deal, but a great reminder. I almost never use multiple connections in my systems, but when building a system that runs along side another, like WordPress, this is important to prevent a conflict. In fact, that’s my situation tonight, and your blog gave me the reminder I needed about the 4th parameter. Thanks.

      • danielsaidi 11:46 pm on January 10, 2011 Permalink | Reply

        Glad to help, Matt, and thanks for commenting so that I was reminded of this as well 🙂

    • Ray Sterling 5:29 am on February 17, 2012 Permalink | Reply

      Matt, I am trying to connect to a second database that would hold some information for my website running through wordpress as well… How have you accomplished connecting to a second database in order to run queries from that database and present the data in your wordpress site? — Thanks for any help you can supply.

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc