mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '3.6' into 3
This commit is contained in:
commit
09726333b7
29
LICENSE
Normal file
29
LICENSE
Normal file
@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2006-2018, SilverStripe Limited - www.silverstripe.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20
README.md
20
README.md
@ -34,26 +34,6 @@ If you would like to make changes to the SilverStripe core codebase, we have an
|
||||
* [Bugtracker: Installer](https://github.com/silverstripe/silverstripe-installer/issues)
|
||||
* [Forums](http://silverstripe.org/forums)
|
||||
* [Developer Mailinglist](https://groups.google.com/forum/#!forum/silverstripe-dev)
|
||||
|
||||
## License ##
|
||||
|
||||
Copyright (c) 2006-2014, SilverStripe Limited - www.silverstripe.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SilverStripe nor the names of its contributors may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
|
||||
## Attribution ##
|
||||
|
||||
|
@ -551,6 +551,11 @@ class Injector {
|
||||
$constructorParams = $spec['constructor'];
|
||||
}
|
||||
|
||||
// If we're dealing with a DataObject, pass through Singleton flag as second argument
|
||||
if ($type != 'prototype' && empty($constructorParams) && is_subclass_of($class, 'DataObject')) {
|
||||
$constructorParams = array(null, true);
|
||||
}
|
||||
|
||||
$factory = isset($spec['factory']) ? $this->get($spec['factory']) : $this->getObjectCreator();
|
||||
$object = $factory->create($class, $constructorParams);
|
||||
|
||||
|
@ -33,6 +33,51 @@ class DataObjectTest extends SapphireTest {
|
||||
'ManyManyListTest_Category',
|
||||
);
|
||||
|
||||
/**
|
||||
* @dataProvider provideSingletons
|
||||
*/
|
||||
public function testSingleton($inst, $defaultValue, $altDefaultValue)
|
||||
{
|
||||
$inst = $inst();
|
||||
// Test that populateDefaults() isn't called on singletons
|
||||
// which can lead to SQL errors during build, and endless loops
|
||||
if ($defaultValue) {
|
||||
$this->assertEquals($defaultValue, $inst->MyFieldWithDefault);
|
||||
} else {
|
||||
$this->assertEmpty($inst->MyFieldWithDefault);
|
||||
}
|
||||
|
||||
if ($altDefaultValue) {
|
||||
$this->assertEquals($altDefaultValue, $inst->MyFieldWithAltDefault);
|
||||
} else {
|
||||
$this->assertEmpty($inst->MyFieldWithAltDefault);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideSingletons()
|
||||
{
|
||||
// because PHPUnit evalutes test providers *before* setUp methods
|
||||
// any extensions added in the setUp methods won't be available
|
||||
// we must return closures to generate the arguments at run time
|
||||
return array(
|
||||
array(function () {
|
||||
return DataObjectTest_Fixture::create();
|
||||
}, 'Default Value', 'Default Value'),
|
||||
array(function () {
|
||||
return new DataObjectTest_Fixture();
|
||||
}, 'Default Value', 'Default Value'),
|
||||
array(function () {
|
||||
return singleton('DataObjectTest_Fixture');
|
||||
}, null, null),
|
||||
array(function () {
|
||||
return DataObjectTest_Fixture::singleton();
|
||||
}, null, null),
|
||||
array(function () {
|
||||
return new DataObjectTest_Fixture(null, true);
|
||||
}, null, null),
|
||||
);
|
||||
}
|
||||
|
||||
public function testDb() {
|
||||
$obj = new DataObjectTest_TeamComment();
|
||||
$dbFields = $obj->db();
|
||||
|
Loading…
Reference in New Issue
Block a user