Permalink
Browse files

Changed path logic and tests to reference src folder. For #16

  • Loading branch information...
1 parent 24f4c3b commit 2e96692006beb87c2f21889162b565056a952dcb @dhumphreys committed Aug 4, 2011
View
@@ -0,0 +1,8 @@
+<cfcomponent output="false">
+ <cffunction name="onRequestStart">
+ <cfscript>
+ application.cfrel = {};
+ application.cfrel.cfcPrefix = "src";
+ </cfscript>
+ </cffunction>
+</cfcomponent>
View
@@ -49,11 +49,11 @@
</cfscript>
</cffunction>
-<cffunction name="addCfcPrefix" returntype="string" access="private" hint="Append CFC prefix to path">
+<cffunction name="addCfcPrefix" returntype="string" access="private" hint="Prepend CFC prefix to path">
<cfargument name="path" type="string" required="true">
<cfscript>
if (IsDefined("application.cfrel.cfcPrefix"))
- arguments.path = ListAppend(application.cfrel.cfcPrefix, arguments.path, ".");
+ arguments.path = REReplace(arguments.path, "^cfrel", application.cfrel.cfcPrefix);
</cfscript>
<cfreturn arguments.path />
</cffunction>
@@ -62,7 +62,7 @@
<cfargument name="path" type="string" required="true">
<cfscript>
if (IsDefined("application.cfrel.cfcPrefix"))
- arguments.path = REReplace(arguments.path, "^" & application.cfrel.cfcPrefix & "\.", "");
+ arguments.path = REReplace(arguments.path, "^" & application.cfrel.cfcPrefix, "cfrel");
</cfscript>
<cfreturn arguments.path />
</cffunction>
View
@@ -1,5 +1,5 @@
<cfcomponent extends="mxunit.framework.TestCase" output="false" hint="Base-class test for customer functionality/helpers/assertions">
- <cfinclude template="/cfrel/functions.cfm" />
+ <cfinclude template="/src/functions.cfm" />
<cffunction name="setup" returntype="void" access="private" hint="Set up some defaults">
<cfscript>
View
@@ -19,8 +19,8 @@
<cfscript>
var loc = {};
loc.rel = relation(datasource="cfrel", visitor="SqlServer");
- assertIsTypeOf(loc.rel, "cfrel.Relation");
- assertIsTypeOf(loc.rel.visitor, "cfrel.visitors.SqlServer");
+ assertIsTypeOf(loc.rel, "src.Relation");
+ assertIsTypeOf(loc.rel.visitor, "src.visitors.SqlServer");
assertEquals("cfrel", loc.rel.datasource);
</cfscript>
</cffunction>
@@ -50,19 +50,23 @@
<cffunction name="testAddCfcPrefix" returntype="void" access="public">
<cfscript>
- assertEquals("com.component", addCfcPrefix("com.component"));
- application.cfrel.cfcPrefix = "something";
- assertEquals("something.com.component", addCfcPrefix("com.component"));
- StructDelete(application, "cfrel", false);
+ oldPrefix = application.cfrel.cfcPrefix;
+ StructDelete(application.cfrel, "cfcPrefix");
+ assertEquals("cfrel.component", addCfcPrefix("cfrel.component"));
+ application.cfrel.cfcPrefix = "something.else";
+ assertEquals("something.else.component", addCfcPrefix("cfrel.component"));
+ application.cfrel.cfcPrefix = oldPrefix;
</cfscript>
</cffunction>
<cffunction name="testStripCfcPrefix" returntype="void" access="public">
<cfscript>
- assertEquals("com.component", stripCfcPrefix("com.component"));
- application.cfrel.cfcPrefix = "something";
- assertEquals("com.component", stripCfcPrefix("something.com.component"));
- StructDelete(application, "cfrel", false);
+ oldPrefix = application.cfrel.cfcPrefix;
+ StructDelete(application.cfrel, "cfcPrefix");
+ assertEquals("cfrel.component", stripCfcPrefix("cfrel.component"));
+ application.cfrel.cfcPrefix = "something.else";
+ assertEquals("cfrel.component", stripCfcPrefix("something.else.component"));
+ application.cfrel.cfcPrefix = oldPrefix;
</cfscript>
</cffunction>
View
@@ -4,9 +4,9 @@
<cffunction name="setup" returntype="void" access="public">
<cfscript>
super.setup();
- variables.cfc = "cfrel.Relation";
+ variables.cfc = "src.Relation";
variables.datasourceRel = new(datasource="cfrel").select("id,username,password").from("users");
- variables.sqlVisitor = CreateObject("component", "cfrel.visitors.Sql").init();
+ variables.sqlVisitor = CreateObject("component", "src.visitors.Sql").init();
</cfscript>
</cffunction>
@@ -26,7 +26,7 @@
loc.varCount2 = StructCount(loc.instance);
// make sure init modifies instance, not creating a new one
- assertIsTypeOf(loc.instance, "cfrel.Relation");
+ assertIsTypeOf(loc.instance, "src.Relation");
assertSame(loc.obj, loc.instance, "init() should return same instance");
assertTrue(loc.varCount2 GT loc.varCount1, "init() should define private variables");
</cfscript>
@@ -41,7 +41,7 @@
// make sure datasource and visitor were correctly set
assertEquals("test", loc.instance.datasource, "Datasource should be set through constructor");
- assertIsTypeOf(loc.instance.visitor, "cfrel.visitors.SqlServer");
+ assertIsTypeOf(loc.instance.visitor, "src.visitors.SqlServer");
</cfscript>
</cffunction>
@@ -50,7 +50,7 @@
var loc = {};
loc.factory = new(init=false);
loc.instance = loc.factory.new();
- assertIsTypeOf(loc.instance, "cfrel.Relation");
+ assertIsTypeOf(loc.instance, "src.Relation");
assertNotSame(loc.instance, loc.factory, "new() should create a new instance");
</cfscript>
</cffunction>
@@ -68,7 +68,7 @@
loc.private2 = loc.clone2._inspect();
// make sure that call returns a different relation object
- assertIsTypeOf(loc.clone1, "cfrel.Relation");
+ assertIsTypeOf(loc.clone1, "src.Relation");
assertNotSame(loc.clone1, loc.instance, "clone() should return copy of object, not same one");
assertNotSame(loc.clone1, loc.clone2);
assertNotSame(loc.clone1.sql, loc.instance.sql, "clone() should copy the sql struct, not reference it");
@@ -590,7 +590,7 @@
<cffunction name="testSqlGeneration" returntype="void" access="public">
<cfscript>
var loc = {};
- loc.visitor = CreateObject("component", "cfrel.visitors.Sql").init();
+ loc.visitor = CreateObject("component", "src.visitors.Sql").init();
// generate a simple relation
loc.instance = new().select("a").from("b").where("a > 5").order("a ASC").paginate(2, 15);
@@ -3,7 +3,7 @@
<cffunction name="setup" returntype="void" access="public">
<cfscript>
super.setup();
- variables.cfc = "cfrel.visitors.MySql";
+ variables.cfc = "src.visitors.MySql";
</cfscript>
</cffunction>
</cfcomponent>
@@ -11,7 +11,7 @@
<cfscript>
var loc = {};
loc.sql = new();
- loc.factory = CreateObject("component", "cfrel.Relation");
+ loc.factory = CreateObject("component", "src.Relation");
// build a variety of queries
loc.rel1 = loc.factory.new().select("1 + 2", 3, 4).distinct();
@@ -54,7 +54,7 @@
<cfscript>
var loc = {};
loc.visitor = new();
- loc.rel = new("cfrel.Relation").select(1).from("a");
+ loc.rel = new("src.Relation").select(1).from("a");
loc.input = [5, "a", sqlLiteral("b"), loc.rel];
loc.output = [5, "a", "b", "SELECT 1 FROM a"];
assertEquals(loc.output, loc.visitor.visit(loc.input));
@@ -3,15 +3,15 @@
<cffunction name="setup" returntype="void" access="public">
<cfscript>
super.setup();
- variables.cfc = "cfrel.visitors.SqlServer";
+ variables.cfc = "src.visitors.SqlServer";
</cfscript>
</cffunction>
<cffunction name="testColumnEscaping" returntype="void" access="public">
<cfscript>
var loc = {};
loc.visitor = new();
- loc.relation = new("cfrel.Relation").select("a,b,c,SUM(e)").from("tableD").where(a=5).group("a,b,c").order("b ASC");
+ loc.relation = new("src.Relation").select("a,b,c,SUM(e)").from("tableD").where(a=5).group("a,b,c").order("b ASC");
// set expected value
loc.expected = "SELECT [a], [b], [c], SUM([e]) FROM [tableD] WHERE [a] = ? GROUP BY [a], [b], [c] ORDER BY [b] ASC";
@@ -25,7 +25,7 @@
<cfscript>
var loc = {};
loc.visitor = new();
- loc.factory = CreateObject("component", "cfrel.Relation");
+ loc.factory = CreateObject("component", "src.Relation");
// build a variety of queries
loc.rel1 = loc.factory.new().select("a,b,c,d").distinct().from("example").limit(15);
@@ -46,7 +46,7 @@
var loc = {};
loc.pass = false;
loc.visitor = new();
- loc.rel = new("cfrel.Relation").select("c").offset(5);
+ loc.rel = new("src.Relation").select("c").offset(5);
// should not allow OFFSET without LIMIT
try {
@@ -63,7 +63,7 @@
var loc = {};
loc.pass = false;
loc.visitor = new();
- loc.rel = new("cfrel.Relation").select("c").paginate(2, 10);
+ loc.rel = new("src.Relation").select("c").paginate(2, 10);
// should not allow empty ORDER BY
try {
@@ -81,8 +81,8 @@
loc.visitor = new();
// perform TOP and ROW_NUMBER() style limits on data
- loc.rel1 = new("cfrel.Relation").select("a").order("a ASC").limit(5);
- loc.rel2 = new("cfrel.Relation").select("b").order("b DESC").limit(5).offset(10);
+ loc.rel1 = new("src.Relation").select("a").order("a ASC").limit(5);
+ loc.rel2 = new("src.Relation").select("b").order("b DESC").limit(5).offset(10);
// generate sql string
loc.visitor.visit(loc.rel1);
@@ -3,7 +3,7 @@
<cffunction name="setup" returntype="void" access="public">
<cfscript>
super.setup();
- variables.cfc = "cfrel.visitors.Visitor";
+ variables.cfc = "src.visitors.Visitor";
</cfscript>
</cffunction>

0 comments on commit 2e96692

Please sign in to comment.