File tree Expand file tree Collapse file tree 3 files changed +28
-6
lines changed
Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 33 #superclass : #GlorpTestCase ,
44 #instVars : [
55 ' session' ,
6- ' proxy'
6+ ' proxy' ,
7+ ' result'
78 ],
89 #category : #' Glorp-Integration-Tests-Database'
910}
@@ -23,7 +24,8 @@ GlorpProxyTest >> setUp [
2324 proxy := Proxy new .
2425 proxy session: session.
2526 stub := GlorpQueryStub readOneOf: GlorpAddress where: [:address | address id = 1 ].
26- stub result: 42 .
27+ result: = GlorpAddress new .
28+ stub result: result.
2729 proxy query: stub.
2830 proxy parameters: #()
2931]
@@ -55,7 +57,7 @@ GlorpProxyTest >> testCreation [
5557GlorpProxyTest >> testInstantiationFromStub [
5658
5759 self assert: (proxy getValue notNil).
58- self assert: proxy = 42 .
60+ self assert: proxy equals: result .
5961 self assert: proxy isInstantiated.
6062]
6163
@@ -77,3 +79,20 @@ GlorpProxyTest >> testPrintingUninstantiatedCollection [
7779 proxy query readsOneObject: false .
7880 self assert: proxy printString = ' {uninstantiated collection of GlorpAddress}' .
7981]
82+
83+ { #category : #tests }
84+ GlorpProxyTest >> testSpecies [
85+
86+ self assert: proxy species equals: GlorpAddress
87+ ]
88+
89+ { #category : #tests }
90+ GlorpProxyTest >> testSpeciesisProxy [
91+ " a proxy without a result or a query returns Proxy as species"
92+
93+ | prox |
94+
95+ prox := Proxy new .
96+
97+ self assert: prox species equals: Proxy
98+ ]
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ PharoDatabaseAccessor >> databaseDriver: aDriver [
124124{ #category : #executing }
125125PharoDatabaseAccessor >> disconnect [
126126
127- ^ self connection disconnect
127+ ^ self connection ifNotNil: [ :conn | conn disconnect ]
128128]
129129
130130{ #category : #accessing }
Original file line number Diff line number Diff line change @@ -208,10 +208,13 @@ Proxy >> session: aSession [
208208
209209{ #category : #accessing }
210210Proxy >> species [
211+ " returns the class of the proxied object either by looking at the actual value's class"
212+ " or the expected result of the proxy. Returns Proxy otherwise."
211213
212214 self isInstantiated ifTrue: [^ value species].
213215 query isNil ifTrue: [^ Proxy ].
214- query resultClass isNil ifTrue: [^ Proxy ].
215- ^ query resultClass species
216+ " self traceCr: 'not instantiated'."
217+ ^ query resultClass ifNil: [ Proxy ]
218+
216219
217220]
You can’t perform that action at this time.
0 commit comments