@@ -113,6 +113,25 @@ public function testCreateValueInt()
113
113
$ this ->assertEquals (\PHPCR \PropertyType::LONG , $ value ->getType ());
114
114
}
115
115
116
+ /**
117
+ * Test that explicitly setting the type overrides autodetection.
118
+ */
119
+ public function testCreateValueIntWithDouble ()
120
+ {
121
+ $ value = $ this ->node ->setProperty ('propIntNum ' , 100.3 , PropertyType::LONG );
122
+ $ this ->assertInstanceOf ('PHPCR\PropertyInterface ' , $ value );
123
+ $ this ->assertSame ('100 ' , $ value ->getString ());
124
+ $ this ->assertSame (100 , $ value ->getLong ());
125
+ $ this ->assertEquals (\PHPCR \PropertyType::LONG , $ value ->getType ());
126
+
127
+ $ this ->saveAndRenewSession ();
128
+ $ value = $ this ->session ->getProperty ('/tests_general_base/numberPropertyNode/jcr:content/propIntNum ' );
129
+ $ this ->assertSame ('100 ' , $ value ->getString ());
130
+ $ this ->assertSame (100 , $ value ->getLong ());
131
+ $ this ->assertEquals (\PHPCR \PropertyType::LONG , $ value ->getType ());
132
+ }
133
+
134
+
116
135
public function testCreateValueDouble ()
117
136
{
118
137
$ value = $ this ->node ->setProperty ('propDouble ' , 10.6 );
@@ -130,6 +149,26 @@ public function testCreateValueDouble()
130
149
$ this ->assertEquals (\PHPCR \PropertyType::DOUBLE , $ value ->getType ());
131
150
}
132
151
152
+ /**
153
+ * Test that explicitly setting the type overrides autodetection.
154
+ */
155
+ public function testCreateValueDoubleWithInt ()
156
+ {
157
+ $ value = $ this ->node ->setProperty ('propDoubleNum ' , 10 , PropertyType::DOUBLE );
158
+ $ this ->assertInstanceOf ('PHPCR\PropertyInterface ' , $ value );
159
+ $ this ->assertSame ('10 ' , $ value ->getString ());
160
+ $ this ->assertSame (10.0 , $ value ->getDouble ());
161
+ $ this ->assertSame (10 , $ value ->getLong ());
162
+ $ this ->assertEquals (\PHPCR \PropertyType::DOUBLE , $ value ->getType ());
163
+
164
+ $ this ->saveAndRenewSession ();
165
+ $ value = $ this ->session ->getProperty ('/tests_general_base/numberPropertyNode/jcr:content/propDoubleNum ' );
166
+ $ this ->assertSame ('10 ' , $ value ->getString ());
167
+ $ this ->assertSame (10.0 , $ value ->getDouble ());
168
+ $ this ->assertSame (10 , $ value ->getLong ());
169
+ $ this ->assertEquals (\PHPCR \PropertyType::DOUBLE , $ value ->getType ());
170
+ }
171
+
133
172
public function testCreateValueBoolean ()
134
173
{
135
174
$ value = $ this ->node ->setProperty ('propBoolean ' , true );
0 commit comments