Permalink
Browse files

git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@62 406649b4…

…-5d4b-11de-8abc-d1c337b90d21
  • Loading branch information...
1 parent 819120e commit 6b2b2675e8b77cef6616a4507c3da0f5968f5c66 XirisR committed Jan 14, 2010
Showing with 95 additions and 15 deletions.
  1. +32 −15 mongodb-morph/build.xml
  2. +63 −0 mongodb-morph/src/Bootstrap.php
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Mongo Object" default="doc" basedir=".">
- <taskdef classname="phar.PharPackageTask" name="pharpackage"/>
+ <taskdef classname="phar.PharPackageTask2" name="pharpackage2"/>
- <fileset dir="unit-tests" id="unittests">
+ <fileset dir="unit-tests" id="unit-tests">
<include name="**/Test*.php" />
</fileset>
+ <fileset dir="integration-tests" id="integration-tests">
+ <include name="**/Test*.php" />
+ <exclude name="MongoTestCase.php" />
+ </fileset>
+
<fileset dir="src/Morph" id="classes">
<include name="**/*.php" />
</fileset>
@@ -30,28 +35,40 @@
<echo msg="API Documentation Creation Complete" />
</target>
- <target name="unittest" description="Runs Morph unit tests">
- <echo msg="Starting Test Suite" />
+ <target name="unit-test" description="Runs Morph unit tests">
+ <echo msg="Starting Unit Test Suite" />
- <phpunit2 haltonfailure="false" haltonerror="false">
+ <phpunit haltonfailure="false" haltonerror="false">
<formatter type="xml" outfile="test-report.xml" />
<batchtest>
- <fileset refid="unittests" />
+ <fileset refid="unit-tests" />
</batchtest>
- </phpunit2>
+ </phpunit>
<delete dir="doc/test_report" quiet="true" includeemptydirs="true"
verbose="false" failonerror="false" />
<mkdir dir="doc/test_report" />
- <phpunit2report infile="test-report.xml" format="frames"
+ <phpunitreport infile="test-report.xml" format="frames"
todir="doc/test_report" />
<delete file="test-report.xml" />
- <echo msg="Test Suite Complete" />
+ <echo msg="Unit Test Suite Complete" />
</target>
<target name="coverage" description="generates unit test coverage report">
- <exec command="phpunit --coverage-html doc/coverage/ unit-tests/MorphTests.php" checkreturn="false" />
- </target>
+ <exec command="phpunit --coverage-html doc/coverage/ unit-tests/AllTests.php" checkreturn="false" />
+ </target>
+
+ <target name="integration-test" description="Runs Morph integration tests">
+ <echo msg="Starting Integration Test Suite" />
+
+ <phpunit haltonfailure="false" haltonerror="false" printsummary="true">
+ <batchtest>
+ <fileset refid="integration-tests" />
+ </batchtest>
+ </phpunit>
+
+ <echo msg="Integration Test Suite Complete" />
+ </target>
<target name="package" description="builds Morph.phar">
<tstamp>
@@ -60,17 +77,17 @@
<format property="date.build" pattern="%s" />
</tstamp>
- <pharpackage basedir="./src/Morph" destfile="Morph.phar"
- compression="gzip" customStub="./src/MorphStub.php" alias="Morph">
+ <pharpackage2 basedir="./src/Morph" destfile="Morph.phar"
+ compression="gzip" customStub="./src/Bootstrap.php" alias="Morph">
<fileset refid="classes" />
<metadata>
<element name="Created Date" value="${date.created}" />
<element name="Copyright" value="Jonathan Moss (c) 2008-${date.year}" />
<element name="Build" value="${date.build}" />
</metadata>
- </pharpackage>
+ </pharpackage2>
</target>
- <target name="all" description="builds everything" depends="unittest, coverage, doc, package" />
+ <target name="all" description="builds everything" depends="unit-test, coverage, doc, package" />
</project>
@@ -0,0 +1,63 @@
+<?php
+Phar::mapPhar();
+
+/**
+ * Autoloader for the morph package
+ *
+ */
+class MorphAutoloader
+{
+
+ /**
+ * A static array of classes
+ *
+ * @var array
+ */
+ private static $classes = array(
+ 'Morph_Utils' => 'phar://Morph/Utils.php',
+ 'Morph_Iterator' => 'phar://Morph/Iterator.php',
+ 'Morph_Compare_NumericProperty' => 'phar://Morph/Compare/NumericProperty.php',
+ 'Morph_Compare_Property' => 'phar://Morph/Compare/Property.php',
+ 'Morph_Query' => 'phar://Morph/Query.php',
+ 'Morph_Object' => 'phar://Morph/Object.php',
+ 'Morph_ICompare' => 'phar://Morph/ICompare.php',
+ 'Morph_Property_HasMany' => 'phar://Morph/Property/HasMany.php',
+ 'Morph_Property_Date' => 'phar://Morph/Property/Date.php',
+ 'Morph_Property_ComposeMany' => 'phar://Morph/Property/ComposeMany.php',
+ 'Morph_Property_HasOne' => 'phar://Morph/Property/HasOne.php',
+ 'Morph_Property_Enum' => 'phar://Morph/Property/Enum.php',
+ 'Morph_Property_Integer' => 'phar://Morph/Property/Integer.php',
+ 'Morph_Property_File' => 'phar://Morph/Property/File.php',
+ 'Morph_Property_Float' => 'phar://Morph/Property/Float.php',
+ 'Morph_Property_ComposeOne' => 'phar://Morph/Property/ComposeOne.php',
+ 'Morph_Property_String' => 'phar://Morph/Property/String.php',
+ 'Morph_Property_Generic' => 'phar://Morph/Property/Generic.php',
+ 'Morph_Collection' => 'phar://Morph/Collection.php',
+ 'Morph_Query_Property' => 'phar://Morph/Query/Property.php',
+ 'Morph_PropertySet' => 'phar://Morph/PropertySet.php',
+ 'Morph_Storage' => 'phar://Morph/Storage.php',
+ 'Morph_Format_Collection' => 'phar://Morph/Format/Collection.php'
+ );
+
+ /**
+ * Loader function
+ *
+ * @param string $className
+ * @return boolean
+ */
+ public static function load($className)
+ {
+ $isLoaded = false;
+ if (isset(self::$classes[$className])) {
+ include self::$classes[$className];
+ $isLoaded = true;
+ }
+ return $isLoaded;
+ }
+
+}
+
+//register the autoloader
+spl_autoload_register(array('MorphAutoloader', 'load'));
+
+__HALT_COMPILER();

0 comments on commit 6b2b267

Please sign in to comment.