We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13226
    • 953 Posts
    Quote from: markh at Nov 13, 2013, 05:37 PM
    JP works full time for MODX LLC wink

    If I had known that, I wouldn't have written the question !
      • 38290
      • 712 Posts
      It's true. I should probably see about getting my badge changed.
        jpdevries
        • 27708 MODX Staff
        • 2,502 Posts
        I've updated JP's Badge to reflect he is a MODX Staff member.
          Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
          • 3749
          • 24,544 Posts
          Quote from: sottwell at Nov 14, 2013, 12:40 AM

          Probably the second-biggest one (after getting a firm grip on git and github) still remains, though... tests. Many years ago when I was a larval programmer, my library got in a new book, something about mathematically provable programming. At that time it went right over my head, and I've had a phobia ever since. So I have to get a grip on myself and figure out what these "unit test" thingies are all about.

          You can peek at the MyComponent unit tests here: https://github.com/BobRay/MyComponent/tree/master/_build/test

          Here's an excerpt ($this, BTW, is the PHPUnit_Framework_TestCase class which the test class extends):

                  $this->mc->createResources();
                  $resources = $this->mc->props['resources'];
                  $this->assertNotEmpty($resources);
                  $id = null;
                  foreach ($resources as $resource => $fields) {
                      $r = $this->modx->getObject('modResource', array('pagetitle' => $resource));
                      $this->assertInstanceOf('modResource', $r);
                      $pagetitle = $r->get('pagetitle');
                      $this->assertNotEmpty($pagetitle);
                      /* see if parent, template, and TV Values are set properly */
                      if ($pagetitle == 'utResource1') {
                          $this->assertEquals($this->modx->getOption('default_template'), $r->get('template'));
                          $this->assertEquals(0, $r->get('parent'));
                          $id = $r->get('id');
                      } elseif ($pagetitle == 'utResource2') {
                          $templateObj = $this->modx->getObject('modTemplate',
                              array('templatename' => 'utTemplate1'));
                          $templateId = $templateObj->get('id');
                          $this->assertEquals($templateId, $r->get('template'));
                          $this->assertEquals($id, $r->get('parent'));
                          $this->assertEquals('SomeValue', $r->getTVValue('utTv1'));
                          $this->assertEquals('SomeOtherValue', $r->getTVValue('utTv2'));
          
                      } else {
                          /* make sure pagetitles are set properly */
                          assertTrue(false, 'BAD RESOURCE pagetitle');
                      }
                  }


          It's mainly just checking to see that arrays and variables are not empty and values equal what they should.

          It's a great comfort to know that MyComponent passes them all before a new release. When someone reports a bug, I try to add a new test (which fails) before fixing it.

          Unit testing can be pretty addictive.

          BTW, PhpStorm will generate a set of skeleton unit tests for you.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Well, that's startling! I do that sort of thing all the time, it's just common sense to have a way to check your variables and stuff. I didn't know it had a formal designation.

            Well, I don't do it in such an organized fashion, with all those "assert-whatever" methods, but the principle is the same, so it shouldn't be difficult to organize what I've been doing into a more conforming process. I suppose the "unit" part should have been a clue...
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Ok, for installing phpunit, I found post #6 here to work quickly and painlessly - modified to match the actual version of PHP my MAMP installation is using (5.4.10 at this writing) http://stackoverflow.com/questions/5510734/install-pear-on-mamp
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 16278
                • 928 Posts
                Isn't this going a teensy bit off topic? I'd be really interested to know any news about MODX3, when there is some.
                ??? KP
                  • 26931
                  • 2,314 Posts
                  While there may be a 2.4 release, you can expect to see much more discussion and active development on 3.0 once 2.3 is released.
                  why announce it then ?
                    • 18373 ☆ A M B ☆
                    • 3,141 Posts
                    There's not much (if anything) to MODX3 now. Very little has happened on that subject in the past year due to obvious reasons. Why announce it? Well, probably to give the community and the product development a goal to strive for on the long term. A general direction the product will move towards in the future.

                    After 2.3 the planning and development on MODX3 will kick into gear which should provide a process/framework for the community to contribute towards making it a reality.
                      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                      • 38290
                      • 712 Posts
                      Quote from: sharkbait at Nov 15, 2013, 09:35 AM
                      While there may be a 2.4 release, you can expect to see much more discussion and active development on 3.0 once 2.3 is released.
                      why announce it then ?

                      We want the community to understand that if given features don't make it into 2.3 by the Feature Lock (end of November) that we haven't ruled out releasing some minor versions of 2.x between 2.3 and 3.0.
                        jpdevries