diff --git a/application/Espo/Controllers/Layout.php b/application/Espo/Controllers/Layout.php old mode 100644 new mode 100755 diff --git a/application/Espo/Controllers/Metadata.php b/application/Espo/Controllers/Metadata.php old mode 100644 new mode 100755 diff --git a/application/Espo/Controllers/Settings.php b/application/Espo/Controllers/Settings.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Application.php b/application/Espo/Core/Application.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Base/RecordService.php b/application/Espo/Core/Base/RecordService.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Base/Service.php b/application/Espo/Core/Base/Service.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Container.php b/application/Espo/Core/Container.php old mode 100644 new mode 100755 index b86f774f25..ebc2c5bc6d --- a/application/Espo/Core/Container.php +++ b/application/Espo/Core/Container.php @@ -51,11 +51,6 @@ class Container private function loadSlim() { - /* START: remove for composer */ - require 'vendor/Slim/Slim.php'; - \Slim\Slim::registerAutoloader(); - /* END: remove for composer */ - $this->data['slim'] = new \Slim\Slim(); } diff --git a/application/Espo/Core/Controllers/Base.php b/application/Espo/Core/Controllers/Base.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Controllers/Manager.php b/application/Espo/Core/Controllers/Manager.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Doctrine/EspoConverter.php b/application/Espo/Core/Doctrine/EspoConverter.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Doctrine/ORM/Mapping/Driver/EspoPHPDriver.php b/application/Espo/Core/Doctrine/ORM/Mapping/Driver/EspoPHPDriver.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Loaders/EntityManager.php b/application/Espo/Core/Loaders/EntityManager.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/ServiceFactory.php b/application/Espo/Core/ServiceFactory.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Api/Auth.php b/application/Espo/Core/Utils/Api/Auth.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Api/Rest.php b/application/Espo/Core/Utils/Api/Rest.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Config.php b/application/Espo/Core/Utils/Config.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Datetime.php b/application/Espo/Core/Utils/Datetime.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/File/Manager.php b/application/Espo/Core/Utils/File/Manager.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/File/UniteFiles.php b/application/Espo/Core/Utils/File/UniteFiles.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Json.php b/application/Espo/Core/Utils/Json.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Layout.php b/application/Espo/Core/Utils/Layout.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Log.php b/application/Espo/Core/Utils/Log.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Resolver.php b/application/Espo/Core/Utils/Resolver.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/User.php b/application/Espo/Core/Utils/User.php old mode 100644 new mode 100755 diff --git a/application/Espo/Core/Utils/Util.php b/application/Espo/Core/Utils/Util.php old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/App/settings.json b/application/Espo/Resources/layouts/App/settings.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/Home/dashlets.json b/application/Espo/Resources/layouts/Home/dashlets.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/OutboundEmail/detail.json b/application/Espo/Resources/layouts/OutboundEmail/detail.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/Preferences/detail.json b/application/Espo/Resources/layouts/Preferences/detail.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/Role/relationships.json b/application/Espo/Resources/layouts/Role/relationships.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/Settings/outboundEmail.json b/application/Espo/Resources/layouts/Settings/outboundEmail.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/Settings/settings.json b/application/Espo/Resources/layouts/Settings/settings.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/Settings/userInterface.json b/application/Espo/Resources/layouts/Settings/userInterface.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/Team/relationships.json b/application/Espo/Resources/layouts/Team/relationships.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/User/detail.json b/application/Espo/Resources/layouts/User/detail.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/User/detailSmall.json b/application/Espo/Resources/layouts/User/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/User/filters.json b/application/Espo/Resources/layouts/User/filters.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/User/filtersAdvanced.json b/application/Espo/Resources/layouts/User/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/User/list.json b/application/Espo/Resources/layouts/User/list.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/User/listSmall.json b/application/Espo/Resources/layouts/User/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/layouts/User/massUpdate.json b/application/Espo/Resources/layouts/User/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/app/AdminPanel.json b/application/Espo/Resources/metadata/app/AdminPanel.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/app/defaultDashboardLayout.json b/application/Espo/Resources/metadata/app/defaultDashboardLayout.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/dashlets/Stream.json b/application/Espo/Resources/metadata/dashlets/Stream.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/defs/Bug.json b/application/Espo/Resources/metadata/defs/Bug.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/defs/User.json b/application/Espo/Resources/metadata/defs/User.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/Attachment.json b/application/Espo/Resources/metadata/entityDefs/Attachment.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json b/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/Note.json b/application/Espo/Resources/metadata/entityDefs/Note.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/OutboundEmail.json b/application/Espo/Resources/metadata/entityDefs/OutboundEmail.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/Preferences.json b/application/Espo/Resources/metadata/entityDefs/Preferences.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/Role.json b/application/Espo/Resources/metadata/entityDefs/Role.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/Team.json b/application/Espo/Resources/metadata/entityDefs/Team.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/entityDefs/User.json b/application/Espo/Resources/metadata/entityDefs/User.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/address.json b/application/Espo/Resources/metadata/fields/address.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/array.json b/application/Espo/Resources/metadata/fields/array.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/autoincrement.json b/application/Espo/Resources/metadata/fields/autoincrement.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/base.json b/application/Espo/Resources/metadata/fields/base.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/bool.json b/application/Espo/Resources/metadata/fields/bool.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/currency.json b/application/Espo/Resources/metadata/fields/currency.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/date.json b/application/Espo/Resources/metadata/fields/date.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/datetime.json b/application/Espo/Resources/metadata/fields/datetime.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/email.json b/application/Espo/Resources/metadata/fields/email.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/enum.json b/application/Espo/Resources/metadata/fields/enum.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/enumInt.json b/application/Espo/Resources/metadata/fields/enumInt.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/float.json b/application/Espo/Resources/metadata/fields/float.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/int.json b/application/Espo/Resources/metadata/fields/int.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/link.json b/application/Espo/Resources/metadata/fields/link.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/linkMultiple.json b/application/Espo/Resources/metadata/fields/linkMultiple.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/linkParent.json b/application/Espo/Resources/metadata/fields/linkParent.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/multienum.json b/application/Espo/Resources/metadata/fields/multienum.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/password.json b/application/Espo/Resources/metadata/fields/password.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/personName.json b/application/Espo/Resources/metadata/fields/personName.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/phone.json b/application/Espo/Resources/metadata/fields/phone.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/text.json b/application/Espo/Resources/metadata/fields/text.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/url.json b/application/Espo/Resources/metadata/fields/url.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/fields/varchar.json b/application/Espo/Resources/metadata/fields/varchar.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/scopes/Attachment.json b/application/Espo/Resources/metadata/scopes/Attachment.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/scopes/EmailTemplate.json b/application/Espo/Resources/metadata/scopes/EmailTemplate.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/scopes/Note.json b/application/Espo/Resources/metadata/scopes/Note.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/scopes/OutboundEmail.json b/application/Espo/Resources/metadata/scopes/OutboundEmail.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/scopes/Role.json b/application/Espo/Resources/metadata/scopes/Role.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/scopes/Team.json b/application/Espo/Resources/metadata/scopes/Team.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/scopes/User.json b/application/Espo/Resources/metadata/scopes/User.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/viewDefs/EmailTemplate.json b/application/Espo/Resources/metadata/viewDefs/EmailTemplate.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/viewDefs/OutboundEmail.json b/application/Espo/Resources/metadata/viewDefs/OutboundEmail.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/viewDefs/Role.json b/application/Espo/Resources/metadata/viewDefs/Role.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/viewDefs/Team.json b/application/Espo/Resources/metadata/viewDefs/Team.json old mode 100644 new mode 100755 diff --git a/application/Espo/Resources/metadata/viewDefs/User.json b/application/Espo/Resources/metadata/viewDefs/User.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/detail.json b/application/Modules/Crm/Resources/layouts/Account/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/detailSmall.json b/application/Modules/Crm/Resources/layouts/Account/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/filters.json b/application/Modules/Crm/Resources/layouts/Account/filters.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Account/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/list.json b/application/Modules/Crm/Resources/layouts/Account/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/listSelect.json b/application/Modules/Crm/Resources/layouts/Account/listSelect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/listSmall.json b/application/Modules/Crm/Resources/layouts/Account/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/massUpdate.json b/application/Modules/Crm/Resources/layouts/Account/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Account/relationships.json b/application/Modules/Crm/Resources/layouts/Account/relationships.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Call/detail.json b/application/Modules/Crm/Resources/layouts/Call/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Call/detailSmall.json b/application/Modules/Crm/Resources/layouts/Call/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Call/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Call/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Call/list.json b/application/Modules/Crm/Resources/layouts/Call/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Call/listSelect.json b/application/Modules/Crm/Resources/layouts/Call/listSelect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Call/listSmall.json b/application/Modules/Crm/Resources/layouts/Call/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Call/massUpdate.json b/application/Modules/Crm/Resources/layouts/Call/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Case/detail.json b/application/Modules/Crm/Resources/layouts/Case/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Case/detailSmall.json b/application/Modules/Crm/Resources/layouts/Case/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Case/filters.json b/application/Modules/Crm/Resources/layouts/Case/filters.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Case/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Case/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Case/list.json b/application/Modules/Crm/Resources/layouts/Case/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Case/listSmall.json b/application/Modules/Crm/Resources/layouts/Case/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Case/massUpdate.json b/application/Modules/Crm/Resources/layouts/Case/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Case/relationships.json b/application/Modules/Crm/Resources/layouts/Case/relationships.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Contact/detail.json b/application/Modules/Crm/Resources/layouts/Contact/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Contact/detailSmall.json b/application/Modules/Crm/Resources/layouts/Contact/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Contact/filters.json b/application/Modules/Crm/Resources/layouts/Contact/filters.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Contact/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Contact/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Contact/list.json b/application/Modules/Crm/Resources/layouts/Contact/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Contact/listSelect.json b/application/Modules/Crm/Resources/layouts/Contact/listSelect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Contact/listSmall.json b/application/Modules/Crm/Resources/layouts/Contact/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Contact/relationships.json b/application/Modules/Crm/Resources/layouts/Contact/relationships.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Email/detail.json b/application/Modules/Crm/Resources/layouts/Email/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Email/detailSmall.json b/application/Modules/Crm/Resources/layouts/Email/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/EmailTemplate/detail.json b/application/Modules/Crm/Resources/layouts/EmailTemplate/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/EmailTemplate/detailSmall.json b/application/Modules/Crm/Resources/layouts/EmailTemplate/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/EmailTemplate/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/EmailTemplate/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/InboundEmail/detail.json b/application/Modules/Crm/Resources/layouts/InboundEmail/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/InboundEmail/list.json b/application/Modules/Crm/Resources/layouts/InboundEmail/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/detail.json b/application/Modules/Crm/Resources/layouts/Lead/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/detailSmall.json b/application/Modules/Crm/Resources/layouts/Lead/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/filters.json b/application/Modules/Crm/Resources/layouts/Lead/filters.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Lead/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/list.json b/application/Modules/Crm/Resources/layouts/Lead/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/listDashlet.json b/application/Modules/Crm/Resources/layouts/Lead/listDashlet.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/listSelect.json b/application/Modules/Crm/Resources/layouts/Lead/listSelect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/listSmall.json b/application/Modules/Crm/Resources/layouts/Lead/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/massUpdate.json b/application/Modules/Crm/Resources/layouts/Lead/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Lead/relationships.json b/application/Modules/Crm/Resources/layouts/Lead/relationships.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Meeting/detail.json b/application/Modules/Crm/Resources/layouts/Meeting/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Meeting/detailSmall.json b/application/Modules/Crm/Resources/layouts/Meeting/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Meeting/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Meeting/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Meeting/list.json b/application/Modules/Crm/Resources/layouts/Meeting/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Meeting/listSelect.json b/application/Modules/Crm/Resources/layouts/Meeting/listSelect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Meeting/listSmall.json b/application/Modules/Crm/Resources/layouts/Meeting/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Meeting/massUpdate.json b/application/Modules/Crm/Resources/layouts/Meeting/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Opportunity/detail.json b/application/Modules/Crm/Resources/layouts/Opportunity/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Opportunity/detailSmall.json b/application/Modules/Crm/Resources/layouts/Opportunity/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Opportunity/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Opportunity/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Opportunity/list.json b/application/Modules/Crm/Resources/layouts/Opportunity/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Opportunity/listSelect.json b/application/Modules/Crm/Resources/layouts/Opportunity/listSelect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Opportunity/listSmall.json b/application/Modules/Crm/Resources/layouts/Opportunity/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Opportunity/massUpdate.json b/application/Modules/Crm/Resources/layouts/Opportunity/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Opportunity/relationships.json b/application/Modules/Crm/Resources/layouts/Opportunity/relationships.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Prospect/detail.json b/application/Modules/Crm/Resources/layouts/Prospect/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Prospect/detailSmall.json b/application/Modules/Crm/Resources/layouts/Prospect/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Prospect/filters.json b/application/Modules/Crm/Resources/layouts/Prospect/filters.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Prospect/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Prospect/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Prospect/list.json b/application/Modules/Crm/Resources/layouts/Prospect/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Prospect/listSmall.json b/application/Modules/Crm/Resources/layouts/Prospect/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Prospect/massUpdate.json b/application/Modules/Crm/Resources/layouts/Prospect/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Prospect/relationships.json b/application/Modules/Crm/Resources/layouts/Prospect/relationships.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Task/detail.json b/application/Modules/Crm/Resources/layouts/Task/detail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Task/detailSmall.json b/application/Modules/Crm/Resources/layouts/Task/detailSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Task/filtersAdvanced.json b/application/Modules/Crm/Resources/layouts/Task/filtersAdvanced.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Task/list.json b/application/Modules/Crm/Resources/layouts/Task/list.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Task/listSelect.json b/application/Modules/Crm/Resources/layouts/Task/listSelect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Task/listSmall.json b/application/Modules/Crm/Resources/layouts/Task/listSmall.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Task/massUpdate.json b/application/Modules/Crm/Resources/layouts/Task/massUpdate.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/layouts/Task/relationships.json b/application/Modules/Crm/Resources/layouts/Task/relationships.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/Calendar.json b/application/Modules/Crm/Resources/metadata/dashlets/Calendar.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/Cases.json b/application/Modules/Crm/Resources/metadata/dashlets/Cases.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/Leads.json b/application/Modules/Crm/Resources/metadata/dashlets/Leads.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/Opportunities.json b/application/Modules/Crm/Resources/metadata/dashlets/Opportunities.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/OpportunitiesByLeadSource.json b/application/Modules/Crm/Resources/metadata/dashlets/OpportunitiesByLeadSource.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/OpportunitiesByStage.json b/application/Modules/Crm/Resources/metadata/dashlets/OpportunitiesByStage.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/SalesByMonth.json b/application/Modules/Crm/Resources/metadata/dashlets/SalesByMonth.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/SalesPipeline.json b/application/Modules/Crm/Resources/metadata/dashlets/SalesPipeline.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/dashlets/Tasks.json b/application/Modules/Crm/Resources/metadata/dashlets/Tasks.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/defs/Contact.json b/application/Modules/Crm/Resources/metadata/defs/Contact.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/defs/Product.json b/application/Modules/Crm/Resources/metadata/defs/Product.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/defs/unset.json b/application/Modules/Crm/Resources/metadata/defs/unset.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Account.json b/application/Modules/Crm/Resources/metadata/entityDefs/Account.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Call.json b/application/Modules/Crm/Resources/metadata/entityDefs/Call.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Case.json b/application/Modules/Crm/Resources/metadata/entityDefs/Case.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Contact.json b/application/Modules/Crm/Resources/metadata/entityDefs/Contact.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Email.json b/application/Modules/Crm/Resources/metadata/entityDefs/Email.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/InboundEmail.json b/application/Modules/Crm/Resources/metadata/entityDefs/InboundEmail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Modules/Crm/Resources/metadata/entityDefs/Lead.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Meeting.json b/application/Modules/Crm/Resources/metadata/entityDefs/Meeting.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json b/application/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Prospect.json b/application/Modules/Crm/Resources/metadata/entityDefs/Prospect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/entityDefs/Task.json b/application/Modules/Crm/Resources/metadata/entityDefs/Task.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Account.json b/application/Modules/Crm/Resources/metadata/scopes/Account.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Calendar.json b/application/Modules/Crm/Resources/metadata/scopes/Calendar.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Call.json b/application/Modules/Crm/Resources/metadata/scopes/Call.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Case.json b/application/Modules/Crm/Resources/metadata/scopes/Case.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Contact.json b/application/Modules/Crm/Resources/metadata/scopes/Contact.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Email.json b/application/Modules/Crm/Resources/metadata/scopes/Email.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/InboundEmail.json b/application/Modules/Crm/Resources/metadata/scopes/InboundEmail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Lead.json b/application/Modules/Crm/Resources/metadata/scopes/Lead.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Meeting.json b/application/Modules/Crm/Resources/metadata/scopes/Meeting.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Opportunity.json b/application/Modules/Crm/Resources/metadata/scopes/Opportunity.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Prospect.json b/application/Modules/Crm/Resources/metadata/scopes/Prospect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/scopes/Task.json b/application/Modules/Crm/Resources/metadata/scopes/Task.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Account.json b/application/Modules/Crm/Resources/metadata/viewDefs/Account.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Call.json b/application/Modules/Crm/Resources/metadata/viewDefs/Call.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Case.json b/application/Modules/Crm/Resources/metadata/viewDefs/Case.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Contact.json b/application/Modules/Crm/Resources/metadata/viewDefs/Contact.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/InboundEmail.json b/application/Modules/Crm/Resources/metadata/viewDefs/InboundEmail.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Lead.json b/application/Modules/Crm/Resources/metadata/viewDefs/Lead.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Meeting.json b/application/Modules/Crm/Resources/metadata/viewDefs/Meeting.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Opportunity.json b/application/Modules/Crm/Resources/metadata/viewDefs/Opportunity.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Prospect.json b/application/Modules/Crm/Resources/metadata/viewDefs/Prospect.json old mode 100644 new mode 100755 diff --git a/application/Modules/Crm/Resources/metadata/viewDefs/Task.json b/application/Modules/Crm/Resources/metadata/viewDefs/Task.json old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json index ff986abf6e..c34ed9b8b4 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "require": { - "doctrine/orm": "2.*", + "doctrine/orm": "2.4.*", + "symfony/yaml": "2.*", "slim/slim": "2.*" }, "autoload": { diff --git a/composer.lock b/composer.lock index 4f20fea9ff..a210e4f40c 100755 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "419e58f2a1bfcd26cbc0a6bedc700103", + "hash": "2d47d82de4e8d58c920ca5f5225becfd", "packages": [ { "name": "doctrine/annotations", @@ -45,7 +45,8 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" + "homepage": "http://www.jwage.com/", + "role": "Creator" }, { "name": "Guilherme Blanco", @@ -78,16 +79,16 @@ }, { "name": "doctrine/cache", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "d0e4447707a064a5814b18cb0dcc2f24185f6179" + "reference": "e16d7adf45664a50fa86f515b6d5e7f670130449" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/d0e4447707a064a5814b18cb0dcc2f24185f6179", - "reference": "d0e4447707a064a5814b18cb0dcc2f24185f6179", + "url": "https://api.github.com/repos/doctrine/cache/zipball/e16d7adf45664a50fa86f515b6d5e7f670130449", + "reference": "e16d7adf45664a50fa86f515b6d5e7f670130449", "shasum": "" }, "require": { @@ -96,6 +97,10 @@ "conflict": { "doctrine/common": ">2.2,<2.4" }, + "require-dev": { + "phpunit/phpunit": ">=3.7", + "satooshi/php-coveralls": "~0.6" + }, "type": "library", "extra": { "branch-alias": { @@ -113,9 +118,10 @@ ], "authors": [ { - "name": "Jonathan Wage", + "name": "Jonathan H. Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" + "homepage": "http://www.jwage.com/", + "role": "Creator" }, { "name": "Guilherme Blanco", @@ -143,7 +149,7 @@ "cache", "caching" ], - "time": "2013-09-26 19:23:25" + "time": "2013-10-25 19:04:14" }, { "name": "doctrine/collections", @@ -181,7 +187,8 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" + "homepage": "http://www.jwage.com/", + "role": "Creator" }, { "name": "Guilherme Blanco", @@ -253,7 +260,8 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" + "homepage": "http://www.jwage.com/", + "role": "Creator" }, { "name": "Guilherme Blanco", @@ -288,16 +296,16 @@ }, { "name": "doctrine/dbal", - "version": "v2.4.0", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "3eb557f144ec41e6e84997e43acb1946c92fbc88" + "reference": "328357bd9eea9d671fe5fff0737f01953bfe66a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/3eb557f144ec41e6e84997e43acb1946c92fbc88", - "reference": "3eb557f144ec41e6e84997e43acb1946c92fbc88", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/328357bd9eea9d671fe5fff0737f01953bfe66a0", + "reference": "328357bd9eea9d671fe5fff0737f01953bfe66a0", "shasum": "" }, "require": { @@ -325,7 +333,8 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" + "homepage": "http://www.jwage.com/", + "role": "Creator" }, { "name": "Guilherme Blanco", @@ -349,7 +358,7 @@ "persistence", "queryobject" ], - "time": "2013-09-07 10:49:18" + "time": "2013-11-12 12:38:28" }, { "name": "doctrine/inflector", @@ -382,7 +391,8 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" + "homepage": "http://www.jwage.com/", + "role": "Creator" }, { "name": "Guilherme Blanco", @@ -400,7 +410,7 @@ { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", + "homepage": "http://jmsyst.com", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -468,16 +478,16 @@ }, { "name": "doctrine/orm", - "version": "v2.4.0", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/doctrine2.git", - "reference": "57705e0d781719b96daf322a6d6f66ff21e3cdc9" + "reference": "84373d05a4198ec380918d535abf83c454c3867f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/57705e0d781719b96daf322a6d6f66ff21e3cdc9", - "reference": "57705e0d781719b96daf322a6d6f66ff21e3cdc9", + "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/84373d05a4198ec380918d535abf83c454c3867f", + "reference": "84373d05a4198ec380918d535abf83c454c3867f", "shasum": "" }, "require": { @@ -517,7 +527,8 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" + "homepage": "http://www.jwage.com/", + "role": "Creator" }, { "name": "Guilherme Blanco", @@ -539,7 +550,7 @@ "database", "orm" ], - "time": "2013-09-07 16:19:56" + "time": "2013-11-12 12:40:13" }, { "name": "slim/slim", @@ -586,17 +597,17 @@ }, { "name": "symfony/console", - "version": "v2.3.6", + "version": "v2.3.7", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "f880062d56edefb25b36f2defa65aafe65959dc7" + "reference": "00848d3e13cf512e77c7498c2b3b0192f61f4b18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/f880062d56edefb25b36f2defa65aafe65959dc7", - "reference": "f880062d56edefb25b36f2defa65aafe65959dc7", + "url": "https://api.github.com/repos/symfony/Console/zipball/00848d3e13cf512e77c7498c2b3b0192f61f4b18", + "reference": "00848d3e13cf512e77c7498c2b3b0192f61f4b18", "shasum": "" }, "require": { @@ -635,7 +646,54 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2013-09-25 06:04:15" + "time": "2013-11-13 21:27:40" + }, + { + "name": "symfony/yaml", + "version": "v2.3.7", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "c1bda5b459d792cb253de12c65beba3040163b2b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/c1bda5b459d792cb253de12c65beba3040163b2b", + "reference": "c1bda5b459d792cb253de12c65beba3040163b2b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2013-10-17 11:48:01" } ], "packages-dev": [ @@ -1005,53 +1063,6 @@ "xunit" ], "time": "2013-01-13 10:24:48" - }, - { - "name": "symfony/yaml", - "version": "v2.3.6", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "6bb881b948368482e1abf1a75c08bcf88a1c5fc3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/6bb881b948368482e1abf1a75c08bcf88a1c5fc3", - "reference": "6bb881b948368482e1abf1a75c08bcf88a1c5fc3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2013-09-22 18:04:39" } ], "aliases": [ diff --git a/composer.phar b/composer.phar index 73a5170cf5..9ff64bb441 100755 Binary files a/composer.phar and b/composer.phar differ diff --git a/tests/Api/LayoutTest.php b/tests/Api/LayoutTest.php old mode 100644 new mode 100755 diff --git a/tests/Api/MetadataTest.php b/tests/Api/MetadataTest.php old mode 100644 new mode 100755 diff --git a/tests/Api/RestTesterClass.php b/tests/Api/RestTesterClass.php old mode 100644 new mode 100755 diff --git a/tests/Api/SettingsTest.php b/tests/Api/SettingsTest.php old mode 100644 new mode 100755 diff --git a/tests/config.php b/tests/config.php old mode 100644 new mode 100755 diff --git a/tests/testBootstrap.php b/tests/testBootstrap.php old mode 100644 new mode 100755 diff --git a/vendor/Slim/Middleware/HttpBasicAuth.php b/vendor/Slim/Middleware/HttpBasicAuth.php deleted file mode 100755 index d473b8d5a6..0000000000 --- a/vendor/Slim/Middleware/HttpBasicAuth.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @version 1.0 - * @copyright 2012 Josh Lockhart - * - * USAGE - * - * $app = new \Slim\Slim(); - * $app->add(new \Slim\Extras\Middleware\HttpBasicAuth('theUsername', 'thePassword')); - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Extras\Middleware; - -class HttpBasicAuth extends \Slim\Middleware -{ - /** - * @var string - */ - protected $realm; - - /** - * @var string - */ - protected $username; - - /** - * @var string - */ - protected $password; - - /** - * Constructor - * - * @param string $username The HTTP Authentication username - * @param string $password The HTTP Authentication password - * @param string $realm The HTTP Authentication realm - */ - public function __construct($username, $password, $realm = 'Protected Area') - { - $this->username = $username; - $this->password = $password; - $this->realm = $realm; - } - - /** - * Call - * - * This method will check the HTTP request headers for previous authentication. If - * the request has already authenticated, the next middleware is called. Otherwise, - * a 401 Authentication Required response is returned to the client. - */ - public function call() - { - $req = $this->app->request(); - $res = $this->app->response(); - $authUser = $req->headers('PHP_AUTH_USER'); - $authPass = $req->headers('PHP_AUTH_PW'); - if ($authUser && $authPass && $authUser === $this->username && $authPass === $this->password) { - $this->next->call(); - } else { - $res->status(401); - $res->header('WWW-Authenticate', sprintf('Basic realm="%s"', $this->realm)); - } - } -} diff --git a/vendor/autoload.php b/vendor/autoload.php index ace040ac12..cea0f7a69d 100755 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -1,7 +1,7 @@ $vendorDir . '/phpunit/php-token-stream/PHP/Token.php', 'PHP_Token_CLASS' => $vendorDir . '/phpunit/php-token-stream/PHP/Token.php', 'PHP_Token_CLASS_C' => $vendorDir . '/phpunit/php-token-stream/PHP/Token.php', + 'PHP_Token_CLASS_NAME_CONSTANT' => $vendorDir . '/phpunit/php-token-stream/PHP/Token.php', 'PHP_Token_CLONE' => $vendorDir . '/phpunit/php-token-stream/PHP/Token.php', 'PHP_Token_CLOSE_BRACKET' => $vendorDir . '/phpunit/php-token-stream/PHP/Token.php', 'PHP_Token_CLOSE_CURLY' => $vendorDir . '/phpunit/php-token-stream/PHP/Token.php', diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 9523d88e19..ebb7a3dc52 100755 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -1,6 +1,6 @@ array($vendorDir . '/symfony/yaml'), 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'), - 'Doctrine\\ORM' => array($vendorDir . '/doctrine/orm/lib'), - 'Doctrine\\DBAL' => array($vendorDir . '/doctrine/dbal/lib'), - 'Doctrine\\Common' => array($vendorDir . '/doctrine/common/lib'), + 'Slim' => array($vendorDir . '/slim/slim'), + 'Doctrine\\ORM\\' => array($vendorDir . '/doctrine/orm/lib'), + 'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib'), + 'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'), + 'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'), + 'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'), + 'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'), + 'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'), + 'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib'), '' => array($baseDir . '/application'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 205232fdcf..71686893fd 100755 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -1,8 +1,8 @@ =5.3.2" - }, - "time": "2012-09-19 22:55:18", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Doctrine\\Common": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "Common Library for Doctrine projects", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "collections", - "eventmanager", - "persistence", - "spl" - ] - }, - { - "name": "symfony/console", - "version": "v2.3.3", - "version_normalized": "2.3.3.0", - "target-dir": "Symfony/Component/Console", - "source": { - "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "v2.3.3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/v2.3.3", - "reference": "v2.3.3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/event-dispatcher": "~2.1" - }, - "suggest": { - "symfony/event-dispatcher": "" - }, - "time": "2013-07-21 12:12:18", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Console\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "http://symfony.com" - }, - { - "name": "doctrine/dbal", - "version": "2.3.4", - "version_normalized": "2.3.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/dbal.git", - "reference": "2.3.4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/2.3.4", - "reference": "2.3.4", - "shasum": "" - }, - "require": { - "doctrine/common": ">=2.3.0,<2.5-dev", - "php": ">=5.3.2" - }, - "time": "2013-05-11 07:45:37", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Doctrine\\DBAL": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - } - ], - "description": "Database Abstraction Layer", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "database", - "dbal", - "persistence", - "queryobject" - ] - }, - { - "name": "doctrine/orm", - "version": "2.3.4", - "version_normalized": "2.3.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/doctrine2.git", - "reference": "2.3.4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/2.3.4", - "reference": "2.3.4", - "shasum": "" - }, - "require": { - "doctrine/dbal": "2.3.*", - "ext-pdo": "*", - "php": ">=5.3.2", - "symfony/console": "2.*" - }, - "suggest": { - "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" - }, - "time": "2013-05-11 07:51:12", - "bin": [ - "bin/doctrine", - "bin/doctrine.php" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Doctrine\\ORM": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - } - ], - "description": "Object-Relational-Mapper for PHP", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "database", - "orm" - ] - }, - { - "name": "symfony/yaml", - "version": "v2.3.3", - "version_normalized": "2.3.3.0", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "3837ccd0830ef44ed5c5844403bf6f69f7998758" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/3837ccd0830ef44ed5c5844403bf6f69f7998758", - "reference": "3837ccd0830ef44ed5c5844403bf6f69f7998758", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "time": "2013-07-21 12:12:18", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com" - }, { "name": "phpunit/php-text-template", "version": "1.1.4", @@ -455,25 +143,692 @@ ] }, { - "name": "phpunit/php-token-stream", - "version": "1.2.0", - "version_normalized": "1.2.0.0", + "name": "doctrine/lexer", + "version": "v1.0", + "version_normalized": "1.0.0.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1.2.0" + "url": "https://github.com/doctrine/lexer.git", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1.2.0", - "reference": "1.2.0", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2013-01-12 18:59:04", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ] + }, + { + "name": "doctrine/annotations", + "version": "v1.1.2", + "version_normalized": "1.1.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "40db0c96985aab2822edbc4848b3bd2429e02670" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/40db0c96985aab2822edbc4848b3bd2429e02670", + "reference": "40db0c96985aab2822edbc4848b3bd2429e02670", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "doctrine/cache": "1.*" + }, + "time": "2013-06-16 21:33:03", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ] + }, + { + "name": "doctrine/collections", + "version": "v1.1", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "560f29c39cfcfbcd210e5d549d993a39d898b04b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/560f29c39cfcfbcd210e5d549d993a39d898b04b", + "reference": "560f29c39cfcfbcd210e5d549d993a39d898b04b", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2013-03-07 12:15:54", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ] + }, + { + "name": "doctrine/cache", + "version": "v1.3.0", + "version_normalized": "1.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "e16d7adf45664a50fa86f515b6d5e7f670130449" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/e16d7adf45664a50fa86f515b6d5e7f670130449", + "reference": "e16d7adf45664a50fa86f515b6d5e7f670130449", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "phpunit/phpunit": ">=3.7", + "satooshi/php-coveralls": "~0.6" + }, + "time": "2013-10-25 19:04:14", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Cache\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan H. Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ] + }, + { + "name": "doctrine/inflector", + "version": "v1.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "54b8333d2a5682afdc690060c1cf384ba9f47f08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/54b8333d2a5682afdc690060c1cf384ba9f47f08", + "reference": "54b8333d2a5682afdc690060c1cf384ba9f47f08", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2013-01-10 21:49:15", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Inflector\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluarlize", + "singuarlize", + "string" + ] + }, + { + "name": "doctrine/common", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "ceb18cf9b0230f3ea208b6238130fd415abda0a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/ceb18cf9b0230f3ea208b6238130fd415abda0a7", + "reference": "ceb18cf9b0230f3ea208b6238130fd415abda0a7", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "time": "2013-09-07 10:20:34", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ] + }, + { + "name": "symfony/console", + "version": "v2.3.7", + "version_normalized": "2.3.7.0", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "00848d3e13cf512e77c7498c2b3b0192f61f4b18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/00848d3e13cf512e77c7498c2b3b0192f61f4b18", + "reference": "00848d3e13cf512e77c7498c2b3b0192f61f4b18", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "" + }, + "time": "2013-11-13 21:27:40", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "http://symfony.com" + }, + { + "name": "doctrine/dbal", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "328357bd9eea9d671fe5fff0737f01953bfe66a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/328357bd9eea9d671fe5fff0737f01953bfe66a0", + "reference": "328357bd9eea9d671fe5fff0737f01953bfe66a0", + "shasum": "" + }, + "require": { + "doctrine/common": "~2.4", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "symfony/console": "~2.0" + }, + "suggest": { + "symfony/console": "Allows use of the command line interface" + }, + "time": "2013-11-12 12:38:28", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\DBAL\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + } + ], + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "persistence", + "queryobject" + ] + }, + { + "name": "doctrine/orm", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/doctrine2.git", + "reference": "84373d05a4198ec380918d535abf83c454c3867f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/84373d05a4198ec380918d535abf83c454c3867f", + "reference": "84373d05a4198ec380918d535abf83c454c3867f", + "shasum": "" + }, + "require": { + "doctrine/collections": "~1.1", + "doctrine/dbal": "~2.4", + "ext-pdo": "*", + "php": ">=5.3.2", + "symfony/console": "~2.0" + }, + "require-dev": { + "satooshi/php-coveralls": "dev-master", + "symfony/yaml": "~2.1" + }, + "suggest": { + "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" + }, + "time": "2013-11-12 12:40:13", + "bin": [ + "bin/doctrine", + "bin/doctrine.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\ORM\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + } + ], + "description": "Object-Relational-Mapper for PHP", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "orm" + ] + }, + { + "name": "symfony/yaml", + "version": "v2.3.7", + "version_normalized": "2.3.7.0", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "c1bda5b459d792cb253de12c65beba3040163b2b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/c1bda5b459d792cb253de12c65beba3040163b2b", + "reference": "c1bda5b459d792cb253de12c65beba3040163b2b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2013-10-17 11:48:01", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.2.1", + "version_normalized": "1.2.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", + "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", "shasum": "" }, "require": { "ext-tokenizer": "*", "php": ">=5.3.3" }, - "time": "2013-08-04 05:57:48", + "time": "2013-09-13 04:58:23", "type": "library", "extra": { "branch-alias": { @@ -508,23 +863,23 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.3.3", - "version_normalized": "1.3.3.0", + "version": "1.3.4", + "version_normalized": "1.3.4.0", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "1.3.3" + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-file-iterator/zipball/1.3.3", - "reference": "1.3.3", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-10-11 04:44:38", + "time": "2013-10-10 15:34:57", "type": "library", "installation-source": "dist", "autoload": { @@ -547,7 +902,7 @@ } ], "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", "keywords": [ "filesystem", "iterator" @@ -555,17 +910,17 @@ }, { "name": "phpunit/php-code-coverage", - "version": "1.2.12", - "version_normalized": "1.2.12.0", + "version": "1.2.13", + "version_normalized": "1.2.13.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "0e9958c459d675fb497d8dc5001c91d335734e48" + "reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e9958c459d675fb497d8dc5001c91d335734e48", - "reference": "0e9958c459d675fb497d8dc5001c91d335734e48", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/466e7cd2554b4e264c9e3f31216d25ac0e5f3d94", + "reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94", "shasum": "" }, "require": { @@ -581,7 +936,7 @@ "ext-dom": "*", "ext-xdebug": ">=2.0.5" }, - "time": "2013-07-06 06:26:16", + "time": "2013-09-10 08:14:32", "type": "library", "extra": { "branch-alias": { @@ -618,17 +973,17 @@ }, { "name": "phpunit/phpunit", - "version": "3.7.24", - "version_normalized": "3.7.24.0", + "version": "3.7.28", + "version_normalized": "3.7.28.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3.7.24" + "reference": "3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.24", - "reference": "3.7.24", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d", + "reference": "3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d", "shasum": "" }, "require": { @@ -653,7 +1008,7 @@ "ext-tokenizer": "*", "phpunit/php-invoker": ">=1.1.0,<1.2.0" }, - "time": "2013-08-09 06:58:24", + "time": "2013-10-17 07:27:40", "bin": [ "composer/bin/phpunit" ], @@ -691,5 +1046,50 @@ "testing", "xunit" ] + }, + { + "name": "slim/slim", + "version": "2.2.0", + "version_normalized": "2.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/codeguy/Slim.git", + "reference": "b8181de1112a1e2f565b40158b621c34ded38053" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeguy/Slim/zipball/b8181de1112a1e2f565b40158b621c34ded38053", + "reference": "b8181de1112a1e2f565b40158b621c34ded38053", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2012-12-13 02:15:50", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Slim": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Josh Lockhart", + "email": "info@joshlockhart.com", + "homepage": "http://www.joshlockhart.com/" + } + ], + "description": "Slim Framework, a PHP micro framework", + "homepage": "http://github.com/codeguy/Slim", + "keywords": [ + "microframework", + "rest", + "router" + ] } ] diff --git a/vendor/doctrine/annotations/.gitignore b/vendor/doctrine/annotations/.gitignore new file mode 100644 index 0000000000..164c346629 --- /dev/null +++ b/vendor/doctrine/annotations/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +composer.phar diff --git a/vendor/doctrine/annotations/.travis.yml b/vendor/doctrine/annotations/.travis.yml new file mode 100644 index 0000000000..f3dcb237f3 --- /dev/null +++ b/vendor/doctrine/annotations/.travis.yml @@ -0,0 +1,9 @@ +language: php + +php: + - 5.3 + - 5.4 + +before_script: + - composer --prefer-source --dev install + - phpunit diff --git a/vendor/doctrine/annotations/README.md b/vendor/doctrine/annotations/README.md new file mode 100644 index 0000000000..faad51fcfc --- /dev/null +++ b/vendor/doctrine/annotations/README.md @@ -0,0 +1,11 @@ +# Doctrine Annotations + +[![Build Status](https://travis-ci.org/doctrine/annotations.png?branch=master)](https://travis-ci.org/doctrine/annotations) + +Docblock Annotations Parser library (extracted from Doctrine Common). + +## Changelog + +### v1.1 + +* Add Exception when ZendOptimizer+ or Opcache is configured to drop comments diff --git a/vendor/doctrine/annotations/composer.json b/vendor/doctrine/annotations/composer.json new file mode 100644 index 0000000000..3569cf4c2b --- /dev/null +++ b/vendor/doctrine/annotations/composer.json @@ -0,0 +1,30 @@ +{ + "name": "doctrine/annotations", + "type": "library", + "description": "Docblock Annotations Parser", + "keywords": ["annotations", "docblock", "parser"], + "homepage": "http://www.doctrine-project.org", + "license": "MIT", + "authors": [ + {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, + {"name": "Roman Borschel", "email": "roman@code-factory.org"}, + {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, + {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, + {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} + ], + "require": { + "php": ">=5.3.2", + "doctrine/lexer": "1.*" + }, + "require-dev": { + "doctrine/cache": "1.*" + }, + "autoload": { + "psr-0": { "Doctrine\\Common\\Annotations\\": "lib/" } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attribute.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attribute.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attribute.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attribute.php diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attributes.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attributes.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attributes.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attributes.php diff --git a/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php new file mode 100644 index 0000000000..315812f592 --- /dev/null +++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php @@ -0,0 +1,85 @@ +. + */ + +namespace Doctrine\Common\Annotations\Annotation; + +/** + * Annotation that can be used to signal to the parser + * to check the available values during the parsing process. + * + * @since 2.4 + * @author Fabio B. Silva + * + * @Annotation + * @Attributes({ + * @Attribute("value", required = true, type = "array"), + * @Attribute("literal", required = false, type = "array") + * }) + */ +final class Enum +{ + /** + * @var array + */ + public $value; + + /** + * Literal target declaration. + * + * @var array + */ + public $literal; + + /** + * Annotation construct + * + * @param array $values + * + * @throws \InvalidArgumentException + */ + public function __construct(array $values) + { + if ( ! isset($values['literal'])) { + $values['literal'] = array(); + } + + foreach ($values['value'] as $var) { + if( ! is_scalar($var)) { + throw new \InvalidArgumentException(sprintf( + '@Enum supports only scalar values "%s" given.', + is_object($var) ? get_class($var) : gettype($var) + )); + } + } + + foreach ($values['literal'] as $key => $var) { + if( ! in_array($key, $values['value'])) { + throw new \InvalidArgumentException(sprintf( + 'Undefined enumerator value "%s" for literal "%s".', + $key , $var + )); + } + } + + $this->value = $values['value']; + $this->literal = $values['literal']; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Required.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Required.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Required.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Required.php diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Target.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Target.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php old mode 100755 new mode 100644 similarity index 81% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php index 109beeb96d..6cdb6615f3 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php +++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php @@ -124,4 +124,35 @@ class AnnotationException extends \Exception $expected )); } + + /** + * Creates a new AnnotationException describing a invalid enummerator. + * + * @since 2.4 + * @param string $attributeName + * @param string $annotationName + * @param string $context + * @param array $available + * @param mixed $given + * @return AnnotationException + */ + public static function enumeratorError($attributeName, $annotationName, $context, $available, $given) + { + throw new self(sprintf( + '[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.', + $attributeName, + $annotationName, + $context, + implode(', ', $available), + is_object($given) ? get_class($given) : $given + )); + } + + /** + * @return AnnotationException + */ + public static function optimizerPlusSaveComments() + { + throw new self("You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1."); + } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php old mode 100755 new mode 100644 similarity index 95% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php index 286e7d09db..ad4a264910 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php +++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php @@ -60,7 +60,7 @@ class AnnotationReader implements Reader 'subpackage'=> true, 'name'=> true, 'global'=> true, 'param'=> true, 'return'=> true, 'staticvar'=> true, 'category'=> true, 'staticVar'=> true, 'static'=> true, 'var'=> true, 'throws'=> true, 'inheritdoc'=> true, - 'inheritDoc'=> true, 'license'=> true, 'todo'=> true, + 'inheritDoc'=> true, 'license'=> true, 'todo'=> true, 'TODO'=> true, 'deprec'=> true, 'property' => true, 'method' => true, 'abstract'=> true, 'exception'=> true, 'magic' => true, 'api' => true, 'final'=> true, 'filesource'=> true, 'throw' => true, 'uses' => true, @@ -69,7 +69,7 @@ class AnnotationReader implements Reader 'Required' => true, 'Attribute' => true, 'Attributes' => true, 'Target' => true, 'SuppressWarnings' => true, 'ingroup' => true, 'code' => true, 'endcode' => true, - 'package_version' => true, + 'package_version' => true, 'fixme' => true ); /** @@ -124,6 +124,14 @@ class AnnotationReader implements Reader */ public function __construct() { + if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === "0" || ini_get('opcache.save_comments') === "0")) { + throw AnnotationException::optimizerPlusSaveComments(); + } + + if (extension_loaded('opcache') && ini_get('opcache.save_comments') == 0) { + throw AnnotationException::optimizerPlusSaveComments(); + } + AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php'); $this->parser = new DocParser; diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php old mode 100755 new mode 100644 similarity index 98% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php index dfa846a04a..6135f53d3d --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php +++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php @@ -120,7 +120,7 @@ final class AnnotationRegistry } } else { foreach((array)$dirs AS $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $file)) { + if (is_file($dir . DIRECTORY_SEPARATOR . $file)) { require $dir . DIRECTORY_SEPARATOR . $file; return true; } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php old mode 100755 new mode 100644 similarity index 97% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php index c9a6f7a2d8..ddc84d6990 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php +++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php @@ -19,7 +19,7 @@ namespace Doctrine\Common\Annotations; -use Doctrine\Common\Lexer; +use Doctrine\Common\Lexer\AbstractLexer; /** * Simple lexer for docblock annotations. @@ -30,7 +30,7 @@ use Doctrine\Common\Lexer; * @author Roman Borschel * @author Johannes M. Schmitt */ -final class DocLexer extends Lexer +final class DocLexer extends AbstractLexer { const T_NONE = 1; const T_INTEGER = 2; diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php old mode 100755 new mode 100644 similarity index 92% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php index de31e0b486..9b5daeca7f --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php +++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php @@ -21,6 +21,7 @@ namespace Doctrine\Common\Annotations; use Closure; use ReflectionClass; +use Doctrine\Common\Annotations\Annotation\Enum; use Doctrine\Common\Annotations\Annotation\Target; use Doctrine\Common\Annotations\Annotation\Attribute; use Doctrine\Common\Annotations\Annotation\Attributes; @@ -187,6 +188,26 @@ final class DocParser ) ), ), + 'Doctrine\Common\Annotations\Annotation\Enum' => array( + 'is_annotation' => true, + 'has_constructor' => true, + 'targets_literal' => 'ANNOTATION_PROPERTY', + 'targets' => Target::TARGET_PROPERTY, + 'default_property' => 'value', + 'properties' => array( + 'value' => 'value' + ), + 'attribute_types' => array( + 'value' => array( + 'type' => 'array', + 'required' => true, + ), + 'literal' => array( + 'type' => 'array', + 'required' => false, + ), + ), + ), ); /** @@ -393,13 +414,15 @@ final class DocParser { if (self::$metadataParser == null){ self::$metadataParser = new self(); - self::$metadataParser->setTarget(Target::TARGET_CLASS); self::$metadataParser->setIgnoreNotImportedAnnotations(true); + self::$metadataParser->setIgnoredAnnotationNames($this->ignoredAnnotationNames); self::$metadataParser->setImports(array( + 'enum' => 'Doctrine\Common\Annotations\Annotation\Enum', 'target' => 'Doctrine\Common\Annotations\Annotation\Target', 'attribute' => 'Doctrine\Common\Annotations\Annotation\Attribute', 'attributes' => 'Doctrine\Common\Annotations\Annotation\Attributes' )); + AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Enum.php'); AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Target.php'); AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attribute.php'); AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attributes.php'); @@ -422,6 +445,9 @@ final class DocParser // verify that the class is really meant to be an annotation if ($metadata['is_annotation']) { + + self::$metadataParser->setTarget(Target::TARGET_CLASS); + foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { if ($annotation instanceof Target) { $metadata['targets'] = $annotation->targets; @@ -459,10 +485,13 @@ final class DocParser // collect all public properties foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { $metadata['properties'][$property->name] = $property->name; + + if(false === ($propertyComment = $property->getDocComment())) { + continue; + } // checks if the property has @var annotation - if ((false !== $propertyComment = $property->getDocComment()) - && false !== strpos($propertyComment, '@var') + if (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) { // literal type declaration $value = $matches[1]; @@ -489,6 +518,20 @@ final class DocParser $metadata['attribute_types'][$property->name]['required'] = false !== strpos($propertyComment, '@Required'); } } + + // checks if the property has @Enum + if (false !== strpos($propertyComment, '@Enum')){ + + $context = 'property ' . $class->name . "::\$" . $property->name; + self::$metadataParser->setTarget(Target::TARGET_PROPERTY); + + foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) { + if($annotation instanceof Enum) { + $metadata['enum'][$property->name]['value'] = $annotation->value; + $metadata['enum'][$property->name]['literal'] = ! empty($annotation->literal) ? $annotation->literal : $annotation->value; + } + } + } } // choose the first property as default property @@ -641,6 +684,16 @@ final class DocParser $this->match(DocLexer::T_CLOSE_PARENTHESIS); } + if (isset(self::$annotationMetadata[$name]['enum'])) { + // checks all declared attributes + foreach (self::$annotationMetadata[$name]['enum'] as $property => $enum) { + // checks if the attribute is a valid enumerator + if (isset($values[$property]) && ! in_array($values[$property], $enum['value'])) { + throw AnnotationException::enumeratorError($property, $name, $this->context, $enum['literal'], $values[$property]); + } + } + } + // checks all declared attributes foreach (self::$annotationMetadata[$name]['attribute_types'] as $property => $type) { if ($property === self::$annotationMetadata[$name]['default_property'] @@ -659,7 +712,7 @@ final class DocParser if ($type['type'] === 'array') { // handle the case of a single value - if (!is_array($values[$property])) { + if ( ! is_array($values[$property])) { $values[$property] = array($values[$property]); } @@ -929,6 +982,14 @@ final class DocParser $array = $values = array(); $this->match(DocLexer::T_OPEN_CURLY_BRACES); + + // If the array is empty, stop parsing and return. + if ($this->lexer->isNextToken(DocLexer::T_CLOSE_CURLY_BRACES)) { + $this->match(DocLexer::T_CLOSE_CURLY_BRACES); + + return $array; + } + $values[] = $this->ArrayEntry(); while ($this->lexer->isNextToken(DocLexer::T_COMMA)) { diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/FileCacheReader.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php old mode 100755 new mode 100644 similarity index 90% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/FileCacheReader.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php index 3934861b0f..5e937a8615 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/FileCacheReader.php +++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php @@ -48,6 +48,8 @@ class FileCacheReader implements Reader */ private $loadedAnnotations = array(); + private $classNameHashes = array(); + /** * Constructor * @@ -79,14 +81,17 @@ class FileCacheReader implements Reader */ public function getClassAnnotations(\ReflectionClass $class) { - $key = $class->getName(); + if ( ! isset($this->classNameHashes[$class->name])) { + $this->classNameHashes[$class->name] = sha1($class->name); + } + $key = $this->classNameHashes[$class->name]; if (isset($this->loadedAnnotations[$key])) { return $this->loadedAnnotations[$key]; } $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; - if (!file_exists($path)) { + if (!is_file($path)) { $annot = $this->reader->getClassAnnotations($class); $this->saveCacheFile($path, $annot); return $this->loadedAnnotations[$key] = $annot; @@ -114,14 +119,17 @@ class FileCacheReader implements Reader public function getPropertyAnnotations(\ReflectionProperty $property) { $class = $property->getDeclaringClass(); - $key = $class->getName().'$'.$property->getName(); + if ( ! isset($this->classNameHashes[$class->name])) { + $this->classNameHashes[$class->name] = sha1($class->name); + } + $key = $this->classNameHashes[$class->name].'$'.$property->getName(); if (isset($this->loadedAnnotations[$key])) { return $this->loadedAnnotations[$key]; } $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; - if (!file_exists($path)) { + if (!is_file($path)) { $annot = $this->reader->getPropertyAnnotations($property); $this->saveCacheFile($path, $annot); return $this->loadedAnnotations[$key] = $annot; @@ -130,7 +138,7 @@ class FileCacheReader implements Reader if ($this->debug && (false !== $filename = $class->getFilename()) && filemtime($path) < filemtime($filename)) { - unlink($path); + @unlink($path); $annot = $this->reader->getPropertyAnnotations($property); $this->saveCacheFile($path, $annot); @@ -149,14 +157,17 @@ class FileCacheReader implements Reader public function getMethodAnnotations(\ReflectionMethod $method) { $class = $method->getDeclaringClass(); - $key = $class->getName().'#'.$method->getName(); + if ( ! isset($this->classNameHashes[$class->name])) { + $this->classNameHashes[$class->name] = sha1($class->name); + } + $key = $this->classNameHashes[$class->name].'#'.$method->getName(); if (isset($this->loadedAnnotations[$key])) { return $this->loadedAnnotations[$key]; } $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; - if (!file_exists($path)) { + if (!is_file($path)) { $annot = $this->reader->getMethodAnnotations($method); $this->saveCacheFile($path, $annot); return $this->loadedAnnotations[$key] = $annot; @@ -165,7 +176,7 @@ class FileCacheReader implements Reader if ($this->debug && (false !== $filename = $class->getFilename()) && filemtime($path) < filemtime($filename)) { - unlink($path); + @unlink($path); $annot = $this->reader->getMethodAnnotations($method); $this->saveCacheFile($path, $annot); diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/IndexedReader.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/IndexedReader.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/PhpParser.php b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php old mode 100755 new mode 100644 similarity index 92% rename from vendor/doctrine/common/lib/Doctrine/Common/Annotations/PhpParser.php rename to vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php index c09dd51d1b..9d61020d36 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/PhpParser.php +++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php @@ -46,7 +46,12 @@ final class PhpParser } $content = $this->getFileContent($filename, $class->getStartLine()); - $namespace = str_replace('\\', '\\\\', $class->getNamespaceName()); + + if (null === $content) { + return array(); + } + + $namespace = preg_quote($class->getNamespaceName()); $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content); $tokenizer = new TokenParser(' + + + + + ./tests/Doctrine/ + + + + + + ./lib/Doctrine/ + + + + + + performance + + + diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php old mode 100755 new mode 100644 similarity index 88% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index 4261e6b7a7..ea52b02ede --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -3,8 +3,6 @@ namespace Doctrine\Tests\Common\Annotations; use Doctrine\Common\Annotations\DoctrineReader; -use Doctrine\Common\Reflection\StaticReflectionParser; -use Doctrine\Common\Reflection\Psr0FindFile; use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; use Doctrine\Common\Annotations\Annotation\IgnorePhpDoc; use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader; @@ -24,23 +22,14 @@ abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase public function getReflectionClass() { $className = 'Doctrine\Tests\Common\Annotations\DummyClass'; - $testsRoot = substr(__DIR__, 0, -strlen(__NAMESPACE__) - 1); - $paths = array( - 'Doctrine\\Tests' => array($testsRoot), - ); - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); - return array( - 'native' => array(new ReflectionClass($className)), - 'static' => array($staticReflectionParser->getReflectionClass()), - ); + return new ReflectionClass($className); } - /** - * @dataProvider getReflectionClass - */ - public function testAnnotations($class) + public function testAnnotations() { + $class = $this->getReflectionClass(); $reader = $this->getReader(); + $this->assertEquals(1, count($reader->getClassAnnotations($class))); $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation', $annot = $reader->getClassAnnotation($class, $annotName)); $this->assertEquals("hello", $annot->dummyValue); @@ -114,6 +103,13 @@ abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass')); } + public function testClassWithWithInclude() + { + $reader = $this->getReader(); + $annots = $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithRequire')); + $this->assertCount(1, $annots); + } + /** * @expectedException Doctrine\Common\Annotations\AnnotationException * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$foo. You may only use this annotation on these code elements: CLASS @@ -343,6 +339,45 @@ abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase $this->assertCount(0, $reader->getPropertyAnnotations($class->getProperty('foo'))); } + public function testAnnotationEnumeratorException() + { + $reader = $this->getReader(); + $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum'); + + $this->assertCount(1, $bar = $reader->getMethodAnnotations($class->getMethod('bar'))); + $this->assertCount(1, $foo = $reader->getPropertyAnnotations($class->getProperty('foo'))); + + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $bar[0]); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $foo[0]); + + try { + $reader->getPropertyAnnotations($class->getProperty('invalidProperty')); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::$invalidProperty accept only [ONE, TWO, THREE], but got FOUR.', $exc->getMessage()); + } + + try { + $reader->getMethodAnnotations($class->getMethod('invalidMethod')); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::invalidMethod() accept only [ONE, TWO, THREE], but got 5.', $exc->getMessage()); + } + } + + /** + * @group DCOM-106 + */ + public function testIgnoreFixMeAndUpperCaseToDo() + { + $reader = $this->getReader(); + $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\DCOM106'); + $reader->getClassAnnotations($ref); + } + + /** + * @return AnnotationReader + */ abstract protected function getReader(); } @@ -438,6 +473,15 @@ class DummyGeneratedValue extends \Doctrine\Common\Annotations\Annotation {} class DummyAnnotation extends \Doctrine\Common\Annotations\Annotation { public $dummyValue; } + +/** + * @api + * @Annotation + */ +class DummyAnnotationWithIgnoredAnnotation extends \Doctrine\Common\Annotations\Annotation { + public $dummyValue; +} + /** @Annotation */ class DummyJoinColumn extends \Doctrine\Common\Annotations\Annotation { public $name; @@ -500,6 +544,16 @@ class DummyClassWithEmail } + +/** + * @fixme public + * @TODO + */ +class DCOM106 +{ + +} + namespace Doctrine\Tests\Common\Annotations\Foo; /** @Annotation */ diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php old mode 100755 new mode 100644 similarity index 93% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index b14698f8e9..6c8016fd2b --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -665,6 +665,62 @@ DOCBLOCK; } + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on property SomeClassName::invalidProperty. accept only [ONE, TWO, THREE], but got FOUR. + */ + public function testAnnotationEnumeratorException() + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::invalidProperty.'; + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum("FOUR")'; + + $parser->setIgnoreNotImportedAnnotations(false); + $parser->setTarget(Target::TARGET_PROPERTY); + $parser->parse($docblock, $context); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnumLiteral declared on property SomeClassName::invalidProperty. accept only [AnnotationEnumLiteral::ONE, AnnotationEnumLiteral::TWO, AnnotationEnumLiteral::THREE], but got 4. + */ + public function testAnnotationEnumeratorLiteralException() + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::invalidProperty.'; + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnumLiteral(4)'; + + $parser->setIgnoreNotImportedAnnotations(false); + $parser->setTarget(Target::TARGET_PROPERTY); + $parser->parse($docblock, $context); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage @Enum supports only scalar values "array" given. + */ + public function testAnnotationEnumInvalidTypeDeclarationException() + { + $parser = $this->createTestParser(); + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnumInvalid("foo")'; + + $parser->setIgnoreNotImportedAnnotations(false); + $parser->parse($docblock); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Undefined enumerator value "3" for literal "AnnotationEnumLiteral::THREE". + */ + public function testAnnotationEnumInvalidLiteralDeclarationException() + { + $parser = $this->createTestParser(); + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnumLiteralInvalid("foo")'; + + $parser->setIgnoreNotImportedAnnotations(false); + $parser->parse($docblock); + } + public function getConstantsProvider() { $provider[] = array( @@ -1142,6 +1198,18 @@ DOCBLOCK; $parser = $this->createTestParser(); $parser->parse('@Name(foo: "bar")'); } + + /** + * Tests parsing empty arrays. + */ + public function testEmptyArray() + { + $parser = $this->createTestParser(); + + $annots = $parser->parse('@Name({"foo": {}})'); + $this->assertEquals(1, count($annots)); + $this->assertEquals(array('foo' => array()), $annots[0]->value); + } } /** @Annotation */ diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DummyClass.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DummyClass.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DummyClass.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DummyClass.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Autoload.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Autoload.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Autoload.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Autoload.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Route.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Route.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Route.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Route.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Secure.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Secure.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Secure.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Secure.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php diff --git a/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationEnum.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationEnum.php new file mode 100644 index 0000000000..cc9862a8bd --- /dev/null +++ b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationEnum.php @@ -0,0 +1,21 @@ +assertEquals(array(), $parser->parseClass(new \ReflectionClass('\stdClass'))); } + public function testClassFileDoesNotExist() + { + $class = $this->getMockBuilder('\ReflectionClass') + ->disableOriginalConstructor() + ->getMock(); + $class->expects($this->once()) + ->method('getFilename') + ->will($this->returnValue('/valid/class/Fake.php(35) : eval()d code')); + + $parser = new PhpParser(); + $this->assertEquals(array(), $parser->parseClass($class)); + } + public function testParseClassWhenClassIsNotNamespaced() { $parser = new PhpParser(); diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DoctrineTestCase.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/DoctrineTestCase.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/dbal/tests/Doctrine/Tests/DoctrineTestCase.php rename to vendor/doctrine/annotations/tests/Doctrine/Tests/DoctrineTestCase.php diff --git a/vendor/doctrine/annotations/tests/Doctrine/Tests/TestInit.php b/vendor/doctrine/annotations/tests/Doctrine/Tests/TestInit.php new file mode 100644 index 0000000000..07d74e6780 --- /dev/null +++ b/vendor/doctrine/annotations/tests/Doctrine/Tests/TestInit.php @@ -0,0 +1,26 @@ +> ./tests/travis/php.ini ;fi" + - composer self-update + - composer --prefer-source --dev install + - phpenv config-add ./tests/travis/php.ini + +script: + - ./vendor/bin/phpunit -c ./tests/travis/phpunit.travis.xml -v + +after_script: + - php vendor/bin/coveralls -v diff --git a/vendor/doctrine/cache/LICENSE b/vendor/doctrine/cache/LICENSE new file mode 100644 index 0000000000..4a91f0bf28 --- /dev/null +++ b/vendor/doctrine/cache/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2006-2012 Doctrine Project + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/doctrine/cache/README.md b/vendor/doctrine/cache/README.md new file mode 100644 index 0000000000..94f80a30ee --- /dev/null +++ b/vendor/doctrine/cache/README.md @@ -0,0 +1,14 @@ +# Doctrine Cache + +Master: [![Build Status](https://secure.travis-ci.org/doctrine/cache.png?branch=master)](http://travis-ci.org/doctrine/cache) [![Coverage Status](https://coveralls.io/repos/doctrine/cache/badge.png?branch=master)](https://coveralls.io/r/doctrine/cache?branch=master) + +[![Latest Stable Version](https://poser.pugx.org/doctrine/cache/v/stable.png)](https://packagist.org/packages/doctrine/cache) [![Total Downloads](https://poser.pugx.org/doctrine/cache/downloads.png)](https://packagist.org/packages/doctrine/cache) + +Cache component extracted from the Doctrine Common project. + +## Changelog + +### v1.2 + +* Added support for MongoDB as Cache Provider +* Fix namespace version reset diff --git a/vendor/doctrine/cache/build.properties b/vendor/doctrine/cache/build.properties new file mode 100644 index 0000000000..2d98c360aa --- /dev/null +++ b/vendor/doctrine/cache/build.properties @@ -0,0 +1,3 @@ +# Version class and file +project.version_class = Doctrine\\Common\\Cache\\Version +project.version_file = lib/Doctrine/Common/Cache/Version.php diff --git a/vendor/doctrine/cache/build.xml b/vendor/doctrine/cache/build.xml new file mode 100644 index 0000000000..a7c52e3cf3 --- /dev/null +++ b/vendor/doctrine/cache/build.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/doctrine/cache/composer.json b/vendor/doctrine/cache/composer.json new file mode 100644 index 0000000000..31765287d9 --- /dev/null +++ b/vendor/doctrine/cache/composer.json @@ -0,0 +1,33 @@ +{ + "name": "doctrine/cache", + "type": "library", + "description": "Caching library offering an object-oriented API for many cache backends", + "keywords": ["cache", "caching"], + "homepage": "http://www.doctrine-project.org", + "license": "MIT", + "authors": [ + {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, + {"name": "Roman Borschel", "email": "roman@code-factory.org"}, + {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, + {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, + {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} + ], + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": ">=3.7", + "satooshi/php-coveralls": "~0.6" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "autoload": { + "psr-0": { "Doctrine\\Common\\Cache\\": "lib/" } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ApcCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php old mode 100755 new mode 100644 similarity index 64% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/ApcCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php index 2d0cd23afd..1f19db675b --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ApcCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php @@ -1,5 +1,4 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie */ class ApcCache extends CacheProvider { @@ -82,12 +80,19 @@ class ApcCache extends CacheProvider $info = apc_cache_info(); $sma = apc_sma_info(); + // @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42 + if (PHP_VERSION_ID >= 50500) { + $info['num_hits'] = isset($info['num_hits']) ? $info['num_hits'] : $info['nhits']; + $info['num_misses'] = isset($info['num_misses']) ? $info['num_misses'] : $info['nmisses']; + $info['start_time'] = isset($info['start_time']) ? $info['start_time'] : $info['stime']; + } + return array( - Cache::STATS_HITS => $info['num_hits'], - Cache::STATS_MISSES => $info['num_misses'], - Cache::STATS_UPTIME => $info['start_time'], - Cache::STATS_MEMORY_USAGE => $info['mem_size'], - Cache::STATS_MEMORY_AVAILIABLE => $sma['avail_mem'], + Cache::STATS_HITS => $info['num_hits'], + Cache::STATS_MISSES => $info['num_misses'], + Cache::STATS_UPTIME => $info['start_time'], + Cache::STATS_MEMORY_USAGE => $info['mem_size'], + Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'], ); } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ArrayCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php old mode 100755 new mode 100644 similarity index 83% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/ArrayCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php index a7a70aad51..e9f08a24bb --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ArrayCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php @@ -1,7 +1,5 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie */ class ArrayCache extends CacheProvider { diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/Cache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php old mode 100755 new mode 100644 similarity index 63% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/Cache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php index 5493562de7..0785f263b7 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/Cache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php @@ -1,7 +1,5 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Fabio B. Silva + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Fabio B. Silva */ interface Cache { - const STATS_HITS = 'hits'; - const STATS_MISSES = 'misses'; - const STATS_UPTIME = 'uptime'; - const STATS_MEMORY_USAGE = 'memory_usage'; - const STATS_MEMORY_AVAILIABLE = 'memory_available'; + const STATS_HITS = 'hits'; + const STATS_MISSES = 'misses'; + const STATS_UPTIME = 'uptime'; + const STATS_MEMORY_USAGE = 'memory_usage'; + const STATS_MEMORY_AVAILABLE = 'memory_available'; + /** + * Only for backward compatibility (may be removed in next major release) + * + * @deprecated + */ + const STATS_MEMORY_AVAILIABLE = 'memory_available'; /** * Fetches an entry from the cache. * - * @param string $id cache id The id of the cache entry to fetch. + * @param string $id The id of the cache entry to fetch. + * * @return mixed The cached data or FALSE, if no cache entry exists for the given id. */ function fetch($id); /** - * Test if an entry exists in the cache. + * Tests if an entry exists in the cache. + * + * @param string $id The cache id of the entry to check for. * - * @param string $id cache id The cache id of the entry to check for. * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise. */ function contains($id); @@ -60,9 +65,11 @@ interface Cache /** * Puts data into the cache. * - * @param string $id The cache id. - * @param mixed $data The cache entry/data. - * @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime). + * @param string $id The cache id. + * @param mixed $data The cache entry/data. + * @param int $lifeTime The cache lifetime. + * If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime). + * * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. */ function save($id, $data, $lifeTime = 0); @@ -70,13 +77,14 @@ interface Cache /** * Deletes a cache entry. * - * @param string $id cache id + * @param string $id The cache id. + * * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. */ function delete($id); /** - * Retrieves cached information from data store + * Retrieves cached information from the data store. * * The server's statistics array has the following values: * @@ -95,8 +103,9 @@ interface Cache * - memory_available * Memory allowed to use for storage. * - * @since 2.2 - * @var array Associative array with server's statistics if available, NULL otherwise. + * @since 2.2 + * + * @return array|null An associative array with server's statistics if available, NULL otherwise. */ function getStats(); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/CacheProvider.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php old mode 100755 new mode 100644 similarity index 72% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/CacheProvider.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php index 4221a62e59..ce88e49223 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/CacheProvider.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php @@ -1,5 +1,4 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Fabio B. Silva + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Fabio B. Silva */ abstract class CacheProvider implements Cache { const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]'; /** - * @var string The namespace to prefix all cache ids with + * The namespace to prefix all cache ids with. + * + * @var string */ private $namespace = ''; /** - * @var string The namespace version + * The namespace version. + * + * @var string */ private $namespaceVersion; /** - * Set the namespace to prefix all cache ids with. + * Sets the namespace to prefix all cache ids with. * * @param string $namespace + * * @return void */ public function setNamespace($namespace) { - $this->namespace = (string) $namespace; + $this->namespace = (string) $namespace; + $this->namespaceVersion = null; } /** - * Retrieve the namespace that prefixes all cache ids. + * Retrieves the namespace that prefixes all cache ids. * * @return string */ @@ -106,7 +111,7 @@ abstract class CacheProvider implements Cache } /** - * Deletes all cache entries. + * Flushes all cache entries. * * @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise. */ @@ -116,7 +121,7 @@ abstract class CacheProvider implements Cache } /** - * Delete all cache entries. + * Deletes all cache entries. * * @return boolean TRUE if the cache entries were successfully deleted, FALSE otherwise. */ @@ -131,10 +136,11 @@ abstract class CacheProvider implements Cache } /** - * Prefix the passed id with the configured namespace value + * Prefixes the passed id with the configured namespace value. * - * @param string $id The id to namespace - * @return string $id The namespaced id + * @param string $id The id to namespace. + * + * @return string The namespaced id. */ private function getNamespacedId($id) { @@ -144,9 +150,9 @@ abstract class CacheProvider implements Cache } /** - * Namespace cache key + * Returns the namespace cache key. * - * @return string $namespaceCacheKey + * @return string */ private function getNamespaceCacheKey() { @@ -154,9 +160,9 @@ abstract class CacheProvider implements Cache } /** - * Namespace version + * Returns the namespace version. * - * @return string $namespaceVersion + * @return string */ private function getNamespaceVersion() { @@ -181,15 +187,17 @@ abstract class CacheProvider implements Cache /** * Fetches an entry from the cache. * - * @param string $id cache id The id of the cache entry to fetch. - * @return string The cached data or FALSE, if no cache entry exists for the given id. + * @param string $id The id of the cache entry to fetch. + * + * @return string|bool The cached data or FALSE, if no cache entry exists for the given id. */ abstract protected function doFetch($id); /** - * Test if an entry exists in the cache. + * Tests if an entry exists in the cache. + * + * @param string $id The cache id of the entry to check for. * - * @param string $id cache id The cache id of the entry to check for. * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise. */ abstract protected function doContains($id); @@ -197,35 +205,37 @@ abstract class CacheProvider implements Cache /** * Puts data into the cache. * - * @param string $id The cache id. - * @param string $data The cache entry/data. - * @param bool|int $lifeTime The lifetime. If != false, sets a specific lifetime for this - * cache entry (null => infinite lifeTime). + * @param string $id The cache id. + * @param string $data The cache entry/data. + * @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this + * cache entry (0 => infinite lifeTime). * * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. */ - abstract protected function doSave($id, $data, $lifeTime = false); + abstract protected function doSave($id, $data, $lifeTime = 0); /** * Deletes a cache entry. * - * @param string $id cache id + * @param string $id The cache id. + * * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. */ abstract protected function doDelete($id); /** - * Deletes all cache entries. + * Flushes all cache entries. * * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. */ abstract protected function doFlush(); - /** - * Retrieves cached information from data store + /** + * Retrieves cached information from the data store. * - * @since 2.2 - * @return array An associative array with server's statistics if available, NULL otherwise. + * @since 2.2 + * + * @return array|null An associative array with server's statistics if available, NULL otherwise. */ abstract protected function doGetStats(); } diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseCache.php new file mode 100644 index 0000000000..c21691df96 --- /dev/null +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseCache.php @@ -0,0 +1,121 @@ +. + */ + +namespace Doctrine\Common\Cache; + +use \Couchbase; + +/** + * Couchbase cache provider. + * + * @link www.doctrine-project.org + * @since 2.4 + * @author Michael Nitschinger + */ +class CouchbaseCache extends CacheProvider +{ + /** + * @var Couchbase|null + */ + private $couchbase; + + /** + * Sets the Couchbase instance to use. + * + * @param Couchbase $couchbase + * + * @return void + */ + public function setCouchbase(Couchbase $couchbase) + { + $this->couchbase = $couchbase; + } + + /** + * Gets the Couchbase instance used by the cache. + * + * @return Couchbase|null + */ + public function getCouchbase() + { + return $this->couchbase; + } + + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + return $this->couchbase->get($id) ?: false; + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + return (null !== $this->couchbase->get($id)); + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + if ($lifeTime > 30 * 24 * 3600) { + $lifeTime = time() + $lifeTime; + } + return $this->couchbase->set($id, $data, (int) $lifeTime); + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + return $this->couchbase->delete($id); + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + return $this->couchbase->flush(); + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + $stats = $this->couchbase->getStats(); + $servers = $this->couchbase->getServers(); + $server = explode(":", $servers[0]); + $key = $server[0] . ":" . "11210"; + $stats = $stats[$key]; + return array( + Cache::STATS_HITS => $stats['get_hits'], + Cache::STATS_MISSES => $stats['get_misses'], + Cache::STATS_UPTIME => $stats['uptime'], + Cache::STATS_MEMORY_USAGE => $stats['bytes'], + Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'], + ); + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php old mode 100755 new mode 100644 similarity index 69% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php index da650b4c6e..1aa4d79118 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php @@ -1,5 +1,4 @@ + * @since 2.3 + * @author Fabio B. Silva */ abstract class FileCache extends CacheProvider { /** - * @var string Cache directory. + * The cache directory. + * + * @var string */ protected $directory; /** - * @var string Cache file extension. + * The cache file extension. + * + * @var string|null */ protected $extension; /** - * Constructor + * Constructor. * - * @param string $directory Cache directory. - * @param string $directory Cache file extension. + * @param string $directory The cache directory. + * @param string|null $extension The cache file extension. * * @throws \InvalidArgumentException */ @@ -68,7 +71,7 @@ abstract class FileCache extends CacheProvider /** * Gets the cache directory. - * + * * @return string */ public function getDirectory() @@ -78,8 +81,8 @@ abstract class FileCache extends CacheProvider /** * Gets the cache file extension. - * - * @return string + * + * @return string|null */ public function getExtension() { @@ -87,12 +90,16 @@ abstract class FileCache extends CacheProvider } /** + * @param string $id + * * @return string */ protected function getFilename($id) { - $path = implode(str_split(md5($id), 12), DIRECTORY_SEPARATOR); + $hash = hash('sha256', $id); + $path = implode(str_split($hash, 16), DIRECTORY_SEPARATOR); $path = $this->directory . DIRECTORY_SEPARATOR . $path; + $id = preg_replace('@[\\\/:"*?<>|]+@', '', $id); return $path . DIRECTORY_SEPARATOR . $id . $this->extension; } @@ -110,12 +117,7 @@ abstract class FileCache extends CacheProvider */ protected function doFlush() { - $pattern = '/^.+\\' . $this->extension . '$/i'; - $iterator = new \RecursiveDirectoryIterator($this->directory); - $iterator = new \RecursiveIteratorIterator($iterator); - $iterator = new \RegexIterator($iterator, $pattern); - - foreach ($iterator as $name => $file) { + foreach ($this->getIterator() as $name => $file) { @unlink($name); } @@ -127,6 +129,30 @@ abstract class FileCache extends CacheProvider */ protected function doGetStats() { - return null; + $usage = 0; + foreach ($this->getIterator() as $name => $file) { + $usage += $file->getSize(); + } + + $free = disk_free_space($this->directory); + + return array( + Cache::STATS_HITS => null, + Cache::STATS_MISSES => null, + Cache::STATS_UPTIME => null, + Cache::STATS_MEMORY_USAGE => $usage, + Cache::STATS_MEMORY_AVAILABLE => $free, + ); } -} \ No newline at end of file + + /** + * @return \Iterator + */ + private function getIterator() + { + $pattern = '/^.+\\' . $this->extension . '$/i'; + $iterator = new \RecursiveDirectoryIterator($this->directory); + $iterator = new \RecursiveIteratorIterator($iterator); + return new \RegexIterator($iterator, $pattern); + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/FilesystemCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php old mode 100755 new mode 100644 similarity index 94% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/FilesystemCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php index a27a7176b8..23aaa37bd7 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/FilesystemCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php @@ -1,5 +1,4 @@ + * @since 2.3 + * @author Fabio B. Silva */ class FilesystemCache extends FileCache { @@ -44,7 +43,7 @@ class FilesystemCache extends FileCache $lifetime = -1; $filename = $this->getFilename($id); - if ( ! file_exists($filename)) { + if ( ! is_file($filename)) { return false; } @@ -77,7 +76,7 @@ class FilesystemCache extends FileCache $lifetime = -1; $filename = $this->getFilename($id); - if ( ! file_exists($filename)) { + if ( ! is_file($filename)) { return false; } @@ -109,6 +108,6 @@ class FilesystemCache extends FileCache mkdir($filepath, 0777, true); } - return file_put_contents($filename, $lifeTime . PHP_EOL . $data); + return file_put_contents($filename, $lifeTime . PHP_EOL . $data) !== false; } -} \ No newline at end of file +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcacheCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcacheCache.php old mode 100755 new mode 100644 similarity index 82% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcacheCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcacheCache.php index 5687b965f1..f839a65918 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcacheCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcacheCache.php @@ -1,5 +1,4 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie */ class MemcacheCache extends CacheProvider { /** - * @var Memcache + * @var Memcache|null */ private $memcache; @@ -45,6 +43,8 @@ class MemcacheCache extends CacheProvider * Sets the memcache instance to use. * * @param Memcache $memcache + * + * @return void */ public function setMemcache(Memcache $memcache) { @@ -54,7 +54,7 @@ class MemcacheCache extends CacheProvider /** * Gets the memcache instance used by the cache. * - * @return Memcache + * @return Memcache|null */ public function getMemcache() { @@ -114,8 +114,8 @@ class MemcacheCache extends CacheProvider Cache::STATS_HITS => $stats['get_hits'], Cache::STATS_MISSES => $stats['get_misses'], Cache::STATS_UPTIME => $stats['uptime'], - Cache::STATS_MEMORY_USAGE => $stats['bytes'], - Cache::STATS_MEMORY_AVAILIABLE => $stats['limit_maxbytes'], + Cache::STATS_MEMORY_USAGE => $stats['bytes'], + Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'], ); } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcachedCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php old mode 100755 new mode 100644 similarity index 83% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcachedCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php index 75f1345550..f7e5500a1c --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcachedCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php @@ -1,5 +1,4 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie */ class MemcachedCache extends CacheProvider { /** - * @var Memcached + * @var Memcached|null */ private $memcached; @@ -45,6 +43,8 @@ class MemcachedCache extends CacheProvider * Sets the memcache instance to use. * * @param Memcached $memcached + * + * @return void */ public function setMemcached(Memcached $memcached) { @@ -54,7 +54,7 @@ class MemcachedCache extends CacheProvider /** * Gets the memcached instance used by the cache. * - * @return Memcached + * @return Memcached|null */ public function getMemcached() { @@ -117,8 +117,8 @@ class MemcachedCache extends CacheProvider Cache::STATS_HITS => $stats['get_hits'], Cache::STATS_MISSES => $stats['get_misses'], Cache::STATS_UPTIME => $stats['uptime'], - Cache::STATS_MEMORY_USAGE => $stats['bytes'], - Cache::STATS_MEMORY_AVAILIABLE => $stats['limit_maxbytes'], + Cache::STATS_MEMORY_USAGE => $stats['bytes'], + Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'], ); } } diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php new file mode 100644 index 0000000000..0c7ac0a093 --- /dev/null +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php @@ -0,0 +1,191 @@ +. + */ + +namespace Doctrine\Common\Cache; + +use MongoBinData; +use MongoCollection; +use MongoDate; + +/** + * MongoDB cache provider. + * + * @since 1.1 + * @author Jeremy Mikola + */ +class MongoDBCache extends CacheProvider +{ + /** + * The data field will store the serialized PHP value. + */ + const DATA_FIELD = 'd'; + + /** + * The expiration field will store a MongoDate value indicating when the + * cache entry should expire. + * + * With MongoDB 2.2+, entries can be automatically deleted by MongoDB by + * indexing this field wit the "expireAfterSeconds" option equal to zero. + * This will direct MongoDB to regularly query for and delete any entries + * whose date is older than the current time. Entries without a date value + * in this field will be ignored. + * + * The cache provider will also check dates on its own, in case expired + * entries are fetched before MongoDB's TTLMonitor pass can expire them. + * + * @see http://docs.mongodb.org/manual/tutorial/expire-data/ + */ + const EXPIRATION_FIELD = 'e'; + + /** + * @var MongoCollection + */ + private $collection; + + /** + * Constructor. + * + * This provider will default to the write concern and read preference + * options set on the MongoCollection instance (or inherited from MongoDB or + * MongoClient). Using an unacknowledged write concern (< 1) may make the + * return values of delete() and save() unreliable. Reading from secondaries + * may make contain() and fetch() unreliable. + * + * @see http://www.php.net/manual/en/mongo.readpreferences.php + * @see http://www.php.net/manual/en/mongo.writeconcerns.php + * @param MongoCollection $collection + */ + public function __construct(MongoCollection $collection) + { + $this->collection = $collection; + } + + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + $document = $this->collection->findOne(array('_id' => $id), array(self::DATA_FIELD, self::EXPIRATION_FIELD)); + + if ($document === null) { + return false; + } + + if ($this->isExpired($document)) { + $this->doDelete($id); + return false; + } + + return unserialize($document[self::DATA_FIELD]->bin); + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + $document = $this->collection->findOne(array('_id' => $id), array(self::EXPIRATION_FIELD)); + + if ($document === null) { + return false; + } + + if ($this->isExpired($document)) { + $this->doDelete($id); + return false; + } + + return true; + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + $result = $this->collection->update( + array('_id' => $id), + array('$set' => array( + self::EXPIRATION_FIELD => ($lifeTime > 0 ? new MongoDate(time() + $lifeTime) : null), + self::DATA_FIELD => new MongoBinData(serialize($data), MongoBinData::BYTE_ARRAY), + )), + array('upsert' => true, 'multiple' => false) + ); + + return isset($result['ok']) ? $result['ok'] == 1 : true; + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + $result = $this->collection->remove(array('_id' => $id)); + + return isset($result['n']) ? $result['n'] == 1 : true; + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + // Use remove() in lieu of drop() to maintain any collection indexes + $result = $this->collection->remove(); + + return isset($result['ok']) ? $result['ok'] == 1 : true; + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + $serverStatus = $this->collection->db->command(array( + 'serverStatus' => 1, + 'locks' => 0, + 'metrics' => 0, + 'recordStats' => 0, + 'repl' => 0, + )); + + $collStats = $this->collection->db->command(array('collStats' => 1)); + + return array( + Cache::STATS_HITS => null, + Cache::STATS_MISSES => null, + Cache::STATS_UPTIME => (isset($serverStatus['uptime']) ? (integer) $serverStatus['uptime'] : null), + Cache::STATS_MEMORY_USAGE => (isset($collStats['size']) ? (integer) $collStats['size'] : null), + Cache::STATS_MEMORY_AVAILABLE => null, + ); + } + + /** + * Check if the document is expired. + * + * @param array $document + * @return boolean + */ + private function isExpired(array $document) + { + return isset($document[self::EXPIRATION_FIELD]) && + $document[self::EXPIRATION_FIELD] instanceof MongoDate && + $document[self::EXPIRATION_FIELD]->sec < time(); + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/PhpFileCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php old mode 100755 new mode 100644 similarity index 93% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/PhpFileCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php index 0971cd9675..f017d83326 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/PhpFileCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php @@ -1,5 +1,4 @@ + * @since 2.3 + * @author Fabio B. Silva */ class PhpFileCache extends FileCache { @@ -42,7 +41,7 @@ class PhpFileCache extends FileCache { $filename = $this->getFilename($id); - if ( ! file_exists($filename)) { + if ( ! is_file($filename)) { return false; } @@ -62,7 +61,7 @@ class PhpFileCache extends FileCache { $filename = $this->getFilename($id); - if ( ! file_exists($filename)) { + if ( ! is_file($filename)) { return false; } @@ -103,6 +102,6 @@ class PhpFileCache extends FileCache $value = var_export($value, true); $code = sprintf(' + * @link www.doctrine-project.org + * @since 2.2 + * @author Osman Ungur */ class RedisCache extends CacheProvider { /** - * @var Redis + * @var Redis|null */ private $redis; @@ -41,17 +39,19 @@ class RedisCache extends CacheProvider * Sets the redis instance to use. * * @param Redis $redis + * + * @return void */ public function setRedis(Redis $redis) { - $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); + $redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue()); $this->redis = $redis; } /** * Gets the redis instance used by the cache. * - * @return Redis + * @return Redis|null */ public function getRedis() { @@ -79,11 +79,11 @@ class RedisCache extends CacheProvider */ protected function doSave($id, $data, $lifeTime = 0) { - $result = $this->redis->set($id, $data); if ($lifeTime > 0) { - $this->redis->expire($id, $lifeTime); + return $this->redis->setex($id, $lifeTime, $data); } - return $result; + + return $this->redis->set($id, $data); } /** @@ -91,7 +91,7 @@ class RedisCache extends CacheProvider */ protected function doDelete($id) { - return $this->redis->delete($id); + return $this->redis->delete($id) > 0; } /** @@ -112,8 +112,20 @@ class RedisCache extends CacheProvider Cache::STATS_HITS => false, Cache::STATS_MISSES => false, Cache::STATS_UPTIME => $info['uptime_in_seconds'], - Cache::STATS_MEMORY_USAGE => $info['used_memory'], - Cache::STATS_MEMORY_AVAILIABLE => false + Cache::STATS_MEMORY_USAGE => $info['used_memory'], + Cache::STATS_MEMORY_AVAILABLE => false ); } + + /** + * Returns the serializer constant to use. If Redis is compiled with + * igbinary support, that is used. Otherwise the default PHP serializer is + * used. + * + * @return integer One of the Redis::SERIALIZER_* constants + */ + protected function getSerializerValue() + { + return defined('Redis::SERIALIZER_IGBINARY') ? Redis::SERIALIZER_IGBINARY : Redis::SERIALIZER_PHP; + } } diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/RiakCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/RiakCache.php new file mode 100644 index 0000000000..8bb6b4bf99 --- /dev/null +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/RiakCache.php @@ -0,0 +1,250 @@ +. + */ + +namespace Doctrine\Common\Cache; + +use Riak\Bucket; +use Riak\Connection; +use Riak\Input; +use Riak\Exception; +use Riak\Object; + +/** + * Riak cache provider. + * + * @link www.doctrine-project.org + * @since 1.1 + * @author Guilherme Blanco + */ +class RiakCache extends CacheProvider +{ + const EXPIRES_HEADER = 'X-Riak-Meta-Expires'; + + /** + * @var \Riak\Bucket + */ + private $bucket; + + /** + * Sets the riak bucket instance to use. + * + * @param \Riak\Bucket $bucket + */ + public function __construct(Bucket $bucket) + { + $this->bucket = $bucket; + } + + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + try { + $response = $this->bucket->get($id); + + // No objects found + if ( ! $response->hasObject()) { + return false; + } + + // Check for attempted siblings + $object = ($response->hasSiblings()) + ? $this->resolveConflict($id, $response->getVClock(), $response->getObjectList()) + : $response->getFirstObject(); + + // Check for expired object + if ($this->isExpired($object)) { + $this->bucket->delete($object); + + return false; + } + + return unserialize($object->getContent()); + } catch (Exception\RiakException $e) { + // Covers: + // - Riak\ConnectionException + // - Riak\CommunicationException + // - Riak\UnexpectedResponseException + // - Riak\NotFoundException + } + + return false; + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + try { + // We only need the HEAD, not the entire object + $input = new Input\GetInput(); + + $input->setReturnHead(true); + + $response = $this->bucket->get($id, $input); + + // No objects found + if ( ! $response->hasObject()) { + return false; + } + + $object = $response->getFirstObject(); + + // Check for expired object + if ($this->isExpired($object)) { + $this->bucket->delete($object); + + return false; + } + + return true; + } catch (Exception\RiakException $e) { + // Do nothing + } + + return false; + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + try { + $object = new Object($id); + + $object->setContent(serialize($data)); + + if ($lifeTime > 0) { + $object->addMetadata(self::EXPIRES_HEADER, (string) (time() + $lifeTime)); + } + + $this->bucket->put($object); + + return true; + } catch (Exception\RiakException $e) { + // Do nothing + } + + return false; + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + try { + $this->bucket->delete($id); + + return true; + } catch (Exception\BadArgumentsException $e) { + // Key did not exist on cluster already + } catch (Exception\RiakException $e) { + // Covers: + // - Riak\Exception\ConnectionException + // - Riak\Exception\CommunicationException + // - Riak\Exception\UnexpectedResponseException + } + + return false; + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + try { + $keyList = $this->bucket->getKeyList(); + + foreach ($keyList as $key) { + $this->bucket->delete($key); + } + + return true; + } catch (Exception\RiakException $e) { + // Do nothing + } + + return false; + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + // Only exposed through HTTP stats API, not Protocol Buffers API + return null; + } + + /** + * Check if a given Riak Object have expired. + * + * @param \Riak\Object $object + * + * @return boolean + */ + private function isExpired(Object $object) + { + $metadataMap = $object->getMetadataMap(); + + return isset($metadataMap[self::EXPIRES_HEADER]) + && $metadataMap[self::EXPIRES_HEADER] < time(); + } + + /** + * On-read conflict resolution. Applied approach here is last write wins. + * Specific needs may override this method to apply alternate conflict resolutions. + * + * {@internal Riak does not attempt to resolve a write conflict, and store + * it as sibling of conflicted one. By following this approach, it is up to + * the next read to resolve the conflict. When this happens, your fetched + * object will have a list of siblings (read as a list of objects). + * In our specific case, we do not care about the intermediate ones since + * they are all the same read from storage, and we do apply a last sibling + * (last write) wins logic. + * If by any means our resolution generates another conflict, it'll up to + * next read to properly solve it.} + * + * @param string $id + * @param string $vClock + * @param array $objectList + * + * @return \Riak\Object + */ + protected function resolveConflict($id, $vClock, array $objectList) + { + // Our approach here is last-write wins + $winner = $objectList[count($objectList)]; + + $putInput = new Input\PutInput(); + $putInput->setVClock($vClock); + + $mergedObject = new Object($id); + $mergedObject->setContent($winner->getContent()); + + $this->bucket->put($mergedObject, $putInput); + + return $mergedObject; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/Version.php old mode 100755 new mode 100644 similarity index 84% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/Version.php index 9f0937aa1e..e35fbcc5a8 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/Version.php @@ -1,5 +1,4 @@ . */ -namespace Doctrine\Tests\Models\DDC753; +namespace Doctrine\Common\Cache; -use Doctrine\ORM\EntityRepository; - -class DDC753InvalidRepository +class Version { - -} \ No newline at end of file + const VERSION = '1.3.0'; +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/WinCacheCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php old mode 100755 new mode 100644 similarity index 73% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/WinCacheCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php index 777d0fd535..ae32772930 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/WinCacheCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php @@ -1,5 +1,4 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie */ class WinCacheCache extends CacheProvider { @@ -83,11 +81,11 @@ class WinCacheCache extends CacheProvider $meminfo = wincache_ucache_meminfo(); return array( - Cache::STATS_HITS => $info['total_hit_count'], - Cache::STATS_MISSES => $info['total_miss_count'], - Cache::STATS_UPTIME => $info['total_cache_uptime'], - Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'], - Cache::STATS_MEMORY_AVAILIABLE => $meminfo['memory_free'], + Cache::STATS_HITS => $info['total_hit_count'], + Cache::STATS_MISSES => $info['total_miss_count'], + Cache::STATS_UPTIME => $info['total_cache_uptime'], + Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'], + Cache::STATS_MEMORY_AVAILABLE => $meminfo['memory_free'], ); } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/XcacheCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php old mode 100755 new mode 100644 similarity index 82% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/XcacheCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php index 8733e266cc..833b02a89b --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/XcacheCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php @@ -1,5 +1,4 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie */ class XcacheCache extends CacheProvider { @@ -79,10 +77,11 @@ class XcacheCache extends CacheProvider } /** - * Checks that xcache.admin.enable_auth is Off + * Checks that xcache.admin.enable_auth is Off. * - * @throws \BadMethodCallException When xcache.admin.enable_auth is On * @return void + * + * @throws \BadMethodCallException When xcache.admin.enable_auth is On. */ protected function checkAuthorization() { @@ -103,8 +102,8 @@ class XcacheCache extends CacheProvider Cache::STATS_HITS => $info['hits'], Cache::STATS_MISSES => $info['misses'], Cache::STATS_UPTIME => null, - Cache::STATS_MEMORY_USAGE => $info['size'], - Cache::STATS_MEMORY_AVAILIABLE => $info['avail'], + Cache::STATS_MEMORY_USAGE => $info['size'], + Cache::STATS_MEMORY_AVAILABLE => $info['avail'], ); } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php old mode 100755 new mode 100644 similarity index 89% rename from vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php rename to vendor/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php index fc90bc6909..6e35ac8236 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php +++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php @@ -22,11 +22,10 @@ namespace Doctrine\Common\Cache; /** * Zend Data Cache cache driver. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Ralph Schindler - * @author Guilherme Blanco + * @link www.doctrine-project.org + * @since 2.0 + * @author Ralph Schindler + * @author Guilherme Blanco */ class ZendDataCache extends CacheProvider { diff --git a/vendor/doctrine/cache/phpunit.xml.dist b/vendor/doctrine/cache/phpunit.xml.dist new file mode 100644 index 0000000000..900378bf36 --- /dev/null +++ b/vendor/doctrine/cache/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + ./tests/Doctrine/ + + + + + + ./lib/Doctrine/ + + + + + + performance + + + diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php old mode 100755 new mode 100644 similarity index 83% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php index 6cad8915b6..a6c3097d3b --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php @@ -18,4 +18,9 @@ class ArrayCacheTest extends CacheTest $this->assertNull($stats); } + + protected function isSharedStorage() + { + return false; + } } \ No newline at end of file diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php new file mode 100644 index 0000000000..eaedd99446 --- /dev/null +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/BaseFileCacheTest.php @@ -0,0 +1,40 @@ +directory = sys_get_temp_dir() . '/doctrine_cache_'. uniqid(); + } while (file_exists($this->directory)); + } + + public function tearDown() + { + if ( ! is_dir($this->directory)) { + return; + } + + $iterator = new RecursiveDirectoryIterator($this->directory); + + foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) { + if ($file->isFile()) { + @unlink($file->getRealPath()); + } elseif ($file->isDir()) { + @rmdir($file->getRealPath()); + } + } + } + + protected function isSharedStorage() + { + return false; + } +} diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CacheTest.php new file mode 100644 index 0000000000..5242574382 --- /dev/null +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CacheTest.php @@ -0,0 +1,241 @@ +_getCacheDriver(); + + // Test saving a value, checking if it exists, and fetching it back + $this->assertTrue($cache->save('key', 'value')); + $this->assertTrue($cache->contains('key')); + $this->assertEquals('value', $cache->fetch('key')); + + // Test updating the value of a cache entry + $this->assertTrue($cache->save('key', 'value-changed')); + $this->assertTrue($cache->contains('key')); + $this->assertEquals('value-changed', $cache->fetch('key')); + + // Test deleting a value + $this->assertTrue($cache->delete('key')); + $this->assertFalse($cache->contains('key')); + } + + public function provideCrudValues() + { + return array( + 'array' => array(array('one', 2, 3.0)), + 'string' => array('value'), + 'integer' => array(1), + 'float' => array(1.5), + 'object' => array(new ArrayObject()), + ); + } + + public function testDeleteAll() + { + $cache = $this->_getCacheDriver(); + + $this->assertTrue($cache->save('key1', 1)); + $this->assertTrue($cache->save('key2', 2)); + $this->assertTrue($cache->deleteAll()); + $this->assertFalse($cache->contains('key1')); + $this->assertFalse($cache->contains('key2')); + } + + public function testDeleteAllAndNamespaceVersioningBetweenCaches() + { + if ( ! $this->isSharedStorage()) { + $this->markTestSkipped('The ' . __CLASS__ .' does not use shared storage'); + } + + $cache1 = $this->_getCacheDriver(); + $cache2 = $this->_getCacheDriver(); + + $this->assertTrue($cache1->save('key1', 1)); + $this->assertTrue($cache2->save('key2', 2)); + + /* Both providers are initialized with the same namespace version, so + * they can see entries set by each other. + */ + $this->assertTrue($cache1->contains('key1')); + $this->assertTrue($cache1->contains('key2')); + $this->assertTrue($cache2->contains('key1')); + $this->assertTrue($cache2->contains('key2')); + + /* Deleting all entries through one provider will only increment the + * namespace version on that object (and in the cache itself, which new + * instances will use to initialize). The second provider will retain + * its original version and still see stale data. + */ + $this->assertTrue($cache1->deleteAll()); + $this->assertFalse($cache1->contains('key1')); + $this->assertFalse($cache1->contains('key2')); + $this->assertTrue($cache2->contains('key1')); + $this->assertTrue($cache2->contains('key2')); + + /* A new cache provider should not see the deleted entries, since its + * namespace version will be initialized. + */ + $cache3 = $this->_getCacheDriver(); + $this->assertFalse($cache3->contains('key1')); + $this->assertFalse($cache3->contains('key2')); + } + + public function testFlushAll() + { + $cache = $this->_getCacheDriver(); + + $this->assertTrue($cache->save('key1', 1)); + $this->assertTrue($cache->save('key2', 2)); + $this->assertTrue($cache->flushAll()); + $this->assertFalse($cache->contains('key1')); + $this->assertFalse($cache->contains('key2')); + } + + public function testFlushAllAndNamespaceVersioningBetweenCaches() + { + if ( ! $this->isSharedStorage()) { + $this->markTestSkipped('The ' . __CLASS__ .' does not use shared storage'); + } + + $cache1 = $this->_getCacheDriver(); + $cache2 = $this->_getCacheDriver(); + + /* Deleting all elements from the first provider should increment its + * namespace version before saving the first entry. + */ + $cache1->deleteAll(); + $this->assertTrue($cache1->save('key1', 1)); + + /* The second provider will be initialized with the same namespace + * version upon its first save operation. + */ + $this->assertTrue($cache2->save('key2', 2)); + + /* Both providers have the same namespace version and can see entires + * set by each other. + */ + $this->assertTrue($cache1->contains('key1')); + $this->assertTrue($cache1->contains('key2')); + $this->assertTrue($cache2->contains('key1')); + $this->assertTrue($cache2->contains('key2')); + + /* Flushing all entries through one cache will remove all entries from + * the cache but leave their namespace version as-is. + */ + $this->assertTrue($cache1->flushAll()); + $this->assertFalse($cache1->contains('key1')); + $this->assertFalse($cache1->contains('key2')); + $this->assertFalse($cache2->contains('key1')); + $this->assertFalse($cache2->contains('key2')); + + /* Inserting a new entry will use the same, incremented namespace + * version, and it will be visible to both providers. + */ + $this->assertTrue($cache1->save('key1', 1)); + $this->assertTrue($cache1->contains('key1')); + $this->assertTrue($cache2->contains('key1')); + + /* A new cache provider will be initialized with the original namespace + * version and not share any visibility with the first two providers. + */ + $cache3 = $this->_getCacheDriver(); + $this->assertFalse($cache3->contains('key1')); + $this->assertFalse($cache3->contains('key2')); + $this->assertTrue($cache3->save('key3', 3)); + $this->assertTrue($cache3->contains('key3')); + } + + public function testNamespace() + { + $cache = $this->_getCacheDriver(); + + $cache->setNamespace('ns1_'); + + $this->assertTrue($cache->save('key1', 1)); + $this->assertTrue($cache->contains('key1')); + + $cache->setNamespace('ns2_'); + + $this->assertFalse($cache->contains('key1')); + } + + public function testDeleteAllNamespace() + { + $cache = $this->_getCacheDriver(); + + $cache->setNamespace('ns1'); + $this->assertFalse($cache->contains('key1')); + $cache->save('key1', 'test'); + $this->assertTrue($cache->contains('key1')); + + $cache->setNamespace('ns2'); + $this->assertFalse($cache->contains('key1')); + $cache->save('key1', 'test'); + $this->assertTrue($cache->contains('key1')); + + $cache->setNamespace('ns1'); + $this->assertTrue($cache->contains('key1')); + $cache->deleteAll(); + $this->assertFalse($cache->contains('key1')); + + $cache->setNamespace('ns2'); + $this->assertTrue($cache->contains('key1')); + $cache->deleteAll(); + $this->assertFalse($cache->contains('key1')); + } + + /** + * @group DCOM-43 + */ + public function testGetStats() + { + $cache = $this->_getCacheDriver(); + $stats = $cache->getStats(); + + $this->assertArrayHasKey(Cache::STATS_HITS, $stats); + $this->assertArrayHasKey(Cache::STATS_MISSES, $stats); + $this->assertArrayHasKey(Cache::STATS_UPTIME, $stats); + $this->assertArrayHasKey(Cache::STATS_MEMORY_USAGE, $stats); + $this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILABLE, $stats); + } + + public function testFetchMissShouldReturnFalse() + { + $cache = $this->_getCacheDriver(); + + /* Ensure that caches return boolean false instead of null on a fetch + * miss to be compatible with ORM integration. + */ + $result = $cache->fetch('nonexistent_key'); + + $this->assertFalse($result); + $this->assertNotNull($result); + } + + /** + * Return whether multiple cache providers share the same storage. + * + * This is used for skipping certain tests for shared storage behavior. + * + * @return boolean + */ + protected function isSharedStorage() + { + return true; + } + + /** + * @return \Doctrine\Common\Cache\CacheProvider + */ + abstract protected function _getCacheDriver(); +} diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CouchbaseCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CouchbaseCacheTest.php new file mode 100644 index 0000000000..40d5a6934b --- /dev/null +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CouchbaseCacheTest.php @@ -0,0 +1,47 @@ +couchbase = new Couchbase('127.0.0.1', 'Administrator', 'password', 'default'); + } catch(Exception $ex) { + $this->markTestSkipped('Could not instantiate the Couchbase cache because of: ' . $ex); + } + } else { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of the couchbase extension'); + } + } + + public function testNoExpire() + { + $cache = $this->_getCacheDriver(); + $cache->save('noexpire', 'value', 0); + sleep(1); + $this->assertTrue($cache->contains('noexpire'), 'Couchbase provider should support no-expire'); + } + + public function testLongLifetime() + { + $cache = $this->_getCacheDriver(); + $cache->save('key', 'value', 30 * 24 * 3600 + 1); + + $this->assertTrue($cache->contains('key'), 'Couchbase provider should support TTL > 30 days'); + } + + protected function _getCacheDriver() + { + $driver = new CouchbaseCache(); + $driver->setCouchbase($this->couchbase); + return $driver; + } +} \ No newline at end of file diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FileCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FileCacheTest.php new file mode 100644 index 0000000000..6f9df8158e --- /dev/null +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FileCacheTest.php @@ -0,0 +1,107 @@ +driver = $this->getMock( + 'Doctrine\Common\Cache\FileCache', + array('doFetch', 'doContains', 'doSave'), + array(), '', false + ); + } + + public function getProviderFileName() + { + return array( + //The characters :\/<>"*?| are not valid in Windows filenames. + array('key:1', 'key1'), + array('key\2', 'key2'), + array('key/3', 'key3'), + array('key<4', 'key4'), + array('key>5', 'key5'), + array('key"6', 'key6'), + array('key*7', 'key7'), + array('key?8', 'key8'), + array('key|9', 'key9'), + array('key[0]','key[0]'), + ); + } + + /** + * @dataProvider getProviderFileName + */ + public function testInvalidFilename($key, $expected) + { + $cache = $this->driver; + $method = new \ReflectionMethod($cache, 'getFilename'); + + $method->setAccessible(true); + + $value = $method->invoke($cache, $key); + $actual = pathinfo($value, PATHINFO_FILENAME); + + $this->assertEquals($expected, $actual); + } + + public function testFilenameCollision() + { + $data['key:0'] = 'key0'; + $data['key\0'] = 'key0'; + $data['key/0'] = 'key0'; + $data['key<0'] = 'key0'; + $data['key>0'] = 'key0'; + $data['key"0'] = 'key0'; + $data['key*0'] = 'key0'; + $data['key?0'] = 'key0'; + $data['key|0'] = 'key0'; + + $paths = array(); + $cache = $this->driver; + $method = new \ReflectionMethod($cache, 'getFilename'); + + $method->setAccessible(true); + + foreach ($data as $key => $expected) { + $path = $method->invoke($cache, $key); + $actual = pathinfo($path, PATHINFO_FILENAME); + + $this->assertNotContains($path, $paths); + $this->assertEquals($expected, $actual); + + $paths[] = $path; + } + } + + public function testFilenameShouldCreateThePathWithFourSubDirectories() + { + $cache = $this->driver; + $method = new \ReflectionMethod($cache, 'getFilename'); + $key = 'item-key'; + $expectedDir[] = '84e0e2e893febb73'; + $expectedDir[] = '7a0fee0c89d53f4b'; + $expectedDir[] = 'b7fcb44c57cdf3d3'; + $expectedDir[] = '2ce7363f5d597760'; + $expectedDir = implode(DIRECTORY_SEPARATOR, $expectedDir); + + $method->setAccessible(true); + + $path = $method->invoke($cache, $key); + $filename = pathinfo($path, PATHINFO_FILENAME); + $dirname = pathinfo($path, PATHINFO_DIRNAME); + + $this->assertEquals('item-key', $filename); + $this->assertEquals(DIRECTORY_SEPARATOR . $expectedDir, $dirname); + $this->assertEquals(DIRECTORY_SEPARATOR . $expectedDir . DIRECTORY_SEPARATOR . $key, $path); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php old mode 100755 new mode 100644 similarity index 65% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php index f782e3c002..e3b74cd016 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php @@ -2,29 +2,14 @@ namespace Doctrine\Tests\Common\Cache; +use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\FilesystemCache; /** * @group DCOM-101 */ -class FilesystemCacheTest extends CacheTest +class FilesystemCacheTest extends BaseFileCacheTest { - /** - * @var \Doctrine\Common\Cache\FilesystemCache - */ - private $driver; - - protected function _getCacheDriver() - { - $dir = sys_get_temp_dir() . "/doctrine_cache_". uniqid(); - $this->assertFalse(is_dir($dir)); - - $this->driver = new FilesystemCache($dir); - $this->assertTrue(is_dir($dir)); - - return $this->driver; - } - public function testLifetime() { $cache = $this->_getCacheDriver(); @@ -76,22 +61,15 @@ class FilesystemCacheTest extends CacheTest $cache = $this->_getCacheDriver(); $stats = $cache->getStats(); - $this->assertNull($stats); + $this->assertNull($stats[Cache::STATS_HITS]); + $this->assertNull($stats[Cache::STATS_MISSES]); + $this->assertNull($stats[Cache::STATS_UPTIME]); + $this->assertEquals(0, $stats[Cache::STATS_MEMORY_USAGE]); + $this->assertGreaterThan(0, $stats[Cache::STATS_MEMORY_AVAILABLE]); } - public function tearDown() + protected function _getCacheDriver() { - $dir = $this->driver->getDirectory(); - $ext = $this->driver->getExtension(); - $iterator = new \RecursiveDirectoryIterator($dir); - - foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) { - if ($file->isFile()) { - @unlink($file->getRealPath()); - } else { - @rmdir($file->getRealPath()); - } - } + return new FilesystemCache($this->directory); } - -} \ No newline at end of file +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php old mode 100755 new mode 100644 similarity index 60% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php index 36c180c935..b0da1b9697 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php @@ -3,25 +3,35 @@ namespace Doctrine\Tests\Common\Cache; use Doctrine\Common\Cache\MemcacheCache; +use Memcache; class MemcacheCacheTest extends CacheTest { - private $_memcache; + private $memcache; public function setUp() { - if (extension_loaded('memcache')) { - $this->_memcache = new \Memcache; - $ok = @$this->_memcache->connect('localhost', 11211); - if (!$ok) { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); - } - } else { + if ( ! extension_loaded('memcache')) { $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); } + + $this->memcache = new Memcache(); + + if (@$this->memcache->connect('localhost', 11211) === false) { + unset($this->memcache); + $this->markTestSkipped('The ' . __CLASS__ .' cannot connect to memcache'); + } } - public function testNoExpire() { + public function tearDown() + { + if ($this->memcache instanceof Memcache) { + $this->memcache->flush(); + } + } + + public function testNoExpire() + { $cache = $this->_getCacheDriver(); $cache->save('noexpire', 'value', 0); sleep(1); @@ -38,8 +48,7 @@ class MemcacheCacheTest extends CacheTest protected function _getCacheDriver() { $driver = new MemcacheCache(); - $driver->setMemcache($this->_memcache); + $driver->setMemcache($this->memcache); return $driver; } - } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php old mode 100755 new mode 100644 similarity index 52% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php index ecbe5a6001..071329fbcf --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\Common\Cache; use Doctrine\Common\Cache\MemcachedCache; +use Memcached; class MemcachedCacheTest extends CacheTest { @@ -10,21 +11,29 @@ class MemcachedCacheTest extends CacheTest public function setUp() { - if (extension_loaded('memcached')) { - $this->memcached = new \Memcached(); - $this->memcached->setOption(\Memcached::OPT_COMPRESSION, false); - $this->memcached->addServer('127.0.0.1', 11211); + if ( ! extension_loaded('memcached')) { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcached'); + } - $fh = @fsockopen('127.0.0.1', 11211); - if (!$fh) { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); - } - } else { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); + $this->memcached = new Memcached(); + $this->memcached->setOption(Memcached::OPT_COMPRESSION, false); + $this->memcached->addServer('127.0.0.1', 11211); + + if (@fsockopen('127.0.0.1', 11211) === false) { + unset($this->memcached); + $this->markTestSkipped('The ' . __CLASS__ .' cannot connect to memcache'); } } - public function testNoExpire() { + public function tearDown() + { + if ($this->memcached instanceof Memcached) { + $this->memcached->flush(); + } + } + + public function testNoExpire() + { $cache = $this->_getCacheDriver(); $cache->save('noexpire', 'value', 0); sleep(1); @@ -35,8 +44,7 @@ class MemcachedCacheTest extends CacheTest { $cache = $this->_getCacheDriver(); $cache->save('key', 'value', 30 * 24 * 3600 + 1); - - $this->assertTrue($cache->contains('key'), 'Memcached provider should support TTL > 30 days'); + $this->assertTrue($cache->contains('key'), 'Memcache provider should support TTL > 30 days'); } protected function _getCacheDriver() diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MongoDBCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MongoDBCacheTest.php new file mode 100644 index 0000000000..8c2f6e0e7c --- /dev/null +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MongoDBCacheTest.php @@ -0,0 +1,61 @@ +=')) { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of mongo >= 1.3.0'); + } + + $mongo = new MongoClient(); + $this->collection = $mongo->selectCollection('doctrine_common_cache', 'test'); + } + + public function tearDown() + { + if ($this->collection instanceof MongoCollection) { + $this->collection->drop(); + } + } + + public function testSaveWithNonUtf8String() + { + // Invalid 2-octet sequence + $data = "\xc3\x28"; + + $cache = $this->_getCacheDriver(); + + $this->assertTrue($cache->save('key', $data)); + $this->assertEquals($data, $cache->fetch('key')); + } + + public function testGetStats() + { + $cache = $this->_getCacheDriver(); + $stats = $cache->getStats(); + + $this->assertNull($stats[Cache::STATS_HITS]); + $this->assertNull($stats[Cache::STATS_MISSES]); + $this->assertGreaterThan(0, $stats[Cache::STATS_UPTIME]); + $this->assertEquals(0, $stats[Cache::STATS_MEMORY_USAGE]); + $this->assertNull($stats[Cache::STATS_MEMORY_AVAILABLE]); + } + + protected function _getCacheDriver() + { + return new MongoDBCache($this->collection); + } +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php old mode 100755 new mode 100644 similarity index 71% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php index 5085f46640..f49ce25e4e --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php @@ -2,34 +2,14 @@ namespace Doctrine\Tests\Common\Cache; +use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\PhpFileCache; /** * @group DCOM-101 */ -class PhpFileCacheTest extends CacheTest +class PhpFileCacheTest extends BaseFileCacheTest { - /** - * @var \Doctrine\Common\Cache\PhpFileCache - */ - private $driver; - - protected function _getCacheDriver() - { - $dir = sys_get_temp_dir() . "/doctrine_cache_". uniqid(); - $this->assertFalse(is_dir($dir)); - - $this->driver = new PhpFileCache($dir); - $this->assertTrue(is_dir($dir)); - - return $this->driver; - } - - public function testObjects() - { - $this->markTestSkipped('PhpFileCache does not support saving objects that dont implement __set_state()'); - } - public function testLifetime() { $cache = $this->_getCacheDriver(); @@ -98,28 +78,17 @@ class PhpFileCacheTest extends CacheTest $cache = $this->_getCacheDriver(); $stats = $cache->getStats(); - $this->assertNull($stats); + $this->assertNull($stats[Cache::STATS_HITS]); + $this->assertNull($stats[Cache::STATS_MISSES]); + $this->assertNull($stats[Cache::STATS_UPTIME]); + $this->assertEquals(0, $stats[Cache::STATS_MEMORY_USAGE]); + $this->assertGreaterThan(0, $stats[Cache::STATS_MEMORY_AVAILABLE]); } - public function tearDown() + protected function _getCacheDriver() { - if (!$this->driver) { - return; - } - - $dir = $this->driver->getDirectory(); - $ext = $this->driver->getExtension(); - $iterator = new \RecursiveDirectoryIterator($dir); - - foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) { - if ($file->isFile()) { - @unlink($file->getRealPath()); - } else { - @rmdir($file->getRealPath()); - } - } + return new PhpFileCache($this->directory); } - } class NotSetStateClass diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RiakCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RiakCacheTest.php new file mode 100644 index 0000000000..dce8cc00e2 --- /dev/null +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RiakCacheTest.php @@ -0,0 +1,64 @@ +markTestSkipped('The ' . __CLASS__ .' requires the use of Riak'); + } + + try { + $this->connection = new Connection('127.0.0.1', 8087); + $this->bucket = new Bucket($this->connection, 'test'); + } catch (Exception\RiakException $e) { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of Riak'); + } + } + + /** + * {@inheritdoc} + */ + public function testGetStats() + { + $cache = $this->_getCacheDriver(); + $stats = $cache->getStats(); + + $this->assertNull($stats); + } + + /** + * Retrieve RiakCache instance. + * + * @return \Doctrine\Common\Cache\RiakCache + */ + protected function _getCacheDriver() + { + return new RiakCache($this->bucket); + } +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/DoctrineTestCase.php b/vendor/doctrine/cache/tests/Doctrine/Tests/DoctrineTestCase.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/orm/tests/Doctrine/Tests/DoctrineTestCase.php rename to vendor/doctrine/cache/tests/Doctrine/Tests/DoctrineTestCase.php diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/TestInit.php b/vendor/doctrine/cache/tests/Doctrine/Tests/TestInit.php new file mode 100644 index 0000000000..5fc09af0c4 --- /dev/null +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/TestInit.php @@ -0,0 +1,21 @@ +add('Doctrine\\Tests\\', __DIR__ . '/../../'); +unset($classLoader); diff --git a/vendor/doctrine/cache/tests/travis/php.ini b/vendor/doctrine/cache/tests/travis/php.ini new file mode 100644 index 0000000000..ef5d9a1b7b --- /dev/null +++ b/vendor/doctrine/cache/tests/travis/php.ini @@ -0,0 +1,6 @@ +extension="mongo.so" +extension="memcache.so" +extension="memcached.so" + +apc.enabled=1 +apc.enable_cli=1 diff --git a/vendor/doctrine/cache/tests/travis/phpunit.travis.xml b/vendor/doctrine/cache/tests/travis/phpunit.travis.xml new file mode 100644 index 0000000000..a01faa5c2d --- /dev/null +++ b/vendor/doctrine/cache/tests/travis/phpunit.travis.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + ../Doctrine/ + + + + + + ../../lib/Doctrine/ + + + + + + performance + + + diff --git a/vendor/doctrine/collections/.gitignore b/vendor/doctrine/collections/.gitignore new file mode 100644 index 0000000000..48b8bf9072 --- /dev/null +++ b/vendor/doctrine/collections/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/vendor/doctrine/collections/.travis.yml b/vendor/doctrine/collections/.travis.yml new file mode 100644 index 0000000000..ecc35406d2 --- /dev/null +++ b/vendor/doctrine/collections/.travis.yml @@ -0,0 +1,9 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + +before_script: + - composer --prefer-source --dev install diff --git a/vendor/doctrine/collections/README.md b/vendor/doctrine/collections/README.md new file mode 100644 index 0000000000..9393a5515d --- /dev/null +++ b/vendor/doctrine/collections/README.md @@ -0,0 +1,3 @@ +# Doctrine Collections + +Collections Abstraction library diff --git a/vendor/doctrine/collections/composer.json b/vendor/doctrine/collections/composer.json new file mode 100644 index 0000000000..7e287ba65a --- /dev/null +++ b/vendor/doctrine/collections/composer.json @@ -0,0 +1,26 @@ +{ + "name": "doctrine/collections", + "type": "library", + "description": "Collections Abstraction library", + "keywords": ["collections", "array", "iterator"], + "homepage": "http://www.doctrine-project.org", + "license": "MIT", + "authors": [ + {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, + {"name": "Roman Borschel", "email": "roman@code-factory.org"}, + {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, + {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, + {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} + ], + "require": { + "php": ">=5.3.2" + }, + "autoload": { + "psr-0": { "Doctrine\\Common\\Collections\\": "lib/" } + }, + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/ArrayCollection.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php old mode 100755 new mode 100644 similarity index 51% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/ArrayCollection.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php index 7c2b13e690..9c2c8e1474 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -20,16 +20,15 @@ namespace Doctrine\Common\Collections; use Closure, ArrayIterator; -use Doctrine\Common\Collections\Expr\Expression; use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor; /** * An ArrayCollection is a Collection implementation that wraps a regular PHP array. * - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class ArrayCollection implements Collection, Selectable { @@ -51,9 +50,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Gets the PHP array representation of this collection. - * - * @return array The PHP array representation of this collection. + * {@inheritDoc} */ public function toArray() { @@ -61,10 +58,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Sets the internal iterator to the first element in the collection and - * returns this element. - * - * @return mixed + * {@inheritDoc} */ public function first() { @@ -72,10 +66,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Sets the internal iterator to the last element in the collection and - * returns this element. - * - * @return mixed + * {@inheritDoc} */ public function last() { @@ -83,9 +74,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Gets the current key/index at the current internal iterator position. - * - * @return mixed + * {@inheritDoc} */ public function key() { @@ -93,9 +82,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Moves the internal iterator position to the next element. - * - * @return mixed + * {@inheritDoc} */ public function next() { @@ -103,9 +90,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Gets the element of the collection at the current internal iterator position. - * - * @return mixed + * {@inheritDoc} */ public function current() { @@ -113,14 +98,11 @@ class ArrayCollection implements Collection, Selectable } /** - * Removes an element with a specific key/index from the collection. - * - * @param mixed $key - * @return mixed The removed element or NULL, if no element exists for the given key. + * {@inheritDoc} */ public function remove($key) { - if (isset($this->_elements[$key])) { + if (isset($this->_elements[$key]) || array_key_exists($key, $this->_elements)) { $removed = $this->_elements[$key]; unset($this->_elements[$key]); @@ -131,10 +113,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Removes the specified element from the collection, if it is found. - * - * @param mixed $element The element to remove. - * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. + * {@inheritDoc} */ public function removeElement($element) { @@ -150,12 +129,9 @@ class ArrayCollection implements Collection, Selectable } /** - * ArrayAccess implementation of offsetExists() + * Required by interface ArrayAccess. * - * @see containsKey() - * - * @param mixed $offset - * @return bool + * {@inheritDoc} */ public function offsetExists($offset) { @@ -163,12 +139,9 @@ class ArrayCollection implements Collection, Selectable } /** - * ArrayAccess implementation of offsetGet() + * Required by interface ArrayAccess. * - * @see get() - * - * @param mixed $offset - * @return mixed + * {@inheritDoc} */ public function offsetGet($offset) { @@ -176,14 +149,9 @@ class ArrayCollection implements Collection, Selectable } /** - * ArrayAccess implementation of offsetSet() + * Required by interface ArrayAccess. * - * @see add() - * @see set() - * - * @param mixed $offset - * @param mixed $value - * @return bool + * {@inheritDoc} */ public function offsetSet($offset, $value) { @@ -194,12 +162,9 @@ class ArrayCollection implements Collection, Selectable } /** - * ArrayAccess implementation of offsetUnset() + * Required by interface ArrayAccess. * - * @see remove() - * - * @param mixed $offset - * @return mixed + * {@inheritDoc} */ public function offsetUnset($offset) { @@ -207,42 +172,23 @@ class ArrayCollection implements Collection, Selectable } /** - * Checks whether the collection contains a specific key/index. - * - * @param mixed $key The key to check for. - * @return boolean TRUE if the given key/index exists, FALSE otherwise. + * {@inheritDoc} */ public function containsKey($key) { - return isset($this->_elements[$key]); + return isset($this->_elements[$key]) || array_key_exists($key, $this->_elements); } /** - * Checks whether the given element is contained in the collection. - * Only element values are compared, not keys. The comparison of two elements - * is strict, that means not only the value but also the type must match. - * For objects this means reference equality. - * - * @param mixed $element - * @return boolean TRUE if the given element is contained in the collection, - * FALSE otherwise. + * {@inheritDoc} */ public function contains($element) { - foreach ($this->_elements as $collectionElement) { - if ($element === $collectionElement) { - return true; - } - } - - return false; + return in_array($element, $this->_elements, true); } /** - * Tests for the existence of an element that satisfies the given predicate. - * - * @param Closure $p The predicate. - * @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise. + * {@inheritDoc} */ public function exists(Closure $p) { @@ -255,13 +201,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Searches for a given element and, if found, returns the corresponding key/index - * of that element. The comparison of two elements is strict, that means not - * only the value but also the type must match. - * For objects this means reference equality. - * - * @param mixed $element The element to search for. - * @return mixed The key/index of the element or FALSE if the element was not found. + * {@inheritDoc} */ public function indexOf($element) { @@ -269,10 +209,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Gets the element with the given key/index. - * - * @param mixed $key The key. - * @return mixed The element or NULL, if no element exists for the given key. + * {@inheritDoc} */ public function get($key) { @@ -283,9 +220,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Gets all keys/indexes of the collection elements. - * - * @return array + * {@inheritDoc} */ public function getKeys() { @@ -293,9 +228,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Gets all elements. - * - * @return array + * {@inheritDoc} */ public function getValues() { @@ -303,11 +236,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Returns the number of elements in the collection. - * - * Implementation of the Countable interface. - * - * @return integer The number of elements in the collection. + * {@inheritDoc} */ public function count() { @@ -315,13 +244,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Adds/sets an element in the collection at the index / with the specified key. - * - * When the collection is a Map this is like put(key,value)/add(key,value). - * When the collection is a List this is like add(position,value). - * - * @param mixed $key - * @param mixed $value + * {@inheritDoc} */ public function set($key, $value) { @@ -329,10 +252,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Adds an element to the collection. - * - * @param mixed $value - * @return boolean Always TRUE. + * {@inheritDoc} */ public function add($value) { @@ -341,11 +261,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Checks whether the collection is empty. - * - * Note: This is preferable over count() == 0. - * - * @return boolean TRUE if the collection is empty, FALSE otherwise. + * {@inheritDoc} */ public function isEmpty() { @@ -353,9 +269,9 @@ class ArrayCollection implements Collection, Selectable } /** - * Gets an iterator for iterating over the elements in the collection. + * Required by interface IteratorAggregate. * - * @return ArrayIterator + * {@inheritDoc} */ public function getIterator() { @@ -363,11 +279,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Applies the given function to each element in the collection and returns - * a new collection with the elements returned by the function. - * - * @param Closure $func - * @return Collection + * {@inheritDoc} */ public function map(Closure $func) { @@ -375,11 +287,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Returns all the elements of this collection that satisfy the predicate p. - * The order of the elements is preserved. - * - * @param Closure $p The predicate used for filtering. - * @return Collection A collection with the results of the filter operation. + * {@inheritDoc} */ public function filter(Closure $p) { @@ -387,11 +295,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Applies the given predicate p to all elements of this collection, - * returning true, if the predicate yields true for all elements. - * - * @param Closure $p The predicate. - * @return boolean TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. + * {@inheritDoc} */ public function forAll(Closure $p) { @@ -405,13 +309,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Partitions this collection in two collections according to a predicate. - * Keys are preserved in the resulting collections. - * - * @param Closure $p The predicate on which to partition. - * @return array An array with two elements. The first element contains the collection - * of elements where the predicate returned TRUE, the second element - * contains the collection of elements where the predicate returned FALSE. + * {@inheritDoc} */ public function partition(Closure $p) { @@ -437,7 +335,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Clears the collection. + * {@inheritDoc} */ public function clear() { @@ -445,15 +343,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Extract a slice of $length elements starting at position $offset from the Collection. - * - * If $length is null it returns all elements from $offset to the end of the Collection. - * Keys have to be preserved by this method. Calling this method will only return the - * selected slice and NOT change the elements contained in the collection slice is called on. - * - * @param int $offset - * @param int $length - * @return array + * {@inheritDoc} */ public function slice($offset, $length = null) { @@ -461,11 +351,7 @@ class ArrayCollection implements Collection, Selectable } /** - * Select all elements from a selectable that match the criteria and - * return a new collection containing these elements. - * - * @param Criteria $criteria - * @return Collection + * {@inheritDoc} */ public function matching(Criteria $criteria) { @@ -497,4 +383,3 @@ class ArrayCollection implements Collection, Selectable return new static($filtered); } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Collection.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php old mode 100755 new mode 100644 similarity index 86% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Collection.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php index 51eb9e7a76..0edf054a35 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Collection.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php @@ -38,10 +38,10 @@ use Closure, Countable, IteratorAggregate, ArrayAccess; * position unless you explicitly positioned it before. Prefer iteration with * external iterators. * - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ interface Collection extends Countable, IteratorAggregate, ArrayAccess { @@ -49,12 +49,15 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Adds an element at the end of the collection. * * @param mixed $element The element to add. + * * @return boolean Always TRUE. */ function add($element); /** * Clears the collection, removing all elements. + * + * @return void */ function clear(); @@ -63,6 +66,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * This is an O(n) operation, where n is the size of the collection. * * @param mixed $element The element to search for. + * * @return boolean TRUE if the collection contains the element, FALSE otherwise. */ function contains($element); @@ -78,6 +82,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Removes the element at the specified index from the collection. * * @param string|integer $key The kex/index of the element to remove. + * * @return mixed The removed element or NULL, if the collection did not contain the element. */ function remove($key); @@ -86,6 +91,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Removes the specified element from the collection, if it is found. * * @param mixed $element The element to remove. + * * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. */ function removeElement($element); @@ -94,8 +100,9 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Checks whether the collection contains an element with the specified key/index. * * @param string|integer $key The key/index to check for. + * * @return boolean TRUE if the collection contains an element with the specified key/index, - * FALSE otherwise. + * FALSE otherwise. */ function containsKey($key); @@ -103,6 +110,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Gets the element at the specified key/index. * * @param string|integer $key The key/index of the element to retrieve. + * * @return mixed */ function get($key); @@ -111,7 +119,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Gets all keys/indices of the collection. * * @return array The keys/indices of the collection, in the order of the corresponding - * elements in the collection. + * elements in the collection. */ function getKeys(); @@ -119,15 +127,17 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Gets all values of the collection. * * @return array The values of all elements in the collection, in the order they - * appear in the collection. + * appear in the collection. */ function getValues(); /** * Sets an element in the collection at the specified key/index. * - * @param string|integer $key The key/index of the element to set. - * @param mixed $value The element to set. + * @param string|integer $key The key/index of the element to set. + * @param mixed $value The element to set. + * + * @return void */ function set($key, $value); @@ -139,16 +149,14 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess function toArray(); /** - * Sets the internal iterator to the first element in the collection and - * returns this element. + * Sets the internal iterator to the first element in the collection and returns this element. * * @return mixed */ function first(); /** - * Sets the internal iterator to the last element in the collection and - * returns this element. + * Sets the internal iterator to the last element in the collection and returns this element. * * @return mixed */ @@ -157,18 +165,21 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess /** * Gets the key/index of the element at the current iterator position. * + * @return int|string */ function key(); /** * Gets the element of the collection at the current iterator position. * + * @return mixed */ function current(); /** - * Moves the internal iterator position to the next element. + * Moves the internal iterator position to the next element and returns this element. * + * @return mixed */ function next(); @@ -176,6 +187,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Tests for the existence of an element that satisfies the given predicate. * * @param Closure $p The predicate. + * * @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise. */ function exists(Closure $p); @@ -185,6 +197,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * The order of the elements is preserved. * * @param Closure $p The predicate used for filtering. + * * @return Collection A collection with the results of the filter operation. */ function filter(Closure $p); @@ -194,6 +207,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * returning true, if the predicate yields true for all elements. * * @param Closure $p The predicate. + * * @return boolean TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. */ function forAll(Closure $p); @@ -203,6 +217,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * a new collection with the elements returned by the function. * * @param Closure $func + * * @return Collection */ function map(Closure $func); @@ -212,6 +227,7 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * Keys are preserved in the resulting collections. * * @param Closure $p The predicate on which to partition. + * * @return array An array with two elements. The first element contains the collection * of elements where the predicate returned TRUE, the second element * contains the collection of elements where the predicate returned FALSE. @@ -224,19 +240,21 @@ interface Collection extends Countable, IteratorAggregate, ArrayAccess * For objects this means reference equality. * * @param mixed $element The element to search for. - * @return mixed The key/index of the element or FALSE if the element was not found. + * + * @return int|string|bool The key/index of the element or FALSE if the element was not found. */ function indexOf($element); /** - * Extract a slice of $length elements starting at position $offset from the Collection. + * Extracts a slice of $length elements starting at position $offset from the Collection. * * If $length is null it returns all elements from $offset to the end of the Collection. * Keys have to be preserved by this method. Calling this method will only return the * selected slice and NOT change the elements contained in the collection slice is called on. * - * @param int $offset - * @param int $length + * @param int $offset The offset to start from. + * @param int|null $length The maximum number of elements to return, or null for no limit. + * * @return array */ function slice($offset, $length = null); diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Criteria.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php old mode 100755 new mode 100644 similarity index 78% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Criteria.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php index 3b055495b1..42929bdcaa --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Criteria.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php @@ -41,12 +41,12 @@ class Criteria const DESC = 'DESC'; /** - * @var \Doctrine\Common\Collections\ExpressionBuilder + * @var \Doctrine\Common\Collections\ExpressionBuilder|null */ private static $expressionBuilder; /** - * @var \Doctrine\Common\Collections\Expr\Expression + * @var \Doctrine\Common\Collections\Expr\Expression|null */ private $expression; @@ -56,12 +56,12 @@ class Criteria private $orderings; /** - * @var int + * @var int|null */ private $firstResult; /** - * @var int + * @var int|null */ private $maxResults; @@ -76,7 +76,7 @@ class Criteria } /** - * Return the expression builder. + * Returns the expression builder. * * @return \Doctrine\Common\Collections\ExpressionBuilder */ @@ -89,12 +89,12 @@ class Criteria } /** - * Construct new criteria + * Construct a new Criteria. * * @param Expression $expression - * @param array $orderings - * @param int $firstResult - * @param int $maxResults + * @param array|null $orderings + * @param int|null $firstResult + * @param int|null $maxResults */ public function __construct(Expression $expression = null, array $orderings = null, $firstResult = null, $maxResults = null) { @@ -105,9 +105,10 @@ class Criteria } /** - * Set the where expression to evaluate when this criteria is searched for. + * Sets the where expression to evaluate when this Criteria is searched for. + * + * @param Expression $expression * - * @param Expression * @return Criteria */ public function where(Expression $expression) @@ -117,10 +118,11 @@ class Criteria } /** - * Append the where expression to evaluate when this criteria is searched for + * Appends the where expression to evaluate when this Criteria is searched for * using an AND with previous expression. * - * @param Expression + * @param Expression $expression + * * @return Criteria */ public function andWhere(Expression $expression) @@ -137,10 +139,11 @@ class Criteria } /** - * Append the where expression to evaluate when this criteria is searched for + * Appends the where expression to evaluate when this Criteria is searched for * using an OR with previous expression. * - * @param Expression + * @param Expression $expression + * * @return Criteria */ public function orWhere(Expression $expression) @@ -157,7 +160,7 @@ class Criteria } /** - * Get the expression attached to this criteria. + * Gets the expression attached to this Criteria. * * @return Expression|null */ @@ -167,7 +170,7 @@ class Criteria } /** - * Get current orderings of this Criteria + * Gets the current orderings of this Criteria. * * @return array */ @@ -177,14 +180,15 @@ class Criteria } /** - * Set the ordering of the result of this criteria. + * Sets the ordering of the result of this Criteria. * * Keys are field and values are the order, being either ASC or DESC. * * @see Criteria::ASC * @see Criteria::DESC * - * @param array + * @param array $orderings + * * @return Criteria */ public function orderBy(array $orderings) @@ -194,9 +198,9 @@ class Criteria } /** - * Get current first result option of the critera. + * Gets the current first result option of this Criteria. * - * @return firstResult. + * @return int|null */ public function getFirstResult() { @@ -204,9 +208,10 @@ class Criteria } /** - * Set number of first result that this criteria should return. + * Set the number of first result that this Criteria should return. + * + * @param int|null $firstResult The value to set. * - * @param firstResult the value to set. * @return Criteria */ public function setFirstResult($firstResult) @@ -216,9 +221,9 @@ class Criteria } /** - * Get maxResults. + * Gets maxResults. * - * @return maxResults. + * @return int|null */ public function getMaxResults() { @@ -226,9 +231,10 @@ class Criteria } /** - * Set maxResults. + * Sets maxResults. + * + * @param int|null $maxResults The value to set. * - * @param maxResults the value to set. * @return Criteria */ public function setMaxResults($maxResults) @@ -237,4 +243,3 @@ class Criteria return $this; } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php old mode 100755 new mode 100644 similarity index 80% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php index 06ccb047f0..78a0755aca --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php @@ -26,27 +26,42 @@ namespace Doctrine\Common\Collections\Expr; * by {@ArrayCollection#select()}. * * @author Benjamin Eberlei - * @since 2.3 + * @since 2.3 */ class ClosureExpressionVisitor extends ExpressionVisitor { /** - * Access the field of a given object. This field has to be public directly - * or indirectly (through an accessor get* or a magic method, __get, __call). + * Accesses the field of a given object. This field has to be public + * directly or indirectly (through an accessor get*, is*, or a magic + * method, __get, __call). * - * is*() is not supported. + * @param object $object + * @param string $field * * @return mixed */ - static public function getObjectFieldValue($object, $field) + public static function getObjectFieldValue($object, $field) { - $accessor = "get" . $field; + $accessors = array('get', 'is'); + + foreach ($accessors as $accessor) { + $accessor .= $field; + + if ( ! method_exists($object, $accessor)) { + continue; + } - if (method_exists($object, $accessor) || method_exists($object, '__call')) { return $object->$accessor(); } - if ($object instanceof \ArrayAccess) { + // __call should be triggered for get. + $accessor = $accessors[0] . $field; + + if (method_exists($object, '__call')) { + return $object->$accessor(); + } + + if ($object instanceof \ArrayAccess || is_array($object)) { return $object[$field]; } @@ -54,15 +69,15 @@ class ClosureExpressionVisitor extends ExpressionVisitor } /** - * Helper for sorting arrays of objects based on multiple fields + - * orientations. + * Helper for sorting arrays of objects based on multiple fields + orientations. * - * @param string $name - * @param int $orientation - * @param Closure $next - * @return Closure + * @param string $name + * @param int $orientation + * @param \Closure $next + * + * @return \Closure */ - static public function sortByField($name, $orientation = 1, \Closure $next = null) + public static function sortByField($name, $orientation = 1, \Closure $next = null) { if (!$next) { $next = function() { @@ -132,6 +147,11 @@ class ClosureExpressionVisitor extends ExpressionVisitor return ! in_array(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value); }; + case Comparison::CONTAINS: + return function ($object) use ($field, $value) { + return false !== strpos(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value); + }; + default: throw new \RuntimeException("Unknown comparison operator: " . $comparison->getOperator()); } @@ -168,6 +188,11 @@ class ClosureExpressionVisitor extends ExpressionVisitor } } + /** + * @param array $expressions + * + * @return callable + */ private function andExpressions($expressions) { return function ($object) use ($expressions) { @@ -180,6 +205,11 @@ class ClosureExpressionVisitor extends ExpressionVisitor }; } + /** + * @param array $expressions + * + * @return callable + */ private function orExpressions($expressions) { return function ($object) use ($expressions) { @@ -192,4 +222,3 @@ class ClosureExpressionVisitor extends ExpressionVisitor }; } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Comparison.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php old mode 100755 new mode 100644 similarity index 73% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Comparison.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php index 29cfcffa2c..641feecf81 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Comparison.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php @@ -23,24 +23,41 @@ namespace Doctrine\Common\Collections\Expr; * Comparison of a field with a value by the given operator. * * @author Benjamin Eberlei - * @since 2.3 + * @since 2.3 */ class Comparison implements Expression { - const EQ = '='; - const NEQ = '<>'; - const LT = '<'; - const LTE = '<='; - const GT = '>'; - const GTE = '>='; - const IS = 'IS'; - const IN = 'IN'; - const NIN = 'NIN'; + const EQ = '='; + const NEQ = '<>'; + const LT = '<'; + const LTE = '<='; + const GT = '>'; + const GTE = '>='; + const IS = 'IS'; + const IN = 'IN'; + const NIN = 'NIN'; + const CONTAINS = 'CONTAINS'; + /** + * @var string + */ private $field; + + /** + * @var string + */ private $op; + + /** + * @var Value + */ private $value; + /** + * @param string $field + * @param string $operator + * @param mixed $value + */ public function __construct($field, $operator, $value) { if ( ! ($value instanceof Value)) { @@ -52,24 +69,35 @@ class Comparison implements Expression $this->value = $value; } + /** + * @return string + */ public function getField() { return $this->field; } + /** + * @return Value + */ public function getValue() { return $this->value; } + /** + * @return string + */ public function getOperator() { return $this->op; } + /** + * {@inheritDoc} + */ public function visit(ExpressionVisitor $visitor) { return $visitor->walkComparison($this); } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php old mode 100755 new mode 100644 similarity index 86% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php index fe917cf3b5..3613c02745 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php @@ -23,16 +23,29 @@ namespace Doctrine\Common\Collections\Expr; * Expression of Expressions combined by AND or OR operation. * * @author Benjamin Eberlei - * @since 2.3 + * @since 2.3 */ class CompositeExpression implements Expression { const TYPE_AND = 'AND'; const TYPE_OR = 'OR'; + /** + * @var string + */ private $type; + + /** + * @var Expression[] + */ private $expressions = array(); + /** + * @param string $type + * @param array $expressions + * + * @throws \RuntimeException + */ public function __construct($type, array $expressions) { $this->type = $type; @@ -50,7 +63,7 @@ class CompositeExpression implements Expression } /** - * Return the list of expressions nested in this composite. + * Returns the list of expressions nested in this composite. * * @return Expression[] */ @@ -59,14 +72,19 @@ class CompositeExpression implements Expression return $this->expressions; } + /** + * @return string + */ public function getType() { return $this->type; } + /** + * {@inheritDoc} + */ public function visit(ExpressionVisitor $visitor) { return $visitor->walkCompositeExpression($this); } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Expression.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php old mode 100755 new mode 100644 similarity index 93% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Expression.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php index b0762ad2f4..68db767c07 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Expression.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php @@ -26,6 +26,10 @@ namespace Doctrine\Common\Collections\Expr; */ interface Expression { + /** + * @param ExpressionVisitor $visitor + * + * @return mixed + */ public function visit(ExpressionVisitor $visitor); } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php old mode 100755 new mode 100644 similarity index 86% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php index 5e69b987c7..080afdc6df --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php @@ -28,7 +28,7 @@ namespace Doctrine\Common\Collections\Expr; abstract class ExpressionVisitor { /** - * Convert a comparison expression into the target query language output + * Converts a comparison expression into the target query language output. * * @param Comparison $comparison * @@ -37,7 +37,7 @@ abstract class ExpressionVisitor abstract public function walkComparison(Comparison $comparison); /** - * Convert a value expression into the target query language part. + * Converts a value expression into the target query language part. * * @param Value $value * @@ -46,7 +46,7 @@ abstract class ExpressionVisitor abstract public function walkValue(Value $value); /** - * Convert a composite expression into the target query language output + * Converts a composite expression into the target query language output. * * @param CompositeExpression $expr * @@ -55,11 +55,13 @@ abstract class ExpressionVisitor abstract public function walkCompositeExpression(CompositeExpression $expr); /** - * Dispatch walking an expression to the appropriate handler. + * Dispatches walking an expression to the appropriate handler. * - * @param Expression + * @param Expression $expr * * @return mixed + * + * @throws \RuntimeException */ public function dispatch(Expression $expr) { @@ -78,4 +80,3 @@ abstract class ExpressionVisitor } } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Value.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php old mode 100755 new mode 100644 similarity index 90% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Value.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php index f0df11ac6d..7f6e83143b --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Value.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php @@ -21,21 +21,32 @@ namespace Doctrine\Common\Collections\Expr; class Value implements Expression { + /** + * @var mixed + */ private $value; + /** + * @param mixed $value + */ public function __construct($value) { $this->value = $value; } + /** + * @return mixed + */ public function getValue() { return $this->value; } + /** + * {@inheritDoc} + */ public function visit(ExpressionVisitor $visitor) { return $visitor->walkValue($this); } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/ExpressionBuilder.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php old mode 100755 new mode 100644 similarity index 84% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/ExpressionBuilder.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php index b53f0cd747..2bd7eaab64 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/ExpressionBuilder.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php @@ -1,9 +1,9 @@ - * @since 2.3 + * @since 2.3 */ class ExpressionBuilder { /** + * @param mixed $x + * * @return CompositeExpression */ public function andX($x = null) @@ -40,6 +42,8 @@ class ExpressionBuilder } /** + * @param mixed $x + * * @return CompositeExpression */ public function orX($x = null) @@ -49,7 +53,7 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value + * @param mixed $value * * @return Comparison */ @@ -60,7 +64,7 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value + * @param mixed $value * * @return Comparison */ @@ -71,7 +75,7 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value + * @param mixed $value * * @return Comparison */ @@ -82,7 +86,7 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value + * @param mixed $value * * @return Comparison */ @@ -93,7 +97,7 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value + * @param mixed $value * * @return Comparison */ @@ -104,7 +108,7 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value + * @param mixed $value * * @return Comparison */ @@ -115,7 +119,6 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value * * @return Comparison */ @@ -126,7 +129,7 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value + * @param mixed $values * * @return Comparison */ @@ -137,7 +140,7 @@ class ExpressionBuilder /** * @param string $field - * @param mixed $value + * @param mixed $values * * @return Comparison */ @@ -145,5 +148,15 @@ class ExpressionBuilder { return new Comparison($field, Comparison::NIN, new Value($values)); } -} + /** + * @param string $field + * @param mixed $value + * + * @return Comparison + */ + public function contains($field, $value) + { + return new Comparison($field, Comparison::CONTAINS, new Value($value)); + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Selectable.php b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Selectable.php old mode 100755 new mode 100644 similarity index 92% rename from vendor/doctrine/common/lib/Doctrine/Common/Collections/Selectable.php rename to vendor/doctrine/collections/lib/Doctrine/Common/Collections/Selectable.php index 675d6ea8b0..401d46e4df --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Selectable.php +++ b/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Selectable.php @@ -32,17 +32,17 @@ namespace Doctrine\Common\Collections; * EntityManager or Repositories. * * @author Benjamin Eberlei - * @since 2.3 + * @since 2.3 */ interface Selectable { /** - * Select all elements from a selectable that match the expression and - * return a new collection containing these elements. + * Selects all elements from a selectable that match the expression and + * returns a new collection containing these elements. * * @param Criteria $criteria + * * @return Collection */ function matching(Criteria $criteria); } - diff --git a/vendor/doctrine/collections/phpunit.xml.dist b/vendor/doctrine/collections/phpunit.xml.dist new file mode 100644 index 0000000000..36968e99c3 --- /dev/null +++ b/vendor/doctrine/collections/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + ./tests/Doctrine/ + + + + + + ./lib/Doctrine/ + + + + + + performance + + + diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php b/vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php old mode 100755 new mode 100644 similarity index 82% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php rename to vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php index e40afba7c2..b640043e6e --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php +++ b/vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php @@ -13,7 +13,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ @@ -36,6 +36,20 @@ class ClosureExpressionVisitorTest extends \PHPUnit_Framework_TestCase $this->builder = new ExpressionBuilder(); } + public function testGetObjectFieldValueIsAccessor() + { + $object = new TestObject(1, 2, true); + + $this->assertTrue($this->visitor->getObjectFieldValue($object, 'baz')); + } + + public function testGetObjectFieldValueMagicCallMethod() + { + $object = new TestObject(1, 2, true, 3); + + $this->assertEquals(3, $this->visitor->getObjectFieldValue($object, 'qux')); + } + public function testWalkEqualsComparison() { $closure = $this->visitor->walkComparison($this->builder->eq("foo", 1)); @@ -106,6 +120,14 @@ class ClosureExpressionVisitorTest extends \PHPUnit_Framework_TestCase $this->assertTrue($closure(new TestObject(4))); } + public function testWalkContainsComparison() + { + $closure = $this->visitor->walkComparison($this->builder->contains('foo', 'hello')); + + $this->assertTrue($closure(new TestObject('hello world'))); + $this->assertFalse($closure(new TestObject('world'))); + } + public function testWalkAndCompositeExpression() { $closure = $this->visitor->walkCompositeExpression( @@ -172,17 +194,35 @@ class ClosureExpressionVisitorTest extends \PHPUnit_Framework_TestCase $this->assertEquals("b", $objects[1]->getBar()); $this->assertEquals("c", $objects[2]->getBar()); } + + public function testArrayComparison() + { + $closure = $this->visitor->walkComparison($this->builder->eq("foo", 42)); + + $this->assertTrue($closure(array('foo' => 42))); + } } class TestObject { private $foo; private $bar; + private $baz; + private $qux; - public function __construct($foo = null, $bar = null) + public function __construct($foo = null, $bar = null, $baz = null, $qux = null) { $this->foo = $foo; $this->bar = $bar; + $this->baz = $baz; + $this->qux = $qux; + } + + public function __call($name, $arguments) + { + if ('getqux' === $name) { + return $this->qux; + } } public function getFoo() @@ -194,5 +234,10 @@ class TestObject { return $this->bar; } + + public function isBaz() + { + return $this->baz; + } } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CollectionTest.php b/vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/CollectionTest.php old mode 100755 new mode 100644 similarity index 95% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CollectionTest.php rename to vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/CollectionTest.php index 280efa3802..d98246c429 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CollectionTest.php +++ b/vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/CollectionTest.php @@ -248,4 +248,17 @@ class CollectionTest extends \Doctrine\Tests\DoctrineTestCase $this->assertEquals(1, count($col)); $this->assertEquals('baz', $col[0]->foo); } + + public function testCanRemoveNullValuesByKey() + { + $this->_coll->add(null); + $this->_coll->remove(0); + $this->assertTrue($this->_coll->isEmpty()); + } + + public function testCanVerifyExistingKeysWithNullValues() + { + $this->_coll->set('key', null); + $this->assertTrue($this->_coll->containsKey('key')); + } } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php b/vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php rename to vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php b/vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php old mode 100755 new mode 100644 similarity index 92% rename from vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php rename to vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php index 68896b37f7..23dfc21714 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php +++ b/vendor/doctrine/collections/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php @@ -110,5 +110,13 @@ class ExpressionBuilderTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); $this->assertEquals(Comparison::IS, $expr->getOperator()); } + + public function testContains() + { + $expr = $this->builder->contains("a", "b"); + + $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); + $this->assertEquals(Comparison::CONTAINS, $expr->getOperator()); + } } diff --git a/vendor/doctrine/collections/tests/Doctrine/Tests/DoctrineTestCase.php b/vendor/doctrine/collections/tests/Doctrine/Tests/DoctrineTestCase.php new file mode 100644 index 0000000000..e8323d2940 --- /dev/null +++ b/vendor/doctrine/collections/tests/Doctrine/Tests/DoctrineTestCase.php @@ -0,0 +1,10 @@ +. - */ - -/** - * Install PHP extensions required for testing by Travis CI. - * - * @author Victor Berchet - * @since 2.2 - */ -$installer = new PhpExtensions(); - -if (isset($argv[1]) && 'APC' === strtoupper($argv[1])) { - $installer->install('apc'); -} else { - $installer->install('xcache'); -} - -$installer->install('memcache'); -$installer->install('memcached'); - -class PhpExtensions -{ - protected $extensions; - protected $phpVersion; - protected $iniPath; - - public function __construct() - { - $this->phpVersion = phpversion(); - $this->iniPath = php_ini_loaded_file(); - $this->extensions = array( - 'memcache' => array( - 'url' => 'http://pecl.php.net/get/memcache-2.2.6.tgz', - 'php_version' => array(), - 'cfg' => array('--enable-memcache'), - 'ini' => array('extension=memcache.so'), - ), - 'memcached' => array( - 'url' => 'http://pecl.php.net/get/memcached-1.0.2.tgz', - 'php_version' => array( - // memcached 1.0.2 does not build on PHP 5.4 - array('<', '5.4'), - ), - 'cfg' => array(), - 'ini' => array('extension=memcached.so'), - ), - 'apc' => array( - 'url' => 'http://pecl.php.net/get/APC-3.1.9.tgz', - 'php_version' => array( - // apc 3.1.9 causes a segfault on PHP 5.4 - array('<', '5.4'), - ), - 'cfg' => array(), - 'ini' => array( - 'extension=apc.so', - 'apc.enabled=1', - 'apc.enable_cli=1' - ), - ), - 'xcache' => array( - 'url' => 'http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz', - 'php_version' => array( - // xcache does not build with Travis CI (as of 2012-01-09) - array('<', '5'), - ), - 'cfg' => array('--enable-xcache'), - 'ini' => array( - 'extension=xcache.so', - 'xcache.cacher=false', - 'xcache.admin.enable_auth=0', - 'xcache.var_size=1M', - ), - ), - ); - } - - public function install($name) - { - if (array_key_exists($name, $this->extensions)) { - $extension = $this->extensions[$name]; - - - echo "== extension: $name ==\n"; - - foreach ($extension['php_version'] as $version) { - if (!version_compare($this->phpVersion, $version[1], $version[0])) { - printf( - "=> not installed, requires a PHP version %s %s (%s installed)\n", - $version[0], - $version[1], - $this->phpVersion - ); - - return; - } - } - - $this->system(sprintf("wget %s > /dev/null 2>&1", $extension['url'])); - $file = basename($extension['url']); - $this->system(sprintf("tar -xzf %s > /dev/null 2>&1", $file)); - $folder = basename($file, ".tgz"); - $folder = basename($folder, ".tar.gz"); - $this->system(sprintf( - 'sh -c "cd %s && phpize && ./configure %s && make && sudo make install" > /dev/null 2>&1', - $folder, - implode(' ', $extension['cfg']) - )); - foreach ($extension['ini'] as $ini) { - $this->system(sprintf("echo %s >> %s", $ini, $this->iniPath)); - } - printf("=> installed (%s)\n", $folder); - } - } - - private function system($cmd) - { - $ret = 0; - system($cmd, $ret); - if (0 !== $ret) { - printf("=> Command '%s' failed !", $cmd); - - exit($ret); - } - } -} diff --git a/vendor/doctrine/common/build.properties b/vendor/doctrine/common/build.properties old mode 100755 new mode 100644 index ff311a4592..ef51d207f6 --- a/vendor/doctrine/common/build.properties +++ b/vendor/doctrine/common/build.properties @@ -1,6 +1,3 @@ -# Project Name -project.name=DoctrineCommon - # Version class and file -project.version_class = Doctrine\Common\Version +project.version_class = Doctrine\\Common\\Version project.version_file = lib/Doctrine/Common/Version.php diff --git a/vendor/doctrine/common/build.xml b/vendor/doctrine/common/build.xml old mode 100755 new mode 100644 index 71a9a5000e..429b7688fe --- a/vendor/doctrine/common/build.xml +++ b/vendor/doctrine/common/build.xml @@ -1,59 +1,101 @@ - - - - + - - - - - - - - - - - - - - - - - - - - + + + + - - - - DoctrineCommon - Doctrine Common PHP Extensions - pear.doctrine-project.org - The Doctrine Common package contains shared code between the other packages. - - - - - LGPL - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/doctrine/common/composer.json b/vendor/doctrine/common/composer.json old mode 100755 new mode 100644 index c87258de0a..b8c36b5ea1 --- a/vendor/doctrine/common/composer.json +++ b/vendor/doctrine/common/composer.json @@ -13,14 +13,22 @@ {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} ], "require": { - "php": ">=5.3.2" + "php": ">=5.3.2", + "doctrine/inflector": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/lexer": "1.*", + "doctrine/annotations": "1.*" }, "autoload": { - "psr-0": { "Doctrine\\Common": "lib/" } + "psr-0": { "Doctrine\\Common\\": "lib/" } }, "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "2.4.x-dev" } + }, + "archive": { + "exclude": ["!vendor", "tests", "*phpunit.xml", ".travis.yml", "build.xml", "build.properties", "composer.phar"] } } diff --git a/vendor/doctrine/common/composer.lock b/vendor/doctrine/common/composer.lock new file mode 100644 index 0000000000..1ed8a6b230 --- /dev/null +++ b/vendor/doctrine/common/composer.lock @@ -0,0 +1,322 @@ +{ + "hash": "f763db6a8f5bcaff6e51ae516283a4c9", + "packages": [ + { + "name": "doctrine/annotations", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "v1.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/doctrine/annotations/archive/v1.0.zip", + "reference": "v1.0", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "doctrine/lexer": "1.*" + }, + "require-dev": { + "doctrine/cache": "1.*" + }, + "time": "2013-01-12 19:23:32", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "parser", + "docblock" + ] + }, + { + "name": "doctrine/cache", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "v1.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/doctrine/cache/archive/v1.0.zip", + "reference": "v1.0", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2013-01-10 22:43:46", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Cache\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ] + }, + { + "name": "doctrine/collections", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "v1.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/doctrine/collections/archive/v1.0.zip", + "reference": "v1.0", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2013-01-12 16:36:50", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "collections", + "iterator", + "array" + ] + }, + { + "name": "doctrine/inflector", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "v1.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/doctrine/inflector/archive/v1.0.zip", + "reference": "v1.0", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2013-01-10 21:49:15", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Inflector\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "string", + "inflection", + "singuarlize", + "pluarlize" + ] + }, + { + "name": "doctrine/lexer", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "v1.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/doctrine/lexer/archive/v1.0.zip", + "reference": "v1.0", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2013-01-12 18:59:04", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "parser", + "lexer" + ] + } + ], + "packages-dev": null, + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ] +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php b/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php old mode 100755 new mode 100644 index 45024e16cd..632805e570 --- a/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php @@ -34,22 +34,30 @@ namespace Doctrine\Common; class ClassLoader { /** - * @var string PHP file extension + * PHP file extension. + * + * @var string */ protected $fileExtension = '.php'; /** - * @var string Current namespace + * Current namespace. + * + * @var string|null */ protected $namespace; /** - * @var string Current include path + * Current include path. + * + * @var string|null */ protected $includePath; /** - * @var string PHP namespace separator + * PHP namespace separator. + * + * @var string */ protected $namespaceSeparator = '\\'; @@ -61,8 +69,8 @@ class ClassLoader * If neither a namespace nor an include path is given, the ClassLoader will * be responsible for loading all classes, thereby relying on the PHP include_path. * - * @param string $ns The namespace of the classes to load. - * @param string $includePath The base include path to use. + * @param string|null $ns The namespace of the classes to load. + * @param string|null $includePath The base include path to use. */ public function __construct($ns = null, $includePath = null) { @@ -74,6 +82,8 @@ class ClassLoader * Sets the namespace separator used by classes in the namespace of this ClassLoader. * * @param string $sep The separator to use. + * + * @return void */ public function setNamespaceSeparator($sep) { @@ -93,7 +103,9 @@ class ClassLoader /** * Sets the base include path for all class files in the namespace of this ClassLoader. * - * @param string $includePath + * @param string|null $includePath + * + * @return void */ public function setIncludePath($includePath) { @@ -103,7 +115,7 @@ class ClassLoader /** * Gets the base include path for all class files in the namespace of this ClassLoader. * - * @return string + * @return string|null */ public function getIncludePath() { @@ -114,6 +126,8 @@ class ClassLoader * Sets the file extension of class files in the namespace of this ClassLoader. * * @param string $fileExtension + * + * @return void */ public function setFileExtension($fileExtension) { @@ -132,6 +146,8 @@ class ClassLoader /** * Registers this ClassLoader on the SPL autoload stack. + * + * @return void */ public function register() { @@ -140,6 +156,8 @@ class ClassLoader /** * Removes this ClassLoader from the SPL autoload stack. + * + * @return void */ public function unregister() { @@ -150,7 +168,7 @@ class ClassLoader * Loads the given class or interface. * * @param string $className The name of the class to load. - + * * @return boolean TRUE if the class has been successfully loaded, FALSE otherwise. */ public function loadClass($className) @@ -171,6 +189,7 @@ class ClassLoader * the given name. * * @param string $className The fully-qualified name of the class. + * * @return boolean TRUE if this ClassLoader can load the class, FALSE otherwise. */ public function canLoadClass($className) @@ -182,7 +201,7 @@ class ClassLoader $file = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) . $this->fileExtension; if ($this->includePath !== null) { - return file_exists($this->includePath . DIRECTORY_SEPARATOR . $file); + return is_file($this->includePath . DIRECTORY_SEPARATOR . $file); } return (false !== stream_resolve_include_path($file)); @@ -207,6 +226,7 @@ class ClassLoader * these responsibilities. * * @param string $className The fully-qualified name of the class. + * * @return boolean TRUE if the class exists as per the definition given above, FALSE otherwise. */ public static function classExists($className) @@ -235,9 +255,13 @@ class ClassLoader } else if (is_string($loader) && $loader($className)) { // "MyClass::loadClass" return true; } + + if (class_exists($className, false) || interface_exists($className, false)) { + return true; + } } - return class_exists($className, false) || interface_exists($className, false); + return false; } /** @@ -245,6 +269,7 @@ class ClassLoader * for (and is able to load) the class with the given name. * * @param string $className The name of the class. + * * @return ClassLoader The ClassLoader for the class or NULL if no such ClassLoader exists. */ public static function getClassLoader($className) diff --git a/vendor/doctrine/common/lib/Doctrine/Common/CommonException.php b/vendor/doctrine/common/lib/Doctrine/Common/CommonException.php old mode 100755 new mode 100644 index 6db7675950..2a1a08e7ef --- a/vendor/doctrine/common/lib/Doctrine/Common/CommonException.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/CommonException.php @@ -20,9 +20,10 @@ namespace Doctrine\Common; /** - * Base exception class for package Doctrine\Common - * @author heinrich + * Base exception class for package Doctrine\Common. * + * @author heinrich */ -class CommonException extends \Exception { +class CommonException extends \Exception +{ } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Comparable.php b/vendor/doctrine/common/lib/Doctrine/Common/Comparable.php old mode 100755 new mode 100644 index 20d065e74d..8cd02c9f29 --- a/vendor/doctrine/common/lib/Doctrine/Common/Comparable.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Comparable.php @@ -17,22 +17,20 @@ * . */ - namespace Doctrine\Common; /** * Comparable interface that allows to compare two value objects to each other for similarity. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco */ interface Comparable { /** - * Compare the current object to the passed $other. + * Compares the current object to the passed $other. * * Returns 0 if they are semantically equal, 1 if the other object * is less than the current one, or -1 if its more than the current one. @@ -46,4 +44,3 @@ interface Comparable */ public function compareTo($other); } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/EventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/EventArgs.php old mode 100755 new mode 100644 index a87eee89ac..75506e6acf --- a/vendor/doctrine/common/lib/Doctrine/Common/EventArgs.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/EventArgs.php @@ -1,7 +1,5 @@ - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class EventArgs { /** - * @var EventArgs Single instance of EventArgs + * Single instance of EventArgs. + * + * @var EventArgs */ private static $_emptyEventArgsInstance; @@ -50,10 +48,12 @@ class EventArgs * like this: EventManager::dispatchEvent('eventname'); * * The benefit from this is that only one empty instance is instantiated and shared - * (otherwise there would be instances for every dispatched in the abovementioned form) + * (otherwise there would be instances for every dispatched in the abovementioned form). * * @see EventManager::dispatchEvent + * * @link http://msdn.microsoft.com/en-us/library/system.eventargs.aspx + * * @return EventArgs */ public static function getEmptyInstance() diff --git a/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php b/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php old mode 100755 new mode 100644 index 25aac445d1..fbbd2a8ae4 --- a/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php @@ -1,7 +1,5 @@ - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class EventManager { @@ -47,10 +43,11 @@ class EventManager /** * Dispatches an event to all registered listeners. * - * @param string $eventName The name of the event to dispatch. The name of the event is - * the name of the method that is invoked on listeners. - * @param EventArgs $eventArgs The event arguments to pass to the event handlers/listeners. - * If not supplied, the single empty EventArgs instance is used. + * @param string $eventName The name of the event to dispatch. The name of the event is + * the name of the method that is invoked on listeners. + * @param EventArgs|null $eventArgs The event arguments to pass to the event handlers/listeners. + * If not supplied, the single empty EventArgs instance is used. + * * @return boolean */ public function dispatchEvent($eventName, EventArgs $eventArgs = null) @@ -67,7 +64,8 @@ class EventManager /** * Gets the listeners of a specific event or all listeners. * - * @param string $event The name of the event. + * @param string|null $event The name of the event. + * * @return array The event listeners for the specified event, or all event listeners. */ public function getListeners($event = null) @@ -79,6 +77,7 @@ class EventManager * Checks whether an event has any registered listeners. * * @param string $event + * * @return boolean TRUE if the specified event has any listeners, FALSE otherwise. */ public function hasListeners($event) @@ -89,8 +88,10 @@ class EventManager /** * Adds an event listener that listens on the specified events. * - * @param string|array $events The event(s) to listen on. - * @param object $listener The listener object. + * @param string|array $events The event(s) to listen on. + * @param object $listener The listener object. + * + * @return void */ public function addEventListener($events, $listener) { @@ -108,7 +109,9 @@ class EventManager * Removes an event listener from the specified events. * * @param string|array $events - * @param object $listener + * @param object $listener + * + * @return void */ public function removeEventListener($events, $listener) { @@ -128,20 +131,24 @@ class EventManager * interested in and added as a listener for these events. * * @param \Doctrine\Common\EventSubscriber $subscriber The subscriber. + * + * @return void */ public function addEventSubscriber(EventSubscriber $subscriber) { $this->addEventListener($subscriber->getSubscribedEvents(), $subscriber); } - + /** * Removes an EventSubscriber. The subscriber is asked for all the events it is * interested in and removed as a listener for these events. * * @param \Doctrine\Common\EventSubscriber $subscriber The subscriber. + * + * @return void */ public function removeEventSubscriber(EventSubscriber $subscriber) { $this->removeEventListener($subscriber->getSubscribedEvents(), $subscriber); - } + } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/EventSubscriber.php b/vendor/doctrine/common/lib/Doctrine/Common/EventSubscriber.php old mode 100755 new mode 100644 index 14587913a7..55d0f7d0ef --- a/vendor/doctrine/common/lib/Doctrine/Common/EventSubscriber.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/EventSubscriber.php @@ -1,7 +1,5 @@ - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ interface EventSubscriber { @@ -41,5 +38,5 @@ interface EventSubscriber * * @return array */ - function getSubscribedEvents(); + public function getSubscribedEvents(); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php b/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php old mode 100755 new mode 100644 index 8e2554c75f..0aa07f8564 --- a/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php @@ -19,248 +19,19 @@ namespace Doctrine\Common; +use Doctrine\Common\Lexer\AbstractLexer; + /** * Base class for writing simple lexers, i.e. for creating small DSLs. * - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @todo Rename: AbstractLexer + * Lexer moved into its own Component Doctrine\Common\Lexer. This class + * only stays for being BC. + * + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ -abstract class Lexer +abstract class Lexer extends AbstractLexer { - /** - * @var array Array of scanned tokens - */ - private $tokens = array(); - - /** - * @var integer Current lexer position in input string - */ - private $position = 0; - - /** - * @var integer Current peek of current lexer position - */ - private $peek = 0; - - /** - * @var array The next token in the input. - */ - public $lookahead; - - /** - * @var array The last matched/seen token. - */ - public $token; - - /** - * Sets the input data to be tokenized. - * - * The Lexer is immediately reset and the new input tokenized. - * Any unprocessed tokens from any previous input are lost. - * - * @param string $input The input to be tokenized. - */ - public function setInput($input) - { - $this->tokens = array(); - $this->reset(); - $this->scan($input); - } - - /** - * Resets the lexer. - */ - public function reset() - { - $this->lookahead = null; - $this->token = null; - $this->peek = 0; - $this->position = 0; - } - - /** - * Resets the peek pointer to 0. - */ - public function resetPeek() - { - $this->peek = 0; - } - - /** - * Resets the lexer position on the input to the given position. - * - * @param integer $position Position to place the lexical scanner - */ - public function resetPosition($position = 0) - { - $this->position = $position; - } - - /** - * Checks whether a given token matches the current lookahead. - * - * @param integer|string $token - * @return boolean - */ - public function isNextToken($token) - { - return null !== $this->lookahead && $this->lookahead['type'] === $token; - } - - /** - * Checks whether any of the given tokens matches the current lookahead - * - * @param array $tokens - * @return boolean - */ - public function isNextTokenAny(array $tokens) - { - return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true); - } - - /** - * Moves to the next token in the input string. - * - * A token is an associative array containing three items: - * - 'value' : the string value of the token in the input string - * - 'type' : the type of the token (identifier, numeric, string, input - * parameter, none) - * - 'position' : the position of the token in the input string - * - * @return array|null the next token; null if there is no more tokens left - */ - public function moveNext() - { - $this->peek = 0; - $this->token = $this->lookahead; - $this->lookahead = (isset($this->tokens[$this->position])) - ? $this->tokens[$this->position++] : null; - - return $this->lookahead !== null; - } - - /** - * Tells the lexer to skip input tokens until it sees a token with the given value. - * - * @param string $type The token type to skip until. - */ - public function skipUntil($type) - { - while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { - $this->moveNext(); - } - } - - /** - * Checks if given value is identical to the given token - * - * @param mixed $value - * @param integer $token - * @return boolean - */ - public function isA($value, $token) - { - return $this->getType($value) === $token; - } - - /** - * Moves the lookahead token forward. - * - * @return array | null The next token or NULL if there are no more tokens ahead. - */ - public function peek() - { - if (isset($this->tokens[$this->position + $this->peek])) { - return $this->tokens[$this->position + $this->peek++]; - } else { - return null; - } - } - - /** - * Peeks at the next token, returns it and immediately resets the peek. - * - * @return array|null The next token or NULL if there are no more tokens ahead. - */ - public function glimpse() - { - $peek = $this->peek(); - $this->peek = 0; - return $peek; - } - - /** - * Scans the input string for tokens. - * - * @param string $input a query string - */ - protected function scan($input) - { - static $regex; - - if ( ! isset($regex)) { - $regex = '/(' . implode(')|(', $this->getCatchablePatterns()) . ')|' - . implode('|', $this->getNonCatchablePatterns()) . '/i'; - } - - $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; - $matches = preg_split($regex, $input, -1, $flags); - - foreach ($matches as $match) { - // Must remain before 'value' assignment since it can change content - $type = $this->getType($match[0]); - - $this->tokens[] = array( - 'value' => $match[0], - 'type' => $type, - 'position' => $match[1], - ); - } - } - - /** - * Gets the literal for a given token. - * - * @param integer $token - * @return string - */ - public function getLiteral($token) - { - $className = get_class($this); - $reflClass = new \ReflectionClass($className); - $constants = $reflClass->getConstants(); - - foreach ($constants as $name => $value) { - if ($value === $token) { - return $className . '::' . $name; - } - } - - return $token; - } - - /** - * Lexical catchable patterns. - * - * @return array - */ - abstract protected function getCatchablePatterns(); - - /** - * Lexical non-catchable patterns. - * - * @return array - */ - abstract protected function getNonCatchablePatterns(); - - /** - * Retrieve token type. Also processes the token value if necessary. - * - * @param string $value - * @return integer - */ - abstract protected function getType(&$value); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/NotifyPropertyChanged.php b/vendor/doctrine/common/lib/Doctrine/Common/NotifyPropertyChanged.php old mode 100755 new mode 100644 index e32c0b98e4..e25e999708 --- a/vendor/doctrine/common/lib/Doctrine/Common/NotifyPropertyChanged.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/NotifyPropertyChanged.php @@ -1,7 +1,5 @@ - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ interface NotifyPropertyChanged { @@ -39,7 +35,8 @@ interface NotifyPropertyChanged * Adds a listener that wants to be notified about property changes. * * @param PropertyChangedListener $listener + * + * @return void */ - function addPropertyChangedListener(PropertyChangedListener $listener); + public function addPropertyChangedListener(PropertyChangedListener $listener); } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php old mode 100755 new mode 100644 index 94fcd052a7..15b5aa32cf --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php @@ -1,5 +1,4 @@ - * @author Benjamin Eberlei - * @author Lukas Kahwe Smith + * @link www.doctrine-project.org + * @since 2.2 + * @author Fabien Potencier + * @author Benjamin Eberlei + * @author Lukas Kahwe Smith */ abstract class AbstractManagerRegistry implements ManagerRegistry { @@ -65,11 +63,11 @@ abstract class AbstractManagerRegistry implements ManagerRegistry private $proxyInterfaceName; /** - * Constructor + * Constructor. * * @param string $name - * @param array $connections - * @param array $managers + * @param array $connections + * @param array $managers * @param string $defaultConnection * @param string $defaultManager * @param string $proxyInterfaceName @@ -85,27 +83,29 @@ abstract class AbstractManagerRegistry implements ManagerRegistry } /** - * Fetches/creates the given services + * Fetches/creates the given services. * - * A service in this context is connection or a manager instance + * A service in this context is connection or a manager instance. * - * @param string $name name of the service - * @return object instance of the given service + * @param string $name The name of the service. + * + * @return object The instance of the given service. */ abstract protected function getService($name); /** - * Resets the given services + * Resets the given services. * - * A service in this context is connection or a manager instance + * A service in this context is connection or a manager instance. + * + * @param string $name The name of the service. * - * @param string $name name of the service * @return void */ abstract protected function resetService($name); /** - * Get the name of the registry + * Gets the name of the registry. * * @return string */ diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php old mode 100755 new mode 100644 index 7d6f0cfb36..7c25e98aad --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php @@ -22,42 +22,41 @@ namespace Doctrine\Common\Persistence; /** * Contract covering connection for a Doctrine persistence layer ManagerRegistry class to implement. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Fabien Potencier - * @author Benjamin Eberlei - * @author Lukas Kahwe Smith + * @link www.doctrine-project.org + * @since 2.2 + * @author Fabien Potencier + * @author Benjamin Eberlei + * @author Lukas Kahwe Smith */ interface ConnectionRegistry { /** * Gets the default connection name. * - * @return string The default connection name + * @return string The default connection name. */ - function getDefaultConnectionName(); + public function getDefaultConnectionName(); /** * Gets the named connection. * - * @param string $name The connection name (null for the default one) + * @param string $name The connection name (null for the default one). * * @return object */ - function getConnection($name = null); + public function getConnection($name = null); /** - * Gets an array of all registered connections + * Gets an array of all registered connections. * - * @return array An array of Connection instances + * @return array An array of Connection instances. */ - function getConnections(); + public function getConnections(); /** * Gets all connection names. * - * @return array An array of connection names + * @return array An array of connection names. */ - function getConnectionNames(); + public function getConnectionNames(); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php old mode 100755 new mode 100644 index 2fb7c4737c..52f41c0e75 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\Common\Persistence\Event; @@ -41,32 +41,44 @@ class LifecycleEventArgs extends EventArgs /** * @var object */ - private $entity; + private $object; /** - * Constructor + * Constructor. * - * @param object $entity + * @param object $object * @param ObjectManager $objectManager */ - public function __construct($entity, ObjectManager $objectManager) + public function __construct($object, ObjectManager $objectManager) { - $this->entity = $entity; + $this->object = $object; $this->objectManager = $objectManager; } /** - * Retrieve associated Entity. + * Retrieves the associated entity. + * + * @deprecated * * @return object */ public function getEntity() { - return $this->entity; + return $this->object; } /** - * Retrieve associated ObjectManager. + * Retrieves the associated object. + * + * @return object + */ + public function getObject() + { + return $this->object; + } + + /** + * Retrieves the associated ObjectManager. * * @return ObjectManager */ diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php old mode 100755 new mode 100644 index c014d7318e..07770bb7cc --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php @@ -54,7 +54,7 @@ class LoadClassMetadataEventArgs extends EventArgs } /** - * Retrieve associated ClassMetadata. + * Retrieves the associated ClassMetadata. * * @return ClassMetadata */ @@ -64,7 +64,7 @@ class LoadClassMetadataEventArgs extends EventArgs } /** - * Retrieve associated ObjectManager. + * Retrieves the associated ObjectManager. * * @return ObjectManager */ @@ -73,4 +73,3 @@ class LoadClassMetadataEventArgs extends EventArgs return $this->objectManager; } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php old mode 100755 new mode 100644 index f1393658de..5527d4d47b --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php @@ -15,22 +15,22 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\Common\Persistence\Event; +use Doctrine\Common\EventArgs; use Doctrine\Common\Persistence\ObjectManager; /** * Provides event arguments for the preFlush event. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Roman Borschel - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.2 + * @author Roman Borschel + * @author Benjamin Eberlei */ -class ManagerEventArgs extends \Doctrine\Common\EventArgs +class ManagerEventArgs extends EventArgs { /** * @var ObjectManager @@ -48,7 +48,7 @@ class ManagerEventArgs extends \Doctrine\Common\EventArgs } /** - * Retrieve associated ObjectManager. + * Retrieves the associated ObjectManager. * * @return ObjectManager */ diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php old mode 100755 new mode 100644 index 18b655411c..b78bad9920 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php @@ -19,16 +19,18 @@ namespace Doctrine\Common\Persistence\Event; +use Doctrine\Common\EventArgs; +use Doctrine\Common\Persistence\ObjectManager; + /** * Provides event arguments for the onClear event. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Roman Borschel - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.2 + * @author Roman Borschel + * @author Benjamin Eberlei */ -class OnClearEventArgs extends \Doctrine\Common\EventArgs +class OnClearEventArgs extends EventArgs { /** * @var \Doctrine\Common\Persistence\ObjectManager @@ -36,15 +38,15 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs private $objectManager; /** - * @var string + * @var string|null */ private $entityClass; /** * Constructor. * - * @param \Doctrine\Common\Persistence\ObjectManager $objectManager - * @param string $entityClass Optional entity class + * @param ObjectManager $objectManager The object manager. + * @param string|null $entityClass The optional entity class. */ public function __construct($objectManager, $entityClass = null) { @@ -53,7 +55,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs } /** - * Retrieve associated ObjectManager. + * Retrieves the associated ObjectManager. * * @return \Doctrine\Common\Persistence\ObjectManager */ @@ -63,9 +65,9 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs } /** - * Name of the entity class that is cleared, or empty if all are cleared. + * Returns the name of the entity class that is cleared, or null if all are cleared. * - * @return string + * @return string|null */ public function getEntityClass() { @@ -73,7 +75,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs } /** - * Check if event clears all entities. + * Returns whether this event clears all entities. * * @return bool */ diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php old mode 100755 new mode 100644 index 86ac8193f8..d34de841e4 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php @@ -19,8 +19,8 @@ namespace Doctrine\Common\Persistence\Event; -use Doctrine\Common\EventArgs, - Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Common\EventArgs; +use Doctrine\Common\Persistence\ObjectManager; /** * Class that holds event arguments for a preUpdate event. @@ -40,9 +40,9 @@ class PreUpdateEventArgs extends LifecycleEventArgs /** * Constructor. * - * @param object $entity + * @param object $entity * @param ObjectManager $objectManager - * @param array $changeSet + * @param array $changeSet */ public function __construct($entity, ObjectManager $objectManager, array &$changeSet) { @@ -52,7 +52,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Retrieve entity changeset. + * Retrieves the entity changeset. * * @return array */ @@ -62,7 +62,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Check if field has a changeset. + * Checks if field has a changeset. * * @param string $field * @@ -74,9 +74,10 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Get the old value of the changeset of the changed field. + * Gets the old value of the changeset of the changed field. + * + * @param string $field * - * @param string $field * @return mixed */ public function getOldValue($field) @@ -87,9 +88,10 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Get the new value of the changeset of the changed field. + * Gets the new value of the changeset of the changed field. + * + * @param string $field * - * @param string $field * @return mixed */ public function getNewValue($field) @@ -100,10 +102,12 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Set the new value of this field. + * Sets the new value of this field. * * @param string $field - * @param mixed $value + * @param mixed $value + * + * @return void */ public function setNewValue($field, $value) { @@ -113,10 +117,12 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Assert the field exists in changeset. + * Asserts the field exists in changeset. * * @param string $field * + * @return void + * * @throws \InvalidArgumentException */ private function assertValidField($field) @@ -130,4 +136,3 @@ class PreUpdateEventArgs extends LifecycleEventArgs } } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php old mode 100755 new mode 100644 index bdb23bd290..fce854b62c --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php @@ -22,37 +22,36 @@ namespace Doctrine\Common\Persistence; /** * Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Fabien Potencier - * @author Benjamin Eberlei - * @author Lukas Kahwe Smith + * @link www.doctrine-project.org + * @since 2.2 + * @author Fabien Potencier + * @author Benjamin Eberlei + * @author Lukas Kahwe Smith */ interface ManagerRegistry extends ConnectionRegistry { /** * Gets the default object manager name. * - * @return string The default object manager name + * @return string The default object manager name. */ - function getDefaultManagerName(); + public function getDefaultManagerName(); /** * Gets a named object manager. * - * @param string $name The object manager name (null for the default one) + * @param string $name The object manager name (null for the default one). * * @return \Doctrine\Common\Persistence\ObjectManager */ - function getManager($name = null); + public function getManager($name = null); /** - * Gets an array of all registered object managers + * Gets an array of all registered object managers. * * @return \Doctrine\Common\Persistence\ObjectManager[] An array of ObjectManager instances */ - function getManagers(); + public function getManagers(); /** * Resets a named object manager. @@ -67,46 +66,46 @@ interface ManagerRegistry extends ConnectionRegistry * hold an obsolete reference. You can inject the registry instead * to avoid this problem. * - * @param string $name The object manager name (null for the default one) + * @param string|null $name The object manager name (null for the default one). * * @return \Doctrine\Common\Persistence\ObjectManager */ - function resetManager($name = null); + public function resetManager($name = null); /** * Resolves a registered namespace alias to the full namespace. * * This method looks for the alias in all registered object managers. * - * @param string $alias The alias + * @param string $alias The alias. * - * @return string The full namespace + * @return string The full namespace. */ - function getAliasNamespace($alias); + public function getAliasNamespace($alias); /** * Gets all connection names. * - * @return array An array of connection names + * @return array An array of connection names. */ - function getManagerNames(); + public function getManagerNames(); /** * Gets the ObjectRepository for an persistent object. * - * @param string $persistentObject The name of the persistent object. - * @param string $persistentManagerName The object manager name (null for the default one) + * @param string $persistentObject The name of the persistent object. + * @param string $persistentManagerName The object manager name (null for the default one). * * @return \Doctrine\Common\Persistence\ObjectRepository */ - function getRepository($persistentObject, $persistentManagerName = null); + public function getRepository($persistentObject, $persistentManagerName = null); /** * Gets the object manager associated with a given class. * - * @param string $class A persistent object class name + * @param string $class A persistent object class name. * * @return \Doctrine\Common\Persistence\ObjectManager|null */ - function getManagerForClass($class); + public function getManagerForClass($class); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php old mode 100755 new mode 100644 index 1ace1ccb60..01ad58fd04 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php @@ -19,21 +19,21 @@ namespace Doctrine\Common\Persistence\Mapping; -use Doctrine\Common\Cache\Cache, - Doctrine\Common\Util\ClassUtils; +use Doctrine\Common\Cache\Cache; +use Doctrine\Common\Util\ClassUtils; /** * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the * metadata mapping informations of a class which describes how a class should be mapped * to a relational database. * - * This class was abstracted from the ORM ClassMetadataFactory + * This class was abstracted from the ORM ClassMetadataFactory. * - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory { @@ -42,10 +42,10 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory * * @var string */ - protected $cacheSalt = "\$CLASSMETADATA"; + protected $cacheSalt = '$CLASSMETADATA'; /** - * @var \Doctrine\Common\Cache\Cache + * @var \Doctrine\Common\Cache\Cache|null */ private $cacheDriver; @@ -60,14 +60,16 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory protected $initialized = false; /** - * @var ReflectionService + * @var ReflectionService|null */ - private $reflectionService; + private $reflectionService = null; /** * Sets the cache driver used by the factory to cache ClassMetadata instances. * - * @param Doctrine\Common\Cache\Cache $cacheDriver + * @param \Doctrine\Common\Cache\Cache $cacheDriver + * + * @return void */ public function setCacheDriver(Cache $cacheDriver = null) { @@ -77,7 +79,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory /** * Gets the cache driver used by the factory to cache ClassMetadata instances. * - * @return Doctrine\Common\Cache\Cache + * @return \Doctrine\Common\Cache\Cache|null */ public function getCacheDriver() { @@ -85,7 +87,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory } /** - * Return an array of all the loaded metadata currently in memory. + * Returns an array of all the loaded metadata currently in memory. * * @return array */ @@ -124,35 +126,38 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory abstract protected function initialize(); /** - * Get the fully qualified class-name from the namespace alias. + * Gets the fully qualified class-name from the namespace alias. * * @param string $namespaceAlias * @param string $simpleClassName + * * @return string */ abstract protected function getFqcnFromAlias($namespaceAlias, $simpleClassName); /** - * Return the mapping driver implementation. + * Returns the mapping driver implementation. * * @return \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver */ abstract protected function getDriver(); /** - * Wakeup reflection after ClassMetadata gets unserialized from cache. + * Wakes up reflection after ClassMetadata gets unserialized from cache. * - * @param ClassMetadata $class + * @param ClassMetadata $class * @param ReflectionService $reflService + * * @return void */ abstract protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService); /** - * Initialize Reflection after ClassMetadata was constructed. + * Initializes Reflection after ClassMetadata was constructed. * - * @param ClassMetadata $class + * @param ClassMetadata $class * @param ReflectionService $reflService + * * @return void */ abstract protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService); @@ -160,10 +165,10 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory /** * Checks whether the class metadata is an entity. * - * This method should false for mapped superclasses or - * embedded classes. + * This method should return false for mapped superclasses or embedded classes. * * @param ClassMetadata $class + * * @return boolean */ abstract protected function isEntity(ClassMetadata $class); @@ -172,6 +177,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory * Gets the class metadata descriptor for a class. * * @param string $className The name of the class. + * * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata */ public function getMetadataFor($className) @@ -224,6 +230,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory * Checks whether the factory has the metadata for a class loaded already. * * @param string $className + * * @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise. */ public function hasMetadataFor($className) @@ -236,8 +243,10 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory * * NOTE: This is only useful in very special cases, like when generating proxy classes. * - * @param string $className + * @param string $className * @param ClassMetadata $class + * + * @return void */ public function setMetadataFor($className, $class) { @@ -245,10 +254,11 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory } /** - * Get array of parent classes for the given entity class + * Gets an array of parent classes for the given entity class. * * @param string $name - * @return array $parentClasses + * + * @return array */ protected function getParentClasses($name) { @@ -266,6 +276,12 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory * Loads the metadata of the class in question and all it's ancestors whose metadata * is still not loaded. * + * Important: The class $name does not necesarily exist at this point here. + * Scenarios in a code-generation setup might have access to XML/YAML + * Mapping files without the actual PHP code existing here. That is why the + * {@see Doctrine\Common\Persistence\Mapping\ReflectionService} interface + * should be used for reflection. + * * @param string $name The name of the class for which the metadata should get loaded. * * @return array @@ -319,12 +335,14 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory } /** - * Actually load the metadata from the underlying metadata + * Actually loads the metadata from the underlying metadata. * - * @param ClassMetadata $class + * @param ClassMetadata $class * @param ClassMetadata|null $parent - * @param bool $rootEntityFound - * @param array $nonSuperclassParents classnames all parent classes that are not marked as mapped superclasses + * @param bool $rootEntityFound + * @param array $nonSuperclassParents All parent class names + * that are not marked as mapped superclasses. + * * @return void */ abstract protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents); @@ -333,15 +351,13 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory * Creates a new ClassMetadata instance for the given class name. * * @param string $className + * * @return ClassMetadata */ abstract protected function newClassMetadataInstance($className); /** - * Check if this class is mapped by this Object Manager + ClassMetadata configuration - * - * @param $class - * @return bool + * {@inheritDoc} */ public function isTransient($class) { @@ -359,9 +375,11 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory } /** - * Set reflectionService. + * Sets the reflectionService. * * @param ReflectionService $reflectionService + * + * @return void */ public function setReflectionService(ReflectionService $reflectionService) { @@ -369,7 +387,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory } /** - * Get the reflection service associated with this metadata factory. + * Gets the reflection service associated with this metadata factory. * * @return ReflectionService */ diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php old mode 100755 new mode 100644 index 4836bf8723..b8445f1b9f --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php @@ -22,20 +22,19 @@ namespace Doctrine\Common\Persistence\Mapping; /** * Contract for a Doctrine persistence layer ClassMetadata class to implement. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Benjamin Eberlei - * @author Jonathan Wage + * @link www.doctrine-project.org + * @since 2.1 + * @author Benjamin Eberlei + * @author Jonathan Wage */ interface ClassMetadata { /** - * Get fully-qualified class name of this persistent class. + * Gets the fully-qualified class name of this persistent class. * * @return string */ - function getName(); + public function getName(); /** * Gets the mapped identifier field name. @@ -44,54 +43,59 @@ interface ClassMetadata * * @return array */ - function getIdentifier(); + public function getIdentifier(); /** * Gets the ReflectionClass instance for this mapped class. * * @return \ReflectionClass */ - function getReflectionClass(); + public function getReflectionClass(); /** * Checks if the given field name is a mapped identifier for this class. * * @param string $fieldName + * * @return boolean */ - function isIdentifier($fieldName); + public function isIdentifier($fieldName); /** * Checks if the given field is a mapped property for this class. * * @param string $fieldName + * * @return boolean */ - function hasField($fieldName); + public function hasField($fieldName); /** * Checks if the given field is a mapped association for this class. * * @param string $fieldName + * * @return boolean */ - function hasAssociation($fieldName); + public function hasAssociation($fieldName); /** * Checks if the given field is a mapped single valued association for this class. * * @param string $fieldName + * * @return boolean */ - function isSingleValuedAssociation($fieldName); + public function isSingleValuedAssociation($fieldName); /** * Checks if the given field is a mapped collection valued association for this class. * * @param string $fieldName + * * @return boolean */ - function isCollectionValuedAssociation($fieldName); + public function isCollectionValuedAssociation($fieldName); /** * A numerically indexed list of field names of this persistent class. @@ -100,23 +104,23 @@ interface ClassMetadata * * @return array */ - function getFieldNames(); + public function getFieldNames(); /** * Returns an array of identifier field names numerically indexed. * * @return array */ - function getIdentifierFieldNames(); + public function getIdentifierFieldNames(); /** - * A numerically indexed list of association names of this persistent class. + * Returns a numerically indexed list of association names of this persistent class. * * This array includes identifier associations if present on this class. * * @return array */ - function getAssociationNames(); + public function getAssociationNames(); /** * Returns a type name of this field. @@ -125,41 +129,46 @@ interface ClassMetadata * integer, string, boolean, float/double, datetime. * * @param string $fieldName + * * @return string */ - function getTypeOfField($fieldName); + public function getTypeOfField($fieldName); /** * Returns the target class name of the given association. * * @param string $assocName + * * @return string */ - function getAssociationTargetClass($assocName); + public function getAssociationTargetClass($assocName); /** - * Checks if the association is the inverse side of a bidirectional association + * Checks if the association is the inverse side of a bidirectional association. * * @param string $assocName + * * @return boolean */ - function isAssociationInverseSide($assocName); + public function isAssociationInverseSide($assocName); /** - * Returns the target field of the owning side of the association + * Returns the target field of the owning side of the association. * * @param string $assocName + * * @return string */ - function getAssociationMappedByTargetField($assocName); + public function getAssociationMappedByTargetField($assocName); /** - * Return the identifier of this object as an array with field name as key. + * Returns the identifier of this object as an array with field name as key. * * Has to return an empty array if no identifier isset. * * @param object $object + * * @return array */ - function getIdentifierValues($object); + public function getIdentifierValues($object); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php old mode 100755 new mode 100644 index 3fa39bcb3d..3d82881195 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php @@ -22,11 +22,10 @@ namespace Doctrine\Common\Persistence\Mapping; /** * Contract for a Doctrine persistence layer ClassMetadata class to implement. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Benjamin Eberlei - * @author Jonathan Wage + * @link www.doctrine-project.org + * @since 2.1 + * @author Benjamin Eberlei + * @author Jonathan Wage */ interface ClassMetadataFactory { @@ -36,39 +35,42 @@ interface ClassMetadataFactory * * @return array The ClassMetadata instances of all mapped classes. */ - function getAllMetadata(); + public function getAllMetadata(); /** * Gets the class metadata descriptor for a class. * * @param string $className The name of the class. + * * @return ClassMetadata */ - function getMetadataFor($className); + public function getMetadataFor($className); /** * Checks whether the factory has the metadata for a class loaded already. * * @param string $className + * * @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise. */ - function hasMetadataFor($className); + public function hasMetadataFor($className); /** * Sets the metadata descriptor for a specific class. * * @param string $className + * * @param ClassMetadata $class */ - function setMetadataFor($className, $class); + public function setMetadataFor($className, $class); /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped directly or as a - * MappedSuperclass. + * Returns whether the class with the specified name should have its metadata loaded. + * This is only the case if it is either mapped directly or as a MappedSuperclass. * * @param string $className + * * @return boolean */ - function isTransient($className); + public function isTransient($className); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php old mode 100755 new mode 100644 index 1131add5a0..1737243253 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php @@ -19,15 +19,14 @@ namespace Doctrine\Common\Persistence\Mapping\Driver; -use Doctrine\Common\Cache\ArrayCache, - Doctrine\Common\Annotations\AnnotationReader, - Doctrine\Common\Annotations\AnnotationRegistry, - Doctrine\Common\Persistence\Mapping\MappingException; +use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Annotations\AnnotationRegistry; +use Doctrine\Common\Persistence\Mapping\MappingException; /** * The AnnotationDriver reads the mapping metadata from docblock annotations. * - * @since 2.2 + * @since 2.2 * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan H. Wage @@ -57,14 +56,14 @@ abstract class AnnotationDriver implements MappingDriver protected $fileExtension = '.php'; /** - * Cache for AnnotationDriver#getAllClassNames() + * Cache for AnnotationDriver#getAllClassNames(). * - * @var array + * @var array|null */ protected $classNames; /** - * Name of the entity annotations as keys + * Name of the entity annotations as keys. * * @var array */ @@ -74,8 +73,8 @@ abstract class AnnotationDriver implements MappingDriver * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading * docblock annotations. * - * @param AnnotationReader $reader The AnnotationReader to use, duck-typed. - * @param string|array $paths One or multiple paths where mapping classes can be found. + * @param AnnotationReader $reader The AnnotationReader to use, duck-typed. + * @param string|array|null $paths One or multiple paths where mapping classes can be found. */ public function __construct($reader, $paths = null) { @@ -86,9 +85,11 @@ abstract class AnnotationDriver implements MappingDriver } /** - * Append lookup paths to metadata driver. + * Appends lookup paths to metadata driver. * * @param array $paths + * + * @return void */ public function addPaths(array $paths) { @@ -96,7 +97,7 @@ abstract class AnnotationDriver implements MappingDriver } /** - * Retrieve the defined metadata lookup paths. + * Retrieves the defined metadata lookup paths. * * @return array */ @@ -106,7 +107,7 @@ abstract class AnnotationDriver implements MappingDriver } /** - * Retrieve the current annotation reader + * Retrieves the current annotation reader. * * @return AnnotationReader */ @@ -116,7 +117,7 @@ abstract class AnnotationDriver implements MappingDriver } /** - * Get the file extension used to look for mapping files under + * Gets the file extension used to look for mapping files under. * * @return string */ @@ -126,9 +127,10 @@ abstract class AnnotationDriver implements MappingDriver } /** - * Set the file extension used to look for mapping files under + * Sets the file extension used to look for mapping files under. + * + * @param string $fileExtension The file extension to set. * - * @param string $fileExtension The file extension to set * @return void */ public function setFileExtension($fileExtension) @@ -137,13 +139,14 @@ abstract class AnnotationDriver implements MappingDriver } /** - * Whether the class with the specified name is transient. Only non-transient + * Returns whether the class with the specified name is transient. Only non-transient * classes, that is entities and mapped superclasses, should have their metadata loaded. * * A class is non-transient if it is annotated with an annotation * from the {@see AnnotationDriver::entityAnnotationClasses}. * * @param string $className + * * @return boolean */ public function isTransient($className) @@ -184,7 +187,7 @@ abstract class AnnotationDriver implements MappingDriver new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY ), - '/^.+' . str_replace('.', '\.', $this->fileExtension) . '$/i', + '/^.+' . preg_quote($this->fileExtension) . '$/i', \RecursiveRegexIterator::GET_MATCH ); diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php old mode 100755 new mode 100644 index ddd724cf0f..6a9e27647c --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php @@ -15,16 +15,16 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\Common\Persistence\Mapping\Driver; use Doctrine\Common\Persistence\Mapping\MappingException; /** - * Locate the file that contains the metadata information for a given class name. + * Locates the file that contains the metadata information for a given class name. * - * This behavior is inpependent of the actual content of the file. It just detects + * This behavior is independent of the actual content of the file. It just detects * the file which is responsible for the given class name. * * @author Benjamin Eberlei @@ -42,7 +42,7 @@ class DefaultFileLocator implements FileLocator /** * The file extension of mapping documents. * - * @var string + * @var string|null */ protected $fileExtension; @@ -50,8 +50,8 @@ class DefaultFileLocator implements FileLocator * Initializes a new FileDriver that looks in the given path(s) for mapping * documents and operates in the specified operating mode. * - * @param string|array $paths One or multiple paths where mapping documents can be found. - * @param string|null $fileExtension + * @param string|array $paths One or multiple paths where mapping documents can be found. + * @param string|null $fileExtension The file extension of mapping documents. */ public function __construct($paths, $fileExtension = null) { @@ -60,9 +60,11 @@ class DefaultFileLocator implements FileLocator } /** - * Append lookup paths to metadata driver. + * Appends lookup paths to metadata driver. * * @param array $paths + * + * @return void */ public function addPaths(array $paths) { @@ -70,7 +72,7 @@ class DefaultFileLocator implements FileLocator } /** - * Retrieve the defined metadata lookup paths. + * Retrieves the defined metadata lookup paths. * * @return array */ @@ -80,9 +82,9 @@ class DefaultFileLocator implements FileLocator } /** - * Get the file extension used to look for mapping files under + * Gets the file extension used to look for mapping files under. * - * @return string + * @return string|null */ public function getFileExtension() { @@ -90,9 +92,10 @@ class DefaultFileLocator implements FileLocator } /** - * Set the file extension used to look for mapping files under + * Sets the file extension used to look for mapping files under. + * + * @param string|null $fileExtension The file extension to set. * - * @param string $fileExtension The file extension to set * @return void */ public function setFileExtension($fileExtension) @@ -104,12 +107,12 @@ class DefaultFileLocator implements FileLocator * {@inheritDoc} */ public function findMappingFile($className) - { + { $fileName = str_replace('\\', '.', $className) . $this->fileExtension; // Check whether file exists foreach ($this->paths as $path) { - if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { + if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) { return $path . DIRECTORY_SEPARATOR . $fileName; } } @@ -160,7 +163,7 @@ class DefaultFileLocator implements FileLocator // Check whether file exists foreach ((array) $this->paths as $path) { - if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { + if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) { return true; } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php old mode 100755 new mode 100644 index b0a7685c8e..ccc64faf8c --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php @@ -29,13 +29,12 @@ use Doctrine\Common\Persistence\Mapping\MappingException; * file per class and the file names of the mapping files must correspond to the full * class name, including namespace, with the namespace delimiters '\', replaced by dots '.'. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan H. Wage + * @author Roman Borschel */ abstract class FileDriver implements MappingDriver { @@ -45,12 +44,12 @@ abstract class FileDriver implements MappingDriver protected $locator; /** - * @var array + * @var array|null */ protected $classCache; /** - * @var string + * @var string|null */ protected $globalBasename; @@ -58,8 +57,9 @@ abstract class FileDriver implements MappingDriver * Initializes a new FileDriver that looks in the given path(s) for mapping * documents and operates in the specified operating mode. * - * @param string|array|FileLocator $locator A FileLocator or one/multiple paths where mapping documents can be found. - * @param string $fileExtension + * @param string|array|FileLocator $locator A FileLocator or one/multiple paths + * where mapping documents can be found. + * @param string|null $fileExtension */ public function __construct($locator, $fileExtension = null) { @@ -71,9 +71,11 @@ abstract class FileDriver implements MappingDriver } /** - * Set global basename + * Sets the global basename. * * @param string $file + * + * @return void */ public function setGlobalBasename($file) { @@ -81,9 +83,9 @@ abstract class FileDriver implements MappingDriver } /** - * Retrieve global basename + * Retrieves the global basename. * - * @return string + * @return string|null */ public function getGlobalBasename() { @@ -91,13 +93,14 @@ abstract class FileDriver implements MappingDriver } /** - * Get the element of schema meta data for the class from the mapping file. - * This will lazily load the mapping file if it is not loaded yet + * Gets the element of schema meta data for the class from the mapping file. + * This will lazily load the mapping file if it is not loaded yet. * * @param string $className * + * @return array The element of schema meta data. + * * @throws MappingException - * @return array The element of schema meta data */ public function getElement($className) { @@ -118,12 +121,7 @@ abstract class FileDriver implements MappingDriver } /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped as an Entity or a - * MappedSuperclass. - * - * @param string $className - * @return boolean + * {@inheritDoc} */ public function isTransient($className) { @@ -139,9 +137,7 @@ abstract class FileDriver implements MappingDriver } /** - * Gets the names of all mapped classes known to this driver. - * - * @return array The names of all mapped classes known to this driver. + * {@inheritDoc} */ public function getAllClassNames() { @@ -161,12 +157,13 @@ abstract class FileDriver implements MappingDriver * from class/entity names to their corresponding file driver elements. * * @param string $file The mapping file to load. + * * @return array */ abstract protected function loadMappingFile($file); /** - * Initialize the class cache from all the global files. + * Initializes the class cache from all the global files. * * Using this feature adds a substantial performance hit to file drivers as * more metadata has to be loaded into memory than might actually be @@ -193,7 +190,7 @@ abstract class FileDriver implements MappingDriver } /** - * Retrieve the locator used to discover mapping files by className + * Retrieves the locator used to discover mapping files by className. * * @return FileLocator */ @@ -203,7 +200,7 @@ abstract class FileDriver implements MappingDriver } /** - * Set the locator used to discover mapping files by className + * Sets the locator used to discover mapping files by className. * * @param FileLocator $locator */ diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php old mode 100755 new mode 100644 index ec2b60652f..f622856da8 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php @@ -15,12 +15,12 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\Common\Persistence\Mapping\Driver; /** - * Locate the file that contains the metadata information for a given class name. + * Locates the file that contains the metadata information for a given class name. * * This behavior is independent of the actual content of the file. It just detects * the file which is responsible for the given class name. @@ -31,41 +31,43 @@ namespace Doctrine\Common\Persistence\Mapping\Driver; interface FileLocator { /** - * Locate mapping file for the given class name. + * Locates mapping file for the given class name. * * @param string $className + * * @return string */ - function findMappingFile($className); + public function findMappingFile($className); /** - * Get all class names that are found with this file locator. + * Gets all class names that are found with this file locator. + * + * @param string $globalBasename Passed to allow excluding the basename. * - * @param string $globalBasename Passed to allow excluding the basename * @return array */ - function getAllClassNames($globalBasename); + public function getAllClassNames($globalBasename); /** - * Check if a file can be found for this class name. + * Checks if a file can be found for this class name. * * @param string $className * * @return bool */ - function fileExists($className); + public function fileExists($className); /** - * Get all the paths that this file locator looks for mapping files. + * Gets all the paths that this file locator looks for mapping files. * * @return array */ - function getPaths(); + public function getPaths(); /** - * Get the file extension that mapping files are suffixed with. + * Gets the file extension that mapping files are suffixed with. * * @return string */ - function getFileExtension(); + public function getFileExtension(); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php old mode 100755 new mode 100644 index 955d831dcf..b5d7ec03a1 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php @@ -24,7 +24,7 @@ use Doctrine\Common\Persistence\Mapping\ClassMetadata; /** * Contract for metadata drivers. * - * @since 2.2 + * @since 2.2 * @author Jonathan H. Wage */ interface MappingDriver @@ -32,25 +32,27 @@ interface MappingDriver /** * Loads the metadata for the specified class into the provided container. * - * @param string $className + * @param string $className * @param ClassMetadata $metadata + * + * @return void */ - function loadMetadataForClass($className, ClassMetadata $metadata); + public function loadMetadataForClass($className, ClassMetadata $metadata); /** * Gets the names of all mapped classes known to this driver. * * @return array The names of all mapped classes known to this driver. */ - function getAllClassNames(); + public function getAllClassNames(); /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped as an Entity or a - * MappedSuperclass. + * Returns whether the class with the specified name should have its metadata loaded. + * This is only the case if it is either mapped as an Entity or a MappedSuperclass. * * @param string $className + * * @return boolean */ - function isTransient($className); + public function isTransient($className); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php old mode 100755 new mode 100644 index 3b1049dfe2..5fa9a7a801 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php @@ -19,13 +19,13 @@ namespace Doctrine\Common\Persistence\Mapping\Driver; -use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, - Doctrine\Common\Persistence\Mapping\ClassMetadata, - Doctrine\Common\Persistence\Mapping\MappingException; +use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\Mapping\MappingException; /** * The DriverChain allows you to add multiple other mapping drivers for - * certain namespaces + * certain namespaces. * * @since 2.2 * @author Benjamin Eberlei @@ -36,11 +36,11 @@ use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, class MappingDriverChain implements MappingDriver { /** - * The default driver + * The default driver. * - * @var MappingDriver + * @var MappingDriver|null */ - private $defaultDriver; + private $defaultDriver = null; /** * @var array @@ -48,7 +48,7 @@ class MappingDriverChain implements MappingDriver private $drivers = array(); /** - * Get the default driver. + * Gets the default driver. * * @return MappingDriver|null */ @@ -61,6 +61,8 @@ class MappingDriverChain implements MappingDriver * Set the default driver. * * @param MappingDriver $driver + * + * @return void */ public function setDefaultDriver(MappingDriver $driver) { @@ -68,10 +70,12 @@ class MappingDriverChain implements MappingDriver } /** - * Add a nested driver. + * Adds a nested driver. * * @param MappingDriver $nestedDriver - * @param string $namespace + * @param string $namespace + * + * @return void */ public function addDriver(MappingDriver $nestedDriver, $namespace) { @@ -79,7 +83,7 @@ class MappingDriverChain implements MappingDriver } /** - * Get the array of nested drivers. + * Gets the array of nested drivers. * * @return array $drivers */ @@ -89,12 +93,7 @@ class MappingDriverChain implements MappingDriver } /** - * Loads the metadata for the specified class into the provided container. - * - * @param string $className - * @param ClassMetadata $metadata - * - * @throws MappingException + * {@inheritDoc} */ public function loadMetadataForClass($className, ClassMetadata $metadata) { @@ -115,9 +114,7 @@ class MappingDriverChain implements MappingDriver } /** - * Gets the names of all mapped classes known to this driver. - * - * @return array The names of all mapped classes known to this driver. + * {@inheritDoc} */ public function getAllClassNames() { @@ -139,16 +136,17 @@ class MappingDriverChain implements MappingDriver } } + if (null !== $this->defaultDriver) { + foreach ($this->defaultDriver->getAllClassNames() as $className) { + $classNames[$className] = true; + } + } + return array_keys($classNames); } /** - * Whether the class with the specified name should have its metadata loaded. - * - * This is only the case for non-transient classes either mapped as an Entity or MappedSuperclass. - * - * @param string $className - * @return boolean + * {@inheritDoc} */ public function isTransient($className) { diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php old mode 100755 new mode 100644 index 68ab34dd47..31651f3ea6 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php @@ -23,21 +23,19 @@ use Doctrine\Common\Persistence\Mapping\ClassMetadata; /** * The PHPDriver includes php files which just populate ClassMetadataInfo - * instances with plain php code + * instances with plain PHP code. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan H. Wage + * @author Roman Borschel */ class PHPDriver extends FileDriver { /** - * {@inheritdoc} + * {@inheritDoc} */ protected $metadata; @@ -51,7 +49,7 @@ class PHPDriver extends FileDriver } /** - * {@inheritdoc} + * {@inheritDoc} */ public function loadMetadataForClass($className, ClassMetadata $metadata) { @@ -60,9 +58,9 @@ class PHPDriver extends FileDriver } /** - * {@inheritdoc} + * {@inheritDoc} */ - protected function loadMappingFile($file) + protected function loadMappingFile($file) { $metadata = $this->metadata; include $file; diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php old mode 100755 new mode 100644 index e3cea73000..df8f47700b --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php @@ -26,13 +26,12 @@ use Doctrine\Common\Persistence\Mapping\MappingException; * The StaticPHPDriver calls a static loadMetadata() method on your entity * classes where you can manually populate the ClassMetadata instance. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan H. Wage + * @author Roman Borschel */ class StaticPHPDriver implements MappingDriver { @@ -51,7 +50,7 @@ class StaticPHPDriver implements MappingDriver private $classNames; /** - * Constructor + * Constructor. * * @param array|string $paths */ @@ -61,9 +60,11 @@ class StaticPHPDriver implements MappingDriver } /** - * Add paths + * Adds paths. * * @param array $paths + * + * @return void */ public function addPaths(array $paths) { diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php old mode 100755 new mode 100644 index 9095187d27..dd4d741507 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\Common\Persistence\Mapping\Driver; @@ -26,8 +26,8 @@ use Doctrine\Common\Persistence\Mapping\MappingException; * to the DefaultFileLocator. By assuming paths only contain entities of a certain * namespace the mapping files consists of the short classname only. * - * @author Fabien Potencier - * @author Benjamin Eberlei + * @author Fabien Potencier + * @author Benjamin Eberlei * @license MIT */ class SymfonyFileLocator implements FileLocator @@ -49,14 +49,14 @@ class SymfonyFileLocator implements FileLocator /** * File extension that is searched for. * - * @var string + * @var string|null */ protected $fileExtension; /** - * Constructor + * Constructor. * - * @param array $prefixes + * @param array $prefixes * @param string|null $fileExtension */ public function __construct(array $prefixes, $fileExtension = null) @@ -66,9 +66,11 @@ class SymfonyFileLocator implements FileLocator } /** - * Add Namespace Prefixes + * Adds Namespace Prefixes. * * @param array $prefixes + * + * @return void */ public function addNamespacePrefixes(array $prefixes) { @@ -77,7 +79,7 @@ class SymfonyFileLocator implements FileLocator } /** - * Get Namespace Prefixes + * Gets Namespace Prefixes. * * @return array */ @@ -103,9 +105,10 @@ class SymfonyFileLocator implements FileLocator } /** - * Set the file extension used to look for mapping files under + * Sets the file extension used to look for mapping files under. + * + * @param string $fileExtension The file extension to set. * - * @param string $fileExtension The file extension to set * @return void */ public function setFileExtension($fileExtension) diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php old mode 100755 new mode 100644 index c1e7ad5740..c8c32b2900 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php @@ -14,7 +14,7 @@ * * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see - * . + * . */ namespace Doctrine\Common\Persistence\Mapping; @@ -27,9 +27,8 @@ namespace Doctrine\Common\Persistence\Mapping; class MappingException extends \Exception { /** - * * @param string $className - * @param array $namespaces + * @param array $namespaces * * @return MappingException */ @@ -50,6 +49,7 @@ class MappingException extends \Exception /** * @param string|null $path + * * @return MappingException */ public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null) @@ -67,6 +67,7 @@ class MappingException extends \Exception /** * @param string $entityName * @param string $fileName + * * @return MappingException */ public static function mappingFileNotFound($entityName, $fileName) @@ -77,10 +78,21 @@ class MappingException extends \Exception /** * @param string $entityName * @param string $fileName + * * @return MappingException */ public static function invalidMappingFile($entityName, $fileName) { return new self("Invalid mapping file '$fileName' for class '$entityName'."); } + + /** + * @param string $className + * + * @return \Doctrine\Common\Persistence\Mapping\MappingException + */ + public static function nonExistingClass($className) + { + return new self("Class '$className' does not exist"); + } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php old mode 100755 new mode 100644 index 3db85d9fff..0088ed5ee2 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php @@ -30,51 +30,58 @@ namespace Doctrine\Common\Persistence\Mapping; interface ReflectionService { /** - * Return an array of the parent classes (not interfaces) for the given class. + * Returns an array of the parent classes (not interfaces) for the given class. * * @param string $class + * + * @throws \Doctrine\Common\Persistence\Mapping\MappingException + * * @return array */ - function getParentClasses($class); + public function getParentClasses($class); /** - * Return the shortname of a class. + * Returns the shortname of a class. * * @param string $class + * * @return string */ - function getClassShortName($class); + public function getClassShortName($class); /** * @param string $class + * * @return string */ - function getClassNamespace($class); + public function getClassNamespace($class); /** - * Return a reflection class instance or null + * Returns a reflection class instance or null. * * @param string $class + * * @return \ReflectionClass|null */ - function getClass($class); + public function getClass($class); /** - * Return an accessible property (setAccessible(true)) or null. + * Returns an accessible property (setAccessible(true)) or null. * * @param string $class * @param string $property + * * @return \ReflectionProperty|null */ - function getAccessibleProperty($class, $property); + public function getAccessibleProperty($class, $property); /** - * Check if the class have a public method with the given name. + * Checks if the class have a public method with the given name. * * @param mixed $class * @param mixed $method + * * @return bool */ - function hasPublicMethod($class, $method); + public function hasPublicMethod($class, $method); } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php old mode 100755 new mode 100644 index 77b9e76062..c5a37a897b --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php @@ -21,52 +21,50 @@ namespace Doctrine\Common\Persistence\Mapping; use ReflectionClass; use ReflectionProperty; +use Doctrine\Common\Reflection\RuntimePublicReflectionProperty; +use Doctrine\Common\Persistence\Mapping\MappingException; /** - * PHP Runtime Reflection Service + * PHP Runtime Reflection Service. * * @author Benjamin Eberlei */ class RuntimeReflectionService implements ReflectionService { /** - * Return an array of the parent classes (not interfaces) for the given class. - * - * @param string $class - * @return array + * {@inheritDoc} */ public function getParentClasses($class) { + if ( ! class_exists($class)) { + throw MappingException::nonExistingClass($class); + } + return class_parents($class); } /** - * Return the shortname of a class. - * - * @param string $class - * @return string + * {@inheritDoc} */ public function getClassShortName($class) { - $r = new ReflectionClass($class); - return $r->getShortName(); + $reflectionClass = new ReflectionClass($class); + + return $reflectionClass->getShortName(); } /** - * @param string $class - * @return string + * {@inheritDoc} */ public function getClassNamespace($class) { - $r = new ReflectionClass($class); - return $r->getNamespaceName(); + $reflectionClass = new ReflectionClass($class); + + return $reflectionClass->getNamespaceName(); } /** - * Return a reflection class instance or null - * - * @param string $class - * @return ReflectionClass|null + * {@inheritDoc} */ public function getClass($class) { @@ -74,29 +72,26 @@ class RuntimeReflectionService implements ReflectionService } /** - * Return an accessible property (setAccessible(true)) or null. - * - * @param string $class - * @param string $property - * @return ReflectionProperty|null + * {@inheritDoc} */ public function getAccessibleProperty($class, $property) { - $property = new ReflectionProperty($class, $property); - $property->setAccessible(true); - return $property; + $reflectionProperty = new ReflectionProperty($class, $property); + + if ($reflectionProperty->isPublic()) { + $reflectionProperty = new RuntimePublicReflectionProperty($class, $property); + } + + $reflectionProperty->setAccessible(true); + + return $reflectionProperty; } /** - * Check if the class have a public method with the given name. - * - * @param mixed $class - * @param mixed $method - * @return bool + * {@inheritDoc} */ public function hasPublicMethod($class, $method) { return method_exists($class, $method) && is_callable(array($class, $method)); } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php old mode 100755 new mode 100644 index 4f6d1cfad4..f903097e79 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php @@ -19,21 +19,15 @@ namespace Doctrine\Common\Persistence\Mapping; -use ReflectionClass; -use ReflectionProperty; - /** - * PHP Runtime Reflection Service + * PHP Runtime Reflection Service. * * @author Benjamin Eberlei */ class StaticReflectionService implements ReflectionService { /** - * Return an array of the parent classes (not interfaces) for the given class. - * - * @param string $class - * @return array + * {@inheritDoc} */ public function getParentClasses($class) { @@ -41,10 +35,7 @@ class StaticReflectionService implements ReflectionService } /** - * Return the shortname of a class. - * - * @param string $className - * @return string + * {@inheritDoc} */ public function getClassShortName($className) { @@ -55,10 +46,7 @@ class StaticReflectionService implements ReflectionService } /** - * Return the namespace of a class. - * - * @param string $className - * @return string + * {@inheritDoc} */ public function getClassNamespace($className) { @@ -70,10 +58,7 @@ class StaticReflectionService implements ReflectionService } /** - * Return a reflection class instance or null - * - * @param string $class - * @return ReflectionClass|null + * {@inheritDoc} */ public function getClass($class) { @@ -81,11 +66,7 @@ class StaticReflectionService implements ReflectionService } /** - * Return an accessible property (setAccessible(true)) or null. - * - * @param string $class - * @param string $property - * @return ReflectionProperty|null + * {@inheritDoc} */ public function getAccessibleProperty($class, $property) { @@ -93,15 +74,10 @@ class StaticReflectionService implements ReflectionService } /** - * Check if the class have a public method with the given name. - * - * @param mixed $class - * @param mixed $method - * @return bool + * {@inheritDoc} */ public function hasPublicMethod($class, $method) { return method_exists($class, $method) && is_callable(array($class, $method)); } } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php old mode 100755 new mode 100644 index 2bb8722260..bb29e438e1 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php @@ -22,11 +22,10 @@ namespace Doctrine\Common\Persistence; /** * Contract for a Doctrine persistence layer ObjectManager class to implement. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Benjamin Eberlei - * @author Jonathan Wage + * @link www.doctrine-project.org + * @since 2.1 + * @author Benjamin Eberlei + * @author Jonathan Wage */ interface ObjectManager { @@ -35,11 +34,12 @@ interface ObjectManager * * This is just a convenient shortcut for getRepository($className)->find($id). * - * @param string - * @param mixed - * @return object + * @param string $className The class name of the object to find. + * @param mixed $id The identity of the object to find. + * + * @return object The found object. */ - function find($className, $id); + public function find($className, $id); /** * Tells the ObjectManager to make an instance managed and persistent. @@ -50,8 +50,10 @@ interface ObjectManager * this ObjectManager as NEW. Do not pass detached objects to the persist operation. * * @param object $object The instance to make managed and persistent. + * + * @return void */ - function persist($object); + public function persist($object); /** * Removes an object instance. @@ -59,8 +61,10 @@ interface ObjectManager * A removed object will be removed from the database as a result of the flush operation. * * @param object $object The object instance to remove. + * + * @return void */ - function remove($object); + public function remove($object); /** * Merges the state of a detached object into the persistence context @@ -68,17 +72,20 @@ interface ObjectManager * The object passed to merge will not become associated/managed with this ObjectManager. * * @param object $object + * * @return object */ - function merge($object); + public function merge($object); /** * Clears the ObjectManager. All objects that are currently managed * by this ObjectManager become detached. * - * @param string $objectName if given, only objects of this type will get detached + * @param string|null $objectName if given, only objects of this type will get detached. + * + * @return void */ - function clear($objectName = null); + public function clear($objectName = null); /** * Detaches an object from the ObjectManager, causing a managed object to @@ -88,31 +95,38 @@ interface ObjectManager * reference it. * * @param object $object The object to detach. + * + * @return void */ - function detach($object); + public function detach($object); /** * Refreshes the persistent state of an object from the database, * overriding any local changes that have not yet been persisted. * * @param object $object The object to refresh. + * + * @return void */ - function refresh($object); + public function refresh($object); /** * Flushes all changes to objects that have been queued up to now to the database. * This effectively synchronizes the in-memory state of managed objects with the * database. + * + * @return void */ - function flush(); + public function flush(); /** * Gets the repository for a class. * * @param string $className + * * @return \Doctrine\Common\Persistence\ObjectRepository */ - function getRepository($className); + public function getRepository($className); /** * Returns the ClassMetadata descriptor for a class. @@ -121,16 +135,17 @@ interface ObjectManager * (as it is returned by get_class($obj)). * * @param string $className + * * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata */ - function getClassMetadata($className); + public function getClassMetadata($className); /** * Gets the metadata factory used to gather the metadata of classes. * * @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory */ - function getMetadataFactory(); + public function getMetadataFactory(); /** * Helper method to initialize a lazy loading proxy or persistent collection. @@ -138,15 +153,17 @@ interface ObjectManager * This method is a no-op for other objects. * * @param object $obj + * + * @return void */ - function initializeObject($obj); + public function initializeObject($obj); /** - * Check if the object is part of the current UnitOfWork and therefore - * managed. + * Checks if the object is part of the current UnitOfWork and therefore managed. * * @param object $object + * * @return bool */ - function contains($object); + public function contains($object); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php old mode 100755 new mode 100644 index 69fba78d66..9bc248a56a --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php @@ -26,7 +26,7 @@ use Doctrine\Common\Persistence\Mapping\ClassMetadata; * * Using this interface the managing object manager and class metadata instances * are injected into the persistent object after construction. This allows - * you to implement ActiveRecord functionality on top of the persistance-ignorance + * you to implement ActiveRecord functionality on top of the persistence-ignorance * that Doctrine propagates. * * Word of Warning: This is a very powerful hook to change how you can work with your domain models. @@ -44,6 +44,8 @@ interface ObjectManagerAware * * @param ObjectManager $objectManager * @param ClassMetadata $classMetadata + * + * @return void */ public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerDecorator.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerDecorator.php new file mode 100644 index 0000000000..8946475dba --- /dev/null +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerDecorator.php @@ -0,0 +1,140 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +/** + * Base class to simplify ObjectManager decorators + * + * @license http://opensource.org/licenses/MIT MIT + * @link www.doctrine-project.org + * @since 2.4 + * @author Lars Strojny + */ +abstract class ObjectManagerDecorator implements ObjectManager +{ + /** + * @var ObjectManager + */ + protected $wrapped; + + /** + * {@inheritdoc} + */ + public function find($className, $id) + { + return $this->wrapped->find($className, $id); + } + + /** + * {@inheritdoc} + */ + public function persist($object) + { + return $this->wrapped->persist($object); + } + + /** + * {@inheritdoc} + */ + public function remove($object) + { + return $this->wrapped->remove($object); + } + + /** + * {@inheritdoc} + */ + public function merge($object) + { + return $this->wrapped->merge($object); + } + + /** + * {@inheritdoc} + */ + public function clear($objectName = null) + { + return $this->wrapped->clear($objectName); + } + + /** + * {@inheritdoc} + */ + public function detach($object) + { + return $this->wrapped->detach($object); + } + + /** + * {@inheritdoc} + */ + public function refresh($object) + { + return $this->wrapped->refresh($object); + } + + /** + * {@inheritdoc} + */ + public function flush() + { + return $this->wrapped->flush(); + } + + /** + * {@inheritdoc} + */ + public function getRepository($className) + { + return $this->wrapped->getRepository($className); + } + + /** + * {@inheritdoc} + */ + public function getClassMetadata($className) + { + return $this->wrapped->getClassMetadata($className); + } + + /** + * {@inheritdoc} + */ + public function getMetadataFactory() + { + return $this->wrapped->getMetadataFactory(); + } + + /** + * {@inheritdoc} + */ + public function initializeObject($obj) + { + return $this->wrapped->initializeObject($obj); + } + + /** + * {@inheritdoc} + */ + public function contains($object) + { + return $this->wrapped->contains($object); + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php old mode 100755 new mode 100644 index 9a3e5b6f7d..f60721914a --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php @@ -22,28 +22,28 @@ namespace Doctrine\Common\Persistence; /** * Contract for a Doctrine persistence layer ObjectRepository class to implement. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Benjamin Eberlei - * @author Jonathan Wage + * @link www.doctrine-project.org + * @since 2.1 + * @author Benjamin Eberlei + * @author Jonathan Wage */ interface ObjectRepository { /** * Finds an object by its primary key / identifier. * - * @param int $id The identifier. + * @param mixed $id The identifier. + * * @return object The object. */ - function find($id); + public function find($id); /** * Finds all objects in the repository. * - * @return mixed The objects. + * @return array The objects. */ - function findAll(); + public function findAll(); /** * Finds objects by a set of criteria. @@ -52,27 +52,30 @@ interface ObjectRepository * an UnexpectedValueException if certain values of the sorting or limiting details are * not supported. * - * @throws \UnexpectedValueException - * @param array $criteria + * @param array $criteria * @param array|null $orderBy - * @param int|null $limit - * @param int|null $offset - * @return mixed The objects. + * @param int|null $limit + * @param int|null $offset + * + * @return array The objects. + * + * @throws \UnexpectedValueException */ - function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null); + public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null); /** * Finds a single object by a set of criteria. * - * @param array $criteria + * @param array $criteria The criteria. + * * @return object The object. */ - function findOneBy(array $criteria); + public function findOneBy(array $criteria); /** - * Returns the class name of the object managed by the repository + * Returns the class name of the object managed by the repository. * * @return string */ - function getClassName(); + public function getClassName(); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php old mode 100755 new mode 100644 index 9fcc4cba11..08c69427a2 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php @@ -29,7 +29,6 @@ use Doctrine\Common\Collections\Collection; * * This class is a forward compatible implementation of the PersistentObject trait. * - * * Limitations: * * 1. All persistent objects have to be associated with a single ObjectManager, multiple @@ -38,7 +37,7 @@ use Doctrine\Common\Collections\Collection; * This is either done on `postLoad` of an object or by accessing the global object manager. * 3. There are no hooks for setters/getters. Just implement the method yourself instead of relying on __call(). * 4. Slower than handcoded implementations: An average of 7 method calls per access to a field and 11 for an association. - * 5. Only the inverse side associations get autoset on the owning side aswell. Setting objects on the owning side + * 5. Only the inverse side associations get autoset on the owning side as well. Setting objects on the owning side * will not set the inverse side associations. * * @example @@ -58,19 +57,21 @@ use Doctrine\Common\Collections\Collection; abstract class PersistentObject implements ObjectManagerAware { /** - * @var ObjectManager + * @var ObjectManager|null */ - private static $objectManager; + private static $objectManager = null; /** - * @var ClassMetadata + * @var ClassMetadata|null */ - private $cm; + private $cm = null; /** - * Set the object manager responsible for all persistent object base classes. + * Sets the object manager responsible for all persistent object base classes. * - * @param ObjectManager $objectManager + * @param ObjectManager|null $objectManager + * + * @return void */ static public function setObjectManager(ObjectManager $objectManager = null) { @@ -78,7 +79,7 @@ abstract class PersistentObject implements ObjectManagerAware } /** - * @return ObjectManager + * @return ObjectManager|null */ static public function getObjectManager() { @@ -86,11 +87,13 @@ abstract class PersistentObject implements ObjectManagerAware } /** - * Inject Doctrine Object Manager + * Injects the Doctrine Object Manager. * * @param ObjectManager $objectManager * @param ClassMetadata $classMetadata * + * @return void + * * @throws \RuntimeException */ public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata) @@ -107,11 +110,12 @@ abstract class PersistentObject implements ObjectManagerAware * Sets a persistent fields value. * * @param string $field - * @param array $args + * @param array $args * - * @throws \BadMethodCallException - When no persistent field exists by that name. - * @throws \InvalidArgumentException - When the wrong target object type is passed to an association * @return void + * + * @throws \BadMethodCallException When no persistent field exists by that name. + * @throws \InvalidArgumentException When the wrong target object type is passed to an association. */ private function set($field, $args) { @@ -132,13 +136,13 @@ abstract class PersistentObject implements ObjectManagerAware } /** - * Get persistent field value. - * + * Gets a persistent field value. * * @param string $field * - * @throws \BadMethodCallException - When no persistent field exists by that name. * @return mixed + * + * @throws \BadMethodCallException When no persistent field exists by that name. */ private function get($field) { @@ -152,15 +156,17 @@ abstract class PersistentObject implements ObjectManagerAware } /** - * If this is an inverse side association complete the owning side. + * If this is an inverse side association, completes the owning side. * - * @param string $field + * @param string $field * @param ClassMetadata $targetClass - * @param object $targetObject + * @param object $targetObject + * + * @return void */ private function completeOwningSide($field, $targetClass, $targetObject) { - // add this object on the owning side aswell, for obvious infinite recursion + // add this object on the owning side as well, for obvious infinite recursion // reasons this is only done when called on the inverse side. if ($this->cm->isAssociationInverseSide($field)) { $mappedByField = $this->cm->getAssociationMappedByTargetField($field); @@ -172,10 +178,12 @@ abstract class PersistentObject implements ObjectManagerAware } /** - * Add an object to a collection + * Adds an object to a collection. * * @param string $field - * @param array $args + * @param array $args + * + * @return void * * @throws \BadMethodCallException * @throws \InvalidArgumentException @@ -200,10 +208,11 @@ abstract class PersistentObject implements ObjectManagerAware } /** - * Initialize Doctrine Metadata for this class. + * Initializes Doctrine Metadata for this class. + * + * @return void * * @throws \RuntimeException - * @return void */ private function initializeDoctrine() { @@ -219,13 +228,14 @@ abstract class PersistentObject implements ObjectManagerAware } /** - * Magic method that implements + * Magic methods. * * @param string $method - * @param array $args + * @param array $args + * + * @return mixed * * @throws \BadMethodCallException - * @return mixed */ public function __call($method, $args) { diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php old mode 100755 new mode 100644 index e25598c670..3369eb9498 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php @@ -1,5 +1,4 @@ - * @since 2.2 + * @since 2.2 */ interface Proxy { @@ -36,14 +35,14 @@ interface Proxy const MARKER = '__CG__'; /** - * Length of the proxy marker + * Length of the proxy marker. * - * @var int + * @var integer */ const MARKER_LENGTH = 6; /** - * Initialize this proxy if its not yet initialized. + * Initializes this proxy if its not yet initialized. * * Acts as a no-op if already initialized. * @@ -52,7 +51,7 @@ interface Proxy public function __load(); /** - * Is this proxy initialized or not. + * Returns whether this proxy is initialized or not. * * @return bool */ diff --git a/vendor/doctrine/common/lib/Doctrine/Common/PropertyChangedListener.php b/vendor/doctrine/common/lib/Doctrine/Common/PropertyChangedListener.php old mode 100755 new mode 100644 index 1171874bc2..1a59cd4dd8 --- a/vendor/doctrine/common/lib/Doctrine/Common/PropertyChangedListener.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/PropertyChangedListener.php @@ -1,7 +1,5 @@ NotifyPropertyChanged * implementor. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision: 3938 $ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ interface PropertyChangedListener { /** * Notifies the listener of a property change. * - * @param object $sender The object on which the property changed. + * @param object $sender The object on which the property changed. * @param string $propertyName The name of the property that changed. - * @param mixed $oldValue The old value of the property that changed. - * @param mixed $newValue The new value of the property that changed. + * @param mixed $oldValue The old value of the property that changed. + * @param mixed $newValue The new value of the property that changed. + * + * @return void */ function propertyChanged($sender, $propertyName, $oldValue, $newValue); } - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php new file mode 100644 index 0000000000..adb6c7b7b1 --- /dev/null +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php @@ -0,0 +1,237 @@ +. + */ + +namespace Doctrine\Common\Proxy; + +use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory; +use Doctrine\Common\Proxy\Exception\InvalidArgumentException; +use Doctrine\Common\Util\ClassUtils; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; + +/** + * Abstract factory for proxy objects. + * + * @author Benjamin Eberlei + */ +abstract class AbstractProxyFactory +{ + /** + * Never autogenerate a proxy and rely that it was generated by some + * process before deployment. + * + * @var integer + */ + const AUTOGENERATE_NEVER = 0; + + /** + * Always generates a new proxy in every request. + * + * This is only sane during development. + * + * @var integer + */ + const AUTOGENERATE_ALWAYS = 1; + + /** + * Autogenerate the proxy class when the proxy file does not exist. + * + * This strategy causes a file exists call whenever any proxy is used the + * first time in a request. + * + * @var integer + */ + const AUTOGENERATE_FILE_NOT_EXISTS = 2; + + /** + * Generate the proxy classes using eval(). + * + * This strategy is only sane for development, and even then it gives me + * the creeps a little. + * + * @var integer + */ + const AUTOGENERATE_EVAL = 3; + + /** + * @var \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory + */ + private $metadataFactory; + + /** + * @var \Doctrine\Common\Proxy\ProxyGenerator the proxy generator responsible for creating the proxy classes/files. + */ + private $proxyGenerator; + + /** + * @var bool Whether to automatically (re)generate proxy classes. + */ + private $autoGenerate; + + /** + * @var \Doctrine\Common\Proxy\ProxyDefinition[] + */ + private $definitions = array(); + + /** + * @param \Doctrine\Common\Proxy\ProxyGenerator $proxyGenerator + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory $metadataFactory + * @param bool|int $autoGenerate + */ + public function __construct(ProxyGenerator $proxyGenerator, ClassMetadataFactory $metadataFactory, $autoGenerate) + { + $this->proxyGenerator = $proxyGenerator; + $this->metadataFactory = $metadataFactory; + $this->autoGenerate = (int)$autoGenerate; + } + + /** + * Gets a reference proxy instance for the entity of the given type and identified by + * the given identifier. + * + * @param string $className + * @param array $identifier + * + * @return \Doctrine\Common\Proxy\Proxy + */ + public function getProxy($className, array $identifier) + { + $definition = isset($this->definitions[$className]) + ? $this->definitions[$className] + : $this->getProxyDefinition($className); + $fqcn = $definition->proxyClassName; + $proxy = new $fqcn($definition->initializer, $definition->cloner); + + foreach ($definition->identifierFields as $idField) { + $definition->reflectionFields[$idField]->setValue($proxy, $identifier[$idField]); + } + + return $proxy; + } + + /** + * Generates proxy classes for all given classes. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata[] $classes The classes (ClassMetadata instances) + * for which to generate proxies. + * @param string $proxyDir The target directory of the proxy classes. If not specified, the + * directory configured on the Configuration of the EntityManager used + * by this factory is used. + * @return int Number of generated proxies. + */ + public function generateProxyClasses(array $classes, $proxyDir = null) + { + $generated = 0; + + foreach ($classes as $class) { + if ($this->skipClass($class)) { + continue; + } + + $proxyFileName = $this->proxyGenerator->getProxyFileName($class->getName(), $proxyDir); + + $this->proxyGenerator->generateProxyClass($class, $proxyFileName); + + $generated += 1; + } + + return $generated; + } + + /** + * Reset initialization/cloning logic for an un-initialized proxy + * + * @param \Doctrine\Common\Proxy\Proxy $proxy + * + * @return \Doctrine\Common\Proxy\Proxy + * + * @throws \Doctrine\Common\Proxy\Exception\InvalidArgumentException + */ + public function resetUninitializedProxy(Proxy $proxy) + { + if ($proxy->__isInitialized()) { + throw InvalidArgumentException::unitializedProxyExpected($proxy); + } + + $className = ClassUtils::getClass($proxy); + $definition = isset($this->definitions[$className]) + ? $this->definitions[$className] + : $this->getProxyDefinition($className); + + $proxy->__setInitializer($definition->initializer); + $proxy->__setCloner($definition->cloner); + + return $proxy; + } + + /** + * Get a proxy definition for the given class name. + * + * @return ProxyDefinition + */ + private function getProxyDefinition($className) + { + $classMetadata = $this->metadataFactory->getMetadataFor($className); + $className = $classMetadata->getName(); // aliases and case sensitivity + + $this->definitions[$className] = $this->createProxyDefinition($className); + $proxyClassName = $this->definitions[$className]->proxyClassName; + + if ( ! class_exists($proxyClassName, false)) { + $fileName = $this->proxyGenerator->getProxyFileName($className); + + switch ($this->autoGenerate) { + case self::AUTOGENERATE_NEVER: + require $fileName; + break; + + case self::AUTOGENERATE_FILE_NOT_EXISTS: + if ( ! file_exists($fileName)) { + $this->proxyGenerator->generateProxyClass($classMetadata, $fileName); + } + require $fileName; + break; + + case self::AUTOGENERATE_ALWAYS: + $this->proxyGenerator->generateProxyClass($classMetadata, $fileName); + require $fileName; + break; + + case self::AUTOGENERATE_EVAL: + $this->proxyGenerator->generateProxyClass($classMetadata, false); + break; + } + } + + return $this->definitions[$className]; + } + + /** + * Determine if this class should be skipped during proxy generation. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata + * @return bool + */ + abstract protected function skipClass(ClassMetadata $metadata); + + /** + * @return ProxyDefinition + */ + abstract protected function createProxyDefinition($className); +} + diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Autoloader.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Autoloader.php new file mode 100644 index 0000000000..0aa930b229 --- /dev/null +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Autoloader.php @@ -0,0 +1,92 @@ +. + */ + +namespace Doctrine\Common\Proxy; + +use Doctrine\Common\Proxy\Exception\InvalidArgumentException; + +/** + * Special Autoloader for Proxy classes, which are not PSR-0 compliant. + * + * @author Benjamin Eberlei + */ +class Autoloader +{ + /** + * Resolves proxy class name to a filename based on the following pattern. + * + * 1. Remove Proxy namespace from class name. + * 2. Remove namespace separators from remaining class name. + * 3. Return PHP filename from proxy-dir with the result from 2. + * + * @param string $proxyDir + * @param string $proxyNamespace + * @param string $className + * + * @return string + * + * @throws InvalidArgumentException + */ + public static function resolveFile($proxyDir, $proxyNamespace, $className) + { + if (0 !== strpos($className, $proxyNamespace)) { + throw InvalidArgumentException::notProxyClass($className, $proxyNamespace); + } + + $className = str_replace('\\', '', substr($className, strlen($proxyNamespace) + 1)); + + return $proxyDir . DIRECTORY_SEPARATOR . $className . '.php'; + } + + /** + * Registers and returns autoloader callback for the given proxy dir and namespace. + * + * @param string $proxyDir + * @param string $proxyNamespace + * @param callable|null $notFoundCallback Invoked when the proxy file is not found. + * + * @return \Closure + * + * @throws InvalidArgumentException + */ + public static function register($proxyDir, $proxyNamespace, $notFoundCallback = null) + { + $proxyNamespace = ltrim($proxyNamespace, '\\'); + + if ( ! (null === $notFoundCallback || is_callable($notFoundCallback))) { + throw InvalidArgumentException::invalidClassNotFoundCallback($notFoundCallback); + } + + $autoloader = function ($className) use ($proxyDir, $proxyNamespace, $notFoundCallback) { + if (0 === strpos($className, $proxyNamespace)) { + $file = Autoloader::resolveFile($proxyDir, $proxyNamespace, $className); + + if ($notFoundCallback && ! file_exists($file)) { + call_user_func($notFoundCallback, $proxyDir, $proxyNamespace, $className); + } + + require $file; + } + }; + + spl_autoload_register($autoloader); + + return $autoloader; + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/InvalidArgumentException.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/InvalidArgumentException.php new file mode 100644 index 0000000000..24a2194308 --- /dev/null +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/InvalidArgumentException.php @@ -0,0 +1,90 @@ +. + */ + +namespace Doctrine\Common\Proxy\Exception; + +use Doctrine\Common\Persistence\Proxy; +use InvalidArgumentException as BaseInvalidArgumentException; + +/** + * Proxy Invalid Argument Exception. + * + * @link www.doctrine-project.org + * @since 2.4 + * @author Marco Pivetta + */ +class InvalidArgumentException extends BaseInvalidArgumentException implements ProxyException +{ + /** + * @return self + */ + public static function proxyDirectoryRequired() + { + return new self('You must configure a proxy directory. See docs for details'); + } + + /** + * @param string $className + * @param string $proxyNamespace + * + * @return self + */ + public static function notProxyClass($className, $proxyNamespace) + { + return new self(sprintf('The class "%s" is not part of the proxy namespace "%s"', $className, $proxyNamespace)); + } + + /** + * @param string $name + * + * @return self + */ + public static function invalidPlaceholder($name) + { + return new self(sprintf('Provided placeholder for "%s" must be either a string or a valid callable', $name)); + } + + /** + * @return self + */ + public static function proxyNamespaceRequired() + { + return new self('You must configure a proxy namespace'); + } + + /** + * @return self + */ + public static function unitializedProxyExpected(Proxy $proxy) + { + return new self(sprintf('Provided proxy of type "%s" must not be initialized.', get_class($proxy))); + } + + /** + * @param mixed $callback + * + * @return self + */ + public static function invalidClassNotFoundCallback($callback) + { + $type = is_object($callback) ? get_class($callback) : gettype($callback); + + return new self(sprintf('Invalid \$notFoundCallback given: must be a callable, "%s" given', $type)); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/ProxyException.php old mode 100755 new mode 100644 similarity index 76% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php rename to vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/ProxyException.php index 59cd21a61e..0d1ff1408f --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/ProxyException.php @@ -1,5 +1,4 @@ . */ -namespace Doctrine\Tests\Models\DDC889; +namespace Doctrine\Common\Proxy\Exception; /** - * @Entity + * Base exception interface for proxy exceptions. + * + * @link www.doctrine-project.org + * @since 2.4 + * @author Marco Pivetta */ -class DDC889Entity extends DDC889SuperClass +interface ProxyException { - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - } - -} \ No newline at end of file +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/UnexpectedValueException.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/UnexpectedValueException.php new file mode 100644 index 0000000000..73ec64d302 --- /dev/null +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/UnexpectedValueException.php @@ -0,0 +1,62 @@ +. + */ + +namespace Doctrine\Common\Proxy\Exception; + +use UnexpectedValueException as BaseUnexpectedValueException; + +/** + * Proxy Unexpected Value Exception. + * + * @link www.doctrine-project.org + * @since 2.4 + * @author Marco Pivetta + */ +class UnexpectedValueException extends BaseUnexpectedValueException implements ProxyException +{ + /** + * @return self + */ + public static function proxyDirectoryNotWritable() + { + return new self('Your proxy directory must be writable'); + } + + /** + * @param string $className + * @param string $methodName + * @param string $parameterName + * @param \Exception $previous + * + * @return self + */ + public static function invalidParameterTypeHint($className, $methodName, $parameterName, \Exception $previous) + { + return new self( + sprintf( + 'The type hint of parameter "%s" in method "%s" in class "%s" is invalid.', + $parameterName, + $methodName, + $className + ), + 0, + $previous + ); + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Proxy.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Proxy.php new file mode 100644 index 0000000000..83684306a6 --- /dev/null +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Proxy.php @@ -0,0 +1,90 @@ +. + */ + +namespace Doctrine\Common\Proxy; + +use Doctrine\Common\Persistence\Proxy as BaseProxy; +use Closure; + +/** + * Interface for proxy classes. + * + * @author Roman Borschel + * @author Marco Pivetta + * @since 2.4 + */ +interface Proxy extends BaseProxy +{ + /** + * Marks the proxy as initialized or not. + * + * @param boolean $initialized + * + * @return void + */ + public function __setInitialized($initialized); + + /** + * Sets the initializer callback to be used when initializing the proxy. That + * initializer should accept 3 parameters: $proxy, $method and $params. Those + * are respectively the proxy object that is being initialized, the method name + * that triggered initialization and the parameters passed to that method. + * + * @param Closure|null $initializer + * + * @return void + */ + public function __setInitializer(Closure $initializer = null); + + /** + * Retrieves the initializer callback used to initialize the proxy. + * + * @see __setInitializer + * + * @return Closure|null + */ + public function __getInitializer(); + + /** + * Sets the callback to be used when cloning the proxy. That initializer should accept + * a single parameter, which is the cloned proxy instance itself. + * + * @param Closure|null $cloner + * + * @return void + */ + public function __setCloner(Closure $cloner = null); + + /** + * Retrieves the callback to be used when cloning the proxy. + * + * @see __setCloner + * + * @return Closure|null + */ + public function __getCloner(); + + /** + * Retrieves the list of lazy loaded properties for a given proxy + * + * @return array Keys are the property names, and values are the default values + * for those properties. + */ + public function __getLazyProperties(); +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyDefinition.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyDefinition.php new file mode 100644 index 0000000000..48b149a305 --- /dev/null +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyDefinition.php @@ -0,0 +1,70 @@ +. + */ + +namespace Doctrine\Common\Proxy; + +/** + * Definition structure how to create a proxy. + * + * @author Benjamin Eberlei + */ +class ProxyDefinition +{ + /** + * @var string + */ + public $proxyClassName; + + /** + * @var array + */ + public $identifierFields; + + /** + * @var \ReflectionProperty[] + */ + public $reflectionFields; + + /** + * @var callable + */ + public $initializer; + + /** + * @var callable + */ + public $cloner; + + /** + * @param string $proxyClassName + * @param array $identifierFields + * @param array $reflectionFields + * @param callable $initializer + * @param callable $cloner + */ + public function __construct($proxyClassName, array $identifierFields, array $reflectionFields, $initializer, $cloner) + { + $this->proxyClassName = $proxyClassName; + $this->identifierFields = $identifierFields; + $this->reflectionFields = $reflectionFields; + $this->initializer = $initializer; + $this->cloner = $cloner; + } +} + diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php new file mode 100644 index 0000000000..25f3ed1f1e --- /dev/null +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php @@ -0,0 +1,926 @@ +. + */ + +namespace Doctrine\Common\Proxy; + +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Util\ClassUtils; +use Doctrine\Common\Proxy\Exception\InvalidArgumentException; +use Doctrine\Common\Proxy\Exception\UnexpectedValueException; + +/** + * This factory is used to generate proxy classes. + * It builds proxies from given parameters, a template and class metadata. + * + * @author Marco Pivetta + * @since 2.4 + */ +class ProxyGenerator +{ + /** + * Used to match very simple id methods that don't need + * to be decorated since the identifier is known. + */ + const PATTERN_MATCH_ID_METHOD = '((public\s)?(function\s{1,}%s\s?\(\)\s{1,})\s{0,}{\s{0,}return\s{0,}\$this->%s;\s{0,}})i'; + + /** + * The namespace that contains all proxy classes. + * + * @var string + */ + private $proxyNamespace; + + /** + * The directory that contains all proxy classes. + * + * @var string + */ + private $proxyDirectory; + + /** + * Map of callables used to fill in placeholders set in the template. + * + * @var string[]|callable[] + */ + protected $placeholders = array( + 'baseProxyInterface' => 'Doctrine\Common\Proxy\Proxy', + 'additionalProperties' => '', + ); + + /** + * Template used as a blueprint to generate proxies. + * + * @var string + */ + protected $proxyClassTemplate = '; + +/** + * DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE\'S PROXY GENERATOR + */ +class extends \ implements \ +{ + /** + * @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with + * three parameters, being respectively the proxy object to be initialized, the method that triggered the + * initialization process and an array of ordered parameters that were passed to that method. + * + * @see \Doctrine\Common\Persistence\Proxy::__setInitializer + */ + public $__initializer__; + + /** + * @var \Closure the callback responsible of loading properties that need to be copied in the cloned object + * + * @see \Doctrine\Common\Persistence\Proxy::__setCloner + */ + public $__cloner__; + + /** + * @var boolean flag indicating if this object was already initialized + * + * @see \Doctrine\Common\Persistence\Proxy::__isInitialized + */ + public $__isInitialized__ = false; + + /** + * @var array properties to be lazy loaded, with keys being the property + * names and values being their default values + * + * @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties + */ + public static $lazyPropertiesDefaults = array(); + + + + + + + + + + + + + + + + + + /** + * Forces initialization of the proxy + */ + public function __load() + { + $this->__initializer__ && $this->__initializer__->__invoke($this, \'__load\', array()); + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __isInitialized() + { + return $this->__isInitialized__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitialized($initialized) + { + $this->__isInitialized__ = $initialized; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->__initializer__ = $initializer; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __getInitializer() + { + return $this->__initializer__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + */ + public function __setCloner(\Closure $cloner = null) + { + $this->__cloner__ = $cloner; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific cloning logic + */ + public function __getCloner() + { + return $this->__cloner__; + } + + /** + * {@inheritDoc} + * @internal generated method: use only when explicitly handling proxy specific loading logic + * @static + */ + public function __getLazyProperties() + { + return self::$lazyPropertiesDefaults; + } + + +} +'; + + /** + * Initializes a new instance of the ProxyFactory class that is + * connected to the given EntityManager. + * + * @param string $proxyDirectory The directory to use for the proxy classes. It must exist. + * @param string $proxyNamespace The namespace to use for the proxy classes. + * + * @throws InvalidArgumentException + */ + public function __construct($proxyDirectory, $proxyNamespace) + { + if ( ! $proxyDirectory) { + throw InvalidArgumentException::proxyDirectoryRequired(); + } + + if ( ! $proxyNamespace) { + throw InvalidArgumentException::proxyNamespaceRequired(); + } + + $this->proxyDirectory = $proxyDirectory; + $this->proxyNamespace = $proxyNamespace; + } + + /** + * Sets a placeholder to be replaced in the template. + * + * @param string $name + * @param string|callable $placeholder + * + * @throws InvalidArgumentException + */ + public function setPlaceholder($name, $placeholder) + { + if ( ! is_string($placeholder) && ! is_callable($placeholder)) { + throw InvalidArgumentException::invalidPlaceholder($name); + } + + $this->placeholders[$name] = $placeholder; + } + + /** + * Sets the base template used to create proxy classes. + * + * @param string $proxyClassTemplate + */ + public function setProxyClassTemplate($proxyClassTemplate) + { + $this->proxyClassTemplate = (string) $proxyClassTemplate; + } + + /** + * Generates a proxy class file. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class Metadata for the original class. + * @param string|bool $fileName Filename (full path) for the generated class. If none is given, eval() is used. + * + * @throws UnexpectedValueException + */ + public function generateProxyClass(ClassMetadata $class, $fileName = false) + { + preg_match_all('(<([a-zA-Z]+)>)', $this->proxyClassTemplate, $placeholderMatches); + + $placeholderMatches = array_combine($placeholderMatches[0], $placeholderMatches[1]); + $placeholders = array(); + + foreach ($placeholderMatches as $placeholder => $name) { + $placeholders[$placeholder] = isset($this->placeholders[$name]) + ? $this->placeholders[$name] + : array($this, 'generate' . $name); + } + + foreach ($placeholders as & $placeholder) { + if (is_callable($placeholder)) { + $placeholder = call_user_func($placeholder, $class); + } + } + + $proxyCode = strtr($this->proxyClassTemplate, $placeholders); + + if ( ! $fileName) { + $proxyClassName = $this->generateNamespace($class) . '\\' . $this->generateProxyShortClassName($class); + + if ( ! class_exists($proxyClassName)) { + eval(substr($proxyCode, 5)); + } + + return; + } + + $parentDirectory = dirname($fileName); + + if ( ! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) { + throw UnexpectedValueException::proxyDirectoryNotWritable(); + } + + if ( ! is_writable($parentDirectory)) { + throw UnexpectedValueException::proxyDirectoryNotWritable(); + } + + $tmpFileName = $fileName . '.' . uniqid('', true); + + file_put_contents($tmpFileName, $proxyCode); + rename($tmpFileName, $fileName); + } + + /** + * Generates the proxy short class name to be used in the template. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateProxyShortClassName(ClassMetadata $class) + { + $proxyClassName = ClassUtils::generateProxyClassName($class->getName(), $this->proxyNamespace); + $parts = explode('\\', strrev($proxyClassName), 2); + + return strrev($parts[0]); + } + + /** + * Generates the proxy namespace. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateNamespace(ClassMetadata $class) + { + $proxyClassName = ClassUtils::generateProxyClassName($class->getName(), $this->proxyNamespace); + $parts = explode('\\', strrev($proxyClassName), 2); + + return strrev($parts[1]); + } + + /** + * Generates the original class name. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateClassName(ClassMetadata $class) + { + return ltrim($class->getName(), '\\'); + } + + /** + * Generates the array representation of lazy loaded public properties and their default values. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateLazyPropertiesDefaults(ClassMetadata $class) + { + $lazyPublicProperties = $this->getLazyLoadedPublicProperties($class); + $values = array(); + + foreach ($lazyPublicProperties as $key => $value) { + $values[] = var_export($key, true) . ' => ' . var_export($value, true); + } + + return implode(', ', $values); + } + + /** + * Generates the constructor code (un-setting public lazy loaded properties, setting identifier field values). + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateConstructorImpl(ClassMetadata $class) + { + $constructorImpl = <<<'EOT' + /** + * @param \Closure $initializer + * @param \Closure $cloner + */ + public function __construct($initializer = null, $cloner = null) + { + +EOT; + $toUnset = array(); + + foreach ($this->getLazyLoadedPublicProperties($class) as $lazyPublicProperty => $unused) { + $toUnset[] = '$this->' . $lazyPublicProperty; + } + + $constructorImpl .= (empty($toUnset) ? '' : ' unset(' . implode(', ', $toUnset) . ");\n") + . <<<'EOT' + + $this->__initializer__ = $initializer; + $this->__cloner__ = $cloner; + } +EOT; + + return $constructorImpl; + } + + /** + * Generates the magic getter invoked when lazy loaded public properties are requested. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateMagicGet(ClassMetadata $class) + { + $lazyPublicProperties = array_keys($this->getLazyLoadedPublicProperties($class)); + $reflectionClass = $class->getReflectionClass(); + $hasParentGet = false; + $returnReference = ''; + $inheritDoc = ''; + + if ($reflectionClass->hasMethod('__get')) { + $hasParentGet = true; + $inheritDoc = '{@inheritDoc}'; + + if ($reflectionClass->getMethod('__get')->returnsReference()) { + $returnReference = '& '; + } + } + + if (empty($lazyPublicProperties) && ! $hasParentGet) { + return ''; + } + + $magicGet = <<__getLazyProperties())) { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__get', array($name)); + + return $this->$name; + } + + +EOT; + } + + if ($hasParentGet) { + $magicGet .= <<<'EOT' + $this->__initializer__ && $this->__initializer__->__invoke($this, '__get', array($name)); + + return parent::__get($name); + +EOT; + } else { + $magicGet .= <<<'EOT' + trigger_error(sprintf('Undefined property: %s::$%s', __CLASS__, $name), E_USER_NOTICE); + +EOT; + } + + $magicGet .= " }"; + + return $magicGet; + } + + /** + * Generates the magic setter (currently unused). + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateMagicSet(ClassMetadata $class) + { + $lazyPublicProperties = $this->getLazyLoadedPublicProperties($class); + $hasParentSet = $class->getReflectionClass()->hasMethod('__set'); + + if (empty($lazyPublicProperties) && ! $hasParentSet) { + return ''; + } + + $inheritDoc = $hasParentSet ? '{@inheritDoc}' : ''; + $magicSet = <<__getLazyProperties())) { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__set', array($name, $value)); + + $this->$name = $value; + + return; + } + + +EOT; + } + + if ($hasParentSet) { + $magicSet .= <<<'EOT' + $this->__initializer__ && $this->__initializer__->__invoke($this, '__set', array($name, $value)); + + return parent::__set($name, $value); +EOT; + } else { + $magicSet .= " \$this->\$name = \$value;"; + } + + $magicSet .= "\n }"; + + return $magicSet; + } + + /** + * Generates the magic issetter invoked when lazy loaded public properties are checked against isset(). + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateMagicIsset(ClassMetadata $class) + { + $lazyPublicProperties = array_keys($this->getLazyLoadedPublicProperties($class)); + $hasParentIsset = $class->getReflectionClass()->hasMethod('__isset'); + + if (empty($lazyPublicProperties) && ! $hasParentIsset) { + return ''; + } + + $inheritDoc = $hasParentIsset ? '{@inheritDoc}' : ''; + $magicIsset = <<__getLazyProperties())) { + $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', array($name)); + + return isset($this->$name); + } + + +EOT; + } + + if ($hasParentIsset) { + $magicIsset .= <<<'EOT' + $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', array($name)); + + return parent::__isset($name); + +EOT; + } else { + $magicIsset .= " return false;"; + } + + return $magicIsset . "\n }"; + } + + /** + * Generates implementation for the `__sleep` method of proxies. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateSleepImpl(ClassMetadata $class) + { + $hasParentSleep = $class->getReflectionClass()->hasMethod('__sleep'); + $inheritDoc = $hasParentSleep ? '{@inheritDoc}' : ''; + $sleepImpl = <<__isInitialized__) { + $properties = array_diff($properties, array_keys($this->__getLazyProperties())); + } + + return $properties; + } +EOT; + } + + $allProperties = array('__isInitialized__'); + + /* @var $prop \ReflectionProperty */ + foreach ($class->getReflectionClass()->getProperties() as $prop) { + $allProperties[] = $prop->getName(); + } + + $lazyPublicProperties = array_keys($this->getLazyLoadedPublicProperties($class)); + $protectedProperties = array_diff($allProperties, $lazyPublicProperties); + + foreach ($allProperties as &$property) { + $property = var_export($property, true); + } + + foreach ($protectedProperties as &$property) { + $property = var_export($property, true); + } + + $allProperties = implode(', ', $allProperties); + $protectedProperties = implode(', ', $protectedProperties); + + return $sleepImpl . <<__isInitialized__) { + return array($allProperties); + } + + return array($protectedProperties); + } +EOT; + } + + /** + * Generates implementation for the `__wakeup` method of proxies. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateWakeupImpl(ClassMetadata $class) + { + $unsetPublicProperties = array(); + $hasWakeup = $class->getReflectionClass()->hasMethod('__wakeup'); + + foreach (array_keys($this->getLazyLoadedPublicProperties($class)) as $lazyPublicProperty) { + $unsetPublicProperties[] = '$this->' . $lazyPublicProperty; + } + + $shortName = $this->generateProxyShortClassName($class); + $inheritDoc = $hasWakeup ? '{@inheritDoc}' : ''; + $wakeupImpl = <<__isInitialized__) { + \$this->__initializer__ = function ($shortName \$proxy) { + \$proxy->__setInitializer(null); + \$proxy->__setCloner(null); + + \$existingProperties = get_object_vars(\$proxy); + + foreach (\$proxy->__getLazyProperties() as \$property => \$defaultValue) { + if ( ! array_key_exists(\$property, \$existingProperties)) { + \$proxy->\$property = \$defaultValue; + } + } + }; + +EOT; + + if ( ! empty($unsetPublicProperties)) { + $wakeupImpl .= "\n unset(" . implode(', ', $unsetPublicProperties) . ");"; + } + + $wakeupImpl .= "\n }"; + + if ($hasWakeup) { + $wakeupImpl .= "\n parent::__wakeup();"; + } + + $wakeupImpl .= "\n }"; + + return $wakeupImpl; + } + + /** + * Generates implementation for the `__clone` method of proxies. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateCloneImpl(ClassMetadata $class) + { + $hasParentClone = $class->getReflectionClass()->hasMethod('__clone'); + $inheritDoc = $hasParentClone ? '{@inheritDoc}' : ''; + $callParentClone = $hasParentClone ? "\n parent::__clone();\n" : ''; + + return <<__cloner__ && \$this->__cloner__->__invoke(\$this, '__clone', array()); +$callParentClone } +EOT; + } + + /** + * Generates decorated methods by picking those available in the parent class. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return string + */ + private function generateMethods(ClassMetadata $class) + { + $methods = ''; + $methodNames = array(); + $reflectionMethods = $class->getReflectionClass()->getMethods(\ReflectionMethod::IS_PUBLIC); + $skippedMethods = array( + '__sleep' => true, + '__clone' => true, + '__wakeup' => true, + '__get' => true, + '__set' => true, + '__isset' => true, + ); + + foreach ($reflectionMethods as $method) { + $name = $method->getName(); + + if ( + $method->isConstructor() || + isset($skippedMethods[strtolower($name)]) || + isset($methodNames[$name]) || + $method->isFinal() || + $method->isStatic() || + ( ! $method->isPublic()) + ) { + continue; + } + + $methodNames[$name] = true; + $methods .= "\n /**\n" + . " * {@inheritDoc}\n" + . " */\n" + . ' public function '; + + if ($method->returnsReference()) { + $methods .= '&'; + } + + $methods .= $name . '('; + + $firstParam = true; + $parameterString = ''; + $argumentString = ''; + $parameters = array(); + + foreach ($method->getParameters() as $param) { + if ($firstParam) { + $firstParam = false; + } else { + $parameterString .= ', '; + $argumentString .= ', '; + } + + try { + $paramClass = $param->getClass(); + } catch (\ReflectionException $previous) { + throw UnexpectedValueException::invalidParameterTypeHint( + $class->getName(), + $method->getName(), + $param->getName(), + $previous + ); + } + + // We need to pick the type hint class too + if (null !== $paramClass) { + $parameterString .= '\\' . $paramClass->getName() . ' '; + } elseif ($param->isArray()) { + $parameterString .= 'array '; + } elseif (method_exists($param, 'isCallable') && $param->isCallable()) { + $parameterString .= 'callable '; + } + + if ($param->isPassedByReference()) { + $parameterString .= '&'; + } + + $parameters[] = '$' . $param->getName(); + $parameterString .= '$' . $param->getName(); + $argumentString .= '$' . $param->getName(); + + if ($param->isDefaultValueAvailable()) { + $parameterString .= ' = ' . var_export($param->getDefaultValue(), true); + } + } + + $methods .= $parameterString . ')'; + $methods .= "\n" . ' {' . "\n"; + + if ($this->isShortIdentifierGetter($method, $class)) { + $identifier = lcfirst(substr($name, 3)); + $fieldType = $class->getTypeOfField($identifier); + $cast = in_array($fieldType, array('integer', 'smallint')) ? '(int) ' : ''; + + $methods .= ' if ($this->__isInitialized__ === false) {' . "\n"; + $methods .= ' return ' . $cast . ' parent::' . $method->getName() . "();\n"; + $methods .= ' }' . "\n\n"; + } + + $methods .= "\n \$this->__initializer__ " + . "&& \$this->__initializer__->__invoke(\$this, " . var_export($name, true) + . ", array(" . implode(', ', $parameters) . "));" + . "\n\n return parent::" . $name . '(' . $argumentString . ');' + . "\n" . ' }' . "\n"; + } + + return $methods; + } + + /** + * Generates the Proxy file name. + * + * @param string $className + * @param string $baseDirectory Optional base directory for proxy file name generation. + * If not specified, the directory configured on the Configuration of the + * EntityManager will be used by this factory. + * + * @return string + */ + public function getProxyFileName($className, $baseDirectory = null) + { + $baseDirectory = $baseDirectory ?: $this->proxyDirectory; + + return rtrim($baseDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . Proxy::MARKER + . str_replace('\\', '', $className) . '.php'; + } + + /** + * Checks if the method is a short identifier getter. + * + * What does this mean? For proxy objects the identifier is already known, + * however accessing the getter for this identifier usually triggers the + * lazy loading, leading to a query that may not be necessary if only the + * ID is interesting for the userland code (for example in views that + * generate links to the entity, but do not display anything else). + * + * @param \ReflectionMethod $method + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return boolean + */ + private function isShortIdentifierGetter($method, ClassMetadata $class) + { + $identifier = lcfirst(substr($method->getName(), 3)); + $startLine = $method->getStartLine(); + $endLine = $method->getEndLine(); + $cheapCheck = ( + $method->getNumberOfParameters() == 0 + && substr($method->getName(), 0, 3) == 'get' + && in_array($identifier, $class->getIdentifier(), true) + && $class->hasField($identifier) + && (($endLine - $startLine) <= 4) + ); + + if ($cheapCheck) { + $code = file($method->getDeclaringClass()->getFileName()); + $code = trim(implode(' ', array_slice($code, $startLine - 1, $endLine - $startLine + 1))); + + $pattern = sprintf(self::PATTERN_MATCH_ID_METHOD, $method->getName(), $identifier); + + if (preg_match($pattern, $code)) { + return true; + } + } + + return false; + } + + /** + * Generates the list of public properties to be lazy loaded, with their default values. + * + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class + * + * @return mixed[] + */ + private function getLazyLoadedPublicProperties(ClassMetadata $class) + { + $defaultProperties = $class->getReflectionClass()->getDefaultProperties(); + $properties = array(); + + foreach ($class->getReflectionClass()->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $name = $property->getName(); + + if (($class->hasField($name) || $class->hasAssociation($name)) && ! $class->isIdentifier($name)) { + $properties[$name] = $defaultProperties[$name]; + } + } + + return $properties; + } +} + diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ClassFinderInterface.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ClassFinderInterface.php old mode 100755 new mode 100644 index ae69607687..639fd69a61 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ClassFinderInterface.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ClassFinderInterface.php @@ -31,8 +31,7 @@ interface ClassFinderInterface * * @param string $class The name of the class. * - * @return - * The name of the class or NULL if not found. + * @return string|null The name of the class or NULL if not found. */ public function findFile($class); } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/Psr0FindFile.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/Psr0FindFile.php old mode 100755 new mode 100644 index b6a5fd1124..418bb0f7b9 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/Psr0FindFile.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/Psr0FindFile.php @@ -29,14 +29,13 @@ class Psr0FindFile implements ClassFinderInterface /** * The PSR-0 prefixes. * - * @var string + * @var array */ protected $prefixes; /** - * @param string $prefixes - * An array of prefixes. Each key is a PHP namespace and each value is - * a list of directories. + * @param array $prefixes An array of prefixes. Each key is a PHP namespace and each value is + * a list of directories. */ public function __construct($prefixes) { @@ -44,12 +43,7 @@ class Psr0FindFile implements ClassFinderInterface } /** - * Finds a class. - * - * @param string $class The name of the class. - * - * @return - * The name of the class or NULL if not found. + * {@inheritDoc} */ public function findFile($class) { @@ -73,11 +67,13 @@ class Psr0FindFile implements ClassFinderInterface foreach ($this->prefixes as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { foreach ($dirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { + if (is_file($dir . DIRECTORY_SEPARATOR . $classPath)) { return $dir . DIRECTORY_SEPARATOR . $classPath; } } } } + + return null; } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ReflectionProviderInterface.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ReflectionProviderInterface.php old mode 100755 new mode 100644 index a436a2d78a..3d970eeedb --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ReflectionProviderInterface.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ReflectionProviderInterface.php @@ -1,5 +1,4 @@ . + */ + +namespace Doctrine\Common\Reflection; + +use ReflectionProperty; +use Doctrine\Common\Proxy\Proxy; + +/** + * PHP Runtime Reflection Public Property - special overrides for public properties. + * + * @author Marco Pivetta + * @since 2.4 + */ +class RuntimePublicReflectionProperty extends ReflectionProperty +{ + /** + * {@inheritDoc} + * + * Checks is the value actually exist before fetching it. + * This is to avoid calling `__get` on the provided $object if it + * is a {@see \Doctrine\Common\Proxy\Proxy}. + */ + public function getValue($object = null) + { + $name = $this->getName(); + + if ($object instanceof Proxy && ! $object->__isInitialized()) { + $originalInitializer = $object->__getInitializer(); + $object->__setInitializer(null); + $val = isset($object->$name) ? $object->$name : null; + $object->__setInitializer($originalInitializer); + + return $val; + } + + return isset($object->$name) ? parent::getValue($object) : null; + } + + /** + * {@inheritDoc} + * + * Avoids triggering lazy loading via `__set` if the provided object + * is a {@see \Doctrine\Common\Proxy\Proxy}. + * @link https://bugs.php.net/bug.php?id=63463 + */ + public function setValue($object, $value = null) + { + if ( ! ($object instanceof Proxy && ! $object->__isInitialized())) { + parent::setValue($object, $value); + + return; + } + + $originalInitializer = $object->__getInitializer(); + $object->__setInitializer(null); + parent::setValue($object, $value); + $object->__setInitializer($originalInitializer); + } +} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php old mode 100755 new mode 100644 index 12e45d57d6..b65979add3 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php @@ -31,82 +31,403 @@ class StaticReflectionClass extends ReflectionClass */ private $staticReflectionParser; + /** + * @param StaticReflectionParser $staticReflectionParser + */ public function __construct(StaticReflectionParser $staticReflectionParser) { $this->staticReflectionParser = $staticReflectionParser; } + /** + * {@inheritDoc} + */ public function getName() { return $this->staticReflectionParser->getClassName(); } + /** + * {@inheritDoc} + */ public function getDocComment() { return $this->staticReflectionParser->getDocComment(); } + /** + * {@inheritDoc} + */ public function getNamespaceName() { return $this->staticReflectionParser->getNamespaceName(); } + /** + * @return array + */ public function getUseStatements() { return $this->staticReflectionParser->getUseStatements(); } + /** + * {@inheritDoc} + */ public function getMethod($name) { return $this->staticReflectionParser->getReflectionMethod($name); } + /** + * {@inheritDoc} + */ public function getProperty($name) { return $this->staticReflectionParser->getReflectionProperty($name); } - public static function export($argument, $return = false) { throw new ReflectionException('Method not implemented'); } - public function getConstant($name) { throw new ReflectionException('Method not implemented'); } - public function getConstants() { throw new ReflectionException('Method not implemented'); } - public function getConstructor() { throw new ReflectionException('Method not implemented'); } - public function getDefaultProperties() { throw new ReflectionException('Method not implemented'); } - public function getEndLine() { throw new ReflectionException('Method not implemented'); } - public function getExtension() { throw new ReflectionException('Method not implemented'); } - public function getExtensionName() { throw new ReflectionException('Method not implemented'); } - public function getFileName() { throw new ReflectionException('Method not implemented'); } - public function getInterfaceNames() { throw new ReflectionException('Method not implemented'); } - public function getInterfaces() { throw new ReflectionException('Method not implemented'); } - public function getMethods($filter = NULL) { throw new ReflectionException('Method not implemented'); } - public function getModifiers() { throw new ReflectionException('Method not implemented'); } - public function getParentClass() { throw new ReflectionException('Method not implemented'); } - public function getProperties($filter = NULL) { throw new ReflectionException('Method not implemented'); } - public function getShortName() { throw new ReflectionException('Method not implemented'); } - public function getStartLine() { throw new ReflectionException('Method not implemented'); } - public function getStaticProperties() { throw new ReflectionException('Method not implemented'); } - public function getStaticPropertyValue($name, $default = '') { throw new ReflectionException('Method not implemented'); } - public function getTraitAliases() { throw new ReflectionException('Method not implemented'); } - public function getTraitNames() { throw new ReflectionException('Method not implemented'); } - public function getTraits() { throw new ReflectionException('Method not implemented'); } - public function hasConstant($name) { throw new ReflectionException('Method not implemented'); } - public function hasMethod($name) { throw new ReflectionException('Method not implemented'); } - public function hasProperty($name) { throw new ReflectionException('Method not implemented'); } - public function implementsInterface($interface) { throw new ReflectionException('Method not implemented'); } - public function inNamespace() { throw new ReflectionException('Method not implemented'); } - public function isAbstract() { throw new ReflectionException('Method not implemented'); } - public function isCloneable() { throw new ReflectionException('Method not implemented'); } - public function isFinal() { throw new ReflectionException('Method not implemented'); } - public function isInstance($object) { throw new ReflectionException('Method not implemented'); } - public function isInstantiable() { throw new ReflectionException('Method not implemented'); } - public function isInterface() { throw new ReflectionException('Method not implemented'); } - public function isInternal() { throw new ReflectionException('Method not implemented'); } - public function isIterateable() { throw new ReflectionException('Method not implemented'); } - public function isSubclassOf($class) { throw new ReflectionException('Method not implemented'); } - public function isTrait() { throw new ReflectionException('Method not implemented'); } - public function isUserDefined() { throw new ReflectionException('Method not implemented'); } - public function newInstance($args) { throw new ReflectionException('Method not implemented'); } - public function newInstanceArgs(array $args = array()) { throw new ReflectionException('Method not implemented'); } - public function newInstanceWithoutConstructor() { throw new ReflectionException('Method not implemented'); } - public function setStaticPropertyValue($name, $value) { throw new ReflectionException('Method not implemented'); } - public function __toString() { throw new ReflectionException('Method not implemented'); } + /** + * {@inheritDoc} + */ + public static function export($argument, $return = false) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getConstant($name) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getConstants() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getConstructor() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getDefaultProperties() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getEndLine() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getExtension() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getExtensionName() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getFileName() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getInterfaceNames() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getInterfaces() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getMethods($filter = null) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getModifiers() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getParentClass() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getProperties($filter = null) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getShortName() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getStartLine() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getStaticProperties() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getStaticPropertyValue($name, $default = '') + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getTraitAliases() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getTraitNames() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getTraits() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function hasConstant($name) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function hasMethod($name) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function hasProperty($name) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function implementsInterface($interface) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function inNamespace() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isAbstract() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isCloneable() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isFinal() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isInstance($object) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isInstantiable() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isInterface() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isInternal() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isIterateable() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isSubclassOf($class) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isTrait() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isUserDefined() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function newInstance($args) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function newInstanceArgs(array $args = array()) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function newInstanceWithoutConstructor() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function setStaticPropertyValue($name, $value) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function __toString() + { + throw new ReflectionException('Method not implemented'); + } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php old mode 100755 new mode 100644 index 6482036e52..311e13044e --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php @@ -38,66 +38,325 @@ class StaticReflectionMethod extends ReflectionMethod */ protected $methodName; + /** + * @param StaticReflectionParser $staticReflectionParser + * @param string $methodName + */ public function __construct(StaticReflectionParser $staticReflectionParser, $methodName) { $this->staticReflectionParser = $staticReflectionParser; $this->methodName = $methodName; } + + /** + * {@inheritDoc} + */ public function getName() { return $this->methodName; } + + /** + * @return StaticReflectionParser + */ protected function getStaticReflectionParser() { return $this->staticReflectionParser->getStaticReflectionParserForDeclaringClass('method', $this->methodName); } + + /** + * {@inheritDoc} + */ public function getDeclaringClass() { return $this->getStaticReflectionParser()->getReflectionClass(); } + + /** + * {@inheritDoc} + */ public function getNamespaceName() { return $this->getStaticReflectionParser()->getNamespaceName(); } + + /** + * {@inheritDoc} + */ public function getDocComment() { return $this->getStaticReflectionParser()->getDocComment('method', $this->methodName); } + + /** + * @return array + */ public function getUseStatements() { return $this->getStaticReflectionParser()->getUseStatements(); } - public static function export($class, $name, $return = false) { throw new ReflectionException('Method not implemented'); } - public function getClosure($object) { throw new ReflectionException('Method not implemented'); } - public function getModifiers() { throw new ReflectionException('Method not implemented'); } - public function getPrototype() { throw new ReflectionException('Method not implemented'); } - public function invoke($object, $parameter = NULL) { throw new ReflectionException('Method not implemented'); } - public function invokeArgs($object, array $args) { throw new ReflectionException('Method not implemented'); } - public function isAbstract() { throw new ReflectionException('Method not implemented'); } - public function isConstructor() { throw new ReflectionException('Method not implemented'); } - public function isDestructor() { throw new ReflectionException('Method not implemented'); } - public function isFinal() { throw new ReflectionException('Method not implemented'); } - public function isPrivate() { throw new ReflectionException('Method not implemented'); } - public function isProtected() { throw new ReflectionException('Method not implemented'); } - public function isPublic() { throw new ReflectionException('Method not implemented'); } - public function isStatic() { throw new ReflectionException('Method not implemented'); } - public function setAccessible($accessible) { throw new ReflectionException('Method not implemented'); } - public function __toString() { throw new ReflectionException('Method not implemented'); } - public function getClosureThis() { throw new ReflectionException('Method not implemented'); } - public function getEndLine() { throw new ReflectionException('Method not implemented'); } - public function getExtension() { throw new ReflectionException('Method not implemented'); } - public function getExtensionName() { throw new ReflectionException('Method not implemented'); } - public function getFileName() { throw new ReflectionException('Method not implemented'); } - public function getNumberOfParameters() { throw new ReflectionException('Method not implemented'); } - public function getNumberOfRequiredParameters() { throw new ReflectionException('Method not implemented'); } - public function getParameters() { throw new ReflectionException('Method not implemented'); } - public function getShortName() { throw new ReflectionException('Method not implemented'); } - public function getStartLine() { throw new ReflectionException('Method not implemented'); } - public function getStaticVariables() { throw new ReflectionException('Method not implemented'); } - public function inNamespace() { throw new ReflectionException('Method not implemented'); } - public function isClosure() { throw new ReflectionException('Method not implemented'); } - public function isDeprecated() { throw new ReflectionException('Method not implemented'); } - public function isInternal() { throw new ReflectionException('Method not implemented'); } - public function isUserDefined() { throw new ReflectionException('Method not implemented'); } - public function returnsReference() { throw new ReflectionException('Method not implemented'); } + + /** + * {@inheritDoc} + */ + public static function export($class, $name, $return = false) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getClosure($object) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getModifiers() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getPrototype() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function invoke($object, $parameter = null) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function invokeArgs($object, array $args) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isAbstract() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isConstructor() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isDestructor() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isFinal() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isPrivate() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isProtected() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isPublic() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isStatic() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function setAccessible($accessible) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function __toString() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getClosureThis() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getEndLine() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getExtension() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getExtensionName() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getFileName() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getNumberOfParameters() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getNumberOfRequiredParameters() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getParameters() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getShortName() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getStartLine() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getStaticVariables() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function inNamespace() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isClosure() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isDeprecated() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isInternal() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isUserDefined() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function returnsReference() + { + throw new ReflectionException('Method not implemented'); + } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php old mode 100755 new mode 100644 index 7f3e41fecb..22a2c96548 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php @@ -29,37 +29,43 @@ use Doctrine\Common\Annotations\TokenParser; */ class StaticReflectionParser implements ReflectionProviderInterface { - /** - * The name of the class. + * The fully qualified class name. * * @var string */ protected $className; /** - * TRUE if the caller only wants class annotations. + * The short class name. + * + * @var string + */ + protected $shortClassName; + + /** + * Whether the caller only wants class annotations. * * @var boolean. */ protected $classAnnotationOptimize; /** - * TRUE when the parser has ran. + * Whether the parser has run. * * @var boolean */ protected $parsed = false; /** - * The namespace of the class + * The namespace of the class. * * @var string */ protected $namespace = ''; /** - * The use statements of this class. + * The use statements of the class. * * @var array */ @@ -73,7 +79,7 @@ class StaticReflectionParser implements ReflectionProviderInterface protected $docComment = array( 'class' => '', 'property' => array(), - 'method' => array(), + 'method' => array() ); /** @@ -86,31 +92,37 @@ class StaticReflectionParser implements ReflectionProviderInterface /** * The parent PSR-0 Parser. * - * @var \Doctrine\Common\Annotations\StaticReflectionParser + * @var \Doctrine\Common\Reflection\StaticReflectionParser */ protected $parentStaticReflectionParser; /** * Parses a class residing in a PSR-0 hierarchy. * - * @param string $class - * The full, namespaced class name. - * @param ClassFinder $finder - * A ClassFinder object which finds the class. - * @param boolean $classAnnotationOptimize - * Only retrieve the class docComment. Presumes there is only one - * statement per line. + * @param string $className The full, namespaced class name. + * @param ClassFinderInterface $finder A ClassFinder object which finds the class. + * @param boolean $classAnnotationOptimize Only retrieve the class docComment. + * Presumes there is only one statement per line. */ public function __construct($className, $finder, $classAnnotationOptimize = false) { $this->className = ltrim($className, '\\'); - if ($lastNsPos = strrpos($this->className, '\\')) { + $lastNsPos = strrpos($this->className, '\\'); + + if ($lastNsPos !== false) { $this->namespace = substr($this->className, 0, $lastNsPos); + $this->shortClassName = substr($this->className, $lastNsPos + 1); + } else { + $this->shortClassName = $this->className; } + $this->finder = $finder; $this->classAnnotationOptimize = $classAnnotationOptimize; } + /** + * @return void + */ protected function parse() { if ($this->parsed || !$fileName = $this->finder->findFile($this->className)) { @@ -119,7 +131,7 @@ class StaticReflectionParser implements ReflectionProviderInterface $this->parsed = true; $contents = file_get_contents($fileName); if ($this->classAnnotationOptimize) { - if (preg_match("/(\A.*)^\s+(abstract|final)?\s+class\s+$className\s+{/sm", $contents, $matches)) { + if (preg_match("/(\A.*)^\s+(abstract|final)?\s+class\s+{$this->shortClassName}\s+{/sm", $contents, $matches)) { $contents = $matches[1]; } } @@ -192,6 +204,9 @@ class StaticReflectionParser implements ReflectionProviderInterface } } + /** + * @return StaticReflectionParser + */ protected function getParentStaticReflectionParser() { if (empty($this->parentStaticReflectionParser)) { @@ -201,18 +216,24 @@ class StaticReflectionParser implements ReflectionProviderInterface return $this->parentStaticReflectionParser; } + /** + * @return string + */ public function getClassName() { return $this->className; } + /** + * @return string + */ public function getNamespaceName() { return $this->namespace; } /** - * Get the ReflectionClass equivalent for this file / class. + * {@inheritDoc} */ public function getReflectionClass() { @@ -220,7 +241,7 @@ class StaticReflectionParser implements ReflectionProviderInterface } /** - * Get the ReflectionMethod equivalent for the method of this file / class. + * {@inheritDoc} */ public function getReflectionMethod($methodName) { @@ -228,7 +249,7 @@ class StaticReflectionParser implements ReflectionProviderInterface } /** - * Get the ReflectionProperty equivalent for the method of this file / class. + * {@inheritDoc} */ public function getReflectionProperty($propertyName) { @@ -236,7 +257,9 @@ class StaticReflectionParser implements ReflectionProviderInterface } /** - * Get the use statements from this file. + * Gets the use statements from this file. + * + * @return array */ public function getUseStatements() { @@ -246,12 +269,12 @@ class StaticReflectionParser implements ReflectionProviderInterface } /** - * Get docComment. + * Gets the doc comment. * - * @param string $type class, property or method. - * @param string $name Name of the property or method, not needed for class. + * @param string $type The type: 'class', 'property' or 'method'. + * @param string $name The name of the property or method, not needed for 'class'. * - * @return string the doc comment or empty string if none. + * @return string The doc comment, empty string if none. */ public function getDocComment($type = 'class', $name = '') { @@ -261,12 +284,14 @@ class StaticReflectionParser implements ReflectionProviderInterface } /** - * Get the PSR-0 parser for the declaring class. + * Gets the PSR-0 parser for the declaring class. * - * @param string $type property or method. - * @param string $name Name of the property or method. + * @param string $type The type: 'property' or 'method'. + * @param string $name The name of the property or method. * * @return StaticReflectionParser A static reflection parser for the declaring class. + * + * @throws ReflectionException */ public function getStaticReflectionParserForDeclaringClass($type, $name) { diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php old mode 100755 new mode 100644 index 7c6411a9d0..1664822033 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php @@ -34,44 +34,145 @@ class StaticReflectionProperty extends ReflectionProperty /** * The name of the property. * - * @var string + * @var string|null */ protected $propertyName; + /** + * @param StaticReflectionParser $staticReflectionParser + * @param string|null $propertyName + */ public function __construct(StaticReflectionParser $staticReflectionParser, $propertyName) { $this->staticReflectionParser = $staticReflectionParser; $this->propertyName = $propertyName; } + + /** + * {@inheritDoc} + */ public function getName() { return $this->propertyName; } + + /** + * @return StaticReflectionParser + */ protected function getStaticReflectionParser() { return $this->staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', $this->propertyName); } + + /** + * {@inheritDoc} + */ public function getDeclaringClass() { return $this->getStaticReflectionParser()->getReflectionClass(); } + + /** + * {@inheritDoc} + */ public function getDocComment() { return $this->getStaticReflectionParser()->getDocComment('property', $this->propertyName); } + + /** + * @return array + */ public function getUseStatements() { return $this->getStaticReflectionParser()->getUseStatements(); } - public static function export ($class, $name, $return = false) { throw new ReflectionException('Method not implemented'); } - public function getModifiers() { throw new ReflectionException('Method not implemented'); } - public function getValue($object = NULL) { throw new ReflectionException('Method not implemented'); } - public function isDefault() { throw new ReflectionException('Method not implemented'); } - public function isPrivate() { throw new ReflectionException('Method not implemented'); } - public function isProtected() { throw new ReflectionException('Method not implemented'); } - public function isPublic() { throw new ReflectionException('Method not implemented'); } - public function isStatic() { throw new ReflectionException('Method not implemented'); } - public function setAccessible ($accessible) { throw new ReflectionException('Method not implemented'); } - public function setValue ($object, $value = NULL) { throw new ReflectionException('Method not implemented'); } - public function __toString() { throw new ReflectionException('Method not implemented'); } + + /** + * {@inheritDoc} + */ + public static function export ($class, $name, $return = false) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getModifiers() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getValue($object = null) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isDefault() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isPrivate() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isProtected() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isPublic() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isStatic() + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function setAccessible ($accessible) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function setValue ($object, $value = null) + { + throw new ReflectionException('Method not implemented'); + } + + /** + * {@inheritDoc} + */ + public function __toString() + { + throw new ReflectionException('Method not implemented'); + } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Util/ClassUtils.php b/vendor/doctrine/common/lib/Doctrine/Common/Util/ClassUtils.php old mode 100755 new mode 100644 index 078a8dba05..49dc7bb172 --- a/vendor/doctrine/common/lib/Doctrine/Common/Util/ClassUtils.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Util/ClassUtils.php @@ -31,9 +31,10 @@ use Doctrine\Common\Persistence\Proxy; class ClassUtils { /** - * Get the real class name of a class name that could be a proxy. + * Gets the real class name of a class name that could be a proxy. + * + * @param string $class * - * @param string * @return string */ public static function getRealClass($class) @@ -46,9 +47,10 @@ class ClassUtils } /** - * Get the real class name of an object (even if its a proxy) + * Gets the real class name of an object (even if its a proxy). + * + * @param object $object * - * @param object * @return string */ public static function getClass($object) @@ -57,9 +59,10 @@ class ClassUtils } /** - * Get the real parent class name of a class or object + * Gets the real parent class name of a class or object. + * + * @param string $className * - * @param string * @return string */ public static function getParentClass($className) @@ -68,9 +71,10 @@ class ClassUtils } /** - * Create a new reflection class + * Creates a new reflection class. + * + * @param string $class * - * @param string * @return \ReflectionClass */ public static function newReflectionClass($class) @@ -79,9 +83,10 @@ class ClassUtils } /** - * Create a new reflection object + * Creates a new reflection object. + * + * @param object $object * - * @param object * @return \ReflectionObject */ public static function newReflectionObject($object) @@ -90,10 +95,11 @@ class ClassUtils } /** - * Given a class name and a proxy namespace return the proxy name. + * Given a class name and a proxy namespace returns the proxy name. * * @param string $className * @param string $proxyNamespace + * * @return string */ public static function generateProxyClassName($className, $proxyNamespace) diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php b/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php old mode 100755 new mode 100644 index 458e5c8848..8f25c9ab20 --- a/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php @@ -19,32 +19,35 @@ namespace Doctrine\Common\Util; +use Doctrine\Common\Persistence\Proxy; + /** * Static class containing most used debug methods. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Giorgio Sironi + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Giorgio Sironi */ final class Debug { /** - * Private constructor (prevents from instantiation) - * + * Private constructor (prevents instantiation). */ - private function __construct() {} + private function __construct() + { + } /** * Prints a dump of the public, protected and private properties of $var. * * @link http://xdebug.org/ - * @param mixed $var - * @param integer $maxDepth Maximum nesting level for object properties - * @param boolean $stripTags Flag that indicate if output should strip HTML tags + * + * @param mixed $var The variable to dump. + * @param integer $maxDepth The maximum nesting level for object properties. + * @param boolean $stripTags Whether output should strip HTML tags. */ public static function dump($var, $maxDepth = 2, $stripTags = true) { @@ -67,10 +70,9 @@ final class Debug } /** - * Export - * * @param mixed $var - * @param int $maxDepth + * @param int $maxDepth + * * @return mixed */ public static function export($var, $maxDepth) @@ -99,11 +101,15 @@ final class Debug $reflClass = ClassUtils::newReflectionObject($var); $return->__CLASS__ = ClassUtils::getClass($var); - if ($var instanceof \Doctrine\Common\Persistence\Proxy) { + if ($var instanceof Proxy) { $return->__IS_PROXY__ = true; $return->__PROXY_INITIALIZED__ = $var->__isInitialized(); } + if ($var instanceof \ArrayObject || $var instanceof \ArrayIterator) { + $return->__STORAGE__ = self::export($var->getArrayCopy(), $maxDepth - 1); + } + foreach ($reflClass->getProperties() as $reflProperty) { $name = $reflProperty->getName(); @@ -123,13 +129,14 @@ final class Debug } /** - * Convert to string + * Returns a string representation of an object. * * @param object $obj + * * @return string */ public static function toString($obj) { - return method_exists('__toString', $obj) ? (string) $obj : get_class($obj) . '@' . spl_object_hash($obj); + return method_exists($obj, '__toString') ? (string) $obj : get_class($obj) . '@' . spl_object_hash($obj); } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Util/Inflector.php b/vendor/doctrine/common/lib/Doctrine/Common/Util/Inflector.php old mode 100755 new mode 100644 index 214ed57449..082dc78944 --- a/vendor/doctrine/common/lib/Doctrine/Common/Util/Inflector.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Util/Inflector.php @@ -1,7 +1,5 @@ - * @author Jonathan H. Wage + * Kept for backwards compatibility reasons, was moved to its own component. */ -class Inflector +class Inflector extends BaseInflector { - /** - * Convert word in to the format for a Doctrine table name. Converts 'ModelName' to 'model_name' - * - * @param string $word Word to tableize - * @return string $word Tableized word - */ - public static function tableize($word) - { - return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word)); - } - - /** - * Convert a word in to the format for a Doctrine class name. Converts 'table_name' to 'TableName' - * - * @param string $word Word to classify - * @return string $word Classified word - */ - public static function classify($word) - { - return str_replace(" ", "", ucwords(strtr($word, "_-", " "))); - } - - /** - * Camelize a word. This uses the classify() method and turns the first character to lowercase - * - * @param string $word - * @return string $word - */ - public static function camelize($word) - { - return lcfirst(self::classify($word)); - } } diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Version.php b/vendor/doctrine/common/lib/Doctrine/Common/Version.php old mode 100755 new mode 100644 index cca4894dfc..f23a461ab2 --- a/vendor/doctrine/common/lib/Doctrine/Common/Version.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Version.php @@ -20,30 +20,28 @@ namespace Doctrine\Common; /** - * Class to store and retrieve the version of Doctrine + * Class to store and retrieve the version of Doctrine. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class Version { /** - * Current Doctrine Version + * Current Doctrine Version. */ - const VERSION = '2.3.0'; + const VERSION = '2.4.1'; /** * Compares a Doctrine version with the current one. * * @param string $version Doctrine version to compare. - * @return int Returns -1 if older, 0 if it is the same, 1 if version - * passed as argument is newer. + * + * @return int -1 if older, 0 if it is the same, 1 if version passed as argument is newer. */ public static function compare($version) { diff --git a/vendor/doctrine/common/phpunit.xml.dist b/vendor/doctrine/common/phpunit.xml.dist old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/.gitignore b/vendor/doctrine/common/tests/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/CacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/CacheTest.php deleted file mode 100755 index 1bbc165053..0000000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/CacheTest.php +++ /dev/null @@ -1,91 +0,0 @@ -_getCacheDriver(); - - // Test save - $cache->save('test_key', 'testing this out'); - - // Test contains to test that save() worked - $this->assertTrue($cache->contains('test_key')); - - // Test fetch - $this->assertEquals('testing this out', $cache->fetch('test_key')); - - // Test delete - $cache->save('test_key2', 'test2'); - $cache->delete('test_key2'); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testObjects() - { - $cache = $this->_getCacheDriver(); - - // Fetch/save test with objects (Is cache driver serializes/unserializes objects correctly ?) - $cache->save('test_object_key', new \ArrayObject()); - $this->assertTrue($cache->fetch('test_object_key') instanceof \ArrayObject); - } - - public function testDeleteAll() - { - $cache = $this->_getCacheDriver(); - $cache->save('test_key1', '1'); - $cache->save('test_key2', '2'); - $cache->deleteAll(); - - $this->assertFalse($cache->contains('test_key1')); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testFlushAll() - { - $cache = $this->_getCacheDriver(); - $cache->save('test_key1', '1'); - $cache->save('test_key2', '2'); - $cache->flushAll(); - - $this->assertFalse($cache->contains('test_key1')); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testNamespace() - { - $cache = $this->_getCacheDriver(); - $cache->setNamespace('test_'); - $cache->save('key1', 'test'); - - $this->assertTrue($cache->contains('key1')); - - $cache->setNamespace('test2_'); - - $this->assertFalse($cache->contains('key1')); - } - - /** - * @group DCOM-43 - */ - public function testGetStats() - { - $cache = $this->_getCacheDriver(); - $stats = $cache->getStats(); - - $this->assertArrayHasKey(Cache::STATS_HITS, $stats); - $this->assertArrayHasKey(Cache::STATS_MISSES, $stats); - $this->assertArrayHasKey(Cache::STATS_UPTIME, $stats); - $this->assertArrayHasKey(Cache::STATS_MEMORY_USAGE, $stats); - $this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILIABLE, $stats); - } - - /** - * @return \Doctrine\Common\Cache\CacheProvider - */ - abstract protected function _getCacheDriver(); -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php old mode 100755 new mode 100644 index 567cf91852..1eb2216b69 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php @@ -42,4 +42,23 @@ class ClassLoaderTest extends \Doctrine\Tests\DoctrineTestCase $this->assertNull(ClassLoader::getClassLoader('This\Class\Does\Not\Exist')); $cl->unregister(); } + + public function testClassExistsWithSilentAutoloader() + { + $test = $this; + $silentLoader = function ($className) use ($test) { + $test->assertSame('ClassLoaderTest\ClassE', $className); + require __DIR__ . '/ClassLoaderTest/ClassE.php'; + }; + $additionalLoader = function () use ($test) { + $test->fail('Should not call this loader, class was already loaded'); + }; + + $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\ClassE')); + spl_autoload_register($silentLoader); + spl_autoload_register($additionalLoader); + $this->assertTrue(ClassLoader::classExists('ClassLoaderTest\ClassE')); + spl_autoload_unregister($additionalLoader); + spl_autoload_unregister($silentLoader); + } } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassB.class.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassB.class.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassC.class.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassC.class.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassD.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassD.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassE.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassE.php new file mode 100644 index 0000000000..f7a0811301 --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassE.php @@ -0,0 +1,5 @@ +getMock('Doctrine\Common\Peristence\ClassMetadata'); + $classMetadata = $this->getMock('Doctrine\Common\Persistence\ClassMetadata'); $chain = new MappingDriverChain(); @@ -93,7 +93,7 @@ class DriverChainTest extends DoctrineTestCase public function testDefaultDriver() { $companyDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $dafaultDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $defaultDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); $entityClassName = 'Doctrine\Tests\ORM\Mapping\DriverChainEntity'; $managerClassName = 'Doctrine\Tests\Models\Company\CompanyManager'; $chain = new MappingDriverChain(); @@ -105,26 +105,48 @@ class DriverChainTest extends DoctrineTestCase ->with($this->equalTo($managerClassName)) ->will($this->returnValue(false)); - $dafaultDriver->expects($this->never()) + $defaultDriver->expects($this->never()) ->method('loadMetadataForClass'); - $dafaultDriver->expects($this->once()) + $defaultDriver->expects($this->once()) ->method('isTransient') ->with($this->equalTo($entityClassName)) ->will($this->returnValue(true)); $this->assertNull($chain->getDefaultDriver()); - $chain->setDefaultDriver($dafaultDriver); + $chain->setDefaultDriver($defaultDriver); $chain->addDriver($companyDriver, 'Doctrine\Tests\Models\Company'); - $this->assertSame($dafaultDriver, $chain->getDefaultDriver()); + $this->assertSame($defaultDriver, $chain->getDefaultDriver()); $this->assertTrue($chain->isTransient($entityClassName)); $this->assertFalse($chain->isTransient($managerClassName)); } + + public function testDefaultDriverGetAllClassNames() + { + $companyDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $defaultDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $chain = new MappingDriverChain(); + + $companyDriver->expects($this->once()) + ->method('getAllClassNames') + ->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo'))); + + $defaultDriver->expects($this->once()) + ->method('getAllClassNames') + ->will($this->returnValue(array('Other\Class'))); + + $chain->setDefaultDriver($defaultDriver); + $chain->addDriver($companyDriver, 'Doctrine\Tests\Models\Company'); + + $classNames = $chain->getAllClassNames(); + + $this->assertEquals(array('Doctrine\Tests\Models\Company\Foo', 'Other\Class'), $classNames); + } } class DriverChainEntity { -} \ No newline at end of file +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php old mode 100755 new mode 100644 index bc1559af14..c5a457f682 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php @@ -39,6 +39,12 @@ class ClassMetadataFactoryTest extends DoctrineTestCase $this->assertTrue($this->cmf->hasMetadataFor('stdClass')); } + public function testGetMetadataForAbsentClass() + { + $this->setExpectedException('Doctrine\Common\Persistence\Mapping\MappingException'); + $this->cmf->getMetadataFor(__NAMESPACE__ . '\AbsentClass'); + } + public function testGetParentMetadata() { $metadata = $this->cmf->getMetadataFor(__NAMESPACE__ . '\ChildEntity'); diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php old mode 100755 new mode 100644 index 5f06cad984..767ccd6394 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php @@ -13,7 +13,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ @@ -26,8 +26,13 @@ use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; */ class RuntimeReflectionServiceTest extends \PHPUnit_Framework_TestCase { + /** + * @var RuntimeReflectionService + */ private $reflectionService; + public $unusedPublicProperty; + public function setUp() { $this->reflectionService = new RuntimeReflectionService(); @@ -49,6 +54,12 @@ class RuntimeReflectionServiceTest extends \PHPUnit_Framework_TestCase $this->assertTrue(count($classes) >= 1, "The test class ".__CLASS__." should have at least one parent."); } + public function testGetParentClassesForAbsentClass() + { + $this->setExpectedException('Doctrine\Common\Persistence\Mapping\MappingException'); + $this->reflectionService->getParentClasses(__NAMESPACE__ . '\AbsentClass'); + } + public function testGetReflectionClass() { $class = $this->reflectionService->getClass(__CLASS__); @@ -65,6 +76,9 @@ class RuntimeReflectionServiceTest extends \PHPUnit_Framework_TestCase { $reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "reflectionService"); $this->assertInstanceOf("ReflectionProperty", $reflProp); + + $reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "unusedPublicProperty"); + $this->assertInstanceOf("Doctrine\Common\Reflection\RuntimePublicReflectionProperty", $reflProp); } } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php old mode 100755 new mode 100644 index ffce6d40a1..1dd7a7afdc --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php @@ -13,7 +13,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/ObjectManagerDecoratorTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/ObjectManagerDecoratorTest.php new file mode 100644 index 0000000000..768b4d30e7 --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/ObjectManagerDecoratorTest.php @@ -0,0 +1,60 @@ +wrapped = $wrapped; + } +} + +class ObjectManagerDecoratorTest extends \PHPUnit_Framework_TestCase +{ + private $wrapped; + private $decorated; + + public function setUp() + { + $this->wrapped = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); + $this->decorated = new NullObjectManagerDecorator($this->wrapped); + } + + public function getMethodParameters() + { + $class = new \ReflectionClass('Doctrine\Common\Persistence\ObjectManager'); + + $methods = array(); + foreach ($class->getMethods() as $method) { + if ($method->getNumberOfRequiredParameters() === 0) { + $methods[] = array($method->getName(), array()); + } elseif ($method->getNumberOfRequiredParameters() > 0) { + $methods[] = array($method->getName(), array_fill(0, $method->getNumberOfRequiredParameters(), 'req') ?: array()); + } + if ($method->getNumberOfParameters() != $method->getNumberOfRequiredParameters()) { + $methods[] = array($method->getName(), array_fill(0, $method->getNumberOfParameters(), 'all') ?: array()); + } + } + + return $methods; + } + + /** + * @dataProvider getMethodParameters + */ + public function testAllMethodCallsAreDelegatedToTheWrappedInstance($method, array $parameters) + { + $stub = $this->wrapped + ->expects($this->once()) + ->method($method) + ->will($this->returnValue('INNER VALUE FROM ' . $method)); + + call_user_func_array(array($stub, 'with'), $parameters); + + $this->assertSame('INNER VALUE FROM ' . $method, call_user_func_array(array($this->decorated, $method), $parameters)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php old mode 100755 new mode 100644 index a0f77b5068..180d0f0d00 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php @@ -84,7 +84,7 @@ class PersistentObjectTest extends \Doctrine\Tests\DoctrineTestCase $this->assertSame($parent, $this->object->getParent($parent)); } - public function testSetInvalidToOneAssocation() + public function testSetInvalidToOneAssociation() { $parent = new \stdClass(); @@ -100,7 +100,7 @@ class PersistentObjectTest extends \Doctrine\Tests\DoctrineTestCase $this->assertNull($this->object->getParent()); } - public function testAddToManyAssocation() + public function testAddToManyAssociation() { $child = new TestObject(); $this->object->addChildren($child); @@ -114,7 +114,7 @@ class PersistentObjectTest extends \Doctrine\Tests\DoctrineTestCase $this->assertEquals(2, count($this->object->getChildren())); } - public function testAddInvalidToManyAssocation() + public function testAddInvalidToManyAssociation() { $this->setExpectedException('InvalidArgumentException'); $this->object->addChildren(new \stdClass()); diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/AbstractProxyFactoryTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/AbstractProxyFactoryTest.php new file mode 100644 index 0000000000..8aa966d9a1 --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/AbstractProxyFactoryTest.php @@ -0,0 +1,118 @@ +getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $proxyGenerator = $this->getMock('Doctrine\Common\Proxy\ProxyGenerator', array(), array(), '', false); + + $proxyGenerator + ->expects($this->once()) + ->method('getProxyFileName'); + $proxyGenerator + ->expects($this->once()) + ->method('generateProxyClass'); + + $metadataFactory = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory'); + $proxyFactory = $this->getMockForAbstractClass( + 'Doctrine\Common\Proxy\AbstractProxyFactory', + array($proxyGenerator, $metadataFactory, true) + ); + + $proxyFactory + ->expects($this->any()) + ->method('skipClass') + ->will($this->returnValue(false)); + + $generated = $proxyFactory->generateProxyClasses(array($metadata), sys_get_temp_dir()); + + $this->assertEquals(1, $generated, 'One proxy was generated'); + } + + public function testGetProxy() + { + $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $proxy = $this->getMock('Doctrine\Common\Proxy\Proxy'); + $definition = new ProxyDefinition(get_class($proxy), array(), array(), null, null); + $proxyGenerator = $this->getMock('Doctrine\Common\Proxy\ProxyGenerator', array(), array(), '', false); + $metadataFactory = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory'); + + $metadataFactory + ->expects($this->once()) + ->method('getMetadataFor') + ->will($this->returnValue($metadata)); + + $proxyFactory = $this->getMockForAbstractClass( + 'Doctrine\Common\Proxy\AbstractProxyFactory', + array($proxyGenerator, $metadataFactory, true) + ); + + $proxyFactory + ->expects($this->any()) + ->method('createProxyDefinition') + ->will($this->returnValue($definition)); + + $generatedProxy = $proxyFactory->getProxy('Class', array('id' => 1)); + + $this->assertInstanceOf(get_class($proxy), $generatedProxy); + } + + public function testResetUnitializedProxy() + { + $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $proxy = $this->getMock('Doctrine\Common\Proxy\Proxy'); + $definition = new ProxyDefinition(get_class($proxy), array(), array(), null, null); + $proxyGenerator = $this->getMock('Doctrine\Common\Proxy\ProxyGenerator', array(), array(), '', false); + $metadataFactory = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory'); + + $metadataFactory + ->expects($this->once()) + ->method('getMetadataFor') + ->will($this->returnValue($metadata)); + + $proxyFactory = $this->getMockForAbstractClass( + 'Doctrine\Common\Proxy\AbstractProxyFactory', + array($proxyGenerator, $metadataFactory, true) + ); + + $proxyFactory + ->expects($this->any()) + ->method('createProxyDefinition') + ->will($this->returnValue($definition)); + + $proxy + ->expects($this->once()) + ->method('__isInitialized') + ->will($this->returnValue(false)); + $proxy + ->expects($this->once()) + ->method('__setInitializer'); + $proxy + ->expects($this->once()) + ->method('__setCloner'); + + $proxyFactory->resetUninitializedProxy($proxy); + } + + public function testDisallowsResettingInitializedProxy() + { + $proxyFactory = $this->getMockForAbstractClass('Doctrine\Common\Proxy\AbstractProxyFactory', array(), '', false); + $proxy = $this->getMock('Doctrine\Common\Proxy\Proxy'); + + $proxy + ->expects($this->any()) + ->method('__isInitialized') + ->will($this->returnValue(true)); + + $this->setExpectedException('Doctrine\Common\Proxy\Exception\InvalidArgumentException'); + + $proxyFactory->resetUninitializedProxy($proxy); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/AutoloaderTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/AutoloaderTest.php old mode 100755 new mode 100644 similarity index 79% rename from vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/AutoloaderTest.php rename to vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/AutoloaderTest.php index af0afec35f..be713fcd28 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/AutoloaderTest.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/AutoloaderTest.php @@ -13,21 +13,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ -namespace Doctrine\Tests\ORM\Proxy; +namespace Doctrine\Tests\Common\Proxy; -use Doctrine\Tests\OrmTestCase; -use Doctrine\ORM\Proxy\Autoloader; +use PHPUnit_Framework_TestCase; +use Doctrine\Common\Proxy\Autoloader; /** * @group DDC-1698 */ -class AutoloaderTest extends OrmTestCase +class AutoloaderTest extends PHPUnit_Framework_TestCase { - static public function dataResolveFile() + public static function dataResolveFile() { return array( array('/tmp', 'MyProxy', 'MyProxy\__CG__\RealClass', '/tmp' . DIRECTORY_SEPARATOR . '__CG__RealClass.php'), @@ -58,5 +58,15 @@ class AutoloaderTest extends OrmTestCase $this->assertTrue(class_exists('ProxyAutoloaderTest\AutoloaderTestClass', true)); unlink(sys_get_temp_dir() ."/AutoloaderTestClass.php"); } + + public function testRegisterWithInvalidCallback() + { + $this->setExpectedException( + 'Doctrine\Common\Proxy\Exception\InvalidArgumentException', + 'Invalid \$notFoundCallback given: must be a callable, "stdClass" given' + ); + + Autoloader::register('', '', new \stdClass()); + } } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/CallableTypeHintClass.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/CallableTypeHintClass.php new file mode 100644 index 0000000000..f5fccb0dc0 --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/CallableTypeHintClass.php @@ -0,0 +1,16 @@ +. + */ + +namespace Doctrine\Tests\Common\Proxy; + +/** + * Test asset representing a lazy loadable object + * + * @author Marco Pivetta + * @since 2.4 + */ +class LazyLoadableObject +{ + /** + * @var string + */ + public $publicIdentifierField; + + /** + * @var string + */ + protected $protectedIdentifierField; + + /** + * @var string + */ + public $publicTransientField = 'publicTransientFieldValue'; + + /** + * @var string + */ + protected $protectedTransientField = 'protectedTransientFieldValue'; + + /** + * @var string + */ + public $publicPersistentField = 'publicPersistentFieldValue'; + + /** + * @var string + */ + protected $protectedPersistentField = 'protectedPersistentFieldValue'; + + /** + * @var string + */ + public $publicAssociation = 'publicAssociationValue'; + + /** + * @var string + */ + protected $protectedAssociation = 'protectedAssociationValue'; + + /** + * @return string + */ + public function getProtectedIdentifierField() + { + return $this->protectedIdentifierField; + } + + /** + * @return string + */ + public function testInitializationTriggeringMethod() + { + return 'testInitializationTriggeringMethod'; + } + + /** + * @return string + */ + public function getProtectedAssociation() + { + return $this->protectedAssociation; + } + + /** + * @param \stdClass $param + */ + public function publicTypeHintedMethod(\stdClass $param) + { + } + + /** + * + */ + public function &byRefMethod() + { + } + + /** + * @param mixed $thisIsNotByRef + * @param &mixed $thisIsByRef + */ + public function byRefParamMethod($thisIsNotByRef, &$thisIsByRef) + { + } +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/LazyLoadableObjectClassMetadata.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/LazyLoadableObjectClassMetadata.php new file mode 100644 index 0000000000..167386e35d --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/LazyLoadableObjectClassMetadata.php @@ -0,0 +1,195 @@ +. + */ + +namespace Doctrine\Tests\Common\Proxy; + +use ReflectionClass; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; + +/** + * Class metadata test asset for @see LazyLoadableObject + * + * @author Marco Pivetta + * @since 2.4 + */ +class LazyLoadableObjectClassMetadata implements ClassMetadata +{ + /** + * @var ReflectionClass + */ + protected $reflectionClass; + + /** + * @var array + */ + protected $identifier = array( + 'publicIdentifierField' => true, + 'protectedIdentifierField' => true, + ); + + /** + * @var array + */ + protected $fields = array( + 'publicIdentifierField' => true, + 'protectedIdentifierField' => true, + 'publicPersistentField' => true, + 'protectedPersistentField' => true, + ); + + /** + * @var array + */ + protected $associations = array( + 'publicAssociation' => true, + 'protectedAssociation' => true, + ); + + /** + * {@inheritDoc} + */ + public function getName() + { + return $this->getReflectionClass()->getName(); + } + + /** + * {@inheritDoc} + */ + public function getIdentifier() + { + return array_keys($this->identifier); + } + + /** + * {@inheritDoc} + */ + public function getReflectionClass() + { + if (null === $this->reflectionClass) { + $this->reflectionClass = new \ReflectionClass(__NAMESPACE__ . '\LazyLoadableObject'); + } + + return $this->reflectionClass; + } + + /** + * {@inheritDoc} + */ + public function isIdentifier($fieldName) + { + return isset($this->identifier[$fieldName]); + } + + /** + * {@inheritDoc} + */ + public function hasField($fieldName) + { + return isset($this->fields[$fieldName]); + } + + /** + * {@inheritDoc} + */ + public function hasAssociation($fieldName) + { + return isset($this->associations[$fieldName]); + } + + /** + * {@inheritDoc} + */ + public function isSingleValuedAssociation($fieldName) + { + throw new \BadMethodCallException('not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isCollectionValuedAssociation($fieldName) + { + throw new \BadMethodCallException('not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getFieldNames() + { + return array_keys($this->fields); + } + + /** + * {@inheritDoc} + */ + public function getIdentifierFieldNames() + { + return $this->getIdentifier(); + } + + /** + * {@inheritDoc} + */ + public function getAssociationNames() + { + return array_keys($this->associations); + } + + /** + * {@inheritDoc} + */ + public function getTypeOfField($fieldName) + { + return 'string'; + } + + /** + * {@inheritDoc} + */ + public function getAssociationTargetClass($assocName) + { + throw new \BadMethodCallException('not implemented'); + } + + /** + * {@inheritDoc} + */ + public function isAssociationInverseSide($assocName) + { + throw new \BadMethodCallException('not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getAssociationMappedByTargetField($assocName) + { + throw new \BadMethodCallException('not implemented'); + } + + /** + * {@inheritDoc} + */ + public function getIdentifierValues($object) + { + throw new \BadMethodCallException('not implemented'); + } +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicCloneClass.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicCloneClass.php new file mode 100644 index 0000000000..33b983dc67 --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicCloneClass.php @@ -0,0 +1,37 @@ +clonedValue = 'newClonedValue'; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicGetByRefClass.php old mode 100755 new mode 100644 similarity index 64% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php rename to vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicGetByRefClass.php index f0db778b81..6adf1f5741 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicGetByRefClass.php @@ -13,29 +13,39 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ -namespace Doctrine\Tests\Models\DirectoryTree; +namespace Doctrine\Tests\Common\Proxy; + +use InvalidArgumentException; /** - * @Entity + * Test asset class + * + * @since 2.4 */ -class Directory extends AbstractContentItem +class MagicGetByRefClass { /** - * @Column(type="string") + * @var mixed */ - protected $path; + public $valueField; - public function setPath($path) + /** + * @param string $name + * + * @return mixed + * + * @throws \InvalidArgumentException + */ + public function & __get($name) { - $this->path = $path; - } + if ($name === 'value') { + return $this->valueField; + } - public function getPath() - { - return $this->path; + throw new InvalidArgumentException(); } } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicGetClass.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicGetClass.php new file mode 100644 index 0000000000..0cab36a961 --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicGetClass.php @@ -0,0 +1,38 @@ +testAttribute = $value; + } + + if ($name === 'publicField' || $name === 'id') { + throw new \BadMethodCallException('Should never be called for "publicField" or "id"'); + } + + $this->testAttribute = $value; + } +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicSleepClass.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicSleepClass.php new file mode 100644 index 0000000000..3934a05e7c --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/MagicSleepClass.php @@ -0,0 +1,37 @@ +wakeupValue = 'newWakeupValue'; + } +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyClassGeneratorTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyClassGeneratorTest.php new file mode 100644 index 0000000000..4d5a6134a0 --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyClassGeneratorTest.php @@ -0,0 +1,209 @@ +. + */ + + +namespace Doctrine\Tests\Common\Proxy; + +use Doctrine\Common\Proxy\ProxyGenerator; +use ReflectionClass; +use ReflectionMethod; +use PHPUnit_Framework_TestCase; + +/** + * Test the proxy generator. Its work is generating on-the-fly subclasses of a given model, which implement the Proxy + * pattern. + * + * @author Giorgio Sironi + * @author Marco Pivetta + */ +class ProxyClassGeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @var string + */ + protected $proxyClass = 'Doctrine\Tests\Common\ProxyProxy\__CG__\Doctrine\Tests\Common\Proxy\LazyLoadableObject'; + + /** + * @var LazyLoadableObjectClassMetadata + */ + protected $metadata; + + /** + * @var ProxyGenerator + */ + protected $proxyGenerator; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->metadata = new LazyLoadableObjectClassMetadata(); + $this->proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true); + + if (class_exists($this->proxyClass, false)) { + return; + } + + $this->generateAndRequire($this->proxyGenerator, $this->metadata); + } + + public function testReferenceProxyRespectsMethodsParametersTypeHinting() + { + $method = new ReflectionMethod($this->proxyClass, 'publicTypeHintedMethod'); + $params = $method->getParameters(); + + $this->assertEquals(1, count($params)); + $this->assertEquals('stdClass', $params[0]->getClass()->getName()); + } + + public function testProxyRespectsMethodsWhichReturnValuesByReference() + { + $method = new ReflectionMethod($this->proxyClass, 'byRefMethod'); + + $this->assertTrue($method->returnsReference()); + } + + public function testProxyRespectsByRefMethodParameters() + { + $method = new ReflectionMethod($this->proxyClass, 'byRefParamMethod'); + $parameters = $method->getParameters(); + $this->assertSame('thisIsNotByRef', $parameters[0]->getName()); + $this->assertFalse($parameters[0]->isPassedByReference()); + $this->assertSame('thisIsByRef', $parameters[1]->getName()); + $this->assertTrue($parameters[1]->isPassedByReference()); + } + + public function testCreatesAssociationProxyAsSubclassOfTheOriginalOne() + { + $this->assertTrue(is_subclass_of($this->proxyClass, $this->metadata->getName())); + } + + public function testNonNamespacedProxyGeneration() + { + $classCode = file_get_contents($this->proxyGenerator->getProxyFileName($this->metadata->getName())); + + $this->assertNotContains("class LazyLoadableObject extends \\\\" . $this->metadata->getName(), $classCode); + $this->assertContains("class LazyLoadableObject extends \\" . $this->metadata->getName(), $classCode); + } + + public function testClassWithSleepProxyGeneration() + { + if (!class_exists('Doctrine\Tests\Common\ProxyProxy\__CG__\SleepClass', false)) { + $className = 'Doctrine\Tests\Common\Proxy\SleepClass'; + $metadata = $this->createClassMetadata($className, array('id')); + $proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true); + + $this->generateAndRequire($proxyGenerator, $metadata); + } + + $classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxySleepClass.php'); + $this->assertEquals(1, substr_count($classCode, 'function __sleep')); + $this->assertEquals(1, substr_count($classCode, 'parent::__sleep()')); + } + + private function generateAndRequire($proxyGenerator, $metadata) + { + $proxyGenerator->generateProxyClass($metadata, $proxyGenerator->getProxyFileName($metadata->getName())); + + require_once $proxyGenerator->getProxyFileName($metadata->getName()); + } + + public function testClassWithCallableTypeHintOnProxiedMethod() + { + if (PHP_VERSION_ID < 50400) { + $this->markTestSkipped('`callable` is only supported in PHP >=5.4.0'); + } + + if (!class_exists('Doctrine\Tests\Common\ProxyProxy\__CG__\CallableTypeHintClass', false)) { + $className = 'Doctrine\Tests\Common\Proxy\CallableTypeHintClass'; + $metadata = $this->createClassMetadata($className, array('id')); + + $proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true); + $this->generateAndRequire($proxyGenerator, $metadata); + } + + $classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyCallableTypeHintClass.php'); + + $this->assertEquals(1, substr_count($classCode, 'call(callable $foo)')); + } + + public function testClassWithInvalidTypeHintOnProxiedMethod() + { + $className = 'Doctrine\Tests\Common\Proxy\InvalidTypeHintClass'; + $metadata = $this->createClassMetadata($className, array('id')); + $proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true); + + $this->setExpectedException( + 'Doctrine\Common\Proxy\Exception\UnexpectedValueException', + 'The type hint of parameter "foo" in method "invalidTypeHintMethod"' + .' in class "' . $className . '" is invalid.' + ); + $proxyGenerator->generateProxyClass($metadata); + } + + public function testNoConfigDirThrowsException() + { + $this->setExpectedException('Doctrine\Common\Proxy\Exception\InvalidArgumentException'); + new ProxyGenerator(null, null); + } + + public function testNoNamespaceThrowsException() + { + $this->setExpectedException('Doctrine\Common\Proxy\Exception\InvalidArgumentException'); + new ProxyGenerator(__DIR__ . '/generated', null); + } + + public function testInvalidPlaceholderThrowsException() + { + $this->setExpectedException('Doctrine\Common\Proxy\Exception\InvalidArgumentException'); + $generator = new ProxyGenerator(__DIR__ . '/generated', 'SomeNamespace'); + $generator->setPlaceholder('', array()); + } + + public function testUseEvalIfNoFilenameIsGiven() + { + $proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true); + + $className = __NAMESPACE__ . '\\EvalBase'; + + $metadata = $this->createClassMetadata($className, array('id')); + + $proxyGenerator->generateProxyClass($metadata); + + $reflClass = new ReflectionClass('Doctrine\Tests\Common\ProxyProxy\__CG__\Doctrine\Tests\Common\Proxy\EvalBase'); + + $this->assertContains("eval()'d code", $reflClass->getFileName()); + } + + private function createClassMetadata($className, array $ids) + { + $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $reflClass = new ReflectionClass($className); + $metadata->expects($this->any())->method('getReflectionClass')->will($this->returnValue($reflClass)); + $metadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue($ids)); + $metadata->expects($this->any())->method('getName')->will($this->returnValue($className)); + + return $metadata; + } +} + +class EvalBase +{ +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php new file mode 100644 index 0000000000..9a5173c1db --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php @@ -0,0 +1,696 @@ +. + */ + +namespace Doctrine\Tests\Common\Proxy; + +use Doctrine\Common\Proxy\ProxyGenerator; +use Doctrine\Common\Proxy\Proxy; +use Doctrine\Common\Proxy\Exception\UnexpectedValueException; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use PHPUnit_Framework_TestCase; + +/** + * Test the generated proxies behavior. These tests make assumptions about the structure of LazyLoadableObject + * + * @author Marco Pivetta + */ +class ProxyLogicTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $proxyLoader; + + /** + * @var ClassMetadata + */ + protected $lazyLoadableObjectMetadata; + + /** + * @var LazyLoadableObject|Proxy + */ + protected $lazyObject; + + protected $identifier = array( + 'publicIdentifierField' => 'publicIdentifierFieldValue', + 'protectedIdentifierField' => 'protectedIdentifierFieldValue', + ); + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|Callable + */ + protected $initializerCallbackMock; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->proxyLoader = $loader = $this->getMock('stdClass', array('load'), array(), '', false); + $this->initializerCallbackMock = $this->getMock('stdClass', array('__invoke')); + $identifier = $this->identifier; + $this->lazyLoadableObjectMetadata = $metadata = new LazyLoadableObjectClassMetadata(); + + // emulating what should happen in a proxy factory + $cloner = function (LazyLoadableObject $proxy) use ($loader, $identifier, $metadata) { + /* @var $proxy LazyLoadableObject|Proxy */ + if ($proxy->__isInitialized()) { + return; + } + + $proxy->__setInitialized(true); + $proxy->__setInitializer(null); + $original = $loader->load($identifier); + + if (null === $original) { + throw new UnexpectedValueException(); + } + + foreach ($metadata->getReflectionClass()->getProperties() as $reflProperty) { + $propertyName = $reflProperty->getName(); + + if ($metadata->hasField($propertyName) || $metadata->hasAssociation($propertyName)) { + $reflProperty->setAccessible(true); + $reflProperty->setValue($proxy, $reflProperty->getValue($original)); + } + } + }; + + $proxyClassName = 'Doctrine\Tests\Common\ProxyProxy\__CG__\Doctrine\Tests\Common\Proxy\LazyLoadableObject'; + + // creating the proxy class + if (!class_exists($proxyClassName, false)) { + $proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true); + $proxyGenerator->generateProxyClass($metadata); + require_once $proxyGenerator->getProxyFileName($metadata->getName()); + } + + $this->lazyObject = new $proxyClassName($this->getClosure($this->initializerCallbackMock), $cloner); + + // setting identifiers in the proxy via reflection + foreach ($metadata->getIdentifierFieldNames() as $idField) { + $prop = $metadata->getReflectionClass()->getProperty($idField); + $prop->setAccessible(true); + $prop->setValue($this->lazyObject, $identifier[$idField]); + } + + $this->assertFalse($this->lazyObject->__isInitialized()); + } + + public function testFetchingPublicIdentifierDoesNotCauseLazyLoading() + { + $this->configureInitializerMock(0); + + $this->assertSame('publicIdentifierFieldValue', $this->lazyObject->publicIdentifierField); + } + + public function testFetchingIdentifiersViaPublicGetterDoesNotCauseLazyLoading() + { + $this->configureInitializerMock(0); + + $this->assertSame('protectedIdentifierFieldValue', $this->lazyObject->getProtectedIdentifierField()); + } + + public function testCallingMethodCausesLazyLoading() + { + $this->configureInitializerMock( + 1, + array($this->lazyObject, 'testInitializationTriggeringMethod', array()), + function (Proxy $proxy) { + $proxy->__setInitializer(null); + } + ); + + $this->lazyObject->testInitializationTriggeringMethod(); + $this->lazyObject->testInitializationTriggeringMethod(); + } + + public function testFetchingPublicFieldsCausesLazyLoading() + { + $test = $this; + $this->configureInitializerMock( + 1, + array($this->lazyObject, '__get', array('publicPersistentField')), + function () use ($test) { + $test->setProxyValue('publicPersistentField', 'loadedValue'); + } + ); + + $this->assertSame('loadedValue', $this->lazyObject->publicPersistentField); + $this->assertSame('loadedValue', $this->lazyObject->publicPersistentField); + } + + public function testFetchingPublicAssociationCausesLazyLoading() + { + $test = $this; + $this->configureInitializerMock( + 1, + array($this->lazyObject, '__get', array('publicAssociation')), + function () use ($test) { + $test->setProxyValue('publicAssociation', 'loadedAssociation'); + } + ); + + $this->assertSame('loadedAssociation', $this->lazyObject->publicAssociation); + $this->assertSame('loadedAssociation', $this->lazyObject->publicAssociation); + } + + public function testFetchingProtectedAssociationViaPublicGetterCausesLazyLoading() + { + $this->configureInitializerMock( + 1, + array($this->lazyObject, 'getProtectedAssociation', array()), + function (Proxy $proxy) { + $proxy->__setInitializer(null); + } + ); + + $this->assertSame('protectedAssociationValue', $this->lazyObject->getProtectedAssociation()); + $this->assertSame('protectedAssociationValue', $this->lazyObject->getProtectedAssociation()); + } + + public function testLazyLoadingTriggeredOnlyAtFirstPublicPropertyRead() + { + $test = $this; + $this->configureInitializerMock( + 1, + array($this->lazyObject, '__get', array('publicPersistentField')), + function () use ($test) { + $test->setProxyValue('publicPersistentField', 'loadedValue'); + $test->setProxyValue('publicAssociation', 'publicAssociationValue'); + } + ); + + $this->assertSame('loadedValue', $this->lazyObject->publicPersistentField); + $this->assertSame('publicAssociationValue', $this->lazyObject->publicAssociation); + } + + public function testNoticeWhenReadingNonExistentPublicProperties() + { + $this->configureInitializerMock(0); + + $class = get_class($this->lazyObject); + $this->setExpectedException( + 'PHPUnit_Framework_Error_Notice', + 'Undefined property: ' . $class . '::$non_existing_property' + ); + + $this->lazyObject->non_existing_property; + } + + public function testFalseWhenCheckingNonExistentProperty() + { + $this->configureInitializerMock(0); + + $this->assertFalse(isset($this->lazyObject->non_existing_property)); + } + + public function testNoErrorWhenSettingNonExistentProperty() + { + $this->configureInitializerMock(0); + + $this->lazyObject->non_existing_property = 'now has a value'; + $this->assertSame('now has a value', $this->lazyObject->non_existing_property); + } + + public function testCloningCallsClonerWithClonedObject() + { + $lazyObject = $this->lazyObject; + $test = $this; + $cb = $this->getMock('stdClass', array('cb')); + $cb + ->expects($this->once()) + ->method('cb') + ->will($this->returnCallback(function (LazyLoadableObject $proxy) use ($lazyObject, $test) { + /* @var $proxy LazyLoadableObject|Proxy */ + $test->assertNotSame($proxy, $lazyObject); + $proxy->__setInitializer(null); + $proxy->publicAssociation = 'clonedAssociation'; + })); + + $this->lazyObject->__setCloner($this->getClosure(array($cb, 'cb'))); + + $cloned = clone $this->lazyObject; + $this->assertSame('clonedAssociation', $cloned->publicAssociation); + $this->assertNotSame($cloned, $lazyObject, 'a clone of the lazy object is retrieved'); + } + + public function testFetchingTransientPropertiesWillNotTriggerLazyLoading() + { + $this->configureInitializerMock(0); + + $this->assertSame( + 'publicTransientFieldValue', + $this->lazyObject->publicTransientField, + 'fetching public transient field won\'t trigger lazy loading' + ); + $property = $this + ->lazyLoadableObjectMetadata + ->getReflectionClass() + ->getProperty('protectedTransientField'); + $property->setAccessible(true); + $this->assertSame( + 'protectedTransientFieldValue', + $property->getValue($this->lazyObject), + 'fetching protected transient field via reflection won\'t trigger lazy loading' + ); + } + + /** + * Provided to guarantee backwards compatibility + */ + public function testLoadProxyMethod() + { + $this->configureInitializerMock(2, array($this->lazyObject, '__load', array())); + + $this->lazyObject->__load(); + $this->lazyObject->__load(); + } + + public function testLoadingWithPersisterWillBeTriggeredOnlyOnce() + { + $this + ->proxyLoader + ->expects($this->once()) + ->method('load') + ->with( + array( + 'publicIdentifierField' => 'publicIdentifierFieldValue', + 'protectedIdentifierField' => 'protectedIdentifierFieldValue', + ), + $this->lazyObject + ) + ->will($this->returnCallback(function ($id, LazyLoadableObject $lazyObject) { + // setting a value to verify that the persister can actually set something in the object + $lazyObject->publicAssociation = $id['publicIdentifierField'] . '-test'; + return true; + })); + $this->lazyObject->__setInitializer($this->getSuggestedInitializerImplementation()); + + $this->lazyObject->__load(); + $this->lazyObject->__load(); + $this->assertSame('publicIdentifierFieldValue-test', $this->lazyObject->publicAssociation); + } + + public function testFailedLoadingWillThrowException() + { + $this->proxyLoader->expects($this->any())->method('load')->will($this->returnValue(null)); + $this->setExpectedException('UnexpectedValueException'); + $this->lazyObject->__setInitializer($this->getSuggestedInitializerImplementation()); + + $this->lazyObject->__load(); + } + + public function testCloningWithPersister() + { + $this->lazyObject->publicTransientField = 'should-not-change'; + $this + ->proxyLoader + ->expects($this->exactly(2)) + ->method('load') + ->with(array( + 'publicIdentifierField' => 'publicIdentifierFieldValue', + 'protectedIdentifierField' => 'protectedIdentifierFieldValue', + )) + ->will($this->returnCallback(function () { + $blueprint = new LazyLoadableObject(); + $blueprint->publicPersistentField = 'checked-persistent-field'; + $blueprint->publicAssociation = 'checked-association-field'; + $blueprint->publicTransientField = 'checked-transient-field'; + + return $blueprint; + })); + + $firstClone = clone $this->lazyObject; + $this->assertSame( + 'checked-persistent-field', + $firstClone->publicPersistentField, + 'Persistent fields are cloned correctly' + ); + $this->assertSame( + 'checked-association-field', + $firstClone->publicAssociation, + 'Associations are cloned correctly' + ); + $this->assertSame( + 'should-not-change', + $firstClone->publicTransientField, + 'Transient fields are not overwritten' + ); + + $secondClone = clone $this->lazyObject; + $this->assertSame( + 'checked-persistent-field', + $secondClone->publicPersistentField, + 'Persistent fields are cloned correctly' + ); + $this->assertSame( + 'checked-association-field', + $secondClone->publicAssociation, + 'Associations are cloned correctly' + ); + $this->assertSame( + 'should-not-change', + $secondClone->publicTransientField, + 'Transient fields are not overwritten' + ); + + // those should not trigger lazy loading + $firstClone->__load(); + $secondClone->__load(); + } + + public function testNotInitializedProxyUnserialization() + { + $this->configureInitializerMock(); + + $serialized = serialize($this->lazyObject); + /* @var $unserialized LazyLoadableObject|Proxy */ + $unserialized = unserialize($serialized); + $reflClass = $this->lazyLoadableObjectMetadata->getReflectionClass(); + + $this->assertFalse($unserialized->__isInitialized(), 'serialization didn\'t cause intialization'); + + // Checking identifiers + $this->assertSame('publicIdentifierFieldValue', $unserialized->publicIdentifierField, 'identifiers are kept'); + $protectedIdentifierField = $reflClass->getProperty('protectedIdentifierField'); + $protectedIdentifierField->setAccessible(true); + $this->assertSame( + 'protectedIdentifierFieldValue', + $protectedIdentifierField->getValue($unserialized), + 'identifiers are kept' + ); + + // Checking transient fields + $this->assertSame( + 'publicTransientFieldValue', + $unserialized->publicTransientField, + 'transient fields are kept' + ); + $protectedTransientField = $reflClass->getProperty('protectedTransientField'); + $protectedTransientField->setAccessible(true); + $this->assertSame( + 'protectedTransientFieldValue', + $protectedTransientField->getValue($unserialized), + 'transient fields are kept' + ); + + // Checking persistent fields + $this->assertSame( + 'publicPersistentFieldValue', + $unserialized->publicPersistentField, + 'persistent fields are kept' + ); + $protectedPersistentField = $reflClass->getProperty('protectedPersistentField'); + $protectedPersistentField->setAccessible(true); + $this->assertSame( + 'protectedPersistentFieldValue', + $protectedPersistentField->getValue($unserialized), + 'persistent fields are kept' + ); + + // Checking associations + $this->assertSame('publicAssociationValue', $unserialized->publicAssociation, 'associations are kept'); + $protectedAssociationField = $reflClass->getProperty('protectedAssociation'); + $protectedAssociationField->setAccessible(true); + $this->assertSame( + 'protectedAssociationValue', + $protectedAssociationField->getValue($unserialized), + 'associations are kept' + ); + } + + public function testInitializedProxyUnserialization() + { + // persister will retrieve the lazy object itself, so that we don't have to re-define all field values + $this->proxyLoader->expects($this->once())->method('load')->will($this->returnValue($this->lazyObject)); + $this->lazyObject->__setInitializer($this->getSuggestedInitializerImplementation()); + $this->lazyObject->__load(); + + $serialized = serialize($this->lazyObject); + $reflClass = $this->lazyLoadableObjectMetadata->getReflectionClass(); + /* @var $unserialized LazyLoadableObject|Proxy */ + $unserialized = unserialize($serialized); + + $this->assertTrue($unserialized->__isInitialized(), 'serialization didn\'t cause intialization'); + + // Checking transient fields + $this->assertSame( + 'publicTransientFieldValue', + $unserialized->publicTransientField, + 'transient fields are kept' + ); + $protectedTransientField = $reflClass->getProperty('protectedTransientField'); + $protectedTransientField->setAccessible(true); + $this->assertSame( + 'protectedTransientFieldValue', + $protectedTransientField->getValue($unserialized), + 'transient fields are kept' + ); + + // Checking persistent fields + $this->assertSame( + 'publicPersistentFieldValue', + $unserialized->publicPersistentField, + 'persistent fields are kept' + ); + $protectedPersistentField = $reflClass->getProperty('protectedPersistentField'); + $protectedPersistentField->setAccessible(true); + $this->assertSame( + 'protectedPersistentFieldValue', + $protectedPersistentField->getValue($unserialized), + 'persistent fields are kept' + ); + + // Checking identifiers + $this->assertSame( + 'publicIdentifierFieldValue', + $unserialized->publicIdentifierField, + 'identifiers are kept' + ); + $protectedIdentifierField = $reflClass->getProperty('protectedIdentifierField'); + $protectedIdentifierField->setAccessible(true); + $this->assertSame( + 'protectedIdentifierFieldValue', + $protectedIdentifierField->getValue($unserialized), + 'identifiers are kept' + ); + + // Checking associations + $this->assertSame('publicAssociationValue', $unserialized->publicAssociation, 'associations are kept'); + $protectedAssociationField = $reflClass->getProperty('protectedAssociation'); + $protectedAssociationField->setAccessible(true); + $this->assertSame( + 'protectedAssociationValue', + $protectedAssociationField->getValue($unserialized), + 'associations are kept' + ); + } + + public function testInitializationRestoresDefaultPublicLazyLoadedFieldValues() + { + // setting noop persister + $this->proxyLoader->expects($this->once())->method('load')->will($this->returnValue($this->lazyObject)); + $this->lazyObject->__setInitializer($this->getSuggestedInitializerImplementation()); + + $this->assertSame( + 'publicPersistentFieldValue', + $this->lazyObject->publicPersistentField, + 'Persistent field is restored to default value' + ); + $this->assertSame( + 'publicAssociationValue', + $this->lazyObject->publicAssociation, + 'Association is restored to default value' + ); + } + + public function testSettingPublicFieldsCausesLazyLoading() + { + $test = $this; + $this->configureInitializerMock( + 1, + array($this->lazyObject, '__set', array('publicPersistentField', 'newPublicPersistentFieldValue')), + function () use ($test) { + $test->setProxyValue('publicPersistentField', 'overrideValue'); + $test->setProxyValue('publicAssociation', 'newAssociationValue'); + } + ); + + $this->lazyObject->publicPersistentField = 'newPublicPersistentFieldValue'; + $this->assertSame('newPublicPersistentFieldValue', $this->lazyObject->publicPersistentField); + $this->assertSame('newAssociationValue', $this->lazyObject->publicAssociation); + } + + public function testSettingPublicAssociationCausesLazyLoading() + { + $test = $this; + $this->configureInitializerMock( + 1, + array($this->lazyObject, '__set', array('publicAssociation', 'newPublicAssociationValue')), + function () use ($test) { + $test->setProxyValue('publicPersistentField', 'newPublicPersistentFieldValue'); + $test->setProxyValue('publicAssociation', 'overrideValue'); + } + ); + + $this->lazyObject->publicAssociation = 'newPublicAssociationValue'; + $this->assertSame('newPublicAssociationValue', $this->lazyObject->publicAssociation); + $this->assertSame('newPublicPersistentFieldValue', $this->lazyObject->publicPersistentField); + } + + public function testCheckingPublicFieldsCausesLazyLoading() + { + $test = $this; + $this->configureInitializerMock( + 1, + array($this->lazyObject, '__isset', array('publicPersistentField')), + function () use ($test) { + $test->setProxyValue('publicPersistentField', null); + $test->setProxyValue('publicAssociation', 'setPublicAssociation'); + } + ); + + $this->assertFalse(isset($this->lazyObject->publicPersistentField)); + $this->assertNull($this->lazyObject->publicPersistentField); + $this->assertTrue(isset($this->lazyObject->publicAssociation)); + $this->assertSame('setPublicAssociation', $this->lazyObject->publicAssociation); + } + + public function testCheckingPublicAssociationCausesLazyLoading() + { + $test = $this; + $this->configureInitializerMock( + 1, + array($this->lazyObject, '__isset', array('publicAssociation')), + function () use ($test) { + $test->setProxyValue('publicPersistentField', 'newPersistentFieldValue'); + $test->setProxyValue('publicAssociation', 'setPublicAssociation'); + } + ); + + $this->assertTrue(isset($this->lazyObject->publicAssociation)); + $this->assertSame('setPublicAssociation', $this->lazyObject->publicAssociation); + $this->assertTrue(isset($this->lazyObject->publicPersistentField)); + $this->assertSame('newPersistentFieldValue', $this->lazyObject->publicPersistentField); + } + + /** + * Converts a given callable into a closure + * + * @param callable $callable + * @return \Closure + */ + public function getClosure($callable) { + return function () use ($callable) { + call_user_func_array($callable, func_get_args()); + }; + } + + /** + * Configures the current initializer callback mock with provided matcher params + * + * @param int $expectedCallCount the number of invocations to be expected. If a value< 0 is provided, `any` is used + * @param array $callParamsMatch an ordered array of parameters to be expected + * @param callable $callbackClosure a return callback closure + * + * @return \PHPUnit_Framework_MockObject_MockObject| + */ + protected function configureInitializerMock( + $expectedCallCount = 0, + array $callParamsMatch = null, + \Closure $callbackClosure = null + ) { + if (!$expectedCallCount) { + $invocationCountMatcher = $this->exactly((int) $expectedCallCount); + } else { + $invocationCountMatcher = $expectedCallCount < 0 ? $this->any() : $this->exactly($expectedCallCount); + } + + $invocationMocker = $this->initializerCallbackMock->expects($invocationCountMatcher)->method('__invoke'); + + if (null !== $callParamsMatch) { + call_user_func_array(array($invocationMocker, 'with'), $callParamsMatch); + } + + if ($callbackClosure) { + $invocationMocker->will($this->returnCallback($callbackClosure)); + } + } + + /** + * Sets a value in the current proxy object without triggering lazy loading through `__set` + * + * @link https://bugs.php.net/bug.php?id=63463 + * + * @param string $property + * @param mixed $value + */ + public function setProxyValue($property, $value) + { + $reflectionProperty = new \ReflectionProperty($this->lazyObject, $property); + $initializer = $this->lazyObject->__getInitializer(); + + // disabling initializer since setting `publicPersistentField` triggers `__set`/`__get` + $this->lazyObject->__setInitializer(null); + $reflectionProperty->setValue($this->lazyObject, $value); + $this->lazyObject->__setInitializer($initializer); + } + + /** + * Retrieves the suggested implementation of an initializer that proxy factories in O*M + * are currently following, and that should be used to initialize the current proxy object + * + * @return \Closure + */ + protected function getSuggestedInitializerImplementation() + { + $loader = $this->proxyLoader; + $identifier = $this->identifier; + + return function (LazyLoadableObject $proxy) use ($loader, $identifier) { + /* @var $proxy LazyLoadableObject|Proxy */ + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + + if ($proxy->__isInitialized()) { + return; + } + + $properties = $proxy->__getLazyProperties(); + + foreach ($properties as $propertyName => $property) { + if (!isset($proxy->$propertyName)) { + $proxy->$propertyName = $properties[$propertyName]; + } + } + + $proxy->__setInitialized(true); + + if (method_exists($proxy, '__wakeup')) { + $proxy->__wakeup(); + } + + if (null === $loader->load($identifier, $proxy)) { + throw new \UnexpectedValueException('Couldn\'t load'); + } + }; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php new file mode 100644 index 0000000000..a63f8bd8ed --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php @@ -0,0 +1,307 @@ +. + */ + +namespace Doctrine\Tests\Common\Proxy; + +use Doctrine\Common\Proxy\ProxyGenerator; +use Doctrine\Common\Proxy\Proxy; +use Doctrine\Common\Proxy\Exception\UnexpectedValueException; +use PHPUnit_Framework_TestCase; +use ReflectionClass; + +/** + * Test for behavior of proxies with inherited magic methods + * + * @author Marco Pivetta + */ +class ProxyMagicMethodsTest extends PHPUnit_Framework_TestCase +{ + /** + * @var \Doctrine\Common\Proxy\ProxyGenerator + */ + protected $proxyGenerator; + + /** + * @var LazyLoadableObject|Proxy + */ + protected $lazyObject; + + protected $identifier = array( + 'publicIdentifierField' => 'publicIdentifierFieldValue', + 'protectedIdentifierField' => 'protectedIdentifierFieldValue', + ); + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|Callable + */ + protected $initializerCallbackMock; + + /** + * {@inheritDoc} + */ + public function setUp() + { + $this->proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . '\\MagicMethodProxy'); + } + + public static function tearDownAfterClass() + { + + } + + public function testInheritedMagicGet() + { + $proxyClassName = $this->generateProxyClass(__NAMESPACE__ . '\\MagicGetClass'); + $proxy = new $proxyClassName( + function (Proxy $proxy, $method, $params) use (&$counter) { + if ( ! in_array($params[0], array('publicField', 'test', 'notDefined'))) { + throw new \InvalidArgumentException('Unexpected access to field "' . $params[0] . '"'); + } + + $initializer = $proxy->__getInitializer(); + + $proxy->__setInitializer(null); + + $proxy->publicField = 'modifiedPublicField'; + $counter += 1; + + $proxy->__setInitializer($initializer); + + } + ); + + $this->assertSame('id', $proxy->id); + $this->assertSame('modifiedPublicField', $proxy->publicField); + $this->assertSame('test', $proxy->test); + $this->assertSame('not defined', $proxy->notDefined); + + $this->assertSame(3, $counter); + } + + /** + * @group DCOM-194 + */ + public function testInheritedMagicGetByRef() + { + $proxyClassName = $this->generateProxyClass(__NAMESPACE__ . '\\MagicGetByRefClass'); + /* @var $proxy \Doctrine\Tests\Common\Proxy\MagicGetByRefClass */ + $proxy = new $proxyClassName(); + $proxy->valueField = 123; + $value = & $proxy->__get('value'); + + $this->assertSame(123, $value); + + $value = 456; + + $this->assertSame(456, $proxy->__get('value'), 'Value was fetched by reference'); + + $this->setExpectedException('InvalidArgumentException'); + + $undefined = $proxy->nonExisting; + } + + public function testInheritedMagicSet() + { + $proxyClassName = $this->generateProxyClass(__NAMESPACE__ . '\\MagicSetClass'); + $proxy = new $proxyClassName( + function (Proxy $proxy, $method, $params) use (&$counter) { + if ( ! in_array($params[0], array('publicField', 'test', 'notDefined'))) { + throw new \InvalidArgumentException('Unexpected access to field "' . $params[0] . '"'); + } + + $counter += 1; + } + ); + + $this->assertSame('id', $proxy->id); + + $proxy->publicField = 'publicFieldValue'; + + $this->assertSame('publicFieldValue', $proxy->publicField); + + $proxy->test = 'testValue'; + + $this->assertSame('testValue', $proxy->testAttribute); + + $proxy->notDefined = 'not defined'; + + $this->assertSame('not defined', $proxy->testAttribute); + $this->assertSame(3, $counter); + } + + public function testInheritedMagicSleep() + { + $proxyClassName = $this->generateProxyClass(__NAMESPACE__ . '\\MagicSleepClass'); + $proxy = new $proxyClassName(); + + $this->assertSame('defaultValue', $proxy->serializedField); + $this->assertSame('defaultValue', $proxy->nonSerializedField); + + $proxy->serializedField = 'changedValue'; + $proxy->nonSerializedField = 'changedValue'; + + $unserialized = unserialize(serialize($proxy)); + + $this->assertSame('changedValue', $unserialized->serializedField); + $this->assertSame('defaultValue', $unserialized->nonSerializedField, 'Field was not returned by "__sleep"'); + } + + public function testInheritedMagicWakeup() + { + $proxyClassName = $this->generateProxyClass(__NAMESPACE__ . '\\MagicWakeupClass'); + $proxy = new $proxyClassName(); + + $this->assertSame('defaultValue', $proxy->wakeupValue); + + $proxy->wakeupValue = 'changedValue'; + $unserialized = unserialize(serialize($proxy)); + + $this->assertSame('newWakeupValue', $unserialized->wakeupValue, '"__wakeup" was called'); + + $unserialized->__setInitializer(function (Proxy $proxy) { + $proxy->__setInitializer(null); + + $proxy->publicField = 'newPublicFieldValue'; + }); + + $this->assertSame('newPublicFieldValue', $unserialized->publicField, 'Proxy can still be initialized'); + } + + public function testInheritedMagicIsset() + { + $proxyClassName = $this->generateProxyClass(__NAMESPACE__ . '\\MagicIssetClass'); + $proxy = new $proxyClassName(function (Proxy $proxy, $method, $params) use (&$counter) { + if (in_array($params[0], array('publicField', 'test', 'nonExisting'))) { + $initializer = $proxy->__getInitializer(); + + $proxy->__setInitializer(null); + + $proxy->publicField = 'modifiedPublicField'; + $counter += 1; + + $proxy->__setInitializer($initializer); + + return; + } + + throw new \InvalidArgumentException( + sprintf('Should not be initialized when checking isset("%s")', $params[0]) + ); + }); + + $this->assertTrue(isset($proxy->id)); + $this->assertTrue(isset($proxy->publicField)); + $this->assertTrue(isset($proxy->test)); + $this->assertFalse(isset($proxy->nonExisting)); + + $this->assertSame(3, $counter); + } + + public function testInheritedMagicClone() + { + $proxyClassName = $this->generateProxyClass(__NAMESPACE__ . '\\MagicCloneClass'); + $proxy = new $proxyClassName( + null, + function ($proxy) { + $proxy->cloned = true; + } + ); + + $cloned = clone $proxy; + + $this->assertSame('newClonedValue', $cloned->clonedValue); + $this->assertFalse($proxy->cloned); + $this->assertTrue($cloned->cloned); + } + + /** + * @param $className + * + * @return string + */ + private function generateProxyClass($className) + { + $proxyClassName = 'Doctrine\\Tests\\Common\\Proxy\\MagicMethodProxy\\__CG__\\' . $className; + + if (class_exists($proxyClassName, false)) { + return $proxyClassName; + } + + $metadata = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata'); + + $metadata + ->expects($this->any()) + ->method('getName') + ->will($this->returnValue($className)); + + $metadata + ->expects($this->any()) + ->method('getIdentifier') + ->will($this->returnValue(array('id'))); + + $metadata + ->expects($this->any()) + ->method('getReflectionClass') + ->will($this->returnValue(new ReflectionClass($className))); + + $metadata + ->expects($this->any()) + ->method('isIdentifier') + ->will($this->returnCallback(function ($fieldName) { + return 'id' === $fieldName; + })); + + $metadata + ->expects($this->any()) + ->method('hasField') + ->will($this->returnCallback(function ($fieldName) { + return in_array($fieldName, array('id', 'publicField')); + })); + + $metadata + ->expects($this->any()) + ->method('hasAssociation') + ->will($this->returnValue(false)); + + $metadata + ->expects($this->any()) + ->method('getFieldNames') + ->will($this->returnValue(array('id', 'publicField'))); + + $metadata + ->expects($this->any()) + ->method('getIdentifierFieldNames') + ->will($this->returnValue(array('id'))); + + $metadata + ->expects($this->any()) + ->method('getAssociationNames') + ->will($this->returnValue(array())); + + $metadata + ->expects($this->any()) + ->method('getTypeOfField') + ->will($this->returnValue('string')); + + $this->proxyGenerator->generateProxyClass($metadata, $this->proxyGenerator->getProxyFileName($className)); + require_once $this->proxyGenerator->getProxyFileName($className); + + return $proxyClassName; + } +} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/SleepClass.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/SleepClass.php new file mode 100644 index 0000000000..3c6ffcdba3 --- /dev/null +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/SleepClass.php @@ -0,0 +1,19 @@ +getMock('stdClass', array('callGet')); + $getCheckMock->expects($this->never())->method('callGet'); + $initializer = function () use ($getCheckMock) { + call_user_func($getCheckMock); + }; + + $mockProxy = new RuntimePublicReflectionPropertyTestProxyMock(); + $mockProxy->__setInitializer($initializer); + + $reflProperty = new RuntimePublicReflectionProperty( + __NAMESPACE__ . '\RuntimePublicReflectionPropertyTestProxyMock', + 'checkedProperty' + ); + + $this->assertSame('testValue', $reflProperty->getValue($mockProxy)); + unset($mockProxy->checkedProperty); + $this->assertNull($reflProperty->getValue($mockProxy)); + } + + public function testSetValueOnProxyPublicProperty() + { + $setCheckMock = $this->getMock('stdClass', array('neverCallSet')); + $setCheckMock->expects($this->never())->method('neverCallSet'); + $initializer = function () use ($setCheckMock) { + call_user_func(array($setCheckMock, 'neverCallSet')); + }; + + $mockProxy = new RuntimePublicReflectionPropertyTestProxyMock(); + $mockProxy->__setInitializer($initializer); + + $reflProperty = new RuntimePublicReflectionProperty( + __NAMESPACE__ . '\RuntimePublicReflectionPropertyTestProxyMock', + 'checkedProperty' + ); + + $reflProperty->setValue($mockProxy, 'newValue'); + $this->assertSame('newValue', $mockProxy->checkedProperty); + + unset($mockProxy->checkedProperty); + $reflProperty->setValue($mockProxy, 'otherNewValue'); + $this->assertSame('otherNewValue', $mockProxy->checkedProperty); + + $setCheckMock = $this->getMock('stdClass', array('callSet')); + $setCheckMock->expects($this->once())->method('callSet'); + $initializer = function () use ($setCheckMock) { + call_user_func(array($setCheckMock, 'callSet')); + }; + + $mockProxy->__setInitializer($initializer); + $mockProxy->__setInitialized(true); + + unset($mockProxy->checkedProperty); + $reflProperty->setValue($mockProxy, 'againNewValue'); + $this->assertSame('againNewValue', $mockProxy->checkedProperty); + } +} + +/** + * Mock that simulates proxy public property lazy loading + */ +class RuntimePublicReflectionPropertyTestProxyMock implements Proxy +{ + /** + * @var \Closure|null + */ + private $initializer = null; + + /** + * @var \Closure|null + */ + private $initialized = false; + + /** + * @var string + */ + public $checkedProperty = 'testValue'; + + /** + * {@inheritDoc} + */ + public function __getInitializer() + { + return $this->initializer; + } + + /** + * {@inheritDoc} + */ + public function __setInitializer(\Closure $initializer = null) + { + $this->initializer = $initializer; + } + + /** + * {@inheritDoc} + */ + public function __getLazyProperties() + { + } + + /** + * {@inheritDoc} + */ + public function __load() + { + } + + /** + * {@inheritDoc} + */ + public function __isInitialized() + { + return $this->initialized; + } + + /** + * {@inheritDoc} + */ + public function __setInitialized($initialized) + { + $this->initialized = (bool) $initialized; + } + + /** + * @param string $name + */ + public function __get($name) + { + if ($this->initializer) { + $cb = $this->initializer; + $cb(); + } + + return $this->checkedProperty; + } + + /** + * @param string $name + * @param mixed $value + */ + public function __set($name, $value) + { + if ($this->initializer) { + $cb = $this->initializer; + $cb(); + } + + // triggers notices if `$name` is used: see https://bugs.php.net/bug.php?id=63463 + $this->checkedProperty = $value; + } + + /** + * @param string $name + * + * @return integer + */ + public function __isset($name) + { + if ($this->initializer) { + $cb = $this->initializer; + $cb(); + } + + return isset($this->checkedProperty); + } + + /** + * {@inheritDoc} + */ + public function __setCloner(\Closure $cloner = null) + { + } + + /** + * {@inheritDoc} + */ + public function __getCloner() + { + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/SameNamespaceParent.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/SameNamespaceParent.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/StaticReflectionParserTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/StaticReflectionParserTest.php old mode 100755 new mode 100644 index 374fdc48ec..a180e09825 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/StaticReflectionParserTest.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/StaticReflectionParserTest.php @@ -8,38 +8,56 @@ use Doctrine\Common\Reflection\Psr0FindFile; class StaticReflectionParserTest extends DoctrineTestCase { - public function testParentClass() + /** + * @dataProvider classAnnotationOptimize + * + * @param bool $classAnnotationOptimize + * + * @return void + */ + public function testParentClass($classAnnotationOptimize) { $testsRoot = substr(__DIR__, 0, -strlen(__NAMESPACE__) - 1); $paths = array( 'Doctrine\\Tests' => array($testsRoot), ); $noParentClassName = 'Doctrine\\Tests\\Common\\Reflection\\NoParent'; - $staticReflectionParser = new StaticReflectionParser($noParentClassName, new Psr0FindFile($paths)); + $staticReflectionParser = new StaticReflectionParser($noParentClassName, new Psr0FindFile($paths), $classAnnotationOptimize); $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); $this->assertEquals($noParentClassName, $declaringClassName); $className = 'Doctrine\\Tests\\Common\\Reflection\\FullyClassifiedParent'; - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); + $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths), $classAnnotationOptimize); $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); $this->assertEquals($noParentClassName, $declaringClassName); $className = 'Doctrine\\Tests\\Common\\Reflection\\SameNamespaceParent'; - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); + $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths), $classAnnotationOptimize); $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); $this->assertEquals($noParentClassName, $declaringClassName); $dummyParentClassName = 'Doctrine\\Tests\\Common\\Reflection\\Dummies\\NoParent'; $className = 'Doctrine\\Tests\\Common\\Reflection\\DeeperNamespaceParent'; - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); + $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths), $classAnnotationOptimize); $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); $this->assertEquals($dummyParentClassName, $declaringClassName); $className = 'Doctrine\\Tests\\Common\\Reflection\\UseParent'; - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); + $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths), $classAnnotationOptimize); $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); $this->assertEquals($dummyParentClassName, $declaringClassName); } + + /** + * @return array + */ + public function classAnnotationOptimize() + { + return array( + array(false), + array(true) + ); + } } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/UseParent.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/UseParent.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/DebugTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/DebugTest.php old mode 100755 new mode 100644 index b4e9eed2cd..f6fc069772 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/DebugTest.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/DebugTest.php @@ -24,4 +24,17 @@ class DebugTest extends DoctrineTestCase $var = Debug::export( $obj, 2 ); $this->assertEquals( "DateTime", $var->__CLASS__ ); } + + public function testExportArrayTraversable() + { + $obj = new \ArrayObject(array('foobar')); + + $var = Debug::export($obj, 2); + $this->assertContains('foobar', $var->__STORAGE__); + + $it = new \ArrayIterator(array('foobar')); + + $var = Debug::export($it, 5); + $this->assertContains('foobar', $var->__STORAGE__); + } } diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/DoctrineTestCase.php b/vendor/doctrine/common/tests/Doctrine/Tests/DoctrineTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/TestInit.php b/vendor/doctrine/common/tests/Doctrine/Tests/TestInit.php old mode 100755 new mode 100644 index e7ab51f3a2..07d74e6780 --- a/vendor/doctrine/common/tests/Doctrine/Tests/TestInit.php +++ b/vendor/doctrine/common/tests/Doctrine/Tests/TestInit.php @@ -11,14 +11,7 @@ spl_autoload_register(function($class) { if (0 === strpos($class, 'Doctrine\Tests\\')) { $path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php'; - if (file_exists($path) && is_readable($path)) { - require_once $path; - - return true; - } - } else if (0 === strpos($class, 'Doctrine\Common\\')) { - $path = __DIR__.'/../../../lib/'.($class = strtr($class, '\\', '/')).'.php'; - if (file_exists($path) && is_readable($path)) { + if (is_file($path) && is_readable($path)) { require_once $path; return true; @@ -26,6 +19,8 @@ spl_autoload_register(function($class) } }); +require_once __DIR__ . "/../../../vendor/autoload.php"; + \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace( 'Doctrine\Tests\Common\Annotations\Fixtures', __DIR__ . '/../../' ); diff --git a/vendor/doctrine/common/tests/NativePhpunitTask.php b/vendor/doctrine/common/tests/NativePhpunitTask.php old mode 100755 new mode 100644 index 50fd1c3d42..7033283a52 --- a/vendor/doctrine/common/tests/NativePhpunitTask.php +++ b/vendor/doctrine/common/tests/NativePhpunitTask.php @@ -16,7 +16,7 @@ require_once 'PHPUnit/Autoload.php'; /** * A more flexible and powerful PHPUnit Task than the native Phing one. * - * Plus forward compability for PHPUnit 3.5 and later is ensured by using the PHPUnit Test Runner instead of implementing one. + * Plus forward compatibility for PHPUnit 3.5 and later is ensured by using the PHPUnit Test Runner instead of implementing one. * * @author Benjamin Eberlei */ @@ -124,7 +124,7 @@ class NativePhpunitTask extends Task "failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)"); // Hudson for example doesn't like the backslash in class names - if (file_exists($this->coverageClover)) { + if (is_file($this->coverageClover)) { $this->log("Generated Clover Coverage XML to: ".$this->coverageClover); $content = file_get_contents($this->coverageClover); $content = str_replace("\\", ".", $content); diff --git a/vendor/doctrine/common/tests/README.markdown b/vendor/doctrine/common/tests/README.markdown old mode 100755 new mode 100644 diff --git a/vendor/doctrine/dbal/.gitignore b/vendor/doctrine/dbal/.gitignore deleted file mode 100755 index a9b57aaada..0000000000 --- a/vendor/doctrine/dbal/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -build/ -logs/ -reports/ -dist/ -download/ -lib/Doctrine/Common/ diff --git a/vendor/doctrine/dbal/.gitmodules b/vendor/doctrine/dbal/.gitmodules deleted file mode 100755 index 00dc3fa1c4..0000000000 --- a/vendor/doctrine/dbal/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "lib/vendor/doctrine-common"] - path = lib/vendor/doctrine-common - url = git://github.com/doctrine/common.git -[submodule "lib/vendor/Symfony/Component/Console"] - path = lib/vendor/Symfony/Component/Console - url = git://github.com/symfony/Console.git -[submodule "lib/vendor/doctrine-build-common"] - path = lib/vendor/doctrine-build-common - url = git://github.com/doctrine/doctrine-build-common.git diff --git a/vendor/doctrine/dbal/.travis.yml b/vendor/doctrine/dbal/.travis.yml deleted file mode 100755 index 1a438ca27f..0000000000 --- a/vendor/doctrine/dbal/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 -env: - - DB=mysql - - DB=pgsql - - DB=sqlite - - DB=mysqli - -before_script: - - composer update --dev --prefer-source - - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS doctrine_tests;' -U postgres; fi" - - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS doctrine_tests_tmp;' -U postgres; fi" - - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database doctrine_tests;' -U postgres; fi" - - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database doctrine_tests_tmp;' -U postgres; fi" - - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS doctrine_tests_tmp;create database IF NOT EXISTS doctrine_tests;'; fi" - - sh -c "if [ '$DB' = 'mysqli' ]; then mysql -e 'create database IF NOT EXISTS doctrine_tests_tmp;create database IF NOT EXISTS doctrine_tests;'; fi" - -script: phpunit --configuration tests/travis/$DB.travis.xml - diff --git a/vendor/doctrine/dbal/LICENSE b/vendor/doctrine/dbal/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/doctrine/dbal/README.md b/vendor/doctrine/dbal/README.md old mode 100755 new mode 100644 index c88f9e670e..970db7bb43 --- a/vendor/doctrine/dbal/README.md +++ b/vendor/doctrine/dbal/README.md @@ -3,12 +3,12 @@ Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction. * Master: [![Build Status](https://secure.travis-ci.org/doctrine/dbal.png?branch=master)](http://travis-ci.org/doctrine/dbal) +* 2.3: [![Build Status](https://secure.travis-ci.org/doctrine/dbal.png?branch=2.3)](http://travis-ci.org/doctrine/dbal) * 2.2: [![Build Status](https://secure.travis-ci.org/doctrine/dbal.png?branch=2.2)](http://travis-ci.org/doctrine/dbal) -* 2.1.x: [![Build Status](https://secure.travis-ci.org/doctrine/dbal.png?branch=2.1.x)](http://travis-ci.org/doctrine/dbal) ## More resources: -* [Website](http://www.doctrine-project.org) -* [Documentation](http://www.doctrine-project.org/projects/dbal/current/docs/en) +* [Website](http://www.doctrine-project.org/projects/dbal.html) +* [Documentation](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/) * [Issue Tracker](http://www.doctrine-project.org/jira/browse/DBAL) * [Downloads](http://github.com/doctrine/dbal/downloads) diff --git a/vendor/doctrine/dbal/UPGRADE b/vendor/doctrine/dbal/UPGRADE old mode 100755 new mode 100644 index 36ca80eea3..04d488cc8b --- a/vendor/doctrine/dbal/UPGRADE +++ b/vendor/doctrine/dbal/UPGRADE @@ -1,3 +1,13 @@ +# Upgrade to 2.4 + +## Doctrine\DBAL\Schema\Constraint + +If you have custom classes that implement the constraint interface, you have to implement +an additional method ``getQuotedColumns`` now. This method is used to build proper constraint +SQL for columns that need to be quoted, like keywords reserved by the specific platform used. +The method has to return the same values as ``getColumns`` only that those column names that +need quotation have to be returned quoted for the given platform. + # Upgrade to 2.3 ## Oracle Session Init now sets Numeric Character @@ -76,7 +86,7 @@ now set to 'utf8'/'utf8_unicode_ci' by default. Previously the MySQL server defa # Upgrade to 2.2 -## Doctrine\DBAL\Connection#insert and Doctrine\DBAL\Connnection#update +## Doctrine\DBAL\Connection#insert and Doctrine\DBAL\Connection#update Both methods now accept an optional last parameter $types with binding types of the values passed. This can potentially break child classes that have overwritten one of these methods. @@ -88,7 +98,7 @@ Doctrine\DBAL\Connection#executeQuery() got a new last parameter "QueryCacheProf ## Doctrine\DBAL\Driver\Statement split The Driver statement was split into a ResultStatement and the normal statement extending from it. -This seperates the configuration and the retrieval API from a statement. +This separates the configuration and the retrieval API from a statement. ## MsSql Platform/SchemaManager renamed diff --git a/vendor/doctrine/dbal/bin/doctrine-dbal b/vendor/doctrine/dbal/bin/doctrine-dbal old mode 100755 new mode 100644 diff --git a/vendor/doctrine/dbal/bin/doctrine-dbal.php b/vendor/doctrine/dbal/bin/doctrine-dbal.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/dbal/bin/doctrine.php b/vendor/doctrine/dbal/bin/doctrine.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/dbal/build.properties b/vendor/doctrine/dbal/build.properties deleted file mode 100755 index 12b5e8fc33..0000000000 --- a/vendor/doctrine/dbal/build.properties +++ /dev/null @@ -1,10 +0,0 @@ -# Project Name -project.name=DoctrineDBAL - -# Dependency minimum versions -dependencies.common=2.0.1 -dependencies.sfconsole=2.0.0 - -# Version class and file -project.version_class = Doctrine\DBAL\Version -project.version_file = lib/Doctrine/DBAL/Version.php diff --git a/vendor/doctrine/dbal/build.xml b/vendor/doctrine/dbal/build.xml deleted file mode 100755 index 0fb05ff523..0000000000 --- a/vendor/doctrine/dbal/build.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${project.name} - Doctrine Database Abstraction Layer - pear.doctrine-project.org - The Doctrine DBAL package is the database abstraction layer used to power the ORM package. - - - - - LGPL - - - - - - - - - - - script - Doctrine/Common/ - Doctrine/Symfony/ - - - - - - - diff --git a/vendor/doctrine/dbal/composer.json b/vendor/doctrine/dbal/composer.json old mode 100755 new mode 100644 index 22f9d53fbe..1fba289566 --- a/vendor/doctrine/dbal/composer.json +++ b/vendor/doctrine/dbal/composer.json @@ -1,6 +1,6 @@ { "name": "doctrine/dbal", - "type": "library","version":"2.3.4", + "type": "library", "description": "Database Abstraction Layer", "keywords": ["dbal", "database", "persistence", "queryobject"], "homepage": "http://www.doctrine-project.org", @@ -13,14 +13,22 @@ ], "require": { "php": ">=5.3.2", - "doctrine/common": ">=2.3.0,<2.5-dev" + "doctrine/common": "~2.4" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "symfony/console": "~2.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "suggest": { + "symfony/console": "Allows use of the command line interface" }, "autoload": { - "psr-0": { "Doctrine\\DBAL": "lib/" } + "psr-0": { "Doctrine\\DBAL\\": "lib/" } }, - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } + "archive": { + "exclude": ["!vendor", "tests", "*phpunit.xml", ".travis.yml", "build.xml", "build.properties", "composer.phar"] } } diff --git a/vendor/doctrine/dbal/docs/design/AZURE_FEDERATIONS.md b/vendor/doctrine/dbal/docs/design/AZURE_FEDERATIONS.md deleted file mode 100755 index 99d7e3cfb5..0000000000 --- a/vendor/doctrine/dbal/docs/design/AZURE_FEDERATIONS.md +++ /dev/null @@ -1,94 +0,0 @@ -# Azure Federations - -Implementing Federations inside a new Doctrine Sharding Extension. Some extensions to the DBAL and ORM core have to be done to get this working. - -1. DBAL (Database Abstraction Layer) - -* Add support for Database Schema Operations - * CREATE FEDERATION - * CREATE TABLE ... FEDERATED ON - * Add support to create a multi-tenent schema from any given schema -* Add API to pick a shard based on distribution key and atomic value -* Add API to ask about federations, federation members and so on. -* Add Sharding Abstraction - * If a shard is picked via distribution key and atomic value fire queries against this only - * Or query the global database. - -2. ORM (Object-Relational Mapper) - -* Federation Key has to be part of the clustered index of the table - * Test with a pure Multi-Tenent App with Filtering = ON (TaskList) - * Test with sharded app (Weather) - -## Implementation Details - -SQL Azure requires one and exactly one clustered index. It makes no difference if the primary key -or any other key is the clustered index. Sharding requires an external ID generation (no auto-increment) -such as GUIDs. GUIDs have negative properties with regard to clustered index performance, so that -typically you would add a "created" timestamp for example that holds the clustered index instead -of making the GUID a clustered index. - -## Example API: - - @@@ php - 'tcp:dbname.database.windows.net', - 'sharding' => array( - 'federationName' => 'Orders_Federation', - 'distributionKey' => 'CustID', - 'distributionType' => 'integer', - 'filteringEnabled' => false, - ), - // ... - ); - - $conn = DriverManager::getConnection($dbParams); - $shardManager = $conn->getShardManager(); - - // Example 1: query against root database - $sql = "SELECT * FROM Products"; - $rows = $conn->executeQuery($sql); - - // Example 2: query against the selected shard with CustomerId = 100 - $aCustomerID = 100; - $shardManager->selectShard($aCustomerID); // Using Default federationName and distributionKey - // Query: "USE FEDERATION Orders_Federation (CustID = $aCustomerID) WITH RESET, FILTERING OFF;" - - $sql = "SELECT * FROM Customers"; - $rows = $conn->executeQuery($sql); - - // Example 3: Reset API to root database again - $shardManager->selectGlobal(); - -## ID Generation - -With sharding all the ids have to be generated for global uniqueness. There are three strategies for this. - -1. Use GUIDs as described here http://blogs.msdn.com/b/cbiyikoglu/archive/2011/06/20/id-generation-in-federations-identity-sequences-and-guids-uniqueidentifier.aspx -2. Having a central table that is accessed with a second connection to generate sequential ids -3. Using natural keys from the domain. - -The second approach has the benefit of having numerical primary keys, however also a central failure location. The third strategy can seldom be used, because the domains dont allow this. Identity columns cannot be used at all. - - @@@ php - 'dbname.database.windows.net', - // ... - ); - $conn = DriverManager::getConnection($dbParams); - - $idGenerator = new TableHiLoIdGenerator($conn, 'id_table_name', $multiplicator = 1); - // only once, create this table - $idGenerator->createTable(); - - $nextId = $idGenerator->generateId('for_table_name'); - $nextOtherId = $idGenerator->generateId('for_other_table'); - -The connection for the table generator has to be a different one than the one used for the main app to avoid transaction clashes. diff --git a/vendor/doctrine/dbal/docs/design/SHARDING.md b/vendor/doctrine/dbal/docs/design/SHARDING.md deleted file mode 100755 index 24e6cef3e4..0000000000 --- a/vendor/doctrine/dbal/docs/design/SHARDING.md +++ /dev/null @@ -1,74 +0,0 @@ -# Doctrine Shards - -Doctrine Extension to support horizontal sharding in the Doctrine ORM. - -## Idea - -Implement sharding inside Doctrine at a level that is as unobtrusive to the developer as possible. - -Problems to tackle: - -1. Where to send INSERT statements? -2. How to generate primary keys? -3. How to pick shards for update, delete statements? -4. How to pick shards for select operations? -5. How to merge select queries that span multiple shards? -6. How to handle/prevent multi-shard queries that cannot be merged (GROUP BY)? -7. How to handle non-sharded data? (static metadata tables for example) -8. How to handle multiple connections? -9. Implementation on the DBAL or ORM level? - -## Roadmap - -Version 1: DBAL 2.3 (Multi-Tenant Apps) - - 1. ID Generation support (in DBAL + ORM done) - 2. Multi-Tenant Support: Either pick a global metadata database or exactly one shard. - 3. Fan-out queries over all shards (or a subset) by result appending - -Version 2: ORM related (complex): - - 4. ID resolving (Pick shard for a new ID) - 5. Query resolving (Pick shards a query should send to) - 6. Shard resolving (Pick shards an ID could be on) - 7. Transactions - 8. Read Only objects - -## Technical Requirements for Database Schemas - -Sharded tables require the sharding-distribution key as one of their columns. This will affect your code compared to a normalized db-schema. If you have a Blog <-> BlogPost <-> PostComments entity setup sharded by `blog_id` then even the PostComment table needs this column, even if an "unsharded", normalized DB-Schema does not need this information. - -## Implementation Details - -Assumptions: - -* For querying you either want to query ALL or just exactly one shard. -* IDs for ALL sharded tables have to be unique across all shards. -* Non-shareded data is replicated between all shards. They redundantly keep the information available. This is necessary so join queries on shards to reference data work. -* If you retrieve an object A from a shard, then all references and collections of this object reside on the same shard. -* The database schema on all shards is the same (or compatible) - -### SQL Azure Federations - -SQL Azure is a special case, points 1, 2, 3, 4, 7 and 8 are partly handled on the database level. This makes it a perfect test-implementation for just the subset of features in points 5-6. However there need to be a way to configure SchemaTool to generate the correct Schema on SQL Azure. - -* SELECT Operations: The most simple assumption is to always query all shards unless the user specifies otherwise explicitly. -* Queries can be merged in PHP code, this obviously does not work for DISTINCT, GROUP BY and ORDER BY queries. - -### Generic Sharding - -More features are necessary to implement sharding on the PHP level, independent from database support: - -1. Configuration of multiple connections, one connection = one shard. -2. Primary Key Generation mechanisms (UUID, central table, sequence emulation) - -## Primary Use-Cases - -1. Multi-Tenant Applications - -These are easier to support as you have some value to determine the shard id for the whole request very early on. -Here also queries can always be limited to a single shard. - -2. Scale-Out by some attribute (Round-Robin?) - -This strategy requires access to multiple shards in a single request based on the data accessed. diff --git a/vendor/doctrine/dbal/docs/examples/sharding/README.md b/vendor/doctrine/dbal/docs/examples/sharding/README.md deleted file mode 100755 index 3680e544f4..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Sharding with SQLAzure Example - -This example demonstrates Sharding with SQL Azure Federations. - -## Requirements - -1. Windows Azure Account -2. SQL Azure Database -3. Composer for dependencies - -## Install - - composer install - -Change "examples/sharding/bootstrap.php" to contain Database connection. - -## Order to execute Scripts - -1. create_schema.php -2. view_federation_members.php -3. insert_data.php -4. split_federation.php -5. insert_data_after_split.php -6. query_filtering_off.php -7. query_filtering_on.php - diff --git a/vendor/doctrine/dbal/docs/examples/sharding/bootstrap.php b/vendor/doctrine/dbal/docs/examples/sharding/bootstrap.php deleted file mode 100755 index fe174f1c1b..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/bootstrap.php +++ /dev/null @@ -1,26 +0,0 @@ - 'SalesDB', - 'host' => 'tcp:dbname.windows.net', - 'user' => 'user@dbname', - 'password' => 'XXX', - 'sharding' => array( - 'federationName' => 'Orders_Federation', - 'distributionKey' => 'CustId', - 'distributionType' => 'integer', - ) -); - -if ($config['host'] == "tcp:dbname.windows.net") { - die("You have to change the configuration to your Azure account.\n"); -} - -$conn = DriverManager::getConnection($config); -$shardManager = new SQLAzureShardManager($conn); - diff --git a/vendor/doctrine/dbal/docs/examples/sharding/composer.json b/vendor/doctrine/dbal/docs/examples/sharding/composer.json deleted file mode 100755 index 214f922178..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/composer.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "require": { - "doctrine/dbal": "*", - "doctrine/shards": "0.3" - } -} diff --git a/vendor/doctrine/dbal/docs/examples/sharding/create_schema.php b/vendor/doctrine/dbal/docs/examples/sharding/create_schema.php deleted file mode 100755 index ac6b66cd81..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/create_schema.php +++ /dev/null @@ -1,51 +0,0 @@ -createTable('Products'); -$products->addColumn('ProductID', 'integer'); -$products->addColumn('SupplierID', 'integer'); -$products->addColumn('ProductName', 'string'); -$products->addColumn('Price', 'decimal', array('scale' => 2, 'precision' => 12)); -$products->setPrimaryKey(array('ProductID')); -$products->addOption('azure.federated', true); - -$customers = $schema->createTable('Customers'); -$customers->addColumn('CustomerID', 'integer'); -$customers->addColumn('CompanyName', 'string'); -$customers->addColumn('FirstName', 'string'); -$customers->addColumn('LastName', 'string'); -$customers->setPrimaryKey(array('CustomerID')); -$customers->addOption('azure.federated', true); -$customers->addOption('azure.federatedOnColumnName', 'CustomerID'); - -$orders = $schema->createTable('Orders'); -$orders->addColumn('CustomerID', 'integer'); -$orders->addColumn('OrderID', 'integer'); -$orders->addColumn('OrderDate', 'datetime'); -$orders->setPrimaryKey(array('CustomerID', 'OrderID')); -$orders->addOption('azure.federated', true); -$orders->addOption('azure.federatedOnColumnName', 'CustomerID'); - -$orderItems = $schema->createTable('OrderItems'); -$orderItems->addColumn('CustomerID', 'integer'); -$orderItems->addColumn('OrderID', 'integer'); -$orderItems->addColumn('ProductID', 'integer'); -$orderItems->addColumn('Quantity', 'integer'); -$orderItems->setPrimaryKey(array('CustomerID', 'OrderID', 'ProductID')); -$orderItems->addOption('azure.federated', true); -$orderItems->addOption('azure.federatedOnColumnName', 'CustomerID'); - -// Create the Schema + Federation: -$synchronizer = new SQLAzureSchemaSynchronizer($conn, $shardManager); - -// Or jut look at the SQL: -echo implode("\n", $synchronizer->getCreateSchema($schema)); - -$synchronizer->createSchema($schema); - diff --git a/vendor/doctrine/dbal/docs/examples/sharding/insert_data.php b/vendor/doctrine/dbal/docs/examples/sharding/insert_data.php deleted file mode 100755 index 57aeda6c9f..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/insert_data.php +++ /dev/null @@ -1,132 +0,0 @@ -selectShard(0); - -$conn->insert("Products", array( - "ProductID" => 386, - "SupplierID" => 1001, - "ProductName" => 'Titanium Extension Bracket Left Hand', - "Price" => 5.25, -)); -$conn->insert("Products", array( - "ProductID" => 387, - "SupplierID" => 1001, - "ProductName" => 'Titanium Extension Bracket Right Hand', - "Price" => 5.25, -)); -$conn->insert("Products", array( - "ProductID" => 388, - "SupplierID" => 1001, - "ProductName" => 'Fusion Generator Module 5 kV', - "Price" => 10.50, -)); -$conn->insert("Products", array( - "ProductID" => 389, - "SupplierID" => 1001, - "ProductName" => 'Bypass Filter 400 MHz Low Pass', - "Price" => 10.50, -)); - -$conn->insert("Customers", array( - 'CustomerID' => 10, - 'CompanyName' => 'Van Nuys', - 'FirstName' => 'Catherine', - 'LastName' => 'Abel', -)); -$conn->insert("Customers", array( - 'CustomerID' => 20, - 'CompanyName' => 'Abercrombie', - 'FirstName' => 'Kim', - 'LastName' => 'Branch', -)); -$conn->insert("Customers", array( - 'CustomerID' => 30, - 'CompanyName' => 'Contoso', - 'FirstName' => 'Frances', - 'LastName' => 'Adams', -)); -$conn->insert("Customers", array( - 'CustomerID' => 40, - 'CompanyName' => 'A. Datum Corporation', - 'FirstName' => 'Mark', - 'LastName' => 'Harrington', -)); -$conn->insert("Customers", array( - 'CustomerID' => 50, - 'CompanyName' => 'Adventure Works', - 'FirstName' => 'Keith', - 'LastName' => 'Harris', -)); -$conn->insert("Customers", array( - 'CustomerID' => 60, - 'CompanyName' => 'Alpine Ski House', - 'FirstName' => 'Wilson', - 'LastName' => 'Pais', -)); -$conn->insert("Customers", array( - 'CustomerID' => 70, - 'CompanyName' => 'Baldwin Museum of Science', - 'FirstName' => 'Roger', - 'LastName' => 'Harui', -)); -$conn->insert("Customers", array( - 'CustomerID' => 80, - 'CompanyName' => 'Blue Yonder Airlines', - 'FirstName' => 'Pilar', - 'LastName' => 'Pinilla', -)); -$conn->insert("Customers", array( - 'CustomerID' => 90, - 'CompanyName' => 'City Power & Light', - 'FirstName' => 'Kari', - 'LastName' => 'Hensien', -)); -$conn->insert("Customers", array( - 'CustomerID' => 100, - 'CompanyName' => 'Coho Winery', - 'FirstName' => 'Peter', - 'LastName' => 'Brehm', -)); - -$conn->executeUpdate(" - DECLARE @orderId INT - - DECLARE @customerId INT - - SET @orderId = 10 - SELECT @customerId = CustomerId FROM Customers WHERE LastName = 'Hensien' and FirstName = 'Kari' - - INSERT INTO Orders (CustomerId, OrderId, OrderDate) - VALUES (@customerId, @orderId, GetDate()) - - INSERT INTO OrderItems (CustomerID, OrderID, ProductID, Quantity) - VALUES (@customerId, @orderId, 388, 4) - - SET @orderId = 20 - SELECT @customerId = CustomerId FROM Customers WHERE LastName = 'Harui' and FirstName = 'Roger' - - INSERT INTO Orders (CustomerId, OrderId, OrderDate) - VALUES (@customerId, @orderId, GetDate()) - - INSERT INTO OrderItems (CustomerID, OrderID, ProductID, Quantity) - VALUES (@customerId, @orderId, 389, 2) - - SET @orderId = 30 - SELECT @customerId = CustomerId FROM Customers WHERE LastName = 'Brehm' and FirstName = 'Peter' - - INSERT INTO Orders (CustomerId, OrderId, OrderDate) - VALUES (@customerId, @orderId, GetDate()) - - INSERT INTO OrderItems (CustomerID, OrderID, ProductID, Quantity) - VALUES (@customerId, @orderId, 387, 3) - - SET @orderId = 40 - SELECT @customerId = CustomerId FROM Customers WHERE LastName = 'Pais' and FirstName = 'Wilson' - - INSERT INTO Orders (CustomerId, OrderId, OrderDate) - VALUES (@customerId, @orderId, GetDate()) - - INSERT INTO OrderItems (CustomerID, OrderID, ProductID, Quantity) - VALUES (@customerId, @orderId, 388, 1)"); diff --git a/vendor/doctrine/dbal/docs/examples/sharding/insert_data_aftersplit.php b/vendor/doctrine/dbal/docs/examples/sharding/insert_data_aftersplit.php deleted file mode 100755 index 312e90b235..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/insert_data_aftersplit.php +++ /dev/null @@ -1,27 +0,0 @@ -selectShard($newCustomerId); - -$conn->insert("Customers", array( - "CustomerID" => $newCustomerId, - "CompanyName" => "Microsoft", - "FirstName" => "Brian", - "LastName" => "Swan", -)); - -$conn->insert("Orders", array( - "CustomerID" => 55, - "OrderID" => 37, - "OrderDate" => date('Y-m-d H:i:s'), -)); - -$conn->insert("OrderItems", array( - "CustomerID" => 55, - "OrderID" => 37, - "ProductID" => 387, - "Quantity" => 1, -)); diff --git a/vendor/doctrine/dbal/docs/examples/sharding/query_filtering_off.php b/vendor/doctrine/dbal/docs/examples/sharding/query_filtering_off.php deleted file mode 100755 index c0b24fa087..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/query_filtering_off.php +++ /dev/null @@ -1,8 +0,0 @@ -selectShard(0); - -$data = $conn->fetchAll('SELECT * FROM Customers'); -print_r($data); diff --git a/vendor/doctrine/dbal/docs/examples/sharding/query_filtering_on.php b/vendor/doctrine/dbal/docs/examples/sharding/query_filtering_on.php deleted file mode 100755 index e7d9e14546..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/query_filtering_on.php +++ /dev/null @@ -1,9 +0,0 @@ -setFilteringEnabled(true); -$shardManager->selectShard(55); - -$data = $conn->fetchAll('SELECT * FROM Customers'); -print_r($data); diff --git a/vendor/doctrine/dbal/docs/examples/sharding/split_federation.php b/vendor/doctrine/dbal/docs/examples/sharding/split_federation.php deleted file mode 100755 index ff681edfd2..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/split_federation.php +++ /dev/null @@ -1,5 +0,0 @@ -splitFederation(60); diff --git a/vendor/doctrine/dbal/docs/examples/sharding/view_federation_members.php b/vendor/doctrine/dbal/docs/examples/sharding/view_federation_members.php deleted file mode 100755 index 497e4df6d2..0000000000 --- a/vendor/doctrine/dbal/docs/examples/sharding/view_federation_members.php +++ /dev/null @@ -1,8 +0,0 @@ -getShards(); -foreach ($shards as $shard) { - print_r($shard); -} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/ArrayStatement.php old mode 100755 new mode 100644 index 8ad167bcab..23f9117260 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -24,11 +24,29 @@ use PDO; class ArrayStatement implements \IteratorAggregate, ResultStatement { + /** + * @var array + */ private $data; + + /** + * @var integer + */ private $columnCount = 0; + + /** + * @var integer + */ private $num = 0; + + /** + * @var integer + */ private $defaultFetchMode = PDO::FETCH_BOTH; + /** + * @param array $data + */ public function __construct(array $data) { $this->data = $data; @@ -37,16 +55,25 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement } } + /** + * {@inheritdoc} + */ public function closeCursor() { unset ($this->data); } + /** + * {@inheritdoc} + */ public function columnCount() { return $this->columnCount; } + /** + * {@inheritdoc} + */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { if ($arg2 !== null || $arg3 !== null) { @@ -54,14 +81,23 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement } $this->defaultFetchMode = $fetchMode; + + return true; } + /** + * {@inheritdoc} + */ public function getIterator() { $data = $this->fetchAll(); + return new \ArrayIterator($data); } + /** + * {@inheritdoc} + */ public function fetch($fetchMode = null) { if (isset($this->data[$this->num])) { @@ -79,18 +115,26 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement throw new \InvalidArgumentException("Invalid fetch-style given for fetching result."); } } + return false; } + /** + * {@inheritdoc} + */ public function fetchAll($fetchMode = null) { $rows = array(); while ($row = $this->fetch($fetchMode)) { $rows[] = $row; } + return $rows; } + /** + * {@inheritdoc} + */ public function fetchColumn($columnIndex = 0) { $row = $this->fetch(PDO::FETCH_NUM); @@ -98,6 +142,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement // TODO: verify this is correct behavior return false; } + return $row[$columnIndex]; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php old mode 100755 new mode 100644 index dd274779c4..6b3b5394bb --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/CacheException.php @@ -25,11 +25,17 @@ namespace Doctrine\DBAL\Cache; */ class CacheException extends \Doctrine\DBAL\DBALException { + /** + * @return \Doctrine\DBAL\Cache\CacheException + */ static public function noCacheKey() { return new self("No cache key was set."); } + /** + * @return \Doctrine\DBAL\Cache\CacheException + */ static public function noResultDriverConfigured() { return new self("Trying to cache a query but no result driver is configured."); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php old mode 100755 new mode 100644 index 54c34b9b5c..330eec91f2 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php @@ -31,22 +31,24 @@ use Doctrine\Common\Cache\Cache; class QueryCacheProfile { /** - * @var Cache + * @var \Doctrine\Common\Cache\Cache|null */ private $resultCacheDriver; + /** - * @var int + * @var integer */ private $lifetime = 0; + /** - * @var string + * @var string|null */ private $cacheKey; /** - * @param int $lifetime - * @param string $cacheKey - * @param Cache $resultCache + * @param integer $lifetime + * @param string|null $cacheKey + * @param \Doctrine\Common\Cache\Cache|null $resultCache */ public function __construct($lifetime = 0, $cacheKey = null, Cache $resultCache = null) { @@ -56,7 +58,7 @@ class QueryCacheProfile } /** - * @return Cache + * @return \Doctrine\Common\Cache\Cache|null */ public function getResultCacheDriver() { @@ -64,7 +66,7 @@ class QueryCacheProfile } /** - * @return int + * @return integer */ public function getLifetime() { @@ -73,21 +75,25 @@ class QueryCacheProfile /** * @return string + * + * @throws \Doctrine\DBAL\Cache\CacheException */ public function getCacheKey() { if ($this->cacheKey === null) { throw CacheException::noCacheKey(); } + return $this->cacheKey; } /** - * Generate the real cache key from query, params and types. + * Generates the real cache key from query, params and types. * * @param string $query - * @param array $params - * @param array $types + * @param array $params + * @param array $types + * * @return array */ public function generateCacheKeys($query, $params, $types) @@ -99,12 +105,14 @@ class QueryCacheProfile } else { $cacheKey = $this->cacheKey; } + return array($cacheKey, $realCacheKey); } /** - * @param Cache $cache - * @return QueryCacheProfile + * @param \Doctrine\Common\Cache\Cache $cache + * + * @return \Doctrine\DBAL\Cache\QueryCacheProfile */ public function setResultCacheDriver(Cache $cache) { @@ -113,7 +121,8 @@ class QueryCacheProfile /** * @param string|null $cacheKey - * @return QueryCacheProfile + * + * @return \Doctrine\DBAL\Cache\QueryCacheProfile */ public function setCacheKey($cacheKey) { @@ -121,8 +130,9 @@ class QueryCacheProfile } /** - * @param int $lifetime - * @return QueryCacheProfile + * @param integer $lifetime + * + * @return \Doctrine\DBAL\Cache\QueryCacheProfile */ public function setLifetime($lifetime) { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php old mode 100755 new mode 100644 index f118e7c537..a3afe50a0e --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -21,7 +21,6 @@ namespace Doctrine\DBAL\Cache; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\ResultStatement; -use Doctrine\DBAL\Connection; use Doctrine\Common\Cache\Cache; use PDO; @@ -57,19 +56,19 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement private $realKey; /** - * @var int + * @var integer */ private $lifetime; /** - * @var Doctrine\DBAL\Driver\Statement + * @var \Doctrine\DBAL\Driver\Statement */ private $statement; /** * Did we reach the end of the statement? * - * @var bool + * @var boolean */ private $emptied = false; @@ -79,16 +78,16 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement private $data; /** - * @var int + * @var integer */ private $defaultFetchMode = PDO::FETCH_BOTH; /** - * @param Statement $stmt - * @param Cache $resultCache - * @param string $cacheKey - * @param string $realKey - * @param int $lifetime + * @param \Doctrine\DBAL\Driver\Statement $stmt + * @param \Doctrine\Common\Cache\Cache $resultCache + * @param string $cacheKey + * @param string $realKey + * @param integer $lifetime */ public function __construct(Statement $stmt, Cache $resultCache, $cacheKey, $realKey, $lifetime) { @@ -100,9 +99,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement } /** - * Closes the cursor, enabling the statement to be executed again. - * - * @return boolean Returns TRUE on success or FALSE on failure. + * {@inheritdoc} */ public function closeCursor() { @@ -120,38 +117,35 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement } /** - * columnCount - * Returns the number of columns in the result set - * - * @return integer Returns the number of columns in the result set represented - * by the PDOStatement object. If there is no result set, - * this method should return 0. + * {@inheritdoc} */ public function columnCount() { return $this->statement->columnCount(); } + /** + * {@inheritdoc} + */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { $this->defaultFetchMode = $fetchMode; + + return true; } + /** + * {@inheritdoc} + */ public function getIterator() { $data = $this->fetchAll(); + return new \ArrayIterator($data); } /** - * fetch - * - * @see Query::HYDRATE_* constants - * @param integer $fetchMode Controls how the next row will be returned to the caller. - * This value must be one of the Query::HYDRATE_* constants, - * defaulting to Query::HYDRATE_BOTH - * - * @return mixed + * {@inheritdoc} */ public function fetch($fetchMode = null) { @@ -178,17 +172,12 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement } } $this->emptied = true; + return false; } /** - * Returns an array containing all of the result set rows - * - * @param integer $fetchMode Controls how the next row will be returned to the caller. - * This value must be one of the Query::HYDRATE_* constants, - * defaulting to Query::HYDRATE_BOTH - * - * @return array + * {@inheritdoc} */ public function fetchAll($fetchMode = null) { @@ -196,19 +185,12 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement while ($row = $this->fetch($fetchMode)) { $rows[] = $row; } + return $rows; } /** - * fetchColumn - * Returns a single column from the next row of a - * result set or FALSE if there are no more rows. - * - * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no - * value is supplied, PDOStatement->fetchColumn() - * fetches the first column. - * - * @return string returns a single column in the next row of a result set. + * {@inheritdoc} */ public function fetchColumn($columnIndex = 0) { @@ -217,12 +199,12 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement // TODO: verify this is correct behavior return false; } + return $row[$columnIndex]; } /** - * rowCount - * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement + * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement * executed by the corresponding object. * * If the last SQL statement executed by the associated Statement object was a SELECT statement, @@ -230,7 +212,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement * this behaviour is not guaranteed for all databases and should not be * relied on for portable applications. * - * @return integer Returns the number of rows. + * @return integer The number of rows. */ public function rowCount() { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Configuration.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Configuration.php old mode 100755 new mode 100644 index 53f7b5e7d2..0225d1faa1 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Configuration.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Configuration.php @@ -25,10 +25,10 @@ use Doctrine\Common\Cache\Cache; /** * Configuration container for the Doctrine DBAL. * - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel * @internal When adding a new configuration option just write a getter/setter * pair and add the option to the _attributes array with a proper default value. */ @@ -45,7 +45,9 @@ class Configuration /** * Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled. * - * @param SQLLogger $logger + * @param \Doctrine\DBAL\Logging\SQLLogger|null $logger + * + * @return void */ public function setSQLLogger(SQLLogger $logger = null) { @@ -55,7 +57,7 @@ class Configuration /** * Gets the SQL logger that is used. * - * @return SQLLogger + * @return \Doctrine\DBAL\Logging\SQLLogger */ public function getSQLLogger() { @@ -66,7 +68,7 @@ class Configuration /** * Gets the cache driver implementation that is used for query result caching. * - * @return \Doctrine\Common\Cache\Cache + * @return \Doctrine\Common\Cache\Cache|null */ public function getResultCacheImpl() { @@ -78,6 +80,8 @@ class Configuration * Sets the cache driver implementation that is used for query result caching. * * @param \Doctrine\Common\Cache\Cache $cacheImpl + * + * @return void */ public function setResultCacheImpl(Cache $cacheImpl) { @@ -85,13 +89,15 @@ class Configuration } /** - * Filter schema assets expression. + * Sets the filter schema assets expression. * * Only include tables/sequences matching the filter expression regexp in * schema instances generated for the active connection when calling * {AbstractSchemaManager#createSchema()}. * * @param string $filterExpression + * + * @return void */ public function setFilterSchemaAssetsExpression($filterExpression) { @@ -99,7 +105,7 @@ class Configuration } /** - * Return filter schema assets expression. + * Returns filter schema assets expression. * * @return string|null */ @@ -108,6 +114,7 @@ class Configuration if (isset($this->_attributes['filterSchemaAssetsExpression'])) { return $this->_attributes['filterSchemaAssetsExpression']; } + return null; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php old mode 100755 new mode 100644 index 80efa94b27..85cf0bb281 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php @@ -19,30 +19,31 @@ namespace Doctrine\DBAL; -use PDO, Closure, Exception, - Doctrine\DBAL\Types\Type, - Doctrine\DBAL\Driver\Connection as DriverConnection, - Doctrine\Common\EventManager, - Doctrine\DBAL\DBALException, - Doctrine\DBAL\Cache\ResultCacheStatement, - Doctrine\DBAL\Cache\QueryCacheProfile, - Doctrine\DBAL\Cache\ArrayStatement, - Doctrine\DBAL\Cache\CacheException; +use PDO; +use Closure; +use Exception; +use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Driver\Connection as DriverConnection; +use Doctrine\Common\EventManager; +use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Cache\ResultCacheStatement; +use Doctrine\DBAL\Cache\QueryCacheProfile; +use Doctrine\DBAL\Cache\ArrayStatement; +use Doctrine\DBAL\Cache\CacheException; /** * A wrapper around a Doctrine\DBAL\Driver\Connection that adds features like * events, transaction isolation levels, configuration, emulated transaction nesting, * lazy connecting and more. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Konsta Vesterinen - * @author Lukas Smith (MDB2 library) - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Konsta Vesterinen + * @author Lukas Smith (MDB2 library) + * @author Benjamin Eberlei */ class Connection implements DriverConnection { @@ -69,21 +70,21 @@ class Connection implements DriverConnection /** * Represents an array of ints to be expanded by Doctrine SQL parsing. * - * @var int + * @var integer */ const PARAM_INT_ARRAY = 101; /** * Represents an array of strings to be expanded by Doctrine SQL parsing. * - * @var int + * @var integer */ const PARAM_STR_ARRAY = 102; /** * Offset by which PARAM_* constants are detected as arrays of the param type. * - * @var int + * @var integer */ const ARRAY_PARAM_OFFSET = 100; @@ -131,7 +132,7 @@ class Connection implements DriverConnection private $_transactionIsolationLevel; /** - * If nested transations should use savepoints + * If nested transactions should use savepoints. * * @var integer */ @@ -173,15 +174,20 @@ class Connection implements DriverConnection */ private $_isRollbackOnly = false; - private $_defaultFetchMode = PDO::FETCH_ASSOC; + /** + * @var integer + */ + protected $defaultFetchMode = PDO::FETCH_ASSOC; /** * Initializes a new instance of the Connection class. * - * @param array $params The connection parameters. - * @param Driver $driver - * @param Configuration $config - * @param EventManager $eventManager + * @param array $params The connection parameters. + * @param \Doctrine\DBAL\Driver $driver The driver to use. + * @param \Doctrine\DBAL\Configuration|null $config The configuration, optional. + * @param \Doctrine\Common\EventManager|null $eventManager The event manager, optional. + * + * @throws \Doctrine\DBAL\DBALException */ public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) @@ -224,7 +230,7 @@ class Connection implements DriverConnection /** * Gets the parameters used during instantiation. * - * @return array $params + * @return array */ public function getParams() { @@ -234,7 +240,7 @@ class Connection implements DriverConnection /** * Gets the name of the database this Connection is connected to. * - * @return string $database + * @return string */ public function getDatabase() { @@ -244,7 +250,7 @@ class Connection implements DriverConnection /** * Gets the hostname of the currently connected database. * - * @return string + * @return string|null */ public function getHost() { @@ -264,7 +270,7 @@ class Connection implements DriverConnection /** * Gets the username used by this connection. * - * @return string + * @return string|null */ public function getUsername() { @@ -274,7 +280,7 @@ class Connection implements DriverConnection /** * Gets the password used by this connection. * - * @return string + * @return string|null */ public function getPassword() { @@ -359,13 +365,15 @@ class Connection implements DriverConnection } /** - * setFetchMode + * Sets the fetch mode. * * @param integer $fetchMode + * + * @return void */ public function setFetchMode($fetchMode) { - $this->_defaultFetchMode = $fetchMode; + $this->defaultFetchMode = $fetchMode; } /** @@ -373,7 +381,8 @@ class Connection implements DriverConnection * as an associative array. * * @param string $statement The SQL query. - * @param array $params The query parameters. + * @param array $params The query parameters. + * * @return array */ public function fetchAssoc($statement, array $params = array()) @@ -385,8 +394,9 @@ class Connection implements DriverConnection * Prepares and executes an SQL query and returns the first row of the result * as a numerically indexed array. * - * @param string $statement sql query to be executed - * @param array $params prepared statement params + * @param string $statement The SQL query to be executed. + * @param array $params The prepared statement params. + * * @return array */ public function fetchArray($statement, array $params = array()) @@ -398,9 +408,10 @@ class Connection implements DriverConnection * Prepares and executes an SQL query and returns the value of a single column * of the first row of the result. * - * @param string $statement sql query to be executed - * @param array $params prepared statement params - * @param int $colnum 0-indexed column number to retrieve + * @param string $statement The SQL query to be executed. + * @param array $params The prepared statement params. + * @param integer $colnum The 0-indexed column number to retrieve. + * * @return mixed */ public function fetchColumn($statement, array $params = array(), $colnum = 0) @@ -431,11 +442,13 @@ class Connection implements DriverConnection /** * Executes an SQL DELETE statement on a table. * - * @param string $tableName The name of the table on which to delete. - * @param array $identifier The deletion criteria. An associative array containing column-value pairs. + * @param string $tableName The name of the table on which to delete. + * @param array $identifier The deletion criteria. An associative array containing column-value pairs. + * @param array $types The types of identifiers. + * * @return integer The number of affected rows. */ - public function delete($tableName, array $identifier) + public function delete($tableName, array $identifier, array $types = array()) { $this->connect(); @@ -445,9 +458,13 @@ class Connection implements DriverConnection $criteria[] = $columnName . ' = ?'; } + if ( ! is_int(key($types))) { + $types = $this->extractTypeValues($identifier, $types); + } + $query = 'DELETE FROM ' . $tableName . ' WHERE ' . implode(' AND ', $criteria); - return $this->executeUpdate($query, array_values($identifier)); + return $this->executeUpdate($query, array_values($identifier), $types); } /** @@ -466,6 +483,7 @@ class Connection implements DriverConnection * Sets the transaction isolation level. * * @param integer $level The level to set. + * * @return integer */ public function setTransactionIsolation($level) @@ -488,20 +506,26 @@ class Connection implements DriverConnection /** * Executes an SQL UPDATE statement on a table. * - * @param string $tableName The name of the table to update. - * @param array $data - * @param array $identifier The update criteria. An associative array containing column-value pairs. - * @param array $types Types of the merged $data and $identifier arrays in that order. + * @param string $tableName The name of the table to update. + * @param array $data An associative array containing column-value pairs. + * @param array $identifier The update criteria. An associative array containing column-value pairs. + * @param array $types Types of the merged $data and $identifier arrays in that order. + * * @return integer The number of affected rows. */ public function update($tableName, array $data, array $identifier, array $types = array()) { $this->connect(); $set = array(); + foreach ($data as $columnName => $value) { $set[] = $columnName . ' = ?'; } + if ( ! is_int(key($types))) { + $types = $this->extractTypeValues(array_merge($data, $identifier), $types); + } + $params = array_merge(array_values($data), array_values($identifier)); $sql = 'UPDATE ' . $tableName . ' SET ' . implode(', ', $set) @@ -515,32 +539,49 @@ class Connection implements DriverConnection * Inserts a table row with specified data. * * @param string $tableName The name of the table to insert data into. - * @param array $data An associative array containing column-value pairs. - * @param array $types Types of the inserted data. + * @param array $data An associative array containing column-value pairs. + * @param array $types Types of the inserted data. + * * @return integer The number of affected rows. */ public function insert($tableName, array $data, array $types = array()) { $this->connect(); - // column names are specified as array keys - $cols = array(); - $placeholders = array(); - - foreach ($data as $columnName => $value) { - $cols[] = $columnName; - $placeholders[] = '?'; + if ( ! is_int(key($types))) { + $types = $this->extractTypeValues($data, $types); } $query = 'INSERT INTO ' . $tableName - . ' (' . implode(', ', $cols) . ')' - . ' VALUES (' . implode(', ', $placeholders) . ')'; + . ' (' . implode(', ', array_keys($data)) . ')' + . ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')'; return $this->executeUpdate($query, array_values($data), $types); } /** - * Quote a string so it can be safely used as a table or column name, even if + * Extract ordered type list from two associate key lists of data and types. + * + * @param array $data + * @param array $types + * + * @return array + */ + private function extractTypeValues(array $data, array $types) + { + $typeValues = array(); + + foreach ($data as $k => $_) { + $typeValues[] = isset($types[$k]) + ? $types[$k] + : \PDO::PARAM_STR; + } + + return $typeValues; + } + + /** + * Quotes a string so it can be safely used as a table or column name, even if * it is a reserved name. * * Delimiting style depends on the underlying database platform that is being used. @@ -550,6 +591,7 @@ class Connection implements DriverConnection * problems than they solve. * * @param string $str The name to be quoted. + * * @return string The quoted name. */ public function quoteIdentifier($str) @@ -560,8 +602,9 @@ class Connection implements DriverConnection /** * Quotes a given input parameter. * - * @param mixed $input Parameter to be quoted. - * @param string $type Type of the parameter. + * @param mixed $input The parameter to be quoted. + * @param string|null $type The type of the parameter. + * * @return string The quoted parameter. */ public function quote($input, $type = null) @@ -575,20 +618,25 @@ class Connection implements DriverConnection /** * Prepares and executes an SQL query and returns the result as an associative array. * - * @param string $sql The SQL query. - * @param array $params The query parameters. + * @param string $sql The SQL query. + * @param array $params The query parameters. + * @param array $types The query parameter types. + * * @return array */ - public function fetchAll($sql, array $params = array()) + public function fetchAll($sql, array $params = array(), $types = array()) { - return $this->executeQuery($sql, $params)->fetchAll(); + return $this->executeQuery($sql, $params, $types)->fetchAll(); } /** * Prepares an SQL statement. * * @param string $statement The SQL statement to prepare. + * * @return \Doctrine\DBAL\Driver\Statement The prepared statement. + * + * @throws \Doctrine\DBAL\DBALException */ public function prepare($statement) { @@ -600,22 +648,26 @@ class Connection implements DriverConnection throw DBALException::driverExceptionDuringQuery($ex, $statement); } - $stmt->setFetchMode($this->_defaultFetchMode); + $stmt->setFetchMode($this->defaultFetchMode); return $stmt; } /** - * Executes an, optionally parameterized, SQL query. + * Executes an, optionally parametrized, SQL query. * - * If the query is parameterized, a prepared statement is used. + * If the query is parametrized, a prepared statement is used. * If an SQLLogger is configured, the execution is logged. * - * @param string $query The SQL query to execute. - * @param array $params The parameters to bind to the query, if any. - * @param array $types The types the previous parameters are in. - * @param QueryCacheProfile $qcp + * @param string $query The SQL query to execute. + * @param array $params The parameters to bind to the query, if any. + * @param array $types The types the previous parameters are in. + * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp The query cache profile, optional. + * * @return \Doctrine\DBAL\Driver\Statement The executed statement. + * + * @throws \Doctrine\DBAL\DBALException + * * @internal PERF: Directly prepares a driver statement, not a wrapper. */ public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null) @@ -649,7 +701,7 @@ class Connection implements DriverConnection throw DBALException::driverExceptionDuringQuery($ex, $query, $this->resolveParams($params, $types)); } - $stmt->setFetchMode($this->_defaultFetchMode); + $stmt->setFetchMode($this->defaultFetchMode); if ($logger) { $logger->stopQuery(); @@ -659,13 +711,16 @@ class Connection implements DriverConnection } /** - * Execute a caching query and + * Executes a caching query. + * + * @param string $query The SQL query to execute. + * @param array $params The parameters to bind to the query, if any. + * @param array $types The types the previous parameters are in. + * @param \Doctrine\DBAL\Cache\QueryCacheProfile $qcp The query cache profile. * - * @param string $query - * @param array $params - * @param array $types - * @param QueryCacheProfile $qcp * @return \Doctrine\DBAL\Driver\ResultStatement + * + * @throws \Doctrine\DBAL\Cache\CacheException */ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp) { @@ -690,20 +745,21 @@ class Connection implements DriverConnection $stmt = new ResultCacheStatement($this->executeQuery($query, $params, $types), $resultCache, $cacheKey, $realKey, $qcp->getLifetime()); } - $stmt->setFetchMode($this->_defaultFetchMode); + $stmt->setFetchMode($this->defaultFetchMode); return $stmt; } /** - * Executes an, optionally parameterized, SQL query and returns the result, + * Executes an, optionally parametrized, SQL query and returns the result, * applying a given projection/transformation function on each row of the result. * - * @param string $query The SQL query to execute. - * @param array $params The parameters, if any. - * @param Closure $mapper The transformation function that is applied on each row. - * The function receives a single paramater, an array, that - * represents a row of the result set. + * @param string $query The SQL query to execute. + * @param array $params The parameters, if any. + * @param \Closure $function The transformation function that is applied on each row. + * The function receives a single parameter, an array, that + * represents a row of the result set. + * * @return mixed The projected result of the query. */ public function project($query, array $params, Closure $function) @@ -723,9 +779,9 @@ class Connection implements DriverConnection /** * Executes an SQL statement, returning a result set as a Statement object. * - * @param string $statement - * @param integer $fetchType * @return \Doctrine\DBAL\Driver\Statement + * + * @throws \Doctrine\DBAL\DBALException */ public function query() { @@ -739,12 +795,22 @@ class Connection implements DriverConnection } try { - $statement = call_user_func_array(array($this->_conn, 'query'), $args); + switch (func_num_args()) { + case 1: + $statement = $this->_conn->query($args[0]); + break; + case 2: + $statement = $this->_conn->query($args[0], $args[1]); + break; + default: + $statement = call_user_func_array(array($this->_conn, 'query'), $args); + break; + } } catch (\Exception $ex) { - throw DBALException::driverExceptionDuringQuery($ex, func_get_arg(0)); + throw DBALException::driverExceptionDuringQuery($ex, $args[0]); } - $statement->setFetchMode($this->_defaultFetchMode); + $statement->setFetchMode($this->defaultFetchMode); if ($logger) { $logger->stopQuery(); @@ -759,10 +825,14 @@ class Connection implements DriverConnection * * This method supports PDO binding types as well as DBAL mapping types. * - * @param string $query The SQL query. - * @param array $params The query parameters. - * @param array $types The parameter types. + * @param string $query The SQL query. + * @param array $params The query parameters. + * @param array $types The parameter types. + * * @return integer The number of affected rows. + * + * @throws \Doctrine\DBAL\DBALException + * * @internal PERF: Directly prepares a driver statement, not a wrapper. */ public function executeUpdate($query, array $params = array(), array $types = array()) @@ -801,10 +871,13 @@ class Connection implements DriverConnection } /** - * Execute an SQL statement and return the number of affected rows. + * Executes an SQL statement and return the number of affected rows. * * @param string $statement + * * @return integer The number of affected rows. + * + * @throws \Doctrine\DBAL\DBALException */ public function exec($statement) { @@ -839,24 +912,26 @@ class Connection implements DriverConnection } /** - * Fetch the SQLSTATE associated with the last database operation. + * Fetches the SQLSTATE associated with the last database operation. * * @return integer The last error code. */ public function errorCode() { $this->connect(); + return $this->_conn->errorCode(); } /** - * Fetch extended error information associated with the last database operation. + * Fetches extended error information associated with the last database operation. * * @return array The last error information. */ public function errorInfo() { $this->connect(); + return $this->_conn->errorInfo(); } @@ -868,12 +943,14 @@ class Connection implements DriverConnection * because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY * columns or sequences. * - * @param string $seqName Name of the sequence object from which the ID should be returned. + * @param string|null $seqName Name of the sequence object from which the ID should be returned. + * * @return string A string representation of the last inserted ID. */ public function lastInsertId($seqName = null) { $this->connect(); + return $this->_conn->lastInsertId($seqName); } @@ -885,7 +962,11 @@ class Connection implements DriverConnection * If an exception occurs during execution of the function or transaction commit, * the transaction is rolled back and the exception re-thrown. * - * @param Closure $func The function to execute transactionally. + * @param \Closure $func The function to execute transactionally. + * + * @return void + * + * @throws \Exception */ public function transactional(Closure $func) { @@ -900,10 +981,13 @@ class Connection implements DriverConnection } /** - * Set if nested transactions should use savepoints + * Sets if nested transactions should use savepoints. * * @param boolean $nestTransactionsWithSavepoints + * * @return void + * + * @throws \Doctrine\DBAL\ConnectionException */ public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoints) { @@ -919,7 +1003,7 @@ class Connection implements DriverConnection } /** - * Get if nested transactions should use savepoints + * Gets if nested transactions should use savepoints. * * @return boolean */ @@ -932,7 +1016,7 @@ class Connection implements DriverConnection * Returns the savepoint name to use for nested transactions are false if they are not supported * "savepointFormat" parameter is not set * - * @return mixed a string with the savepoint name or false + * @return mixed A string with the savepoint name or false. */ protected function _getNestedTransactionSavePointName() { @@ -975,8 +1059,9 @@ class Connection implements DriverConnection * Commits the current transaction. * * @return void - * @throws ConnectionException If the commit failed due to no active transaction or - * because the transaction was marked for rollback only. + * + * @throws \Doctrine\DBAL\ConnectionException If the commit failed due to no active transaction or + * because the transaction was marked for rollback only. */ public function commit() { @@ -1013,12 +1098,12 @@ class Connection implements DriverConnection } /** - * Cancel any database changes done during the current transaction. + * Cancels any database changes done during the current transaction. * - * this method can be listened with onPreTransactionRollback and onTransactionRollback - * eventlistener methods + * This method can be listened with onPreTransactionRollback and onTransactionRollback + * eventlistener methods. * - * @throws ConnectionException If the rollback operation failed. + * @throws \Doctrine\DBAL\ConnectionException If the rollback operation failed. */ public function rollBack() { @@ -1056,11 +1141,13 @@ class Connection implements DriverConnection } /** - * createSavepoint - * creates a new savepoint + * Creates a new savepoint. + * + * @param string $savepoint The name of the savepoint to create. * - * @param string $savepoint name of a savepoint to set * @return void + * + * @throws \Doctrine\DBAL\ConnectionException */ public function createSavepoint($savepoint) { @@ -1072,11 +1159,13 @@ class Connection implements DriverConnection } /** - * releaseSavePoint - * releases given savepoint + * Releases the given savepoint. + * + * @param string $savepoint The name of the savepoint to release. * - * @param string $savepoint name of a savepoint to release * @return void + * + * @throws \Doctrine\DBAL\ConnectionException */ public function releaseSavepoint($savepoint) { @@ -1090,11 +1179,13 @@ class Connection implements DriverConnection } /** - * rollbackSavePoint - * releases given savepoint + * Rolls back to the given savepoint. + * + * @param string $savepoint The name of the savepoint to rollback to. * - * @param string $savepoint name of a savepoint to rollback to * @return void + * + * @throws \Doctrine\DBAL\ConnectionException */ public function rollbackSavepoint($savepoint) { @@ -1136,7 +1227,9 @@ class Connection implements DriverConnection * Marks the current transaction so that the only possible * outcome for the transaction to be rolled back. * - * @throws ConnectionException If no transaction is active. + * @return void + * + * @throws \Doctrine\DBAL\ConnectionException If no transaction is active. */ public function setRollbackOnly() { @@ -1147,16 +1240,18 @@ class Connection implements DriverConnection } /** - * Check whether the current transaction is marked for rollback only. + * Checks whether the current transaction is marked for rollback only. * * @return boolean - * @throws ConnectionException If no transaction is active. + * + * @throws \Doctrine\DBAL\ConnectionException If no transaction is active. */ public function isRollbackOnly() { if ($this->_transactionNestingLevel == 0) { throw ConnectionException::noActiveTransaction(); } + return $this->_isRollbackOnly; } @@ -1164,8 +1259,9 @@ class Connection implements DriverConnection * Converts a given value to its database representation according to the conversion * rules of a specific DBAL mapping type. * - * @param mixed $value The value to convert. - * @param string $type The name of the DBAL mapping type. + * @param mixed $value The value to convert. + * @param string $type The name of the DBAL mapping type. + * * @return mixed The converted value. */ public function convertToDatabaseValue($value, $type) @@ -1177,8 +1273,9 @@ class Connection implements DriverConnection * Converts a given value to its PHP representation according to the conversion * rules of a specific DBAL mapping type. * - * @param mixed $value The value to convert. - * @param string $type The name of the DBAL mapping type. + * @param mixed $value The value to convert. + * @param string $type The name of the DBAL mapping type. + * * @return mixed The converted type. */ public function convertToPHPValue($value, $type) @@ -1190,9 +1287,12 @@ class Connection implements DriverConnection * Binds a set of parameters, some or all of which are typed with a PDO binding type * or DBAL mapping type, to a given statement. * - * @param string $stmt The statement to bind the values to. - * @param array $params The map/list of named/positional parameters. - * @param array $types The parameter types (PDO binding types or DBAL mapping types). + * @param \Doctrine\DBAL\Driver\Statement $stmt The statement to bind the values to. + * @param array $params The map/list of named/positional parameters. + * @param array $types The parameter types (PDO binding types or DBAL mapping types). + * + * @return void + * * @internal Duck-typing used on the $stmt parameter to support driver statements as well as * raw PDOStatement instances. */ @@ -1231,9 +1331,10 @@ class Connection implements DriverConnection /** * Gets the binding type of a given type. The given type can be a PDO or DBAL mapping type. * - * @param mixed $value The value to bind - * @param mixed $type The type to bind (PDO or DBAL) - * @return array [0] => the (escaped) value, [1] => the binding type + * @param mixed $value The value to bind. + * @param mixed $type The type to bind (PDO or DBAL). + * + * @return array [0] => the (escaped) value, [1] => the binding type. */ private function getBindingInfo($value, $type) { @@ -1246,6 +1347,7 @@ class Connection implements DriverConnection } else { $bindingType = $type; // PDO::PARAM_* constants } + return array($value, $bindingType); } @@ -1297,7 +1399,7 @@ class Connection implements DriverConnection } /** - * Create a new instance of a SQL query builder. + * Creates a new instance of a SQL query builder. * * @return \Doctrine\DBAL\Query\QueryBuilder */ diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/ConnectionException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/ConnectionException.php old mode 100755 new mode 100644 index 4b41ef2493..86494b0361 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/ConnectionException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/ConnectionException.php @@ -1,7 +1,5 @@ null, 'slave' => null); @@ -94,17 +93,19 @@ class MasterSlaveConnection extends Connection * You can keep the slave connection and then switch back to it * during the request if you know what you are doing. * - * @var bool + * @var boolean */ protected $keepSlave = false; /** - * Create Master Slave Connection + * Creates Master Slave Connection. * - * @param array $params - * @param Driver $driver - * @param Configuration $config - * @param EventManager $eventManager + * @param array $params + * @param \Doctrine\DBAL\Driver $driver + * @param \Doctrine\DBAL\Configuration|null $config + * @param \Doctrine\Common\EventManager|null $eventManager + * + * @throws \InvalidArgumentException */ public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) { @@ -126,9 +127,9 @@ class MasterSlaveConnection extends Connection } /** - * Check if the connection is currently towards the master or not. + * Checks if the connection is currently towards the master or not. * - * @return bool + * @return boolean */ public function isConnectedToMaster() { @@ -194,10 +195,11 @@ class MasterSlaveConnection extends Connection } /** - * Connect to a specific connection + * Connects to a specific connection. * - * @param string $connectionName - * @return Driver + * @param string $connectionName + * + * @return \Doctrine\DBAL\Driver */ protected function connectTo($connectionName) { @@ -213,6 +215,12 @@ class MasterSlaveConnection extends Connection return $this->_driver->connect($connectionParams, $user, $password, $driverOptions); } + /** + * @param string $connectionName + * @param array $params + * + * @return mixed + */ protected function chooseConnectionConfiguration($connectionName, $params) { if ($connectionName === 'master') { @@ -228,6 +236,7 @@ class MasterSlaveConnection extends Connection public function executeUpdate($query, array $params = array(), array $types = array()) { $this->connect('master'); + return parent::executeUpdate($query, $params, $types); } @@ -237,6 +246,7 @@ class MasterSlaveConnection extends Connection public function beginTransaction() { $this->connect('master'); + return parent::beginTransaction(); } @@ -246,6 +256,7 @@ class MasterSlaveConnection extends Connection public function commit() { $this->connect('master'); + return parent::commit(); } @@ -255,16 +266,18 @@ class MasterSlaveConnection extends Connection public function rollBack() { $this->connect('master'); + return parent::rollBack(); } /** * {@inheritDoc} */ - public function delete($tableName, array $identifier) + public function delete($tableName, array $identifier, array $types = array()) { $this->connect('master'); - return parent::delete($tableName, $identifier); + + return parent::delete($tableName, $identifier, $types); } /** @@ -273,6 +286,7 @@ class MasterSlaveConnection extends Connection public function update($tableName, array $data, array $identifier, array $types = array()) { $this->connect('master'); + return parent::update($tableName, $data, $identifier, $types); } @@ -282,6 +296,7 @@ class MasterSlaveConnection extends Connection public function insert($tableName, array $data, array $types = array()) { $this->connect('master'); + return parent::insert($tableName, $data, $types); } @@ -291,6 +306,7 @@ class MasterSlaveConnection extends Connection public function exec($statement) { $this->connect('master'); + return parent::exec($statement); } @@ -324,6 +340,9 @@ class MasterSlaveConnection extends Connection return parent::rollbackSavepoint($savepoint); } + /** + * {@inheritDoc} + */ public function query() { $this->connect('master'); @@ -344,6 +363,9 @@ class MasterSlaveConnection extends Connection return $statement; } + /** + * {@inheritDoc} + */ public function prepare($statement) { $this->connect('master'); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php old mode 100755 new mode 100644 index 2b4151e0d9..b101f48d9b --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php @@ -1,14 +1,39 @@ . + */ namespace Doctrine\DBAL; class DBALException extends \Exception { + /** + * @param string $method + * + * @return \Doctrine\DBAL\DBALException + */ public static function notSupported($method) { return new self("Operation '$method' is not supported by platform."); } + /** + * @return \Doctrine\DBAL\DBALException + */ public static function invalidPlatformSpecified() { return new self( @@ -16,6 +41,9 @@ class DBALException extends \Exception "\Doctrine\DBAL\Platforms\AbstractPlatform."); } + /** + * @return \Doctrine\DBAL\DBALException + */ public static function invalidPdoInstance() { return new self( @@ -24,18 +52,34 @@ class DBALException extends \Exception ); } + /** + * @return \Doctrine\DBAL\DBALException + */ public static function driverRequired() { return new self("The options 'driver' or 'driverClass' are mandatory if no PDO ". "instance is given to DriverManager::getConnection()."); } + /** + * @param string $unknownDriverName + * @param array $knownDrivers + * + * @return \Doctrine\DBAL\DBALException + */ public static function unknownDriver($unknownDriverName, array $knownDrivers) { return new self("The given 'driver' ".$unknownDriverName." is unknown, ". "Doctrine currently supports only the following drivers: ".implode(", ", $knownDrivers)); } + /** + * @param \Exception $driverEx + * @param string $sql + * @param array $params + * + * @return \Doctrine\DBAL\DBALException + */ public static function driverExceptionDuringQuery(\Exception $driverEx, $sql, array $params = array()) { $msg = "An exception occurred while executing '".$sql."'"; @@ -69,12 +113,22 @@ class DBALException extends \Exception }, $params)) . ']'; } + /** + * @param string $wrapperClass + * + * @return \Doctrine\DBAL\DBALException + */ public static function invalidWrapperClass($wrapperClass) { return new self("The given 'wrapperClass' ".$wrapperClass." has to be a ". "subtype of \Doctrine\DBAL\Connection."); } + /** + * @param string $driverClass + * + * @return \Doctrine\DBAL\DBALException + */ public static function invalidDriverClass($driverClass) { return new self("The given 'driverClass' ".$driverClass." has to implement the ". @@ -83,7 +137,8 @@ class DBALException extends \Exception /** * @param string $tableName - * @return DBALException + * + * @return \Doctrine\DBAL\DBALException */ public static function invalidTableName($tableName) { @@ -92,28 +147,42 @@ class DBALException extends \Exception /** * @param string $tableName - * @return DBALException + * + * @return \Doctrine\DBAL\DBALException */ public static function noColumnsSpecifiedForTable($tableName) { return new self("No columns specified for table ".$tableName); } + /** + * @return \Doctrine\DBAL\DBALException + */ public static function limitOffsetInvalid() { return new self("Invalid Offset in Limit Query, it has to be larger or equal to 0."); } + /** + * @param string $name + * + * @return \Doctrine\DBAL\DBALException + */ public static function typeExists($name) { return new self('Type '.$name.' already exists.'); } + /** + * @param string $name + * + * @return \Doctrine\DBAL\DBALException + */ public static function unknownColumnType($name) { return new self('Unknown column type "'.$name.'" requested. Any Doctrine type that you use has ' . 'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the ' . - 'known types with \Doctrine\DBAL\Types\Type::getTypeMap(). If this error occurs during database ' . + 'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database ' . 'introspection then you might have forgot to register all database types for a Doctrine Type. Use ' . 'AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement ' . 'Type#getMappedDatabaseTypes(). If the type name is empty you might ' . @@ -121,6 +190,11 @@ class DBALException extends \Exception ); } + /** + * @param string $name + * + * @return \Doctrine\DBAL\DBALException + */ public static function typeNotFound($name) { return new self('Type to be overwritten '.$name.' does not exist.'); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver.php old mode 100755 new mode 100644 index 83649902f3..21d6064664 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver.php @@ -30,10 +30,11 @@ interface Driver /** * Attempts to create a connection with the database. * - * @param array $params All connection parameters passed by the user. - * @param string $username The username to use when connecting. - * @param string $password The password to use when connecting. - * @param array $driverOptions The driver options to use when connecting. + * @param array $params All connection parameters passed by the user. + * @param string|null $username The username to use when connecting. + * @param string|null $password The password to use when connecting. + * @param array $driverOptions The driver options to use when connecting. + * * @return \Doctrine\DBAL\Driver\Connection The database connection. */ public function connect(array $params, $username = null, $password = null, array $driverOptions = array()); @@ -50,7 +51,8 @@ interface Driver * Gets the SchemaManager that can be used to inspect and change the underlying * database schema of the platform this driver connects to. * - * @param \Doctrine\DBAL\Connection $conn + * @param \Doctrine\DBAL\Connection $conn + * * @return \Doctrine\DBAL\Schema\AbstractSchemaManager */ public function getSchemaManager(Connection $conn); @@ -63,10 +65,11 @@ interface Driver public function getName(); /** - * Get the name of the database connected to for this driver. + * Gets the name of the database connected to for this driver. * - * @param \Doctrine\DBAL\Connection $conn - * @return string $database + * @param \Doctrine\DBAL\Connection $conn + * + * @return string The name of the database. */ public function getDatabase(Connection $conn); } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Connection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Connection.php old mode 100755 new mode 100644 index a618487b2a..401f2175c8 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Connection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Connection.php @@ -29,14 +29,82 @@ namespace Doctrine\DBAL\Driver; */ interface Connection { + /** + * Prepares a statement for execution and returns a Statement object. + * + * @param string $prepareString + * + * @return \Doctrine\DBAL\Driver\Statement + */ function prepare($prepareString); + + /** + * Executes an SQL statement, returning a result set as a Statement object. + * + * @return \Doctrine\DBAL\Driver\Statement + */ function query(); + + /** + * Quotes a string for use in a query. + * + * @param string $input + * @param integer $type + * + * @return string + */ function quote($input, $type=\PDO::PARAM_STR); + + /** + * Executes an SQL statement and return the number of affected rows. + * + * @param string $statement + * + * @return integer + */ function exec($statement); + + /** + * Returns the ID of the last inserted row or sequence value. + * + * @param string|null $name + * + * @return string + */ function lastInsertId($name = null); + + /** + * Initiates a transaction. + * + * @return boolean TRUE on success or FALSE on failure. + */ function beginTransaction(); + + /** + * Commits a transaction. + * + * @return boolean TRUE on success or FALSE on failure. + */ function commit(); + + /** + * Rolls back the current transaction, as initiated by beginTransaction(). + * + * @return boolean TRUE on success or FALSE on failure. + */ function rollBack(); + + /** + * Returns the error code associated with the last operation on the database handle. + * + * @return string|null The error code, or null if no operation has been run on the database handle. + */ function errorCode(); + + /** + * Returns extended error information associated with the last operation on the database handle. + * + * @return array + */ function errorInfo(); } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php old mode 100755 new mode 100644 index 8030bbc4e5..376718b509 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php @@ -43,7 +43,9 @@ class Driver implements \Doctrine\DBAL\Driver /** * Constructs the Drizzle MySql PDO DSN. * - * @return string The DSN. + * @param array $params + * + * @return string The DSN. */ private function _constructPdoDsn(array $params) { @@ -94,6 +96,7 @@ class Driver implements \Doctrine\DBAL\Driver public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); + return $params['dbname']; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php old mode 100755 new mode 100644 index c1c2212fd6..4571c45104 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL\Driver\IBMDB2; class DB2Connection implements \Doctrine\DBAL\Driver\Connection { + /** + * @var resource + */ private $_conn = null; + /** + * @param array $params + * @param string $username + * @param string $password + * @param array $driverOptions + * + * @throws \Doctrine\DBAL\Driver\IBMDB2\DB2Exception + */ public function __construct(array $params, $username, $password, $driverOptions = array()) { $isPersistant = (isset($params['persistent']) && $params['persistent'] == true); @@ -39,6 +48,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection } } + /** + * {@inheritdoc} + */ public function prepare($sql) { $stmt = @db2_prepare($this->_conn, $sql); @@ -48,6 +60,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection return new DB2Statement($stmt); } + /** + * {@inheritdoc} + */ public function query() { $args = func_get_args(); @@ -57,6 +72,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection return $stmt; } + /** + * {@inheritdoc} + */ public function quote($input, $type=\PDO::PARAM_STR) { $input = db2_escape_string($input); @@ -67,6 +85,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection } } + /** + * {@inheritdoc} + */ public function exec($statement) { $stmt = $this->prepare($statement); @@ -74,16 +95,25 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection return $stmt->rowCount(); } + /** + * {@inheritdoc} + */ public function lastInsertId($name = null) { return db2_last_insert_id($this->_conn); } + /** + * {@inheritdoc} + */ public function beginTransaction() { db2_autocommit($this->_conn, DB2_AUTOCOMMIT_OFF); } + /** + * {@inheritdoc} + */ public function commit() { if (!db2_commit($this->_conn)) { @@ -92,6 +122,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON); } + /** + * {@inheritdoc} + */ public function rollBack() { if (!db2_rollback($this->_conn)) { @@ -100,11 +133,17 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON); } + /** + * {@inheritdoc} + */ public function errorCode() { return db2_conn_error($this->_conn); } + /** + * {@inheritdoc} + */ public function errorInfo() { return array( diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php old mode 100755 new mode 100644 index 82c71e5d50..447b2c5b13 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php @@ -15,15 +15,15 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Driver\IBMDB2; -use Doctrine\DBAL\Driver, - Doctrine\DBAL\Connection; +use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Connection; /** - * IBM DB2 Driver + * IBM DB2 Driver. * * @since 2.0 * @author Benjamin Eberlei @@ -31,13 +31,7 @@ use Doctrine\DBAL\Driver, class DB2Driver implements Driver { /** - * Attempts to create a connection with the database. - * - * @param array $params All connection parameters passed by the user. - * @param string $username The username to use when connecting. - * @param string $password The password to use when connecting. - * @param array $driverOptions The driver options to use when connecting. - * @return \Doctrine\DBAL\Driver\Connection The database connection. + * {@inheritdoc} */ public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) { @@ -65,10 +59,7 @@ class DB2Driver implements Driver } /** - * Gets the DatabasePlatform instance that provides all the metadata about - * the platform this driver connects to. - * - * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. + * {@inheritdoc} */ public function getDatabasePlatform() { @@ -76,11 +67,7 @@ class DB2Driver implements Driver } /** - * Gets the SchemaManager that can be used to inspect and change the underlying - * database schema of the platform this driver connects to. - * - * @param \Doctrine\DBAL\Connection $conn - * @return \Doctrine\DBAL\Schema\DB2SchemaManager + * {@inheritdoc} */ public function getSchemaManager(Connection $conn) { @@ -88,9 +75,7 @@ class DB2Driver implements Driver } /** - * Gets the name of the driver. - * - * @return string The name of the driver. + * {@inheritdoc} */ public function getName() { @@ -98,14 +83,12 @@ class DB2Driver implements Driver } /** - * Get the name of the database connected to for this driver. - * - * @param \Doctrine\DBAL\Connection $conn - * @return string $database + * {@inheritdoc} */ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); + return $params['dbname']; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php old mode 100755 new mode 100644 index 3d076582c9..72775cbfe7 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL\Driver\IBMDB2; class DB2Exception extends \Exception { - } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php old mode 100755 new mode 100644 index 9a43f9fa92..bf63eac7c8 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL\Driver\IBMDB2; @@ -25,14 +23,24 @@ use \Doctrine\DBAL\Driver\Statement; class DB2Statement implements \IteratorAggregate, Statement { + /** + * @var resource + */ private $_stmt = null; + /** + * @var array + */ private $_bindParam = array(); + /** + * @var integer + */ private $_defaultFetchMode = \PDO::FETCH_BOTH; /** * DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG + * * @var array */ static private $_typeMap = array( @@ -40,6 +48,9 @@ class DB2Statement implements \IteratorAggregate, Statement \PDO::PARAM_STR => DB2_CHAR, ); + /** + * @param resource $stmt + */ public function __construct($stmt) { $this->_stmt = $stmt; @@ -69,6 +80,7 @@ class DB2Statement implements \IteratorAggregate, Statement if (!db2_bind_param($this->_stmt, $column, "variable", DB2_PARAM_IN, $type)) { throw new DB2Exception(db2_stmt_errormsg()); } + return true; } @@ -85,6 +97,7 @@ class DB2Statement implements \IteratorAggregate, Statement db2_free_result($this->_stmt); $ret = db2_free_stmt($this->_stmt); $this->_stmt = false; + return $ret; } @@ -96,6 +109,7 @@ class DB2Statement implements \IteratorAggregate, Statement if ( ! $this->_stmt) { return false; } + return db2_num_fields($this->_stmt); } @@ -142,6 +156,7 @@ class DB2Statement implements \IteratorAggregate, Statement if ($retval === false) { throw new DB2Exception(db2_stmt_errormsg()); } + return $retval; } @@ -151,6 +166,8 @@ class DB2Statement implements \IteratorAggregate, Statement public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { $this->_defaultFetchMode = $fetchMode; + + return true; } /** @@ -159,6 +176,7 @@ class DB2Statement implements \IteratorAggregate, Statement public function getIterator() { $data = $this->fetchAll(); + return new \ArrayIterator($data); } @@ -189,6 +207,7 @@ class DB2Statement implements \IteratorAggregate, Statement while ($row = $this->fetch($fetchMode)) { $rows[] = $row; } + return $rows; } @@ -201,6 +220,7 @@ class DB2Statement implements \IteratorAggregate, Statement if ($row && isset($row[$columnIndex])) { return $row[$columnIndex]; } + return false; } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php old mode 100755 new mode 100644 index 60defba741..74d5a1ed98 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php @@ -64,6 +64,7 @@ class Driver implements DriverInterface public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); + return $params['dbname']; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php old mode 100755 new mode 100644 index 7ffa2ca8e6..3ea1c987e9 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -31,6 +31,14 @@ class MysqliConnection implements Connection */ private $_conn; + /** + * @param array $params + * @param string $username + * @param string $password + * @param array $driverOptions + * + * @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException + */ public function __construct(array $params, $username, $password, array $driverOptions = array()) { $port = isset($params['port']) ? $params['port'] : ini_get('mysqli.default_port'); @@ -47,9 +55,9 @@ class MysqliConnection implements Connection } /** - * Retrieve mysqli native resource handle. + * Retrieves mysqli native resource handle. * - * Could be used if part of your application is not using DBAL + * Could be used if part of your application is not using DBAL. * * @return \mysqli */ diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php old mode 100755 new mode 100644 index 139ce8fa46..b5583d8532 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Driver\Mysqli; @@ -23,4 +23,5 @@ namespace Doctrine\DBAL\Driver\Mysqli; * @author Kim Hemsø Rasmussen */ class MysqliException extends \Exception -{} +{ +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php old mode 100755 new mode 100644 index 2eaa8fd8a8..1e27cfebeb --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -27,6 +27,9 @@ use PDO; */ class MysqliStatement implements \IteratorAggregate, Statement { + /** + * @var array + */ protected static $_paramTypeMap = array( PDO::PARAM_STR => 's', PDO::PARAM_BOOL => 'i', @@ -35,11 +38,18 @@ class MysqliStatement implements \IteratorAggregate, Statement PDO::PARAM_LOB => 's' // TODO Support LOB bigger then max package size. ); + /** + * @var \mysqli + */ protected $_conn; + + /** + * @var \mysqli_stmt + */ protected $_stmt; /** - * @var null|false|array + * @var null|boolean|array */ protected $_columnNames; @@ -54,14 +64,23 @@ class MysqliStatement implements \IteratorAggregate, Statement protected $_bindedValues; /** - * Contains ref values for bindValue() + * Contains ref values for bindValue(). * * @var array */ protected $_values = array(); + /** + * @var integer + */ protected $_defaultFetchMode = PDO::FETCH_BOTH; + /** + * @param \mysqli $conn + * @param string $prepareString + * + * @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException + */ public function __construct(\mysqli $conn, $prepareString) { $this->_conn = $conn; @@ -94,12 +113,13 @@ class MysqliStatement implements \IteratorAggregate, Statement if (isset(self::$_paramTypeMap[$type])) { $type = self::$_paramTypeMap[$type]; } else { - throw new MysqliException("Unkown type: '{$type}'"); + throw new MysqliException("Unknown type: '{$type}'"); } } $this->_bindedValues[$column] =& $variable; $this->_bindedValues[0][$column - 1] = $type; + return true; } @@ -121,6 +141,7 @@ class MysqliStatement implements \IteratorAggregate, Statement $this->_values[$param] = $value; $this->_bindedValues[$param] =& $this->_values[$param]; $this->_bindedValues[0][$param - 1] = $type; + return true; } @@ -174,13 +195,15 @@ class MysqliStatement implements \IteratorAggregate, Statement if (false !== $this->_columnNames) { $this->_stmt->store_result(); } + return true; } /** - * Bind a array of values to bound parameters + * Binds a array of values to bound parameters. * * @param array $values + * * @return boolean */ private function _bindValues($values) @@ -192,6 +215,7 @@ class MysqliStatement implements \IteratorAggregate, Statement foreach ($values as &$v) { $params[] =& $v; } + return call_user_func_array(array($this->_stmt, 'bind_param'), $params); } @@ -210,6 +234,7 @@ class MysqliStatement implements \IteratorAggregate, Statement } return $values; } + return $ret; } @@ -276,6 +301,7 @@ class MysqliStatement implements \IteratorAggregate, Statement if (null === $row) { return false; } + return $row[$columnIndex]; } @@ -301,6 +327,7 @@ class MysqliStatement implements \IteratorAggregate, Statement public function closeCursor() { $this->_stmt->free_result(); + return true; } @@ -329,6 +356,8 @@ class MysqliStatement implements \IteratorAggregate, Statement public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { $this->_defaultFetchMode = $fetchMode; + + return true; } /** @@ -337,6 +366,7 @@ class MysqliStatement implements \IteratorAggregate, Statement public function getIterator() { $data = $this->fetchAll(); + return new \ArrayIterator($data); } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php old mode 100755 new mode 100644 index d512610eff..5fcc299c7b --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/Driver.php @@ -1,7 +1,5 @@ getParams(); + return $params['user']; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php old mode 100755 new mode 100644 index bc74787e1b..6776635b5a --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -34,16 +34,21 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection protected $dbh; /** - * @var int + * @var integer */ protected $executeMode = OCI_COMMIT_ON_SUCCESS; /** - * Create a Connection to an Oracle Database using oci8 extension. + * Creates a Connection to an Oracle Database using oci8 extension. * - * @param string $username - * @param string $password - * @param string $db + * @param string $username + * @param string $password + * @param string $db + * @param string|null $charset + * @param integer $sessionMode + * @param boolean $persistent + * + * @throws OCI8Exception */ public function __construct($username, $password, $db, $charset = null, $sessionMode = OCI_DEFAULT, $persistent = false) { @@ -61,10 +66,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection } /** - * Create a non-executed prepared statement. - * - * @param string $prepareString - * @return OCI8Statement + * {@inheritdoc} */ public function prepare($prepareString) { @@ -72,8 +74,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection } /** - * @param string $sql - * @return OCI8Statement + * {@inheritdoc} */ public function query() { @@ -82,15 +83,12 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection //$fetchMode = $args[1]; $stmt = $this->prepare($sql); $stmt->execute(); + return $stmt; } /** - * Quote input value. - * - * @param mixed $input - * @param int $type PDO::PARAM* - * @return mixed + * {@inheritdoc} */ public function quote($value, $type=\PDO::PARAM_STR) { @@ -98,23 +96,23 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection return $value; } $value = str_replace("'", "''", $value); + return "'" . addcslashes($value, "\000\n\r\\\032") . "'"; } /** - * - * @param string $statement - * @return int + * {@inheritdoc} */ public function exec($statement) { $stmt = $this->prepare($statement); $stmt->execute(); + return $stmt->rowCount(); } /** - * {@inheritDoc} + * {@inheritdoc} */ public function lastInsertId($name = null) { @@ -136,7 +134,9 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection } /** - * Return the current execution mode. + * Returns the current execution mode. + * + * @return integer */ public function getExecuteMode() { @@ -144,23 +144,17 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection } /** - * Start a transactiom - * - * Oracle has to explicitly set the autocommit mode off. That means - * after connection, a commit or rollback there is always automatically - * opened a new transaction. - * - * @return bool + * {@inheritdoc} */ public function beginTransaction() { $this->executeMode = OCI_NO_AUTO_COMMIT; + return true; } /** - * @throws OCI8Exception - * @return bool + * {@inheritdoc} */ public function commit() { @@ -168,12 +162,12 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection throw OCI8Exception::fromErrorInfo($this->errorInfo()); } $this->executeMode = OCI_COMMIT_ON_SUCCESS; + return true; } /** - * @throws OCI8Exception - * @return bool + * {@inheritdoc} */ public function rollBack() { @@ -181,18 +175,26 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection throw OCI8Exception::fromErrorInfo($this->errorInfo()); } $this->executeMode = OCI_COMMIT_ON_SUCCESS; + return true; } + /** + * {@inheritdoc} + */ public function errorCode() { $error = oci_error($this->dbh); if ($error !== false) { $error = $error['code']; } + return $error; } + /** + * {@inheritdoc} + */ public function errorInfo() { return oci_error($this->dbh); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php old mode 100755 new mode 100644 index adeb13f0fb..339959217e --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL\Driver\OCI8; class OCI8Exception extends \Exception { + /** + * @param array $error + * + * @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception + */ static public function fromErrorInfo($error) { return new self($error['message'], $error['code']); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php old mode 100755 new mode 100644 index 8bf3121c3f..fe25ccf375 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -31,26 +31,52 @@ use Doctrine\DBAL\Driver\Statement; */ class OCI8Statement implements \IteratorAggregate, Statement { - /** Statement handle. */ + /** + * @var resource + */ protected $_dbh; + + /** + * @var resource + */ protected $_sth; + + /** + * @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection + */ protected $_conn; + + /** + * @var string + */ protected static $_PARAM = ':param'; + + /** + * @var array + */ protected static $fetchModeMap = array( PDO::FETCH_BOTH => OCI_BOTH, PDO::FETCH_ASSOC => OCI_ASSOC, PDO::FETCH_NUM => OCI_NUM, - PDO::PARAM_LOB => OCI_B_BLOB, PDO::FETCH_COLUMN => OCI_NUM, ); + + /** + * @var integer + */ protected $_defaultFetchMode = PDO::FETCH_BOTH; + + /** + * @var array + */ protected $_paramMap = array(); /** * Creates a new OCI8Statement that uses the given connection handle and SQL statement. * - * @param resource $dbh The connection handle. - * @param string $statement The SQL statement. + * @param resource $dbh The connection handle. + * @param string $statement The SQL statement. + * @param \Doctrine\DBAL\Driver\OCI8\OCI8Connection $conn */ public function __construct($dbh, $statement, OCI8Connection $conn) { @@ -62,7 +88,7 @@ class OCI8Statement implements \IteratorAggregate, Statement } /** - * Convert positional (?) into named placeholders (:param) + * Converts positional (?) into named placeholders (:param). * * Oracle does not support positional parameters, hence this method converts all * positional parameters into artificially named parameters. Note that this conversion @@ -75,7 +101,9 @@ class OCI8Statement implements \IteratorAggregate, Statement * * @todo extract into utility class in Doctrine\DBAL\Util namespace * @todo review and test for lost spaces. we experienced missing spaces with oci8 in some sql statements. + * * @param string $statement The SQL statement to convert. + * * @return string */ static public function convertPositionalToNamedPlaceholders($statement) @@ -112,7 +140,7 @@ class OCI8Statement implements \IteratorAggregate, Statement /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = null,$length = null) + public function bindParam($column, &$variable, $type = null, $length = null) { $column = isset($this->_paramMap[$column]) ? $this->_paramMap[$column] : $column; @@ -121,15 +149,15 @@ class OCI8Statement implements \IteratorAggregate, Statement $lob->writeTemporary($variable, OCI_TEMP_BLOB); return oci_bind_by_name($this->_sth, $column, $lob, -1, OCI_B_BLOB); - } else { - return oci_bind_by_name($this->_sth, $column, $variable); + } else if ($length !== null) { + return oci_bind_by_name($this->_sth, $column, $variable, $length); } + + return oci_bind_by_name($this->_sth, $column, $variable); } /** - * Closes the cursor, enabling the statement to be executed again. - * - * @return boolean Returns TRUE on success or FALSE on failure. + * {@inheritdoc} */ public function closeCursor() { @@ -153,6 +181,7 @@ class OCI8Statement implements \IteratorAggregate, Statement if ($error !== false) { $error = $error['code']; } + return $error; } @@ -184,6 +213,7 @@ class OCI8Statement implements \IteratorAggregate, Statement if ( ! $ret) { throw OCI8Exception::fromErrorInfo($this->errorInfo()); } + return $ret; } @@ -193,6 +223,8 @@ class OCI8Statement implements \IteratorAggregate, Statement public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { $this->_defaultFetchMode = $fetchMode; + + return true; } /** @@ -201,6 +233,7 @@ class OCI8Statement implements \IteratorAggregate, Statement public function getIterator() { $data = $this->fetchAll(); + return new \ArrayIterator($data); } @@ -255,6 +288,7 @@ class OCI8Statement implements \IteratorAggregate, Statement public function fetchColumn($columnIndex = 0) { $row = oci_fetch_array($this->_sth, OCI_NUM | OCI_RETURN_NULLS | OCI_RETURN_LOBS); + return isset($row[$columnIndex]) ? $row[$columnIndex] : false; } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php old mode 100755 new mode 100644 index 4595e5a464..b65290e9f8 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL\Driver\PDOIbm; use Doctrine\DBAL\Connection; /** - * Driver for the PDO IBM extension + * Driver for the PDO IBM extension. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 1.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 1.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class Driver implements \Doctrine\DBAL\Driver { /** - * Attempts to establish a connection with the underlying driver. - * - * @param array $params - * @param string $username - * @param string $password - * @param array $driverOptions - * @return \Doctrine\DBAL\Driver\Connection + * {@inheritdoc} */ public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) { @@ -54,13 +44,16 @@ class Driver implements \Doctrine\DBAL\Driver $password, $driverOptions ); + return $conn; } /** - * Constructs the MySql PDO DSN. + * Constructs the IBM PDO DSN. * - * @return string The DSN. + * @param array $params + * + * @return string The DSN. */ private function _constructPdoDsn(array $params) { @@ -80,10 +73,7 @@ class Driver implements \Doctrine\DBAL\Driver } /** - * Gets the DatabasePlatform instance that provides all the metadata about - * the platform this driver connects to. - * - * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. + * {@inheritdoc} */ public function getDatabasePlatform() { @@ -91,11 +81,7 @@ class Driver implements \Doctrine\DBAL\Driver } /** - * Gets the SchemaManager that can be used to inspect and change the underlying - * database schema of the platform this driver connects to. - * - * @param \Doctrine\DBAL\Connection $conn - * @return \Doctrine\DBAL\Schema\DB2SchemaManager + * {@inheritdoc} */ public function getSchemaManager(Connection $conn) { @@ -103,9 +89,7 @@ class Driver implements \Doctrine\DBAL\Driver } /** - * Gets the name of the driver. - * - * @return string The name of the driver. + * {@inheritdoc} */ public function getName() { @@ -113,14 +97,12 @@ class Driver implements \Doctrine\DBAL\Driver } /** - * Get the name of the database connected to for this driver. - * - * @param \Doctrine\DBAL\Connection $conn - * @return string $database + * {@inheritdoc} */ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); + return $params['dbname']; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php old mode 100755 new mode 100644 index eeb6727976..1c54e72a6c --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php @@ -29,13 +29,7 @@ use Doctrine\DBAL\Connection; class Driver implements \Doctrine\DBAL\Driver { /** - * Attempts to establish a connection with the underlying driver. - * - * @param array $params - * @param string $username - * @param string $password - * @param array $driverOptions - * @return \Doctrine\DBAL\Driver\Connection + * {@inheritdoc} */ public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) { @@ -45,13 +39,16 @@ class Driver implements \Doctrine\DBAL\Driver $password, $driverOptions ); + return $conn; } /** * Constructs the MySql PDO DSN. * - * @return string The DSN. + * @param array $params + * + * @return string The DSN. */ private function _constructPdoDsn(array $params) { @@ -75,21 +72,33 @@ class Driver implements \Doctrine\DBAL\Driver return $dsn; } + /** + * {@inheritdoc} + */ public function getDatabasePlatform() { return new \Doctrine\DBAL\Platforms\MySqlPlatform(); } + /** + * {@inheritdoc} + */ public function getSchemaManager(\Doctrine\DBAL\Connection $conn) { return new \Doctrine\DBAL\Schema\MySqlSchemaManager($conn); } + /** + * {@inheritdoc} + */ public function getName() { return 'pdo_mysql'; } + /** + * {@inheritdoc} + */ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php old mode 100755 new mode 100644 index cb2e6b03c7..61c8ba36e6 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php @@ -22,15 +22,18 @@ namespace Doctrine\DBAL\Driver\PDOOracle; use Doctrine\DBAL\Platforms; /** - * PDO Oracle driver + * PDO Oracle driver. * - * WARNING: This driver gives us segfauls in our testsuites on CLOB and other + * WARNING: This driver gives us segfaults in our testsuites on CLOB and other * stuff. PDO Oracle is not maintained by Oracle or anyone in the PHP community, * which leads us to the recommendation to use the "oci8" driver to connect * to Oracle instead. */ class Driver implements \Doctrine\DBAL\Driver { + /** + * {@inheritdoc} + */ public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) { return new \Doctrine\DBAL\Driver\PDOConnection( @@ -44,7 +47,9 @@ class Driver implements \Doctrine\DBAL\Driver /** * Constructs the Oracle PDO DSN. * - * @return string The DSN. + * @param array $params + * + * @return string The DSN. */ private function _constructPdoDsn(array $params) { @@ -75,24 +80,37 @@ class Driver implements \Doctrine\DBAL\Driver return $dsn; } + /** + * {@inheritdoc} + */ public function getDatabasePlatform() { return new \Doctrine\DBAL\Platforms\OraclePlatform(); } + /** + * {@inheritdoc} + */ public function getSchemaManager(\Doctrine\DBAL\Connection $conn) { return new \Doctrine\DBAL\Schema\OracleSchemaManager($conn); } + /** + * {@inheritdoc} + */ public function getName() { return 'pdo_oracle'; } + /** + * {@inheritdoc} + */ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); + return $params['user']; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php old mode 100755 new mode 100644 index 951406dd81..5da59d528b --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -1,4 +1,21 @@ . + */ namespace Doctrine\DBAL\Driver\PDOPgSql; @@ -12,9 +29,7 @@ use Doctrine\DBAL\Platforms; class Driver implements \Doctrine\DBAL\Driver { /** - * Attempts to connect to the database and returns a driver connection on success. - * - * @return \Doctrine\DBAL\Driver\Connection + * {@inheritdoc} */ public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) { @@ -29,6 +44,8 @@ class Driver implements \Doctrine\DBAL\Driver /** * Constructs the Postgres PDO DSN. * + * @param array $params + * * @return string The DSN. */ private function _constructPdoDsn(array $params) @@ -47,24 +64,40 @@ class Driver implements \Doctrine\DBAL\Driver return $dsn; } + /** + * {@inheritdoc} + */ public function getDatabasePlatform() { return new \Doctrine\DBAL\Platforms\PostgreSqlPlatform(); } + /** + * {@inheritdoc} + */ public function getSchemaManager(\Doctrine\DBAL\Connection $conn) { return new \Doctrine\DBAL\Schema\PostgreSqlSchemaManager($conn); } + /** + * {@inheritdoc} + */ public function getName() { return 'pdo_pgsql'; } + /** + * {@inheritdoc} + */ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); - return $params['dbname']; + + return (isset($params['dbname'])) + ? $params['dbname'] + : $conn->query('SELECT CURRENT_DATABASE()')->fetchColumn(); } } + diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php old mode 100755 new mode 100644 index 903d9994dd..56e0346e1a --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -36,13 +36,7 @@ class Driver implements \Doctrine\DBAL\Driver ); /** - * Tries to establish a database connection to SQLite. - * - * @param array $params - * @param string $username - * @param string $password - * @param array $driverOptions - * @return \Doctrine\DBAL\Driver\PDOConnection + * {@inheritdoc} */ public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) { @@ -69,8 +63,9 @@ class Driver implements \Doctrine\DBAL\Driver /** * Constructs the Sqlite PDO DSN. * - * @return string The DSN. - * @override + * @param array $params + * + * @return string The DSN. */ protected function _constructPdoDsn(array $params) { @@ -85,7 +80,7 @@ class Driver implements \Doctrine\DBAL\Driver } /** - * Gets the database platform that is relevant for this driver. + * {@inheritdoc} */ public function getDatabasePlatform() { @@ -93,24 +88,28 @@ class Driver implements \Doctrine\DBAL\Driver } /** - * Gets the schema manager that is relevant for this driver. - * - * @param \Doctrine\DBAL\Connection $conn - * @return \Doctrine\DBAL\Schema\SqliteSchemaManager + * {@inheritdoc} */ public function getSchemaManager(\Doctrine\DBAL\Connection $conn) { return new \Doctrine\DBAL\Schema\SqliteSchemaManager($conn); } + /** + * {@inheritdoc} + */ public function getName() { return 'pdo_sqlite'; } + /** + * {@inheritdoc} + */ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); + return isset($params['path']) ? $params['path'] : null; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php old mode 100755 new mode 100644 index 01a5769f57..93314af0e3 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -1,7 +1,5 @@ getParams(); + return $params['dbname']; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php old mode 100755 new mode 100644 index 2673ae9d2b..0aee56d5b5 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -1,7 +1,5 @@ fetchColumn() - * fetches the first column. + * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. + * If no value is supplied, PDOStatement->fetchColumn() + * fetches the first column. * - * @return string returns a single column in the next row of a result set. + * @return string|boolean A single column in the next row of a result set, or FALSE if there are no more rows. */ - function fetchColumn($columnIndex = 0); + public function fetchColumn($columnIndex = 0); } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php old mode 100755 new mode 100644 index c7043cc601..cb6297c23e --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php @@ -20,10 +20,13 @@ namespace Doctrine\DBAL\Driver\SQLSrv; /** - * Driver for ext/sqlsrv + * Driver for ext/sqlsrv. */ class Driver implements \Doctrine\DBAL\Driver { + /** + * {@inheritdoc} + */ public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) { if (!isset($params['host'])) { @@ -48,25 +51,36 @@ class Driver implements \Doctrine\DBAL\Driver return new SQLSrvConnection($serverName, $driverOptions); } + /** + * {@inheritdoc} + */ public function getDatabasePlatform() { return new \Doctrine\DBAL\Platforms\SQLServer2008Platform(); } + /** + * {@inheritdoc} + */ public function getSchemaManager(\Doctrine\DBAL\Connection $conn) { return new \Doctrine\DBAL\Schema\SQLServerSchemaManager($conn); } + /** + * {@inheritdoc} + */ public function getName() { return 'sqlsrv'; } + /** + * {@inheritdoc} + */ public function getDatabase(\Doctrine\DBAL\Connection $conn) { $params = $conn->getParams(); return $params['dbname']; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php old mode 100755 new mode 100644 index 421d071513..67c7bfa851 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php @@ -20,23 +20,31 @@ namespace Doctrine\DBAL\Driver\SQLSrv; /** - * Last Id Data Container + * Last Id Data Container. * * @since 2.3 * @author Benjamin Eberlei */ class LastInsertId { + /** + * @var integer + */ private $id; + /** + * @param integer $id + */ public function setId($id) { $this->id = $id; } + /** + * @return integer + */ public function getId() { return $this->id; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php old mode 100755 new mode 100644 index 82544ca180..948c27f985 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -33,11 +33,16 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection protected $conn; /** - * @var LastInsertId + * @var \Doctrine\DBAL\Driver\SQLSrv\LastInsertId */ protected $lastInsertId; - + /** + * @param string $serverName + * @param array $connectionOptions + * + * @throws \Doctrine\DBAL\Driver\SQLSrv\SQLSrvException + */ public function __construct($serverName, $connectionOptions) { $this->conn = sqlsrv_connect($serverName, $connectionOptions); @@ -64,6 +69,7 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection $sql = $args[0]; $stmt = $this->prepare($sql); $stmt->execute(); + return $stmt; } @@ -89,6 +95,7 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection { $stmt = $this->prepare($statement); $stmt->execute(); + return $stmt->rowCount(); } @@ -147,6 +154,7 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection if ($errors) { return $errors[0]['code']; } + return false; } @@ -158,4 +166,3 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection return sqlsrv_errors(SQLSRV_ERR_ERRORS); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php old mode 100755 new mode 100644 index 6777877434..3631e65059 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php @@ -24,7 +24,7 @@ class SQLSrvException extends \Doctrine\DBAL\DBALException /** * Helper method to turn sql server errors into exception. * - * @return SQLSrvException + * @return \Doctrine\DBAL\Driver\SQLSrv\SQLSrvException */ static public function fromSqlSrvErrors() { @@ -34,10 +34,9 @@ class SQLSrvException extends \Doctrine\DBAL\DBALException $message .= "SQLSTATE [".$error['SQLSTATE'].", ".$error['code']."]: ". $error['message']."\n"; } if ( ! $message) { - $message = "SQL Server error occured but no error message was retrieved from driver."; + $message = "SQL Server error occurred but no error message was retrieved from driver."; } return new self(rtrim($message)); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php old mode 100755 new mode 100644 index 76a156b3ed..fc11453c97 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -24,7 +24,7 @@ use IteratorAggregate; use Doctrine\DBAL\Driver\Statement; /** - * SQL Server Statement + * SQL Server Statement. * * @since 2.3 * @author Benjamin Eberlei @@ -32,35 +32,35 @@ use Doctrine\DBAL\Driver\Statement; class SQLSrvStatement implements IteratorAggregate, Statement { /** - * SQLSRV Resource + * The SQLSRV Resource. * * @var resource */ private $conn; /** - * SQL Statement to execute + * The SQL statement to execute. * * @var string */ private $sql; /** - * SQLSRV Statement Resource + * The SQLSRV statement resource. * * @var resource */ private $stmt; /** - * Parameters to bind + * Parameters to bind. * * @var array */ private $params = array(); /** - * Translations + * Translations. * * @var array */ @@ -71,14 +71,16 @@ class SQLSrvStatement implements IteratorAggregate, Statement ); /** - * Fetch Style + * The fetch style. * - * @param int + * @param integer */ private $defaultFetchMode = PDO::FETCH_BOTH; /** - * @var int|null + * The last insert ID. + * + * @var \Doctrine\DBAL\Driver\SQLSrv\LastInsertId|null */ private $lastInsertId; @@ -89,6 +91,11 @@ class SQLSrvStatement implements IteratorAggregate, Statement */ const LAST_INSERT_ID_SQL = ';SELECT SCOPE_IDENTITY() AS LastInsertId;'; + /** + * @param resource $conn + * @param string $sql + * @param integer|null $lastInsertId + */ public function __construct($conn, $sql, $lastInsertId = null) { $this->conn = $conn; @@ -100,6 +107,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement } } + /** + * {@inheritdoc} + */ public function bindValue($param, $value, $type = null) { return $this->bindParam($param, $value, $type,null); @@ -121,6 +131,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement } } + /** + * {@inheritdoc} + */ public function closeCursor() { if ($this->stmt) { @@ -128,13 +141,16 @@ class SQLSrvStatement implements IteratorAggregate, Statement } } + /** + * {@inheritdoc} + */ public function columnCount() { return sqlsrv_num_fields($this->stmt); } /** - * {@inheritDoc} + * {@inheritdoc} */ public function errorCode() { @@ -142,17 +158,21 @@ class SQLSrvStatement implements IteratorAggregate, Statement if ($errors) { return $errors[0]['code']; } + return false; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function errorInfo() { return sqlsrv_errors(SQLSRV_ERR_ERRORS); } + /** + * {@inheritdoc} + */ public function execute($params = null) { if ($params) { @@ -175,9 +195,14 @@ class SQLSrvStatement implements IteratorAggregate, Statement } } + /** + * {@inheritdoc} + */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { $this->defaultFetchMode = $fetchMode; + + return true; } /** @@ -186,6 +211,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement public function getIterator() { $data = $this->fetchAll(); + return new \ArrayIterator($data); } @@ -228,6 +254,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement while ($row = $this->fetch($fetchMode, $className, $ctorArgs)) { $rows[] = $row; } + return $rows; } @@ -237,6 +264,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement public function fetchColumn($columnIndex = 0) { $row = $this->fetch(PDO::FETCH_NUM); + return $row[$columnIndex]; } @@ -248,4 +276,3 @@ class SQLSrvStatement implements IteratorAggregate, Statement return sqlsrv_rows_affected($this->stmt); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php old mode 100755 new mode 100644 index 718614d83f..f545cd1e76 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Statement.php @@ -19,19 +19,16 @@ namespace Doctrine\DBAL\Driver; -use \PDO; - /** * Statement interface. * Drivers must implement this interface. * * This resembles (a subset of) the PDOStatement interface. * - * @author Konsta Vesterinen - * @author Roman Borschel - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 + * @author Konsta Vesterinen + * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 */ interface Statement extends ResultStatement { @@ -39,14 +36,13 @@ interface Statement extends ResultStatement * Binds a value to a corresponding named or positional * placeholder in the SQL statement that was used to prepare the statement. * - * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, - * this will be a parameter name of the form :name. For a prepared statement - * using question mark placeholders, this will be the 1-indexed position of the parameter + * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement + * using question mark placeholders, this will be the 1-indexed position of the parameter. + * @param mixed $value The value to bind to the parameter. + * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. * - * @param mixed $value The value to bind to the parameter. - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. - * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return boolean TRUE on success or FALSE on failure. */ function bindValue($param, $value, $type = null); @@ -61,35 +57,35 @@ interface Statement extends ResultStatement * of stored procedures that return data as output parameters, and some also as input/output * parameters that both send in data and are updated to receive it. * - * @param mixed $column Parameter identifier. For a prepared statement using named placeholders, - * this will be a parameter name of the form :name. For a prepared statement - * using question mark placeholders, this will be the 1-indexed position of the parameter + * @param mixed $column Parameter identifier. For a prepared statement using named placeholders, + * this will be a parameter name of the form :name. For a prepared statement using + * question mark placeholders, this will be the 1-indexed position of the parameter. + * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. + * @param integer|null $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return + * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the + * PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter. + * @param integer|null $length You must specify maxlength when using an OUT bind + * so that PHP allocates enough memory to hold the returned value. * - * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. - * - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return - * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the - * PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter. - * @param integer $length You must specify maxlength when using an OUT bind so that PHP allocates enough memory to hold the returned value. - * @return boolean Returns TRUE on success or FALSE on failure. + * @return boolean TRUE on success or FALSE on failure. */ function bindParam($column, &$variable, $type = null, $length = null); /** - * errorCode - * Fetch the SQLSTATE associated with the last operation on the statement handle + * Fetches the SQLSTATE associated with the last operation on the statement handle. * * @see Doctrine_Adapter_Interface::errorCode() - * @return string error code string + * + * @return string The error code string. */ function errorCode(); /** - * errorInfo - * Fetch extended error information associated with the last operation on the statement handle + * Fetches extended error information associated with the last operation on the statement handle. * * @see Doctrine_Adapter_Interface::errorInfo() - * @return array error info array + * + * @return array The error info array. */ function errorInfo(); @@ -100,18 +96,18 @@ interface Statement extends ResultStatement * call PDOStatement->bindParam() to bind PHP variables to the parameter markers: * bound variables pass their value as input and receive the output value, * if any, of their associated parameter markers or pass an array of input-only - * parameter values + * parameter values. * * - * @param array $params An array of values with as many elements as there are - * bound parameters in the SQL statement being executed. - * @return boolean Returns TRUE on success or FALSE on failure. + * @param array|null $params An array of values with as many elements as there are + * bound parameters in the SQL statement being executed. + * + * @return boolean TRUE on success or FALSE on failure. */ function execute($params = null); /** - * rowCount - * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement + * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement * executed by the corresponding object. * * If the last SQL statement executed by the associated Statement object was a SELECT statement, @@ -119,7 +115,7 @@ interface Statement extends ResultStatement * this behaviour is not guaranteed for all databases and should not be * relied on for portable applications. * - * @return integer Returns the number of rows. + * @return integer The number of rows. */ function rowCount(); } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php old mode 100755 new mode 100644 index 7cdde95137..295c4c6945 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php @@ -51,8 +51,12 @@ final class DriverManager 'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver', ); - /** Private constructor. This class cannot be instantiated. */ - private function __construct() { } + /** + * Private constructor. This class cannot be instantiated. + */ + private function __construct() + { + } /** * Creates a connection object based on the specified parameters. @@ -101,10 +105,13 @@ final class DriverManager * driverClass: * The driver class to use. * - * @param array $params The parameters. - * @param \Doctrine\DBAL\Configuration The configuration to use. - * @param \Doctrine\Common\EventManager The event manager to use. + * @param array $params The parameters. + * @param \Doctrine\DBAL\Configuration|null $config The configuration to use. + * @param \Doctrine\Common\EventManager|null $eventManager The event manager to use. + * * @return \Doctrine\DBAL\Connection + * + * @throws \Doctrine\DBAL\DBALException */ public static function getConnection( array $params, @@ -151,11 +158,15 @@ final class DriverManager /** * Checks the list of parameters. * - * @param array $params + * @param array $params The list of parameters. + * + * @return void + * + * @throws \Doctrine\DBAL\DBALException */ private static function _checkParams(array $params) { - // check existance of mandatory parameters + // check existence of mandatory parameters // driver if ( ! isset($params['driver']) && ! isset($params['driverClass'])) { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php old mode 100755 new mode 100644 index f4cb1cd864..fd82638e77 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/ConnectionEventArgs.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\Common\EventArgs, - Doctrine\DBAL\Connection; +use Doctrine\Common\EventArgs; +use Doctrine\DBAL\Connection; /** * Event Arguments used when a Driver connection is established inside Doctrine\DBAL\Connection. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 1.0 - * @version $Revision$ - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 1.0 + * @author Benjamin Eberlei */ class ConnectionEventArgs extends EventArgs { /** - * @var Connection + * @var \Doctrine\DBAL\Connection */ - private $_connection = null; + private $_connection; + /** + * @param \Doctrine\DBAL\Connection $connection + */ public function __construct(Connection $connection) { $this->_connection = $connection; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php old mode 100755 new mode 100644 index fc22744a0d..bd362c4cb6 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event\Listeners; @@ -24,32 +24,34 @@ use Doctrine\DBAL\Events; use Doctrine\Common\EventSubscriber; /** - * MySQL Session Init Event Subscriber which allows to set the Client Encoding of the Connection + * MySQL Session Init Event Subscriber which allows to set the Client Encoding of the Connection. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 1.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @deprecated Use "charset" option to PDO MySQL Connection instead. + * @link www.doctrine-project.org + * @since 1.0 + * @author Benjamin Eberlei + * @deprecated Use "charset" option to PDO MySQL Connection instead. */ class MysqlSessionInit implements EventSubscriber { /** + * The charset. + * * @var string */ private $_charset; /** - * @var string + * The collation, or FALSE if no collation. + * + * @var string|boolean */ private $_collation; /** - * Configure Charset and Collation options of MySQL Client for each Connection + * Configure Charset and Collation options of MySQL Client for each Connection. * - * @param string $charset - * @param string $collation + * @param string $charset The charset. + * @param string|boolean $collation The collation, or FALSE if no collation. */ public function __construct($charset = 'utf8', $collation = false) { @@ -58,7 +60,8 @@ class MysqlSessionInit implements EventSubscriber } /** - * @param ConnectionEventArgs $args + * @param \Doctrine\DBAL\Event\ConnectionEventArgs $args + * * @return void */ public function postConnect(ConnectionEventArgs $args) @@ -67,6 +70,9 @@ class MysqlSessionInit implements EventSubscriber $args->getConnection()->executeUpdate("SET NAMES ".$this->_charset . $collation); } + /** + * {@inheritdoc} + */ public function getSubscribedEvents() { return array(Events::postConnect); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php old mode 100755 new mode 100644 index 835540329f..e19540eb67 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event\Listeners; @@ -24,22 +24,24 @@ use Doctrine\DBAL\Events; use Doctrine\Common\EventSubscriber; /** - * Should be used when Oracle Server default enviroment does not match the Doctrine requirements. + * Should be used when Oracle Server default environment does not match the Doctrine requirements. * - * The following enviroment variables are required for the Doctrine default date format: + * The following environment variables are required for the Doctrine default date format: * * NLS_TIME_FORMAT="HH24:MI:SS" * NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS" * NLS_TIMESTAMP_FORMAT="YYYY-MM-DD HH24:MI:SS" * NLS_TIMESTAMP_TZ_FORMAT="YYYY-MM-DD HH24:MI:SS TZH:TZM" * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class OracleSessionInit implements EventSubscriber { + /** + * @var array + */ protected $_defaultSessionVars = array( 'NLS_TIME_FORMAT' => "HH24:MI:SS", 'NLS_DATE_FORMAT' => "YYYY-MM-DD HH24:MI:SS", @@ -57,7 +59,8 @@ class OracleSessionInit implements EventSubscriber } /** - * @param ConnectionEventArgs $args + * @param \Doctrine\DBAL\Event\ConnectionEventArgs $args + * * @return void */ public function postConnect(ConnectionEventArgs $args) @@ -73,6 +76,9 @@ class OracleSessionInit implements EventSubscriber } } + /** + * {@inheritdoc} + */ public function getSubscribedEvents() { return array(Events::postConnect); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php old mode 100755 new mode 100644 index 8dfde6258a..cfa42994cb --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/SQLSessionInit.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event\Listeners; @@ -26,10 +26,9 @@ use Doctrine\Common\EventSubscriber; /** * Session init listener for executing a single SQL statement right after a connection is opened. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei */ class SQLSessionInit implements EventSubscriber { @@ -47,7 +46,8 @@ class SQLSessionInit implements EventSubscriber } /** - * @param ConnectionEventArgs $args + * @param \Doctrine\DBAL\Event\ConnectionEventArgs $args + * * @return void */ public function postConnect(ConnectionEventArgs $args) @@ -56,6 +56,9 @@ class SQLSessionInit implements EventSubscriber $conn->exec($this->sql); } + /** + * {@inheritdoc} + */ public function getSubscribedEvents() { return array(Events::postConnect); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php old mode 100755 new mode 100644 index 0200ce77cc..c4477ad8a1 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php @@ -15,38 +15,37 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\TableDiff; /** * Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs { /** * @var \Doctrine\DBAL\Schema\Column */ - private $_column = null; + private $_column; /** * @var \Doctrine\DBAL\Schema\TableDiff */ - private $_tableDiff = null; + private $_tableDiff; /** * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - private $_platform = null; + private $_platform; /** * @var array @@ -54,8 +53,8 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs private $_sql = array(); /** - * @param \Doctrine\DBAL\Schema\Column $column - * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff + * @param \Doctrine\DBAL\Schema\Column $column + * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform */ public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform) @@ -91,6 +90,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs /** * @param string|array $sql + * * @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs */ public function addSql($sql) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php old mode 100755 new mode 100644 index bd59d7d703..7249b63cb6 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php @@ -15,38 +15,37 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\ColumnDiff, - Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\ColumnDiff; +use Doctrine\DBAL\Schema\TableDiff; /** * Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs { /** * @var \Doctrine\DBAL\Schema\ColumnDiff */ - private $_columnDiff = null; + private $_columnDiff; /** * @var \Doctrine\DBAL\Schema\TableDiff */ - private $_tableDiff = null; + private $_tableDiff; /** * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - private $_platform = null; + private $_platform; /** * @var array @@ -54,8 +53,8 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs private $_sql = array(); /** - * @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff - * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff + * @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff + * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform */ public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform) @@ -91,6 +90,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs /** * @param string|array $sql + * * @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs */ public function addSql($sql) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php old mode 100755 new mode 100644 index 9f853388d4..384315d5a0 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php @@ -15,33 +15,31 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\TableDiff; /** * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaAlterTableEventArgs extends SchemaEventArgs { /** * @var \Doctrine\DBAL\Schema\TableDiff */ - private $_tableDiff = null; + private $_tableDiff; /** * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - private $_platform = null; + private $_platform; /** * @var array @@ -49,7 +47,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs private $_sql = array(); /** - * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff + * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform */ public function __construct(TableDiff $tableDiff, AbstractPlatform $platform) @@ -76,6 +74,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs /** * @param string|array $sql + * * @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs */ public function addSql($sql) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php old mode 100755 new mode 100644 index 4b981f896c..06f37888ff --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php @@ -15,38 +15,37 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\TableDiff; /** * Event Arguments used when SQL queries for removing table columns are generated inside Doctrine\DBAL\Platform\*Platform. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs { /** * @var \Doctrine\DBAL\Schema\Column */ - private $_column = null; + private $_column; /** * @var \Doctrine\DBAL\Schema\TableDiff */ - private $_tableDiff = null; + private $_tableDiff; /** * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - private $_platform = null; + private $_platform; /** * @var array @@ -54,8 +53,8 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs private $_sql = array(); /** - * @param \Doctrine\DBAL\Schema\Column $column - * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff + * @param \Doctrine\DBAL\Schema\Column $column + * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform */ public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform) @@ -91,6 +90,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs /** * @param string|array $sql + * * @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs */ public function addSql($sql) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php old mode 100755 new mode 100644 index 90e6a38517..94a274c4fa --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php @@ -15,43 +15,42 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\TableDiff; /** * Event Arguments used when SQL queries for renaming table columns are generated inside Doctrine\DBAL\Platform\*Platform. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs { /** * @var string */ - private $_oldColumnName = null; + private $_oldColumnName; /** * @var \Doctrine\DBAL\Schema\Column */ - private $_column = null; + private $_column; /** * @var \Doctrine\DBAL\Schema\TableDiff */ - private $_tableDiff = null; + private $_tableDiff; /** * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - private $_platform = null; + private $_platform; /** * @var array @@ -59,9 +58,9 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs private $_sql = array(); /** - * @param string $oldColumnName - * @param \Doctrine\DBAL\Schema\Column $column - * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff + * @param string $oldColumnName + * @param \Doctrine\DBAL\Schema\Column $column + * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform */ public function __construct($oldColumnName, Column $column, TableDiff $tableDiff, AbstractPlatform $platform) @@ -106,6 +105,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs /** * @param string|array $sql + * * @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs */ public function addSql($sql) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php old mode 100755 new mode 100644 index fecb015206..14bb8df73b --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php @@ -15,55 +15,54 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Connection, - Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Schema\Column; /** * Event Arguments used when the portable column definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs { /** - * @var \Doctrine\DBAL\Schema\Column + * @var \Doctrine\DBAL\Schema\Column|null */ private $_column = null; /** - * Raw column data as fetched from the database + * Raw column data as fetched from the database. * * @var array */ - private $_tableColumn = null; + private $_tableColumn; /** * @var string */ - private $_table = null; + private $_table; /** * @var string */ - private $_database = null; + private $_database; /** * @var \Doctrine\DBAL\Connection */ - private $_connection = null; + private $_connection; /** - * @param array $tableColumn - * @param string $table - * @param string $database - * @param \Doctrine\DBAL\Connection $conn + * @param array $tableColumn + * @param string $table + * @param string $database + * @param \Doctrine\DBAL\Connection $connection */ public function __construct(array $tableColumn, $table, $database, Connection $connection) { @@ -78,7 +77,8 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs * tables column list. * * @param null|\Doctrine\DBAL\Schema\Column $column - * @return SchemaColumnDefinitionEventArgs + * + * @return \Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs */ public function setColumn(Column $column = null) { @@ -88,7 +88,7 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs } /** - * @return \Doctrine\DBAL\Schema\Column + * @return \Doctrine\DBAL\Schema\Column|null */ public function getColumn() { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php old mode 100755 new mode 100644 index 5e7383c0bf..38b218257b --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php @@ -15,38 +15,37 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\Table; /** * Event Arguments used when SQL queries for creating table columns are generated inside Doctrine\DBAL\Platform\AbstractPlatform. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs { /** * @var \Doctrine\DBAL\Schema\Column */ - private $_column = null; + private $_column; /** * @var \Doctrine\DBAL\Schema\Table */ - private $_table = null; + private $_table; /** * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - private $_platform = null; + private $_platform; /** * @var array @@ -54,8 +53,8 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs private $_sql = array(); /** - * @param \Doctrine\DBAL\Schema\Column $column - * @param \Doctrine\DBAL\Schema\Table $table + * @param \Doctrine\DBAL\Schema\Column $column + * @param \Doctrine\DBAL\Schema\Table $table * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform */ public function __construct(Column $column, Table $table, AbstractPlatform $platform) @@ -91,6 +90,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs /** * @param string|array $sql + * * @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs */ public function addSql($sql) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php old mode 100755 new mode 100644 index 3149faa77a..175b0e9c34 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php @@ -15,42 +15,41 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Table; /** * Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaCreateTableEventArgs extends SchemaEventArgs { /** * @var \Doctrine\DBAL\Schema\Table */ - private $_table = null; + private $_table; /** * @var array */ - private $_columns = null; + private $_columns; /** * @var array */ - private $_options = null; + private $_options; /** * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - private $_platform = null; + private $_platform; /** * @var array @@ -58,9 +57,9 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs private $_sql = array(); /** - * @param \Doctrine\DBAL\Schema\Table $table - * @param array $columns - * @param array $options + * @param \Doctrine\DBAL\Schema\Table $table + * @param array $columns + * @param array $options * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform */ public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform) @@ -105,6 +104,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs /** * @param string|array $sql + * * @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs */ public function addSql($sql) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php old mode 100755 new mode 100644 index 55133be21b..d21488e86c --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php @@ -15,41 +15,42 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Table; /** * Event Arguments used when the SQL query for dropping tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaDropTableEventArgs extends SchemaEventArgs { /** * @var string|\Doctrine\DBAL\Schema\Table */ - private $_table = null; + private $_table; /** * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - private $_platform = null; + private $_platform; /** - * @var string + * @var string|null */ private $_sql = null; /** - * @param string|\Doctrine\DBAL\Schema\Table $table + * @param string|\Doctrine\DBAL\Schema\Table $table * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * + * @throws \InvalidArgumentException */ public function __construct($table, AbstractPlatform $platform) { @@ -79,6 +80,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs /** * @param string $sql + * * @return \Doctrine\DBAL\Event\SchemaDropTableEventArgs */ public function setSql($sql) @@ -89,7 +91,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs } /** - * @return string + * @return string|null */ public function getSql() { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaEventArgs.php old mode 100755 new mode 100644 index a3509fb2cf..d9648b64ff --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaEventArgs.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; @@ -24,10 +24,9 @@ use Doctrine\Common\EventArgs; /** * Base class for schema related events. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaEventArgs extends EventArgs { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php old mode 100755 new mode 100644 index 248d43e982..3fd1d4bf7d --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php @@ -15,49 +15,48 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Event; -use Doctrine\DBAL\Connection, - Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Schema\Index; /** * Event Arguments used when the portable index definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Jan Sorgalla + * @link www.doctrine-project.org + * @since 2.2 + * @author Jan Sorgalla */ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs { /** - * @var \Doctrine\DBAL\Schema\Index + * @var \Doctrine\DBAL\Schema\Index|null */ private $_index = null; /** - * Raw index data as fetched from the database + * Raw index data as fetched from the database. * * @var array */ - private $_tableIndex = null; + private $_tableIndex; /** * @var string */ - private $_table = null; + private $_table; /** * @var \Doctrine\DBAL\Connection */ - private $_connection = null; + private $_connection; /** - * @param array $tableIndex - * @param string $table - * @param \Doctrine\DBAL\Connection $conn + * @param array $tableIndex + * @param string $table + * @param \Doctrine\DBAL\Connection $connection */ public function __construct(array $tableIndex, $table, Connection $connection) { @@ -67,10 +66,10 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs } /** - * Allows to clear the index which means the index will be excluded from - * tables index list. + * Allows to clear the index which means the index will be excluded from tables index list. * * @param null|\Doctrine\DBAL\Schema\Index $index + * * @return SchemaIndexDefinitionEventArgs */ public function setIndex(Index $index = null) @@ -81,7 +80,7 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs } /** - * @return \Doctrine\DBAL\Schema\Index + * @return \Doctrine\DBAL\Schema\Index|null */ public function getIndex() { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Events.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Events.php old mode 100755 new mode 100644 index 0869dd9740..0d31504c70 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Events.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Events.php @@ -1,7 +1,5 @@ sequences[$sequenceName]['value'] >= $this->sequences[$sequenceName]['max']) { unset ($this->sequences[$sequenceName]); } + return $value; } @@ -151,10 +157,9 @@ class TableGenerator } catch(\Exception $e) { $this->conn->rollback(); - throw new \Doctrine\DBAL\DBALException("Error occured while generating ID with TableGenerator, aborted generation: " . $e->getMessage(), 0, $e); + throw new \Doctrine\DBAL\DBALException("Error occurred while generating ID with TableGenerator, aborted generation: " . $e->getMessage(), 0, $e); } return $value; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php old mode 100755 new mode 100644 index e34039763a..25b06aca9f --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Id/TableGeneratorSchemaVisitor.php @@ -19,13 +19,12 @@ namespace Doctrine\DBAL\Id; -use Doctrine\DBAL\Schema\Table, - Doctrine\DBAL\Schema\Schema, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\ForeignKeyConstraint, - Doctrine\DBAL\Schema\Constraint, - Doctrine\DBAL\Schema\Sequence, - Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Sequence; +use Doctrine\DBAL\Schema\Index; class TableGeneratorSchemaVisitor implements \Doctrine\DBAL\Schema\Visitor\Visitor { @@ -34,13 +33,16 @@ class TableGeneratorSchemaVisitor implements \Doctrine\DBAL\Schema\Visitor\Visit */ private $generatorTableName; + /** + * @param string $generatorTableName + */ public function __construct($generatorTableName = 'sequences') { $this->generatorTableName = $generatorTableName; } /** - * @param Schema $schema + * {@inheritdoc} */ public function acceptSchema(Schema $schema) { @@ -51,40 +53,37 @@ class TableGeneratorSchemaVisitor implements \Doctrine\DBAL\Schema\Visitor\Visit } /** - * @param Table $table + * {@inheritdoc} */ public function acceptTable(Table $table) { } /** - * @param Column $column + * {@inheritdoc} */ public function acceptColumn(Table $table, Column $column) { } /** - * @param Table $localTable - * @param ForeignKeyConstraint $fkConstraint + * {@inheritdoc} */ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) { } /** - * @param Table $table - * @param Index $index + * {@inheritdoc} */ public function acceptIndex(Table $table, Index $index) { } /** - * @param Sequence $sequence + * {@inheritdoc} */ public function acceptSequence(Sequence $sequence) { } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/LockMode.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/LockMode.php old mode 100755 new mode 100644 index 52d87d23d3..8d78180ede --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/LockMode.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/LockMode.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL; /** - * Contains all DBAL LockModes + * Contains all DBAL LockModes. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 1.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 1.0 + * @author Benjamin Eberlei + * @author Roman Borschel */ class LockMode { @@ -38,5 +34,10 @@ class LockMode const PESSIMISTIC_READ = 2; const PESSIMISTIC_WRITE = 4; - final private function __construct() { } + /** + * Private constructor. This class cannot be instantiated. + */ + final private function __construct() + { + } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php old mode 100755 new mode 100644 index 7d70b90779..b143a3ee28 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php @@ -1,7 +1,5 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class DebugStack implements SQLLogger { - /** @var array $queries Executed SQL queries. */ + /** + * Executed SQL queries. + * + * @var array + */ public $queries = array(); - /** @var boolean $enabled If Debug Stack is enabled (log queries) or not. */ + /** + * If Debug Stack is enabled (log queries) or not. + * + * @var boolean + */ public $enabled = true; + /** + * @var float|null + */ public $start = null; + /** + * @var integer + */ public $currentQuery = 0; /** @@ -66,4 +76,3 @@ class DebugStack implements SQLLogger } } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php old mode 100755 new mode 100644 index a332258f5c..b1fedf1da1 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php @@ -1,7 +1,5 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class EchoSQLLogger implements SQLLogger { @@ -56,6 +52,5 @@ class EchoSQLLogger implements SQLLogger */ public function stopQuery() { - } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php old mode 100755 new mode 100644 index 6725cc5ee5..81845b1b25 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php @@ -20,21 +20,25 @@ namespace Doctrine\DBAL\Logging; /** - * Chains multiple SQLLogger + * Chains multiple SQLLogger. * - * - * @link www.doctrine-project.org - * @since 2.2 - * @author Christophe Coevoet + * @link www.doctrine-project.org + * @since 2.2 + * @author Christophe Coevoet */ class LoggerChain implements SQLLogger { + /** + * @var \Doctrine\DBAL\Logging\SQLLogger[] + */ private $loggers = array(); /** - * Adds a logger in the chain + * Adds a logger in the chain. * - * @param SQLLogger $logger + * @param \Doctrine\DBAL\Logging\SQLLogger $logger + * + * @return void */ public function addLogger(SQLLogger $logger) { @@ -61,4 +65,3 @@ class LoggerChain implements SQLLogger } } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/SQLLogger.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/SQLLogger.php old mode 100755 new mode 100644 index 9564f4c952..52491e50fe --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/SQLLogger.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/SQLLogger.php @@ -1,7 +1,5 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ interface SQLLogger { /** * Logs a SQL statement somewhere. * - * @param string $sql The SQL to be executed. - * @param array $params The SQL parameters. - * @param array $types The SQL parameter types. + * @param string $sql The SQL to be executed. + * @param array|null $params The SQL parameters. + * @param array|null $types The SQL parameter types. + * * @return void */ public function startQuery($sql, array $params = null, array $types = null); /** - * Mark the last started query as stopped. This can be used for timing of queries. + * Marks the last started query as stopped. This can be used for timing of queries. * * @return void */ diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php old mode 100755 new mode 100644 index e53b5f643a..0faa7a25d1 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -19,43 +19,42 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\DBALException, - Doctrine\DBAL\Connection, - Doctrine\DBAL\Types, - Doctrine\DBAL\Schema\Constraint, - Doctrine\DBAL\Schema\Sequence, - Doctrine\DBAL\Schema\Table, - Doctrine\DBAL\Schema\Index, - Doctrine\DBAL\Schema\ForeignKeyConstraint, - Doctrine\DBAL\Schema\TableDiff, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\ColumnDiff, - Doctrine\DBAL\Types\Type, - Doctrine\DBAL\Events, - Doctrine\Common\EventManager, - Doctrine\DBAL\Event\SchemaCreateTableEventArgs, - Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs, - Doctrine\DBAL\Event\SchemaDropTableEventArgs, - Doctrine\DBAL\Event\SchemaAlterTableEventArgs, - Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs, - Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs, - Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs, - Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs; +use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Types; +use Doctrine\DBAL\Schema\Constraint; +use Doctrine\DBAL\Schema\Sequence; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\ColumnDiff; +use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Events; +use Doctrine\Common\EventManager; +use Doctrine\DBAL\Event\SchemaCreateTableEventArgs; +use Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs; +use Doctrine\DBAL\Event\SchemaDropTableEventArgs; +use Doctrine\DBAL\Event\SchemaAlterTableEventArgs; +use Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs; +use Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs; +use Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs; +use Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs; /** * Base class for all DatabasePlatforms. The DatabasePlatforms are the central * point of abstraction of platform-specific behaviors, features and SQL dialects. * They are a passive source of information. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Lukas Smith (PEAR MDB2 library) - * @author Benjamin Eberlei - * @todo Remove any unnecessary methods. + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Lukas Smith (PEAR MDB2 library) + * @author Benjamin Eberlei + * @todo Remove any unnecessary methods. */ abstract class AbstractPlatform { @@ -90,7 +89,7 @@ abstract class AbstractPlatform const TRIM_BOTH = 3; /** - * @var array + * @var array|null */ protected $doctrineTypeMapping = null; @@ -98,12 +97,12 @@ abstract class AbstractPlatform * Contains a list of all columns that should generate parseable column comments for type-detection * in reverse engineering scenarios. * - * @var array + * @var array|null */ protected $doctrineTypeComments = null; /** - * @var Doctrine\Common\EventManager + * @var \Doctrine\Common\EventManager */ protected $_eventManager; @@ -117,7 +116,9 @@ abstract class AbstractPlatform /** * Constructor. */ - public function __construct() {} + public function __construct() + { + } /** * Sets the EventManager used by the Platform. @@ -140,7 +141,7 @@ abstract class AbstractPlatform } /** - * Gets the SQL snippet that declares a boolean column. + * Returns the SQL snippet that declares a boolean column. * * @param array $columnDef * @@ -149,7 +150,7 @@ abstract class AbstractPlatform abstract public function getBooleanTypeDeclarationSQL(array $columnDef); /** - * Gets the SQL snippet that declares a 4 byte integer column. + * Returns the SQL snippet that declares a 4 byte integer column. * * @param array $columnDef * @@ -158,7 +159,7 @@ abstract class AbstractPlatform abstract public function getIntegerTypeDeclarationSQL(array $columnDef); /** - * Gets the SQL snippet that declares an 8 byte integer column. + * Returns the SQL snippet that declares an 8 byte integer column. * * @param array $columnDef * @@ -167,7 +168,7 @@ abstract class AbstractPlatform abstract public function getBigIntTypeDeclarationSQL(array $columnDef); /** - * Gets the SQL snippet that declares a 2 byte integer column. + * Returns the SQL snippet that declares a 2 byte integer column. * * @param array $columnDef * @@ -176,23 +177,26 @@ abstract class AbstractPlatform abstract public function getSmallIntTypeDeclarationSQL(array $columnDef); /** - * Gets the SQL snippet that declares common properties of an integer column. + * Returns the SQL snippet that declares common properties of an integer column. * * @param array $columnDef + * * @return string */ abstract protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef); /** - * Lazy load Doctrine Type Mappings + * Lazy load Doctrine Type Mappings. * * @return void */ abstract protected function initializeDoctrineTypeMappings(); /** - * Initialize Doctrine Type Mappings with the platform defaults + * Initializes Doctrine Type Mappings with the platform defaults * and with all additional type mappings. + * + * @return void */ private function initializeAllDoctrineTypeMappings() { @@ -206,7 +210,7 @@ abstract class AbstractPlatform } /** - * Gets the SQL snippet used to declare a VARCHAR column type. + * Returns the SQL snippet used to declare a VARCHAR column type. * * @param array $field * @@ -228,7 +232,7 @@ abstract class AbstractPlatform } /** - * Get the SQL Snippet to create a GUID/UUID field. + * Returns the SQL snippet to declare a GUID/UUID field. * * By default this maps directly to a VARCHAR and only maps to more * special datatypes when the underlying databases support this datatype. @@ -248,7 +252,7 @@ abstract class AbstractPlatform * * @return string * - * @throws \Doctrine\DBAL\DBALException + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) { @@ -256,7 +260,7 @@ abstract class AbstractPlatform } /** - * Gets the SQL snippet used to declare a CLOB column type. + * Returns the SQL snippet used to declare a CLOB column type. * * @param array $field * @@ -265,7 +269,7 @@ abstract class AbstractPlatform abstract public function getClobTypeDeclarationSQL(array $field); /** - * Gets the SQL Snippet used to declare a BLOB column type. + * Returns the SQL Snippet used to declare a BLOB column type. * * @param array $field * @@ -281,12 +285,12 @@ abstract class AbstractPlatform abstract public function getName(); /** - * Register a doctrine type to be used in conjunction with a column type of this platform. + * Registers a doctrine type to be used in conjunction with a column type of this platform. * * @param string $dbType * @param string $doctrineType * - * @throws \Doctrine\DBAL\DBALException if the type is not found + * @throws \Doctrine\DBAL\DBALException If the type is not found. */ public function registerDoctrineTypeMapping($dbType, $doctrineType) { @@ -303,11 +307,13 @@ abstract class AbstractPlatform } /** - * Get the Doctrine type that is mapped for the given database column type. + * Gets the Doctrine type that is mapped for the given database column type. * - * @param string $dbType + * @param string $dbType * * @return string + * + * @throws \Doctrine\DBAL\DBALException */ public function getDoctrineTypeMapping($dbType) { @@ -325,7 +331,7 @@ abstract class AbstractPlatform } /** - * Check if a database type is currently supported by this platform. + * Checks if a database type is currently supported by this platform. * * @param string $dbType * @@ -338,11 +344,12 @@ abstract class AbstractPlatform } $dbType = strtolower($dbType); + return isset($this->doctrineTypeMapping[$dbType]); } /** - * Initialize the Doctrine Type comments instance variable for in_array() checks. + * Initializes the Doctrine Type comments instance variable for in_array() checks. * * @return void */ @@ -362,7 +369,7 @@ abstract class AbstractPlatform /** * Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type? * - * @param Type $doctrineType + * @param \Doctrine\DBAL\Types\Type $doctrineType * * @return boolean */ @@ -376,9 +383,9 @@ abstract class AbstractPlatform } /** - * Mark this type as to be commented in ALTER TABLE and CREATE TABLE statements. + * Marks this type as to be commented in ALTER TABLE and CREATE TABLE statements. * - * @param string|Type $doctrineType + * @param string|\Doctrine\DBAL\Types\Type $doctrineType * * @return void */ @@ -392,9 +399,10 @@ abstract class AbstractPlatform } /** - * Get the comment to append to a column comment that helps parsing this type in reverse engineering. + * Gets the comment to append to a column comment that helps parsing this type in reverse engineering. + * + * @param \Doctrine\DBAL\Types\Type $doctrineType * - * @param Type $doctrineType * @return string */ public function getDoctrineTypeComment(Type $doctrineType) @@ -403,9 +411,10 @@ abstract class AbstractPlatform } /** - * Return the comment of a passed column modified by potential doctrine type comment hints. + * Gets the comment of a passed column modified by potential doctrine type comment hints. + * + * @param \Doctrine\DBAL\Schema\Column $column * - * @param Column $column * @return string */ protected function getColumnComment(Column $column) @@ -483,6 +492,8 @@ abstract class AbstractPlatform * Returns the regular expression operator. * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getRegexpExpression() { @@ -490,9 +501,11 @@ abstract class AbstractPlatform } /** - * Returns global unique identifier + * Returns the global unique identifier expression. * - * @return string to get global unique identifier + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getGuidExpression() { @@ -500,26 +513,25 @@ abstract class AbstractPlatform } /** - * Returns the average value of a column + * Returns the SQL snippet to get the average value of a column. * - * @param string $column the column to use + * @param string $column The column to use. * - * @return string generated sql including an AVG aggregate function + * @return string Generated SQL including an AVG aggregate function. */ public function getAvgExpression($column) { - return 'AVG(' . $column . ')'; + return 'AVG(' . $column . ')'; } /** - * Returns the number of rows (without a NULL value) of a column + * Returns the SQL snippet to get the number of rows (without a NULL value) of a column. * - * If a '*' is used instead of a column the number of selected rows - * is returned. + * If a '*' is used instead of a column the number of selected rows is returned. * - * @param string|integer $column the column to use + * @param string|integer $column The column to use. * - * @return string generated sql including a COUNT aggregate function + * @return string Generated SQL including a COUNT aggregate function. */ public function getCountExpression($column) { @@ -527,10 +539,11 @@ abstract class AbstractPlatform } /** - * Returns the highest value of a column + * Returns the SQL snippet to get the highest value of a column. * - * @param string $column the column to use - * @return string generated sql including a MAX aggregate function + * @param string $column The column to use. + * + * @return string Generated SQL including a MAX aggregate function. */ public function getMaxExpression($column) { @@ -538,10 +551,11 @@ abstract class AbstractPlatform } /** - * Returns the lowest value of a column + * Returns the SQL snippet to get the lowest value of a column. * - * @param string $column the column to use - * @return string + * @param string $column The column to use. + * + * @return string Generated SQL including a MIN aggregate function. */ public function getMinExpression($column) { @@ -549,10 +563,11 @@ abstract class AbstractPlatform } /** - * Returns the total sum of a column + * Returns the SQL snippet to get the total sum of a column. * - * @param string $column the column to use - * @return string + * @param string $column The column to use. + * + * @return string Generated SQL including a SUM aggregate function. */ public function getSumExpression($column) { @@ -562,11 +577,12 @@ abstract class AbstractPlatform // scalar functions /** - * Returns the md5 sum of a field. + * Returns the SQL snippet to get the md5 sum of a field. * - * Note: Not SQL92, but common functionality + * Note: Not SQL92, but common functionality. * * @param string $column + * * @return string */ public function getMd5Expression($column) @@ -575,7 +591,7 @@ abstract class AbstractPlatform } /** - * Returns the length of a text field. + * Returns the SQL snippet to get the length of a text field. * * @param string $column * @@ -587,11 +603,11 @@ abstract class AbstractPlatform } /** - * Returns the squared value of a column + * Returns the SQL snippet to get the squared value of a column. * - * @param string $column the column to use + * @param string $column The column to use. * - * @return string generated sql including an SQRT aggregate function + * @return string Generated SQL including an SQRT aggregate function. */ public function getSqrtExpression($column) { @@ -599,9 +615,9 @@ abstract class AbstractPlatform } /** - * Rounds a numeric field to the number of decimals specified. + * Returns the SQL snippet to round a numeric field to the number of decimals specified. * - * @param string $column + * @param string $column * @param integer $decimals * * @return string @@ -612,8 +628,7 @@ abstract class AbstractPlatform } /** - * Returns the remainder of the division operation - * $expression1 / $expression2. + * Returns the SQL snippet to get the remainder of the division operation $expression1 / $expression2. * * @param string $expression1 * @param string $expression2 @@ -626,11 +641,11 @@ abstract class AbstractPlatform } /** - * Trim a string, leading/trailing/both and with a given char which defaults to space. + * Returns the SQL snippet to trim a string. * - * @param string $str - * @param integer $pos - * @param string $char has to be quoted already + * @param string $str The expression to apply the trim to. + * @param integer $pos The position of the trim (leading/trailing/both). + * @param string|boolean $char The char to trim, has to be quoted already. Defaults to space. * * @return string */ @@ -657,10 +672,9 @@ abstract class AbstractPlatform } /** - * rtrim - * returns the string $str with proceeding space characters removed + * Returns the SQL snippet to trim trailing space characters from the expression. * - * @param string $str literal string or column name + * @param string $str Literal string or column name. * * @return string */ @@ -670,10 +684,9 @@ abstract class AbstractPlatform } /** - * ltrim - * returns the string $str with leading space characters removed + * Returns the SQL snippet to trim leading space characters from the expression. * - * @param string $str literal string or column name + * @param string $str Literal string or column name. * * @return string */ @@ -683,11 +696,10 @@ abstract class AbstractPlatform } /** - * upper - * Returns the string $str with all characters changed to - * uppercase according to the current character set mapping. + * Returns the SQL snippet to change all characters from the expression to uppercase, + * according to the current character set mapping. * - * @param string $str literal string or column name + * @param string $str Literal string or column name. * * @return string */ @@ -697,11 +709,10 @@ abstract class AbstractPlatform } /** - * lower - * Returns the string $str with all characters changed to - * lowercase according to the current character set mapping. + * Returns the SQL snippet to change all characters from the expression to lowercase, + * according to the current character set mapping. * - * @param string $str literal string or column name + * @param string $str Literal string or column name. * * @return string */ @@ -711,13 +722,15 @@ abstract class AbstractPlatform } /** - * returns the position of the first occurrence of substring $substr in string $str + * Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str. * - * @param string $str literal string - * @param string $substr literal string to find - * @param integer $startPos position to start at, beginning of string by default + * @param string $str Literal string. + * @param string $substr Literal string to find. + * @param integer|boolean $startPos Position to start at, beginning of string by default. * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getLocateExpression($str, $substr, $startPos = false) { @@ -725,7 +738,7 @@ abstract class AbstractPlatform } /** - * Returns the current system date. + * Returns the SQL snippet to get the current system date. * * @return string */ @@ -735,15 +748,15 @@ abstract class AbstractPlatform } /** - * return string to call a function to get a substring inside an SQL statement + * Returns a SQL snippet to get a substring inside an SQL statement. * * Note: Not SQL92, but common functionality. * - * SQLite only supports the 2 parameter variant of this function + * SQLite only supports the 2 parameter variant of this function. * - * @param string $value an sql string literal or column name/alias - * @param integer $from where to start the substring portion - * @param integer $length the substring portion length + * @param string $value An sql string literal or column name/alias. + * @param integer $from Where to start the substring portion. + * @param integer|null $length The substring portion length. * * @return string */ @@ -757,12 +770,9 @@ abstract class AbstractPlatform } /** - * Returns a series of strings concatinated + * Returns a SQL snippet to concatenate the given expressions. * - * concat() accepts an arbitrary number of parameters. Each parameter - * must contain an expression - * - * @param string $arg1, $arg2 ... $argN strings that will be concatenated. + * Accepts an arbitrary number of string parameters. Each parameter must contain an expression. * * @return string */ @@ -784,7 +794,7 @@ abstract class AbstractPlatform * * @param string $expression * - * @return string a logical expression + * @return string The logical expression. */ public function getNotExpression($expression) { @@ -792,18 +802,19 @@ abstract class AbstractPlatform } /** - * Returns the SQL to check if a value is one in a set of - * given values. + * Returns the SQL to check if a value is one in a set of given values. * - * in() accepts an arbitrary number of parameters. The first parameter + * Accepts an arbitrary number of parameters. The first parameter * must always specify the value that should be matched against. Successive * must contain a logical expression or an array with logical expressions. * These expressions will be matched against the first parameter. * - * @param string $column the value that should be matched against - * @param string|array $values values that will be matched against $column + * @param string $column The value that should be matched against. + * @param string|string[] $values The values that will be matched against $column. * - * @return string logical expression + * @return string The logical expression. + * + * @throws \InvalidArgumentException */ public function getInExpression($column, $values) { @@ -822,11 +833,11 @@ abstract class AbstractPlatform } /** - * Returns SQL that checks if a expression is null. + * Returns the SQL that checks if an expression is null. * - * @param string $expression the expression that should be compared to null + * @param string $expression The expression that should be compared to null. * - * @return string logical expression + * @return string The logical expression. */ public function getIsNullExpression($expression) { @@ -834,11 +845,11 @@ abstract class AbstractPlatform } /** - * Returns SQL that checks if a expression is not null. + * Returns the SQL that checks if an expression is not null. * - * @param string $expression the expression that should be compared to null + * @param string $expression The expression that should be compared to null. * - * @return string logical expression + * @return string The logical expression. */ public function getIsNotNullExpression($expression) { @@ -846,8 +857,7 @@ abstract class AbstractPlatform } /** - * Returns SQL that checks if an expression evaluates to a value between - * two values. + * Returns the SQL that checks if an expression evaluates to a value between two values. * * The parameter $expression is checked if it is between $value1 and $value2. * @@ -855,46 +865,74 @@ abstract class AbstractPlatform * http://www.w3schools.com/sql/sql_between.asp. If you want complete database * independence you should avoid using between(). * - * @param string $expression the value to compare to - * @param string $value1 the lower value to compare with - * @param string $value2 the higher value to compare with + * @param string $expression The value to compare to. + * @param string $value1 The lower value to compare with. + * @param string $value2 The higher value to compare with. * - * @return string logical expression + * @return string The logical expression. */ public function getBetweenExpression($expression, $value1, $value2) { return $expression . ' BETWEEN ' .$value1 . ' AND ' . $value2; } + /** + * Returns the SQL to get the arccosine of a value. + * + * @param string $value + * + * @return string + */ public function getAcosExpression($value) { return 'ACOS(' . $value . ')'; } + /** + * Returns the SQL to get the sine of a value. + * + * @param string $value + * + * @return string + */ public function getSinExpression($value) { return 'SIN(' . $value . ')'; } + /** + * Returns the SQL to get the PI value. + * + * @return string + */ public function getPiExpression() { return 'PI()'; } + /** + * Returns the SQL to get the cosine of a value. + * + * @param string $value + * + * @return string + */ public function getCosExpression($value) { return 'COS(' . $value . ')'; } /** - * Calculate the difference in days between the two passed dates. + * Returns the SQL to calculate the difference in days between the two passed dates. * - * Computes diff = date1 - date2 + * Computes diff = date1 - date2. * * @param string $date1 * @param string $date2 * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getDateDiffExpression($date1, $date2) { @@ -902,12 +940,14 @@ abstract class AbstractPlatform } /** - * Add the number of given days to a date. + * Returns the SQL to add the number of given days to a date. * - * @param string $date + * @param string $date * @param integer $days * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getDateAddDaysExpression($date, $days) { @@ -915,12 +955,14 @@ abstract class AbstractPlatform } /** - * Substract the number of given days to a date. + * Returns the SQL to subtract the number of given days to a date. * - * @param string $date + * @param string $date * @param integer $days * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getDateSubDaysExpression($date, $days) { @@ -928,12 +970,14 @@ abstract class AbstractPlatform } /** - * Add the number of given months to a date. + * Returns the SQL to add the number of given months to a date. * - * @param string $date + * @param string $date * @param integer $months * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getDateAddMonthExpression($date, $months) { @@ -941,12 +985,14 @@ abstract class AbstractPlatform } /** - * Substract the number of given months to a date. + * Returns the SQL to subtract the number of given months to a date. * - * @param string $date + * @param string $date * @param integer $months * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getDateSubMonthExpression($date, $months) { @@ -954,12 +1000,12 @@ abstract class AbstractPlatform } /** - * Gets SQL bit AND comparison expression + * Returns the SQL bit AND comparison expression. * - * @param string $value1 - * @param string $value2 + * @param string $value1 + * @param string $value2 * - * @return string + * @return string */ public function getBitAndComparisonExpression($value1, $value2) { @@ -967,18 +1013,23 @@ abstract class AbstractPlatform } /** - * Gets SQL bit OR comparison expression + * Returns the SQL bit OR comparison expression. * - * @param string $value1 - * @param string $value2 + * @param string $value1 + * @param string $value2 * - * @return string + * @return string */ public function getBitOrComparisonExpression($value1, $value2) { return '(' . $value1 . ' | ' . $value2 . ')'; } + /** + * Returns the FOR UPDATE expression. + * + * @return string + */ public function getForUpdateSQL() { return 'FOR UPDATE'; @@ -987,8 +1038,8 @@ abstract class AbstractPlatform /** * Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification. * - * @param string $fromClause - * @param integer $lockMode + * @param string $fromClause + * @param integer $lockMode * * @return string */ @@ -998,9 +1049,9 @@ abstract class AbstractPlatform } /** - * Get the sql snippet to append to any SELECT statement which locks rows in shared read lock. + * Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock. * - * This defaults to the ASNI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database + * This defaults to the ANSI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database * vendors allow to lighten this constraint up to be a real read lock. * * @return string @@ -1011,9 +1062,9 @@ abstract class AbstractPlatform } /** - * Get the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows. + * Returns the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows. * - * The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ASNI SQL standard. + * The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ANSI SQL standard. * * @return string */ @@ -1023,9 +1074,9 @@ abstract class AbstractPlatform } /** - * Get the SQL snippet to drop an existing database + * Returns the SQL snippet to drop an existing database. * - * @param string $database name of the database that should be dropped + * @param string $database The name of the database that should be dropped. * * @return string */ @@ -1035,13 +1086,13 @@ abstract class AbstractPlatform } /** - * Drop a Table + * Returns the SQL snippet to drop an existing table. * - * @throws \InvalidArgumentException - * - * @param Table|string $table + * @param \Doctrine\DBAL\Schema\Table|string $table * * @return string + * + * @throws \InvalidArgumentException */ public function getDropTableSQL($table) { @@ -1066,9 +1117,9 @@ abstract class AbstractPlatform } /** - * Get SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction. + * Returns the SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction. * - * @param Table|string $table + * @param \Doctrine\DBAL\Schema\Table|string $table * * @return string */ @@ -1078,12 +1129,14 @@ abstract class AbstractPlatform } /** - * Drop index from a table + * Returns the SQL to drop an index from a table. * - * @param Index|string $name - * @param string|Table $table + * @param \Doctrine\DBAL\Schema\Index|string $index + * @param \Doctrine\DBAL\Schema\Table|string $table * * @return string + * + * @throws \InvalidArgumentException */ public function getDropIndexSQL($index, $table = null) { @@ -1097,10 +1150,10 @@ abstract class AbstractPlatform } /** - * Get drop constraint sql + * Returns the SQL to drop a constraint. * - * @param \Doctrine\DBAL\Schema\Constraint $constraint - * @param string|Table $table + * @param \Doctrine\DBAL\Schema\Constraint|string $constraint + * @param \Doctrine\DBAL\Schema\Table|string $table * * @return string */ @@ -1118,8 +1171,10 @@ abstract class AbstractPlatform } /** - * @param ForeignKeyConstraint|string $foreignKey - * @param Table|string $table + * Returns the SQL to drop a foreign key. + * + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint|string $foreignKey + * @param \Doctrine\DBAL\Schema\Table|string $table * * @return string */ @@ -1137,13 +1192,16 @@ abstract class AbstractPlatform } /** - * Gets the SQL statement(s) to create a table with the specified name, columns and constraints + * Returns the SQL statement(s) to create a table with the specified name, columns and constraints * on this platform. * - * @param string $table The name of the table. - * @param integer $createFlags + * @param \Doctrine\DBAL\Schema\Table $table + * @param integer $createFlags * * @return array The sequence of SQL statements. + * + * @throws \Doctrine\DBAL\DBALException + * @throws \InvalidArgumentException */ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES) { @@ -1165,10 +1223,7 @@ abstract class AbstractPlatform foreach ($table->getIndexes() as $index) { /* @var $index Index */ if ($index->isPrimary()) { - $platform = $this; - $options['primary'] = array_map(function ($columnName) use ($table, $platform) { - return $table->getColumn($columnName)->getQuotedName($platform); - }, $index->getColumns()); + $options['primary'] = $index->getQuotedColumns($this); $options['primary_index'] = $index; } else { $options['indexes'][$index->getName()] = $index; @@ -1193,27 +1248,15 @@ abstract class AbstractPlatform } } - $columnData = array(); + $columnData = $column->toArray(); $columnData['name'] = $column->getQuotedName($this); - $columnData['type'] = $column->getType(); - $columnData['length'] = $column->getLength(); - $columnData['notnull'] = $column->getNotNull(); - $columnData['fixed'] = $column->getFixed(); - $columnData['unique'] = false; // TODO: what do we do about this? $columnData['version'] = $column->hasPlatformOption("version") ? $column->getPlatformOption('version') : false; + $columnData['comment'] = $this->getColumnComment($column); if (strtolower($columnData['type']) == "string" && $columnData['length'] === null) { $columnData['length'] = 255; } - $columnData['unsigned'] = $column->getUnsigned(); - $columnData['precision'] = $column->getPrecision(); - $columnData['scale'] = $column->getScale(); - $columnData['default'] = $column->getDefault(); - $columnData['columnDefinition'] = $column->getColumnDefinition(); - $columnData['autoincrement'] = $column->getAutoincrement(); - $columnData['comment'] = $this->getColumnComment($column); - if (in_array($column->getName(), $options['primary'])) { $columnData['primary'] = true; } @@ -1249,17 +1292,24 @@ abstract class AbstractPlatform return array_merge($sql, $columnSql); } + /** + * @param string $tableName + * @param string $columnName + * @param string $comment + * + * @return string + */ public function getCommentOnColumnSQL($tableName, $columnName, $comment) { return "COMMENT ON COLUMN " . $tableName . "." . $columnName . " IS '" . $comment . "'"; } /** - * Gets the SQL used to create a table. + * Returns the SQL used to create a table. * * @param string $tableName - * @param array $columns - * @param array $options + * @param array $columns + * @param array $options * * @return array */ @@ -1302,19 +1352,22 @@ abstract class AbstractPlatform return $sql; } + /** + * @return string + */ public function getCreateTemporaryTableSnippetSQL() { return "CREATE TEMPORARY TABLE"; } /** - * Gets the SQL to create a sequence on this platform. + * Returns the SQL to create a sequence on this platform. * * @param \Doctrine\DBAL\Schema\Sequence $sequence * * @return string * - * @throws DBALException + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getCreateSequenceSQL(Sequence $sequence) { @@ -1322,11 +1375,13 @@ abstract class AbstractPlatform } /** - * Gets the SQL statement to change a sequence on this platform. + * Returns the SQL to change a sequence on this platform. * * @param \Doctrine\DBAL\Schema\Sequence $sequence * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getAlterSequenceSQL(Sequence $sequence) { @@ -1334,12 +1389,14 @@ abstract class AbstractPlatform } /** - * Gets the SQL to create a constraint on a table on this platform. + * Returns the SQL to create a constraint on a table on this platform. * - * @param \Doctrine\DBAL\Schema\Constraint $constraint - * @param string|Table $table + * @param \Doctrine\DBAL\Schema\Constraint $constraint + * @param \Doctrine\DBAL\Schema\Table|string $table * * @return string + * + * @throws \InvalidArgumentException */ public function getCreateConstraintSQL(Constraint $constraint, $table) { @@ -1349,11 +1406,7 @@ abstract class AbstractPlatform $query = 'ALTER TABLE ' . $table . ' ADD CONSTRAINT ' . $constraint->getQuotedName($this); - $columns = array(); - foreach ($constraint->getColumns() as $column) { - $columns[] = $column; - } - $columnList = '('. implode(', ', $columns) . ')'; + $columnList = '('. implode(', ', $constraint->getQuotedColumns($this)) . ')'; $referencesClause = ''; if ($constraint instanceof Index) { @@ -1369,12 +1422,8 @@ abstract class AbstractPlatform } else if ($constraint instanceof ForeignKeyConstraint) { $query .= ' FOREIGN KEY'; - $foreignColumns = array(); - foreach ($constraint->getForeignColumns() as $column) { - $foreignColumns[] = $column; - } - - $referencesClause = ' REFERENCES '.$constraint->getForeignTableName(). ' ('.implode(', ', $foreignColumns).')'; + $referencesClause = ' REFERENCES ' . $constraint->getQuotedForeignTableName($this) . + ' (' . implode(', ', $constraint->getQuotedForeignColumns($this)) . ')'; } $query .= ' '.$columnList.$referencesClause; @@ -1382,12 +1431,14 @@ abstract class AbstractPlatform } /** - * Gets the SQL to create an index on a table on this platform. + * Returns the SQL to create an index on a table on this platform. * - * @param Index $index - * @param string|Table $table name of the table on which the index is to be created + * @param \Doctrine\DBAL\Schema\Index $index + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the index is to be created. * * @return string + * + * @throws \InvalidArgumentException */ public function getCreateIndexSQL(Index $index, $table) { @@ -1395,7 +1446,7 @@ abstract class AbstractPlatform $table = $table->getQuotedName($this); } $name = $index->getQuotedName($this); - $columns = $index->getColumns(); + $columns = $index->getQuotedColumns($this); if (count($columns) == 0) { throw new \InvalidArgumentException("Incomplete definition. 'columns' required."); @@ -1412,9 +1463,9 @@ abstract class AbstractPlatform } /** - * Adds additional flags for index generation + * Adds additional flags for index generation. * - * @param Index $index + * @param \Doctrine\DBAL\Schema\Index $index * * @return string */ @@ -1424,16 +1475,16 @@ abstract class AbstractPlatform } /** - * Get SQL to create an unnamed primary key constraint. + * Returns the SQL to create an unnamed primary key constraint. * - * @param Index $index - * @param string|Table $table + * @param \Doctrine\DBAL\Schema\Index $index + * @param \Doctrine\DBAL\Schema\Table|string $table * * @return string */ public function getCreatePrimaryKeySQL(Index $index, $table) { - return 'ALTER TABLE ' . $table . ' ADD PRIMARY KEY (' . $this->getIndexFieldDeclarationListSQL($index->getColumns()) . ')'; + return 'ALTER TABLE ' . $table . ' ADD PRIMARY KEY (' . $this->getIndexFieldDeclarationListSQL($index->getQuotedColumns($this)) . ')'; } /** @@ -1442,12 +1493,12 @@ abstract class AbstractPlatform * chains separated by dot and quotes them independently. * * NOTE: Just because you CAN use quoted identifiers doesn't mean - * you SHOULD use them. In general, they end up causing way more + * you SHOULD use them. In general, they end up causing way more * problems than they solve. * - * @param string $str identifier name to be quoted + * @param string $str The identifier name to be quoted. * - * @return string quoted identifier string + * @return string The quoted identifier string. */ public function quoteIdentifier($str) { @@ -1461,11 +1512,11 @@ abstract class AbstractPlatform } /** - * Quote a single identifier (no dot chain separation) + * Quotes a single identifier (no dot chain separation). * - * @param string $str + * @param string $str The identifier name to be quoted. * - * @return string + * @return string The quoted identifier string. */ public function quoteSingleIdentifier($str) { @@ -1475,10 +1526,10 @@ abstract class AbstractPlatform } /** - * Create a new foreign key + * Returns the SQL to create a new foreign key. * - * @param ForeignKeyConstraint $foreignKey ForeignKey instance - * @param string|Table $table name of the table on which the foreign key is to be created + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey The foreign key constraint. + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the foreign key is to be created. * * @return string */ @@ -1494,13 +1545,15 @@ abstract class AbstractPlatform } /** - * Gets the sql statements for altering an existing table. + * Gets the SQL statements for altering an existing table. * - * The method returns an array of sql statements, since some platforms need several statements. + * This method returns an array of SQL statements, since some platforms need several statements. * - * @param TableDiff $diff + * @param \Doctrine\DBAL\Schema\TableDiff $diff * * @return array + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getAlterTableSQL(TableDiff $diff) { @@ -1508,9 +1561,9 @@ abstract class AbstractPlatform } /** - * @param Column $column - * @param TableDiff $diff - * @param array $columnSql + * @param \Doctrine\DBAL\Schema\Column $column + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * @param array $columnSql * * @return boolean */ @@ -1533,9 +1586,9 @@ abstract class AbstractPlatform } /** - * @param Column $column - * @param TableDiff $diff - * @param array $columnSql + * @param \Doctrine\DBAL\Schema\Column $column + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * @param array $columnSql * * @return boolean */ @@ -1558,9 +1611,9 @@ abstract class AbstractPlatform } /** - * @param ColumnDiff $columnDiff - * @param TableDiff $diff - * @param array $columnSql + * @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * @param array $columnSql * * @return boolean */ @@ -1583,10 +1636,10 @@ abstract class AbstractPlatform } /** - * @param string $oldColumnName - * @param Column $column - * @param TableDiff $diff - * @param array $columnSql + * @param string $oldColumnName + * @param \Doctrine\DBAL\Schema\Column $column + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * @param array $columnSql * * @return boolean */ @@ -1609,8 +1662,8 @@ abstract class AbstractPlatform } /** - * @param TableDiff $diff - * @param array $sql + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * @param array $sql * * @return boolean */ @@ -1632,6 +1685,11 @@ abstract class AbstractPlatform return $eventArgs->isDefaultPrevented(); } + /** + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * + * @return array + */ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) { $tableName = $diff->name; @@ -1656,6 +1714,11 @@ abstract class AbstractPlatform return $sql; } + /** + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * + * @return array + */ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) { $tableName = false !== $diff->newName ? $diff->newName : $diff->name; @@ -1683,7 +1746,7 @@ abstract class AbstractPlatform /** * Common code for alter table statement generation that updates the changed Index and Foreign Key definitions. * - * @param TableDiff $diff + * @param \Doctrine\DBAL\Schema\TableDiff $diff * * @return array */ @@ -1693,13 +1756,13 @@ abstract class AbstractPlatform } /** - * Get declaration of a number of fields in bulk + * Gets declaration of a number of fields in bulk. * - * @param array $fields a multidimensional associative array. - * The first dimension determines the field name, while the second - * dimension is keyed with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: + * @param array $fields A multidimensional associative array. + * The first dimension determines the field name, while the second + * dimension is keyed with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: * * length * Integer value that determines the maximum length of the text @@ -1733,13 +1796,13 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL code portion needed to declare a generic type + * Obtains DBMS specific SQL code portion needed to declare a generic type * field to be used in statements like CREATE TABLE. * - * @param string $name name the field to be declared. - * @param array $field associative array with the name of the properties - * of the field being declared as array indexes. Currently, the types - * of supported field properties are as follows: + * @param string $name The name the field to be declared. + * @param array $field An associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: * * length * Integer value that determines the maximum length of the text @@ -1763,7 +1826,7 @@ abstract class AbstractPlatform * columnDefinition * a string that defines the complete column * - * @return string DBMS specific SQL code portion that should be used to declare the column. + * @return string DBMS specific SQL code portion that should be used to declare the column. */ public function getColumnDeclarationSQL($name, array $field) { @@ -1798,7 +1861,7 @@ abstract class AbstractPlatform } /** - * Gets the SQL snippet that declares a floating point column of arbitrary precision. + * Returns the SQL snippet that declares a floating point column of arbitrary precision. * * @param array $columnDef * @@ -1815,12 +1878,12 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL code portion needed to set a default value + * Obtains DBMS specific SQL code portion needed to set a default value * declaration to be used in statements like CREATE TABLE. * - * @param array $field field definition array + * @param array $field The field definition array. * - * @return string DBMS specific SQL code portion needed to set a default value + * @return string DBMS specific SQL code portion needed to set a default value. */ public function getDefaultValueDeclarationSQL($field) { @@ -1833,21 +1896,26 @@ abstract class AbstractPlatform $default = " DEFAULT ".$field['default']; } else if ((string)$field['type'] == 'DateTime' && $field['default'] == $this->getCurrentTimestampSQL()) { $default = " DEFAULT ".$this->getCurrentTimestampSQL(); + } else if ((string)$field['type'] == 'Time' && $field['default'] == $this->getCurrentTimeSQL()) { + $default = " DEFAULT ".$this->getCurrentTimeSQL(); + } else if ((string)$field['type'] == 'Date' && $field['default'] == $this->getCurrentDateSQL()) { + $default = " DEFAULT ".$this->getCurrentDateSQL(); } else if ((string) $field['type'] == 'Boolean') { $default = " DEFAULT '" . $this->convertBooleans($field['default']) . "'"; } } } + return $default; } /** - * Obtain DBMS specific SQL code portion needed to set a CHECK constraint + * Obtains DBMS specific SQL code portion needed to set a CHECK constraint * declaration to be used in statements like CREATE TABLE. * - * @param array $definition check definition + * @param array $definition The check definition. * - * @return string DBMS specific SQL code portion needed to set a CHECK constraint + * @return string DBMS specific SQL code portion needed to set a CHECK constraint. */ public function getCheckDeclarationSQL(array $definition) { @@ -1870,55 +1938,55 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL code portion needed to set a unique + * Obtains DBMS specific SQL code portion needed to set a unique * constraint declaration to be used in statements like CREATE TABLE. * - * @param string $name name of the unique constraint - * @param Index $index index definition + * @param string $name The name of the unique constraint. + * @param \Doctrine\DBAL\Schema\Index $index The index definition. * - * @return string DBMS specific SQL code portion needed - * to set a constraint + * @return string DBMS specific SQL code portion needed to set a constraint. + * + * @throws \InvalidArgumentException */ public function getUniqueConstraintDeclarationSQL($name, Index $index) { - if (count($index->getColumns()) === 0) { + $columns = $index->getQuotedColumns($this); + + if (count($columns) === 0) { throw new \InvalidArgumentException("Incomplete definition. 'columns' required."); } return 'CONSTRAINT ' . $name . ' UNIQUE (' - . $this->getIndexFieldDeclarationListSQL($index->getColumns()) + . $this->getIndexFieldDeclarationListSQL($columns) . ')'; } /** - * Obtain DBMS specific SQL code portion needed to set an index + * Obtains DBMS specific SQL code portion needed to set an index * declaration to be used in statements like CREATE TABLE. * - * @param string $name name of the index - * @param Index $index index definition + * @param string $name The name of the index. + * @param \Doctrine\DBAL\Schema\Index $index The index definition. * - * @return string DBMS specific SQL code portion needed to set an index + * @return string DBMS specific SQL code portion needed to set an index. + * + * @throws \InvalidArgumentException */ public function getIndexDeclarationSQL($name, Index $index) { - $type = ''; + $columns = $index->getQuotedColumns($this); - if ($index->isUnique()) { - $type = 'UNIQUE '; - } - - if (count($index->getColumns()) === 0) { + if (count($columns) === 0) { throw new \InvalidArgumentException("Incomplete definition. 'columns' required."); } - return $type . 'INDEX ' . $name . ' (' - . $this->getIndexFieldDeclarationListSQL($index->getColumns()) + return $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' (' + . $this->getIndexFieldDeclarationListSQL($columns) . ')'; } /** - * getCustomTypeDeclarationSql - * Obtail SQL code portion needed to create a custom column, + * Obtains SQL code portion needed to create a custom column, * e.g. when a field has the "columnDefinition" keyword. * Only "AUTOINCREMENT" and "PRIMARY KEY" are added if appropriate. * @@ -1932,8 +2000,7 @@ abstract class AbstractPlatform } /** - * getIndexFieldDeclarationList - * Obtain DBMS specific SQL code portion needed to set an index + * Obtains DBMS specific SQL code portion needed to set an index * declaration to be used in statements like CREATE TABLE. * * @param array $fields @@ -1956,7 +2023,7 @@ abstract class AbstractPlatform } /** - * A method to return the required SQL string that fits between CREATE ... TABLE + * Returns the required SQL string that fits between CREATE ... TABLE * to create the table as a temporary table. * * Should be overridden in driver classes to return the correct string for the @@ -1977,7 +2044,7 @@ abstract class AbstractPlatform /** * Some vendors require temporary table names to be qualified specially. * - * @param string $tableName + * @param string $tableName * * @return string */ @@ -1986,24 +2053,14 @@ abstract class AbstractPlatform return $tableName; } - /** - * Get sql query to show a list of database. - * - * @return string - */ - public function getShowDatabasesSQL() - { - throw DBALException::notSupported(__METHOD__); - } - /** * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint * of a field declaration to be used in statements like CREATE TABLE. * * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey * - * @return string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint - * of a field declaration. + * @return string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint + * of a field declaration. */ public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) { @@ -2014,10 +2071,10 @@ abstract class AbstractPlatform } /** - * Return the FOREIGN KEY query section dealing with non-standard options + * Returns the FOREIGN KEY query section dealing with non-standard options * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... * - * @param ForeignKeyConstraint $foreignKey foreign key definition + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey The foreign key definition. * * @return string */ @@ -2030,18 +2087,18 @@ abstract class AbstractPlatform if ($foreignKey->hasOption('onDelete')) { $query .= ' ON DELETE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onDelete')); } + return $query; } /** - * returns given referential action in uppercase if valid, otherwise throws - * an exception + * Returns the given referential action in uppercase if valid, otherwise throws an exception. * - * @throws \InvalidArgumentException if unknown referential action given - * - * @param string $action foreign key referential action + * @param string $action The foreign key referential action. * * @return string + * + * @throws \InvalidArgumentException if unknown referential action given */ public function getForeignKeyReferentialActionSQL($action) { @@ -2059,12 +2116,14 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint + * Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint * of a field declaration to be used in statements like CREATE TABLE. * - * @param ForeignKeyConstraint $foreignKey + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey * * @return string + * + * @throws \InvalidArgumentException */ public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey) { @@ -2084,20 +2143,20 @@ abstract class AbstractPlatform throw new \InvalidArgumentException("Incomplete definition. 'foreignTable' required."); } - $sql .= implode(', ', $foreignKey->getLocalColumns()) + $sql .= implode(', ', $foreignKey->getQuotedLocalColumns($this)) . ') REFERENCES ' . $foreignKey->getQuotedForeignTableName($this) . ' (' - . implode(', ', $foreignKey->getForeignColumns()) . ')'; + . implode(', ', $foreignKey->getQuotedForeignColumns($this)) . ')'; return $sql; } /** - * Obtain DBMS specific SQL code portion needed to set the UNIQUE constraint + * Obtains DBMS specific SQL code portion needed to set the UNIQUE constraint * of a field declaration to be used in statements like CREATE TABLE. * - * @return string DBMS specific SQL code portion needed to set the UNIQUE constraint - * of a field declaration. + * @return string DBMS specific SQL code portion needed to set the UNIQUE constraint + * of a field declaration. */ public function getUniqueFieldDeclarationSQL() { @@ -2105,13 +2164,13 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL code portion needed to set the CHARACTER SET + * Obtains DBMS specific SQL code portion needed to set the CHARACTER SET * of a field declaration to be used in statements like CREATE TABLE. * - * @param string $charset name of the charset + * @param string $charset The name of the charset. * - * @return string DBMS specific SQL code portion needed to set the CHARACTER SET - * of a field declaration. + * @return string DBMS specific SQL code portion needed to set the CHARACTER SET + * of a field declaration. */ public function getColumnCharsetDeclarationSQL($charset) { @@ -2119,13 +2178,13 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL code portion needed to set the COLLATION + * Obtains DBMS specific SQL code portion needed to set the COLLATION * of a field declaration to be used in statements like CREATE TABLE. * - * @param string $collation name of the collation + * @param string $collation The name of the collation. * - * @return string DBMS specific SQL code portion needed to set the COLLATION - * of a field declaration. + * @return string DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration. */ public function getColumnCollationDeclarationSQL($collation) { @@ -2179,7 +2238,7 @@ abstract class AbstractPlatform } /** - * Gets the SQL specific for the platform to get the current date. + * Returns the SQL specific for the platform to get the current date. * * @return string */ @@ -2189,7 +2248,7 @@ abstract class AbstractPlatform } /** - * Gets the SQL specific for the platform to get the current time. + * Returns the SQL specific for the platform to get the current time. * * @return string */ @@ -2199,7 +2258,7 @@ abstract class AbstractPlatform } /** - * Gets the SQL specific for the platform to get the current timestamp + * Returns the SQL specific for the platform to get the current timestamp * * @return string */ @@ -2209,11 +2268,13 @@ abstract class AbstractPlatform } /** - * Get sql for transaction isolation level Connection constant + * Returns the SQL for a given transaction isolation level Connection constant. * * @param integer $level * * @return string + * + * @throws \InvalidArgumentException */ protected function _getTransactionIsolationLevelSQL($level) { @@ -2231,42 +2292,81 @@ abstract class AbstractPlatform } } + /** + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getListDatabasesSQL() { throw DBALException::notSupported(__METHOD__); } + /** + * @param string $database + * + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getListSequencesSQL($database) { throw DBALException::notSupported(__METHOD__); } + /** + * @param string $table + * + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getListTableConstraintsSQL($table) { throw DBALException::notSupported(__METHOD__); } + /** + * @param string $table + * @param string|null $database + * + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getListTableColumnsSQL($table, $database = null) { throw DBALException::notSupported(__METHOD__); } + /** + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getListTablesSQL() { throw DBALException::notSupported(__METHOD__); } + /** + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getListUsersSQL() { throw DBALException::notSupported(__METHOD__); } /** - * Get the SQL to list all views of a database or user. + * Returns the SQL to list all views of a database or user. * * @param string $database * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getListViewsSQL($database) { @@ -2274,7 +2374,7 @@ abstract class AbstractPlatform } /** - * Get the list of indexes for the current database. + * Returns the list of indexes for the current database. * * The current database parameter is optional but will always be passed * when using the SchemaManager API and is the database the given table is in. @@ -2287,50 +2387,85 @@ abstract class AbstractPlatform * @param string $currentDatabase * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getListTableIndexesSQL($table, $currentDatabase = null) { throw DBALException::notSupported(__METHOD__); } + /** + * @param string $table + * + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getListTableForeignKeysSQL($table) { throw DBALException::notSupported(__METHOD__); } + /** + * @param string $name + * @param string $sql + * + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getCreateViewSQL($name, $sql) { throw DBALException::notSupported(__METHOD__); } + /** + * @param string $name + * + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getDropViewSQL($name) { throw DBALException::notSupported(__METHOD__); } /** - * Get the SQL snippet to drop an existing sequence + * Returns the SQL snippet to drop an existing sequence. * - * @param \Doctrine\DBAL\Schema\Sequence $sequence + * @param \Doctrine\DBAL\Schema\Sequence $sequence * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getDropSequenceSQL($sequence) { throw DBALException::notSupported(__METHOD__); } + /** + * @param string $sequenceName + * + * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. + */ public function getSequenceNextValSQL($sequenceName) { throw DBALException::notSupported(__METHOD__); } /** - * create a new database + * Returns the SQL to create a new database. * - * @param string $database name of the database that should be created + * @param string $database The name of the database that should be created. * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getCreateDatabaseSQL($database) { @@ -2338,11 +2473,13 @@ abstract class AbstractPlatform } /** - * Get sql to set the transaction isolation level + * Returns the SQL to set the transaction isolation level. * * @param integer $level * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getSetTransactionIsolationSQL($level) { @@ -2350,12 +2487,14 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL to be used to create datetime fields in - * statements like CREATE TABLE + * Obtains DBMS specific SQL to be used to create datetime fields in + * statements like CREATE TABLE. * * @param array $fieldDeclaration * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) { @@ -2363,7 +2502,7 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL to be used to create datetime with timezone offset fields. + * Obtains DBMS specific SQL to be used to create datetime with timezone offset fields. * * @param array $fieldDeclaration * @@ -2376,12 +2515,14 @@ abstract class AbstractPlatform /** - * Obtain DBMS specific SQL to be used to create date fields in statements + * Obtains DBMS specific SQL to be used to create date fields in statements * like CREATE TABLE. * * @param array $fieldDeclaration * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getDateTypeDeclarationSQL(array $fieldDeclaration) { @@ -2389,18 +2530,25 @@ abstract class AbstractPlatform } /** - * Obtain DBMS specific SQL to be used to create time fields in statements + * Obtains DBMS specific SQL to be used to create time fields in statements * like CREATE TABLE. * * @param array $fieldDeclaration * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ public function getTimeTypeDeclarationSQL(array $fieldDeclaration) { throw DBALException::notSupported(__METHOD__); } + /** + * @param array $fieldDeclaration + * + * @return string + */ public function getFloatDeclarationSQL(array $fieldDeclaration) { return 'DOUBLE PRECISION'; @@ -2432,7 +2580,8 @@ abstract class AbstractPlatform /** * Whether the platform supports identity columns. - * Identity columns are columns that recieve an auto-generated value from the + * + * Identity columns are columns that receive an auto-generated value from the * database on insert of a row. * * @return boolean @@ -2503,7 +2652,7 @@ abstract class AbstractPlatform } /** - * Does the platform supports foreign key constraints? + * Whether the platform supports foreign key constraints. * * @return boolean */ @@ -2513,7 +2662,7 @@ abstract class AbstractPlatform } /** - * Does this platform supports onUpdate in foreign key constraints? + * Whether this platform supports onUpdate in foreign key constraints. * * @return boolean */ @@ -2533,7 +2682,7 @@ abstract class AbstractPlatform } /** - * Can this platform emulate schemas? + * Whether this platform can emulate schemas. * * Platforms that either support or emulate schemas don't automatically * filter a schema for the namespaced elements in {@link @@ -2547,6 +2696,8 @@ abstract class AbstractPlatform } /** + * Whether this platform supports create database. + * * Some databases don't allow to create and drop databases at all or only with certain tools. * * @return boolean @@ -2557,8 +2708,7 @@ abstract class AbstractPlatform } /** - * Whether the platform supports getting the affected rows of a recent - * update/delete type query. + * Whether the platform supports getting the affected rows of a recent update/delete type query. * * @return boolean */ @@ -2568,7 +2718,7 @@ abstract class AbstractPlatform } /** - * Does this plaform support to add inline column comments as postfix. + * Whether this platform support to add inline column comments as postfix. * * @return boolean */ @@ -2578,7 +2728,7 @@ abstract class AbstractPlatform } /** - * Does this platform support the propriortary synatx "COMMENT ON asset" + * Whether this platform support the proprietary syntax "COMMENT ON asset". * * @return boolean */ @@ -2587,13 +2737,27 @@ abstract class AbstractPlatform return false; } + /** + * Does this platform have native guid type. + * + * @return boolean + */ + public function hasNativeGuidType() + { + return false; + } + + /** + * @deprecated + * @todo Remove in 3.0 + */ public function getIdentityColumnNullInsertSQL() { return ""; } /** - * Does this platform views ? + * Whether this platform supports views. * * @return boolean */ @@ -2647,13 +2811,15 @@ abstract class AbstractPlatform } /** - * Modify limit query + * Adds an driver-specific LIMIT clause to the query. * - * @param string $query - * @param integer $limit - * @param integer $offset + * @param string $query + * @param integer|null $limit + * @param integer|null $offset * * @return string + * + * @throws DBALException */ final public function modifyLimitQuery($query, $limit, $offset = null) { @@ -2676,11 +2842,11 @@ abstract class AbstractPlatform } /** - * Adds an driver-specific LIMIT clause to the query + * Adds an driver-specific LIMIT clause to the query. * - * @param string $query - * @param integer $limit - * @param integer $offset + * @param string $query + * @param integer|null $limit + * @param integer|null $offset * * @return string */ @@ -2698,7 +2864,7 @@ abstract class AbstractPlatform } /** - * Does the database platform support offsets in modify limit clauses? + * Whether the database platform support offsets in modify limit clauses. * * @return boolean */ @@ -2733,7 +2899,7 @@ abstract class AbstractPlatform } /** - * Maximum length of any given databse identifier, like tables or column names. + * Maximum length of any given database identifier, like tables or column names. * * @return integer */ @@ -2743,12 +2909,12 @@ abstract class AbstractPlatform } /** - * Get the insert sql for an empty insert statement + * Returns the insert SQL for an empty insert statement. * * @param string $tableName * @param string $identifierColumnName * - * @return string $sql + * @return string */ public function getEmptyIdentityInsertSQL($tableName, $identifierColumnName) { @@ -2756,13 +2922,13 @@ abstract class AbstractPlatform } /** - * Generate a Truncate Table SQL statement for a given table. + * Generates a Truncate Table SQL statement for a given table. * * Cascade is not supported on many platforms but would optionally cascade the truncate by * following the foreign keys. * - * @param string $tableName - * @param boolean $cascade + * @param string $tableName + * @param boolean $cascade * * @return string */ @@ -2782,7 +2948,7 @@ abstract class AbstractPlatform } /** - * Generate SQL to create a new savepoint + * Returns the SQL to create a new savepoint. * * @param string $savepoint * @@ -2794,7 +2960,7 @@ abstract class AbstractPlatform } /** - * Generate SQL to release a savepoint + * Returns the SQL to release a savepoint. * * @param string $savepoint * @@ -2806,7 +2972,7 @@ abstract class AbstractPlatform } /** - * Generate SQL to rollback a savepoint + * Returns the SQL to rollback a savepoint. * * @param string $savepoint * @@ -2818,13 +2984,11 @@ abstract class AbstractPlatform } /** - * Return the keyword list instance of this platform. - * - * Throws exception if no keyword list is specified. - * - * @throws DBALException + * Returns the keyword list instance of this platform. * * @return \Doctrine\DBAL\Platforms\Keywords\KeywordList + * + * @throws \Doctrine\DBAL\DBALException If no keyword list is specified. */ final public function getReservedKeywordsList() { @@ -2846,9 +3010,11 @@ abstract class AbstractPlatform } /** - * The class name of the reserved keywords list. + * Returns the class name of the reserved keywords list. * * @return string + * + * @throws \Doctrine\DBAL\DBALException If not supported on this platform. */ protected function getReservedKeywordsClass() { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php old mode 100755 new mode 100644 index 114cd7dab0..b3e6adfbc1 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\DBAL\Platforms; @@ -153,16 +153,25 @@ class DB2Platform extends AbstractPlatform return 'TIME'; } + /** + * {@inheritDoc} + */ public function getListDatabasesSQL() { throw DBALException::notSupported(__METHOD__); } + /** + * {@inheritDoc} + */ public function getListSequencesSQL($database) { throw DBALException::notSupported(__METHOD__); } + /** + * {@inheritDoc} + */ public function getListTableConstraintsSQL($table) { throw DBALException::notSupported(__METHOD__); @@ -172,8 +181,10 @@ class DB2Platform extends AbstractPlatform * This code fragment is originally from the Zend_Db_Adapter_Db2 class. * * @license New BSD License - * @param string $table + * + * @param string $table * @param string $database + * * @return string */ public function getListTableColumnsSQL($table, $database = null) @@ -192,11 +203,17 @@ class DB2Platform extends AbstractPlatform WHERE UPPER(c.tabname) = UPPER('" . $table . "') ORDER BY c.colno"; } + /** + * {@inheritDoc} + */ public function getListTablesSQL() { return "SELECT NAME FROM SYSIBM.SYSTABLES WHERE TYPE = 'T'"; } + /** + * {@inheritDoc} + */ public function getListUsersSQL() { throw DBALException::notSupported(__METHOD__); @@ -218,17 +235,26 @@ class DB2Platform extends AbstractPlatform return "SELECT NAME, COLNAMES, UNIQUERULE FROM SYSIBM.SYSINDEXES WHERE TBNAME = UPPER('" . $table . "')"; } + /** + * {@inheritDoc} + */ public function getListTableForeignKeysSQL($table) { return "SELECT TBNAME, RELNAME, REFTBNAME, DELETERULE, UPDATERULE, FKCOLNAMES, PKCOLNAMES ". "FROM SYSIBM.SYSRELS WHERE TBNAME = UPPER('".$table."')"; } + /** + * {@inheritDoc} + */ public function getCreateViewSQL($name, $sql) { return "CREATE VIEW ".$name." AS ".$sql; } + /** + * {@inheritDoc} + */ public function getDropViewSQL($name) { return "DROP VIEW ".$name; @@ -242,6 +268,9 @@ class DB2Platform extends AbstractPlatform throw DBALException::notSupported(__METHOD__); } + /** + * {@inheritDoc} + */ public function getSequenceNextValSQL($sequenceName) { throw DBALException::notSupported(__METHOD__); @@ -428,6 +457,9 @@ class DB2Platform extends AbstractPlatform return 'INSERT INTO ' . $tableName . ' (' . $identifierColumnName . ') VALUES (DEFAULT)'; } + /** + * {@inheritDoc} + */ public function getCreateTemporaryTableSnippetSQL() { return "DECLARE GLOBAL TEMPORARY TABLE"; @@ -510,6 +542,9 @@ class DB2Platform extends AbstractPlatform return strtoupper($column); } + /** + * {@inheritDoc} + */ public function getForUpdateSQL() { return ' WITH RR USE AND KEEP UPDATE LOCKS'; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php old mode 100755 new mode 100644 index 47bb364efd..1ab71bd2d3 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php @@ -19,10 +19,10 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\DBALException, - Doctrine\DBAL\Schema\TableDiff, - Doctrine\DBAL\Schema\Index, - Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\Table; /** * Drizzle platform @@ -47,10 +47,10 @@ class DrizzlePlatform extends AbstractPlatform return '`'; } - /** * {@inheritDoc} - */ public function getConcatExpression() + */ + public function getConcatExpression() { $args = func_get_args(); @@ -202,6 +202,9 @@ class DrizzlePlatform extends AbstractPlatform return 'DROP DATABASE ' . $name; } + /** + * {@inheritDoc} + */ public function getListDatabasesSQL() { return "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE CATALOG_NAME='LOCAL'"; @@ -215,11 +218,17 @@ class DrizzlePlatform extends AbstractPlatform return 'Doctrine\DBAL\Platforms\Keywords\DrizzleKeywords'; } + /** + * {@inheritDoc} + */ public function getListTablesSQL() { return "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE' AND TABLE_SCHEMA=DATABASE()"; } + /** + * {@inheritDoc} + */ public function getListTableColumnsSQL($table, $database = null) { if ($database) { @@ -234,6 +243,9 @@ class DrizzlePlatform extends AbstractPlatform " WHERE TABLE_SCHEMA=" . $database . " AND TABLE_NAME = '" . $table . "'"; } + /** + * {@inheritDoc} + */ public function getListTableForeignKeysSQL($table, $database = null) { if ($database) { @@ -324,10 +336,7 @@ class DrizzlePlatform extends AbstractPlatform } /** - * @param Index $index - * @param Table $table - * - * @return string + * {@inheritDoc} */ protected function getDropPrimaryKeySQL($table) { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php old mode 100755 new mode 100644 index 77c1c67486..ff8aac81c6 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DB2Keywords.php @@ -17,24 +17,28 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; /** - * DB2 Keywords + * DB2 Keywords. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class DB2Keywords extends KeywordList { + /** + * {@inheritdoc} + */ public function getName() { return 'DB2'; } + /** + * {@inheritdoc} + */ protected function getKeywords() { return array( @@ -435,4 +439,3 @@ class DB2Keywords extends KeywordList ); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php old mode 100755 new mode 100644 index c6d3187b3a..b7db0fac39 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php @@ -17,21 +17,26 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; /** - * Drizzle Keywordlist + * Drizzle Keywordlist. * * @author Kim Hemsø Rasmussen */ class DrizzleKeywords extends KeywordList { + /** + * {@inheritdoc} + */ public function getName() { return 'drizzle'; } + /** + * {@inheritdoc} + */ protected function getKeywords() { return array( diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php old mode 100755 new mode 100644 index f30bb368e2..5b8d74d012 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php @@ -17,26 +17,28 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; /** * Abstract interface for a SQL reserved keyword dictionary. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ abstract class KeywordList { + /** + * @var array|null + */ private $keywords = null; /** - * Check if the given word is a keyword of this dialect/vendor platform. + * Checks if the given word is a keyword of this dialect/vendor platform. * - * @param string $word - * @return bool + * @param string $word + * + * @return boolean */ public function isKeyword($word) { @@ -47,15 +49,23 @@ abstract class KeywordList return isset($this->keywords[strtoupper($word)]); } + /** + * @return void + */ protected function initializeKeywords() { $this->keywords = array_flip(array_map('strtoupper', $this->getKeywords())); } + /** + * Returns the list of keywords. + * + * @return array + */ abstract protected function getKeywords(); /** - * Name of this keyword list. + * Returns the name of this keyword list. * * @return string */ diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php old mode 100755 new mode 100644 index 8adac11924..9c8f614993 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php @@ -23,221 +23,21 @@ namespace Doctrine\DBAL\Platforms\Keywords; /** * MsSQL Keywordlist * - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei - * @author David Coallier + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.0 + * @author Benjamin Eberlei + * @author David Coallier + * @author Steve Müller + * @deprecated Use SQLServerKeywords class instead. */ -class MsSQLKeywords extends KeywordList +class MsSQLKeywords extends SQLServerKeywords { + /** + * {@inheritdoc} + */ public function getName() { return 'MsSQL'; } - - protected function getKeywords() - { - return array( - 'ADD', - 'CURRENT_TIMESTAMP', - 'GROUP', - 'OPENQUERY', - 'SERIALIZABLE', - 'ALL', - 'CURRENT_USER', - 'HAVING', - 'OPENROWSET', - 'SESSION_USER', - 'ALTER', - 'CURSOR', - 'HOLDLOCK', - 'OPTION', - 'SET', - 'AND', - 'DATABASE', - 'IDENTITY', - 'OR', - 'SETUSER', - 'ANY', - 'DBCC', - 'IDENTITYCOL', - 'ORDER', - 'SHUTDOWN', - 'AS', - 'DEALLOCATE', - 'IDENTITY_INSERT', - 'OUTER', - 'SOME', - 'ASC', - 'DECLARE', - 'IF', - 'OVER', - 'STATISTICS', - 'AUTHORIZATION', - 'DEFAULT', - 'IN', - 'PERCENT', - 'SUM', - 'AVG', - 'DELETE', - 'INDEX', - 'PERM', - 'SYSTEM_USER', - 'BACKUP', - 'DENY', - 'INNER', - 'PERMANENT', - 'TABLE', - 'BEGIN', - 'DESC', - 'INSERT', - 'PIPE', - 'TAPE', - 'BETWEEN', - 'DISK', - 'INTERSECT', - 'PLAN', - 'TEMP', - 'BREAK', - 'DISTINCT', - 'INTO', - 'PRECISION', - 'TEMPORARY', - 'BROWSE', - 'DISTRIBUTED', - 'IS', - 'PREPARE', - 'TEXTSIZE', - 'BULK', - 'DOUBLE', - 'ISOLATION', - 'PRIMARY', - 'THEN', - 'BY', - 'DROP', - 'JOIN', - 'PRINT', - 'TO', - 'CASCADE', - 'DUMMY', - 'KEY', - 'PRIVILEGES', - 'TOP', - 'CASE', - 'DUMP', - 'KILL', - 'PROC', - 'TRAN', - 'CHECK', - 'ELSE', - 'LEFT', - 'PROCEDURE', - 'TRANSACTION', - 'CHECKPOINT', - 'END', - 'LEVEL', - 'PROCESSEXIT', - 'TRIGGER', - 'CLOSE', - 'ERRLVL', - 'LIKE', - 'PUBLIC', - 'TRUNCATE', - 'CLUSTERED', - 'ERROREXIT', - 'LINENO', - 'RAISERROR', - 'TSEQUAL', - 'COALESCE', - 'ESCAPE', - 'LOAD', - 'READ', - 'UNCOMMITTED', - 'COLUMN', - 'EXCEPT', - 'MAX', - 'READTEXT', - 'UNION', - 'COMMIT', - 'EXEC', - 'MIN', - 'RECONFIGURE', - 'UNIQUE', - 'COMMITTED', - 'EXECUTE', - 'MIRROREXIT', - 'REFERENCES', - 'UPDATE', - 'COMPUTE', - 'EXISTS', - 'NATIONAL', - 'REPEATABLE', - 'UPDATETEXT', - 'CONFIRM', - 'EXIT', - 'NOCHECK', - 'REPLICATION', - 'USE', - 'CONSTRAINT', - 'FETCH', - 'NONCLUSTERED', - 'RESTORE', - 'USER', - 'CONTAINS', - 'FILE', - 'NOT', - 'RESTRICT', - 'VALUES', - 'CONTAINSTABLE', - 'FILLFACTOR', - 'NULL', - 'RETURN', - 'VARYING', - 'CONTINUE', - 'FLOPPY', - 'NULLIF', - 'REVOKE', - 'VIEW', - 'CONTROLROW', - 'FOR', - 'OF', - 'RIGHT', - 'WAITFOR', - 'CONVERT', - 'FOREIGN', - 'OFF', - 'ROLLBACK', - 'WHEN', - 'COUNT', - 'FREETEXT', - 'OFFSETS', - 'ROWCOUNT', - 'WHERE', - 'CREATE', - 'FREETEXTTABLE', - 'ON', - 'ROWGUIDCOL', - 'WHILE', - 'CROSS', - 'FROM', - 'ONCE', - 'RULE', - 'WITH', - 'CURRENT', - 'FULL', - 'ONLY', - 'SAVE', - 'WORK', - 'CURRENT_DATE', - 'GOTO', - 'OPEN', - 'SCHEMA', - 'WRITETEXT', - 'CURRENT_TIME', - 'GRANT', - 'OPENDATASOURCE', - 'SELECT', - ); - } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php old mode 100755 new mode 100644 index c4ad5d684f..ba257741bf --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/MySQLKeywords.php @@ -17,25 +17,29 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; /** - * MySQL Keywordlist + * MySQL Keywordlist. * - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei - * @author David Coallier + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author David Coallier */ class MySQLKeywords extends KeywordList { + /** + * {@inheritdoc} + */ public function getName() { return 'MySQL'; } + /** + * {@inheritdoc} + */ protected function getKeywords() { return array( diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php old mode 100755 new mode 100644 index 9f34ba64a7..b37fdad3de --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/OracleKeywords.php @@ -17,25 +17,29 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; /** - * Oracle Keywordlist + * Oracle Keywordlist. * - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei - * @author David Coallier + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author David Coallier */ class OracleKeywords extends KeywordList { + /** + * {@inheritdoc} + */ public function getName() { return 'Oracle'; } + /** + * {@inheritdoc} + */ protected function getKeywords() { return array( diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php old mode 100755 new mode 100644 index 7950f6a7ec..9e49d7f250 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQLKeywords.php @@ -17,25 +17,29 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; /** - * PostgreSQL Keywordlist + * PostgreSQL Keywordlist. * - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei - * @author Marcelo Santos Araujo + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Marcelo Santos Araujo */ class PostgreSQLKeywords extends KeywordList { + /** + * {@inheritdoc} + */ public function getName() { return 'PostgreSQL'; } + /** + * {@inheritdoc} + */ protected function getKeywords() { return array( diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php old mode 100755 new mode 100644 index a61922bfcf..248f26b134 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php @@ -17,7 +17,6 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; use Doctrine\DBAL\Schema\Visitor\Visitor; @@ -40,11 +39,17 @@ class ReservedKeywordsValidator implements Visitor */ private $violations = array(); + /** + * @param \Doctrine\DBAL\Platforms\Keywords\KeywordList[] $keywordLists + */ public function __construct(array $keywordLists) { $this->keywordLists = $keywordLists; } + /** + * @return array + */ public function getViolations() { return $this->violations; @@ -52,6 +57,7 @@ class ReservedKeywordsValidator implements Visitor /** * @param string $word + * * @return array */ private function isReservedWord($word) @@ -69,6 +75,12 @@ class ReservedKeywordsValidator implements Visitor return $keywordLists; } + /** + * @param string $asset + * @param array $violatedPlatforms + * + * @return void + */ private function addViolation($asset, $violatedPlatforms) { if ( ! $violatedPlatforms) { @@ -78,6 +90,9 @@ class ReservedKeywordsValidator implements Visitor $this->violations[] = $asset . ' keyword violations: ' . implode(', ', $violatedPlatforms); } + /** + * {@inheritdoc} + */ public function acceptColumn(Table $table, Column $column) { $this->addViolation( @@ -86,26 +101,37 @@ class ReservedKeywordsValidator implements Visitor ); } + /** + * {@inheritdoc} + */ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) { - } + /** + * {@inheritdoc} + */ public function acceptIndex(Table $table, Index $index) { - } + /** + * {@inheritdoc} + */ public function acceptSchema(Schema $schema) { - } + /** + * {@inheritdoc} + */ public function acceptSequence(Sequence $sequence) { - } + /** + * {@inheritdoc} + */ public function acceptTable(Table $table) { $this->addViolation( diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php old mode 100755 new mode 100644 similarity index 52% rename from vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyException.php rename to vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php index 4e26d86627..3a7434910f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2005Keywords.php @@ -17,36 +17,40 @@ * . */ -namespace Doctrine\ORM\Proxy; +namespace Doctrine\DBAL\Platforms\Keywords; /** - * ORM Proxy Exception + * Microsoft SQL Server 2005 reserved keyword dictionary. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 1.0 - * @author Benjamin Eberlei + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.3 + * @author Steve Müller */ -class ProxyException extends \Doctrine\ORM\ORMException { - - public static function proxyDirectoryRequired() { - return new self("You must configure a proxy directory. See docs for details"); - } - - public static function proxyDirectoryNotWritable() { - return new self("Your proxy directory must be writable."); - } - - public static function proxyNamespaceRequired() { - return new self("You must configure a proxy namespace. See docs for details"); - } - - public static function notProxyClass($className, $proxyNamespace) +class SQLServer2005Keywords extends SQLServerKeywords +{ + /** + * {@inheritdoc} + */ + public function getName() { - return new self(sprintf( - "The class %s is not part of the proxy namespace %s", - $className, $proxyNamespace + return 'SQLServer2005'; + } + + /** + * {@inheritdoc} + * + * @link http://msdn.microsoft.com/en-US/library/ms189822%28v=sql.90%29.aspx + */ + protected function getKeywords() + { + return array_merge(array_diff(parent::getKeywords(), array('DUMMY')), array( + 'EXTERNAL', + 'PIVOT', + 'REVERT', + 'SECURITYAUDIT', + 'TABLESAMPLE', + 'UNPIVOT' )); } - } diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php old mode 100755 new mode 100644 similarity index 58% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php rename to vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php index 12b27eed37..38556b5055 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2008Keywords.php @@ -13,52 +13,39 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ -namespace Doctrine\Tests\Models\DirectoryTree; +namespace Doctrine\DBAL\Platforms\Keywords; /** - * @MappedSuperclass + * Microsoft SQL Server 2008 reserved keyword dictionary. + * + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.3 + * @author Steve Müller */ -abstract class AbstractContentItem +class SQLServer2008Keywords extends SQLServer2005Keywords { /** - * @Id @Column(type="integer") @GeneratedValue + * {@inheritdoc} */ - private $id; - - /** - * @ManyToOne(targetEntity="Directory") - */ - protected $parentDirectory; - - /** @column(type="string") */ - protected $name; - - public function __construct(Directory $parentDir = null) - { - $this->parentDirectory = $parentDir; - } - - public function getId() - { - return $this->id; - } - - public function setName($name) - { - $this->name = $name; - } - public function getName() { - return $this->name; + return 'SQLServer2008'; } - public function getParent() + /** + * {@inheritdoc} + * + * @link http://msdn.microsoft.com/en-us/library/ms189822%28v=sql.100%29.aspx + */ + protected function getKeywords() { - return $this->parentDirectory; + return array_merge(parent::getKeywords(), array( + 'MERGE' + )); } } diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php old mode 100755 new mode 100644 similarity index 52% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php rename to vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php index cc09c13e9b..ada1c026bd --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php @@ -1,5 +1,4 @@ . */ -namespace Doctrine\Tests\Models\DDC1476; +namespace Doctrine\DBAL\Platforms\Keywords; /** - * @Entity() + * Microsoft SQL Server 2012 reserved keyword dictionary. + * + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.3 + * @author Steve Müller */ -class DDC1476EntityWithDefaultFieldType +class SQLServer2012Keywords extends SQLServer2008Keywords { - /** - * @Id - * @Column() - * @GeneratedValue("NONE") - */ - protected $id; - - /** @column() */ - protected $name; - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * @return string + * {@inheritdoc} */ public function getName() { - return $this->name; + return 'SQLServer2012'; } /** - * @param string $name + * {@inheritdoc} + * + * @link http://msdn.microsoft.com/en-us/library/ms189822.aspx */ - public function setName($name) + protected function getKeywords() { - $this->name = $name; - } - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - $metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', + return array_merge(parent::getKeywords(), array( + 'SEMANTICKEYPHRASETABLE', + 'SEMANTICSIMILARITYDETAILSTABLE', + 'SEMANTICSIMILARITYTABLE', + 'TRY_CONVERT', + 'WITHIN GROUP' )); - $metadata->mapField(array( - 'fieldName' => 'name', - )); - - $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE); } - -} \ No newline at end of file +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php new file mode 100644 index 0000000000..fb43d2d531 --- /dev/null +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLServerKeywords.php @@ -0,0 +1,231 @@ +. + */ + +namespace Doctrine\DBAL\Platforms\Keywords; + +/** + * Microsoft SQL Server 2000 reserved keyword dictionary. + * + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link www.doctrine-project.com + * @since 2.0 + * @author Benjamin Eberlei + * @author David Coallier + * @author Steve Müller + */ +class SQLServerKeywords extends KeywordList +{ + /** + * {@inheritdoc} + */ + public function getName() + { + return 'SQLServer'; + } + + /** + * {@inheritdoc} + * + * @link http://msdn.microsoft.com/en-us/library/aa238507%28v=sql.80%29.aspx + */ + protected function getKeywords() + { + return array( + 'ADD', + 'ALL', + 'ALTER', + 'AND', + 'ANY', + 'AS', + 'ASC', + 'AUTHORIZATION', + 'BACKUP', + 'BEGIN', + 'BETWEEN', + 'BREAK', + 'BROWSE', + 'BULK', + 'BY', + 'CASCADE', + 'CASE', + 'CHECK', + 'CHECKPOINT', + 'CLOSE', + 'CLUSTERED', + 'COALESCE', + 'COLLATE', + 'COLUMN', + 'COMMIT', + 'COMPUTE', + 'CONSTRAINT', + 'CONTAINS', + 'CONTAINSTABLE', + 'CONTINUE', + 'CONVERT', + 'CREATE', + 'CROSS', + 'CURRENT', + 'CURRENT_DATE', + 'CURRENT_TIME', + 'CURRENT_TIMESTAMP', + 'CURRENT_USER', + 'CURSOR', + 'DATABASE', + 'DBCC', + 'DEALLOCATE', + 'DECLARE', + 'DEFAULT', + 'DELETE', + 'DENY', + 'DESC', + 'DISK', + 'DISTINCT', + 'DISTRIBUTED', + 'DOUBLE', + 'DROP', + 'DUMP', + 'ELSE', + 'END', + 'ERRLVL', + 'ESCAPE', + 'EXCEPT', + 'EXEC', + 'EXECUTE', + 'EXISTS', + 'EXIT', + 'EXTERNAL', + 'FETCH', + 'FILE', + 'FILLFACTOR', + 'FOR', + 'FOREIGN', + 'FREETEXT', + 'FREETEXTTABLE', + 'FROM', + 'FULL', + 'FUNCTION', + 'GOTO', + 'GRANT', + 'GROUP', + 'HAVING', + 'HOLDLOCK', + 'IDENTITY', + 'IDENTITY_INSERT', + 'IDENTITYCOL', + 'IF', + 'IN', + 'INDEX', + 'INNER', + 'INSERT', + 'INTERSECT', + 'INTO', + 'IS', + 'JOIN', + 'KEY', + 'KILL', + 'LEFT', + 'LIKE', + 'LINENO', + 'LOAD', + 'NATIONAL', + 'NOCHECK ', + 'NONCLUSTERED', + 'NOT', + 'NULL', + 'NULLIF', + 'OF', + 'OFF', + 'OFFSETS', + 'ON', + 'OPEN', + 'OPENDATASOURCE', + 'OPENQUERY', + 'OPENROWSET', + 'OPENXML', + 'OPTION', + 'OR', + 'ORDER', + 'OUTER', + 'OVER', + 'PERCENT', + 'PIVOT', + 'PLAN', + 'PRECISION', + 'PRIMARY', + 'PRINT', + 'PROC', + 'PROCEDURE', + 'PUBLIC', + 'RAISERROR', + 'READ', + 'READTEXT', + 'RECONFIGURE', + 'REFERENCES', + 'REPLICATION', + 'RESTORE', + 'RESTRICT', + 'RETURN', + 'REVERT', + 'REVOKE', + 'RIGHT', + 'ROLLBACK', + 'ROWCOUNT', + 'ROWGUIDCOL', + 'RULE', + 'SAVE', + 'SCHEMA', + 'SECURITYAUDIT', + 'SELECT', + 'SESSION_USER', + 'SET', + 'SETUSER', + 'SHUTDOWN', + 'SOME', + 'STATISTICS', + 'SYSTEM_USER', + 'TABLE', + 'TABLESAMPLE', + 'TEXTSIZE', + 'THEN', + 'TO', + 'TOP', + 'TRAN', + 'TRANSACTION', + 'TRIGGER', + 'TRUNCATE', + 'TSEQUAL', + 'UNION', + 'UNIQUE', + 'UNPIVOT', + 'UPDATE', + 'UPDATETEXT', + 'USE', + 'USER', + 'VALUES', + 'VARYING', + 'VIEW', + 'WAITFOR', + 'WHEN', + 'WHERE', + 'WHILE', + 'WITH', + 'WRITETEXT' + ); + } +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php old mode 100755 new mode 100644 index d45b994408..a162d3d539 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/SQLiteKeywords.php @@ -17,24 +17,28 @@ * . */ - namespace Doctrine\DBAL\Platforms\Keywords; /** - * SQLite Keywords + * SQLite Keywordlist. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class SQLiteKeywords extends KeywordList { + /** + * {@inheritdoc} + */ public function getName() { return 'SQLite'; } + /** + * {@inheritdoc} + */ protected function getKeywords() { return array( diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php old mode 100755 new mode 100644 index 2cf573f05e..edbc8efd06 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -19,23 +19,49 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\DBALException, - Doctrine\DBAL\Schema\TableDiff, - Doctrine\DBAL\Schema\Index, - Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\Table; /** * The MySqlPlatform provides the behavior, features and SQL dialect of the * MySQL database platform. This platform represents a MySQL 5.0 or greater platform that * uses the InnoDB storage engine. * - * @since 2.0 + * @since 2.0 * @author Roman Borschel * @author Benjamin Eberlei - * @todo Rename: MySQLPlatform + * @todo Rename: MySQLPlatform */ class MySqlPlatform extends AbstractPlatform { + const LENGTH_LIMIT_TINYTEXT = 255; + const LENGTH_LIMIT_TEXT = 65535; + const LENGTH_LIMIT_MEDIUMTEXT = 16777215; + + const LENGTH_LIMIT_TINYBLOB = 255; + const LENGTH_LIMIT_BLOB = 65535; + const LENGTH_LIMIT_MEDIUMBLOB = 16777215; + + /** + * Adds MySQL-specific LIMIT clause to the query + * 18446744073709551615 is 2^64-1 maximum of unsigned BIGINT the biggest limit possible + */ + protected function doModifyLimitQuery($query, $limit, $offset) + { + if ($limit !== null) { + $query .= ' LIMIT ' . $limit; + if ($offset !== null) { + $query .= ' OFFSET ' . $offset; + } + } elseif ($offset !== null) { + $query .= ' LIMIT 18446744073709551615 OFFSET ' . $offset; + } + + return $query; + } + /** * {@inheritDoc} */ @@ -121,11 +147,17 @@ class MySqlPlatform extends AbstractPlatform return 'DATE_SUB(' . $date . ', INTERVAL ' . $months . ' MONTH)'; } + /** + * {@inheritDoc} + */ public function getListDatabasesSQL() { return 'SHOW DATABASES'; } + /** + * {@inheritDoc} + */ public function getListTableConstraintsSQL($table) { return 'SHOW INDEX FROM ' . $table; @@ -136,10 +168,6 @@ class MySqlPlatform extends AbstractPlatform * * Two approaches to listing the table indexes. The information_schema is * preferred, because it doesn't cause problems with SQL keywords such as "order" or "table". - * - * @param string $table - * @param string $currentDatabase - * @return string */ public function getListTableIndexesSQL($table, $currentDatabase = null) { @@ -154,11 +182,17 @@ class MySqlPlatform extends AbstractPlatform return 'SHOW INDEX FROM ' . $table; } + /** + * {@inheritDoc} + */ public function getListViewsSQL($database) { return "SELECT * FROM information_schema.VIEWS WHERE TABLE_SCHEMA = '".$database."'"; } + /** + * {@inheritDoc} + */ public function getListTableForeignKeysSQL($table, $database = null) { $sql = "SELECT DISTINCT k.`CONSTRAINT_NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, ". @@ -177,11 +211,17 @@ class MySqlPlatform extends AbstractPlatform return $sql; } + /** + * {@inheritDoc} + */ public function getCreateViewSQL($name, $sql) { return 'CREATE VIEW ' . $name . ' AS ' . $sql; } + /** + * {@inheritDoc} + */ public function getDropViewSQL($name) { return 'DROP VIEW '. $name; @@ -197,21 +237,30 @@ class MySqlPlatform extends AbstractPlatform } /** - * {@inheritDoc} + * Gets the SQL snippet used to declare a CLOB column type. + * TINYTEXT : 2 ^ 8 - 1 = 255 + * TEXT : 2 ^ 16 - 1 = 65535 + * MEDIUMTEXT : 2 ^ 24 - 1 = 16777215 + * LONGTEXT : 2 ^ 32 - 1 = 4294967295 + * + * @param array $field + * + * @return string */ public function getClobTypeDeclarationSQL(array $field) { if ( ! empty($field['length']) && is_numeric($field['length'])) { $length = $field['length']; - if ($length <= 255) { + + if ($length <= static::LENGTH_LIMIT_TINYTEXT) { return 'TINYTEXT'; } - if ($length <= 65532) { + if ($length <= static::LENGTH_LIMIT_TEXT) { return 'TEXT'; } - if ($length <= 16777215) { + if ($length <= static::LENGTH_LIMIT_MEDIUMTEXT) { return 'MEDIUMTEXT'; } } @@ -301,16 +350,14 @@ class MySqlPlatform extends AbstractPlatform /** * {@inheritDoc} */ - public function getShowDatabasesSQL() - { - return 'SHOW DATABASES'; - } - public function getListTablesSQL() { return "SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'"; } + /** + * {@inheritDoc} + */ public function getListTableColumnsSQL($table, $database = null) { if ($database) { @@ -366,32 +413,14 @@ class MySqlPlatform extends AbstractPlatform } $query = 'CREATE '; + if (!empty($options['temporary'])) { $query .= 'TEMPORARY '; } + $query .= 'TABLE ' . $tableName . ' (' . $queryFields . ') '; - - if (isset($options['comment'])) { - $comment = trim($options['comment'], " '"); - - $query .= sprintf("COMMENT = '%s' ", str_replace("'", "''", $comment)); - } - - if ( ! isset($options['charset'])) { - $options['charset'] = 'utf8'; - } - - if ( ! isset($options['collate'])) { - $options['collate'] = 'utf8_unicode_ci'; - } - - $query .= 'DEFAULT CHARACTER SET ' . $options['charset']; - $query .= ' COLLATE ' . $options['collate']; - - if ( ! isset($options['engine'])) { - $options['engine'] = 'InnoDB'; - } - $query .= ' ENGINE = ' . $options['engine']; + $query .= $this->buildTableOptions($options); + $query .= $this->buildPartitionOptions($options); $sql[] = $query; @@ -404,6 +433,76 @@ class MySqlPlatform extends AbstractPlatform return $sql; } + /** + * Build SQL for table options + * + * @param array $options + * + * @return string + */ + private function buildTableOptions(array $options) + { + if (isset($options['table_options'])) { + return $options['table_options']; + } + + $tableOptions = array(); + + // Charset + if ( ! isset($options['charset'])) { + $options['charset'] = 'utf8'; + } + + $tableOptions[] = sprintf('DEFAULT CHARACTER SET %s', $options['charset']); + + // Collate + if ( ! isset($options['collate'])) { + $options['collate'] = 'utf8_unicode_ci'; + } + + $tableOptions[] = sprintf('COLLATE %s', $options['collate']); + + // Engine + if ( ! isset($options['engine'])) { + $options['engine'] = 'InnoDB'; + } + + $tableOptions[] = sprintf('ENGINE = %s', $options['engine']); + + // Auto increment + if (isset($options['auto_increment'])) { + $tableOptions[] = sprintf('AUTO_INCREMENT = %s', $options['auto_increment']); + } + + // Comment + if (isset($options['comment'])) { + $comment = trim($options['comment'], " '"); + + $tableOptions[] = sprintf("COMMENT = '%s' ", str_replace("'", "''", $comment)); + } + + // Row format + if (isset($options['row_format'])) { + $tableOptions[] = sprintf('ROW_FORMAT = %s', $options['row_format']); + } + + return implode(' ', $tableOptions); + } + + /** + * Build SQL for partition options. + * + * @param array $options + * + * @return string + */ + private function buildPartitionOptions(array $options) + { + return (isset($options['partition_options'])) + ? ' ' . $options['partition_options'] + : ''; + } + /** * {@inheritDoc} */ @@ -487,7 +586,6 @@ class MySqlPlatform extends AbstractPlatform foreach ($diff->addedIndexes as $addKey => $addIndex) { if ($remIndex->getColumns() == $addIndex->getColumns()) { - $columns = $addIndex->getColumns(); $type = ''; if ($addIndex->isUnique()) { $type = 'UNIQUE '; @@ -495,7 +593,7 @@ class MySqlPlatform extends AbstractPlatform $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', '; $query .= 'ADD ' . $type . 'INDEX ' . $addIndex->getName(); - $query .= ' (' . $this->getIndexFieldDeclarationListSQL($columns) . ')'; + $query .= ' (' . $this->getIndexFieldDeclarationListSQL($addIndex->getQuotedColumns($this)) . ')'; $sql[] = $query; @@ -713,10 +811,34 @@ class MySqlPlatform extends AbstractPlatform } /** - * {@inheritDoc} + * Gets the SQL Snippet used to declare a BLOB column type. + * TINYBLOB : 2 ^ 8 - 1 = 255 + * BLOB : 2 ^ 16 - 1 = 65535 + * MEDIUMBLOB : 2 ^ 24 - 1 = 16777215 + * LONGBLOB : 2 ^ 32 - 1 = 4294967295 + * + * @param array $field + * + * @return string */ public function getBlobTypeDeclarationSQL(array $field) { + if ( ! empty($field['length']) && is_numeric($field['length'])) { + $length = $field['length']; + + if ($length <= static::LENGTH_LIMIT_TINYBLOB) { + return 'TINYBLOB'; + } + + if ($length <= static::LENGTH_LIMIT_BLOB) { + return 'BLOB'; + } + + if ($length <= static::LENGTH_LIMIT_MEDIUMBLOB) { + return 'MEDIUMBLOB'; + } + } + return 'LONGBLOB'; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php old mode 100755 new mode 100644 index cd5c774459..eea1498c04 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -37,11 +37,11 @@ use Doctrine\DBAL\DBALException; class OraclePlatform extends AbstractPlatform { /** - * Assertion for Oracle identifiers + * Assertion for Oracle identifiers. * * @link http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm * - * @param string + * @param string $identifier * * @throws DBALException */ @@ -307,11 +307,17 @@ class OraclePlatform extends AbstractPlatform return 'CLOB'; } + /** + * {@inheritDoc} + */ public function getListDatabasesSQL() { return 'SELECT username FROM all_users'; } + /** + * {@inheritDoc} + */ public function getListSequencesSQL($database) { return "SELECT sequence_name, min_value, increment_by FROM sys.all_sequences ". @@ -367,6 +373,9 @@ class OraclePlatform extends AbstractPlatform "WHERE uind.index_name = uind_col.index_name AND uind_col.table_name = '$table' ORDER BY uind_col.column_position ASC"; } + /** + * {@inheritDoc} + */ public function getListTablesSQL() { return 'SELECT * FROM sys.user_tables'; @@ -380,19 +389,34 @@ class OraclePlatform extends AbstractPlatform return 'SELECT view_name, text FROM sys.user_views'; } + /** + * {@inheritDoc} + */ public function getCreateViewSQL($name, $sql) { return 'CREATE VIEW ' . $name . ' AS ' . $sql; } + /** + * {@inheritDoc} + */ public function getDropViewSQL($name) { return 'DROP VIEW '. $name; } + /** + * @param string $name + * @param string $table + * @param integer $start + * + * @return array + */ public function getCreateAutoincrementSql($name, $table, $start = 1) { $table = strtoupper($table); + $name = strtoupper($name); + $sql = array(); $indexName = $table . '_AI_PK'; @@ -408,7 +432,7 @@ BEGIN END IF; END;'; - $sequenceName = $table . '_SEQ'; + $sequenceName = $table . '_' . $name . '_SEQ'; $sequence = new Sequence($sequenceName, $start); $sql[] = $this->getCreateSequenceSQL($sequence); @@ -438,6 +462,11 @@ END;'; return $sql; } + /** + * @param string $table + * + * @return array + */ public function getDropAutoincrementSql($table) { $table = strtoupper($table); @@ -452,6 +481,9 @@ END;'; return $sql; } + /** + * {@inheritDoc} + */ public function getListTableForeignKeysSQL($table) { $table = strtoupper($table); @@ -476,12 +508,18 @@ LEFT JOIN user_cons_columns r_cols AND alc.table_name = '".$table."'"; } + /** + * {@inheritDoc} + */ public function getListTableConstraintsSQL($table) { $table = strtoupper($table); return 'SELECT * FROM user_constraints WHERE table_name = \'' . $table . '\''; } + /** + * {@inheritDoc} + */ public function getListTableColumnsSQL($table, $database = null) { $table = strtoupper($table); @@ -569,9 +607,21 @@ LEFT JOIN user_cons_columns r_cols } $column = $columnDiff->column; - $fields[] = $column->getQuotedName($this). ' ' . $this->getColumnDeclarationSQL('', $column->toArray()); - if ($columnDiff->hasChanged('comment') && $comment = $this->getColumnComment($column)) { - $commentsSQL[] = $this->getCommentOnColumnSQL($diff->name, $column->getName(), $comment); + $columnHasChangedComment = $columnDiff->hasChanged('comment'); + + /** + * Do not add query part if only comment has changed + */ + if ( ! ($columnHasChangedComment && count($columnDiff->changedProperties) === 1)) { + $fields[] = $column->getQuotedName($this). ' ' . $this->getColumnDeclarationSQL('', $column->toArray()); + } + + if ($columnHasChangedComment) { + $commentsSQL[] = $this->getCommentOnColumnSQL( + $diff->name, + $column->getName(), + $this->getColumnComment($column) + ); } } @@ -676,6 +726,9 @@ LEFT JOIN user_cons_columns r_cols return strtoupper($column); } + /** + * {@inheritDoc} + */ public function getCreateTemporaryTableSnippetSQL() { return "CREATE GLOBAL TEMPORARY TABLE"; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php old mode 100755 new mode 100644 index 2f907a2a8c..2e161d34c1 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -19,30 +19,47 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\Schema\TableDiff, - Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\TableDiff; /** * PostgreSqlPlatform. * - * @since 2.0 + * @since 2.0 * @author Roman Borschel * @author Lukas Smith (PEAR MDB2 library) * @author Benjamin Eberlei - * @todo Rename: PostgreSQLPlatform + * @todo Rename: PostgreSQLPlatform */ class PostgreSqlPlatform extends AbstractPlatform { + /** + * @var bool + */ + private $useBooleanTrueFalseStrings = true; + + /** + * PostgreSQL has different behavior with some drivers + * with regard to how booleans have to be handled. + * + * Enables use of 'true'/'false' or otherwise 1 and 0 instead. + * + * @param bool $flag + */ + public function setUseBooleanTrueFalseStrings($flag) + { + $this->useBooleanTrueFalseStrings = (bool)$flag; + } + /** * {@inheritDoc} */ public function getSubstringExpression($value, $from, $length = null) { if ($length === null) { - return 'SUBSTR(' . $value . ', ' . $from . ')'; + return 'SUBSTRING(' . $value . ' FROM ' . $from . ')'; } - return 'SUBSTR(' . $value . ', ' . $from . ', ' . $length . ')'; + return 'SUBSTRING(' . $value . ' FROM ' . $from . ' FOR ' . $length . ')'; } /** @@ -155,11 +172,25 @@ class PostgreSqlPlatform extends AbstractPlatform return true; } + /** + * {@inheritDoc} + */ + public function hasNativeGuidType() + { + return true; + } + + /** + * {@inheritDoc} + */ public function getListDatabasesSQL() { return 'SELECT datname FROM pg_database'; } + /** + * {@inheritDoc} + */ public function getListSequencesSQL($database) { return "SELECT @@ -170,6 +201,9 @@ class PostgreSqlPlatform extends AbstractPlatform (n.nspname NOT LIKE 'pg_%' AND n.nspname != 'information_schema')"; } + /** + * {@inheritDoc} + */ public function getListTablesSQL() { return "SELECT tablename AS table_name, schemaname AS schema_name @@ -184,6 +218,9 @@ class PostgreSqlPlatform extends AbstractPlatform return 'SELECT viewname, definition FROM pg_views'; } + /** + * {@inheritDoc} + */ public function getListTableForeignKeysSQL($table, $database = null) { return "SELECT r.conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef @@ -197,16 +234,25 @@ class PostgreSqlPlatform extends AbstractPlatform AND r.contype = 'f'"; } + /** + * {@inheritDoc} + */ public function getCreateViewSQL($name, $sql) { return 'CREATE VIEW ' . $name . ' AS ' . $sql; } + /** + * {@inheritDoc} + */ public function getDropViewSQL($name) { return 'DROP VIEW '. $name; } + /** + * {@inheritDoc} + */ public function getListTableConstraintsSQL($table) { return "SELECT @@ -261,6 +307,9 @@ class PostgreSqlPlatform extends AbstractPlatform return $whereClause; } + /** + * {@inheritDoc} + */ public function getListTableColumnsSQL($table, $database = null) { return "SELECT @@ -322,7 +371,9 @@ class PostgreSqlPlatform extends AbstractPlatform $query .= ' NOT DEFERRABLE'; } - if ($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false) { + if (($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false) + || ($foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false) + ) { $query .= ' INITIALLY DEFERRED'; } else { $query .= ' INITIALLY IMMEDIATE'; @@ -404,8 +455,12 @@ class PostgreSqlPlatform extends AbstractPlatform } } - if ($columnDiff->hasChanged('comment') && $comment = $this->getColumnComment($column)) { - $commentsSQL[] = $this->getCommentOnColumnSQL($diff->name, $column->getName(), $comment); + if ($columnDiff->hasChanged('comment')) { + $commentsSQL[] = $this->getCommentOnColumnSQL( + $diff->name, + $column->getName(), + $this->getColumnComment($column) + ); } if ($columnDiff->hasChanged('length')) { @@ -435,6 +490,16 @@ class PostgreSqlPlatform extends AbstractPlatform return array_merge($sql, $tableSql, $columnSql); } + /** + * {@inheritdoc} + */ + public function getCommentOnColumnSQL($tableName, $columnName, $comment) + { + $comment = $comment === null ? 'NULL' : "'$comment'"; + + return "COMMENT ON COLUMN $tableName.$columnName IS $comment"; + } + /** * {@inheritDoc} */ @@ -512,6 +577,10 @@ class PostgreSqlPlatform extends AbstractPlatform */ public function convertBooleans($item) { + if ( ! $this->useBooleanTrueFalseStrings) { + return parent::convertBooleans($item); + } + if (is_array($item)) { foreach ($item as $key => $value) { if (is_bool($value) || is_numeric($item)) { @@ -527,6 +596,9 @@ class PostgreSqlPlatform extends AbstractPlatform return $item; } + /** + * {@inheritDoc} + */ public function getSequenceNextValSQL($sequenceName) { return "SELECT NEXTVAL('" . $sequenceName . "')"; @@ -620,6 +692,14 @@ class PostgreSqlPlatform extends AbstractPlatform return 'TIME(0) WITHOUT TIME ZONE'; } + /** + * {@inheritDoc} + */ + public function getGuidExpression() + { + return 'UUID_GENERATE_V4()'; + } + /** * {@inheritDoc} */ @@ -720,6 +800,7 @@ class PostgreSqlPlatform extends AbstractPlatform '_varchar' => 'string', 'char' => 'string', 'bpchar' => 'string', + 'inet' => 'string', 'date' => 'date', 'datetime' => 'datetime', 'timestamp' => 'datetime', diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php old mode 100755 new mode 100644 index 238e54f4ed..71829cd0e0 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php @@ -48,4 +48,3 @@ class SQLAzurePlatform extends SQLServer2008Platform return $sql; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php old mode 100755 new mode 100644 index be3725b39c..6dc1188fad --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php @@ -20,7 +20,7 @@ namespace Doctrine\DBAL\Platforms; /** - * Platform to ensure compatibility of Doctrine with SQLServer2005 version and + * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2005 version and * higher. * * Differences to SQL Server 2008 are: @@ -50,5 +50,14 @@ class SQLServer2005Platform extends SQLServerPlatform { return 'VARCHAR(MAX)'; } -} + /** + * {@inheritdoc} + * + * Returns Microsoft SQL Server 2005 specific keywords class + */ + protected function getReservedKeywordsClass() + { + return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords'; + } +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php old mode 100755 new mode 100644 index 909ab84f83..8946854c1e --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php @@ -20,7 +20,7 @@ namespace Doctrine\DBAL\Platforms; /** - * Platform to ensure compatibility of Doctrine with SQLServer2008 version. + * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2008 version. * * Differences to SQL Server 2005 and before are that a new DATETIME2 type was * introduced that has a higher precision. @@ -97,4 +97,14 @@ class SQLServer2008Platform extends SQLServer2005Platform $this->doctrineTypeMapping['date'] = 'date'; $this->doctrineTypeMapping['time'] = 'time'; } + + /** + * {@inheritdoc} + * + * Returns Microsoft SQL Server 2008 specific keywords class + */ + protected function getReservedKeywordsClass() + { + return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords'; + } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php new file mode 100644 index 0000000000..d5c9570533 --- /dev/null +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php @@ -0,0 +1,98 @@ +. + */ + +namespace Doctrine\DBAL\Platforms; + +use Doctrine\DBAL\Schema\Sequence; + +/** + * Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2012 version. + * + * Differences to SQL Server 2008 and before are that sequences are introduced. + * + * @author Steve Müller + */ +class SQLServer2012Platform extends SQLServer2008Platform +{ + /** + * {@inheritdoc} + */ + public function getAlterSequenceSQL(Sequence $sequence) + { + return 'ALTER SEQUENCE ' . $sequence->getQuotedName($this) . + ' INCREMENT BY ' . $sequence->getAllocationSize(); + } + + /** + * {@inheritdoc} + */ + public function getCreateSequenceSQL(Sequence $sequence) + { + return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) . + ' START WITH ' . $sequence->getInitialValue() . + ' INCREMENT BY ' . $sequence->getAllocationSize() . + ' MINVALUE ' . $sequence->getInitialValue(); + } + + /** + * {@inheritdoc} + */ + public function getDropSequenceSQL($sequence) + { + if ($sequence instanceof Sequence) { + $sequence = $sequence->getQuotedName($this); + } + + return 'DROP SEQUENCE ' . $sequence; + } + + /** + * {@inheritdoc} + */ + public function getListSequencesSQL($database) + { + return 'SELECT seq.name, seq.increment, seq.start_value FROM sys.sequences AS seq'; + } + + /** + * {@inheritdoc} + */ + public function getSequenceNextValSQL($sequenceName) + { + return 'SELECT NEXT VALUE FOR ' . $sequenceName; + } + + /** + * {@inheritdoc} + */ + public function supportsSequences() + { + return true; + } + + /** + * {@inheritdoc} + * + * Returns Microsoft SQL Server 2012 specific keywords class + */ + protected function getReservedKeywordsClass() + { + return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords'; + } +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php old mode 100755 new mode 100644 index c0b31c76bf..c9af278c75 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -1,5 +1,4 @@ * @author Jonathan H. Wage * @author Benjamin Eberlei + * @author Steve Müller */ class SQLServerPlatform extends AbstractPlatform { @@ -80,8 +81,8 @@ class SQLServerPlatform extends AbstractPlatform /** * {@inheritDoc} * - * MsSql prefers "autoincrement" identity columns since sequences can only - * be emulated with a table. + * Microsoft SQL Server prefers "autoincrement" identity columns + * since sequences can only be emulated with a table. */ public function prefersIdentityColumns() { @@ -91,7 +92,7 @@ class SQLServerPlatform extends AbstractPlatform /** * {@inheritDoc} * - * MsSql supports this through AUTO_INCREMENT columns. + * Microsoft SQL Server supports this through AUTO_INCREMENT columns. */ public function supportsIdentityColumns() { @@ -106,6 +107,22 @@ class SQLServerPlatform extends AbstractPlatform return false; } + /** + * {@inheritdoc} + */ + public function supportsSchemas() + { + return true; + } + + /** + * {@inheritDoc} + */ + public function hasNativeGuidType() + { + return true; + } + /** * {@inheritDoc} */ @@ -176,12 +193,22 @@ class SQLServerPlatform extends AbstractPlatform */ protected function _getCreateTableSQL($tableName, array $columns, array $options = array()) { + $defaultConstraintsSql = array(); + // @todo does other code breaks because of this? // force primary keys to be not null foreach ($columns as &$column) { if (isset($column['primary']) && $column['primary']) { $column['notnull'] = true; } + + /** + * Build default constraints SQL statements + */ + if ( ! empty($column['default']) || is_numeric($column['default'])) { + $defaultConstraintsSql[] = 'ALTER TABLE ' . $tableName . + ' ADD' . $this->getDefaultConstraintDeclarationSQL($tableName, $column); + } } $columnListSql = $this->getColumnDeclarationListSQL($columns); @@ -222,7 +249,7 @@ class SQLServerPlatform extends AbstractPlatform } } - return $sql; + return array_merge($sql, $defaultConstraintsSql); } /** @@ -234,7 +261,30 @@ class SQLServerPlatform extends AbstractPlatform if ($index->hasFlag('nonclustered')) { $flags = ' NONCLUSTERED'; } - return 'ALTER TABLE ' . $table . ' ADD PRIMARY KEY' . $flags . ' (' . $this->getIndexFieldDeclarationListSQL($index->getColumns()) . ')'; + return 'ALTER TABLE ' . $table . ' ADD PRIMARY KEY' . $flags . ' (' . $this->getIndexFieldDeclarationListSQL($index->getQuotedColumns($this)) . ')'; + } + + /** + * Returns the SQL snippet for declaring a default constraint. + * + * @param string $table Name of the table to return the default constraint declaration for. + * @param array $column Column definition. + * + * @return string + * + * @throws \InvalidArgumentException + */ + public function getDefaultConstraintDeclarationSQL($table, array $column) + { + if (empty($column['default']) && ! is_numeric($column['default'])) { + throw new \InvalidArgumentException("Incomplete column definition. 'default' required."); + } + + return + ' CONSTRAINT ' . + $this->generateDefaultConstraintName($table, $column['name']) . + $this->getDefaultValueDeclarationSQL($column) . + ' FOR ' . $column['name']; } /** @@ -285,19 +335,16 @@ class SQLServerPlatform extends AbstractPlatform /** * Extend unique key constraint with required filters * - * @param string $sql - * @param Index $index + * @param string $sql + * @param \Doctrine\DBAL\Schema\Index $index * * @return string */ private function _appendUniqueConstraintDefinition($sql, Index $index) { $fields = array(); - foreach ($index->getColumns() as $field => $definition) { - if (!is_array($definition)) { - $field = $definition; - } + foreach ($index->getQuotedColumns($this) as $field) { $fields[] = $field . ' IS NOT NULL'; } @@ -313,12 +360,19 @@ class SQLServerPlatform extends AbstractPlatform $sql = array(); $columnSql = array(); + /** @var \Doctrine\DBAL\Schema\Column $column */ foreach ($diff->addedColumns as $column) { if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { continue; } - $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray()); + $columnDef = $column->toArray(); + $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef); + + if ( ! empty($columnDef['default']) || is_numeric($columnDef['default'])) { + $columnDef['name'] = $column->getQuotedName($this); + $queryParts[] = 'ADD' . $this->getDefaultConstraintDeclarationSQL($diff->name, $columnDef); + } } foreach ($diff->removedColumns as $column) { @@ -329,15 +383,35 @@ class SQLServerPlatform extends AbstractPlatform $queryParts[] = 'DROP COLUMN ' . $column->getQuotedName($this); } + /* @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */ foreach ($diff->changedColumns as $columnDiff) { if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) { continue; } - /* @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */ + $fromColumn = $columnDiff->fromColumn; + $fromColumnDefault = isset($fromColumn) ? $fromColumn->getDefault() : null; $column = $columnDiff->column; + $columnDef = $column->toArray(); + $columnDefaultHasChanged = $columnDiff->hasChanged('default'); + + /** + * Drop existing column default constraint + * if default value has changed and another + * default constraint already exists for the column. + */ + if ($columnDefaultHasChanged && ( ! empty($fromColumnDefault) || is_numeric($fromColumnDefault))) { + $queryParts[] = 'DROP CONSTRAINT ' . + $this->generateDefaultConstraintName($diff->name, $columnDiff->oldColumnName); + } + $queryParts[] = 'ALTER COLUMN ' . - $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray()); + $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef); + + if ($columnDefaultHasChanged && (! empty($columnDef['default']) || is_numeric($columnDef['default']))) { + $columnDef['name'] = $column->getQuotedName($this); + $queryParts[] = 'ADD' . $this->getDefaultConstraintDeclarationSQL($diff->name, $columnDef); + } } foreach ($diff->renamedColumns as $oldColumnName => $column) { @@ -346,8 +420,28 @@ class SQLServerPlatform extends AbstractPlatform } $sql[] = "sp_RENAME '". $diff->name. ".". $oldColumnName . "' , '".$column->getQuotedName($this)."', 'COLUMN'"; + + $columnDef = $column->toArray(); + + /** + * Drop existing default constraint for the old column name + * if column has default value. + */ + if ( ! empty($columnDef['default']) || is_numeric($columnDef['default'])) { + $queryParts[] = 'DROP CONSTRAINT ' . + $this->generateDefaultConstraintName($diff->name, $oldColumnName); + } + $queryParts[] = 'ALTER COLUMN ' . - $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray()); + $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef); + + /** + * Readd default constraint for the new column name. + */ + if ( ! empty($columnDef['default']) || is_numeric($columnDef['default'])) { + $columnDef['name'] = $column->getQuotedName($this); + $queryParts[] = 'ADD' . $this->getDefaultConstraintDeclarationSQL($diff->name, $columnDef); + } } $tableSql = array(); @@ -364,6 +458,23 @@ class SQLServerPlatform extends AbstractPlatform if ($diff->newName !== false) { $sql[] = "sp_RENAME '" . $diff->name . "', '" . $diff->newName . "'"; + + /** + * Rename table's default constraints names + * to match the new table name. + * This is necessary to ensure that the default + * constraints can be referenced in future table + * alterations as the table name is encoded in + * default constraints' names. + */ + $sql[] = "DECLARE @sql NVARCHAR(MAX) = N''; " . + "SELECT @sql += N'EXEC sp_rename N''' + dc.name + ''', N''' " . + "+ REPLACE(dc.name, '" . $this->generateIdentifierName($diff->name) . "', " . + "'" . $this->generateIdentifierName($diff->newName) . "') + ''', ''OBJECT'';' " . + "FROM sys.default_constraints dc " . + "JOIN sys.tables tbl ON dc.parent_object_id = tbl.object_id " . + "WHERE tbl.name = '" . $diff->newName . "';" . + "EXEC sp_executesql @sql"; } return array_merge($sql, $tableSql, $columnSql); @@ -377,14 +488,6 @@ class SQLServerPlatform extends AbstractPlatform return 'INSERT INTO ' . $quotedTableName . ' DEFAULT VALUES'; } - /** - * {@inheritDoc} - */ - public function getShowDatabasesSQL() - { - return 'SHOW DATABASES'; - } - /** * {@inheritDoc} */ @@ -399,7 +502,25 @@ class SQLServerPlatform extends AbstractPlatform */ public function getListTableColumnsSQL($table, $database = null) { - return "exec sp_columns @table_name = '" . $table . "'"; + return "SELECT col.name, + type.name AS type, + col.max_length AS length, + ~col.is_nullable AS notnull, + def.definition AS [default], + col.scale, + col.precision, + col.is_identity AS autoincrement, + col.collation_name AS collation + FROM sys.columns AS col + JOIN sys.types AS type + ON col.user_type_id = type.user_type_id + JOIN sys.objects AS obj + ON col.object_id = obj.object_id + LEFT JOIN sys.default_constraints def + ON col.default_object_id = def.object_id + AND col.object_id = def.parent_object_id + WHERE obj.type = 'U' + AND obj.name = '$table'"; } /** @@ -428,7 +549,21 @@ class SQLServerPlatform extends AbstractPlatform */ public function getListTableIndexesSQL($table, $currentDatabase = null) { - return "exec sp_helpindex '" . $table . "'"; + return "SELECT idx.name AS key_name, + col.name AS column_name, + ~idx.is_unique AS non_unique, + idx.is_primary_key AS [primary], + CASE idx.type + WHEN '1' THEN 'clustered' + WHEN '2' THEN 'nonclustered' + ELSE NULL + END AS flags + FROM sys.tables AS tbl + JOIN sys.indexes AS idx ON tbl.object_id = idx.object_id + JOIN sys.index_columns AS idxcol ON idx.object_id = idxcol.object_id AND idx.index_id = idxcol.index_id + JOIN sys.columns AS col ON idxcol.object_id = col.object_id AND idxcol.column_id = col.column_id + WHERE tbl.name = '$table' + ORDER BY idx.index_id ASC, idxcol.index_column_id ASC"; } /** @@ -455,20 +590,12 @@ class SQLServerPlatform extends AbstractPlatform return 'DROP VIEW ' . $name; } - /** - * {@inheritDoc} - */ - public function getRegexpExpression() - { - return 'RLIKE'; - } - /** * {@inheritDoc} */ public function getGuidExpression() { - return 'UUID()'; + return 'NEWID()'; } /** @@ -545,6 +672,9 @@ class SQLServerPlatform extends AbstractPlatform return '(' . implode(' + ', $args) . ')'; } + /** + * {@inheritDoc} + */ public function getListDatabasesSQL() { return 'SELECT * FROM SYS.DATABASES'; @@ -668,35 +798,66 @@ class SQLServerPlatform extends AbstractPlatform /** * {@inheritDoc} - * - * @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html */ protected function doModifyLimitQuery($query, $limit, $offset = null) { - if ($limit > 0) { - if ($offset == 0) { - $query = preg_replace('/^(SELECT\s(DISTINCT\s)?)/i', '\1TOP ' . $limit . ' ', $query); - } else { - $orderby = stristr($query, 'ORDER BY'); + if ($limit === null) { + return $query; + } - if ( ! $orderby) { - $over = 'ORDER BY (SELECT 0)'; - } else { - $over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby); - } + $start = $offset + 1; + $end = $offset + $limit; + $orderBy = stristr($query, 'ORDER BY'); + $query = preg_replace('/\s+ORDER\s+BY\s+([^\)]*)/', '', $query); //Remove ORDER BY from $query + $format = 'SELECT * FROM (%s) AS doctrine_tbl WHERE doctrine_rownum BETWEEN %d AND %d'; - // Remove ORDER BY clause from $query - $query = preg_replace('/\s+ORDER BY(.*)/', '', $query); - $query = preg_replace('/\sFROM/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM", $query); + if ( ! $orderBy) { + //Replace only first occurrence of FROM with OVER to prevent changing FROM also in subqueries. + $query = preg_replace('/\sFROM\s/i', ', ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM ', $query, 1); - $start = $offset + 1; - $end = $offset + $limit; + return sprintf($format, $query, $start, $end); + } - $query = "SELECT * FROM ($query) AS doctrine_tbl WHERE doctrine_rownum BETWEEN $start AND $end"; + //Clear ORDER BY + $orderBy = preg_replace('/ORDER\s+BY\s+([^\)]*)(.*)/', '$1', $orderBy); + $orderByParts = explode(',', $orderBy); + $orderbyColumns = array(); + + //Split ORDER BY into parts + foreach ($orderByParts as &$part) { + + if (preg_match('/(([^\s]*)\.)?([^\.\s]*)\s*(ASC|DESC)?/i', trim($part), $matches)) { + $orderbyColumns[] = array( + 'column' => $matches[3], + 'hasTable' => ( ! empty($matches[2])), + 'sort' => isset($matches[4]) ? $matches[4] : null, + 'table' => empty($matches[2]) ? '[^\.\s]*' : $matches[2] + ); } } - return $query; + //Find alias for each colum used in ORDER BY + if ( ! empty($orderbyColumns)) { + foreach ($orderbyColumns as $column) { + + $pattern = sprintf('/%s\.(%s)\s*(AS)?\s*([^,\s\)]*)/i', $column['table'], $column['column']); + $overColumn = preg_match($pattern, $query, $matches) + ? ($column['hasTable'] ? $column['table'] . '.' : '') . $column['column'] + : $column['column']; + + if (isset($column['sort'])) { + $overColumn .= ' ' . $column['sort']; + } + + $overColumns[] = $overColumn; + } + } + + //Replace only first occurrence of FROM with $over to prevent changing FROM also in subqueries. + $over = 'ORDER BY ' . implode(', ', $overColumns); + $query = preg_replace('/\sFROM\s/i', ", ROW_NUMBER() OVER ($over) AS doctrine_rownum FROM ", $query, 1); + + return sprintf($format, $query, $start, $end); } /** @@ -845,16 +1006,21 @@ class SQLServerPlatform extends AbstractPlatform */ public function appendLockHint($fromClause, $lockMode) { - // @todo coorect - if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) { - return $fromClause . ' WITH (tablockx)'; + switch ($lockMode) { + case LockMode::NONE: + $lockClause = ' WITH (NOLOCK)'; + break; + case LockMode::PESSIMISTIC_READ: + $lockClause = ' WITH (HOLDLOCK, ROWLOCK)'; + break; + case LockMode::PESSIMISTIC_WRITE: + $lockClause = ' WITH (UPDLOCK, ROWLOCK)'; + break; + default: + $lockClause = ''; } - if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) { - return $fromClause . ' WITH (tablockx)'; - } - - return $fromClause; + return $fromClause . $lockClause; } /** @@ -870,7 +1036,7 @@ class SQLServerPlatform extends AbstractPlatform */ protected function getReservedKeywordsClass() { - return 'Doctrine\DBAL\Platforms\Keywords\MsSQLKeywords'; + return 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords'; } /** @@ -924,4 +1090,65 @@ class SQLServerPlatform extends AbstractPlatform return " DEFAULT '" . $field['default'] . "'"; } + + /** + * {@inheritdoc} + */ + public function getColumnCollationDeclarationSQL($collation) + { + return 'COLLATE ' . $collation; + } + + /** + * {@inheritdoc} + * + * Modifies column declaration order as it differs in Microsoft SQL Server. + */ + public function getColumnDeclarationSQL($name, array $field) + { + if (isset($field['columnDefinition'])) { + $columnDef = $this->getCustomTypeDeclarationSQL($field); + } else { + $collation = (isset($field['collate']) && $field['collate']) ? + ' ' . $this->getColumnCollationDeclarationSQL($field['collate']) : ''; + + $notnull = (isset($field['notnull']) && $field['notnull']) ? ' NOT NULL' : ''; + + $unique = (isset($field['unique']) && $field['unique']) ? + ' ' . $this->getUniqueFieldDeclarationSQL() : ''; + + $check = (isset($field['check']) && $field['check']) ? + ' ' . $field['check'] : ''; + + $typeDecl = $field['type']->getSqlDeclaration($field, $this); + $columnDef = $typeDecl . $collation . $notnull . $unique . $check; + } + + return $name . ' ' . $columnDef; + } + + /** + * Returns a unique default constraint name for a table and column. + * + * @param string $table Name of the table to generate the unique default constraint name for. + * @param string $column Name of the column in the table to generate the unique default constraint name for. + * + * @return string + */ + private function generateDefaultConstraintName($table, $column) + { + return 'DF_' . $this->generateIdentifierName($table) . '_' . $this->generateIdentifierName($column); + } + + /** + * Returns a hash value for a given identifier. + * + * @param string $identifier Identifier to generate a hash value for. + * + * @return string + */ + private function generateIdentifierName($identifier) + { + return strtoupper(dechex(crc32($identifier))); + } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php old mode 100755 new mode 100644 index 6fba88d718..66221342c1 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -20,15 +20,21 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\Constraint; /** * The SqlitePlatform class describes the specifics and dialects of the SQLite * database platform. * - * @since 2.0 + * @since 2.0 * @author Roman Borschel * @author Benjamin Eberlei - * @todo Rename: SQLitePlatform + * @author Martin Hasoň + * @todo Rename: SQLitePlatform */ class SqlitePlatform extends AbstractPlatform { @@ -40,6 +46,17 @@ class SqlitePlatform extends AbstractPlatform return 'RLIKE'; } + /** + * {@inheritDoc} + */ + public function getGuidExpression() + { + return "HEX(RANDOMBLOB(4)) || '-' || HEX(RANDOMBLOB(2)) || '-4' || " + . "SUBSTR(HEX(RANDOMBLOB(2)), 2) || '-' || " + . "SUBSTR('89AB', 1 + (ABS(RANDOM()) % 4), 1) || " + . "SUBSTR(HEX(RANDOMBLOB(2)), 2) || '-' || HEX(RANDOMBLOB(6))"; + } + /** * {@inheritDoc} */ @@ -258,29 +275,59 @@ class SqlitePlatform extends AbstractPlatform return 'INTEGER'; } + /** + * {@inheritDoc} + */ + public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) + { + return parent::getForeignKeyDeclarationSQL(new ForeignKeyConstraint( + $foreignKey->getQuotedLocalColumns($this), + str_replace('.', '__', $foreignKey->getQuotedForeignTableName($this)), + $foreignKey->getQuotedForeignColumns($this), + $foreignKey->getName(), + $foreignKey->getOptions() + )); + } + /** * {@inheritDoc} */ protected function _getCreateTableSQL($name, array $columns, array $options = array()) { - $name = str_replace(".", "__", $name); + $name = str_replace('.', '__', $name); $queryFields = $this->getColumnDeclarationListSQL($columns); + if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) { + foreach ($options['uniqueConstraints'] as $name => $definition) { + $queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($name, $definition); + } + } + if (isset($options['primary']) && ! empty($options['primary'])) { $keyColumns = array_unique(array_values($options['primary'])); $queryFields.= ', PRIMARY KEY('.implode(', ', $keyColumns).')'; } + if (isset($options['foreignKeys'])) { + foreach ($options['foreignKeys'] as $foreignKey) { + $queryFields.= ', '.$this->getForeignKeyDeclarationSQL($foreignKey); + } + } + $query[] = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')'; + if (isset($options['alter']) && true === $options['alter']) { + return $query; + } + if (isset($options['indexes']) && ! empty($options['indexes'])) { - foreach ($options['indexes'] as $index => $indexDef) { + foreach ($options['indexes'] as $indexDef) { $query[] = $this->getCreateIndexSQL($indexDef, $name); } } if (isset($options['unique']) && ! empty($options['unique'])) { - foreach ($options['unique'] as $index => $indexDef) { + foreach ($options['unique'] as $indexDef) { $query[] = $this->getCreateIndexSQL($indexDef, $name); } } @@ -305,18 +352,24 @@ class SqlitePlatform extends AbstractPlatform return 'CLOB'; } + /** + * {@inheritDoc} + */ public function getListTableConstraintsSQL($table) { - $table = str_replace(".", "__", $table); + $table = str_replace('.', '__', $table); return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '$table' AND sql NOT NULL ORDER BY name"; } + /** + * {@inheritDoc} + */ public function getListTableColumnsSQL($table, $currentDatabase = null) { - $table = str_replace(".", "__", $table); + $table = str_replace('.', '__', $table); - return "PRAGMA table_info($table)"; + return "PRAGMA table_info('$table')"; } /** @@ -324,11 +377,14 @@ class SqlitePlatform extends AbstractPlatform */ public function getListTableIndexesSQL($table, $currentDatabase = null) { - $table = str_replace(".", "__", $table); + $table = str_replace('.', '__', $table); - return "PRAGMA index_list($table)"; + return "PRAGMA index_list('$table')"; } + /** + * {@inheritDoc} + */ public function getListTablesSQL() { return "SELECT name FROM sqlite_master WHERE type = 'table' AND name != 'sqlite_sequence' AND name != 'geometry_columns' AND name != 'spatial_ref_sys' " @@ -344,11 +400,17 @@ class SqlitePlatform extends AbstractPlatform return "SELECT name, sql FROM sqlite_master WHERE type='view' AND sql NOT NULL"; } + /** + * {@inheritDoc} + */ public function getCreateViewSQL($name, $sql) { return 'CREATE VIEW ' . $name . ' AS ' . $sql; } + /** + * {@inheritDoc} + */ public function getDropViewSQL($name) { return 'DROP VIEW '. $name; @@ -356,22 +418,15 @@ class SqlitePlatform extends AbstractPlatform /** * {@inheritDoc} - * - * SQLite does support foreign key constraints, but only in CREATE TABLE statements... - * This really limits their usefulness and requires SQLite specific handling, so - * we simply say that SQLite does NOT support foreign keys for now... */ - public function supportsForeignKeyConstraints() + public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey) { - return false; - } + $query = parent::getAdvancedForeignKeyOptionsSQL($foreignKey); - /** - * {@inheritDoc} - */ - public function supportsAlterTable() - { - return false; + $query .= (($foreignKey->hasOption('deferrable') && $foreignKey->getOption('deferrable') !== false) ? ' ' : ' NOT ') . 'DEFERRABLE'; + $query .= ' INITIALLY ' . (($foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false) ? 'DEFERRED' : 'IMMEDIATE'); + + return $query; } /** @@ -395,14 +450,15 @@ class SqlitePlatform extends AbstractPlatform */ public function getTruncateTableSQL($tableName, $cascade = false) { - $tableName = str_replace(".", "__", $tableName); - return 'DELETE FROM '.$tableName; + $tableName = str_replace('.', '__', $tableName); + + return 'DELETE FROM ' . $tableName; } /** - * User-defined function for Sqlite that is used with PDO::sqliteCreateFunction() + * User-defined function for Sqlite that is used with PDO::sqliteCreateFunction(). * - * @param int|float $value + * @param integer|float $value * * @return float */ @@ -412,7 +468,7 @@ class SqlitePlatform extends AbstractPlatform } /** - * User-defined function for Sqlite that implements MOD(a, b) + * User-defined function for Sqlite that implements MOD(a, b). * * @param integer $a * @param integer $b @@ -425,8 +481,8 @@ class SqlitePlatform extends AbstractPlatform } /** - * @param string $str - * @param string $substr + * @param string $str + * @param string $substr * @param integer $offset * * @return integer @@ -441,6 +497,9 @@ class SqlitePlatform extends AbstractPlatform return 0; } + /** + * {@inheritDoc} + */ public function getForUpdateSql() { return ''; @@ -496,6 +555,47 @@ class SqlitePlatform extends AbstractPlatform return 'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords'; } + /** + * {@inheritDoc} + */ + protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) + { + if ( ! $diff->fromTable instanceof Table) { + throw new DBALException('Sqlite platform requires for alter table the table diff with reference to original table schema'); + } + + $sql = array(); + foreach ($diff->fromTable->getIndexes() as $index) { + if ( ! $index->isPrimary()) { + $sql[] = $this->getDropIndexSQL($index, $diff->name); + } + } + + return $sql; + } + + /** + * {@inheritDoc} + */ + protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) + { + if ( ! $diff->fromTable instanceof Table) { + throw new DBALException('Sqlite platform requires for alter table the table diff with reference to original table schema'); + } + + $sql = array(); + $tableName = $diff->newName ?: $diff->name; + foreach ($this->getIndexesInAlteredTable($diff) as $index) { + if ($index->isPrimary()) { + continue; + } + + $sql[] = $this->getCreateIndexSQL($index, $tableName); + } + + return $sql; + } + /** * {@inheritDoc} */ @@ -509,7 +609,7 @@ class SqlitePlatform extends AbstractPlatform */ public function getTemporaryTableName($tableName) { - $tableName = str_replace(".", "__", $tableName); + $tableName = str_replace('.', '__', $tableName); return $tableName; } @@ -527,4 +627,385 @@ class SqlitePlatform extends AbstractPlatform { return true; } + + /** + * {@inheritDoc} + */ + public function supportsForeignKeyConstraints() + { + return false; + } + + /** + * {@inheritDoc} + */ + public function getCreatePrimaryKeySQL(Index $index, $table) + { + throw new DBALException('Sqlite platform does not support alter primary key.'); + } + + /** + * {@inheritdoc} + */ + public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) + { + throw new DBALException('Sqlite platform does not support alter foreign key.'); + } + + /** + * {@inheritdoc} + */ + public function getDropForeignKeySQL($foreignKey, $table) + { + throw new DBALException('Sqlite platform does not support alter foreign key.'); + } + + /** + * {@inheritDoc} + */ + public function getCreateConstraintSQL(Constraint $constraint, $table) + { + throw new DBALException('Sqlite platform does not support alter constraint.'); + } + + /** + * {@inheritDoc} + */ + public function getCreateTableSQL(Table $table, $createFlags = null) + { + $createFlags = null === $createFlags ? self::CREATE_INDEXES | self::CREATE_FOREIGNKEYS : $createFlags; + + return parent::getCreateTableSQL($table, $createFlags); + } + + /** + * {@inheritDoc} + */ + public function getListTableForeignKeysSQL($table, $database = null) + { + $table = str_replace('.', '__', $table); + + return "PRAGMA foreign_key_list('$table')"; + } + + /** + * {@inheritDoc} + */ + public function getAlterTableSQL(TableDiff $diff) + { + $sql = $this->getSimpleAlterTableSQL($diff); + if (false !== $sql) { + return $sql; + } + + $fromTable = $diff->fromTable; + if ( ! $fromTable instanceof Table) { + throw new DBALException('Sqlite platform requires for alter table the table diff with reference to original table schema'); + } + + $table = clone $fromTable; + + $columns = array(); + $oldColumnNames = array(); + $newColumnNames = array(); + $columnSql = array(); + + foreach ($table->getColumns() as $columnName => $column) { + $columnName = strtolower($columnName); + $columns[$columnName] = $column; + $oldColumnNames[$columnName] = $newColumnNames[$columnName] = $column->getQuotedName($this); + } + + foreach ($diff->removedColumns as $columnName => $column) { + if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) { + continue; + } + + $columnName = strtolower($columnName); + if (isset($columns[$columnName])) { + unset($columns[$columnName]); + unset($oldColumnNames[$columnName]); + unset($newColumnNames[$columnName]); + } + } + + foreach ($diff->renamedColumns as $oldColumnName => $column) { + if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $column, $diff, $columnSql)) { + continue; + } + + $oldColumnName = strtolower($oldColumnName); + if (isset($columns[$oldColumnName])) { + unset($columns[$oldColumnName]); + } + + $columns[strtolower($column->getName())] = $column; + + if (isset($newColumnNames[$oldColumnName])) { + $newColumnNames[$oldColumnName] = $column->getQuotedName($this); + } + } + + foreach ($diff->changedColumns as $oldColumnName => $columnDiff) { + if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) { + continue; + } + + if (isset($columns[$oldColumnName])) { + unset($columns[$oldColumnName]); + } + + $columns[strtolower($columnDiff->column->getName())] = $columnDiff->column; + + if (isset($newColumnNames[$oldColumnName])) { + $newColumnNames[$oldColumnName] = $columnDiff->column->getQuotedName($this); + } + } + + foreach ($diff->addedColumns as $columnName => $column) { + if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { + continue; + } + + $columns[strtolower($columnName)] = $column; + } + + $sql = array(); + $tableSql = array(); + if ( ! $this->onSchemaAlterTable($diff, $tableSql)) { + $dataTable = new Table('__temp__'.$table->getName()); + + $newTable = new Table($table->getName(), $columns, $this->getPrimaryIndexInAlteredTable($diff), $this->getForeignKeysInAlteredTable($diff), 0, $table->getOptions()); + $newTable->addOption('alter', true); + + $sql = $this->getPreAlterTableIndexForeignKeySQL($diff); + //$sql = array_merge($sql, $this->getCreateTableSQL($dataTable, 0)); + $sql[] = sprintf('CREATE TEMPORARY TABLE %s AS SELECT %s FROM %s', $dataTable->getQuotedName($this), implode(', ', $oldColumnNames), $table->getQuotedName($this)); + $sql[] = $this->getDropTableSQL($fromTable); + + $sql = array_merge($sql, $this->getCreateTableSQL($newTable)); + $sql[] = sprintf('INSERT INTO %s (%s) SELECT %s FROM %s', $newTable->getQuotedName($this), implode(', ', $newColumnNames), implode(', ', $oldColumnNames), $dataTable->getQuotedName($this)); + $sql[] = $this->getDropTableSQL($dataTable); + + if ($diff->newName && $diff->newName != $diff->name) { + $renamedTable = new Table($diff->newName); + $sql[] = 'ALTER TABLE '.$newTable->getQuotedName($this).' RENAME TO '.$renamedTable->getQuotedName($this); + } + + $sql = array_merge($sql, $this->getPostAlterTableIndexForeignKeySQL($diff)); + } + + return array_merge($sql, $tableSql, $columnSql); + } + + /** + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * + * @return array|bool + */ + private function getSimpleAlterTableSQL(TableDiff $diff) + { + if ( ! empty($diff->renamedColumns) || ! empty($diff->addedForeignKeys) || ! empty($diff->addedIndexes) + || ! empty($diff->changedColumns) || ! empty($diff->changedForeignKeys) || ! empty($diff->changedIndexes) + || ! empty($diff->removedColumns) || ! empty($diff->removedForeignKeys) || ! empty($diff->removedIndexes) + ) { + return false; + } + + $table = new Table($diff->name); + + $sql = array(); + $tableSql = array(); + $columnSql = array(); + + foreach ($diff->addedColumns as $column) { + if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) { + continue; + } + + $field = array_merge(array('unique' => null, 'autoincrement' => null, 'default' => null), $column->toArray()); + $type = (string) $field['type']; + switch (true) { + case isset($field['columnDefinition']) || $field['autoincrement'] || $field['unique']: + case $type == 'DateTime' && $field['default'] == $this->getCurrentTimestampSQL(): + case $type == 'Date' && $field['default'] == $this->getCurrentDateSQL(): + case $type == 'Time' && $field['default'] == $this->getCurrentTimeSQL(): + return false; + } + + $field['name'] = $column->getQuotedName($this); + if (strtolower($field['type']) == 'string' && $field['length'] === null) { + $field['length'] = 255; + } + + $sql[] = 'ALTER TABLE '.$table->getQuotedName($this).' ADD COLUMN '.$this->getColumnDeclarationSQL($field['name'], $field); + } + + if ( ! $this->onSchemaAlterTable($diff, $tableSql)) { + if ($diff->newName !== false) { + $newTable = new Table($diff->newName); + $sql[] = 'ALTER TABLE '.$table->getQuotedName($this).' RENAME TO '.$newTable->getQuotedName($this); + } + } + + return array_merge($sql, $tableSql, $columnSql); + } + + /** + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * + * @return array + */ + private function getColumnNamesInAlteredTable(TableDiff $diff) + { + $columns = array(); + + foreach ($diff->fromTable->getColumns() as $columnName => $column) { + $columns[strtolower($columnName)] = $column->getName(); + } + + foreach ($diff->removedColumns as $columnName => $column) { + $columnName = strtolower($columnName); + if (isset($columns[$columnName])) { + unset($columns[$columnName]); + } + } + + foreach ($diff->renamedColumns as $oldColumnName => $column) { + $columnName = $column->getName(); + $columns[strtolower($oldColumnName)] = $columnName; + $columns[strtolower($columnName)] = $columnName; + } + + foreach ($diff->changedColumns as $oldColumnName => $columnDiff) { + $columnName = $columnDiff->column->getName(); + $columns[strtolower($oldColumnName)] = $columnName; + $columns[strtolower($columnName)] = $columnName; + } + + foreach ($diff->addedColumns as $columnName => $column) { + $columns[strtolower($columnName)] = $columnName; + } + + return $columns; + } + + /** + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * + * @return \Doctrine\DBAL\Schema\Index[] + */ + private function getIndexesInAlteredTable(TableDiff $diff) + { + $indexes = $diff->fromTable->getIndexes(); + $columnNames = $this->getColumnNamesInAlteredTable($diff); + + foreach ($indexes as $key => $index) { + $changed = false; + $indexColumns = array(); + foreach ($index->getColumns() as $columnName) { + $normalizedColumnName = strtolower($columnName); + if ( ! isset($columnNames[$normalizedColumnName])) { + unset($indexes[$key]); + continue 2; + } else { + $indexColumns[] = $columnNames[$normalizedColumnName]; + if ($columnName !== $columnNames[$normalizedColumnName]) { + $changed = true; + } + } + } + + if ($changed) { + $indexes[$key] = new Index($index->getName(), $indexColumns, $index->isUnique(), $index->isPrimary(), $index->getFlags()); + } + } + + foreach ($diff->removedIndexes as $index) { + $indexName = strtolower($index->getName()); + if (strlen($indexName) && isset($indexes[$indexName])) { + unset($indexes[$indexName]); + } + } + + foreach (array_merge($diff->changedIndexes, $diff->addedIndexes) as $index) { + $indexName = strtolower($index->getName()); + if (strlen($indexName)) { + $indexes[$indexName] = $index; + } else { + $indexes[] = $index; + } + } + + return $indexes; + } + + /** + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * + * @return array + */ + private function getForeignKeysInAlteredTable(TableDiff $diff) + { + $foreignKeys = $diff->fromTable->getForeignKeys(); + $columnNames = $this->getColumnNamesInAlteredTable($diff); + + foreach ($foreignKeys as $key => $constraint) { + $changed = false; + $localColumns = array(); + foreach ($constraint->getLocalColumns() as $columnName) { + $normalizedColumnName = strtolower($columnName); + if ( ! isset($columnNames[$normalizedColumnName])) { + unset($foreignKeys[$key]); + continue 2; + } else { + $localColumns[] = $columnNames[$normalizedColumnName]; + if ($columnName !== $columnNames[$normalizedColumnName]) { + $changed = true; + } + } + } + + if ($changed) { + $foreignKeys[$key] = new ForeignKeyConstraint($localColumns, $constraint->getForeignTableName(), $constraint->getForeignColumns(), $constraint->getName(), $constraint->getOptions()); + } + } + + foreach ($diff->removedForeignKeys as $constraint) { + $constraintName = strtolower($constraint->getName()); + if (strlen($constraintName) && isset($foreignKeys[$constraintName])) { + unset($foreignKeys[$constraintName]); + } + } + + foreach (array_merge($diff->changedForeignKeys, $diff->addedForeignKeys) as $constraint) { + $constraintName = strtolower($constraint->getName()); + if (strlen($constraintName)) { + $foreignKeys[$constraintName] = $constraint; + } else { + $foreignKeys[] = $constraint; + } + } + + return $foreignKeys; + } + + /** + * @param \Doctrine\DBAL\Schema\TableDiff $diff + * + * @return array + */ + private function getPrimaryIndexInAlteredTable(TableDiff $diff) + { + $primaryIndex = array(); + + foreach ($this->getIndexesInAlteredTable($diff) as $index) { + if ($index->isPrimary()) { + $primaryIndex = array($index->getName() => $index); + } + } + + return $primaryIndex; + } } + diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Portability/Connection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Portability/Connection.php old mode 100755 new mode 100644 index 410fa825fd..f6a3896690 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Portability/Connection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Portability/Connection.php @@ -17,14 +17,18 @@ * . */ - namespace Doctrine\DBAL\Portability; -use Doctrine\Common\EventManager; -use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Cache\QueryCacheProfile; +/** + * Portability wrapper for a Connection. + * + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + */ class Connection extends \Doctrine\DBAL\Connection { const PORTABILITY_ALL = 255; @@ -41,15 +45,18 @@ class Connection extends \Doctrine\DBAL\Connection const PORTABILITY_SQLSRV = 13; /** - * @var int + * @var integer */ private $portability = self::PORTABILITY_NONE; /** - * @var int + * @var integer */ private $case; + /** + * {@inheritdoc} + */ public function connect() { $ret = parent::connect(); @@ -80,40 +87,59 @@ class Connection extends \Doctrine\DBAL\Connection } } } + return $ret; } + /** + * @return integer + */ public function getPortability() { return $this->portability; } + /** + * @return integer + */ public function getFetchCase() { return $this->case; } + /** + * {@inheritdoc} + */ public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null) { - return new Statement(parent::executeQuery($query, $params, $types, $qcp), $this); + $stmt = new Statement(parent::executeQuery($query, $params, $types, $qcp), $this); + $stmt->setFetchMode($this->defaultFetchMode); + + return $stmt; } /** - * Prepares an SQL statement. - * - * @param string $statement The SQL statement to prepare. - * @return \Doctrine\DBAL\Driver\Statement The prepared statement. + * {@inheritdoc} */ public function prepare($statement) { - return new Statement(parent::prepare($statement), $this); + $stmt = new Statement(parent::prepare($statement), $this); + $stmt->setFetchMode($this->defaultFetchMode); + + return $stmt; } + /** + * {@inheritdoc} + */ public function query() { $this->connect(); $stmt = call_user_func_array(array($this->_conn, 'query'), func_get_args()); - return new Statement($stmt, $this); + $stmt = new Statement($stmt, $this); + $stmt->setFetchMode($this->defaultFetchMode); + + return $stmt; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php old mode 100755 new mode 100644 index 98076bdad2..29bc8b6a4d --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php @@ -1,5 +1,4 @@ + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement { - /** - * @var int + * @var integer */ private $portability; @@ -44,20 +41,20 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement private $stmt; /** - * @var int + * @var integer */ private $case; /** - * @var int + * @var integer */ private $defaultFetchMode = PDO::FETCH_BOTH; /** - * Wraps Statement and applies portability measures + * Wraps Statement and applies portability measures. * - * @param \Doctrine\DBAL\Driver\Statement $stmt - * @param \Doctrine\DBAL\Connection $conn + * @param \Doctrine\DBAL\Driver\Statement $stmt + * @param \Doctrine\DBAL\Portability\Connection $conn */ public function __construct($stmt, Connection $conn) { @@ -66,53 +63,85 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement $this->case = $conn->getFetchCase(); } + /** + * {@inheritdoc} + */ public function bindParam($column, &$variable, $type = null,$length = null) { return $this->stmt->bindParam($column, $variable, $type); } + /** + * {@inheritdoc} + */ public function bindValue($param, $value, $type = null) { return $this->stmt->bindValue($param, $value, $type); } + /** + * {@inheritdoc} + */ public function closeCursor() { return $this->stmt->closeCursor(); } + /** + * {@inheritdoc} + */ public function columnCount() { return $this->stmt->columnCount(); } + /** + * {@inheritdoc} + */ public function errorCode() { return $this->stmt->errorCode(); } + /** + * {@inheritdoc} + */ public function errorInfo() { return $this->stmt->errorInfo(); } + /** + * {@inheritdoc} + */ public function execute($params = null) { return $this->stmt->execute($params); } + /** + * {@inheritdoc} + */ public function setFetchMode($fetchMode, $arg1 = null, $arg2 = null) { $this->defaultFetchMode = $fetchMode; - $this->stmt->setFetchMode($fetchMode, $arg1, $arg2); + + return $this->stmt->setFetchMode($fetchMode, $arg1, $arg2); } + /** + * {@inheritdoc} + */ public function getIterator() { $data = $this->fetchAll(); + return new \ArrayIterator($data); } + /** + * {@inheritdoc} + */ public function fetch($fetchMode = null) { $fetchMode = $fetchMode ?: $this->defaultFetchMode; @@ -127,6 +156,9 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement return $row; } + /** + * {@inheritdoc} + */ public function fetchAll($fetchMode = null, $columnIndex = 0) { $fetchMode = $fetchMode ?: $this->defaultFetchMode; @@ -150,6 +182,13 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement return $rows; } + /** + * @param mixed $row + * @param integer $iterateRow + * @param boolean $fixCase + * + * @return array + */ protected function fixRow($row, $iterateRow, $fixCase) { if ( ! $row) { @@ -169,9 +208,13 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement } } } + return $row; } + /** + * {@inheritdoc} + */ public function fetchColumn($columnIndex = 0) { $value = $this->stmt->fetchColumn($columnIndex); @@ -187,9 +230,11 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement return $value; } + /** + * {@inheritdoc} + */ public function rowCount() { return $this->stmt->rowCount(); } - } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php old mode 100755 new mode 100644 index 5d55b22cd8..937726f044 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php @@ -22,39 +22,42 @@ namespace Doctrine\DBAL\Query\Expression; /** * Composite expression is responsible to build a group of similar expression. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Guilherme Blanco - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.1 + * @author Guilherme Blanco + * @author Benjamin Eberlei */ class CompositeExpression implements \Countable { /** - * Constant that represents an AND composite expression + * Constant that represents an AND composite expression. */ const TYPE_AND = 'AND'; /** - * Constant that represents an OR composite expression + * Constant that represents an OR composite expression. */ const TYPE_OR = 'OR'; /** - * @var string Holds the instance type of composite expression + * The instance type of composite expression. + * + * @var string */ private $type; /** - * @var array Each expression part of the composite expression + * Each expression part of the composite expression. + * + * @var array */ private $parts = array(); /** * Constructor. * - * @param string $type Instance type of composite expression - * @param array $parts Composition of expressions to be joined on composite expression + * @param string $type Instance type of composite expression. + * @param array $parts Composition of expressions to be joined on composite expression. */ public function __construct($type, array $parts = array()) { @@ -68,7 +71,7 @@ class CompositeExpression implements \Countable * * @param array $parts * - * @return CompositeExpression + * @return \Doctrine\DBAL\Query\Expression\CompositeExpression */ public function addMultiple(array $parts = array()) { @@ -83,7 +86,8 @@ class CompositeExpression implements \Countable * Adds an expression to composite expression. * * @param mixed $part - * @return CompositeExpression + * + * @return \Doctrine\DBAL\Query\Expression\CompositeExpression */ public function add($part) { @@ -105,7 +109,7 @@ class CompositeExpression implements \Countable } /** - * Retrieve the string representation of this composite expression. + * Retrieves the string representation of this composite expression. * * @return string */ @@ -119,7 +123,7 @@ class CompositeExpression implements \Countable } /** - * Return type of this composite expression (AND/OR) + * Returns the type of this composite expression (AND/OR). * * @return string */ diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php old mode 100755 new mode 100644 index 4f50232844..5f2b3cfa65 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php @@ -24,11 +24,10 @@ use Doctrine\DBAL\Connection; /** * ExpressionBuilder class is responsible to dynamically create SQL query parts. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.1 - * @author Guilherme Blanco - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.1 + * @author Guilherme Blanco + * @author Benjamin Eberlei */ class ExpressionBuilder { @@ -40,14 +39,16 @@ class ExpressionBuilder const GTE = '>='; /** - * @var Doctrine\DBAL\Connection DBAL Connection + * The DBAL Connection. + * + * @var \Doctrine\DBAL\Connection */ - private $connection = null; + private $connection; /** * Initializes a new ExpressionBuilder. * - * @param \Doctrine\DBAL\Connection $connection DBAL Connection + * @param \Doctrine\DBAL\Connection $connection The DBAL Connection. */ public function __construct(Connection $connection) { @@ -65,7 +66,8 @@ class ExpressionBuilder * * @param mixed $x Optional clause. Defaults = null, but requires * at least one defined when converting to string. - * @return CompositeExpression + * + * @return \Doctrine\DBAL\Query\Expression\CompositeExpression */ public function andX($x = null) { @@ -83,7 +85,8 @@ class ExpressionBuilder * * @param mixed $x Optional clause. Defaults = null, but requires * at least one defined when converting to string. - * @return CompositeExpression + * + * @return \Doctrine\DBAL\Query\Expression\CompositeExpression */ public function orX($x = null) { @@ -93,9 +96,10 @@ class ExpressionBuilder /** * Creates a comparison expression. * - * @param mixed $x Left expression + * @param mixed $x The left expression. * @param string $operator One of the ExpressionBuilder::* constants. - * @param mixed $y Right expression + * @param mixed $y The right expression. + * * @return string */ public function comparison($x, $operator, $y) @@ -113,8 +117,9 @@ class ExpressionBuilder * // u.id = ? * $expr->eq('u.id', '?'); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x The left expression. + * @param mixed $y The right expression. + * * @return string */ public function eq($x, $y) @@ -131,8 +136,9 @@ class ExpressionBuilder * // u.id <> 1 * $q->where($q->expr()->neq('u.id', '1')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x The left expression. + * @param mixed $y The right expression. + * * @return string */ public function neq($x, $y) @@ -149,8 +155,9 @@ class ExpressionBuilder * // u.id < ? * $q->where($q->expr()->lt('u.id', '?')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x The left expression. + * @param mixed $y The right expression. + * * @return string */ public function lt($x, $y) @@ -167,8 +174,9 @@ class ExpressionBuilder * // u.id <= ? * $q->where($q->expr()->lte('u.id', '?')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x The left expression. + * @param mixed $y The right expression. + * * @return string */ public function lte($x, $y) @@ -185,8 +193,9 @@ class ExpressionBuilder * // u.id > ? * $q->where($q->expr()->gt('u.id', '?')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x The left expression. + * @param mixed $y The right expression. + * * @return string */ public function gt($x, $y) @@ -203,8 +212,9 @@ class ExpressionBuilder * // u.id >= ? * $q->where($q->expr()->gte('u.id', '?')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x The left expression. + * @param mixed $y The right expression. + * * @return string */ public function gte($x, $y) @@ -215,7 +225,7 @@ class ExpressionBuilder /** * Creates an IS NULL expression with the given arguments. * - * @param string $x Field in string format to be restricted by IS NULL + * @param string $x The field in string format to be restricted by IS NULL. * * @return string */ @@ -227,7 +237,7 @@ class ExpressionBuilder /** * Creates an IS NOT NULL expression with the given arguments. * - * @param string $x Field in string format to be restricted by IS NOT NULL + * @param string $x The field in string format to be restricted by IS NOT NULL. * * @return string */ @@ -240,7 +250,7 @@ class ExpressionBuilder * Creates a LIKE() comparison expression with the given arguments. * * @param string $x Field in string format to be inspected by LIKE() comparison. - * @param mixed $y Argument to be used in LIKE() comparison. + * @param mixed $y Argument to be used in LIKE() comparison. * * @return string */ @@ -248,12 +258,51 @@ class ExpressionBuilder { return $this->comparison($x, 'LIKE', $y); } + + /** + * Creates a NOT LIKE() comparison expression with the given arguments. + * + * @param string $x Field in string format to be inspected by NOT LIKE() comparison. + * @param mixed $y Argument to be used in NOT LIKE() comparison. + * + * @return string + */ + public function notLike($x, $y) + { + return $this->comparison($x, 'NOT LIKE', $y); + } + + /** + * Creates a IN () comparison expression with the given arguments. + * + * @param string $x The field in string format to be inspected by IN() comparison. + * @param array $y The array of values to be used by IN() comparison. + * + * @return string + */ + public function in($x, array $y) + { + return $this->comparison($x, 'IN', '('.implode(', ', $y).')'); + } + + /** + * Creates a NOT IN () comparison expression with the given arguments. + * + * @param string $x The field in string format to be inspected by NOT IN() comparison. + * @param array $y The array of values to be used by NOT IN() comparison. + * + * @return string + */ + public function notIn($x, array $y) + { + return $this->comparison($x, 'NOT IN', '('.implode(', ', $y).')'); + } /** * Quotes a given input parameter. * - * @param mixed $input Parameter to be quoted. - * @param string $type Type of the parameter. + * @param mixed $input The parameter to be quoted. + * @param string|null $type The type of the parameter. * * @return string */ diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php old mode 100755 new mode 100644 index 3d803d57cc..ff5682366d --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -19,8 +19,8 @@ namespace Doctrine\DBAL\Query; -use Doctrine\DBAL\Query\Expression\CompositeExpression, - Doctrine\DBAL\Connection; +use Doctrine\DBAL\Query\Expression\CompositeExpression; +use Doctrine\DBAL\Connection; /** * QueryBuilder class is responsible to dynamically create SQL queries. @@ -32,27 +32,32 @@ use Doctrine\DBAL\Query\Expression\CompositeExpression, * underlying database vendor. Limit queries and joins are NOT applied to UPDATE and DELETE statements * even if some vendors such as MySQL support it. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.1 - * @author Guilherme Blanco - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.1 + * @author Guilherme Blanco + * @author Benjamin Eberlei */ class QueryBuilder { - /* The query types. */ + /* + * The query types. + */ const SELECT = 0; const DELETE = 1; const UPDATE = 2; - /** The builder states. */ + /* + * The builder states. + */ const STATE_DIRTY = 0; const STATE_CLEAN = 1; /** - * @var Doctrine\DBAL\Connection DBAL Connection + * The DBAL Connection. + * + * @var \Doctrine\DBAL\Connection */ - private $connection = null; + private $connection; /** * @var array The array of SQL parts collected. @@ -69,51 +74,65 @@ class QueryBuilder ); /** - * @var string The complete SQL string for this query. + * The complete SQL string for this query. + * + * @var string */ private $sql; /** - * @var array The query parameters. + * The query parameters. + * + * @var array */ private $params = array(); /** - * @var array The parameter type map of this query. + * The parameter type map of this query. + * + * @var array */ private $paramTypes = array(); /** - * @var integer The type of query this is. Can be select, update or delete. + * The type of query this is. Can be select, update or delete. + * + * @var integer */ private $type = self::SELECT; /** - * @var integer The state of the query object. Can be dirty or clean. + * The state of the query object. Can be dirty or clean. + * + * @var integer */ private $state = self::STATE_CLEAN; /** - * @var integer The index of the first result to retrieve. + * The index of the first result to retrieve. + * + * @var integer */ private $firstResult = null; /** - * @var integer The maximum number of results to retrieve. + * The maximum number of results to retrieve. + * + * @var integer */ private $maxResults = null; /** - * The counter of bound parameters used with {@see bindValue) + * The counter of bound parameters used with {@see bindValue). * - * @var int + * @var integer */ private $boundCounter = 0; /** * Initializes a new QueryBuilder. * - * @param \Doctrine\DBAL\Connection $connection DBAL Connection + * @param \Doctrine\DBAL\Connection $connection The DBAL Connection. */ public function __construct(Connection $connection) { @@ -142,7 +161,7 @@ class QueryBuilder } /** - * Get the type of the currently built query. + * Gets the type of the currently built query. * * @return integer */ @@ -152,7 +171,7 @@ class QueryBuilder } /** - * Get the associated DBAL Connection for this query builder. + * Gets the associated DBAL Connection for this query builder. * * @return \Doctrine\DBAL\Connection */ @@ -162,7 +181,7 @@ class QueryBuilder } /** - * Get the state of this query builder instance. + * Gets the state of this query builder instance. * * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. */ @@ -172,7 +191,7 @@ class QueryBuilder } /** - * Execute this query using the bound parameters and their types. + * Executes this query using the bound parameters and their types. * * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate} * for insert, update and delete statements. @@ -189,7 +208,7 @@ class QueryBuilder } /** - * Get the complete SQL string formed by the current specifications of this QueryBuilder. + * Gets the complete SQL string formed by the current specifications of this QueryBuilder. * * * $qb = $em->createQueryBuilder() @@ -198,7 +217,7 @@ class QueryBuilder * echo $qb->getSQL(); // SELECT u FROM User u * * - * @return string The sql query string. + * @return string The SQL query string. */ public function getSQL() { @@ -206,8 +225,6 @@ class QueryBuilder return $this->sql; } - $sql = ''; - switch ($this->type) { case self::DELETE: $sql = $this->getSQLForDelete(); @@ -240,10 +257,11 @@ class QueryBuilder * ->setParameter(':user_id', 1); * * - * @param string|integer $key The parameter position or name. - * @param mixed $value The parameter value. - * @param string|null $type PDO::PARAM_* - * @return QueryBuilder This QueryBuilder instance. + * @param string|integer $key The parameter position or name. + * @param mixed $value The parameter value. + * @param string|null $type One of the PDO::PARAM_* constants. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function setParameter($key, $value, $type = null) { @@ -272,7 +290,8 @@ class QueryBuilder * * @param array $params The query parameters to set. * @param array $types The query parameters types to set. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function setParameters(array $params, array $types = array()) { @@ -296,6 +315,7 @@ class QueryBuilder * Gets a (previously set) query parameter of the query being constructed. * * @param mixed $key The key (index or name) of the bound parameter. + * * @return mixed The value of the bound parameter. */ public function getParameter($key) @@ -307,12 +327,14 @@ class QueryBuilder * Sets the position of the first result to retrieve (the "offset"). * * @param integer $firstResult The first result to return. + * * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function setFirstResult($firstResult) { $this->state = self::STATE_DIRTY; $this->firstResult = $firstResult; + return $this; } @@ -331,12 +353,14 @@ class QueryBuilder * Sets the maximum number of results to retrieve (the "limit"). * * @param integer $maxResults The maximum number of results to retrieve. + * * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function setMaxResults($maxResults) { $this->state = self::STATE_DIRTY; $this->maxResults = $maxResults; + return $this; } @@ -344,7 +368,7 @@ class QueryBuilder * Gets the maximum number of results the query object was set to retrieve (the "limit"). * Returns NULL if {@link setMaxResults} was not applied to this query builder. * - * @return integer Maximum number of results. + * @return integer The maximum number of results. */ public function getMaxResults() { @@ -360,6 +384,7 @@ class QueryBuilder * @param string $sqlPartName * @param string $sqlPart * @param boolean $append + * * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function add($sqlPartName, $sqlPart, $append = false) @@ -407,7 +432,8 @@ class QueryBuilder * * * @param mixed $select The selection expressions. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function select($select = null) { @@ -434,7 +460,8 @@ class QueryBuilder * * * @param mixed $select The selection expression. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function addSelect($select = null) { @@ -461,8 +488,9 @@ class QueryBuilder * * * @param string $delete The table whose rows are subject to the deletion. - * @param string $alias The table alias used in the constructed query. - * @return QueryBuilder This QueryBuilder instance. + * @param string $alias The table alias used in the constructed query. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function delete($delete = null, $alias = null) { @@ -490,8 +518,9 @@ class QueryBuilder * * * @param string $update The table whose rows are subject to the update. - * @param string $alias The table alias used in the constructed query. - * @return QueryBuilder This QueryBuilder instance. + * @param string $alias The table alias used in the constructed query. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function update($update = null, $alias = null) { @@ -508,7 +537,7 @@ class QueryBuilder } /** - * Create and add a query root corresponding to the table identified by the + * Creates and adds a query root corresponding to the table identified by the * given alias, forming a cartesian product with any existing query roots. * * @@ -517,9 +546,10 @@ class QueryBuilder * ->from('users', 'u') * * - * @param string $from The table - * @param string $alias The alias of the table - * @return QueryBuilder This QueryBuilder instance. + * @param string $from The table. + * @param string $alias The alias of the table. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function from($from, $alias) { @@ -539,11 +569,12 @@ class QueryBuilder * ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1'); * * - * @param string $fromAlias The alias that points to a from clause - * @param string $join The table name to join - * @param string $alias The alias of the join table - * @param string $condition The condition for the join - * @return QueryBuilder This QueryBuilder instance. + * @param string $fromAlias The alias that points to a from clause. + * @param string $join The table name to join. + * @param string $alias The alias of the join table. + * @param string $condition The condition for the join. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function join($fromAlias, $join, $alias, $condition = null) { @@ -560,11 +591,12 @@ class QueryBuilder * ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); * * - * @param string $fromAlias The alias that points to a from clause - * @param string $join The table name to join - * @param string $alias The alias of the join table - * @param string $condition The condition for the join - * @return QueryBuilder This QueryBuilder instance. + * @param string $fromAlias The alias that points to a from clause. + * @param string $join The table name to join. + * @param string $alias The alias of the join table. + * @param string $condition The condition for the join. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function innerJoin($fromAlias, $join, $alias, $condition = null) { @@ -588,11 +620,12 @@ class QueryBuilder * ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); * * - * @param string $fromAlias The alias that points to a from clause - * @param string $join The table name to join - * @param string $alias The alias of the join table - * @param string $condition The condition for the join - * @return QueryBuilder This QueryBuilder instance. + * @param string $fromAlias The alias that points to a from clause. + * @param string $join The table name to join. + * @param string $alias The alias of the join table. + * @param string $condition The condition for the join. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function leftJoin($fromAlias, $join, $alias, $condition = null) { @@ -616,11 +649,12 @@ class QueryBuilder * ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); * * - * @param string $fromAlias The alias that points to a from clause - * @param string $join The table name to join - * @param string $alias The alias of the join table - * @param string $condition The condition for the join - * @return QueryBuilder This QueryBuilder instance. + * @param string $fromAlias The alias that points to a from clause. + * @param string $join The table name to join. + * @param string $alias The alias of the join table. + * @param string $condition The condition for the join. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function rightJoin($fromAlias, $join, $alias, $condition = null) { @@ -644,9 +678,10 @@ class QueryBuilder * ->where('u.id = ?'); * * - * @param string $key The column to set. + * @param string $key The column to set. * @param string $value The value, expression, placeholder, etc. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function set($key, $value) { @@ -676,7 +711,8 @@ class QueryBuilder * * * @param mixed $predicates The restriction predicates. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function where($predicates) { @@ -700,7 +736,9 @@ class QueryBuilder * * * @param mixed $where The query restrictions. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. + * * @see where() */ public function andWhere($where) @@ -730,8 +768,10 @@ class QueryBuilder * ->orWhere('u.id = 2'); * * - * @param mixed $where The WHERE statement - * @return QueryBuilder $qb + * @param mixed $where The WHERE statement. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. + * * @see where() */ public function orWhere($where) @@ -761,7 +801,8 @@ class QueryBuilder * * * @param mixed $groupBy The grouping expression. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function groupBy($groupBy) { @@ -787,7 +828,8 @@ class QueryBuilder * * * @param mixed $groupBy The grouping expression. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function addGroupBy($groupBy) { @@ -805,7 +847,8 @@ class QueryBuilder * Replaces any previous having restrictions, if any. * * @param mixed $having The restriction over the groups. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function having($having) { @@ -821,7 +864,8 @@ class QueryBuilder * conjunction with any existing having restrictions. * * @param mixed $having The restriction to append. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function andHaving($having) { @@ -843,7 +887,8 @@ class QueryBuilder * disjunction with any existing having restrictions. * * @param mixed $having The restriction to add. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function orHaving($having) { @@ -864,9 +909,10 @@ class QueryBuilder * Specifies an ordering for the query results. * Replaces any previously specified orderings, if any. * - * @param string $sort The ordering expression. + * @param string $sort The ordering expression. * @param string $order The ordering direction. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function orderBy($sort, $order = null) { @@ -876,9 +922,10 @@ class QueryBuilder /** * Adds an ordering to the query results. * - * @param string $sort The ordering expression. + * @param string $sort The ordering expression. * @param string $order The ordering direction. - * @return QueryBuilder This QueryBuilder instance. + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function addOrderBy($sort, $order = null) { @@ -886,10 +933,11 @@ class QueryBuilder } /** - * Get a query part by its name. + * Gets a query part by its name. * * @param string $queryPartName - * @return mixed $queryPart + * + * @return mixed */ public function getQueryPart($queryPartName) { @@ -897,9 +945,9 @@ class QueryBuilder } /** - * Get all query parts. + * Gets all query parts. * - * @return array $sqlParts + * @return array */ public function getQueryParts() { @@ -907,10 +955,11 @@ class QueryBuilder } /** - * Reset SQL parts + * Resets SQL parts. * - * @param array $queryPartNames - * @return QueryBuilder + * @param array|null $queryPartNames + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function resetQueryParts($queryPartNames = null) { @@ -926,10 +975,11 @@ class QueryBuilder } /** - * Reset single SQL part + * Resets a single SQL part. * * @param string $queryPartName - * @return QueryBuilder + * + * @return \Doctrine\DBAL\Query\QueryBuilder This QueryBuilder instance. */ public function resetQueryPart($queryPartName) { @@ -941,42 +991,33 @@ class QueryBuilder return $this; } + /** + * @return string + * + * @throws \Doctrine\DBAL\Query\QueryException + */ private function getSQLForSelect() { $query = 'SELECT ' . implode(', ', $this->sqlParts['select']) . ' FROM '; $fromClauses = array(); - $joinsPending = true; - $joinAliases = array(); + $knownAliases = array(); // Loop through all FROM clauses foreach ($this->sqlParts['from'] as $from) { - $fromClause = $from['table'] . ' ' . $from['alias']; - - if ($joinsPending && isset($this->sqlParts['join'][$from['alias']])) { - foreach ($this->sqlParts['join'] as $joins) { - foreach ($joins as $join) { - $fromClause .= ' ' . strtoupper($join['joinType']) - . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias'] - . ' ON ' . ((string) $join['joinCondition']); - $joinAliases[$join['joinAlias']] = true; - } - } - $joinsPending = false; - } + $knownAliases[$from['alias']] = true; + $fromClause = $from['table'] . ' ' . $from['alias'] + . $this->getSQLForJoins($from['alias'], $knownAliases); $fromClauses[$from['alias']] = $fromClause; } - // loop through all JOIN clauses for validation purpose - $knownAliases = array_merge($fromClauses,$joinAliases); foreach ($this->sqlParts['join'] as $fromAlias => $joins) { if ( ! isset($knownAliases[$fromAlias]) ) { throw QueryException::unknownAlias($fromAlias, array_keys($knownAliases)); } } - $query .= implode(', ', $fromClauses) . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '') . ($this->sqlParts['groupBy'] ? ' GROUP BY ' . implode(', ', $this->sqlParts['groupBy']) : '') @@ -1028,7 +1069,7 @@ class QueryBuilder } /** - * Create a new named parameter and bind the value $value to it. + * Creates a new named parameter and bind the value $value to it. * * This method provides a shortcut for PDOStatement::bindValue * when using prepared statements. @@ -1049,9 +1090,11 @@ class QueryBuilder * * @license New BSD License * @link http://www.zetacomponents.org - * @param mixed $value - * @param mixed $type - * @param string $placeHolder the name to bind with. The string must start with a colon ':'. + * + * @param mixed $value + * @param mixed $type + * @param string $placeHolder The name to bind with. The string must start with a colon ':'. + * * @return string the placeholder name used. */ public function createNamedParameter( $value, $type = \PDO::PARAM_STR, $placeHolder = null ) @@ -1066,7 +1109,7 @@ class QueryBuilder } /** - * Create a new positional parameter and bind the given value to it. + * Creates a new positional parameter and bind the given value to it. * * Attention: If you are using positional parameters with the query builder you have * to be very careful to bind all parameters in the order they appear in the SQL @@ -1082,8 +1125,9 @@ class QueryBuilder * ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', PDO::PARAM_STR)) * * - * @param mixed $value - * @param mixed $type + * @param mixed $value + * @param integer $type + * * @return string */ public function createPositionalParameter($value, $type = \PDO::PARAM_STR) @@ -1092,4 +1136,54 @@ class QueryBuilder $this->setParameter($this->boundCounter, $value, $type); return "?"; } + + /** + * @param string $fromAlias + * @param array $knownAliases + * + * @return string + */ + private function getSQLForJoins($fromAlias, array &$knownAliases) + { + $sql = ''; + + if (isset($this->sqlParts['join'][$fromAlias])) { + foreach ($this->sqlParts['join'][$fromAlias] as $join) { + $sql .= ' ' . strtoupper($join['joinType']) + . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias'] + . ' ON ' . ((string) $join['joinCondition']); + $knownAliases[$join['joinAlias']] = true; + + $sql .= $this->getSQLForJoins($join['joinAlias'], $knownAliases); + } + } + + return $sql; + } + + /** + * Deep clone of all expression objects in the SQL parts. + * + * @return void + */ + public function __clone() + { + foreach ($this->sqlParts as $part => $elements) { + if (is_array($this->sqlParts[$part])) { + foreach ($this->sqlParts[$part] as $idx => $element) { + if (is_object($element)) { + $this->sqlParts[$part][$idx] = clone $element; + } + } + } else if (is_object($elements)) { + $this->sqlParts[$part] = clone $elements; + } + } + + foreach ($this->params as $name => $param) { + if(is_object($param)){ + $this->params[$name] = clone $param; + } + } + } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryException.php old mode 100755 new mode 100644 index e2c2b328c1..aeeaab396d --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryException.php @@ -22,13 +22,16 @@ namespace Doctrine\DBAL\Query; use Doctrine\DBAL\DBALException; /** - * Driver interface. - * Interface that all DBAL drivers must implement. - * * @since 2.1.4 */ class QueryException extends DBALException { + /** + * @param string $alias + * @param array $registeredAliases + * + * @return \Doctrine\DBAL\Query\QueryException + */ static public function unknownAlias($alias, $registeredAliases) { return new self("The given alias '" . $alias . "' is not part of " . diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/README.markdown b/vendor/doctrine/dbal/lib/Doctrine/DBAL/README.markdown old mode 100755 new mode 100644 diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php old mode 100755 new mode 100644 index 20cafa93ab..512408da30 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php @@ -17,7 +17,6 @@ * . */ - namespace Doctrine\DBAL; use Doctrine\DBAL\Connection; @@ -25,10 +24,9 @@ use Doctrine\DBAL\Connection; /** * Utility class that parses sql statements with regard to types and parameters. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class SQLParserUtils { @@ -40,13 +38,14 @@ class SQLParserUtils const ESCAPED_DOUBLE_QUOTED_TEXT = '"(?:[^"\\\\]|\\\\"|\\\\\\\\)*"'; /** - * Get an array of the placeholders in an sql statements as keys and their positions in the query string. + * Gets an array of the placeholders in an sql statements as keys and their positions in the query string. * * Returns an integer => integer pair (indexed from zero) for a positional statement * and a string => int[] pair for a named statement. * - * @param string $statement - * @param bool $isPositional + * @param string $statement + * @param boolean $isPositional + * * @return array */ static public function getPlaceholderPositions($statement, $isPositional = true) @@ -77,12 +76,13 @@ class SQLParserUtils /** * For a positional query this method can rewrite the sql statement with regard to array parameters. * - * @param string $query The SQL query to execute. - * @param array $params The parameters to bind to the query. - * @param array $types The types the previous parameters are in. + * @param string $query The SQL query to execute. + * @param array $params The parameters to bind to the query. + * @param array $types The types the previous parameters are in. + * + * @return array * * @throws SQLParserUtilsException - * @return array */ static public function expandListParameters($query, $params, $types) { @@ -137,7 +137,7 @@ class SQLParserUtils array_slice($types, $needle + 1) ); - $expandStr = implode(", ", array_fill(0, $count, "?")); + $expandStr = $count ? implode(", ", array_fill(0, $count, "?")) : 'NULL'; $query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1); $paramOffset += ($count - 1); // Grows larger by number of parameters minus the replaced needle. @@ -147,7 +147,6 @@ class SQLParserUtils return array($query, $params, $types); } - $queryOffset = 0; $typesOrd = array(); $paramsOrd = array(); @@ -167,7 +166,7 @@ class SQLParserUtils } $count = count($value); - $expandStr = $count > 0 ? implode(', ', array_fill(0, $count, '?')) : '?'; + $expandStr = $count > 0 ? implode(', ', array_fill(0, $count, '?')) : 'NULL'; foreach ($value as $val) { $paramsOrd[] = $val; @@ -212,12 +211,12 @@ class SQLParserUtils */ static private function extractParam($paramName, $paramsOrTypes, $isParam, $defaultValue = null) { - if (isset($paramsOrTypes[$paramName])) { + if (array_key_exists($paramName, $paramsOrTypes)) { return $paramsOrTypes[$paramName]; } // Hash keys can be prefixed with a colon for compatibility - if (isset($paramsOrTypes[':' . $paramName])) { + if (array_key_exists(':' . $paramName, $paramsOrTypes)) { return $paramsOrTypes[':' . $paramName]; } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtilsException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtilsException.php old mode 100755 new mode 100644 index 4a74f6cd96..6ac6e9051f --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtilsException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtilsException.php @@ -24,18 +24,28 @@ namespace Doctrine\DBAL; /** * Doctrine\DBAL\ConnectionException * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.4 - * @author Lars Strojny + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.4 + * @author Lars Strojny */ class SQLParserUtilsException extends DBALException { + /** + * @param string $paramName + * + * @return \Doctrine\DBAL\SQLParserUtilsException + */ public static function missingParam($paramName) { return new self(sprintf('Value for :%1$s not found in params array. Params array key should be "%1$s"', $paramName)); } + /** + * @param string $typeName + * + * @return \Doctrine\DBAL\SQLParserUtilsException + */ public static function missingType($typeName) { return new self(sprintf('Value for :%1$s not found in types array. Types array key should be "%1$s"', $typeName)); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractAsset.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractAsset.php old mode 100755 new mode 100644 index 17a9c0ff41..2159b029b7 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractAsset.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractAsset.php @@ -27,10 +27,9 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; * This encapsulation hack is necessary to keep a consistent state of the database schema. Say we have a list of tables * array($tableName => Table($tableName)); if you want to rename the table, you have to make sure * - * - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ abstract class AbstractAsset { @@ -42,19 +41,21 @@ abstract class AbstractAsset /** * Namespace of the asset. If none isset the default namespace is assumed. * - * @var string + * @var string|null */ - protected $_namespace; + protected $_namespace = null; /** - * @var bool + * @var boolean */ protected $_quoted = false; /** - * Set name of this asset + * Sets the name of this asset. * * @param string $name + * + * @return void */ protected function _setName($name) { @@ -74,7 +75,8 @@ abstract class AbstractAsset * Is this asset in the default namespace? * * @param string $defaultNamespaceName - * @return bool + * + * @return boolean */ public function isInDefaultNamespace($defaultNamespaceName) { @@ -82,11 +84,11 @@ abstract class AbstractAsset } /** - * Get namespace name of this asset. + * Gets the namespace name of this asset. * * If NULL is returned this means the default namespace is used. * - * @return string + * @return string|null */ public function getNamespaceName() { @@ -98,6 +100,7 @@ abstract class AbstractAsset * namespaced elements are returned as full-qualified names. * * @param string + * * @return string */ public function getShortestName($defaultNamespaceName) @@ -106,6 +109,7 @@ abstract class AbstractAsset if ($this->_namespace == $defaultNamespaceName) { $shortestName = $this->_name; } + return strtolower($shortestName); } @@ -118,6 +122,8 @@ abstract class AbstractAsset * Every non-namespaced element is prefixed with the default namespace * name which is passed as argument to this method. * + * @param string $defaultNamespaceName + * * @return string */ public function getFullQualifiedName($defaultNamespaceName) @@ -126,13 +132,14 @@ abstract class AbstractAsset if ( ! $this->_namespace) { $name = $defaultNamespaceName . "." . $name; } + return strtolower($name); } /** - * Check if this asset's name is quoted + * Checks if this asset's name is quoted. * - * @return bool + * @return boolean */ public function isQuoted() { @@ -140,10 +147,11 @@ abstract class AbstractAsset } /** - * Check if this identifier is quoted. + * Checks if this identifier is quoted. * - * @param string $identifier - * @return bool + * @param string $identifier + * + * @return boolean */ protected function isIdentifierQuoted($identifier) { @@ -153,7 +161,8 @@ abstract class AbstractAsset /** * Trim quotes from the identifier. * - * @param string $identifier + * @param string $identifier + * * @return string */ protected function trimQuotes($identifier) @@ -162,7 +171,7 @@ abstract class AbstractAsset } /** - * Return name of this schema asset. + * Returns the name of this schema asset. * * @return string */ @@ -175,10 +184,11 @@ abstract class AbstractAsset } /** - * Get the quoted representation of this asset but only if it was defined with one. Otherwise + * Gets the quoted representation of this asset but only if it was defined with one. Otherwise * return the plain unquoted value as inserted. * - * @param AbstractPlatform $platform + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return string */ public function getQuotedName(AbstractPlatform $platform) @@ -193,15 +203,16 @@ abstract class AbstractAsset } /** - * Generate an identifier from a list of column names obeying a certain string length. + * Generates an identifier from a list of column names obeying a certain string length. * * This is especially important for Oracle, since it does not allow identifiers larger than 30 chars, * however building idents automatically for foreign keys, composite keys or such can easily create * very long names. * - * @param array $columnNames - * @param string $prefix - * @param int $maxSize + * @param array $columnNames + * @param string $prefix + * @param integer $maxSize + * * @return string */ protected function _generateIdentifierName($columnNames, $prefix='', $maxSize=30) @@ -209,6 +220,7 @@ abstract class AbstractAsset $hash = implode("", array_map(function($column) { return dechex(crc32($column)); }, $columnNames)); + return substr(strtoupper($prefix . "_" . $hash), 0, $maxSize); } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php old mode 100755 new mode 100644 index 068d6b5dc6..72fb530d3b --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -30,34 +30,34 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; * Base class for schema managers. Schema managers are used to inspect and/or * modify the database schema/structure. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @author Konsta Vesterinen - * @author Lukas Smith (PEAR MDB2 library) - * @author Roman Borschel - * @author Jonathan H. Wage - * @author Benjamin Eberlei - * @since 2.0 + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Roman Borschel + * @author Jonathan H. Wage + * @author Benjamin Eberlei + * @since 2.0 */ abstract class AbstractSchemaManager { /** - * Holds instance of the Doctrine connection for this schema manager + * Holds instance of the Doctrine connection for this schema manager. * * @var \Doctrine\DBAL\Connection */ protected $_conn; /** - * Holds instance of the database platform used for this schema manager + * Holds instance of the database platform used for this schema manager. * * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ protected $_platform; /** - * Constructor. Accepts the Connection instance to manage the schema for + * Constructor. Accepts the Connection instance to manage the schema for. * - * @param \Doctrine\DBAL\Connection $conn + * @param \Doctrine\DBAL\Connection $conn + * @param \Doctrine\DBAL\Platforms\AbstractPlatform|null $platform */ public function __construct(\Doctrine\DBAL\Connection $conn, AbstractPlatform $platform = null) { @@ -66,7 +66,7 @@ abstract class AbstractSchemaManager } /** - * Return associated platform. + * Returns the associated platform. * * @return \Doctrine\DBAL\Platforms\AbstractPlatform */ @@ -76,7 +76,7 @@ abstract class AbstractSchemaManager } /** - * Try any method on the schema manager. Normally a method throws an + * Tries any method on the schema manager. Normally a method throws an * exception when your DBMS doesn't support it or if an error occurs. * This method allows you to try and method on your SchemaManager * instance and will return false if it does not work or is not supported. @@ -102,9 +102,9 @@ abstract class AbstractSchemaManager } /** - * List the available databases for this connection + * Lists the available databases for this connection. * - * @return array $databases + * @return array */ public function listDatabases() { @@ -116,9 +116,11 @@ abstract class AbstractSchemaManager } /** - * List the available sequences for this connection + * Lists the available sequences for this connection. * - * @return Sequence[] + * @param string|null $database + * + * @return \Doctrine\DBAL\Schema\Sequence[] */ public function listSequences($database = null) { @@ -133,7 +135,7 @@ abstract class AbstractSchemaManager } /** - * List the columns for a given table. + * Lists the columns for a given table. * * In contrast to other libraries and to the old version of Doctrine, * this column definition does try to contain the 'primary' field for @@ -142,9 +144,10 @@ abstract class AbstractSchemaManager * of a table. We're a RDBMS specifies more details these are held * in the platformDetails array. * - * @param string $table The name of the table. - * @param string $database - * @return Column[] + * @param string $table The name of the table. + * @param string|null $database + * + * @return \Doctrine\DBAL\Schema\Column[] */ public function listTableColumns($table, $database = null) { @@ -160,12 +163,13 @@ abstract class AbstractSchemaManager } /** - * List the indexes for a given table returning an array of Index instances. + * Lists the indexes for a given table returning an array of Index instances. * * Keys of the portable indexes list are all lower-cased. * - * @param string $table The name of the table - * @return Index[] $tableIndexes + * @param string $table The name of the table. + * + * @return \Doctrine\DBAL\Schema\Index[] */ public function listTableIndexes($table) { @@ -177,19 +181,21 @@ abstract class AbstractSchemaManager } /** - * Return true if all the given tables exist. + * Returns true if all the given tables exist. * * @param array $tableNames - * @return bool + * + * @return boolean */ public function tablesExist($tableNames) { $tableNames = array_map('strtolower', (array)$tableNames); + return count($tableNames) == count(\array_intersect($tableNames, array_map('strtolower', $this->listTableNames()))); } /** - * Return a list of all tables in the current database + * Returns a list of all tables in the current database. * * @return array */ @@ -199,14 +205,16 @@ abstract class AbstractSchemaManager $tables = $this->_conn->fetchAll($sql); $tableNames = $this->_getPortableTablesList($tables); + return $this->filterAssetNames($tableNames); } /** - * Filter asset names if they are configured to return only a subset of all + * Filters asset names if they are configured to return only a subset of all * the found elements. * * @param array $assetNames + * * @return array */ protected function filterAssetNames($assetNames) @@ -215,6 +223,7 @@ abstract class AbstractSchemaManager if ( ! $filterExpr) { return $assetNames; } + return array_values ( array_filter($assetNames, function ($assetName) use ($filterExpr) { $assetName = ($assetName instanceof AbstractAsset) ? $assetName->getName() : $assetName; @@ -223,15 +232,18 @@ abstract class AbstractSchemaManager ); } + /** + * @return string|null + */ protected function getFilterSchemaAssetsExpression() { return $this->_conn->getConfiguration()->getFilterSchemaAssetsExpression(); } /** - * List the tables for this connection + * Lists the tables for this connection. * - * @return Table[] + * @return \Doctrine\DBAL\Schema\Table[] */ public function listTables() { @@ -246,8 +258,9 @@ abstract class AbstractSchemaManager } /** - * @param string $tableName - * @return Table + * @param string $tableName + * + * @return \Doctrine\DBAL\Schema\Table */ public function listTableDetails($tableName) { @@ -262,9 +275,9 @@ abstract class AbstractSchemaManager } /** - * List the views this connection has + * Lists the views this connection has. * - * @return View[] + * @return \Doctrine\DBAL\Schema\View[] */ public function listViews() { @@ -276,10 +289,12 @@ abstract class AbstractSchemaManager } /** - * List the foreign keys for the given table + * Lists the foreign keys for the given table. * - * @param string $table The name of the table - * @return ForeignKeyConstraint[] + * @param string $table The name of the table. + * @param string|null $database + * + * @return \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ public function listTableForeignKeys($table, $database = null) { @@ -299,7 +314,9 @@ abstract class AbstractSchemaManager * * NOTE: You can not drop the database this SchemaManager is currently connected to. * - * @param string $database The name of the database to drop + * @param string $database The name of the database to drop. + * + * @return void */ public function dropDatabase($database) { @@ -307,9 +324,11 @@ abstract class AbstractSchemaManager } /** - * Drop the given table + * Drops the given table. * - * @param string $table The name of the table to drop + * @param string $table The name of the table to drop. + * + * @return void */ public function dropTable($table) { @@ -317,10 +336,12 @@ abstract class AbstractSchemaManager } /** - * Drop the index from the given table + * Drops the index from the given table. * - * @param Index|string $index The name of the index - * @param string|Table $table The name of the table + * @param \Doctrine\DBAL\Schema\Index|string $index The name of the index. + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table. + * + * @return void */ public function dropIndex($index, $table) { @@ -332,10 +353,12 @@ abstract class AbstractSchemaManager } /** - * Drop the constraint from the given table + * Drops the constraint from the given table. * - * @param Constraint $constraint - * @param string $table The name of the table + * @param \Doctrine\DBAL\Schema\Constraint $constraint + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table. + * + * @return void */ public function dropConstraint(Constraint $constraint, $table) { @@ -345,9 +368,10 @@ abstract class AbstractSchemaManager /** * Drops a foreign key from a table. * - * @param ForeignKeyConstraint|string $table The name of the table with the foreign key. - * @param Table|string $name The name of the foreign key. - * @return boolean $result + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint|string $foreignKey The name of the foreign key. + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table with the foreign key. + * + * @return void */ public function dropForeignKey($foreignKey, $table) { @@ -358,6 +382,8 @@ abstract class AbstractSchemaManager * Drops a sequence with a given name. * * @param string $name The name of the sequence to drop. + * + * @return void */ public function dropSequence($name) { @@ -365,10 +391,11 @@ abstract class AbstractSchemaManager } /** - * Drop a view + * Drops a view. * - * @param string $name The name of the view - * @return boolean $result + * @param string $name The name of the view. + * + * @return void */ public function dropView($name) { @@ -381,6 +408,8 @@ abstract class AbstractSchemaManager * Creates a new database. * * @param string $database The name of the database to create. + * + * @return void */ public function createDatabase($database) { @@ -388,10 +417,11 @@ abstract class AbstractSchemaManager } /** - * Create a new table. + * Creates a new table. * - * @param Table $table - * @param int $createFlags + * @param \Doctrine\DBAL\Schema\Table $table + * + * @return void */ public function createTable(Table $table) { @@ -400,10 +430,13 @@ abstract class AbstractSchemaManager } /** - * Create a new sequence + * Creates a new sequence. * - * @param Sequence $sequence - * @throws \Doctrine\DBAL\ConnectionException if something fails at database level + * @param \Doctrine\DBAL\Schema\Sequence $sequence + * + * @return void + * + * @throws \Doctrine\DBAL\ConnectionException If something fails at database level. */ public function createSequence($sequence) { @@ -411,10 +444,12 @@ abstract class AbstractSchemaManager } /** - * Create a constraint on a table + * Creates a constraint on a table. * - * @param Constraint $constraint - * @param string|Table $table + * @param \Doctrine\DBAL\Schema\Constraint $constraint + * @param \Doctrine\DBAL\Schema\Table|string $table + * + * @return void */ public function createConstraint(Constraint $constraint, $table) { @@ -422,10 +457,12 @@ abstract class AbstractSchemaManager } /** - * Create a new index on a table + * Creates a new index on a table. * - * @param Index $index - * @param string $table name of the table on which the index is to be created + * @param \Doctrine\DBAL\Schema\Index $index + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the index is to be created. + * + * @return void */ public function createIndex(Index $index, $table) { @@ -433,10 +470,12 @@ abstract class AbstractSchemaManager } /** - * Create a new foreign key + * Creates a new foreign key. * - * @param ForeignKeyConstraint $foreignKey ForeignKey instance - * @param string|Table $table name of the table on which the foreign key is to be created + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey The ForeignKey instance. + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the foreign key is to be created. + * + * @return void */ public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) { @@ -444,9 +483,11 @@ abstract class AbstractSchemaManager } /** - * Create a new view + * Creates a new view. * - * @param View $view + * @param \Doctrine\DBAL\Schema\View $view + * + * @return void */ public function createView(View $view) { @@ -456,12 +497,15 @@ abstract class AbstractSchemaManager /* dropAndCreate*() Methods */ /** - * Drop and create a constraint + * Drops and creates a constraint. * - * @param Constraint $constraint - * @param string $table * @see dropConstraint() * @see createConstraint() + * + * @param \Doctrine\DBAL\Schema\Constraint $constraint + * @param \Doctrine\DBAL\Schema\Table|string $table + * + * @return void */ public function dropAndCreateConstraint(Constraint $constraint, $table) { @@ -470,10 +514,12 @@ abstract class AbstractSchemaManager } /** - * Drop and create a new index on a table + * Drops and creates a new index on a table. * - * @param string|Table $table name of the table on which the index is to be created - * @param Index $index + * @param \Doctrine\DBAL\Schema\Index $index + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the index is to be created. + * + * @return void */ public function dropAndCreateIndex(Index $index, $table) { @@ -482,10 +528,12 @@ abstract class AbstractSchemaManager } /** - * Drop and create a new foreign key + * Drops and creates a new foreign key. * - * @param ForeignKeyConstraint $foreignKey associative array that defines properties of the foreign key to be created. - * @param string|Table $table name of the table on which the foreign key is to be created + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey An associative array that defines properties of the foreign key to be created. + * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the foreign key is to be created. + * + * @return void */ public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) { @@ -494,10 +542,13 @@ abstract class AbstractSchemaManager } /** - * Drop and create a new sequence + * Drops and create a new sequence. * - * @param Sequence $sequence - * @throws \Doctrine\DBAL\ConnectionException if something fails at database level + * @param \Doctrine\DBAL\Schema\Sequence $sequence + * + * @return void + * + * @throws \Doctrine\DBAL\ConnectionException If something fails at database level. */ public function dropAndCreateSequence(Sequence $sequence) { @@ -506,9 +557,11 @@ abstract class AbstractSchemaManager } /** - * Drop and create a new table. + * Drops and creates a new table. * - * @param Table $table + * @param \Doctrine\DBAL\Schema\Table $table + * + * @return void */ public function dropAndCreateTable(Table $table) { @@ -517,9 +570,11 @@ abstract class AbstractSchemaManager } /** - * Drop and creates a new database. + * Drops and creates a new database. * * @param string $database The name of the database to create. + * + * @return void */ public function dropAndCreateDatabase($database) { @@ -528,9 +583,11 @@ abstract class AbstractSchemaManager } /** - * Drop and create a new view + * Drops and creates a new view. * - * @param View $view + * @param \Doctrine\DBAL\Schema\View $view + * + * @return void */ public function dropAndCreateView(View $view) { @@ -541,9 +598,11 @@ abstract class AbstractSchemaManager /* alterTable() Methods */ /** - * Alter an existing tables schema + * Alters an existing tables schema. * - * @param TableDiff $tableDiff + * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff + * + * @return void */ public function alterTable(TableDiff $tableDiff) { @@ -556,10 +615,12 @@ abstract class AbstractSchemaManager } /** - * Rename a given table to another name + * Renames a given table to another name. * - * @param string $name The current name of the table - * @param string $newName The new name of the table + * @param string $name The current name of the table. + * @param string $newName The new name of the table. + * + * @return void */ public function renameTable($name, $newName) { @@ -573,6 +634,11 @@ abstract class AbstractSchemaManager * the native DBMS data definition to a portable Doctrine definition */ + /** + * @param array $databases + * + * @return array + */ protected function _getPortableDatabasesList($databases) { $list = array(); @@ -581,14 +647,25 @@ abstract class AbstractSchemaManager $list[] = $value; } } + return $list; } + /** + * @param array $database + * + * @return mixed + */ protected function _getPortableDatabaseDefinition($database) { return $database; } + /** + * @param array $functions + * + * @return array + */ protected function _getPortableFunctionsList($functions) { $list = array(); @@ -597,14 +674,25 @@ abstract class AbstractSchemaManager $list[] = $value; } } + return $list; } + /** + * @param array $function + * + * @return mixed + */ protected function _getPortableFunctionDefinition($function) { return $function; } + /** + * @param array $triggers + * + * @return array + */ protected function _getPortableTriggersList($triggers) { $list = array(); @@ -613,14 +701,25 @@ abstract class AbstractSchemaManager $list[] = $value; } } + return $list; } + /** + * @param array $trigger + * + * @return mixed + */ protected function _getPortableTriggerDefinition($trigger) { return $trigger; } + /** + * @param array $sequences + * + * @return array + */ protected function _getPortableSequencesList($sequences) { $list = array(); @@ -629,12 +728,16 @@ abstract class AbstractSchemaManager $list[] = $value; } } + return $list; } /** * @param array $sequence - * @return Sequence + * + * @return \Doctrine\DBAL\Schema\Sequence + * + * @throws \Doctrine\DBAL\DBALException */ protected function _getPortableSequenceDefinition($sequence) { @@ -646,9 +749,10 @@ abstract class AbstractSchemaManager * * The name of the created column instance however is kept in its case. * - * @param string $table The name of the table. - * @param string $database - * @param array $tableColumns + * @param string $table The name of the table. + * @param string $database + * @param array $tableColumns + * * @return array */ protected function _getPortableTableColumnList($table, $database, $tableColumns) @@ -677,22 +781,25 @@ abstract class AbstractSchemaManager $list[$name] = $column; } } + return $list; } /** - * Get Table Column Definition + * Gets Table Column Definition. * * @param array $tableColumn - * @return Column + * + * @return \Doctrine\DBAL\Schema\Column */ abstract protected function _getPortableTableColumnDefinition($tableColumn); /** - * Aggregate and group the index results according to the required data result. + * Aggregates and groups the index results according to the required data result. + * + * @param array $tableIndexRows + * @param string|null $tableName * - * @param array $tableIndexRows - * @param string $tableName * @return array */ protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null) @@ -745,6 +852,11 @@ abstract class AbstractSchemaManager return $indexes; } + /** + * @param array $tables + * + * @return array + */ protected function _getPortableTablesList($tables) { $list = array(); @@ -753,14 +865,25 @@ abstract class AbstractSchemaManager $list[] = $value; } } + return $list; } + /** + * @param array $table + * + * @return array + */ protected function _getPortableTableDefinition($table) { return $table; } + /** + * @param array $users + * + * @return array + */ protected function _getPortableUsersList($users) { $list = array(); @@ -769,14 +892,24 @@ abstract class AbstractSchemaManager $list[] = $value; } } + return $list; } + /** + * @param array $user + * + * @return mixed + */ protected function _getPortableUserDefinition($user) { return $user; } + /** + * @param array $views + * @return array + */ protected function _getPortableViewsList($views) { $list = array(); @@ -786,14 +919,25 @@ abstract class AbstractSchemaManager $list[$viewName] = $view; } } + return $list; } + /** + * @param array $view + * + * @return mixed + */ protected function _getPortableViewDefinition($view) { return false; } + /** + * @param array $tableForeignKeys + * + * @return array + */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { $list = array(); @@ -802,14 +946,25 @@ abstract class AbstractSchemaManager $list[] = $value; } } + return $list; } + /** + * @param array $tableForeignKey + * + * @return mixed + */ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) { return $tableForeignKey; } + /** + * @param array|string $sql + * + * @return void + */ protected function _execSql($sql) { foreach ((array) $sql as $query) { @@ -818,9 +973,9 @@ abstract class AbstractSchemaManager } /** - * Create a schema instance for the current database. + * Creates a schema instance for the current database. * - * @return Schema + * @return \Doctrine\DBAL\Schema\Schema */ public function createSchema() { @@ -834,9 +989,9 @@ abstract class AbstractSchemaManager } /** - * Create the configuration for this schema. + * Creates the configuration for this schema. * - * @return SchemaConfig + * @return \Doctrine\DBAL\Schema\SchemaConfig */ public function createSchemaConfig() { @@ -877,8 +1032,9 @@ abstract class AbstractSchemaManager * Given a table comment this method tries to extract a typehint for Doctrine Type, or returns * the type given as default. * - * @param string $comment - * @param string $currentType + * @param string $comment + * @param string $currentType + * * @return string */ public function extractDoctrineTypeFromComment($comment, $currentType) @@ -886,9 +1042,16 @@ abstract class AbstractSchemaManager if (preg_match("(\(DC2Type:([a-zA-Z0-9_]+)\))", $comment, $match)) { $currentType = $match[1]; } + return $currentType; } + /** + * @param string $comment + * @param string $type + * + * @return string + */ public function removeDoctrineTypeFromComment($comment, $type) { return str_replace('(DC2Type:'.$type.')', '', $comment); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php old mode 100755 new mode 100644 index fa6f70b333..c086c86a1e --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php @@ -19,17 +19,15 @@ namespace Doctrine\DBAL\Schema; -use \Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Schema\Visitor\Visitor; /** - * Object representation of a database column + * Object representation of a database column. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class Column extends AbstractAsset { @@ -39,42 +37,42 @@ class Column extends AbstractAsset protected $_type; /** - * @var int + * @var integer|null */ protected $_length = null; /** - * @var int + * @var integer */ protected $_precision = 10; /** - * @var int + * @var integer */ protected $_scale = 0; /** - * @var bool + * @var boolean */ protected $_unsigned = false; /** - * @var bool + * @var boolean */ protected $_fixed = false; /** - * @var bool + * @var boolean */ protected $_notnull = true; /** - * @var string + * @var string|null */ protected $_default = null; /** - * @var bool + * @var boolean */ protected $_autoincrement = false; @@ -84,12 +82,12 @@ class Column extends AbstractAsset protected $_platformOptions = array(); /** - * @var string + * @var string|null */ protected $_columnDefinition = null; /** - * @var string + * @var string|null */ protected $_comment = null; @@ -99,18 +97,11 @@ class Column extends AbstractAsset protected $_customSchemaOptions = array(); /** - * Create a new Column + * Creates a new Column. * - * @param string $columnName + * @param string $columnName * @param \Doctrine\DBAL\Types\Type $type - * @param int $length - * @param bool $notNull - * @param mixed $default - * @param bool $unsigned - * @param bool $fixed - * @param int $precision - * @param int $scale - * @param array $platformOptions + * @param array $options */ public function __construct($columnName, Type $type, array $options=array()) { @@ -121,7 +112,8 @@ class Column extends AbstractAsset /** * @param array $options - * @return Column + * + * @return \Doctrine\DBAL\Schema\Column */ public function setOptions(array $options) { @@ -131,12 +123,14 @@ class Column extends AbstractAsset $this->$method($value); } } + return $this; } /** - * @param Type $type - * @return Column + * @param \Doctrine\DBAL\Types\Type $type + * + * @return \Doctrine\DBAL\Schema\Column */ public function setType(Type $type) { @@ -145,8 +139,9 @@ class Column extends AbstractAsset } /** - * @param int $length - * @return Column + * @param integer|null $length + * + * @return \Doctrine\DBAL\Schema\Column */ public function setLength($length) { @@ -155,12 +150,14 @@ class Column extends AbstractAsset } else { $this->_length = null; } + return $this; } /** - * @param int $precision - * @return Column + * @param integer $precision + * + * @return \Doctrine\DBAL\Schema\Column */ public function setPrecision($precision) { @@ -169,12 +166,14 @@ class Column extends AbstractAsset } $this->_precision = (int)$precision; + return $this; } /** - * @param int $scale - * @return Column + * @param integer $scale + * + * @return \Doctrine\DBAL\Schema\Column */ public function setScale($scale) { @@ -183,181 +182,250 @@ class Column extends AbstractAsset } $this->_scale = (int)$scale; + return $this; } /** + * @param boolean $unsigned * - * @param bool $unsigned - * @return Column + * @return \Doctrine\DBAL\Schema\Column */ public function setUnsigned($unsigned) { $this->_unsigned = (bool)$unsigned; + return $this; } /** + * @param boolean $fixed * - * @param bool $fixed - * @return Column + * @return \Doctrine\DBAL\Schema\Column */ public function setFixed($fixed) { $this->_fixed = (bool)$fixed; + return $this; } /** - * @param bool $notnull - * @return Column + * @param boolean $notnull + * + * @return \Doctrine\DBAL\Schema\Column */ public function setNotnull($notnull) { $this->_notnull = (bool)$notnull; + return $this; } /** + * @param mixed $default * - * @param mixed $default - * @return Column + * @return \Doctrine\DBAL\Schema\Column */ public function setDefault($default) { $this->_default = $default; + return $this; } /** - * * @param array $platformOptions - * @return Column + * + * @return \Doctrine\DBAL\Schema\Column */ public function setPlatformOptions(array $platformOptions) { $this->_platformOptions = $platformOptions; + return $this; } /** + * @param string $name + * @param mixed $value * - * @param string $name - * @param mixed $value - * @return Column + * @return \Doctrine\DBAL\Schema\Column */ public function setPlatformOption($name, $value) { $this->_platformOptions[$name] = $value; + return $this; } /** + * @param string $value * - * @param string - * @return Column + * @return \Doctrine\DBAL\Schema\Column */ public function setColumnDefinition($value) { $this->_columnDefinition = $value; + return $this; } + /** + * @return \Doctrine\DBAL\Types\Type + */ public function getType() { return $this->_type; } + /** + * @return integer|null + */ public function getLength() { return $this->_length; } + /** + * @return integer + */ public function getPrecision() { return $this->_precision; } + /** + * @return integer + */ public function getScale() { return $this->_scale; } + /** + * @return boolean + */ public function getUnsigned() { return $this->_unsigned; } + /** + * @return boolean + */ public function getFixed() { return $this->_fixed; } + /** + * @return boolean + */ public function getNotnull() { return $this->_notnull; } + /** + * @return string|null + */ public function getDefault() { return $this->_default; } + /** + * @return array + */ public function getPlatformOptions() { return $this->_platformOptions; } + /** + * @param string $name + * + * @return boolean + */ public function hasPlatformOption($name) { return isset($this->_platformOptions[$name]); } + /** + * @param string $name + * + * @return mixed + */ public function getPlatformOption($name) { return $this->_platformOptions[$name]; } + /** + * @return string|null + */ public function getColumnDefinition() { return $this->_columnDefinition; } + /** + * @return boolean + */ public function getAutoincrement() { return $this->_autoincrement; } + /** + * @param boolean $flag + * + * @return \Doctrine\DBAL\Schema\Column + */ public function setAutoincrement($flag) { $this->_autoincrement = $flag; return $this; } + /** + * @param string $comment + * + * @return \Doctrine\DBAL\Schema\Column + */ public function setComment($comment) { $this->_comment = $comment; + return $this; } + /** + * @return string|null + */ public function getComment() { return $this->_comment; } /** - * @param string $name - * @param mixed $value - * @return Column + * @param string $name + * @param mixed $value + * + * @return \Doctrine\DBAL\Schema\Column */ public function setCustomSchemaOption($name, $value) { $this->_customSchemaOptions[$name] = $value; + return $this; } /** - * @param string $name + * @param string $name + * * @return boolean */ public function hasCustomSchemaOption($name) @@ -366,7 +434,8 @@ class Column extends AbstractAsset } /** - * @param string $name + * @param string $name + * * @return mixed */ public function getCustomSchemaOption($name) @@ -376,11 +445,13 @@ class Column extends AbstractAsset /** * @param array $customSchemaOptions - * @return Column + * + * @return \Doctrine\DBAL\Schema\Column */ public function setCustomSchemaOptions(array $customSchemaOptions) { $this->_customSchemaOptions = $customSchemaOptions; + return $this; } @@ -393,9 +464,9 @@ class Column extends AbstractAsset } /** - * @param Visitor $visitor + * @param \Doctrine\DBAL\Schema\Visitor\Visitor $visitor */ - public function visit(\Doctrine\DBAL\Schema\Visitor $visitor) + public function visit(Visitor $visitor) { $visitor->accept($this); } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php old mode 100755 new mode 100644 index 4fc4b9c392..18068b0a6f --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ColumnDiff.php @@ -1,7 +1,5 @@ */ class ColumnDiff { + /** + * @var string + */ public $oldColumnName; /** - * @var Column + * @var \Doctrine\DBAL\Schema\Column */ public $column; @@ -44,13 +43,30 @@ class ColumnDiff */ public $changedProperties = array(); - public function __construct($oldColumnName, Column $column, array $changedProperties = array()) + /** + * @var \Doctrine\DBAL\Schema\Column + */ + public $fromColumn; + + /** + * @param string $oldColumnName + * @param \Doctrine\DBAL\Schema\Column $column + * @param array $changedProperties + * @param \Doctrine\DBAL\Schema\Column $fromColumn + */ + public function __construct($oldColumnName, Column $column, array $changedProperties = array(), Column $fromColumn = null) { $this->oldColumnName = $oldColumnName; $this->column = $column; $this->changedProperties = $changedProperties; + $this->fromColumn = $fromColumn; } + /** + * @param string $propertyName + * + * @return boolean + */ public function hasChanged($propertyName) { return in_array($propertyName, $this->changedProperties); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php old mode 100755 new mode 100644 index b61a69a3d4..839108f4e8 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php @@ -20,26 +20,24 @@ namespace Doctrine\DBAL\Schema; /** - * Compare to Schemas and return an instance of SchemaDiff + * Compares two Schemas and return an instance of SchemaDiff. * - * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - * - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class Comparator { /** - * @param Schema $fromSchema - * @param Schema $toSchema - * @return SchemaDiff + * @param \Doctrine\DBAL\Schema\Schema $fromSchema + * @param \Doctrine\DBAL\Schema\Schema $toSchema + * + * @return \Doctrine\DBAL\Schema\SchemaDiff */ - static public function compareSchemas( Schema $fromSchema, Schema $toSchema ) + static public function compareSchemas(Schema $fromSchema, Schema $toSchema) { $c = new self(); + return $c->compare($fromSchema, $toSchema); } @@ -50,14 +48,15 @@ class Comparator * operations to change the schema stored in $fromSchema to the schema that is * stored in $toSchema. * - * @param Schema $fromSchema - * @param Schema $toSchema + * @param \Doctrine\DBAL\Schema\Schema $fromSchema + * @param \Doctrine\DBAL\Schema\Schema $toSchema * - * @return SchemaDiff + * @return \Doctrine\DBAL\Schema\SchemaDiff */ public function compare(Schema $fromSchema, Schema $toSchema) { $diff = new SchemaDiff(); + $diff->fromSchema = $fromSchema; $foreignKeysToTable = array(); @@ -136,6 +135,12 @@ class Comparator return $diff; } + /** + * @param \Doctrine\DBAL\Schema\Schema $schema + * @param \Doctrine\DBAL\Schema\Sequence $sequence + * + * @return boolean + */ private function isAutoIncrementSequenceInSchema($schema, $sequence) { foreach ($schema->getTables() as $table) { @@ -148,9 +153,10 @@ class Comparator } /** + * @param \Doctrine\DBAL\Schema\Sequence $sequence1 + * @param \Doctrine\DBAL\Schema\Sequence $sequence2 * - * @param Sequence $sequence1 - * @param Sequence $sequence2 + * @return boolean */ public function diffSequence(Sequence $sequence1, Sequence $sequence2) { @@ -170,15 +176,16 @@ class Comparator * * If there are no differences this method returns the boolean false. * - * @param Table $table1 - * @param Table $table2 + * @param \Doctrine\DBAL\Schema\Table $table1 + * @param \Doctrine\DBAL\Schema\Table $table2 * - * @return bool|TableDiff + * @return boolean|\Doctrine\DBAL\Schema\TableDiff */ public function diffTable(Table $table1, Table $table2) { $changes = 0; $tableDifferences = new TableDiff($table1->getName()); + $tableDifferences->fromTable = $table1; $table1Columns = $table1->getColumns(); $table2Columns = $table2->getColumns(); @@ -203,6 +210,7 @@ class Comparator $changedProperties = $this->diffColumn( $column, $table2->getColumn($columnName) ); if (count($changedProperties) ) { $columnDiff = new ColumnDiff($column->getName(), $table2->getColumn($columnName), $changedProperties); + $columnDiff->fromColumn = $column; $tableDifferences->changedColumns[$column->getName()] = $columnDiff; $changes++; } @@ -259,12 +267,12 @@ class Comparator } } - foreach ($fromFkeys as $key1 => $constraint1) { + foreach ($fromFkeys as $constraint1) { $tableDifferences->removedForeignKeys[] = $constraint1; $changes++; } - foreach ($toFkeys as $key2 => $constraint2) { + foreach ($toFkeys as $constraint2) { $tableDifferences->addedForeignKeys[] = $constraint2; $changes++; } @@ -276,13 +284,15 @@ class Comparator * Try to find columns that only changed their name, rename operations maybe cheaper than add/drop * however ambiguities between different possibilities should not lead to renaming at all. * - * @param TableDiff $tableDifferences + * @param \Doctrine\DBAL\Schema\TableDiff $tableDifferences + * + * @return void */ private function detectColumnRenamings(TableDiff $tableDifferences) { $renameCandidates = array(); foreach ($tableDifferences->addedColumns as $addedColumnName => $addedColumn) { - foreach ($tableDifferences->removedColumns as $removedColumnName => $removedColumn) { + foreach ($tableDifferences->removedColumns as $removedColumn) { if (count($this->diffColumn($addedColumn, $removedColumn)) == 0) { $renameCandidates[$addedColumn->getName()][] = array($removedColumn, $addedColumn, $addedColumnName); } @@ -305,9 +315,10 @@ class Comparator } /** - * @param ForeignKeyConstraint $key1 - * @param ForeignKeyConstraint $key2 - * @return bool + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $key1 + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $key2 + * + * @return boolean */ public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2) { @@ -340,8 +351,8 @@ class Comparator * If there are differences this method returns $field2, otherwise the * boolean false. * - * @param Column $column1 - * @param Column $column2 + * @param \Doctrine\DBAL\Schema\Column $column1 + * @param \Doctrine\DBAL\Schema\Column $column2 * * @return array */ @@ -419,15 +430,17 @@ class Comparator * Compares $index1 with $index2 and returns $index2 if there are any * differences or false in case there are no differences. * - * @param Index $index1 - * @param Index $index2 - * @return bool + * @param \Doctrine\DBAL\Schema\Index $index1 + * @param \Doctrine\DBAL\Schema\Index $index2 + * + * @return boolean */ public function diffIndex(Index $index1, Index $index2) { if ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1)) { return false; } + return true; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Constraint.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Constraint.php old mode 100755 new mode 100644 index f80410f2d9..c373472c46 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Constraint.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Constraint.php @@ -1,7 +1,5 @@ + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ interface Constraint { + /** + * @return string + */ public function getName(); + /** + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * + * @return string + */ public function getQuotedName(AbstractPlatform $platform); + /** + * Returns the names of the referencing table columns + * the constraint is associated with. + * + * @return array + */ public function getColumns(); + + /** + * Returns the quoted representation of the column names + * the constraint is associated with. + * + * But only if they were defined with one or a column name + * is a keyword reserved by the platform. + * Otherwise the plain unquoted value as inserted is returned. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The platform to use for quotation. + * + * @return array + */ + public function getQuotedColumns(AbstractPlatform $platform); } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php old mode 100755 new mode 100644 index e11c64cbcb..e26254470f --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL\Schema; @@ -25,23 +23,19 @@ use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs; use Doctrine\DBAL\Events; /** - * IBM Db2 Schema Manager + * IBM Db2 Schema Manager. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 1.0 - * @version $Revision$ - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 1.0 + * @author Benjamin Eberlei */ class DB2SchemaManager extends AbstractSchemaManager { /** - * Return a list of all tables in the current database + * {@inheritdoc} * * Apparently creator is the schema not the user who created it: * {@link http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_sysibmsystablestable.htm} - * - * @return array */ public function listTableNames() { @@ -53,12 +47,8 @@ class DB2SchemaManager extends AbstractSchemaManager return $this->_getPortableTablesList($tables); } - /** - * Get Table Column Definition - * - * @param array $tableColumn - * @return Column + * {@inheritdoc} */ protected function _getPortableTableColumnDefinition($tableColumn) { @@ -111,6 +101,9 @@ class DB2SchemaManager extends AbstractSchemaManager return new Column($tableColumn['colname'], \Doctrine\DBAL\Types\Type::getType($type), $options); } + /** + * {@inheritdoc} + */ protected function _getPortableTablesList($tables) { $tableNames = array(); @@ -118,9 +111,13 @@ class DB2SchemaManager extends AbstractSchemaManager $tableRow = array_change_key_case($tableRow, \CASE_LOWER); $tableNames[] = $tableRow['name']; } + return $tableNames; } + /** + * {@inheritdoc} + */ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { $eventManager = $this->_platform->getEventManager(); @@ -132,11 +129,6 @@ class DB2SchemaManager extends AbstractSchemaManager $primary = ($data['uniquerule'] == "P"); $indexName = strtolower($data['name']); - if ($primary) { - $keyName = 'primary'; - } else { - $keyName = $indexName; - } $data = array( 'name' => $indexName, @@ -168,6 +160,9 @@ class DB2SchemaManager extends AbstractSchemaManager return $indexes; } + /** + * {@inheritdoc} + */ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) { $tableForeignKey = array_change_key_case($tableForeignKey, CASE_LOWER); @@ -187,6 +182,9 @@ class DB2SchemaManager extends AbstractSchemaManager ); } + /** + * {@inheritdoc} + */ protected function _getPortableForeignKeyRuleDef($def) { if ($def == "C") { @@ -194,9 +192,13 @@ class DB2SchemaManager extends AbstractSchemaManager } else if ($def == "N") { return "SET NULL"; } + return null; } + /** + * {@inheritdoc} + */ protected function _getPortableViewDefinition($view) { $view = array_change_key_case($view, \CASE_LOWER); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php old mode 100755 new mode 100644 index f73b223c7f..cffd40e067 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php @@ -26,6 +26,9 @@ namespace Doctrine\DBAL\Schema; */ class DrizzleSchemaManager extends AbstractSchemaManager { + /** + * {@inheritdoc} + */ protected function _getPortableTableColumnDefinition($tableColumn) { $tableName = $tableColumn['COLUMN_NAME']; @@ -48,16 +51,25 @@ class DrizzleSchemaManager extends AbstractSchemaManager return new Column($tableName, \Doctrine\DBAL\Types\Type::getType($type), $options); } + /** + * {@inheritdoc} + */ protected function _getPortableDatabaseDefinition($database) { return $database['SCHEMA_NAME']; } + /** + * {@inheritdoc} + */ protected function _getPortableTableDefinition($table) { return $table['TABLE_NAME']; } + /** + * {@inheritdoc} + */ public function _getPortableTableForeignKeyDefinition($tableForeignKey) { $columns = array(); @@ -82,6 +94,9 @@ class DrizzleSchemaManager extends AbstractSchemaManager ); } + /** + * {@inheritdoc} + */ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { $indexes = array(); @@ -93,4 +108,3 @@ class DrizzleSchemaManager extends AbstractSchemaManager return parent::_getPortableTableIndexesList($indexes, $tableName); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php old mode 100755 new mode 100644 index 0375582bad..9eac562ec8 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php @@ -1,7 +1,5 @@ + * @author Steve Müller + * @link www.doctrine-project.org + * @since 2.0 + */ class ForeignKeyConstraint extends AbstractAsset implements Constraint { /** - * @var Table + * Instance of the referencing table the foreign key constraint is associated with. + * + * @var \Doctrine\DBAL\Schema\Table */ protected $_localTable; /** - * @var array + * Asset identifier instances of the referencing table column names the foreign key constraint is associated with. + * array($columnName => Identifier) + * + * @var Identifier[] */ protected $_localColumnNames; /** - * @var string + * Table or asset identifier instance of the referenced table name the foreign key constraint is associated with. + * + * @var Table|Identifier */ protected $_foreignTableName; /** - * @var array + * Asset identifier instances of the referenced table column names the foreign key constraint is associated with. + * array($columnName => Identifier) + * + * @var Identifier[] */ protected $_foreignColumnNames; /** - * @var string - */ - protected $_cascade = ''; - - /** - * @var array + * @var array Options associated with the foreign key constraint. */ protected $_options; /** + * Initializes the foreign key constraint. * - * @param array $localColumnNames - * @param string $foreignTableName - * @param array $foreignColumnNames - * @param string $cascade - * @param string|null $name + * @param array $localColumnNames Names of the referencing table columns. + * @param Table|string $foreignTableName Referenced table. + * @param array $foreignColumnNames Names of the referenced table columns. + * @param string|null $name Name of the foreign key constraint. + * @param array $options Options associated with the foreign key constraint. */ - public function __construct(array $localColumnNames, $foreignTableName, array $foreignColumnNames, $name=null, array $options=array()) + public function __construct(array $localColumnNames, $foreignTableName, array $foreignColumnNames, $name = null, array $options = array()) { $this->_setName($name); - $this->_localColumnNames = $localColumnNames; - $this->_foreignTableName = $foreignTableName; - $this->_foreignColumnNames = $foreignColumnNames; + $identifierConstructorCallback = function ($column) { + return new Identifier($column); + }; + $this->_localColumnNames = $localColumnNames + ? array_combine($localColumnNames, array_map($identifierConstructorCallback, $localColumnNames)) + : array(); + + if ($foreignTableName instanceof Table) { + $this->_foreignTableName = $foreignTableName; + } else { + $this->_foreignTableName = new Identifier($foreignTableName); + } + + $this->_foreignColumnNames = $foreignColumnNames + ? array_combine($foreignColumnNames, array_map($identifierConstructorCallback, $foreignColumnNames)) + : array(); $this->_options = $options; } /** + * Returns the name of the referencing table + * the foreign key constraint is associated with. + * * @return string */ public function getLocalTableName() @@ -82,7 +109,12 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint } /** - * @param Table $table + * Sets the Table instance of the referencing table + * the foreign key constraint is associated with. + * + * @param \Doctrine\DBAL\Schema\Table $table Instance of the referencing table. + * + * @return void */ public function setLocalTable(Table $table) { @@ -90,75 +122,176 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint } /** + * @return Table + */ + public function getLocalTable() + { + return $this->_localTable; + } + + /** + * Returns the names of the referencing table columns + * the foreign key constraint is associated with. + * * @return array */ public function getLocalColumns() { - return $this->_localColumnNames; - } - - public function getColumns() - { - return $this->_localColumnNames; + return array_keys($this->_localColumnNames); } /** + * Returns the quoted representation of the referencing table column names + * the foreign key constraint is associated with. + * + * But only if they were defined with one or the referencing table column name + * is a keyword reserved by the platform. + * Otherwise the plain unquoted value as inserted is returned. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The platform to use for quotation. + * + * @return array + */ + public function getQuotedLocalColumns(AbstractPlatform $platform) + { + $columns = array(); + + foreach ($this->_localColumnNames as $column) { + $columns[] = $column->getQuotedName($platform); + } + + return $columns; + } + + /** + * {@inheritdoc} + * + * @see getLocalColumns + */ + public function getColumns() + { + return $this->getLocalColumns(); + } + + /** + * Returns the quoted representation of the referencing table column names + * the foreign key constraint is associated with. + * + * But only if they were defined with one or the referencing table column name + * is a keyword reserved by the platform. + * Otherwise the plain unquoted value as inserted is returned. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The platform to use for quotation. + * + * @see getQuotedLocalColumns + * + * @return array + */ + public function getQuotedColumns(AbstractPlatform $platform) + { + return $this->getQuotedLocalColumns($platform); + } + + /** + * Returns the name of the referenced table + * the foreign key constraint is associated with. + * * @return string */ public function getForeignTableName() { - return $this->_foreignTableName; + return $this->_foreignTableName->getName(); } /** - * Return the non-schema qualified foreign table name. + * Returns the non-schema qualified foreign table name. * * @return string */ public function getUnqualifiedForeignTableName() { - $parts = explode(".", $this->_foreignTableName); + $parts = explode(".", $this->_foreignTableName->getName()); return strtolower(end($parts)); } /** - * Get the quoted representation of this asset but only if it was defined with one. Otherwise - * return the plain unquoted value as inserted. + * Returns the quoted representation of the referenced table name + * the foreign key constraint is associated with. + * + * But only if it was defined with one or the referenced table name + * is a keyword reserved by the platform. + * Otherwise the plain unquoted value as inserted is returned. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The platform to use for quotation. * - * @param AbstractPlatform $platform * @return string */ public function getQuotedForeignTableName(AbstractPlatform $platform) { - $keywords = $platform->getReservedKeywordsList(); - $parts = explode(".", $this->getForeignTableName()); - foreach ($parts AS $k => $v) { - $parts[$k] = ($this->_quoted || $keywords->isKeyword($v)) ? $platform->quoteIdentifier($v) : $v; - } - - return implode(".", $parts); + return $this->_foreignTableName->getQuotedName($platform); } /** + * Returns the names of the referenced table columns + * the foreign key constraint is associated with. + * * @return array */ public function getForeignColumns() { - return $this->_foreignColumnNames; + return array_keys($this->_foreignColumnNames); } + /** + * Returns the quoted representation of the referenced table column names + * the foreign key constraint is associated with. + * + * But only if they were defined with one or the referenced table column name + * is a keyword reserved by the platform. + * Otherwise the plain unquoted value as inserted is returned. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The platform to use for quotation. + * + * @return array + */ + public function getQuotedForeignColumns(AbstractPlatform $platform) + { + $columns = array(); + + foreach ($this->_foreignColumnNames as $column) { + $columns[] = $column->getQuotedName($platform); + } + + return $columns; + } + + /** + * Returns whether or not a given option + * is associated with the foreign key constraint. + * + * @param string $name Name of the option to check. + * + * @return boolean + */ public function hasOption($name) { return isset($this->_options[$name]); } + /** + * Returns an option associated with the foreign key constraint. + * + * @param string $name Name of the option the foreign key constraint is associated with. + * + * @return mixed + */ public function getOption($name) { return $this->_options[$name]; } /** - * Gets the options associated with this constraint + * Returns the options associated with the foreign key constraint. * * @return array */ @@ -168,37 +301,46 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint } /** - * Foreign Key onUpdate status + * Returns the referential action for UPDATE operations + * on the referenced table the foreign key constraint is associated with. * * @return string|null */ public function onUpdate() { - return $this->_onEvent('onUpdate'); + return $this->onEvent('onUpdate'); } /** - * Foreign Key onDelete status + * Returns the referential action for DELETE operations + * on the referenced table the foreign key constraint is associated with. * * @return string|null */ public function onDelete() { - return $this->_onEvent('onDelete'); + return $this->onEvent('onDelete'); } /** - * @param string $event + * Returns the referential action for a given database operation + * on the referenced table the foreign key constraint is associated with. + * + * @param string $event Name of the database operation/event to return the referential action for. + * * @return string|null */ - private function _onEvent($event) + private function onEvent($event) { if (isset($this->_options[$event])) { $onEvent = strtoupper($this->_options[$event]); - if (!in_array($onEvent, array('NO ACTION', 'RESTRICT'))) { + + if ( ! in_array($onEvent, array('NO ACTION', 'RESTRICT'))) { return $onEvent; } } + return false; } } + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Identifier.php old mode 100755 new mode 100644 similarity index 60% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php rename to vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Identifier.php index f950df0e06..e50e767811 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Identifier.php @@ -1,5 +1,4 @@ . */ -namespace Doctrine\Tests\Models\DDC869; +namespace Doctrine\DBAL\Schema; -use Doctrine\ORM\EntityRepository; +use Doctrine\DBAL\Schema\AbstractAsset; -class DDC869PaymentRepository extends EntityRepository +/** + * An abstraction class for an asset identifier. + * + * Wraps identifier names like column names in indexes / foreign keys + * in an abstract class for proper quotation capabilities. + * + * @author Steve Müller + * @link www.doctrine-project.org + * @since 2.4 + */ +class Identifier extends AbstractAsset { - /** - * Very complex method + * Constructor. * - * @return bool + * @param string $identifier Identifier name to wrap. */ - public function isTrue() + public function __construct($identifier) { - return true; + $this->_setName($identifier); } -} \ No newline at end of file +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Index.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Index.php old mode 100755 new mode 100644 index 56b9ea8634..7efc20152a --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Index.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Index.php @@ -19,22 +19,25 @@ namespace Doctrine\DBAL\Schema; -use Doctrine\DBAL\Schema\Visitor\Visitor; +use Doctrine\DBAL\Platforms\AbstractPlatform; class Index extends AbstractAsset implements Constraint { /** - * @var array + * Asset identifier instances of the column names the index is associated with. + * array($columnName => Identifier) + * + * @var Identifier[] */ protected $_columns; /** - * @var bool + * @var boolean */ protected $_isUnique = false; /** - * @var bool + * @var boolean */ protected $_isPrimary = false; @@ -46,10 +49,11 @@ class Index extends AbstractAsset implements Constraint protected $_flags = array(); /** - * @param string $indexName - * @param array $column - * @param bool $isUnique - * @param bool $isPrimary + * @param string $indexName + * @param array $columns + * @param boolean $isUnique + * @param boolean $isPrimary + * @param array $flags */ public function __construct($indexName, array $columns, $isUnique = false, $isPrimary = false, array $flags = array()) { @@ -69,22 +73,40 @@ class Index extends AbstractAsset implements Constraint /** * @param string $column + * + * @return void + * + * @throws \InvalidArgumentException */ protected function _addColumn($column) { if(is_string($column)) { - $this->_columns[] = $column; + $this->_columns[$column] = new Identifier($column); } else { throw new \InvalidArgumentException("Expecting a string as Index Column"); } } /** - * @return array + * {@inheritdoc} */ public function getColumns() { - return $this->_columns; + return array_keys($this->_columns); + } + + /** + * {@inheritdoc} + */ + public function getQuotedColumns(AbstractPlatform $platform) + { + $columns = array(); + + foreach ($this->_columns as $column) { + $columns[] = $column->getQuotedName($platform); + } + + return $columns; } /** @@ -98,7 +120,7 @@ class Index extends AbstractAsset implements Constraint /** * Is the index neither unique nor primary key? * - * @return bool + * @return boolean */ public function isSimpleIndex() { @@ -106,7 +128,7 @@ class Index extends AbstractAsset implements Constraint } /** - * @return bool + * @return boolean */ public function isUnique() { @@ -114,7 +136,7 @@ class Index extends AbstractAsset implements Constraint } /** - * @return bool + * @return boolean */ public function isPrimary() { @@ -122,39 +144,47 @@ class Index extends AbstractAsset implements Constraint } /** - * @param string $columnName - * @param int $pos - * @return bool + * @param string $columnName + * @param integer $pos + * + * @return boolean */ public function hasColumnAtPosition($columnName, $pos = 0) { $columnName = $this->trimQuotes(strtolower($columnName)); $indexColumns = array_map('strtolower', $this->getUnquotedColumns()); + return array_search($columnName, $indexColumns) === $pos; } /** - * Check if this index exactly spans the given column names in the correct order. + * Checks if this index exactly spans the given column names in the correct order. * * @param array $columnNames + * * @return boolean */ public function spansColumns(array $columnNames) { - $sameColumns = true; - for ($i = 0; $i < count($this->_columns); $i++) { - if (!isset($columnNames[$i]) || $this->trimQuotes(strtolower($this->_columns[$i])) != $this->trimQuotes(strtolower($columnNames[$i]))) { + $columns = $this->getColumns(); + $numberOfColumns = count($columns); + $sameColumns = true; + + for ($i = 0; $i < $numberOfColumns; $i++) { + if ( ! isset($columnNames[$i]) || $this->trimQuotes(strtolower($columns[$i])) !== $this->trimQuotes(strtolower($columnNames[$i]))) { $sameColumns = false; } } + return $sameColumns; } /** - * Check if the other index already fullfills all the indexing and constraint needs of the current one. + * Checks if the other index already fulfills all the indexing and constraint needs of the current one. * - * @param Index $other - * @return bool + * @param \Doctrine\DBAL\Schema\Index $other + * + * @return boolean */ public function isFullfilledBy(Index $other) { @@ -171,7 +201,7 @@ class Index extends AbstractAsset implements Constraint if ( ! $this->isUnique() && !$this->isPrimary()) { // this is a special case: If the current key is neither primary or unique, any uniqe or // primary key will always have the same effect for the index and there cannot be any constraint - // overlaps. This means a primary or unique index can always fullfill the requirements of just an + // overlaps. This means a primary or unique index can always fulfill the requirements of just an // index that has no constraints. return true; } else if ($other->isPrimary() != $this->isPrimary()) { @@ -179,16 +209,19 @@ class Index extends AbstractAsset implements Constraint } else if ($other->isUnique() != $this->isUnique()) { return false; } + return true; } + return false; } /** - * Detect if the other index is a non-unique, non primary index that can be overwritten by this one. + * Detects if the other index is a non-unique, non primary index that can be overwritten by this one. * - * @param Index $other - * @return bool + * @param \Doctrine\DBAL\Schema\Index $other + * + * @return boolean */ public function overrules(Index $other) { @@ -201,19 +234,33 @@ class Index extends AbstractAsset implements Constraint if ($this->spansColumns($other->getColumns()) && ($this->isPrimary() || $this->isUnique())) { return true; } + return false; } /** - * Add Flag for an index that translates to platform specific handling. + * Returns platform specific flags for indexes. + * + * @return array + */ + public function getFlags() + { + return array_keys($this->_flags); + } + + /** + * Adds Flag for an index that translates to platform specific handling. * * @example $index->addFlag('CLUSTERED') + * * @param string $flag - * @return Index + * + * @return \Doctrine\DBAL\Schema\Index */ public function addFlag($flag) { $this->flags[strtolower($flag)] = true; + return $this; } @@ -221,7 +268,8 @@ class Index extends AbstractAsset implements Constraint * Does this index have a specific flag? * * @param string $flag - * @return bool + * + * @return boolean */ public function hasFlag($flag) { @@ -229,9 +277,10 @@ class Index extends AbstractAsset implements Constraint } /** - * Remove a flag + * Removes a flag. * * @param string $flag + * * @return void */ public function removeFlag($flag) @@ -239,4 +288,3 @@ class Index extends AbstractAsset implements Constraint unset($this->flags[strtolower($flag)]); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php old mode 100755 new mode 100644 index a9a596456a..675b8a0a07 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -22,26 +22,33 @@ namespace Doctrine\DBAL\Schema; /** * Schema manager for the MySql RDBMS. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @author Konsta Vesterinen - * @author Lukas Smith (PEAR MDB2 library) - * @author Roman Borschel - * @author Benjamin Eberlei - * @version $Revision$ - * @since 2.0 + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Roman Borschel + * @author Benjamin Eberlei + * @since 2.0 */ class MySqlSchemaManager extends AbstractSchemaManager { + /** + * {@inheritdoc} + */ protected function _getPortableViewDefinition($view) { return new View($view['TABLE_NAME'], $view['VIEW_DEFINITION']); } + /** + * {@inheritdoc} + */ protected function _getPortableTableDefinition($table) { return array_shift($table); } + /** + * {@inheritdoc} + */ protected function _getPortableUserDefinition($user) { return array( @@ -50,6 +57,9 @@ class MySqlSchemaManager extends AbstractSchemaManager ); } + /** + * {@inheritdoc} + */ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { foreach($tableIndexes as $k => $v) { @@ -68,23 +78,24 @@ class MySqlSchemaManager extends AbstractSchemaManager return parent::_getPortableTableIndexesList($tableIndexes, $tableName); } + /** + * {@inheritdoc} + */ protected function _getPortableSequenceDefinition($sequence) { return end($sequence); } + /** + * {@inheritdoc} + */ protected function _getPortableDatabaseDefinition($database) { return $database['Database']; } /** - * Gets a portable column definition. - * - * The database type is mapped to a corresponding Doctrine mapping type. - * - * @param $tableColumn - * @return array + * {@inheritdoc} */ protected function _getPortableTableColumnDefinition($tableColumn) { @@ -94,12 +105,10 @@ class MySqlSchemaManager extends AbstractSchemaManager $dbType = strtok($dbType, '(), '); if (isset($tableColumn['length'])) { $length = $tableColumn['length']; - $decimal = ''; } else { $length = strtok('(), '); - $decimal = strtok('(), ') ? strtok('(), '):null; } - $type = array(); + $fixed = null; if ( ! isset($tableColumn['name'])) { @@ -110,8 +119,12 @@ class MySqlSchemaManager extends AbstractSchemaManager $precision = null; $type = $this->_platform->getDoctrineTypeMapping($dbType); - $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type); - $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type); + + // In cases where not connected to a database DESCRIBE $table does not return 'Comment' + if (isset($tableColumn['comment'])) { + $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type); + $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type); + } switch ($dbType) { case 'char': @@ -165,10 +178,13 @@ class MySqlSchemaManager extends AbstractSchemaManager return new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options); } + /** + * {@inheritdoc} + */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { $list = array(); - foreach ($tableForeignKeys as $key => $value) { + foreach ($tableForeignKeys as $value) { $value = array_change_key_case($value, CASE_LOWER); if (!isset($list[$value['constraint_name']])) { if (!isset($value['delete_rule']) || $value['delete_rule'] == "RESTRICT") { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php old mode 100755 new mode 100644 index 2a880d9b11..7fd306439d --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -1,7 +1,5 @@ . + * . */ namespace Doctrine\DBAL\Schema; /** - * Oracle Schema Manager + * Oracle Schema Manager. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @author Konsta Vesterinen - * @author Lukas Smith (PEAR MDB2 library) - * @author Benjamin Eberlei - * @version $Revision$ - * @since 2.0 + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Benjamin Eberlei + * @since 2.0 */ class OracleSchemaManager extends AbstractSchemaManager { + /** + * {@inheritdoc} + */ protected function _getPortableViewDefinition($view) { $view = \array_change_key_case($view, CASE_LOWER); @@ -40,6 +39,9 @@ class OracleSchemaManager extends AbstractSchemaManager return new View($view['view_name'], $view['text']); } + /** + * {@inheritdoc} + */ protected function _getPortableUserDefinition($user) { $user = \array_change_key_case($user, CASE_LOWER); @@ -49,6 +51,9 @@ class OracleSchemaManager extends AbstractSchemaManager ); } + /** + * {@inheritdoc} + */ protected function _getPortableTableDefinition($table) { $table = \array_change_key_case($table, CASE_LOWER); @@ -57,11 +62,10 @@ class OracleSchemaManager extends AbstractSchemaManager } /** + * {@inheritdoc} + * * @license New BSD License * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html - * @param array $tableIndexes - * @param string $tableName - * @return array */ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { @@ -83,9 +87,13 @@ class OracleSchemaManager extends AbstractSchemaManager $buffer['column_name'] = $tableIndex['column_name']; $indexBuffer[] = $buffer; } + return parent::_getPortableTableIndexesList($indexBuffer, $tableName); } + /** + * {@inheritdoc} + */ protected function _getPortableTableColumnDefinition($tableColumn) { $tableColumn = \array_change_key_case($tableColumn, CASE_LOWER); @@ -99,11 +107,7 @@ class OracleSchemaManager extends AbstractSchemaManager } } - $type = array(); - $length = $unsigned = $fixed = null; - if ( ! empty($tableColumn['data_length'])) { - $length = $tableColumn['data_length']; - } + $unsigned = $fixed = null; if ( ! isset($tableColumn['column_name'])) { $tableColumn['column_name'] = ''; @@ -196,6 +200,9 @@ class OracleSchemaManager extends AbstractSchemaManager return new Column($tableColumn['column_name'], \Doctrine\DBAL\Types\Type::getType($type), $options); } + /** + * {@inheritdoc} + */ protected function _getPortableTableForeignKeysList($tableForeignKeys) { $list = array(); @@ -230,24 +237,39 @@ class OracleSchemaManager extends AbstractSchemaManager return $result; } + /** + * {@inheritdoc} + */ protected function _getPortableSequenceDefinition($sequence) { $sequence = \array_change_key_case($sequence, CASE_LOWER); + return new Sequence($sequence['sequence_name'], $sequence['increment_by'], $sequence['min_value']); } + /** + * {@inheritdoc} + */ protected function _getPortableFunctionDefinition($function) { $function = \array_change_key_case($function, CASE_LOWER); + return $function['name']; } + /** + * {@inheritdoc} + */ protected function _getPortableDatabaseDefinition($database) { $database = \array_change_key_case($database, CASE_LOWER); + return $database['username']; } + /** + * {@inheritdoc} + */ public function createDatabase($database = null) { if (is_null($database)) { @@ -259,14 +281,19 @@ class OracleSchemaManager extends AbstractSchemaManager $password = $params['password']; $query = 'CREATE USER ' . $username . ' IDENTIFIED BY ' . $password; - $result = $this->_conn->executeUpdate($query); + $this->_conn->executeUpdate($query); $query = 'GRANT CREATE SESSION, CREATE TABLE, UNLIMITED TABLESPACE, CREATE SEQUENCE, CREATE TRIGGER TO ' . $username; - $result = $this->_conn->executeUpdate($query); + $this->_conn->executeUpdate($query); return true; } + /** + * @param string $table + * + * @return boolean + */ public function dropAutoincrement($table) { $sql = $this->_platform->getDropAutoincrementSql($table); @@ -277,10 +304,13 @@ class OracleSchemaManager extends AbstractSchemaManager return true; } + /** + * {@inheritdoc} + */ public function dropTable($name) { $this->dropAutoincrement($name); - return parent::dropTable($name); + parent::dropTable($name); } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php old mode 100755 new mode 100644 index c67e8cd9db..f6955074fa --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -1,5 +1,4 @@ - * @author Lukas Smith (PEAR MDB2 library) - * @author Benjamin Eberlei - * @since 2.0 + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Benjamin Eberlei + * @since 2.0 */ class PostgreSqlSchemaManager extends AbstractSchemaManager { @@ -37,18 +35,19 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager private $existingSchemaPaths; /** - * Get all the existing schema names. + * Gets all the existing schema names. * * @return array */ public function getSchemaNames() { $rows = $this->_conn->fetchAll("SELECT nspname as schema_name FROM pg_namespace WHERE nspname !~ '^pg_.*' and nspname != 'information_schema'"); + return array_map(function($v) { return $v['schema_name']; }, $rows); } /** - * Return an array of schema search paths + * Returns an array of schema search paths. * * This is a PostgreSQL only function. * @@ -67,7 +66,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager } /** - * Get names of all existing schemas in the current users search path. + * Gets names of all existing schemas in the current users search path. * * This is a PostgreSQL only function. * @@ -78,11 +77,12 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager if ($this->existingSchemaPaths === null) { $this->determineExistingSchemaSearchPaths(); } + return $this->existingSchemaPaths; } /** - * Use this to set or reset the order of the existing schemas in the current search path of the user + * Sets or resets the order of the existing schemas in the current search path of the user. * * This is a PostgreSQL only function. * @@ -98,6 +98,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager }); } + /** + * {@inheritdoc} + */ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) { $onUpdate = null; @@ -124,6 +127,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ); } + /** + * {@inheritdoc} + */ public function dropDatabase($database) { $params = $this->_conn->getParams(); @@ -136,10 +142,15 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager parent::dropDatabase($database); + $this->_conn->close(); + $this->_platform = $tmpPlatform; $this->_conn = $tmpConn; } + /** + * {@inheritdoc} + */ public function createDatabase($database) { $params = $this->_conn->getParams(); @@ -152,20 +163,31 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager parent::createDatabase($database); + $this->_conn->close(); + $this->_platform = $tmpPlatform; $this->_conn = $tmpConn; } + /** + * {@inheritdoc} + */ protected function _getPortableTriggerDefinition($trigger) { return $trigger['trigger_name']; } + /** + * {@inheritdoc} + */ protected function _getPortableViewDefinition($view) { return new View($view['viewname'], $view['definition']); } + /** + * {@inheritdoc} + */ protected function _getPortableUserDefinition($user) { return array( @@ -174,6 +196,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ); } + /** + * {@inheritdoc} + */ protected function _getPortableTableDefinition($table) { $schemas = $this->getExistingSchemaSearchPaths(); @@ -187,11 +212,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager } /** + * {@inheritdoc} + * * @license New BSD License * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html - * @param array $tableIndexes - * @param string $tableName - * @return array */ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { @@ -219,14 +243,21 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager } } } + return parent::_getPortableTableIndexesList($buffer, $tableName); } + /** + * {@inheritdoc} + */ protected function _getPortableDatabaseDefinition($database) { return $database['datname']; } + /** + * {@inheritdoc} + */ protected function _getPortableSequenceDefinition($sequence) { if ($sequence['schemaname'] != 'public') { @@ -235,10 +266,14 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager $sequenceName = $sequence['relname']; } - $data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $sequenceName); + $data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName)); + return new Sequence($sequenceName, $data[0]['increment_by'], $data[0]['min_value']); } + /** + * {@inheritdoc} + */ protected function _getPortableTableColumnDefinition($tableColumn) { $tableColumn = array_change_key_case($tableColumn, CASE_LOWER); @@ -361,5 +396,4 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager return new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options); } - } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php old mode 100755 new mode 100644 index 3075fc9a64..45d44930c5 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php @@ -14,71 +14,56 @@ * * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see - * . + * . */ namespace Doctrine\DBAL\Schema; -use Doctrine\DBAL\Events; -use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs; use Doctrine\DBAL\Driver\SQLSrv\SQLSrvException; +use Doctrine\DBAL\Types\Type; /** - * SQL Server Schema Manager + * SQL Server Schema Manager. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @author Konsta Vesterinen - * @author Lukas Smith (PEAR MDB2 library) - * @author Juozas Kaziukenas - * @since 2.0 + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Juozas Kaziukenas + * @author Steve Müller + * @since 2.0 */ class SQLServerSchemaManager extends AbstractSchemaManager { /** - * @override + * {@inheritdoc} + */ + protected function _getPortableSequenceDefinition($sequence) + { + return new Sequence($sequence['name'], $sequence['increment'], $sequence['start_value']); + } + + /** + * {@inheritdoc} */ protected function _getPortableTableColumnDefinition($tableColumn) { - $dbType = strtolower($tableColumn['TYPE_NAME']); - - $autoincrement = false; - if (stripos($dbType, 'identity')) { - $dbType = trim(str_ireplace('identity', '', $dbType)); - $autoincrement = true; - } - - $dbType = strtok($dbType, '(), '); - - $type = array(); - $unsigned = $fixed = null; + $dbType = strtok($tableColumn['type'], '(), '); + $fixed = null; + $length = (int) $tableColumn['length']; + $default = $tableColumn['default']; if (!isset($tableColumn['name'])) { $tableColumn['name'] = ''; } - $default = $tableColumn['COLUMN_DEF']; - while ($default != ($default2 = preg_replace("/^\((.*)\)$/", '$1', $default))) { $default = trim($default2, "'"); + + if ($default == 'getdate()') { + $default = $this->_platform->getCurrentTimestampSQL(); + } } - $length = (int) $tableColumn['LENGTH']; - - $type = $this->_platform->getDoctrineTypeMapping($dbType); - switch ($type) { - case 'char': - if ($tableColumn['LENGTH'] == '1') { - $type = 'boolean'; - if (preg_match('/^(is|has)/', $tableColumn['name'])) { - $type = array_reverse($type); - } - } - $fixed = true; - break; - case 'text': - $fixed = false; - break; - } switch ($dbType) { case 'nchar': case 'nvarchar': @@ -86,98 +71,104 @@ class SQLServerSchemaManager extends AbstractSchemaManager // Unicode data requires 2 bytes per character $length = $length / 2; break; + case 'varchar': + // TEXT type is returned as VARCHAR(MAX) with a length of -1 + if ($length == -1) { + $dbType = 'text'; + } + break; + } + + $type = $this->_platform->getDoctrineTypeMapping($dbType); + + switch ($type) { + case 'char': + $fixed = true; + break; + case 'text': + $fixed = false; + break; } $options = array( 'length' => ($length == 0 || !in_array($type, array('text', 'string'))) ? null : $length, - 'unsigned' => (bool) $unsigned, + 'unsigned' => false, 'fixed' => (bool) $fixed, 'default' => $default !== 'NULL' ? $default : null, - 'notnull' => (bool) ($tableColumn['IS_NULLABLE'] != 'YES'), - 'scale' => $tableColumn['SCALE'], - 'precision' => $tableColumn['PRECISION'], - 'autoincrement' => $autoincrement, + 'notnull' => (bool) $tableColumn['notnull'], + 'scale' => $tableColumn['scale'], + 'precision' => $tableColumn['precision'], + 'autoincrement' => (bool) $tableColumn['autoincrement'], ); - return new Column($tableColumn['COLUMN_NAME'], \Doctrine\DBAL\Types\Type::getType($type), $options); + $platformOptions = array( + 'collate' => $tableColumn['collation'] == 'NULL' ? null : $tableColumn['collation'] + ); + + $column = new Column($tableColumn['name'], Type::getType($type), $options); + $column->setPlatformOptions($platformOptions); + + return $column; } /** - * @override + * {@inheritdoc} + */ + protected function _getPortableTableForeignKeysList($tableForeignKeys) + { + $foreignKeys = array(); + + foreach ($tableForeignKeys as $tableForeignKey) { + if ( ! isset($foreignKeys[$tableForeignKey['ForeignKey']])) { + $foreignKeys[$tableForeignKey['ForeignKey']] = array( + 'local_columns' => array($tableForeignKey['ColumnName']), + 'foreign_table' => $tableForeignKey['ReferenceTableName'], + 'foreign_columns' => array($tableForeignKey['ReferenceColumnName']), + 'name' => $tableForeignKey['ForeignKey'], + 'options' => array( + 'onUpdate' => str_replace('_', ' ', $tableForeignKey['update_referential_action_desc']), + 'onDelete' => str_replace('_', ' ', $tableForeignKey['delete_referential_action_desc']) + ) + ); + } else { + $foreignKeys[$tableForeignKey['ForeignKey']]['local_columns'][] = $tableForeignKey['ColumnName']; + $foreignKeys[$tableForeignKey['ForeignKey']]['foreign_columns'][] = $tableForeignKey['ReferenceColumnName']; + } + } + + return parent::_getPortableTableForeignKeysList($foreignKeys); + } + + /** + * {@inheritdoc} */ protected function _getPortableTableIndexesList($tableIndexRows, $tableName=null) { - // TODO: Remove code duplication with AbstractSchemaManager; - $result = array(); - foreach ($tableIndexRows as $tableIndex) { - $indexName = $keyName = $tableIndex['index_name']; - if (strpos($tableIndex['index_description'], 'primary key') !== false) { - $keyName = 'primary'; - } - $keyName = strtolower($keyName); - - $flags = array(); - if (strpos($tableIndex['index_description'], 'clustered') !== false) { - $flags[] = 'clustered'; - } else if (strpos($tableIndex['index_description'], 'nonclustered') !== false) { - $flags[] = 'nonclustered'; - } - - $result[$keyName] = array( - 'name' => $indexName, - 'columns' => explode(', ', $tableIndex['index_keys']), - 'unique' => strpos($tableIndex['index_description'], 'unique') !== false, - 'primary' => strpos($tableIndex['index_description'], 'primary key') !== false, - 'flags' => $flags, - ); + foreach ($tableIndexRows as &$tableIndex) { + $tableIndex['non_unique'] = (boolean) $tableIndex['non_unique']; + $tableIndex['primary'] = (boolean) $tableIndex['primary']; + $tableIndex['flags'] = $tableIndex['flags'] ? array($tableIndex['flags']) : null; } - $eventManager = $this->_platform->getEventManager(); - - $indexes = array(); - foreach ($result as $indexKey => $data) { - $index = null; - $defaultPrevented = false; - - if (null !== $eventManager && $eventManager->hasListeners(Events::onSchemaIndexDefinition)) { - $eventArgs = new SchemaIndexDefinitionEventArgs($data, $tableName, $this->_conn); - $eventManager->dispatchEvent(Events::onSchemaIndexDefinition, $eventArgs); - - $defaultPrevented = $eventArgs->isDefaultPrevented(); - $index = $eventArgs->getIndex(); - } - - if ( ! $defaultPrevented) { - $index = new Index($data['name'], $data['columns'], $data['unique'], $data['primary']); - } - - if ($index) { - $indexes[$indexKey] = $index; - } - } - - return $indexes; + return parent::_getPortableTableIndexesList($tableIndexRows, $tableName); } /** - * @override + * {@inheritdoc} */ - public function _getPortableTableForeignKeyDefinition($tableForeignKey) + protected function _getPortableTableForeignKeyDefinition($tableForeignKey) { return new ForeignKeyConstraint( - (array) $tableForeignKey['ColumnName'], - $tableForeignKey['ReferenceTableName'], - (array) $tableForeignKey['ReferenceColumnName'], - $tableForeignKey['ForeignKey'], - array( - 'onUpdate' => str_replace('_', ' ', $tableForeignKey['update_referential_action_desc']), - 'onDelete' => str_replace('_', ' ', $tableForeignKey['delete_referential_action_desc']), - ) + $tableForeignKey['local_columns'], + $tableForeignKey['foreign_table'], + $tableForeignKey['foreign_columns'], + $tableForeignKey['name'], + $tableForeignKey['options'] ); } /** - * @override + * {@inheritdoc} */ protected function _getPortableTableDefinition($table) { @@ -185,7 +176,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager } /** - * @override + * {@inheritdoc} */ protected function _getPortableDatabaseDefinition($database) { @@ -193,7 +184,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager } /** - * @override + * {@inheritdoc} */ protected function _getPortableViewDefinition($view) { @@ -202,12 +193,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager } /** - * List the indexes for a given table returning an array of Index instances. - * - * Keys of the portable indexes list are all lower-cased. - * - * @param string $table The name of the table - * @return Index[] $tableIndexes + * {@inheritdoc} */ public function listTableIndexes($table) { @@ -233,7 +219,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager } /** - * @override + * {@inheritdoc} */ public function alterTable(TableDiff $tableDiff) { @@ -246,11 +232,16 @@ class SQLServerSchemaManager extends AbstractSchemaManager } } - return parent::alterTable($tableDiff); + parent::alterTable($tableDiff); } /** - * This function retrieves the constraints for a given column. + * Returns the SQL to retrieve the constraints for a given column. + * + * @param string $table + * @param string $column + * + * @return string */ private function getColumnConstraintSQL($table, $column) { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php old mode 100755 new mode 100644 index 5a6ff75141..fcb6d32387 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php @@ -22,9 +22,10 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector; use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; use Doctrine\DBAL\Schema\Visitor\Visitor; +use Doctrine\DBAL\Platforms\AbstractPlatform; /** - * Object representation of a database schema + * Object representation of a database schema. * * Different vendors have very inconsistent naming with regard to the concept * of a "schema". Doctrine understands a schema as the entity that conceptually @@ -47,34 +48,31 @@ use Doctrine\DBAL\Schema\Visitor\Visitor; * execute them. Only the queries for the currently connected database are * executed. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class Schema extends AbstractAsset { /** - * @var array + * @var \Doctrine\DBAL\Schema\Table[] */ protected $_tables = array(); /** - * @var array + * @var \Doctrine\DBAL\Schema\Sequence[] */ protected $_sequences = array(); /** - * @var SchemaConfig + * @var \Doctrine\DBAL\Schema\SchemaConfig */ protected $_schemaConfig = false; /** - * @param array $tables - * @param array $sequences - * @param array $views - * @param array $triggers - * @param SchemaConfig $schemaConfig + * @param \Doctrine\DBAL\Schema\Table[] $tables + * @param \Doctrine\DBAL\Schema\Sequence[] $sequences + * @param \Doctrine\DBAL\Schema\SchemaConfig $schemaConfig */ public function __construct(array $tables=array(), array $sequences=array(), SchemaConfig $schemaConfig=null) { @@ -94,7 +92,7 @@ class Schema extends AbstractAsset } /** - * @return bool + * @return boolean */ public function hasExplicitForeignKeyIndexes() { @@ -102,7 +100,11 @@ class Schema extends AbstractAsset } /** - * @param Table $table + * @param \Doctrine\DBAL\Schema\Table $table + * + * @return void + * + * @throws \Doctrine\DBAL\Schema\SchemaException */ protected function _addTable(Table $table) { @@ -116,7 +118,11 @@ class Schema extends AbstractAsset } /** - * @param Sequence $sequence + * @param \Doctrine\DBAL\Schema\Sequence $sequence + * + * @return void + * + * @throws \Doctrine\DBAL\Schema\SchemaException */ protected function _addSequence(Sequence $sequence) { @@ -128,9 +134,9 @@ class Schema extends AbstractAsset } /** - * Get all tables of this schema. + * Gets all tables of this schema. * - * @return array + * @return \Doctrine\DBAL\Schema\Table[] */ public function getTables() { @@ -139,7 +145,10 @@ class Schema extends AbstractAsset /** * @param string $tableName - * @return Table + * + * @return \Doctrine\DBAL\Schema\Table + * + * @throws \Doctrine\DBAL\Schema\SchemaException */ public function getTable($tableName) { @@ -152,6 +161,8 @@ class Schema extends AbstractAsset } /** + * @param string $name + * * @return string */ private function getFullQualifiedAssetName($name) @@ -162,24 +173,26 @@ class Schema extends AbstractAsset if (strpos($name, ".") === false) { $name = $this->getName() . "." . $name; } + return strtolower($name); } /** * Does this schema have a table with the given name? * - * @param string $tableName - * @return Schema + * @param string $tableName + * + * @return boolean */ public function hasTable($tableName) { $tableName = $this->getFullQualifiedAssetName($tableName); + return isset($this->_tables[$tableName]); } /** - * Get all table names, prefixed with a schema name, even the default one - * if present. + * Gets all table names, prefixed with a schema name, even the default one if present. * * @return array */ @@ -188,16 +201,24 @@ class Schema extends AbstractAsset return array_keys($this->_tables); } + /** + * @param string $sequenceName + * + * @return boolean + */ public function hasSequence($sequenceName) { $sequenceName = $this->getFullQualifiedAssetName($sequenceName); + return isset($this->_sequences[$sequenceName]); } /** - * @throws SchemaException - * @param string $sequenceName + * @param string $sequenceName + * * @return \Doctrine\DBAL\Schema\Sequence + * + * @throws \Doctrine\DBAL\Schema\SchemaException */ public function getSequence($sequenceName) { @@ -205,6 +226,7 @@ class Schema extends AbstractAsset if(!$this->hasSequence($sequenceName)) { throw SchemaException::sequenceDoesNotExist($sequenceName); } + return $this->_sequences[$sequenceName]; } @@ -217,10 +239,11 @@ class Schema extends AbstractAsset } /** - * Create a new table + * Creates a new table. * - * @param string $tableName - * @return Table + * @param string $tableName + * + * @return \Doctrine\DBAL\Schema\Table */ public function createTable($tableName) { @@ -235,11 +258,12 @@ class Schema extends AbstractAsset } /** - * Rename a table + * Renames a table. * * @param string $oldTableName * @param string $newTableName - * @return Schema + * + * @return \Doctrine\DBAL\Schema\Schema */ public function renameTable($oldTableName, $newTableName) { @@ -248,56 +272,64 @@ class Schema extends AbstractAsset $this->dropTable($oldTableName); $this->_addTable($table); + return $this; } /** - * Drop a table from the schema. + * Drops a table from the schema. * * @param string $tableName - * @return Schema + * + * @return \Doctrine\DBAL\Schema\Schema */ public function dropTable($tableName) { $tableName = $this->getFullQualifiedAssetName($tableName); - $table = $this->getTable($tableName); + $this->getTable($tableName); unset($this->_tables[$tableName]); + return $this; } /** - * Create a new sequence + * Creates a new sequence. * - * @param string $sequenceName - * @param int $allocationSize - * @param int $initialValue - * @return Sequence + * @param string $sequenceName + * @param integer $allocationSize + * @param integer $initialValue + * + * @return \Doctrine\DBAL\Schema\Sequence */ public function createSequence($sequenceName, $allocationSize=1, $initialValue=1) { $seq = new Sequence($sequenceName, $allocationSize, $initialValue); $this->_addSequence($seq); + return $seq; } /** * @param string $sequenceName - * @return Schema + * + * @return \Doctrine\DBAL\Schema\Schema */ public function dropSequence($sequenceName) { $sequenceName = $this->getFullQualifiedAssetName($sequenceName); unset($this->_sequences[$sequenceName]); + return $this; } /** - * Return an array of necessary sql queries to create the schema on the given platform. + * Returns an array of necessary SQL queries to create the schema on the given platform. * * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return array */ - public function toSql(\Doctrine\DBAL\Platforms\AbstractPlatform $platform) + public function toSql(AbstractPlatform $platform) { $sqlCollector = new CreateSchemaSqlCollector($platform); $this->visit($sqlCollector); @@ -306,12 +338,13 @@ class Schema extends AbstractAsset } /** - * Return an array of necessary sql queries to drop the schema on the given platform. + * Return an array of necessary SQL queries to drop the schema on the given platform. * * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return array */ - public function toDropSql(\Doctrine\DBAL\Platforms\AbstractPlatform $platform) + public function toDropSql(AbstractPlatform $platform) { $dropSqlCollector = new DropSchemaSqlCollector($platform); $this->visit($dropSqlCollector); @@ -320,29 +353,37 @@ class Schema extends AbstractAsset } /** - * @param Schema $toSchema + * @param \Doctrine\DBAL\Schema\Schema $toSchema * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * + * @return array */ - public function getMigrateToSql(Schema $toSchema, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) + public function getMigrateToSql(Schema $toSchema, AbstractPlatform $platform) { $comparator = new Comparator(); $schemaDiff = $comparator->compare($this, $toSchema); + return $schemaDiff->toSql($platform); } /** - * @param Schema $fromSchema + * @param \Doctrine\DBAL\Schema\Schema $fromSchema * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * + * @return array */ - public function getMigrateFromSql(Schema $fromSchema, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) + public function getMigrateFromSql(Schema $fromSchema, AbstractPlatform $platform) { $comparator = new Comparator(); $schemaDiff = $comparator->compare($fromSchema, $this); + return $schemaDiff->toSql($platform); } /** - * @param Visitor $visitor + * @param \Doctrine\DBAL\Schema\Visitor\Visitor $visitor + * + * @return void */ public function visit(Visitor $visitor) { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaConfig.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaConfig.php old mode 100755 new mode 100644 index d90da20617..e8ba6fd56b --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaConfig.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaConfig.php @@ -20,22 +20,21 @@ namespace Doctrine\DBAL\Schema; /** - * Configuration for a Schema + * Configuration for a Schema. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class SchemaConfig { /** - * @var bool + * @var boolean */ protected $hasExplicitForeignKeyIndexes = false; /** - * @var int + * @var integer */ protected $maxIdentifierLength = 63; @@ -50,7 +49,7 @@ class SchemaConfig protected $defaultTableOptions = array(); /** - * @return bool + * @return boolean */ public function hasExplicitForeignKeyIndexes() { @@ -58,7 +57,9 @@ class SchemaConfig } /** - * @param bool $flag + * @param boolean $flag + * + * @return void */ public function setExplicitForeignKeyIndexes($flag) { @@ -66,7 +67,9 @@ class SchemaConfig } /** - * @param int $length + * @param integer $length + * + * @return void */ public function setMaxIdentifierLength($length) { @@ -74,7 +77,7 @@ class SchemaConfig } /** - * @return int + * @return integer */ public function getMaxIdentifierLength() { @@ -82,7 +85,7 @@ class SchemaConfig } /** - * Get default namespace of schema objects. + * Gets the default namespace of schema objects. * * @return string */ @@ -92,9 +95,11 @@ class SchemaConfig } /** - * set default namespace name of schema objects. + * Sets the default namespace name of schema objects. * - * @param string $name the value to set. + * @param string $name The value to set. + * + * @return void */ public function setName($name) { @@ -102,7 +107,7 @@ class SchemaConfig } /** - * Get the default options that are passed to Table instances created with + * Gets the default options that are passed to Table instances created with * Schema#createTable(). * * @return array @@ -112,6 +117,11 @@ class SchemaConfig return $this->defaultTableOptions; } + /** + * @param array $defaultTableOptions + * + * @return void + */ public function setDefaultTableOptions(array $defaultTableOptions) { $this->defaultTableOptions = $defaultTableOptions; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php old mode 100755 new mode 100644 index ba0d9e6fb6..4fcdc308f6 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php @@ -22,71 +22,76 @@ namespace Doctrine\DBAL\Schema; use \Doctrine\DBAL\Platforms\AbstractPlatform; /** - * Schema Diff + * Schema Diff. * - * - * @link www.doctrine-project.org + * @link www.doctrine-project.org * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei + * @license http://ez.no/licenses/new_bsd New BSD License + * @since 2.0 + * @author Benjamin Eberlei */ class SchemaDiff { /** - * All added tables + * @var \Doctrine\DBAL\Schema\Schema + */ + public $fromSchema; + + /** + * All added tables. * - * @var array(string=>ezcDbSchemaTable) + * @var \Doctrine\DBAL\Schema\Table[] */ public $newTables = array(); /** - * All changed tables + * All changed tables. * - * @var array(string=>ezcDbSchemaTableDiff) + * @var \Doctrine\DBAL\Schema\TableDiff[] */ public $changedTables = array(); /** - * All removed tables + * All removed tables. * - * @var array(string=>Table) + * @var \Doctrine\DBAL\Schema\Table[] */ public $removedTables = array(); /** - * @var array + * @var \Doctrine\DBAL\Schema\Sequence[] */ public $newSequences = array(); /** - * @var array + * @var \Doctrine\DBAL\Schema\Sequence[] */ public $changedSequences = array(); /** - * @var array + * @var \Doctrine\DBAL\Schema\Sequence[] */ public $removedSequences = array(); /** - * @var array + * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ public $orphanedForeignKeys = array(); /** * Constructs an SchemaDiff object. * - * @param array(string=>Table) $newTables - * @param array(string=>TableDiff) $changedTables - * @param array(string=>bool) $removedTables + * @param \Doctrine\DBAL\Schema\Table[] $newTables + * @param \Doctrine\DBAL\Schema\TableDiff[] $changedTables + * @param \Doctrine\DBAL\Schema\Table[] $removedTables + * @param \Doctrine\DBAL\Schema\Schema|null $fromSchema */ - public function __construct($newTables = array(), $changedTables = array(), $removedTables = array()) + public function __construct($newTables = array(), $changedTables = array(), $removedTables = array(), Schema $fromSchema = null) { - $this->newTables = $newTables; + $this->newTables = $newTables; $this->changedTables = $changedTables; $this->removedTables = $removedTables; + $this->fromSchema = $fromSchema; } /** @@ -98,7 +103,8 @@ class SchemaDiff * * This way it is ensured that assets are deleted which might not be relevant to the metadata schema at all. * - * @param AbstractPlatform $platform + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return array */ public function toSaveSql(AbstractPlatform $platform) @@ -107,7 +113,8 @@ class SchemaDiff } /** - * @param AbstractPlatform $platform + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return array */ public function toSql(AbstractPlatform $platform) @@ -116,8 +123,9 @@ class SchemaDiff } /** - * @param AbstractPlatform $platform - * @param bool $saveMode + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * @param boolean $saveMode + * * @return array */ protected function _toSql(AbstractPlatform $platform, $saveMode = false) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php old mode 100755 new mode 100644 index a8cb93d735..2b2d2ef316 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaException.php @@ -1,4 +1,21 @@ . + */ namespace Doctrine\DBAL\Schema; @@ -17,7 +34,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException /** * @param string $tableName - * @return SchemaException + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function tableDoesNotExist($tableName) { @@ -26,7 +44,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException /** * @param string $indexName - * @return SchemaException + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function indexNameInvalid($indexName) { @@ -35,7 +54,9 @@ class SchemaException extends \Doctrine\DBAL\DBALException /** * @param string $indexName - * @return SchemaException + * @param string $table + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function indexDoesNotExist($indexName, $table) { @@ -44,7 +65,9 @@ class SchemaException extends \Doctrine\DBAL\DBALException /** * @param string $indexName - * @return SchemaException + * @param string $table + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function indexAlreadyExists($indexName, $table) { @@ -53,7 +76,9 @@ class SchemaException extends \Doctrine\DBAL\DBALException /** * @param string $columnName - * @return SchemaException + * @param string $table + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function columnDoesNotExist($columnName, $table) { @@ -61,9 +86,9 @@ class SchemaException extends \Doctrine\DBAL\DBALException } /** + * @param string $tableName * - * @param string $tableName - * @return SchemaException + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function tableAlreadyExists($tableName) { @@ -71,10 +96,10 @@ class SchemaException extends \Doctrine\DBAL\DBALException } /** - * * @param string $tableName * @param string $columnName - * @return SchemaException + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function columnAlreadyExists($tableName, $columnName) { @@ -85,7 +110,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException /** * @param string $sequenceName - * @return SchemaException + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function sequenceAlreadyExists($sequenceName) { @@ -94,7 +120,8 @@ class SchemaException extends \Doctrine\DBAL\DBALException /** * @param string $sequenceName - * @return SchemaException + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function sequenceDoesNotExist($sequenceName) { @@ -102,14 +129,22 @@ class SchemaException extends \Doctrine\DBAL\DBALException } /** - * @param string $fkName - * @return SchemaException + * @param string $fkName + * @param string $table + * + * @return \Doctrine\DBAL\Schema\SchemaException */ static public function foreignKeyDoesNotExist($fkName, $table) { return new self("There exists no foreign key with the name '$fkName' on table '$table'.", self::FOREIGNKEY_DOESNT_EXIST); } + /** + * @param \Doctrine\DBAL\Schema\Table $localTable + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey + * + * @return \Doctrine\DBAL\Schema\SchemaException + */ static public function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey) { return new self( @@ -120,7 +155,13 @@ class SchemaException extends \Doctrine\DBAL\DBALException ); } - static public function alterTableChangeNotSupported($changeName) { + /** + * @param string $changeName + * + * @return \Doctrine\DBAL\Schema\SchemaException + */ + static public function alterTableChangeNotSupported($changeName) + { return new self ("Alter table change not supported, given '$changeName'"); } -} \ No newline at end of file +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php old mode 100755 new mode 100644 index 87ff0fa7a9..1077237593 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php @@ -22,31 +22,28 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Visitor\Visitor; /** - * Sequence Structure + * Sequence structure. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class Sequence extends AbstractAsset { /** - * @var int + * @var integer */ protected $_allocationSize = 1; /** - * @var int + * @var integer */ protected $_initialValue = 1; /** - * - * @param string $name - * @param int $allocationSize - * @param int $initialValue + * @param string $name + * @param integer $allocationSize + * @param integer $initialValue */ public function __construct($name, $allocationSize=1, $initialValue=1) { @@ -55,35 +52,51 @@ class Sequence extends AbstractAsset $this->_initialValue = (is_numeric($initialValue))?$initialValue:1; } + /** + * @return integer + */ public function getAllocationSize() { return $this->_allocationSize; } + /** + * @return integer + */ public function getInitialValue() { return $this->_initialValue; } + /** + * @param integer $allocationSize + * + * @return void + */ public function setAllocationSize($allocationSize) { $this->_allocationSize = (is_numeric($allocationSize))?$allocationSize:1; } + /** + * @param integer $initialValue + * + * @return void + */ public function setInitialValue($initialValue) { $this->_initialValue = (is_numeric($initialValue))?$initialValue:1; } /** - * Check if this sequence is an autoincrement sequence for a given table. + * Checks if this sequence is an autoincrement sequence for a given table. * * This is used inside the comparator to not report sequences as missing, * when the "from" schema implicitly creates the sequences. * - * @param Table $table + * @param \Doctrine\DBAL\Schema\Table $table * - * @return bool + * @return boolean */ public function isAutoIncrementsFor(Table $table) { @@ -111,7 +124,9 @@ class Sequence extends AbstractAsset } /** - * @param Visitor $visitor + * @param \Doctrine\DBAL\Schema\Visitor\Visitor $visitor + * + * @return void */ public function visit(Visitor $visitor) { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php old mode 100755 new mode 100644 index f980f9570f..e67f41df07 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -19,22 +19,21 @@ namespace Doctrine\DBAL\Schema; +use Doctrine\DBAL\DBALException; + /** - * SqliteSchemaManager + * Sqlite SchemaManager. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @author Konsta Vesterinen - * @author Lukas Smith (PEAR MDB2 library) - * @author Jonathan H. Wage - * @version $Revision$ - * @since 2.0 + * @author Konsta Vesterinen + * @author Lukas Smith (PEAR MDB2 library) + * @author Jonathan H. Wage + * @author Martin Hasoň + * @since 2.0 */ class SqliteSchemaManager extends AbstractSchemaManager { /** * {@inheritdoc} - * - * @override */ public function dropDatabase($database) { @@ -45,8 +44,6 @@ class SqliteSchemaManager extends AbstractSchemaManager /** * {@inheritdoc} - * - * @override */ public function createDatabase($database) { @@ -61,17 +58,106 @@ class SqliteSchemaManager extends AbstractSchemaManager $conn->close(); } + /** + * {@inheritdoc} + */ + public function renameTable($name, $newName) + { + $tableDiff = new TableDiff($name); + $tableDiff->fromTable = $this->listTableDetails($name); + $tableDiff->newName = $newName; + $this->alterTable($tableDiff); + } + + /** + * {@inheritdoc} + */ + public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) + { + $tableDiff = $this->getTableDiffForAlterForeignKey($foreignKey, $table); + $tableDiff->addedForeignKeys[] = $foreignKey; + + $this->alterTable($tableDiff); + } + + /** + * {@inheritdoc} + */ + public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) + { + $tableDiff = $this->getTableDiffForAlterForeignKey($foreignKey, $table); + $tableDiff->changedForeignKeys[] = $foreignKey; + + $this->alterTable($tableDiff); + } + + /** + * {@inheritdoc} + */ + public function dropForeignKey($foreignKey, $table) + { + $tableDiff = $this->getTableDiffForAlterForeignKey($foreignKey, $table); + $tableDiff->removedForeignKeys[] = $foreignKey; + + $this->alterTable($tableDiff); + } + + /** + * {@inheritdoc} + */ + public function listTableForeignKeys($table, $database = null) + { + if (null === $database) { + $database = $this->_conn->getDatabase(); + } + $sql = $this->_platform->getListTableForeignKeysSQL($table, $database); + $tableForeignKeys = $this->_conn->fetchAll($sql); + + if ( ! empty($tableForeignKeys)) { + $createSql = $this->_conn->fetchAll("SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type = 'table' AND name = '$table'"); + $createSql = isset($createSql[0]['sql']) ? $createSql[0]['sql'] : ''; + if (preg_match_all('# + (?:CONSTRAINT\s+([^\s]+)\s+)? + (?:FOREIGN\s+KEY[^\)]+\)\s*)? + REFERENCES\s+[^\s]+\s+(?:\([^\)]+\))? + (?: + [^,]*? + (NOT\s+DEFERRABLE|DEFERRABLE) + (?:\s+INITIALLY\s+(DEFERRED|IMMEDIATE))? + )?#isx', + $createSql, $match)) { + + $names = array_reverse($match[1]); + $deferrable = array_reverse($match[2]); + $deferred = array_reverse($match[3]); + } else { + $names = $deferrable = $deferred = array(); + } + + foreach ($tableForeignKeys as $key => $value) { + $id = $value['id']; + $tableForeignKeys[$key]['constraint_name'] = isset($names[$id]) && '' != $names[$id] ? $names[$id] : $id; + $tableForeignKeys[$key]['deferrable'] = isset($deferrable[$id]) && 'deferrable' == strtolower($deferrable[$id]) ? true : false; + $tableForeignKeys[$key]['deferred'] = isset($deferred[$id]) && 'deferred' == strtolower($deferred[$id]) ? true : false; + } + } + + return $this->_getPortableTableForeignKeysList($tableForeignKeys); + } + + /** + * {@inheritdoc} + */ protected function _getPortableTableDefinition($table) { return $table['name']; } /** + * {@inheritdoc} + * * @license New BSD License * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html - * @param array $tableIndexes - * @param string $tableName - * @return array */ protected function _getPortableTableIndexesList($tableIndexes, $tableName=null) { @@ -114,6 +200,9 @@ class SqliteSchemaManager extends AbstractSchemaManager return parent::_getPortableTableIndexesList($indexBuffer, $tableName); } + /** + * {@inheritdoc} + */ protected function _getPortableTableIndexDefinition($tableIndex) { return array( @@ -122,6 +211,37 @@ class SqliteSchemaManager extends AbstractSchemaManager ); } + /** + * {@inheritdoc} + */ + protected function _getPortableTableColumnList($table, $database, $tableColumns) + { + $list = parent::_getPortableTableColumnList($table, $database, $tableColumns); + $autoincrementColumn = null; + $autoincrementCount = 0; + foreach ($tableColumns as $tableColumn) { + if ('1' == $tableColumn['pk']) { + $autoincrementCount++; + if (null === $autoincrementColumn && 'integer' == strtolower($tableColumn['type'])) { + $autoincrementColumn = $tableColumn['name']; + } + } + } + + if (1 == $autoincrementCount && null !== $autoincrementColumn) { + foreach ($list as $column) { + if ($autoincrementColumn == $column->getName()) { + $column->setAutoincrement(true); + } + } + } + + return $list; + } + + /** + * {@inheritdoc} + */ protected function _getPortableTableColumnDefinition($tableColumn) { $e = explode('(', $tableColumn['type']); @@ -186,8 +306,85 @@ class SqliteSchemaManager extends AbstractSchemaManager return new Column($tableColumn['name'], \Doctrine\DBAL\Types\Type::getType($type), $options); } + /** + * {@inheritdoc} + */ protected function _getPortableViewDefinition($view) { return new View($view['name'], $view['sql']); } + + /** + * {@inheritdoc} + */ + protected function _getPortableTableForeignKeysList($tableForeignKeys) + { + $list = array(); + foreach ($tableForeignKeys as $value) { + $value = array_change_key_case($value, CASE_LOWER); + $name = $value['constraint_name']; + if ( ! isset($list[$name])) { + if ( ! isset($value['on_delete']) || $value['on_delete'] == "RESTRICT") { + $value['on_delete'] = null; + } + if ( ! isset($value['on_update']) || $value['on_update'] == "RESTRICT") { + $value['on_update'] = null; + } + + $list[$name] = array( + 'name' => $name, + 'local' => array(), + 'foreign' => array(), + 'foreignTable' => $value['table'], + 'onDelete' => $value['on_delete'], + 'onUpdate' => $value['on_update'], + 'deferrable' => $value['deferrable'], + 'deferred'=> $value['deferred'], + ); + } + $list[$name]['local'][] = $value['from']; + $list[$name]['foreign'][] = $value['to']; + } + + $result = array(); + foreach($list as $constraint) { + $result[] = new ForeignKeyConstraint( + array_values($constraint['local']), $constraint['foreignTable'], + array_values($constraint['foreign']), $constraint['name'], + array( + 'onDelete' => $constraint['onDelete'], + 'onUpdate' => $constraint['onUpdate'], + 'deferrable' => $constraint['deferrable'], + 'deferred'=> $constraint['deferred'], + ) + ); + } + + return $result; + } + + /** + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey + * @param \Doctrine\DBAL\Schema\Table|string $table + * + * @return \Doctrine\DBAL\Schema\TableDiff + * + * @throws \Doctrine\DBAL\DBALException + */ + private function getTableDiffForAlterForeignKey(ForeignKeyConstraint $foreignKey, $table) + { + if ( ! $table instanceof Table) { + $tableDetails = $this->tryMethod('listTableDetails', $table); + if (false === $table) { + throw new DBALException(sprintf('Sqlite schema manager requires to modify foreign keys table definition "%s".', $table)); + } + + $table = $tableDetails; + } + + $tableDiff = new TableDiff($table->getName()); + $tableDiff->fromTable = $table; + + return $tableDiff; + } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php old mode 100755 new mode 100644 index 16fb033994..fc1bec1be0 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php @@ -27,15 +27,21 @@ use Doctrine\DBAL\Connection; abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer { /** - * @var Connection + * @var \Doctrine\DBAL\Connection */ protected $conn; + /** + * @param \Doctrine\DBAL\Connection $conn + */ public function __construct(Connection $conn) { $this->conn = $conn; } + /** + * @param array $sql + */ protected function processSqlSafely(array $sql) { foreach ($sql as $s) { @@ -47,12 +53,13 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer } } + /** + * @param array $sql + */ protected function processSql(array $sql) { foreach ($sql as $s) { $this->conn->exec($s); } } - } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php old mode 100755 new mode 100644 index c24981529a..1a5552ea68 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php @@ -30,67 +30,72 @@ use Doctrine\DBAL\Schema\Schema; interface SchemaSynchronizer { /** - * Get the SQL statements that can be executed to create the schema. + * Gets the SQL statements that can be executed to create the schema. + * + * @param \Doctrine\DBAL\Schema\Schema $createSchema * - * @param Schema $createSchema * @return array */ function getCreateSchema(Schema $createSchema); /** - * Get the SQL Statements to update given schema with the underlying db. + * Gets the SQL Statements to update given schema with the underlying db. + * + * @param \Doctrine\DBAL\Schema\Schema $toSchema + * @param boolean $noDrops * - * @param Schema $toSchema - * @param bool $noDrops * @return array */ function getUpdateSchema(Schema $toSchema, $noDrops = false); /** - * Get the SQL Statements to drop the given schema from underlying db. + * Gets the SQL Statements to drop the given schema from underlying db. + * + * @param \Doctrine\DBAL\Schema\Schema $dropSchema * - * @param Schema $dropSchema * @return array */ function getDropSchema(Schema $dropSchema); /** - * Get the SQL statements to drop all schema assets from underlying db. + * Gets the SQL statements to drop all schema assets from underlying db. * * @return array */ function getDropAllSchema(); /** - * Create the Schema + * Creates the Schema. + * + * @param \Doctrine\DBAL\Schema\Schema $createSchema * - * @param Schema $createSchema * @return void */ function createSchema(Schema $createSchema); /** - * Update the Schema to new schema version. + * Updates the Schema to new schema version. + * + * @param \Doctrine\DBAL\Schema\Schema $toSchema + * @param boolean $noDrops * - * @param Schema $toSchema - * @param bool $noDrops * @return void */ function updateSchema(Schema $toSchema, $noDrops = false); /** - * Drop the given database schema from the underlying db. + * Drops the given database schema from the underlying db. + * + * @param \Doctrine\DBAL\Schema\Schema $dropSchema * - * @param Schema $dropSchema * @return void */ function dropSchema(Schema $dropSchema); /** - * Drop all assets from the underyling db. + * Drops all assets from the underlying db. * * @return void */ function dropAllSchema(); } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php old mode 100755 new mode 100644 index 38ea53ac0b..9e28cb0fe2 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php @@ -16,6 +16,7 @@ * and is licensed under the MIT license. For more information, see * . */ + namespace Doctrine\DBAL\Schema\Synchronizer; use Doctrine\DBAL\Connection; @@ -24,17 +25,20 @@ use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; /** - * Schema Synchronizer for Default DBAL Connection + * Schema Synchronizer for Default DBAL Connection. * * @author Benjamin Eberlei */ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer { /** - * @var Doctrine\DBAL\Platforms\AbstractPlatform + * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ private $platform; + /** + * @param \Doctrine\DBAL\Connection $conn + */ public function __construct(Connection $conn) { parent::__construct($conn); @@ -42,22 +46,16 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer } /** - * Get the SQL statements that can be executed to create the schema. - * - * @param Schema $createSchema - * @return array + * {@inheritdoc} */ public function getCreateSchema(Schema $createSchema) { return $createSchema->toSql($this->platform); } + /** - * Get the SQL Statements to update given schema with the underlying db. - * - * @param Schema $toSchema - * @param bool $noDrops - * @return array + * {@inheritdoc} */ public function getUpdateSchema(Schema $toSchema, $noDrops = false) { @@ -75,10 +73,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer } /** - * Get the SQL Statements to drop the given schema from underlying db. - * - * @param Schema $dropSchema - * @return array + * {@inheritdoc} */ public function getDropSchema(Schema $dropSchema) { @@ -114,7 +109,6 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer } foreach ($dropSchema->getTables() as $table) { - /* @var $sequence Table */ if ( ! $table->hasPrimaryKey()) { continue; } @@ -134,9 +128,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer } /** - * Get the SQL statements to drop all schema assets from underlying db. - * - * @return array + * {@inheritdoc} */ public function getDropAllSchema() { @@ -151,10 +143,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer } /** - * Create the Schema - * - * @param Schema $createSchema - * @return void + * {@inheritdoc} */ public function createSchema(Schema $createSchema) { @@ -162,11 +151,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer } /** - * Update the Schema to new schema version. - * - * @param Schema $toSchema - * @param bool $noDrops - * @return void + * {@inheritdoc} */ public function updateSchema(Schema $toSchema, $noDrops = false) { @@ -174,10 +159,7 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer } /** - * Drop the given database schema from the underlying db. - * - * @param Schema $dropSchema - * @return void + * {@inheritdoc} */ public function dropSchema(Schema $dropSchema) { @@ -185,13 +167,10 @@ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer } /** - * Drop all assets from the underyling db. - * - * @return void + * {@inheritdoc} */ public function dropAllSchema() { $this->processSql($this->getDropAllSchema()); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php old mode 100755 new mode 100644 index d0763c5ccf..37a9962ad5 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php @@ -1,7 +1,5 @@ + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class Table extends AbstractAsset { @@ -42,12 +38,12 @@ class Table extends AbstractAsset protected $_name = null; /** - * @var array + * @var \Doctrine\DBAL\Schema\Column[] */ protected $_columns = array(); /** - * @var array + * @var \Doctrine\DBAL\Schema\Index[] */ protected $_indexes = array(); @@ -57,7 +53,7 @@ class Table extends AbstractAsset protected $_primaryKeyName = false; /** - * @var array + * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ protected $_fkConstraints = array(); @@ -67,18 +63,19 @@ class Table extends AbstractAsset protected $_options = array(); /** - * @var SchemaConfig + * @var \Doctrine\DBAL\Schema\SchemaConfig */ protected $_schemaConfig = null; /** + * @param string $tableName + * @param array $columns + * @param array $indexes + * @param array $fkConstraints + * @param integer $idGeneratorType + * @param array $options * - * @param string $tableName - * @param array $columns - * @param array $indexes - * @param array $fkConstraints - * @param int $idGeneratorType - * @param array $options + * @throws \Doctrine\DBAL\DBALException */ public function __construct($tableName, array $columns=array(), array $indexes=array(), array $fkConstraints=array(), $idGeneratorType = 0, array $options=array()) { @@ -105,7 +102,9 @@ class Table extends AbstractAsset } /** - * @param SchemaConfig $schemaConfig + * @param \Doctrine\DBAL\Schema\SchemaConfig $schemaConfig + * + * @return void */ public function setSchemaConfig(SchemaConfig $schemaConfig) { @@ -113,7 +112,7 @@ class Table extends AbstractAsset } /** - * @return int + * @return integer */ protected function _getMaxIdentifierLength() { @@ -125,11 +124,12 @@ class Table extends AbstractAsset } /** - * Set Primary Key + * Sets the Primary Key. * - * @param array $columns - * @param string $indexName - * @return Table + * @param array $columns + * @param string|boolean $indexName + * + * @return \Doctrine\DBAL\Schema\Table */ public function setPrimaryKey(array $columns, $indexName = false) { @@ -144,11 +144,13 @@ class Table extends AbstractAsset } /** - * @param array $columnNames - * @param string $indexName - * @return Table + * @param array $columnNames + * @param string|null $indexName + * @param array $flags + * + * @return \Doctrine\DBAL\Schema\Table */ - public function addIndex(array $columnNames, $indexName = null) + public function addIndex(array $columnNames, $indexName = null, array $flags = array()) { if($indexName == null) { $indexName = $this->_generateIdentifierName( @@ -156,13 +158,12 @@ class Table extends AbstractAsset ); } - return $this->_createIndex($columnNames, $indexName, false, false); + return $this->_createIndex($columnNames, $indexName, false, false, $flags); } /** - * Drop an index from this table. + * Drops the primary key from this table. * - * @param string $indexName * @return void */ public function dropPrimaryKey() @@ -172,10 +173,13 @@ class Table extends AbstractAsset } /** - * Drop an index from this table. + * Drops an index from this table. + * + * @param string $indexName The index name. * - * @param string $indexName * @return void + * + * @throws \Doctrine\DBAL\Schema\SchemaException If the index does not exist. */ public function dropIndex($indexName) { @@ -187,10 +191,10 @@ class Table extends AbstractAsset } /** + * @param array $columnNames + * @param string|null $indexName * - * @param array $columnNames - * @param string $indexName - * @return Table + * @return \Doctrine\DBAL\Schema\Table */ public function addUniqueIndex(array $columnNames, $indexName = null) { @@ -204,10 +208,11 @@ class Table extends AbstractAsset } /** - * Check if an index begins in the order of the given columns. + * Checks if an index begins in the order of the given columns. * - * @param array $columnsNames - * @return bool + * @param array $columnsNames + * + * @return boolean */ public function columnsAreIndexed(array $columnsNames) { @@ -217,18 +222,22 @@ class Table extends AbstractAsset return true; } } + return false; } /** + * @param array $columnNames + * @param string $indexName + * @param boolean $isUnique + * @param boolean $isPrimary + * @param array $flags * - * @param array $columnNames - * @param string $indexName - * @param bool $isUnique - * @param bool $isPrimary - * @return Table + * @return \Doctrine\DBAL\Schema\Table + * + * @throws \Doctrine\DBAL\Schema\SchemaException */ - private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary) + private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = array()) { if (preg_match('(([^a-zA-Z0-9_]+))', $indexName)) { throw SchemaException::indexNameInvalid($indexName); @@ -243,30 +252,37 @@ class Table extends AbstractAsset throw SchemaException::columnDoesNotExist($columnName, $this->_name); } } - $this->_addIndex(new Index($indexName, $columnNames, $isUnique, $isPrimary)); + + $this->_addIndex(new Index($indexName, $columnNames, $isUnique, $isPrimary, $flags)); + return $this; } /** * @param string $columnName - * @param string $columnType - * @param array $options - * @return Column + * @param string $typeName + * @param array $options + * + * @return \Doctrine\DBAL\Schema\Column */ public function addColumn($columnName, $typeName, array $options=array()) { $column = new Column($columnName, Type::getType($typeName), $options); $this->_addColumn($column); + return $column; } /** - * Rename Column + * Renames a Column. * * @param string $oldColumnName * @param string $newColumnName - * @return Table + * + * @return \Doctrine\DBAL\Schema\Table + * + * @throws \Doctrine\DBAL\DBALException */ public function renameColumn($oldColumnName, $newColumnName) { @@ -276,63 +292,69 @@ class Table extends AbstractAsset } /** - * Change Column Details + * Change Column Details. * * @param string $columnName - * @param array $options - * @return Table + * @param array $options + * + * @return \Doctrine\DBAL\Schema\Table */ public function changeColumn($columnName, array $options) { $column = $this->getColumn($columnName); $column->setOptions($options); + return $this; } /** - * Drop Column from Table + * Drops a Column from the Table. * * @param string $columnName - * @return Table + * + * @return \Doctrine\DBAL\Schema\Table */ public function dropColumn($columnName) { $columnName = strtolower($columnName); - $column = $this->getColumn($columnName); unset($this->_columns[$columnName]); + return $this; } - /** - * Add a foreign key constraint + * Adds a foreign key constraint. * - * Name is inferred from the local columns + * Name is inferred from the local columns. * - * @param Table $foreignTable - * @param array $localColumns - * @param array $foreignColumns - * @param array $options - * @param string $constraintName - * @return Table + * @param \Doctrine\DBAL\Schema\Table $foreignTable + * @param array $localColumnNames + * @param array $foreignColumnNames + * @param array $options + * @param string|null $constraintName + * + * @return \Doctrine\DBAL\Schema\Table */ public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array(), $constraintName = null) { $constraintName = $constraintName ?: $this->_generateIdentifierName(array_merge((array)$this->getName(), $localColumnNames), "fk", $this->_getMaxIdentifierLength()); + return $this->addNamedForeignKeyConstraint($constraintName, $foreignTable, $localColumnNames, $foreignColumnNames, $options); } /** - * Add a foreign key constraint + * Adds a foreign key constraint. * - * Name is to be generated by the database itsself. + * Name is to be generated by the database itself. * * @deprecated Use {@link addForeignKeyConstraint} - * @param Table $foreignTable - * @param array $localColumns - * @param array $foreignColumns - * @param array $options - * @return Table + * + * @param \Doctrine\DBAL\Schema\Table $foreignTable + * @param array $localColumnNames + * @param array $foreignColumnNames + * @param array $options + * + * @return \Doctrine\DBAL\Schema\Table */ public function addUnnamedForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array()) { @@ -340,28 +362,28 @@ class Table extends AbstractAsset } /** - * Add a foreign key constraint with a given name + * Adds a foreign key constraint with a given name. * * @deprecated Use {@link addForeignKeyConstraint} - * @param string $name - * @param Table $foreignTable - * @param array $localColumns - * @param array $foreignColumns - * @param array $options - * @return Table + * + * @param string $name + * @param \Doctrine\DBAL\Schema\Table $foreignTable + * @param array $localColumnNames + * @param array $foreignColumnNames + * @param array $options + * + * @return \Doctrine\DBAL\Schema\Table + * + * @throws \Doctrine\DBAL\Schema\SchemaException */ public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options=array()) { if ($foreignTable instanceof Table) { - $foreignTableName = $foreignTable->getName(); - foreach ($foreignColumnNames as $columnName) { if ( ! $foreignTable->hasColumn($columnName)) { throw SchemaException::columnDoesNotExist($columnName, $foreignTable->getName()); } } - } else { - $foreignTableName = $foreignTable; } foreach ($localColumnNames as $columnName) { @@ -371,7 +393,7 @@ class Table extends AbstractAsset } $constraint = new ForeignKeyConstraint( - $localColumnNames, $foreignTableName, $foreignColumnNames, $name, $options + $localColumnNames, $foreignTable, $foreignColumnNames, $name, $options ); $this->_addForeignKeyConstraint($constraint); @@ -381,16 +403,22 @@ class Table extends AbstractAsset /** * @param string $name * @param string $value - * @return Table + * + * @return \Doctrine\DBAL\Schema\Table */ public function addOption($name, $value) { $this->_options[$name] = $value; + return $this; } /** - * @param Column $column + * @param \Doctrine\DBAL\Schema\Column $column + * + * @return void + * + * @throws \Doctrine\DBAL\Schema\SchemaException */ protected function _addColumn(Column $column) { @@ -405,10 +433,13 @@ class Table extends AbstractAsset } /** - * Add index to table + * Adds an index to the table. * - * @param Index $indexCandidate - * @return Table + * @param \Doctrine\DBAL\Schema\Index $indexCandidate + * + * @return \Doctrine\DBAL\Schema\Table + * + * @throws \Doctrine\DBAL\Schema\SchemaException */ protected function _addIndex(Index $indexCandidate) { @@ -438,11 +469,14 @@ class Table extends AbstractAsset } $this->_indexes[$indexName] = $indexCandidate; + return $this; } /** - * @param ForeignKeyConstraint $constraint + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $constraint + * + * @return void */ protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint) { @@ -458,27 +492,34 @@ class Table extends AbstractAsset $name = strtolower($name); $this->_fkConstraints[$name] = $constraint; - // add an explicit index on the foreign key columns. If there is already an index that fullfils this requirements drop the request. + // add an explicit index on the foreign key columns. If there is already an index that fulfils this requirements drop the request. // In the case of __construct calling this method during hydration from schema-details all the explicitly added indexes - // lead to duplicates. This creates compuation overhead in this case, however no duplicate indexes are ever added (based on columns). + // lead to duplicates. This creates computation overhead in this case, however no duplicate indexes are ever added (based on columns). $this->addIndex($constraint->getColumns()); } /** - * Does Table have a foreign key constraint with the given name? - * * - * @param string $constraintName - * @return bool + * Returns whether this table has a foreign key constraint with the given name. + * + * @param string $constraintName + * + * @return boolean */ public function hasForeignKey($constraintName) { $constraintName = strtolower($constraintName); + return isset($this->_fkConstraints[$constraintName]); } /** - * @param string $constraintName - * @return ForeignKeyConstraint + * Returns the foreign key constraint with the given name. + * + * @param string $constraintName The constraint name. + * + * @return \Doctrine\DBAL\Schema\ForeignKeyConstraint + * + * @throws \Doctrine\DBAL\Schema\SchemaException If the foreign key does not exist. */ public function getForeignKey($constraintName) { @@ -490,6 +531,15 @@ class Table extends AbstractAsset return $this->_fkConstraints[$constraintName]; } + /** + * Removes the foreign key constraint with the given name. + * + * @param string $constraintName The constraint name. + * + * @return void + * + * @throws \Doctrine\DBAL\Schema\SchemaException + */ public function removeForeignKey($constraintName) { $constraintName = strtolower($constraintName); @@ -501,7 +551,7 @@ class Table extends AbstractAsset } /** - * @return Column[] + * @return \Doctrine\DBAL\Schema\Column[] */ public function getColumns() { @@ -522,27 +572,32 @@ class Table extends AbstractAsset uksort($columns, function($a, $b) use($colNames) { return (array_search($a, $colNames) >= array_search($b, $colNames)); }); + return $columns; } - /** - * Does this table have a column with the given name? + * Returns whether this table has a Column with the given name. * - * @param string $columnName - * @return bool + * @param string $columnName The column name. + * + * @return boolean */ public function hasColumn($columnName) { $columnName = $this->trimQuotes(strtolower($columnName)); + return isset($this->_columns[$columnName]); } /** - * Get a column instance + * Returns the Column with the given name. * - * @param string $columnName - * @return Column + * @param string $columnName The column name. + * + * @return \Doctrine\DBAL\Schema\Column + * + * @throws \Doctrine\DBAL\Schema\SchemaException If the column does not exist. */ public function getColumn($columnName) { @@ -555,28 +610,39 @@ class Table extends AbstractAsset } /** - * @return Index|null + * Returns the primary key. + * + * @return \Doctrine\DBAL\Schema\Index|null The primary key, or null if this Table has no primary key. */ public function getPrimaryKey() { if ( ! $this->hasPrimaryKey()) { return null; } + return $this->getIndex($this->_primaryKeyName); } + /** + * Returns the primary key columns. + * + * @return array + * + * @throws \Doctrine\DBAL\DBALException + */ public function getPrimaryKeyColumns() { if ( ! $this->hasPrimaryKey()) { throw new DBALException("Table " . $this->getName() . " has no primary key."); } + return $this->getPrimaryKey()->getColumns(); } /** - * Check if this table has a primary key. + * Returns whether this table has a primary key. * - * @return bool + * @return boolean */ public function hasPrimaryKey() { @@ -584,18 +650,27 @@ class Table extends AbstractAsset } /** - * @param string $indexName - * @return bool + * Returns whether this table has an Index with the given name. + * + * @param string $indexName The index name. + * + * @return boolean */ public function hasIndex($indexName) { $indexName = strtolower($indexName); + return (isset($this->_indexes[$indexName])); } /** - * @param string $indexName - * @return Index + * Returns the Index with the given name. + * + * @param string $indexName The index name. + * + * @return \Doctrine\DBAL\Schema\Index + * + * @throws \Doctrine\DBAL\Schema\SchemaException If the index does not exist. */ public function getIndex($indexName) { @@ -603,11 +678,12 @@ class Table extends AbstractAsset if ( ! $this->hasIndex($indexName)) { throw SchemaException::indexDoesNotExist($indexName, $this->_name); } + return $this->_indexes[$indexName]; } /** - * @return array + * @return \Doctrine\DBAL\Schema\Index[] */ public function getIndexes() { @@ -615,32 +691,47 @@ class Table extends AbstractAsset } /** - * Get Constraints + * Returns the foreign key constraints. * - * @return array + * @return \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ public function getForeignKeys() { return $this->_fkConstraints; } + /** + * @param string $name + * + * @return boolean + */ public function hasOption($name) { return isset($this->_options[$name]); } + /** + * @param string $name + * + * @return mixed + */ public function getOption($name) { return $this->_options[$name]; } + /** + * @return array + */ public function getOptions() { return $this->_options; } /** - * @param Visitor $visitor + * @param \Doctrine\DBAL\Schema\Visitor\Visitor $visitor + * + * @return void */ public function visit(Visitor $visitor) { @@ -660,7 +751,9 @@ class Table extends AbstractAsset } /** - * Clone of a Table triggers a deep clone of all affected assets + * Clone of a Table triggers a deep clone of all affected assets. + * + * @return void */ public function __clone() { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/TableDiff.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/TableDiff.php old mode 100755 new mode 100644 index 257a3bd0da..a61f0ce265 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/TableDiff.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/TableDiff.php @@ -20,14 +20,11 @@ namespace Doctrine\DBAL\Schema; /** - * Table Diff + * Table Diff. * - * - * @link www.doctrine-project.org - * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - * @since 2.0 - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ class TableDiff { @@ -37,93 +34,100 @@ class TableDiff public $name = null; /** - * @var string + * @var string|boolean */ public $newName = false; /** - * All added fields + * All added fields. * - * @var array(string=>Column) + * @var \Doctrine\DBAL\Schema\Column[] */ public $addedColumns; /** - * All changed fields + * All changed fields. * - * @var array(string=>Column) + * @var \Doctrine\DBAL\Schema\Column[] */ public $changedColumns = array(); /** - * All removed fields + * All removed fields. * - * @var array(string=>Column) + * @var \Doctrine\DBAL\Schema\Column[] */ public $removedColumns = array(); /** * Columns that are only renamed from key to column instance name. * - * @var array(string=>Column) + * @var \Doctrine\DBAL\Schema\Column[] */ public $renamedColumns = array(); /** - * All added indexes + * All added indexes. * - * @var array(string=>Index) + * @var \Doctrine\DBAL\Schema\Index[] */ public $addedIndexes = array(); /** - * All changed indexes + * All changed indexes. * - * @var array(string=>Index) + * @var \Doctrine\DBAL\Schema\Index[] */ public $changedIndexes = array(); /** * All removed indexes * - * @var array(string=>bool) + * @var \Doctrine\DBAL\Schema\Index[] */ public $removedIndexes = array(); /** * All added foreign key definitions * - * @var array + * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ public $addedForeignKeys = array(); /** * All changed foreign keys * - * @var array + * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ public $changedForeignKeys = array(); /** * All removed foreign keys * - * @var array + * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[] */ public $removedForeignKeys = array(); + /** + * @var \Doctrine\DBAL\Schema\Table + */ + public $fromTable; + /** * Constructs an TableDiff object. * - * @param array(string=>Column) $addedColumns - * @param array(string=>Column) $changedColumns - * @param array(string=>bool) $removedColumns - * @param array(string=>Index) $addedIndexes - * @param array(string=>Index) $changedIndexes - * @param array(string=>bool) $removedIndexes + * @param string $tableName + * @param \Doctrine\DBAL\Schema\Column[] $addedColumns + * @param \Doctrine\DBAL\Schema\Column[] $changedColumns + * @param \Doctrine\DBAL\Schema\Column[] $removedColumns + * @param \Doctrine\DBAL\Schema\Index[] $addedIndexes + * @param \Doctrine\DBAL\Schema\Index[] $changedIndexes + * @param \Doctrine\DBAL\Schema\Index[] $removedIndexes + * @param \Doctrine\DBAL\Schema\Table|null $fromTable */ public function __construct($tableName, $addedColumns = array(), $changedColumns = array(), $removedColumns = array(), $addedIndexes = array(), - $changedIndexes = array(), $removedIndexes = array()) + $changedIndexes = array(), $removedIndexes = array(), Table $fromTable = null) { $this->name = $tableName; $this->addedColumns = $addedColumns; @@ -132,5 +136,6 @@ class TableDiff $this->addedIndexes = $addedIndexes; $this->changedIndexes = $changedIndexes; $this->removedIndexes = $removedIndexes; + $this->fromTable = $fromTable; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/View.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/View.php old mode 100755 new mode 100644 index 8283d07d70..0ef7d305bb --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/View.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/View.php @@ -1,7 +1,5 @@ . -*/ + */ namespace Doctrine\DBAL\Schema; /** - * Representation of a Database View + * Representation of a Database View. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 1.0 - * @version $Revision$ - * @author Benjamin Eberlei + * @link www.doctrine-project.org + * @since 1.0 + * @author Benjamin Eberlei */ class View extends AbstractAsset { @@ -37,6 +33,10 @@ class View extends AbstractAsset */ private $_sql; + /** + * @param string $name + * @param string $sql + */ public function __construct($name, $sql) { $this->_setName($name); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php new file mode 100644 index 0000000000..af1b63ea7b --- /dev/null +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php @@ -0,0 +1,79 @@ +. + */ + +namespace Doctrine\DBAL\Schema\Visitor; + +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Sequence; +use Doctrine\DBAL\Schema\Index; + +/** + * Abstract Visitor with empty methods for easy extension. + */ +class AbstractVisitor implements Visitor +{ + /** + * @param \Doctrine\DBAL\Schema\Schema $schema + */ + public function acceptSchema(Schema $schema) + { + } + + /** + * @param \Doctrine\DBAL\Schema\Table $table + */ + public function acceptTable(Table $table) + { + } + + /** + * @param \Doctrine\DBAL\Schema\Table $table + * @param \Doctrine\DBAL\Schema\Column $column + */ + public function acceptColumn(Table $table, Column $column) + { + } + + /** + * @param \Doctrine\DBAL\Schema\Table $localTable + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $fkConstraint + */ + public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) + { + } + + /** + * @param \Doctrine\DBAL\Schema\Table $table + * @param \Doctrine\DBAL\Schema\Index $index + */ + public function acceptIndex(Table $table, Index $index) + { + } + + /** + * @param \Doctrine\DBAL\Schema\Sequence $sequence + */ + public function acceptSequence(Sequence $sequence) + { + } +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php old mode 100755 new mode 100644 index 51228c1829..ad28e6483d --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php @@ -1,7 +1,5 @@ _platform = $platform; + $this->platform = $platform; } /** - * @param Schema $schema - */ - public function acceptSchema(Schema $schema) - { - - } - - /** - * Generate DDL Statements to create the accepted table with all its dependencies. - * - * @param Table $table + * {@inheritdoc} */ public function acceptTable(Table $table) { $namespace = $this->getNamespace($table); - $this->_createTableQueries[$namespace] = array_merge( - $this->_createTableQueries[$namespace], - $this->_platform->getCreateTableSQL($table) + $this->createTableQueries[$namespace] = array_merge( + $this->createTableQueries[$namespace], + $this->platform->getCreateTableSQL($table) ); } - public function acceptColumn(Table $table, Column $column) - { - - } - /** - * @param Table $localTable - * @param ForeignKeyConstraint $fkConstraint + * {@inheritdoc} */ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) { $namespace = $this->getNamespace($localTable); - if ($this->_platform->supportsForeignKeyConstraints()) { - $this->_createFkConstraintQueries[$namespace] = array_merge( - $this->_createFkConstraintQueries[$namespace], - (array) $this->_platform->getCreateForeignKeySQL( + if ($this->platform->supportsForeignKeyConstraints()) { + $this->createFkConstraintQueries[$namespace] = array_merge( + $this->createFkConstraintQueries[$namespace], + (array) $this->platform->getCreateForeignKeySQL( $fkConstraint, $localTable ) ); @@ -108,71 +86,72 @@ class CreateSchemaSqlCollector implements Visitor } /** - * @param Table $table - * @param Index $index - */ - public function acceptIndex(Table $table, Index $index) - { - - } - - /** - * @param Sequence $sequence + * {@inheritdoc} */ public function acceptSequence(Sequence $sequence) { $namespace = $this->getNamespace($sequence); - $this->_createSequenceQueries[$namespace] = array_merge( - $this->_createSequenceQueries[$namespace], - (array)$this->_platform->getCreateSequenceSQL($sequence) + $this->createSequenceQueries[$namespace] = array_merge( + $this->createSequenceQueries[$namespace], + (array)$this->platform->getCreateSequenceSQL($sequence) ); } + /** + * @param \Doctrine\DBAL\Schema\AbstractAsset $asset + * + * @return string + */ private function getNamespace($asset) { $namespace = $asset->getNamespaceName() ?: 'default'; - if ( !isset($this->_createTableQueries[$namespace])) { - $this->_createTableQueries[$namespace] = array(); - $this->_createSequenceQueries[$namespace] = array(); - $this->_createFkConstraintQueries[$namespace] = array(); + if ( !isset($this->createTableQueries[$namespace])) { + $this->createTableQueries[$namespace] = array(); + $this->createSequenceQueries[$namespace] = array(); + $this->createFkConstraintQueries[$namespace] = array(); } return $namespace; } /** - * @return array + * @return void */ public function resetQueries() { - $this->_createTableQueries = array(); - $this->_createSequenceQueries = array(); - $this->_createFkConstraintQueries = array(); + $this->createTableQueries = array(); + $this->createSequenceQueries = array(); + $this->createFkConstraintQueries = array(); } /** - * Get all queries collected so far. + * Gets all queries collected so far. * * @return array */ public function getQueries() { $sql = array(); - foreach (array_keys($this->_createTableQueries) as $namespace) { - if ($this->_platform->supportsSchemas()) { + + foreach (array_keys($this->createTableQueries) as $namespace) { + if ($this->platform->supportsSchemas()) { // TODO: Create Schema here } } - foreach ($this->_createTableQueries as $schemaSql) { + + foreach ($this->createTableQueries as $schemaSql) { $sql = array_merge($sql, $schemaSql); } - foreach ($this->_createSequenceQueries as $schemaSql) { + + foreach ($this->createSequenceQueries as $schemaSql) { $sql = array_merge($sql, $schemaSql); } - foreach ($this->_createFkConstraintQueries as $schemaSql) { + + foreach ($this->createFkConstraintQueries as $schemaSql) { $sql = array_merge($sql, $schemaSql); } + return $sql; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php old mode 100755 new mode 100644 index 3d74cb90e1..047ac98e62 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php @@ -1,7 +1,5 @@ + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ -class DropSchemaSqlCollector implements Visitor +class DropSchemaSqlCollector extends AbstractVisitor { /** * @var \SplObjectStorage @@ -57,13 +50,12 @@ class DropSchemaSqlCollector implements Visitor private $tables; /** - * * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ private $platform; /** - * @param AbstractPlatform $platform + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform */ public function __construct(AbstractPlatform $platform) { @@ -72,15 +64,7 @@ class DropSchemaSqlCollector implements Visitor } /** - * @param Schema $schema - */ - public function acceptSchema(Schema $schema) - { - - } - - /** - * @param Table $table + * {@inheritdoc} */ public function acceptTable(Table $table) { @@ -88,16 +72,7 @@ class DropSchemaSqlCollector implements Visitor } /** - * @param Column $column - */ - public function acceptColumn(Table $table, Column $column) - { - - } - - /** - * @param Table $localTable - * @param ForeignKeyConstraint $fkConstraint + * {@inheritdoc} */ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) { @@ -110,16 +85,7 @@ class DropSchemaSqlCollector implements Visitor } /** - * @param Table $table - * @param Index $index - */ - public function acceptIndex(Table $table, Index $index) - { - - } - - /** - * @param Sequence $sequence + * {@inheritdoc} */ public function acceptSequence(Sequence $sequence) { @@ -142,6 +108,7 @@ class DropSchemaSqlCollector implements Visitor public function getQueries() { $sql = array(); + foreach ($this->constraints as $fkConstraint) { $localTable = $this->constraints[$fkConstraint]; $sql[] = $this->platform->getDropForeignKeySQL($fkConstraint, $localTable); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php old mode 100755 new mode 100644 index 8ae69a2fbf..e49afdd0db --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php @@ -1,5 +1,4 @@ output .= $this->createNodeRelation( @@ -51,11 +50,9 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ); } - public function acceptIndex(Table $table, Index $index) - { - - } - + /** + * {@inheritdoc} + */ public function acceptSchema(Schema $schema) { $this->output = 'digraph "' . sha1( mt_rand() ) . '" {' . "\n"; @@ -66,11 +63,9 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor $this->output .= 'sep = .2;' . "\n"; } - public function acceptSequence(Sequence $sequence) - { - - } - + /** + * {@inheritdoc} + */ public function acceptTable(Table $table) { $this->output .= $this->createNode( @@ -82,7 +77,12 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ); } - private function createTableLabel( Table $table ) + /** + * @param \Doctrine\DBAL\Schema\Table $table + * + * @return string + */ + private function createTableLabel(Table $table) { // Start the table $label = '<'; @@ -111,7 +111,13 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor return $label; } - private function createNode( $name, $options ) + /** + * @param string $name + * @param array $options + * + * @return string + */ + private function createNode($name, $options) { $node = $name . " ["; foreach( $options as $key => $value ) @@ -119,10 +125,18 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor $node .= $key . '=' . $value . ' '; } $node .= "]\n"; + return $node; } - private function createNodeRelation( $node1, $node2, $options ) + /** + * @param string $node1 + * @param string $node2 + * @param array $options + * + * @return string + */ + private function createNodeRelation($node1, $node2, $options) { $relation = $node1 . ' -> ' . $node2 . ' ['; foreach( $options as $key => $value ) @@ -130,11 +144,22 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor $relation .= $key . '=' . $value . ' '; } $relation .= "]\n"; + return $relation; } /** - * Write dot language output to a file. This should usually be a *.dot file. + * Get Graphviz Output + * + * @return string + */ + public function getOutput() + { + return $this->output . "}"; + } + + /** + * Writes dot language output to a file. This should usually be a *.dot file. * * You have to convert the output into a viewable format. For example use "neato" on linux systems * and execute: @@ -142,10 +167,11 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor * neato -Tpng -o er.png er.dot * * @param string $filename + * * @return void */ public function write($filename) { - file_put_contents($filename, $this->output . "}"); + file_put_contents($filename, $this->getOutput()); } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php old mode 100755 new mode 100644 index 348b2b7b58..05f52bea2d --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php @@ -19,17 +19,14 @@ namespace Doctrine\DBAL\Schema\Visitor; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\Schema\Table, - Doctrine\DBAL\Schema\Schema, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\ForeignKeyConstraint, - Doctrine\DBAL\Schema\Constraint, - Doctrine\DBAL\Schema\Sequence, - Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Sequence; /** - * Remove assets from a schema that are not in the default namespace. + * Removes assets from a schema that are not in the default namespace. * * Some databases such as MySQL support cross databases joins, but don't * allow to call DDLs to a database from another connected database. @@ -40,17 +37,17 @@ use Doctrine\DBAL\Platforms\AbstractPlatform, * and removes them from the SChema instance. * * @author Benjamin Eberlei - * @since 2.2 + * @since 2.2 */ -class RemoveNamespacedAssets implements Visitor +class RemoveNamespacedAssets extends AbstractVisitor { /** - * @var Schema + * @var \Doctrine\DBAL\Schema\Schema */ private $schema; /** - * @param Schema $schema + * {@inheritdoc} */ public function acceptSchema(Schema $schema) { @@ -58,7 +55,7 @@ class RemoveNamespacedAssets implements Visitor } /** - * @param Table $table + * {@inheritdoc} */ public function acceptTable(Table $table) { @@ -66,8 +63,9 @@ class RemoveNamespacedAssets implements Visitor $this->schema->dropTable($table->getName()); } } + /** - * @param Sequence $sequence + * {@inheritdoc} */ public function acceptSequence(Sequence $sequence) { @@ -77,15 +75,7 @@ class RemoveNamespacedAssets implements Visitor } /** - * @param Column $column - */ - public function acceptColumn(Table $table, Column $column) - { - } - - /** - * @param Table $localTable - * @param ForeignKeyConstraint $fkConstraint + * {@inheritdoc} */ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) { @@ -102,12 +92,4 @@ class RemoveNamespacedAssets implements Visitor $localTable->removeForeignKey($fkConstraint->getName()); } } - - /** - * @param Table $table - * @param Index $index - */ - public function acceptIndex(Table $table, Index $index) - { - } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php new file mode 100644 index 0000000000..b139aa22e7 --- /dev/null +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php @@ -0,0 +1,84 @@ +. + */ + +namespace Doctrine\DBAL\Schema\Visitor; + +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Sequence; +use Doctrine\DBAL\Schema\SchemaException; + +/** + * Visit a SchemaDiff. + * + * @link www.doctrine-project.org + * @since 2.4 + * @author Benjamin Eberlei + */ +interface SchemaDiffVisitor +{ + /** + * Visit an orphaned foreign key whose table was deleted. + * + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey + */ + function visitOrphanedForeignKey(ForeignKeyConstraint $foreignKey); + + /** + * Visit a sequence that has changed. + * + * @param \Doctrine\DBAL\Schema\Sequence $sequence + */ + function visitChangedSequence(Sequence $sequence); + + /** + * Visit a sequence that has been removed. + * + * @param \Doctrine\DBAL\Schema\Sequence $sequence + */ + function visitRemovedSequence(Sequence $sequence); + + /** + * @param \Doctrine\DBAL\Schema\Sequence $sequence + */ + function visitNewSequence(Sequence $sequence); + + /** + * @param \Doctrine\DBAL\Schema\Table $table + */ + function visitNewTable(Table $table); + + /** + * @param \Doctrine\DBAL\Schema\Table $table + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey + */ + function visitNewTableForeignKey(Table $table, ForeignKeyConstraint $foreignKey); + + /** + * @param \Doctrine\DBAL\Schema\Table $table + */ + function visitRemovedTable(Table $table); + + /** + * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff + */ + function visitChangedTable(TableDiff $tableDiff); +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Visitor.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Visitor.php old mode 100755 new mode 100644 index 45eff81992..9bd5528c7d --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Visitor.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Visitor/Visitor.php @@ -1,7 +1,5 @@ + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei */ interface Visitor { /** - * @param Schema $schema + * @param \Doctrine\DBAL\Schema\Schema $schema + * + * @return void */ public function acceptSchema(Schema $schema); /** - * @param Table $table + * @param \Doctrine\DBAL\Schema\Table $table + * + * @return void */ public function acceptTable(Table $table); /** - * @param Column $column + * @param \Doctrine\DBAL\Schema\Table $table + * @param \Doctrine\DBAL\Schema\Column $column + * + * @return void */ public function acceptColumn(Table $table, Column $column); /** - * @param Table $localTable - * @param ForeignKeyConstraint $fkConstraint + * @param \Doctrine\DBAL\Schema\Table $localTable + * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $fkConstraint + * + * @return void */ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint); /** - * @param Table $table - * @param Index $index + * @param \Doctrine\DBAL\Schema\Table $table + * @param \Doctrine\DBAL\Schema\Index $index + * + * @return void */ public function acceptIndex(Table $table, Index $index); /** - * @param Sequence $sequence + * @param \Doctrine\DBAL\Schema\Sequence $sequence + * + * @return void */ public function acceptSequence(Sequence $sequence); } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php old mode 100755 new mode 100644 index 6453e63831..6048e814c3 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php @@ -72,7 +72,7 @@ class PoolingShardConnection extends Connection private $activeConnections; /** - * @var int + * @var integer */ private $activeShardId; @@ -82,10 +82,13 @@ class PoolingShardConnection extends Connection private $connections; /** - * @var ShardManager + * @param array $params + * @param \Doctrine\DBAL\Driver $driver + * @param \Doctrine\DBAL\Configuration $config + * @param \Doctrine\Common\EventManager $eventManager + * + * @throws \InvalidArgumentException */ - private $shardManager; - public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) { if ( !isset($params['global']) || !isset($params['shards'])) { @@ -108,7 +111,7 @@ class PoolingShardConnection extends Connection foreach ($params['shards'] as $shard) { if ( ! isset($shard['id'])) { - throw new \InvalidArgumentException("Missing 'id' for one configured shard. Please specificy a unique shard-id."); + throw new \InvalidArgumentException("Missing 'id' for one configured shard. Please specify a unique shard-id."); } if ( !is_numeric($shard['id']) || $shard['id'] < 1) { @@ -126,10 +129,13 @@ class PoolingShardConnection extends Connection } /** - * Connect to a given shard + * Connects to a given shard. * * @param mixed $shardId - * @return bool + * + * @return boolean + * + * @throws \Doctrine\DBAL\Sharding\ShardingException */ public function connect($shardId = null) { @@ -155,19 +161,19 @@ class PoolingShardConnection extends Connection $this->_conn = $this->activeConnections[$this->activeShardId] = $this->connectTo($this->activeShardId); if ($this->_eventManager->hasListeners(Events::postConnect)) { - $eventArgs = new Event\ConnectionEventArgs($this); + $eventArgs = new \Doctrine\DBAL\Event\ConnectionEventArgs($this); $this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs); } return true; } - /** - * Connect to a specific connection + * Connects to a specific connection. * - * @param string $shardId - * @return Driver + * @param string $shardId + * + * @return \Doctrine\DBAL\Driver\Connection */ protected function connectTo($shardId) { @@ -183,6 +189,11 @@ class PoolingShardConnection extends Connection return $this->_driver->connect($connectionParams, $user, $password, $driverOptions); } + /** + * @param string|null $shardId + * + * @return boolean + */ public function isConnected($shardId = null) { if ($shardId === null) { @@ -192,10 +203,12 @@ class PoolingShardConnection extends Connection return isset($this->activeConnections[$shardId]); } + /** + * @return void + */ public function close() { $this->_conn = null; $this->activeConnections = null; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php old mode 100755 new mode 100644 index 6f6c5d2c2b..d4bdee80fc --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php @@ -19,8 +19,6 @@ namespace Doctrine\DBAL\Sharding; -use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser; - /** * Shard Manager for the Connection Pooling Shard Strategy * @@ -28,10 +26,24 @@ use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser; */ class PoolingShardManager implements ShardManager { + /** + * @var \Doctrine\DBAL\Sharding\PoolingShardConnection + */ private $conn; + + /** + * @var \Doctrine\DBAL\Sharding\ShardChoser\ShardChoser + */ private $choser; + + /** + * @var string|null + */ private $currentDistributionValue; + /** + * @param \Doctrine\DBAL\Sharding\PoolingShardConnection $conn + */ public function __construct(PoolingShardConnection $conn) { $params = $conn->getParams(); @@ -39,12 +51,20 @@ class PoolingShardManager implements ShardManager $this->choser = $params['shardChoser']; } + /** + * @return void + */ public function selectGlobal() { $this->conn->connect(0); $this->currentDistributionValue = null; } + /** + * @param string $distributionValue + * + * @return void + */ public function selectShard($distributionValue) { $shardId = $this->choser->pickShard($distributionValue, $this->conn); @@ -52,11 +72,17 @@ class PoolingShardManager implements ShardManager $this->currentDistributionValue = $distributionValue; } + /** + * @return string|null + */ public function getCurrentDistributionValue() { return $this->currentDistributionValue; } + /** + * @return array + */ public function getShards() { $params = $this->conn->getParams(); @@ -69,6 +95,15 @@ class PoolingShardManager implements ShardManager return $shards; } + /** + * @param string $sql + * @param array $params + * @param array $types + * + * @return array + * + * @throws \RuntimeException + */ public function queryAll($sql, array $params, array $types) { $shards = $this->getShards(); @@ -80,7 +115,7 @@ class PoolingShardManager implements ShardManager $oldDistribution = $this->getCurrentDistributionValue(); foreach ($shards as $shard) { - $this->selectShard($shard['id']); + $this->conn->connect($shard['id']); foreach ($this->conn->fetchAll($sql, $params, $types) as $row) { $result[] = $row; } @@ -95,4 +130,3 @@ class PoolingShardManager implements ShardManager return $result; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php old mode 100755 new mode 100644 index 4001379ff7..564c54b69a --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php @@ -24,15 +24,16 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Schema\Synchronizer\AbstractSchemaSynchronizer; -use Doctrine\DBAL\Sharding\SingleDatabaseSynchronizer; +use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer; +use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer; /** - * SQL Azure Schema Synchronizer + * SQL Azure Schema Synchronizer. * * Will iterate over all shards when performing schema operations. This is done * by partitioning the passed schema into subschemas for the federation and the * global database and then applying the operations step by step using the - * {@see \Doctrine\DBAL\Sharding\SingleDatabaseSynchronizer}. + * {@see \Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer}. * * @author Benjamin Eberlei */ @@ -41,17 +42,21 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer const FEDERATION_TABLE_FEDERATED = 'azure.federated'; const FEDERATION_DISTRIBUTION_NAME = 'azure.federatedOnDistributionName'; - /** - * @var SQLAzureShardManager + * @var \Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager */ private $shardManager; /** - * @var SchemaSynchronizer + * @var \Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer */ private $synchronizer; + /** + * @param \Doctrine\DBAL\Connection $conn + * @param \Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager $shardManager + * @param \Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer|null $sync + */ public function __construct(Connection $conn, SQLAzureShardManager $shardManager, SchemaSynchronizer $sync = null) { parent::__construct($conn); @@ -60,10 +65,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } /** - * Get the SQL statements that can be executed to create the schema. - * - * @param Schema $createSchema - * @return array + * {@inheritdoc} */ public function getCreateSchema(Schema $createSchema) { @@ -92,11 +94,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } /** - * Get the SQL Statements to update given schema with the underlying db. - * - * @param Schema $toSchema - * @param bool $noDrops - * @return array + * {@inheritdoc} */ public function getUpdateSchema(Schema $toSchema, $noDrops = false) { @@ -106,10 +104,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } /** - * Get the SQL Statements to drop the given schema from underlying db. - * - * @param Schema $dropSchema - * @return array + * {@inheritdoc} */ public function getDropSchema(Schema $dropSchema) { @@ -119,10 +114,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } /** - * Create the Schema - * - * @param Schema $createSchema - * @return void + * {@inheritdoc} */ public function createSchema(Schema $createSchema) { @@ -130,10 +122,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } /** - * Update the Schema to new schema version. - * - * @param Schema $toSchema - * @return void + * {@inheritdoc} */ public function updateSchema(Schema $toSchema, $noDrops = false) { @@ -141,10 +130,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } /** - * Drop the given database schema from the underlying db. - * - * @param Schema $dropSchema - * @return void + * {@inheritdoc} */ public function dropSchema(Schema $dropSchema) { @@ -152,9 +138,7 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } /** - * Get the SQL statements to drop all schema assets from underlying db. - * - * @return array + * {@inheritdoc} */ public function getDropAllSchema() { @@ -185,15 +169,18 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } /** - * Drop all assets from the underyling db. - * - * @return void + * {@inheritdoc} */ public function dropAllSchema() { $this->processSqlSafely($this->getDropAllSchema()); } + /** + * @param \Doctrine\DBAL\Schema\Schema $schema + * + * @return array + */ private function partitionSchema(Schema $schema) { return array( @@ -202,17 +189,25 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer ); } + /** + * @param \Doctrine\DBAL\Schema\Schema $schema + * @param boolean $isFederation + * + * @return \Doctrine\DBAL\Schema\Schema + * + * @throws \RuntimeException + */ private function extractSchemaFederation(Schema $schema, $isFederation) { - $partionedSchema = clone $schema; + $partitionedSchema = clone $schema; - foreach ($partionedSchema->getTables() as $table) { + foreach ($partitionedSchema->getTables() as $table) { if ($isFederation) { $table->addOption(self::FEDERATION_DISTRIBUTION_NAME, $this->shardManager->getDistributionKey()); } if ( $table->hasOption(self::FEDERATION_TABLE_FEDERATED) !== $isFederation) { - $partionedSchema->dropTable($table->getName()); + $partitionedSchema->dropTable($table->getName()); } else { foreach ($table->getForeignKeys() as $fk) { $foreignTable = $schema->getTable($fk->getForeignTableName()); @@ -223,16 +218,17 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer } } - return $partionedSchema; + return $partitionedSchema; } /** * Work on the Global/Federation based on currently existing shards and - * perform the given operation on the underyling schema synchronizer given - * the different partioned schema instances. + * perform the given operation on the underlying schema synchronizer given + * the different partitioned schema instances. + * + * @param \Doctrine\DBAL\Schema\Schema $schema + * @param \Closure $operation * - * @param Schema $schema - * @param Closure $operation * @return array */ private function work(Schema $schema, \Closure $operation) @@ -264,6 +260,9 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer return $sql; } + /** + * @return string + */ private function getFederationTypeDefaultValue() { $federationType = Type::getType($this->shardManager->getDistributionType()); @@ -284,6 +283,9 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer return $defaultValue; } + /** + * @return string + */ private function getCreateFederationStatement() { $federationType = Type::getType($this->shardManager->getDistributionType()); @@ -293,4 +295,3 @@ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer "CREATE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " " . $federationTypeSql ." RANGE)"; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php old mode 100755 new mode 100644 index 80ca3d928a..c343981d0a --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php @@ -37,7 +37,7 @@ class SQLAzureShardManager implements ShardManager private $federationName; /** - * @var bool + * @var boolean */ private $filteringEnabled; @@ -52,7 +52,7 @@ class SQLAzureShardManager implements ShardManager private $distributionType; /** - * @var Connection + * @var \Doctrine\DBAL\Connection */ private $conn; @@ -62,7 +62,9 @@ class SQLAzureShardManager implements ShardManager private $currentDistributionValue; /** - * @param Connection $conn + * @param \Doctrine\DBAL\Connection $conn + * + * @throws \Doctrine\DBAL\Sharding\ShardingException */ public function __construct(Connection $conn) { @@ -88,7 +90,7 @@ class SQLAzureShardManager implements ShardManager } /** - * Get name of the federation + * Gets the name of the federation. * * @return string */ @@ -98,7 +100,7 @@ class SQLAzureShardManager implements ShardManager } /** - * Get the distribution key + * Gets the distribution key. * * @return string */ @@ -108,7 +110,7 @@ class SQLAzureShardManager implements ShardManager } /** - * Get the Doctrine Type name used for the distribution + * Gets the Doctrine Type name used for the distribution. * * @return string */ @@ -118,9 +120,10 @@ class SQLAzureShardManager implements ShardManager } /** - * Enabled/Disable filtering on the fly. + * Sets Enabled/Disable filtering on the fly. + * + * @param boolean $flag * - * @param bool $flag * @return void */ public function setFilteringEnabled($flag) @@ -221,9 +224,11 @@ class SQLAzureShardManager implements ShardManager } /** - * Split Federation at a given distribution value. + * Splits Federation at a given distribution value. * * @param mixed $splitDistributionValue + * + * @return void */ public function splitFederation($splitDistributionValue) { @@ -235,4 +240,3 @@ class SQLAzureShardManager implements ShardManager $this->conn->exec($sql); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php old mode 100755 new mode 100644 index 2b2b4578d1..ae327a4f7f --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php @@ -19,14 +19,13 @@ namespace Doctrine\DBAL\Sharding\SQLAzure\Schema; -use Doctrine\DBAL\Schema\Visitor\Visitor, - Doctrine\DBAL\Schema\Table, - Doctrine\DBAL\Schema\Schema, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\ForeignKeyConstraint, - Doctrine\DBAL\Schema\Constraint, - Doctrine\DBAL\Schema\Sequence, - Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\Visitor\Visitor; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Sequence; +use Doctrine\DBAL\Schema\Index; /** * Converts a single tenant schema into a multi-tenant schema for SQL Azure @@ -74,6 +73,11 @@ class MultiTenantVisitor implements Visitor */ private $distributionName; + /** + * @param array $excludedTables + * @param string $tenantColumnName + * @param string|null $distributionName + */ public function __construct(array $excludedTables = array(), $tenantColumnName = 'tenant_id', $distributionName = null) { $this->excludedTables = $excludedTables; @@ -82,7 +86,7 @@ class MultiTenantVisitor implements Visitor } /** - * @param Table $table + * {@inheritdoc} */ public function acceptTable(Table $table) { @@ -109,6 +113,13 @@ class MultiTenantVisitor implements Visitor } } + /** + * @param \Doctrine\DBAL\Schema\Table $table + * + * @return \Doctrine\DBAL\Schema\Index + * + * @throws \RuntimeException + */ private function getClusteredIndex($table) { foreach ($table->getIndexes() as $index) { @@ -122,40 +133,37 @@ class MultiTenantVisitor implements Visitor } /** - * @param Schema $schema + * {@inheritdoc} */ public function acceptSchema(Schema $schema) { } /** - * @param Column $column + * {@inheritdoc} */ public function acceptColumn(Table $table, Column $column) { } /** - * @param Table $localTable - * @param ForeignKeyConstraint $fkConstraint + * {@inheritdoc} */ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) { } /** - * @param Table $table - * @param Index $index + * {@inheritdoc} */ public function acceptIndex(Table $table, Index $index) { } /** - * @param Sequence $sequence + * {@inheritdoc} */ public function acceptSequence(Sequence $sequence) { } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php old mode 100755 new mode 100644 index c6cdabfb4c..f1d51b8c95 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php @@ -29,9 +29,11 @@ use Doctrine\DBAL\Sharding\PoolingShardConnection; */ class MultiTenantShardChoser implements ShardChoser { + /** + * {@inheritdoc} + */ public function pickShard($distributionValue, PoolingShardConnection $conn) { return $distributionValue; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php old mode 100755 new mode 100644 index 2aa9f74ea7..a7b85a66bb --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php @@ -30,12 +30,12 @@ use Doctrine\DBAL\Sharding\PoolingShardConnection; interface ShardChoser { /** - * Pick a shard for the given distribution value + * Picks a shard for the given distribution value. * - * @param string $distributionValue - * @param PoolingShardConnection $conn - * @return int + * @param string $distributionValue + * @param \Doctrine\DBAL\Sharding\PoolingShardConnection $conn + * + * @return integer */ function pickShard($distributionValue, PoolingShardConnection $conn); } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardManager.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardManager.php old mode 100755 new mode 100644 index aa67992a30..b742793b81 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardManager.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardManager.php @@ -19,8 +19,6 @@ namespace Doctrine\DBAL\Sharding; -use Doctrine\DBAL\Connection; - /** * Sharding Manager gives access to APIs to implementing sharding on top of * Doctrine\DBAL\Connection instances. @@ -34,7 +32,7 @@ use Doctrine\DBAL\Connection; * necessary data for all use-cases. Switching between shards should be done with * caution, especially if lazy loading is implemented. Any query is always * executed against the last shard that was selected. If a query is created for - * a shard Y but then a shard X is selected when its actually excecuted you + * a shard Y but then a shard X is selected when its actually executed you * will hit the wrong shard. * * @author Benjamin Eberlei @@ -42,7 +40,7 @@ use Doctrine\DBAL\Connection; interface ShardManager { /** - * Select global database with global data. + * Selects global database with global data. * * This is the default database that is connected when no shard is * selected. @@ -52,44 +50,44 @@ interface ShardManager function selectGlobal(); /** - * SELECT queries after this statement will be issued against the selected - * shard. + * Selects the shard against which the queries after this statement will be issued. + * + * @param string $distributionValue * - * @throws ShardingException If no value is passed as shard identifier. - * @param mixed $distributionValue - * @param array $options * @return void + * + * @throws \Doctrine\DBAL\Sharding\ShardingException If no value is passed as shard identifier. */ function selectShard($distributionValue); /** - * Get the distribution value currently used for sharding. + * Gets the distribution value currently used for sharding. * * @return string */ function getCurrentDistributionValue(); /** - * Get information about the amount of shards and other details. + * Gets information about the amount of shards and other details. * - * Format is implementation specific, each shard is one element and has a - * 'name' attribute at least. + * Format is implementation specific, each shard is one element and has an + * 'id' attribute at least. * * @return array */ function getShards(); /** - * Query all shards in undefined order and return the results appended to + * Queries all shards in undefined order and return the results appended to * each other. Restore the previous distribution value after execution. * - * Using {@link Connection::fetchAll} to retrieve rows internally. + * Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally. * * @param string $sql - * @param array $params - * @param array $types + * @param array $params + * @param array $types + * * @return array */ function queryAll($sql, array $params, array $types); } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardingException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardingException.php old mode 100755 new mode 100644 index 06dd1695af..407bf847d4 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardingException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Sharding/ShardingException.php @@ -28,34 +28,51 @@ use Doctrine\DBAL\DBALException; */ class ShardingException extends DBALException { + /** + * @return \Doctrine\DBAL\Sharding\ShardingException + */ static public function notImplemented() { return new self("This functionality is not implemented with this sharding provider.", 1331557937); } + /** + * @return \Doctrine\DBAL\Sharding\ShardingException + */ static public function missingDefaultFederationName() { return new self("SQLAzure requires a federation name to be set during sharding configuration.", 1332141280); } + /** + * @return \Doctrine\DBAL\Sharding\ShardingException + */ static public function missingDefaultDistributionKey() { return new self("SQLAzure requires a distribution key to be set during sharding configuration.", 1332141329); } + /** + * @return \Doctrine\DBAL\Sharding\ShardingException + */ static public function activeTransaction() { return new self("Cannot switch shard during an active transaction.", 1332141766); } + /** + * @return \Doctrine\DBAL\Sharding\ShardingException + */ static public function noShardDistributionValue() { return new self("You have to specify a string or integer as shard distribution value.", 1332142103); } + /** + * @return \Doctrine\DBAL\Sharding\ShardingException + */ static public function missingDistributionType() { return new self("You have to specify a sharding distribution type such as 'integer', 'string', 'guid'."); } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php old mode 100755 new mode 100644 index 1bf9d7427e..7943d6c9d5 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php @@ -1,7 +1,5 @@ Statement for the given SQL and Connection. * - * @param string $sql The SQL of the statement. - * @param \Doctrine\DBAL\Connection The connection on which the statement should be executed. + * @param string $sql The SQL of the statement. + * @param \Doctrine\DBAL\Connection $conn The connection on which the statement should be executed. */ public function __construct($sql, Connection $conn) { @@ -81,9 +96,10 @@ class Statement implements \IteratorAggregate, DriverStatement * type and the value undergoes the conversion routines of the mapping type before * being bound. * - * @param string $name The name or position of the parameter. - * @param mixed $value The value of the parameter. - * @param mixed $type Either a PDO binding type or a DBAL mapping type name or instance. + * @param string $name The name or position of the parameter. + * @param mixed $value The value of the parameter. + * @param mixed $type Either a PDO binding type or a DBAL mapping type name or instance. + * * @return boolean TRUE on success, FALSE on failure. */ public function bindValue($name, $value, $type = null) @@ -100,6 +116,7 @@ class Statement implements \IteratorAggregate, DriverStatement } else { $bindingType = $type; // PDO::PARAM_* constants } + return $this->stmt->bindValue($name, $value, $bindingType); } else { return $this->stmt->bindValue($name, $value); @@ -111,24 +128,34 @@ class Statement implements \IteratorAggregate, DriverStatement * * Binding a parameter by reference does not support DBAL mapping types. * - * @param string $name The name or position of the parameter. - * @param mixed $var The reference to the variable to bind - * @param integer $type The PDO binding type. + * @param string $name The name or position of the parameter. + * @param mixed $var The reference to the variable to bind. + * @param integer $type The PDO binding type. + * @param integer|null $length Must be specified when using an OUT bind + * so that PHP allocates enough memory to hold the returned value. + * * @return boolean TRUE on success, FALSE on failure. */ public function bindParam($name, &$var, $type = PDO::PARAM_STR, $length = null) { - return $this->stmt->bindParam($name, $var, $type, $length ); + return $this->stmt->bindParam($name, $var, $type, $length); } /** * Executes the statement with the currently bound parameters. * - * @param array $params + * @param array|null $params + * * @return boolean TRUE on success, FALSE on failure. + * + * @throws \Doctrine\DBAL\DBALException */ public function execute($params = null) { + if (is_array($params)) { + $this->params = $params; + } + $logger = $this->conn->getConfiguration()->getSQLLogger(); if ($logger) { $logger->startQuery($this->sql, $this->params, $this->types); @@ -145,6 +172,7 @@ class Statement implements \IteratorAggregate, DriverStatement } $this->params = array(); $this->types = array(); + return $stmt; } @@ -188,6 +216,9 @@ class Statement implements \IteratorAggregate, DriverStatement return $this->stmt->errorInfo(); } + /** + * {@inheritdoc} + */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { if ($arg2 === null) { @@ -199,6 +230,11 @@ class Statement implements \IteratorAggregate, DriverStatement return $this->stmt->setFetchMode($fetchMode, $arg2, $arg3); } + /** + * Required by interface IteratorAggregate. + * + * {@inheritdoc} + */ public function getIterator() { return $this->stmt; @@ -207,7 +243,8 @@ class Statement implements \IteratorAggregate, DriverStatement /** * Fetches the next row from a result set. * - * @param integer $fetchMode + * @param integer|null $fetchMode + * * @return mixed The return value of this function on success depends on the fetch type. * In all cases, FALSE is returned on failure. */ @@ -219,8 +256,9 @@ class Statement implements \IteratorAggregate, DriverStatement /** * Returns an array containing all of the result set rows. * - * @param integer $fetchMode - * @param mixed $fetchArgument + * @param integer|null $fetchMode + * @param mixed $fetchArgument + * * @return array An array containing all of the remaining rows in the result set. */ public function fetchAll($fetchMode = null, $fetchArgument = 0) @@ -228,6 +266,7 @@ class Statement implements \IteratorAggregate, DriverStatement if ($fetchArgument !== 0) { return $this->stmt->fetchAll($fetchMode, $fetchArgument); } + return $this->stmt->fetchAll($fetchMode); } @@ -235,6 +274,7 @@ class Statement implements \IteratorAggregate, DriverStatement * Returns a single column from the next row of a result set. * * @param integer $columnIndex + * * @return mixed A single column from the next row of a result set or FALSE if there are no more rows. */ public function fetchColumn($columnIndex = 0) diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php old mode 100755 new mode 100644 index 6b2b8c275a..18744315ff --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php @@ -19,25 +19,26 @@ namespace Doctrine\DBAL\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * Task for executing arbitrary SQL that can come from a file or directly from * the command line. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ -class ImportCommand extends Console\Command\Command +class ImportCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -56,9 +57,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $conn = $this->getHelper('db')->getConnection(); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php old mode 100755 new mode 100644 index 7b1bb1c424..846acb82ba --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -17,32 +17,39 @@ * . */ - namespace Doctrine\DBAL\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console\Command\Command, - Symfony\Component\Console\Input\InputInterface, - Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator; class ReservedWordsCommand extends Command { + /** + * @var array + */ private $keywordListClasses = array( - 'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords', - 'mssql' => 'Doctrine\DBAL\Platforms\Keywords\MsSQLKeywords', - 'sqlite' => 'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords', - 'pgsql' => 'Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords', - 'oracle' => 'Doctrine\DBAL\Platforms\Keywords\OracleKeywords', - 'db2' => 'Doctrine\DBAL\Platforms\Keywords\DB2Keywords', + 'mysql' => 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords', + 'sqlserver' => 'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords', + 'sqlserver2005' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords', + 'sqlserver2008' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords', + 'sqlserver2012' => 'Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords', + 'sqlite' => 'Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords', + 'pgsql' => 'Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords', + 'oracle' => 'Doctrine\DBAL\Platforms\Keywords\OracleKeywords', + 'db2' => 'Doctrine\DBAL\Platforms\Keywords\DB2Keywords', ); /** - * If you want to add or replace a keywords list use this command + * If you want to add or replace a keywords list use this command. * * @param string $name * @param string $class + * + * @return void */ public function setKeywordListClass($name, $class) { @@ -50,7 +57,7 @@ class ReservedWordsCommand extends Command } /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -66,7 +73,7 @@ class ReservedWordsCommand extends Command Checks if the current database contains tables and columns with names that are identifiers in this dialect or in other SQL dialects. -By default SQLite, MySQL, PostgreSQL, MsSQL and Oracle +By default SQLite, MySQL, PostgreSQL, Microsoft SQL Server and Oracle keywords are checked: %command.full_name% @@ -82,14 +89,17 @@ The following keyword lists are currently shipped with Doctrine: * pgsql * sqlite * oracle - * mssql + * sqlserver + * sqlserver2005 + * sqlserver2008 + * sqlserver2012 * db2 (Not checked by default) EOT ); } /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -98,7 +108,16 @@ EOT $keywordLists = (array)$input->getOption('list'); if ( ! $keywordLists) { - $keywordLists = array('mysql', 'pgsql', 'sqlite', 'oracle', 'mssql'); + $keywordLists = array( + 'mysql', + 'pgsql', + 'sqlite', + 'oracle', + 'sqlserver', + 'sqlserver2005', + 'sqlserver2008', + 'sqlserver2012' + ); } $keywords = array(); @@ -128,6 +147,8 @@ EOT foreach ($violations as $violation) { $output->write(' - ' . $violation, true); } + + return 1; } } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php old mode 100755 new mode 100644 index b1af34bdb2..b2b2d97004 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -19,26 +19,27 @@ namespace Doctrine\DBAL\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputOption; /** * Task for executing arbitrary SQL that can come from a file or directly from * the command line. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ -class RunSqlCommand extends Console\Command\Command +class RunSqlCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -56,9 +57,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $conn = $this->getHelper('db')->getConnection(); diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php old mode 100755 new mode 100644 index 877cb64fbd..1331c2baea --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.php @@ -1,7 +1,5 @@ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class ConnectionHelper extends Helper { /** - * Doctrine Database Connection - * @var Connection + * The Doctrine database Connection. + * + * @var \Doctrine\DBAL\Connection */ protected $_connection; /** - * Constructor + * Constructor. * - * @param Connection $connection Doctrine Database Connection + * @param \Doctrine\DBAL\Connection $connection The Doctrine database Connection. */ public function __construct(Connection $connection) { @@ -55,9 +52,9 @@ class ConnectionHelper extends Helper } /** - * Retrieves Doctrine Database Connection + * Retrieves the Doctrine database Connection. * - * @return Connection + * @return \Doctrine\DBAL\Connection */ public function getConnection() { @@ -65,7 +62,7 @@ class ConnectionHelper extends Helper } /** - * @see Helper + * {@inheritdoc} */ public function getName() { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php old mode 100755 new mode 100644 index 447f9ee90c..f8c62cb7a9 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php @@ -28,17 +28,27 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; */ class ArrayType extends Type { - public function getSQLDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) + /** + * {@inheritdoc} + */ + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getClobTypeDeclarationSQL($fieldDeclaration); } - public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) + /** + * {@inheritdoc} + */ + public function convertToDatabaseValue($value, AbstractPlatform $platform) { + // @todo 3.0 - $value === null check to save real NULL in database return serialize($value); } - public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) + /** + * {@inheritdoc} + */ + public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; @@ -49,14 +59,21 @@ class ArrayType extends Type if ($val === false && $value != 'b:0;') { throw ConversionException::conversionFailed($value, $this->getName()); } + return $val; } + /** + * {@inheritdoc} + */ public function getName() { return Type::TARRAY; } + /** + * {@inheritdoc} + */ public function requiresSQLCommentHint(AbstractPlatform $platform) { return true; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BigIntType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BigIntType.php old mode 100755 new mode 100644 index 7648bef6a7..ded07ee5f5 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BigIntType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BigIntType.php @@ -1,7 +1,5 @@ getBigIntTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function getBindingType() { return \PDO::PARAM_STR; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BlobType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BlobType.php old mode 100755 new mode 100644 index ff046556d9..7ce033fb97 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BlobType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BlobType.php @@ -22,25 +22,22 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; /** - * Type that maps an SQL BLOB to a PHP resource stream + * Type that maps an SQL BLOB to a PHP resource stream. * * @since 2.2 */ class BlobType extends Type { - /** @override */ + /** + * {@inheritdoc} + */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getBlobTypeDeclarationSQL($fieldDeclaration); } /** - * Converts a value from its database representation to its PHP representation - * of this type. - * - * @param mixed $value The value to convert. - * @param AbstractPlatform $platform The currently used database platform. - * @return mixed The PHP representation of the value. + * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { @@ -59,11 +56,17 @@ class BlobType extends Type return $value; } + /** + * {@inheritdoc} + */ public function getName() { return Type::BLOB; } + /** + * {@inheritdoc} + */ public function getBindingType() { return \PDO::PARAM_LOB; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BooleanType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BooleanType.php old mode 100755 new mode 100644 index f1a968d777..6b101fb560 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BooleanType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/BooleanType.php @@ -1,7 +1,5 @@ getBooleanTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { return $platform->convertBooleans($value); } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { return (null === $value) ? null : (bool) $value; } + /** + * {@inheritdoc} + */ public function getName() { return Type::BOOLEAN; } + /** + * {@inheritdoc} + */ public function getBindingType() { return \PDO::PARAM_BOOL; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ConversionException.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ConversionException.php old mode 100755 new mode 100644 index 3a19d1a4cf..4675101b30 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ConversionException.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ConversionException.php @@ -17,17 +17,15 @@ * . */ - /** - * Conversion Exception is thrown when the database to PHP conversion fails + * Conversion Exception is thrown when the database to PHP conversion fails. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ namespace Doctrine\DBAL\Types; @@ -36,13 +34,15 @@ class ConversionException extends \Doctrine\DBAL\DBALException /** * Thrown when a Database to Doctrine Type Conversion fails. * - * @param string $value - * @param string $toType - * @return ConversionException + * @param string $value + * @param string $toType + * + * @return \Doctrine\DBAL\Types\ConversionException */ static public function conversionFailed($value, $toType) { $value = (strlen($value) > 32) ? substr($value, 0, 20) . "..." : $value; + return new self('Could not convert database value "' . $value . '" to Doctrine Type ' . $toType); } @@ -50,13 +50,16 @@ class ConversionException extends \Doctrine\DBAL\DBALException * Thrown when a Database to Doctrine Type Conversion fails and we can make a statement * about the expected format. * - * @param string $value - * @param string $toType - * @return ConversionException + * @param string $value + * @param string $toType + * @param string $expectedFormat + * + * @return \Doctrine\DBAL\Types\ConversionException */ static public function conversionFailedFormat($value, $toType, $expectedFormat) { $value = (strlen($value) > 32) ? substr($value, 0, 20) . "..." : $value; + return new self( 'Could not convert database value "' . $value . '" to Doctrine Type ' . $toType . '. Expected format: ' . $expectedFormat diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php old mode 100755 new mode 100644 index 06de729ba2..bd6eda10e3 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php @@ -28,22 +28,34 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; */ class DateTimeType extends Type { + /** + * {@inheritdoc} + */ public function getName() { return Type::DATETIME; } + /** + * {@inheritdoc} + */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getDateTimeTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { return ($value !== null) ? $value->format($platform->getDateTimeFormatString()) : null; } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null || $value instanceof \DateTime) { @@ -54,6 +66,7 @@ class DateTimeType extends Type if ( ! $val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString()); } + return $val; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeTzType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeTzType.php old mode 100755 new mode 100644 index e0a786c6d0..7303ff01ca --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeTzType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeTzType.php @@ -17,7 +17,6 @@ * . */ - namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -38,32 +37,43 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; * the offset and re-created from persistence with only the offset, not the original timezone * attached. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 1.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 1.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class DateTimeTzType extends Type { + /** + * {@inheritdoc} + */ public function getName() { return Type::DATETIMETZ; } + /** + * {@inheritdoc} + */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getDateTimeTzTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { return ($value !== null) ? $value->format($platform->getDateTimeTzFormatString()) : null; } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null || $value instanceof \DateTime) { @@ -74,6 +84,7 @@ class DateTimeTzType extends Type if ( ! $val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeTzFormatString()); } + return $val; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateType.php old mode 100755 new mode 100644 index a3f7018154..9d33755863 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateType.php @@ -28,22 +28,34 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; */ class DateType extends Type { + /** + * {@inheritdoc} + */ public function getName() { return Type::DATE; } + /** + * {@inheritdoc} + */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getDateTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { return ($value !== null) ? $value->format($platform->getDateFormatString()) : null; } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null || $value instanceof \DateTime) { @@ -54,6 +66,7 @@ class DateType extends Type if ( ! $val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateFormatString()); } + return $val; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DecimalType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DecimalType.php old mode 100755 new mode 100644 index fd61b53fe9..ceb7d69111 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DecimalType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DecimalType.php @@ -28,16 +28,25 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; */ class DecimalType extends Type { + /** + * {@inheritdoc} + */ public function getName() { return Type::DECIMAL; } + /** + * {@inheritdoc} + */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getDecimalTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { return (null === $value) ? null : $value; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/FloatType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/FloatType.php old mode 100755 new mode 100644 index d02ca0c515..87f9c32ae1 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/FloatType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/FloatType.php @@ -17,22 +17,22 @@ * . */ - namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; class FloatType extends Type { + /** + * {@inheritdoc} + */ public function getName() { return Type::FLOAT; } /** - * @param array $fieldDeclaration - * @param AbstractPlatform $platform - * @return string + * {@inheritdoc} */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { @@ -40,12 +40,7 @@ class FloatType extends Type } /** - * Converts a value from its database representation to its PHP representation - * of this type. - * - * @param mixed $value The value to convert. - * @param AbstractPlatform $platform The currently used database platform. - * @return mixed The PHP representation of the value. + * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/GuidType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/GuidType.php old mode 100755 new mode 100644 index a8251dd334..761d58a8e8 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/GuidType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/GuidType.php @@ -22,21 +22,34 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; /** - * Represents a GUID/UUID datatype (both are actually synomys) in the database. + * Represents a GUID/UUID datatype (both are actually synonyms) in the database. * * @author Benjamin Eberlei - * @since 2.3 + * @since 2.3 */ class GuidType extends StringType { + /** + * {@inheritdoc} + */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getGuidTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function getName() { return Type::GUID; } -} + /** + * {@inheritdoc} + */ + public function requiresSQLCommentHint(AbstractPlatform $platform) + { + return !$platform->hasNativeGuidType(); + } +} diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/IntegerType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/IntegerType.php old mode 100755 new mode 100644 index bac9b3f563..6fe6375ec8 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/IntegerType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/IntegerType.php @@ -1,7 +1,5 @@ getIntegerTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { return (null === $value) ? null : (int) $value; } + /** + * {@inheritdoc} + */ public function getBindingType() { return \PDO::PARAM_INT; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php index ca0055787e..173c8268b4 100755 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/JsonArrayType.php @@ -24,16 +24,22 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; /** * Array Type which can be used to generate json arrays. * - * @since 2.3 + * @since 2.3 * @author Johannes M. Schmitt */ class JsonArrayType extends Type { + /** + * {@inheritdoc} + */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getClobTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { if (null === $value) { @@ -43,6 +49,9 @@ class JsonArrayType extends Type return json_encode($value); } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { @@ -54,11 +63,17 @@ class JsonArrayType extends Type return json_decode($value, true); } + /** + * {@inheritdoc} + */ public function getName() { return Type::JSON_ARRAY; } + /** + * {@inheritdoc} + */ public function requiresSQLCommentHint(AbstractPlatform $platform) { return true; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php old mode 100755 new mode 100644 index 9510d29c24..0b1f87a23c --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ObjectType.php @@ -28,17 +28,26 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; */ class ObjectType extends Type { - public function getSQLDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) + /** + * {@inheritdoc} + */ + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getClobTypeDeclarationSQL($fieldDeclaration); } - public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) + /** + * {@inheritdoc} + */ + public function convertToDatabaseValue($value, AbstractPlatform $platform) { return serialize($value); } - public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) + /** + * {@inheritdoc} + */ + public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; @@ -49,14 +58,21 @@ class ObjectType extends Type if ($val === false && $value !== 'b:0;') { throw ConversionException::conversionFailed($value, $this->getName()); } + return $val; } + /** + * {@inheritdoc} + */ public function getName() { return Type::OBJECT; } + /** + * {@inheritdoc} + */ public function requiresSQLCommentHint(AbstractPlatform $platform) { return true; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php index 719d7f1e73..47c821be4e 100755 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php @@ -1,7 +1,6 @@ */ class SimpleArrayType extends Type { + /** + * {@inheritdoc} + */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getClobTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { if (!$value) { @@ -46,6 +51,9 @@ class SimpleArrayType extends Type return implode(',', $value); } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { @@ -57,11 +65,17 @@ class SimpleArrayType extends Type return explode(',', $value); } + /** + * {@inheritdoc} + */ public function getName() { return Type::SIMPLE_ARRAY; } + /** + * {@inheritdoc} + */ public function requiresSQLCommentHint(AbstractPlatform $platform) { return true; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php old mode 100755 new mode 100644 index 97e9aaff5a..7ebae6ebe2 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SmallIntType.php @@ -1,7 +1,5 @@ getSmallIntTypeDeclarationSQL($fieldDeclaration); } + /** + * {@inheritdoc} + */ public function convertToPHPValue($value, AbstractPlatform $platform) { return (null === $value) ? null : (int) $value; } + /** + * {@inheritdoc} + */ public function getBindingType() { return \PDO::PARAM_INT; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/StringType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/StringType.php old mode 100755 new mode 100644 index 48c76d6a7b..39bd32dbc8 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/StringType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/StringType.php @@ -1,7 +1,5 @@ getVarcharTypeDeclarationSQL($fieldDeclaration); } - /** @override */ + /** + * {@inheritdoc} + */ public function getDefaultLength(AbstractPlatform $platform) { return $platform->getVarcharDefaultLength(); } - /** @override */ + /** + * {@inheritdoc} + */ public function getName() { return Type::STRING; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TextType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TextType.php old mode 100755 new mode 100644 index 98ecbe625d..4055ac88d2 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TextType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TextType.php @@ -1,7 +1,5 @@ getClobTypeDeclarationSQL($fieldDeclaration); } /** - * Converts a value from its database representation to its PHP representation - * of this type. - * - * @param mixed $value The value to convert. - * @param AbstractPlatform $platform The currently used database platform. - * @return mixed The PHP representation of the value. + * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { return (is_resource($value)) ? stream_get_contents($value) : $value; } + /** + * {@inheritdoc} + */ public function getName() { return Type::TEXT; diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TimeType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TimeType.php old mode 100755 new mode 100644 index 8653750fa5..54e740bb4f --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TimeType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TimeType.php @@ -28,6 +28,9 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; */ class TimeType extends Type { + /** + * {@inheritdoc} + */ public function getName() { return Type::TIME; @@ -63,6 +66,7 @@ class TimeType extends Type if ( ! $val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getTimeFormatString()); } + return $val; } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php old mode 100755 new mode 100644 index 29947bef73..73f853fc60 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php @@ -19,8 +19,8 @@ namespace Doctrine\DBAL\Types; -use Doctrine\DBAL\Platforms\AbstractPlatform, - Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\DBALException; /** * The base class for so-called Doctrine mapping types. @@ -29,7 +29,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform, * * @author Roman Borschel * @author Benjamin Eberlei - * @since 2.0 + * @since 2.0 */ abstract class Type { @@ -52,10 +52,18 @@ abstract class Type const FLOAT = 'float'; const GUID = 'guid'; - /** Map of already instantiated type objects. One instance per type (flyweight). */ + /** + * Map of already instantiated type objects. One instance per type (flyweight). + * + * @var array + */ private static $_typeObjects = array(); - /** The map of supported doctrine mapping types. */ + /** + * The map of supported doctrine mapping types. + * + * @var array + */ private static $_typesMap = array( self::TARRAY => 'Doctrine\DBAL\Types\ArrayType', self::SIMPLE_ARRAY => 'Doctrine\DBAL\Types\SimpleArrayType', @@ -77,15 +85,20 @@ abstract class Type self::GUID => 'Doctrine\DBAL\Types\GuidType', ); - /* Prevent instantiation and force use of the factory method. */ - final private function __construct() {} + /** + * Prevents instantiation and forces use of the factory method. + */ + final private function __construct() + { + } /** * Converts a value from its PHP representation to its database representation * of this type. * - * @param mixed $value The value to convert. - * @param AbstractPlatform $platform The currently used database platform. + * @param mixed $value The value to convert. + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The currently used database platform. + * * @return mixed The database representation of the value. */ public function convertToDatabaseValue($value, AbstractPlatform $platform) @@ -97,8 +110,9 @@ abstract class Type * Converts a value from its database representation to its PHP representation * of this type. * - * @param mixed $value The value to convert. - * @param AbstractPlatform $platform The currently used database platform. + * @param mixed $value The value to convert. + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The currently used database platform. + * * @return mixed The PHP representation of the value. */ public function convertToPHPValue($value, AbstractPlatform $platform) @@ -109,6 +123,10 @@ abstract class Type /** * Gets the default length of this type. * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * + * @return integer|null + * * @todo Needed? */ public function getDefaultLength(AbstractPlatform $platform) @@ -119,8 +137,10 @@ abstract class Type /** * Gets the SQL declaration snippet for a field of this type. * - * @param array $fieldDeclaration The field declaration. - * @param AbstractPlatform $platform The currently used database platform. + * @param array $fieldDeclaration The field declaration. + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The currently used database platform. + * + * @return string */ abstract public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform); @@ -128,6 +148,7 @@ abstract class Type * Gets the name of this type. * * @return string + * * @todo Needed? */ abstract public function getName(); @@ -136,10 +157,11 @@ abstract class Type * Factory method to create type instances. * Type instances are implemented as flyweights. * - * @static - * @throws DBALException * @param string $name The name of the type (as returned by getName()). + * * @return \Doctrine\DBAL\Types\Type + * + * @throws \Doctrine\DBAL\DBALException */ public static function getType($name) { @@ -156,10 +178,12 @@ abstract class Type /** * Adds a custom type to the type map. * - * @static - * @param string $name Name of the type. This should correspond to what getName() returns. + * @param string $name The name of the type. This should correspond to what getName() returns. * @param string $className The class name of the custom type. - * @throws DBALException + * + * @return void + * + * @throws \Doctrine\DBAL\DBALException */ public static function addType($name, $className) { @@ -173,9 +197,9 @@ abstract class Type /** * Checks if exists support for a type. * - * @static - * @param string $name Name of the type - * @return boolean TRUE if type is supported; FALSE otherwise + * @param string $name The name of the type. + * + * @return boolean TRUE if type is supported; FALSE otherwise. */ public static function hasType($name) { @@ -185,10 +209,12 @@ abstract class Type /** * Overrides an already defined type to use a different implementation. * - * @static * @param string $name * @param string $className - * @throws DBALException + * + * @return void + * + * @throws \Doctrine\DBAL\DBALException */ public static function overrideType($name, $className) { @@ -223,19 +249,23 @@ abstract class Type } /** - * Get the types array map which holds all registered types and the corresponding + * Gets the types array map which holds all registered types and the corresponding * type class * - * @return array $typesMap + * @return array */ public static function getTypesMap() { return self::$_typesMap; } + /** + * @return string + */ public function __toString() { $e = explode('\\', get_class($this)); + return str_replace('Type', '', end($e)); } @@ -247,7 +277,7 @@ abstract class Type * {@link convertToPHPValueSQL} works for any type and mostly * does nothing. This method can additionally be used for optimization purposes. * - * @return bool + * @return boolean */ public function canRequireSQLConversion() { @@ -257,8 +287,9 @@ abstract class Type /** * Modifies the SQL expression (identifier, parameter) to convert to a database value. * - * @param string $sqlExpr - * @param AbstractPlatform $platform + * @param string $sqlExpr + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return string */ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) @@ -269,8 +300,9 @@ abstract class Type /** * Modifies the SQL expression (identifier, parameter) to convert to a PHP value. * - * @param string $sqlExpr - * @param AbstractPlatform $platform + * @param string $sqlExpr + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return string */ public function convertToPHPValueSQL($sqlExpr, $platform) @@ -279,9 +311,10 @@ abstract class Type } /** - * Get an array of database types that map to this Doctrine type. + * Gets an array of database types that map to this Doctrine type. + * + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform * - * @param AbstractPlatform $platform * @return array */ public function getMappedDatabaseTypes(AbstractPlatform $platform) @@ -295,12 +328,12 @@ abstract class Type * one of those types as commented, which will have Doctrine use an SQL * comment to typehint the actual Doctrine Type. * - * @param AbstractPlatform $platform - * @return bool + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * + * @return boolean */ public function requiresSQLCommentHint(AbstractPlatform $platform) { return false; } } - diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php old mode 100755 new mode 100644 index 7085822383..52bd56b4bc --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/VarDateTimeType.php @@ -17,33 +17,28 @@ * . */ - namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; /** - * Variable DateTime Type using date_create() instead of DateTime::createFromFormat() + * Variable DateTime Type using date_create() instead of DateTime::createFromFormat(). * * This type has performance implications as it runs twice as long as the regular * {@see DateTimeType}, however in certain PostgreSQL configurations with * TIMESTAMP(n) columns where n > 0 it is necessary to use this type. * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class VarDateTimeType extends DateTimeType { /** - * @throws ConversionException - * @param string $value - * @param AbstractPlatform $platform - * @return \DateTime + * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Version.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Version.php old mode 100755 new mode 100644 index 363763169c..5a94c1e874 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Version.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Version.php @@ -20,30 +20,28 @@ namespace Doctrine\DBAL; /** - * Class to store and retrieve the version of Doctrine + * Class to store and retrieve the version of Doctrine. * - * - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel */ class Version { /** - * Current Doctrine Version + * Current Doctrine Version. */ - const VERSION = '2.3.4'; + const VERSION = '2.4.1'; /** * Compares a Doctrine version with the current one. * - * @param string $version Doctrine version to compare. - * @return int Returns -1 if older, 0 if it is the same, 1 if version - * passed as argument is newer. + * @param string $version The Doctrine version to compare to. + * + * @return integer -1 if older, 0 if it is the same, 1 if version passed as argument is newer. */ public static function compare($version) { diff --git a/vendor/doctrine/dbal/phpunit.xml.dist b/vendor/doctrine/dbal/phpunit.xml.dist deleted file mode 100755 index fe1d515e46..0000000000 --- a/vendor/doctrine/dbal/phpunit.xml.dist +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - ./tests/Doctrine/Tests/DBAL - - - \ No newline at end of file diff --git a/vendor/doctrine/dbal/run-all.sh b/vendor/doctrine/dbal/run-all.sh deleted file mode 100755 index 80712eebc7..0000000000 --- a/vendor/doctrine/dbal/run-all.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# This script is a small convenience wrapper for running the doctrine testsuite against a large bunch of databases. -# Just create the phpunit.xmls as described in the array below and configure the specific files section -# to connect to that database. Just omit a file if you dont have that database and the tests will be skipped. - -configs[1]="mysql.phpunit.xml" -configs[2]='postgres.phpunit.xml' -configs[3]='sqlite.phpunit.xml' -configs[4]='oracle.phpunit.xml' -configs[5]='db2.phpunit.xml' -configs[6]='pdo-ibm.phpunit.xml' -configs[7]='sqlsrv.phpunit.xml' - -for i in "${configs[@]}"; do - if [ -f "$i" ]; - then - echo "RUNNING TESTS WITH CONFIG $i" - phpunit -c "$i" "$@" - fi; -done diff --git a/vendor/doctrine/dbal/tests/.gitignore b/vendor/doctrine/dbal/tests/.gitignore deleted file mode 100755 index 7210405266..0000000000 --- a/vendor/doctrine/dbal/tests/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Doctrine/Tests/Proxies/ -Doctrine/Tests/ORM/Proxy/generated/ -Doctrine/Tests/ORM/Tools/Export/export diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php deleted file mode 100755 index 48fbb69fcd..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ /dev/null @@ -1,177 +0,0 @@ - 'pdo_mysql', - 'host' => 'localhost', - 'user' => 'root', - 'password' => 'password', - 'port' => '1234' - ); - $this->_conn = \Doctrine\DBAL\DriverManager::getConnection($params); - } - - public function testIsConnected() - { - $this->assertFalse($this->_conn->isConnected()); - } - - public function testNoTransactionActiveByDefault() - { - $this->assertFalse($this->_conn->isTransactionActive()); - } - - public function testCommitWithNoActiveTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->commit(); - } - - public function testRollbackWithNoActiveTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->rollback(); - } - - public function testSetRollbackOnlyNoActiveTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->setRollbackOnly(); - } - - public function testIsRollbackOnlyNoActiveTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->isRollbackOnly(); - } - - public function testGetConfiguration() - { - $config = $this->_conn->getConfiguration(); - - $this->assertInstanceOf('Doctrine\DBAL\Configuration', $config); - } - - public function testGetHost() - { - $this->assertEquals('localhost', $this->_conn->getHost()); - } - - public function testGetPort() - { - $this->assertEquals('1234', $this->_conn->getPort()); - } - - public function testGetUsername() - { - $this->assertEquals('root', $this->_conn->getUsername()); - } - - public function testGetPassword() - { - $this->assertEquals('password', $this->_conn->getPassword()); - } - - public function testGetDriver() - { - $this->assertInstanceOf('Doctrine\DBAL\Driver\PDOMySql\Driver', $this->_conn->getDriver()); - } - - public function testGetEventManager() - { - $this->assertInstanceOf('Doctrine\Common\EventManager', $this->_conn->getEventManager()); - } - - public function testConnectDispatchEvent() - { - $listenerMock = $this->getMock('ConnectDispatchEventListener', array('postConnect')); - $listenerMock->expects($this->once())->method('postConnect'); - - $eventManager = new EventManager(); - $eventManager->addEventListener(array(Events::postConnect), $listenerMock); - - $driverMock = $this->getMock('Doctrine\DBAL\Driver'); - $driverMock->expects(($this->at(0))) - ->method('connect'); - $platform = new Mocks\MockPlatform(); - - $conn = new Connection(array('platform' => $platform), $driverMock, new Configuration(), $eventManager); - $conn->connect(); - } - - public function testEventManagerPassedToPlatform() - { - $this->assertInstanceOf('Doctrine\Common\EventManager', $this->_conn->getDatabasePlatform()->getEventManager()); - $this->assertSame($this->_conn->getEventManager(), $this->_conn->getDatabasePlatform()->getEventManager()); - } - - /** - * @expectedException Doctrine\DBAL\DBALException - * @dataProvider getQueryMethods - */ - public function testDriverExceptionIsWrapped($method) - { - $this->setExpectedException('Doctrine\DBAL\DBALException', "An exception occurred while executing 'MUUHAAAAHAAAA': - -SQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\""); - - $con = \Doctrine\DBAL\DriverManager::getConnection(array( - 'driver' => 'pdo_sqlite', - 'memory' => true, - )); - - $con->$method('MUUHAAAAHAAAA'); - } - - public function getQueryMethods() - { - return array( - array('exec'), - array('query'), - array('executeQuery'), - array('executeUpdate'), - array('prepare'), - ); - } - - /** - * Pretty dumb test, however we want to check that the EchoSQLLogger correctly implements the interface. - * - * @group DBAL-11 - */ - public function testEchoSQLLogger() - { - $logger = new \Doctrine\DBAL\Logging\EchoSQLLogger(); - $this->_conn->getConfiguration()->setSQLLogger($logger); - $this->assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger()); - } - - /** - * Pretty dumb test, however we want to check that the DebugStack correctly implements the interface. - * - * @group DBAL-11 - */ - public function testDebugSQLStack() - { - $logger = new \Doctrine\DBAL\Logging\DebugStack(); - $this->_conn->getConfiguration()->setSQLLogger($logger); - $this->assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php deleted file mode 100755 index 19796c7cd1..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php +++ /dev/null @@ -1,14 +0,0 @@ -assertContains('with params ["ABC", "\x80"]', $e->getMessage()); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php deleted file mode 100755 index a3dfe2af64..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ /dev/null @@ -1,82 +0,0 @@ -markTestSkipped('oci8 is not installed.'); - } - - parent::setUp(); - } - - /** - * This scenario shows that when the first parameter is not null - * it properly sets $hasZeroIndex to 1 and calls bindValue starting at 1. - * - * This also verifies that the statement will check with the connection to - * see what the current execution mode is. - * - * The expected exception is due to oci_execute failing due to no valid connection. - * - * @dataProvider executeDataProvider - * @expectedException \Doctrine\DBAL\Driver\OCI8\OCI8Exception - */ - public function testExecute(array $params) - { - $statement = $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Statement', - array('bindValue', 'errorInfo'), - array(), '', false); - - $statement->expects($this->at(0)) - ->method('bindValue') - ->with( - $this->equalTo(1), - $this->equalTo($params[0]) - ); - $statement->expects($this->at(1)) - ->method('bindValue') - ->with( - $this->equalTo(2), - $this->equalTo($params[1]) - ); - $statement->expects($this->at(2)) - ->method('bindValue') - ->with( - $this->equalTo(3), - $this->equalTo($params[2]) - ); - - // can't pass to constructor since we don't have a real database handle, - // but execute must check the connection for the executeMode - $conn = $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Connection', array('getExecuteMode'), array(), '', false); - $conn->expects($this->once()) - ->method('getExecuteMode'); - - $reflProperty = new \ReflectionProperty($statement, '_conn'); - $reflProperty->setAccessible(true); - $reflProperty->setValue($statement, $conn); - - $statement->execute($params); - } - - public static function executeDataProvider() - { - return array( - // $hasZeroIndex = isset($params[0]); == true - array( - array(0 => 'test', 1 => null, 2 => 'value') - ), - // $hasZeroIndex = isset($params[0]); == false - array( - array(0 => null, 1 => 'test', 2 => 'value') - ) - ); - } - -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php deleted file mode 100755 index 055b2aeb63..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ /dev/null @@ -1,117 +0,0 @@ - 'test' - ); - $test = \Doctrine\DBAL\DriverManager::getConnection($options); - } - - public function testValidPdoInstance() - { - $options = array( - 'pdo' => new \PDO('sqlite::memory:') - ); - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertEquals('sqlite', $conn->getDatabasePlatform()->getName()); - } - - /** - * @group DBAL-32 - */ - public function testPdoInstanceSetErrorMode() - { - $pdo = new \PDO('sqlite::memory:'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); - $options = array( - 'pdo' => $pdo - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertEquals(\PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(\PDO::ATTR_ERRMODE)); - } - - /** - * @expectedException \Doctrine\DBAL\DBALException - */ - public function testCheckParams() - { - $conn = \Doctrine\DBAL\DriverManager::getConnection(array()); - } - - /** - * @expectedException \Doctrine\DBAL\DBALException - */ - public function testInvalidDriver() - { - $conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'invalid_driver')); - } - - public function testCustomPlatform() - { - $mockPlatform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $options = array( - 'pdo' => new \PDO('sqlite::memory:'), - 'platform' => $mockPlatform - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertSame($mockPlatform, $conn->getDatabasePlatform()); - } - - public function testCustomWrapper() - { - $wrapperClass = 'Doctrine\Tests\Mocks\ConnectionMock'; - - $options = array( - 'pdo' => new \PDO('sqlite::memory:'), - 'wrapperClass' => $wrapperClass, - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertInstanceOf($wrapperClass, $conn); - } - - public function testInvalidWrapperClass() - { - $this->setExpectedException('\Doctrine\DBAL\DBALException'); - - $options = array( - 'pdo' => new \PDO('sqlite::memory:'), - 'wrapperClass' => 'stdClass', - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - } - - public function testInvalidDriverClass() - { - $this->setExpectedException('\Doctrine\DBAL\DBALException'); - - $options = array( - 'driverClass' => 'stdClass' - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - } - - public function testValidDriverClass() - { - $options = array( - 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertInstanceOf('Doctrine\DBAL\Driver\PDOMySql\Driver', $conn->getDriver()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php deleted file mode 100755 index 1ef47dd539..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php +++ /dev/null @@ -1,33 +0,0 @@ -getMock('Doctrine\DBAL\Connection', array(), array(), '', false); - $connectionMock->expects($this->once()) - ->method('executeUpdate') - ->with($this->equalTo("SET NAMES foo COLLATE bar")); - - $eventArgs = new ConnectionEventArgs($connectionMock); - - - $listener = new MysqlSessionInit('foo', 'bar'); - $listener->postConnect($eventArgs); - } - - public function testGetSubscribedEvents() - { - $listener = new MysqlSessionInit(); - $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php deleted file mode 100755 index 847ed6b155..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php +++ /dev/null @@ -1,33 +0,0 @@ -getMock('Doctrine\DBAL\Connection', array(), array(), '', false); - $connectionMock->expects($this->once()) - ->method('executeUpdate') - ->with($this->isType('string')); - - $eventArgs = new ConnectionEventArgs($connectionMock); - - - $listener = new OracleSessionInit(); - $listener->postConnect($eventArgs); - } - - public function testGetSubscribedEvents() - { - $listener = new OracleSessionInit(); - $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php deleted file mode 100755 index ed2dd43d1e..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php +++ /dev/null @@ -1,35 +0,0 @@ -getMock('Doctrine\DBAL\Connection', array(), array(), '', false); - $connectionMock->expects($this->once()) - ->method('exec') - ->with($this->equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'")); - - $eventArgs = new ConnectionEventArgs($connectionMock); - - $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"); - $listener->postConnect($eventArgs); - } - - public function testGetSubscribedEvents() - { - $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"); - $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php deleted file mode 100755 index 7c565425dd..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php +++ /dev/null @@ -1,83 +0,0 @@ -addColumn('id', 'integer'); - $table->addColumn('clobfield', 'text'); - $table->addColumn('blobfield', 'blob'); - $table->setPrimaryKey(array('id')); - - $sm = $this->_conn->getSchemaManager(); - $sm->createTable($table); - } catch(\Exception $e) { - - } - $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('blob_table')); - } - - public function testInsert() - { - $ret = $this->_conn->insert('blob_table', - array('id' => 1, 'clobfield' => 'test', 'blobfield' => 'test'), - array(\PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_LOB) - ); - $this->assertEquals(1, $ret); - } - - public function testSelect() - { - $ret = $this->_conn->insert('blob_table', - array('id' => 1, 'clobfield' => 'test', 'blobfield' => 'test'), - array(\PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_LOB) - ); - - $this->assertBlobContains('test'); - } - - public function testUpdate() - { - $ret = $this->_conn->insert('blob_table', - array('id' => 1, 'clobfield' => 'test', 'blobfield' => 'test'), - array(\PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_LOB) - ); - - $this->_conn->update('blob_table', - array('blobfield' => 'test2'), - array('id' => 1), - array(\PDO::PARAM_LOB, \PDO::PARAM_INT) - ); - - $this->assertBlobContains('test2'); - } - - private function assertBlobContains($text) - { - $rows = $this->_conn->fetchAll('SELECT * FROM blob_table'); - - $this->assertEquals(1, count($rows)); - $row = array_change_key_case($rows[0], CASE_LOWER); - - $blobValue = Type::getType('blob')->convertToPHPValue($row['blobfield'], $this->_conn->getDatabasePlatform()); - - $this->assertInternalType('resource', $blobValue); - $this->assertEquals($text, stream_get_contents($blobValue)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php deleted file mode 100755 index 31da42f32b..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ /dev/null @@ -1,219 +0,0 @@ -resetSharedConn(); - parent::setUp(); - } - - public function tearDown() - { - parent::tearDown(); - $this->resetSharedConn(); - } - - public function testGetWrappedConnection() - { - $this->assertInstanceOf('Doctrine\DBAL\Driver\Connection', $this->_conn->getWrappedConnection()); - } - - public function testCommitWithRollbackOnlyThrowsException() - { - $this->_conn->beginTransaction(); - $this->_conn->setRollbackOnly(); - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->commit(); - } - - public function testTransactionNestingBehavior() - { - try { - $this->_conn->beginTransaction(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - - try { - $this->_conn->beginTransaction(); - $this->assertEquals(2, $this->_conn->getTransactionNestingLevel()); - throw new \Exception; - $this->_conn->commit(); // never reached - } catch (\Exception $e) { - $this->_conn->rollback(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - //no rethrow - } - $this->assertTrue($this->_conn->isRollbackOnly()); - - $this->_conn->commit(); // should throw exception - $this->fail('Transaction commit after failed nested transaction should fail.'); - } catch (ConnectionException $e) { - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - $this->_conn->rollback(); - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - } - - public function testTransactionNestingBehaviorWithSavepoints() - { - if (!$this->_conn->getDatabasePlatform()->supportsSavepoints()) { - $this->markTestSkipped('This test requires the platform to support savepoints.'); - } - - $this->_conn->setNestTransactionsWithSavepoints(true); - try { - $this->_conn->beginTransaction(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - - try { - $this->_conn->beginTransaction(); - $this->assertEquals(2, $this->_conn->getTransactionNestingLevel()); - $this->_conn->beginTransaction(); - $this->assertEquals(3, $this->_conn->getTransactionNestingLevel()); - $this->_conn->commit(); - $this->assertEquals(2, $this->_conn->getTransactionNestingLevel()); - throw new \Exception; - $this->_conn->commit(); // never reached - } catch (\Exception $e) { - $this->_conn->rollback(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - //no rethrow - } - $this->assertFalse($this->_conn->isRollbackOnly()); - try { - $this->_conn->setNestTransactionsWithSavepoints(false); - $this->fail('Should not be able to disable savepoints in usage for nested transactions inside an open transaction.'); - } catch (ConnectionException $e) { - $this->assertTrue($this->_conn->getNestTransactionsWithSavepoints()); - } - $this->_conn->commit(); // should not throw exception - } catch (ConnectionException $e) { - $this->fail('Transaction commit after failed nested transaction should not fail when using savepoints.'); - $this->_conn->rollback(); - } - } - - public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction() - { - if (!$this->_conn->getDatabasePlatform()->supportsSavepoints()) { - $this->markTestSkipped('This test requires the platform to support savepoints.'); - } - - $this->_conn->beginTransaction(); - try { - $this->_conn->setNestTransactionsWithSavepoints(true); - $this->fail('An exception should have been thrown by chaning the nesting transaction behavior within an transaction.'); - } catch(ConnectionException $e) { - $this->_conn->rollBack(); - } - } - - public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException() - { - if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) { - $this->markTestSkipped('This test requires the platform not to support savepoints.'); - } - - $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver."); - - $this->_conn->setNestTransactionsWithSavepoints(true); - } - - public function testCreateSavepointsNotSupportedThrowsException() - { - if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) { - $this->markTestSkipped('This test requires the platform not to support savepoints.'); - } - - $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver."); - - $this->_conn->createSavepoint('foo'); - } - - public function testReleaseSavepointsNotSupportedThrowsException() - { - if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) { - $this->markTestSkipped('This test requires the platform not to support savepoints.'); - } - - $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver."); - - $this->_conn->releaseSavepoint('foo'); - } - - public function testRollbackSavepointsNotSupportedThrowsException() - { - if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) { - $this->markTestSkipped('This test requires the platform not to support savepoints.'); - } - - $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver."); - - $this->_conn->rollbackSavepoint('foo'); - } - - public function testTransactionBehaviorWithRollback() - { - try { - $this->_conn->beginTransaction(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - - throw new \Exception; - - $this->_conn->commit(); // never reached - } catch (\Exception $e) { - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - $this->_conn->rollback(); - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - } - - public function testTransactionBehaviour() - { - try { - $this->_conn->beginTransaction(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - $this->_conn->commit(); - } catch (\Exception $e) { - $this->_conn->rollback(); - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - - public function testTransactionalWithException() - { - try { - $this->_conn->transactional(function($conn) { - $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); - throw new \RuntimeException("Ooops!"); - }); - } catch (\RuntimeException $expected) { - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - } - - public function testTransactional() - { - $this->_conn->transactional(function($conn) { - /* @var $conn Connection */ - $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); - }); - } - - /** - * Tests that the quote function accepts DBAL and PDO types. - */ - public function testQuote() - { - $this->assertEquals($this->_conn->quote("foo", Type::STRING), $this->_conn->quote("foo", \PDO::PARAM_STR)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php deleted file mode 100755 index 4b57a4478d..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ /dev/null @@ -1,543 +0,0 @@ -addColumn('test_int', 'integer'); - $table->addColumn('test_string', 'string'); - $table->addColumn('test_datetime', 'datetime', array('notnull' => false)); - $table->setPrimaryKey(array('test_int')); - - $sm = $this->_conn->getSchemaManager(); - $sm->createTable($table); - - $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10')); - self::$generated = true; - } - } - - public function testPrepareWithBindValue() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindValue(1, 1); - $stmt->bindValue(2, 'foo'); - $stmt->execute(); - - $row = $stmt->fetch(\PDO::FETCH_ASSOC); - $row = array_change_key_case($row, \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); - } - - public function testPrepareWithBindParam() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindParam(1, $paramInt); - $stmt->bindParam(2, $paramStr); - $stmt->execute(); - - $row = $stmt->fetch(\PDO::FETCH_ASSOC); - $row = array_change_key_case($row, \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); - } - - public function testPrepareWithFetchAll() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindParam(1, $paramInt); - $stmt->bindParam(2, $paramStr); - $stmt->execute(); - - $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); - $rows[0] = array_change_key_case($rows[0], \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]); - } - - /** - * @group DBAL-228 - */ - public function testPrepareWithFetchAllBoth() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindParam(1, $paramInt); - $stmt->bindParam(2, $paramStr); - $stmt->execute(); - - $rows = $stmt->fetchAll(\PDO::FETCH_BOTH); - $rows[0] = array_change_key_case($rows[0], \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'), $rows[0]); - } - - public function testPrepareWithFetchColumn() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindParam(1, $paramInt); - $stmt->bindParam(2, $paramStr); - $stmt->execute(); - - $column = $stmt->fetchColumn(); - $this->assertEquals(1, $column); - } - - public function testPrepareWithIterator() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindParam(1, $paramInt); - $stmt->bindParam(2, $paramStr); - $stmt->execute(); - - $rows = array(); - $stmt->setFetchMode(\PDO::FETCH_ASSOC); - foreach ($stmt as $row) { - $rows[] = array_change_key_case($row, \CASE_LOWER); - } - - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]); - } - - public function testPrepareWithQuoted() - { - $table = 'fetch_table'; - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM " . $this->_conn->quoteIdentifier($table) . " ". - "WHERE test_int = " . $this->_conn->quote($paramInt) . " AND test_string = " . $this->_conn->quote($paramStr); - $stmt = $this->_conn->prepare($sql); - $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); - } - - public function testPrepareWithExecuteParams() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); - $stmt->execute(array($paramInt, $paramStr)); - - $row = $stmt->fetch(\PDO::FETCH_ASSOC); - $this->assertTrue($row !== false); - $row = array_change_key_case($row, \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); - } - - public function testFetchAll() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $data = $this->_conn->fetchAll($sql, array(1, 'foo')); - - $this->assertEquals(1, count($data)); - - $row = $data[0]; - $this->assertEquals(2, count($row)); - - $row = array_change_key_case($row, \CASE_LOWER); - $this->assertEquals(1, $row['test_int']); - $this->assertEquals('foo', $row['test_string']); - } - - public function testFetchBoth() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $row = $this->_conn->executeQuery($sql, array(1, 'foo'))->fetch(\PDO::FETCH_BOTH); - - $this->assertTrue($row !== false); - - $row = array_change_key_case($row, \CASE_LOWER); - - $this->assertEquals(1, $row['test_int']); - $this->assertEquals('foo', $row['test_string']); - $this->assertEquals(1, $row[0]); - $this->assertEquals('foo', $row[1]); - } - - public function testFetchRow() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $row = $this->_conn->fetchAssoc($sql, array(1, 'foo')); - - $this->assertTrue($row !== false); - - $row = array_change_key_case($row, \CASE_LOWER); - - $this->assertEquals(1, $row['test_int']); - $this->assertEquals('foo', $row['test_string']); - } - - public function testFetchArray() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $row = $this->_conn->fetchArray($sql, array(1, 'foo')); - - $this->assertEquals(1, $row[0]); - $this->assertEquals('foo', $row[1]); - } - - public function testFetchColumn() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $testInt = $this->_conn->fetchColumn($sql, array(1, 'foo'), 0); - - $this->assertEquals(1, $testInt); - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $testString = $this->_conn->fetchColumn($sql, array(1, 'foo'), 1); - - $this->assertEquals('foo', $testString); - } - - /** - * @group DDC-697 - */ - public function testExecuteQueryBindDateTimeType() - { - $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; - $stmt = $this->_conn->executeQuery($sql, - array(1 => new \DateTime('2010-01-01 10:10:10')), - array(1 => Type::DATETIME) - ); - - $this->assertEquals(1, $stmt->fetchColumn()); - } - - /** - * @group DDC-697 - */ - public function testExecuteUpdateBindDateTimeType() - { - $datetime = new \DateTime('2010-02-02 20:20:20'); - - $sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)'; - $affectedRows = $this->_conn->executeUpdate($sql, - array(1 => 50, 2 => 'foo', 3 => $datetime), - array(1 => PDO::PARAM_INT, 2 => PDO::PARAM_STR, 3 => Type::DATETIME) - ); - - $this->assertEquals(1, $affectedRows); - $this->assertEquals(1, $this->_conn->executeQuery( - 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?', - array(1 => $datetime), - array(1 => Type::DATETIME) - )->fetchColumn()); - } - - /** - * @group DDC-697 - */ - public function testPrepareQueryBindValueDateTimeType() - { - $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; - $stmt = $this->_conn->prepare($sql); - $stmt->bindValue(1, new \DateTime('2010-01-01 10:10:10'), Type::DATETIME); - $stmt->execute(); - - $this->assertEquals(1, $stmt->fetchColumn()); - } - - /** - * @group DBAL-78 - */ - public function testNativeArrayListSupport() - { - for ($i = 100; $i < 110; $i++) { - $this->_conn->insert('fetch_table', array('test_int' => $i, 'test_string' => 'foo' . $i, 'test_datetime' => '2010-01-01 10:10:10')); - } - - $stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_int IN (?)', - array(array(100, 101, 102, 103, 104)), array(Connection::PARAM_INT_ARRAY)); - - $data = $stmt->fetchAll(PDO::FETCH_NUM); - $this->assertEquals(5, count($data)); - $this->assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data); - - $stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_string IN (?)', - array(array('foo100', 'foo101', 'foo102', 'foo103', 'foo104')), array(Connection::PARAM_STR_ARRAY)); - - $data = $stmt->fetchAll(PDO::FETCH_NUM); - $this->assertEquals(5, count($data)); - $this->assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data); - } - - /** - * @group DDC-1014 - */ - public function testDateArithmetics() - { - $p = $this->_conn->getDatabasePlatform(); - $sql = 'SELECT '; - $sql .= $p->getDateDiffExpression('test_datetime', $p->getCurrentTimestampSQL()) .' AS diff, '; - $sql .= $p->getDateAddDaysExpression('test_datetime', 10) .' AS add_days, '; - $sql .= $p->getDateSubDaysExpression('test_datetime', 10) .' AS sub_days, '; - $sql .= $p->getDateAddMonthExpression('test_datetime', 2) .' AS add_month, '; - $sql .= $p->getDateSubMonthExpression('test_datetime', 2) .' AS sub_month '; - $sql .= 'FROM fetch_table'; - - $row = $this->_conn->fetchAssoc($sql); - $row = array_change_key_case($row, CASE_LOWER); - - $diff = floor( (strtotime('2010-01-01')-time()) / 3600 / 24); - $this->assertEquals($diff, (int)$row['diff'], "Date difference should be approx. ".$diff." days.", 1); - $this->assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])), "Adding date should end up on 2010-01-11"); - $this->assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])), "Subtracting date should end up on 2009-12-22"); - $this->assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])), "Adding month should end up on 2010-03-01"); - $this->assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])), "Adding month should end up on 2009-11-01"); - } - - public function testQuoteSQLInjection() - { - $sql = "SELECT * FROM fetch_table WHERE test_string = " . $this->_conn->quote("bar' OR '1'='1"); - $rows = $this->_conn->fetchAll($sql); - - $this->assertEquals(0, count($rows), "no result should be returned, otherwise SQL injection is possible"); - } - - /** - * @group DDC-1213 - */ - public function testBitComparisonExpressionSupport() - { - $this->_conn->executeQuery('DELETE FROM fetch_table')->execute(); - $platform = $this->_conn->getDatabasePlatform(); - $bitmap = array(); - - for ($i = 2; $i < 9; $i = $i + 2) { - $bitmap[$i] = array( - 'bit_or' => ($i | 2), - 'bit_and' => ($i & 2) - ); - $this->_conn->insert('fetch_table', array( - 'test_int' => $i, - 'test_string' => json_encode($bitmap[$i]), - 'test_datetime' => '2010-01-01 10:10:10' - )); - } - - $sql[] = 'SELECT '; - $sql[] = 'test_int, '; - $sql[] = 'test_string, '; - $sql[] = $platform->getBitOrComparisonExpression('test_int', 2) . ' AS bit_or, '; - $sql[] = $platform->getBitAndComparisonExpression('test_int', 2) . ' AS bit_and '; - $sql[] = 'FROM fetch_table'; - - $stmt = $this->_conn->executeQuery(implode(PHP_EOL, $sql)); - $data = $stmt->fetchAll(PDO::FETCH_ASSOC); - - - $this->assertEquals(4, count($data)); - $this->assertEquals(count($bitmap), count($data)); - foreach ($data as $row) { - $row = array_change_key_case($row, CASE_LOWER); - - $this->assertArrayHasKey('test_int', $row); - - $id = $row['test_int']; - - $this->assertArrayHasKey($id, $bitmap); - $this->assertArrayHasKey($id, $bitmap); - - $this->assertArrayHasKey('bit_or', $row); - $this->assertArrayHasKey('bit_and', $row); - - $this->assertEquals($row['bit_or'], $bitmap[$id]['bit_or']); - $this->assertEquals($row['bit_and'], $bitmap[$id]['bit_and']); - } - } - - public function testSetDefaultFetchMode() - { - $stmt = $this->_conn->query("SELECT * FROM fetch_table"); - $stmt->setFetchMode(\PDO::FETCH_NUM); - - $row = array_keys($stmt->fetch()); - $this->assertEquals(0, count( array_filter($row, function($v) { return ! is_numeric($v); })), "should be no non-numerical elements in the result."); - } - - /** - * @group DBAL-196 - */ - public function testFetchAllSupportFetchClass() - { - $this->skipOci8AndMysqli(); - $this->setupFixture(); - - $sql = "SELECT test_int, test_string, test_datetime FROM fetch_table"; - $stmt = $this->_conn->prepare($sql); - $stmt->execute(); - - $results = $stmt->fetchAll( - \PDO::FETCH_CLASS, - __NAMESPACE__.'\\MyFetchClass' - ); - - $this->assertEquals(1, count($results)); - $this->assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]); - - $this->assertEquals(1, $results[0]->test_int); - $this->assertEquals('foo', $results[0]->test_string); - $this->assertStringStartsWith('2010-01-01 10:10:10', $results[0]->test_datetime); - } - - /** - * @group DBAL-241 - */ - public function testFetchAllStyleColumn() - { - $sql = "DELETE FROM fetch_table"; - $this->_conn->executeUpdate($sql); - - $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo')); - $this->_conn->insert('fetch_table', array('test_int' => 10, 'test_string' => 'foo')); - - $sql = "SELECT test_int FROM fetch_table"; - $rows = $this->_conn->query($sql)->fetchAll(\PDO::FETCH_COLUMN); - - $this->assertEquals(array(1, 10), $rows); - } - - /** - * @group DBAL-214 - */ - public function testSetFetchModeClassFetchAll() - { - $this->skipOci8AndMysqli(); - $this->setupFixture(); - - $sql = "SELECT * FROM fetch_table"; - $stmt = $this->_conn->query($sql); - $stmt->setFetchMode(\PDO::FETCH_CLASS, __NAMESPACE__ . '\\MyFetchClass', array()); - - $results = $stmt->fetchAll(); - - $this->assertEquals(1, count($results)); - $this->assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]); - - $this->assertEquals(1, $results[0]->test_int); - $this->assertEquals('foo', $results[0]->test_string); - $this->assertStringStartsWith('2010-01-01 10:10:10', $results[0]->test_datetime); - } - - /** - * @group DBAL-214 - */ - public function testSetFetchModeClassFetch() - { - $this->skipOci8AndMysqli(); - $this->setupFixture(); - - $sql = "SELECT * FROM fetch_table"; - $stmt = $this->_conn->query($sql); - $stmt->setFetchMode(\PDO::FETCH_CLASS, __NAMESPACE__ . '\\MyFetchClass', array()); - - $results = array(); - while ($row = $stmt->fetch()) { - $results[] = $row; - } - - $this->assertEquals(1, count($results)); - $this->assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]); - - $this->assertEquals(1, $results[0]->test_int); - $this->assertEquals('foo', $results[0]->test_string); - $this->assertStringStartsWith('2010-01-01 10:10:10', $results[0]->test_datetime); - } - - /** - * @group DBAL-257 - */ - public function testEmptyFetchColumnReturnsFalse() - { - $this->_conn->executeQuery('DELETE FROM fetch_table')->execute(); - $this->assertFalse($this->_conn->fetchColumn('SELECT test_int FROM fetch_table')); - $this->assertFalse($this->_conn->query('SELECT test_int FROM fetch_table')->fetchColumn()); - } - - /** - * @group DBAL-339 - */ - public function testSetFetchModeOnDbalStatement() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->executeQuery($sql, array(1, "foo")); - $stmt->setFetchMode(\PDO::FETCH_NUM); - - while ($row = $stmt->fetch()) { - $this->assertTrue(isset($row[0])); - $this->assertTrue(isset($row[1])); - } - } - - private function setupFixture() - { - $this->_conn->executeQuery('DELETE FROM fetch_table')->execute(); - $this->_conn->insert('fetch_table', array( - 'test_int' => 1, - 'test_string' => 'foo', - 'test_datetime' => '2010-01-01 10:10:10' - )); - } - - private function skipOci8AndMysqli() - { - if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] == "oci8") { - $this->markTestSkipped("Not supported by OCI8"); - } - if ('mysqli' == $this->_conn->getDriver()->getName()) { - $this->markTestSkipped('Mysqli driver dont support this feature.'); - } - } -} - -class MyFetchClass -{ - public $test_int, $test_string, $test_datetime; -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php deleted file mode 100755 index 7c96813120..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php +++ /dev/null @@ -1,52 +0,0 @@ -_conn->getDatabasePlatform()->getDummySelectSQL(); - - $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger'); - $logMock->expects($this->at(0)) - ->method('startQuery') - ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array())); - $logMock->expects($this->at(1)) - ->method('stopQuery'); - $this->_conn->getConfiguration()->setSQLLogger($logMock); - $this->_conn->executeQuery($sql, array()); - } - - public function testLogExecuteUpdate() - { - $this->markTestSkipped('Test breaks MySQL but works on all other platforms (Unbuffered Queries stuff).'); - - $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL(); - - $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger'); - $logMock->expects($this->at(0)) - ->method('startQuery') - ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array())); - $logMock->expects($this->at(1)) - ->method('stopQuery'); - $this->_conn->getConfiguration()->setSQLLogger($logMock); - $this->_conn->executeUpdate($sql, array()); - } - - public function testLogPrepareExecute() - { - $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL(); - - $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger'); - $logMock->expects($this->once()) - ->method('startQuery') - ->with($this->equalTo($sql), $this->equalTo(array())); - $logMock->expects($this->at(1)) - ->method('stopQuery'); - $this->_conn->getConfiguration()->setSQLLogger($logMock); - - $stmt = $this->_conn->prepare($sql); - $stmt->execute(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php deleted file mode 100755 index d1fef14c92..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php +++ /dev/null @@ -1,105 +0,0 @@ -_conn->getDatabasePlatform()->getName() == "sqlite") { - $this->markTestSkipped('Test does not work on sqlite.'); - } - - try { - /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ - $table = new \Doctrine\DBAL\Schema\Table("master_slave_table"); - $table->addColumn('test_int', 'integer'); - $table->setPrimaryKey(array('test_int')); - - $sm = $this->_conn->getSchemaManager(); - $sm->createTable($table); - - - } catch(\Exception $e) { - } - - $this->_conn->executeUpdate('DELETE FROM master_slave_table'); - $this->_conn->insert('master_slave_table', array('test_int' => 1)); - } - - public function createMasterSlaveConnection($keepSlave = false) - { - $params = $this->_conn->getParams(); - $params['master'] = $params; - $params['slaves'] = array($params, $params); - $params['keepSlave'] = $keepSlave; - $params['wrapperClass'] = 'Doctrine\DBAL\Connections\MasterSlaveConnection'; - - return DriverManager::getConnection($params); - } - - public function testMasterOnConnect() - { - $conn = $this->createMasterSlaveConnection(); - - $this->assertFalse($conn->isConnectedToMaster()); - $conn->connect('slave'); - $this->assertFalse($conn->isConnectedToMaster()); - $conn->connect('master'); - $this->assertTrue($conn->isConnectedToMaster()); - } - - public function testNoMasterOnExecuteQuery() - { - $conn = $this->createMasterSlaveConnection(); - - $sql = "SELECT count(*) as num FROM master_slave_table"; - $data = $conn->fetchAll($sql); - $data[0] = array_change_key_case($data[0], CASE_LOWER); - - $this->assertEquals(1, $data[0]['num']); - $this->assertFalse($conn->isConnectedToMaster()); - } - - public function testMasterOnWriteOperation() - { - $conn = $this->createMasterSlaveConnection(); - $conn->insert('master_slave_table', array('test_int' => 30)); - - $this->assertTrue($conn->isConnectedToMaster()); - - $sql = "SELECT count(*) as num FROM master_slave_table"; - $data = $conn->fetchAll($sql); - $data[0] = array_change_key_case($data[0], CASE_LOWER); - - $this->assertEquals(2, $data[0]['num']); - $this->assertTrue($conn->isConnectedToMaster()); - } - - /** - * @group DBAL-335 - */ - public function testKeepSlaveBeginTransactionStaysOnMaster() - { - $conn = $this->createMasterSlaveConnection($keepSlave = true); - $conn->connect('slave'); - - $conn->insert('master_slave_table', array('test_int' => 40)); - - $this->assertTrue($conn->isConnectedToMaster()); - - $conn->connect(); - $this->assertTrue($conn->isConnectedToMaster()); - - $conn->connect('slave'); - $this->assertFalse($conn->isConnectedToMaster()); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php deleted file mode 100755 index 69ba6ac290..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php +++ /dev/null @@ -1,114 +0,0 @@ -addColumn('test_int', 'integer'); - $table->setPrimaryKey(array('test_int')); - - $table2 = new \Doctrine\DBAL\Schema\Table("modify_limit_table2"); - $table2->addColumn('id', 'integer', array('autoincrement' => true)); - $table2->addColumn('test_int', 'integer'); - $table2->setPrimaryKey(array('id')); - - $sm = $this->_conn->getSchemaManager(); - $sm->createTable($table); - $sm->createTable($table2); - self::$tableCreated = true; - } - $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table')); - $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2')); - } - - public function testModifyLimitQuerySimpleQuery() - { - $this->_conn->insert('modify_limit_table', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table', array('test_int' => 2)); - $this->_conn->insert('modify_limit_table', array('test_int' => 3)); - $this->_conn->insert('modify_limit_table', array('test_int' => 4)); - - $sql = "SELECT * FROM modify_limit_table"; - - $this->assertLimitResult(array(1, 2, 3, 4), $sql, 10, 0); - $this->assertLimitResult(array(1, 2), $sql, 2, 0); - $this->assertLimitResult(array(3, 4), $sql, 2, 2); - } - - public function testModifyLimitQueryJoinQuery() - { - $this->_conn->insert('modify_limit_table', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table', array('test_int' => 2)); - - $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table2', array('test_int' => 2)); - $this->_conn->insert('modify_limit_table2', array('test_int' => 2)); - - $sql = "SELECT modify_limit_table.test_int FROM modify_limit_table INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int"; - - $this->assertLimitResult(array(1, 1, 1, 2, 2), $sql, 10, 0); - $this->assertLimitResult(array(1, 1, 1), $sql, 3, 0); - $this->assertLimitResult(array(2, 2), $sql, 2, 3); - } - - public function testModifyLimitQueryOrderBy() - { - $this->_conn->insert('modify_limit_table', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table', array('test_int' => 2)); - $this->_conn->insert('modify_limit_table', array('test_int' => 3)); - $this->_conn->insert('modify_limit_table', array('test_int' => 4)); - - $sql = "SELECT * FROM modify_limit_table ORDER BY test_int DESC"; - - $this->assertLimitResult(array(4, 3, 2, 1), $sql, 10, 0); - $this->assertLimitResult(array(4, 3), $sql, 2, 0); - $this->assertLimitResult(array(2, 1), $sql, 2, 2); - } - - public function testModifyLimitQueryGroupBy() - { - $this->_conn->insert('modify_limit_table', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table', array('test_int' => 2)); - - $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); - $this->_conn->insert('modify_limit_table2', array('test_int' => 2)); - $this->_conn->insert('modify_limit_table2', array('test_int' => 2)); - - $sql = "SELECT modify_limit_table.test_int FROM modify_limit_table " . - "INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int ". - "GROUP BY modify_limit_table.test_int"; - $this->assertLimitResult(array(1, 2), $sql, 10, 0); - $this->assertLimitResult(array(1), $sql, 1, 0); - $this->assertLimitResult(array(2), $sql, 1, 1); - } - - public function assertLimitResult($expectedResults, $sql, $limit, $offset) - { - $p = $this->_conn->getDatabasePlatform(); - $data = array(); - foreach ($this->_conn->fetchAll($p->modifyLimitQuery($sql, $limit, $offset)) AS $row) { - $row = array_change_key_case($row, CASE_LOWER); - $data[] = $row['test_int']; - } - $this->assertEquals($expectedResults, $data); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php deleted file mode 100755 index 6f9e513c17..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php +++ /dev/null @@ -1,166 +0,0 @@ -1,'bar'=> array(1, 2, 3)), - array('foo'=>PDO::PARAM_INT,'bar'=> Connection::PARAM_INT_ARRAY,), - array( - array('id'=>1,'foo'=>1,'bar'=>1), - array('id'=>2,'foo'=>1,'bar'=>2), - array('id'=>3,'foo'=>1,'bar'=>3), - ) - ), - - array( - 'SELECT * FROM ddc1372_foobar f WHERE f.foo = :foo AND f.bar IN (:bar)', - array('foo'=>1,'bar'=> array(1, 2, 3)), - array('bar'=> Connection::PARAM_INT_ARRAY,'foo'=>PDO::PARAM_INT), - array( - array('id'=>1,'foo'=>1,'bar'=>1), - array('id'=>2,'foo'=>1,'bar'=>2), - array('id'=>3,'foo'=>1,'bar'=>3), - ) - ), - - array( - 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo = :foo', - array('foo'=>1,'bar'=> array(1, 2, 3)), - array('bar'=> Connection::PARAM_INT_ARRAY,'foo'=>PDO::PARAM_INT), - array( - array('id'=>1,'foo'=>1,'bar'=>1), - array('id'=>2,'foo'=>1,'bar'=>2), - array('id'=>3,'foo'=>1,'bar'=>3), - ) - ), - - array( - 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo = :foo', - array('foo'=>1,'bar'=> array('1', '2', '3')), - array('bar'=> Connection::PARAM_STR_ARRAY,'foo'=>PDO::PARAM_INT), - array( - array('id'=>1,'foo'=>1,'bar'=>1), - array('id'=>2,'foo'=>1,'bar'=>2), - array('id'=>3,'foo'=>1,'bar'=>3), - ) - ), - - array( - 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo IN (:foo)', - array('foo'=>array('1'),'bar'=> array(1, 2, 3,4)), - array('bar'=> Connection::PARAM_STR_ARRAY,'foo'=>Connection::PARAM_INT_ARRAY), - array( - array('id'=>1,'foo'=>1,'bar'=>1), - array('id'=>2,'foo'=>1,'bar'=>2), - array('id'=>3,'foo'=>1,'bar'=>3), - array('id'=>4,'foo'=>1,'bar'=>4), - ) - ), - - array( - 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo IN (:foo)', - array('foo'=>1,'bar'=> 2), - array('bar'=>PDO::PARAM_INT,'foo'=>PDO::PARAM_INT), - array( - array('id'=>2,'foo'=>1,'bar'=>2), - ) - ), - - array( - 'SELECT * FROM ddc1372_foobar f WHERE f.bar = :arg AND f.foo <> :arg', - array('arg'=>'1'), - array('arg'=>PDO::PARAM_STR), - array( - array('id'=>5,'foo'=>2,'bar'=>1), - ) - ), - - array( - 'SELECT * FROM ddc1372_foobar f WHERE f.bar NOT IN (:arg) AND f.foo IN (:arg)', - array('arg'=>array(1, 2)), - array('arg'=>Connection::PARAM_INT_ARRAY), - array( - array('id'=>3,'foo'=>1,'bar'=>3), - array('id'=>4,'foo'=>1,'bar'=>4), - ) - ), - - ); - } - - public function setUp() - { - parent::setUp(); - - if (!$this->_conn->getSchemaManager()->tablesExist("ddc1372_foobar")) { - try { - $table = new \Doctrine\DBAL\Schema\Table("ddc1372_foobar"); - $table->addColumn('id', 'integer'); - $table->addColumn('foo','string'); - $table->addColumn('bar','string'); - $table->setPrimaryKey(array('id')); - - - $sm = $this->_conn->getSchemaManager(); - $sm->createTable($table); - - $this->_conn->insert('ddc1372_foobar', array( - 'id' => 1, 'foo' => 1, 'bar' => 1 - )); - $this->_conn->insert('ddc1372_foobar', array( - 'id' => 2, 'foo' => 1, 'bar' => 2 - )); - $this->_conn->insert('ddc1372_foobar', array( - 'id' => 3, 'foo' => 1, 'bar' => 3 - )); - $this->_conn->insert('ddc1372_foobar', array( - 'id' => 4, 'foo' => 1, 'bar' => 4 - )); - $this->_conn->insert('ddc1372_foobar', array( - 'id' => 5, 'foo' => 2, 'bar' => 1 - )); - $this->_conn->insert('ddc1372_foobar', array( - 'id' => 6, 'foo' => 2, 'bar' => 2 - )); - } catch(\Exception $e) { - $this->fail($e->getMessage()); - } - } - } - - /** - * @dataProvider ticketProvider - * @param string $query - * @param array $params - * @param array $types - * @param array $expected - */ - public function testTicket($query,$params,$types,$expected) - { - $stmt = $this->_conn->executeQuery($query, $params, $types); - $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); - - foreach ($result as $k => $v) { - $result[$k] = array_change_key_case($v, CASE_LOWER); - } - - $this->assertEquals($result, $expected); - } - -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php deleted file mode 100755 index acf995bbc4..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php +++ /dev/null @@ -1,97 +0,0 @@ -portableConnection) { - $this->portableConnection->close(); - } - } - - private function getPortableConnection($portabilityMode = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL, $case = \PDO::CASE_LOWER) - { - if (!$this->portableConnection) { - $params = $this->_conn->getParams(); - $params['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection'; - $params['portability'] = $portabilityMode; - $params['fetch_case'] = $case; - $this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager()); - - try { - /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ - $table = new \Doctrine\DBAL\Schema\Table("portability_table"); - $table->addColumn('Test_Int', 'integer'); - $table->addColumn('Test_String', 'string', array('fixed' => true, 'length' => 32)); - $table->addColumn('Test_Null', 'string', array('notnull' => false)); - $table->setPrimaryKey(array('Test_Int')); - - $sm = $this->portableConnection->getSchemaManager(); - $sm->createTable($table); - - $this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => '')); - $this->portableConnection->insert('portability_table', array('Test_Int' => 2, 'Test_String' => 'foo ', 'Test_Null' => null)); - } catch(\Exception $e) { - - } - } - - return $this->portableConnection; - } - - public function testFullFetchMode() - { - $rows = $this->getPortableConnection()->fetchAll('SELECT * FROM portability_table'); - $this->assertFetchResultRows($rows); - - $stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table'); - $stmt->setFetchMode(\PDO::FETCH_ASSOC); - foreach ($stmt as $row) { - $this->assertFetchResultRow($row); - } - - $stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table'); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $this->assertFetchResultRow($row); - } - - $stmt = $this->getPortableConnection()->prepare('SELECT * FROM portability_table'); - $stmt->execute(); - - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $this->assertFetchResultRow($row); - } - } - - public function assertFetchResultRows($rows) - { - $this->assertEquals(2, count($rows)); - foreach ($rows AS $row) { - $this->assertFetchResultRow($row); - } - } - - public function assertFetchResultRow($row) - { - $this->assertTrue(in_array($row['test_int'], array(1, 2)), "Primary key test_int should either be 1 or 2."); - $this->assertArrayHasKey('test_string', $row, "Case should be lowered."); - $this->assertEquals(3, strlen($row['test_string']), "test_string should be rtrimed to length of three for CHAR(32) column."); - $this->assertNull($row['test_null']); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php deleted file mode 100755 index dc82911530..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ /dev/null @@ -1,208 +0,0 @@ - 100, 'test_string' => 'foo'), array('test_int' => 200, 'test_string' => 'bar'), array('test_int' => 300, 'test_string' => 'baz')); - private $sqlLogger; - - public function setUp() - { - parent::setUp(); - - try { - /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ - $table = new \Doctrine\DBAL\Schema\Table("caching"); - $table->addColumn('test_int', 'integer'); - $table->addColumn('test_string', 'string', array('notnull' => false)); - $table->setPrimaryKey(array('test_int')); - - $sm = $this->_conn->getSchemaManager(); - $sm->createTable($table); - } catch(\Exception $e) { - - } - $this->_conn->executeUpdate('DELETE FROM caching'); - foreach ($this->expectedResult AS $row) { - $this->_conn->insert('caching', $row); - } - - $config = $this->_conn->getConfiguration(); - $config->setSQLLogger($this->sqlLogger = new \Doctrine\DBAL\Logging\DebugStack); - - $cache = new \Doctrine\Common\Cache\ArrayCache; - $config->setResultCacheImpl($cache); - } - - public function testCacheFetchAssoc() - { - $this->assertCacheNonCacheSelectSameFetchModeAreEqual($this->expectedResult, \PDO::FETCH_ASSOC); - } - - public function testFetchNum() - { - $expectedResult = array(); - foreach ($this->expectedResult AS $v) { - $expectedResult[] = array_values($v); - } - $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, \PDO::FETCH_NUM); - } - - public function testFetchBoth() - { - $expectedResult = array(); - foreach ($this->expectedResult AS $v) { - $expectedResult[] = array_merge($v, array_values($v)); - } - $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, \PDO::FETCH_BOTH); - } - - public function testFetchColumn() - { - $expectedResult = array(); - foreach ($this->expectedResult AS $v) { - $expectedResult[] = array_shift($v); - } - $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, \PDO::FETCH_COLUMN); - } - - public function testMixingFetch() - { - $numExpectedResult = array(); - foreach ($this->expectedResult AS $v) { - $numExpectedResult[] = array_values($v); - } - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - - $data = $this->hydrateStmt($stmt, \PDO::FETCH_ASSOC); - - $this->assertEquals($this->expectedResult, $data); - - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - - $data = $this->hydrateStmt($stmt, \PDO::FETCH_NUM); - - $this->assertEquals($numExpectedResult, $data); - } - - public function testIteratorFetch() - { - $this->assertStandardAndIteratorFetchAreEqual(\PDO::FETCH_BOTH); - $this->assertStandardAndIteratorFetchAreEqual(\PDO::FETCH_ASSOC); - $this->assertStandardAndIteratorFetchAreEqual(\PDO::FETCH_NUM); - } - - public function assertStandardAndIteratorFetchAreEqual($fetchMode) - { - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - $data = $this->hydrateStmt($stmt, $fetchMode); - - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - $data_iterator = $this->hydrateStmtIterator($stmt, $fetchMode); - - $this->assertEquals($data, $data_iterator); - } - - public function testDontCloseNoCache() - { - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - - $data = array(); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $data[] = $row; - } - - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - - $data = array(); - while ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $data[] = $row; - } - - $this->assertEquals(2, count($this->sqlLogger->queries)); - } - - public function testDontFinishNoCache() - { - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - - $row = $stmt->fetch(\PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - - $data = $this->hydrateStmt($stmt, \PDO::FETCH_NUM); - - $this->assertEquals(2, count($this->sqlLogger->queries)); - } - - public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchMode) - { - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - - $this->assertEquals(2, $stmt->columnCount()); - $data = $this->hydrateStmt($stmt, $fetchMode); - $this->assertEquals($expectedResult, $data); - - $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); - - $this->assertEquals(2, $stmt->columnCount()); - $data = $this->hydrateStmt($stmt, $fetchMode); - $this->assertEquals($expectedResult, $data); - $this->assertEquals(1, count($this->sqlLogger->queries), "just one dbal hit"); - } - - public function testEmptyResultCache() - { - $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey")); - $data = $this->hydrateStmt($stmt); - - $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey")); - $data = $this->hydrateStmt($stmt); - - $this->assertEquals(1, count($this->sqlLogger->queries), "just one dbal hit"); - } - - public function testChangeCacheImpl() - { - $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey")); - $data = $this->hydrateStmt($stmt); - - $secondCache = new \Doctrine\Common\Cache\ArrayCache; - $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey", $secondCache)); - $data = $this->hydrateStmt($stmt); - - $this->assertEquals(2, count($this->sqlLogger->queries), "two hits"); - $this->assertEquals(1, count($secondCache->fetch("emptycachekey"))); - } - - private function hydrateStmt($stmt, $fetchMode = \PDO::FETCH_ASSOC) - { - $data = array(); - while ($row = $stmt->fetch($fetchMode)) { - $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; - } - $stmt->closeCursor(); - return $data; - } - - private function hydrateStmtIterator($stmt, $fetchMode = \PDO::FETCH_ASSOC) - { - $data = array(); - $stmt->setFetchMode($fetchMode); - foreach ($stmt as $row) { - $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; - } - $stmt->closeCursor(); - return $data; - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php deleted file mode 100755 index a567900c96..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php +++ /dev/null @@ -1,12 +0,0 @@ -addColumn('foo_id', 'integer'); - $tableOld->addColumn('bar_id', 'integer'); - $tableNew = clone $tableOld; - - $this->_sm->createTable($tableOld); - $tableFetched = $this->_sm->listTableDetails("switch_primary_key_columns"); - $tableNew = clone $tableFetched; - $tableNew->setPrimaryKey(array('bar_id', 'foo_id')); - - $comparator = new \Doctrine\DBAL\Schema\Comparator; - $this->_sm->alterTable($comparator->diffTable($tableFetched, $tableNew)); - } - - public function testDiffTableBug() - { - $schema = new Schema(); - $table = $schema->createTable('diffbug_routing_translations'); - $table->addColumn('id', 'integer'); - $table->addColumn('route', 'string'); - $table->addColumn('locale', 'string'); - $table->addColumn('attribute', 'string'); - $table->addColumn('localized_value', 'string'); - $table->addColumn('original_value', 'string'); - $table->setPrimaryKey(array('id')); - $table->addUniqueIndex(array('route', 'locale', 'attribute')); - $table->addIndex(array('localized_value')); // this is much more selective than the unique index - - $this->_sm->createTable($table); - $tableFetched = $this->_sm->listTableDetails("diffbug_routing_translations"); - - $comparator = new \Doctrine\DBAL\Schema\Comparator; - $diff = $comparator->diffTable($tableFetched, $table); - - $this->assertFalse($diff, "no changes expected."); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php deleted file mode 100755 index 231b542116..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php +++ /dev/null @@ -1,39 +0,0 @@ -markTestSkipped('Foo'); - } - - $username = $GLOBALS['db_username']; - - $query = "GRANT ALL PRIVILEGES TO ".$username; - - $conn = \Doctrine\Tests\TestUtil::getTempConnection(); - $conn->executeUpdate($query); - } - - public function testRenameTable() - { - $this->_sm->tryMethod('DropTable', 'list_tables_test'); - $this->_sm->tryMethod('DropTable', 'list_tables_test_new_name'); - - $this->createTestTable('list_tables_test'); - $this->_sm->renameTable('list_tables_test', 'list_tables_test_new_name'); - - $tables = $this->_sm->listTables(); - - $this->assertHasTable($tables, 'list_tables_test_new_name'); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php deleted file mode 100755 index 0b6c2606aa..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ /dev/null @@ -1,279 +0,0 @@ -_conn) { - return; - } - - $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression(null); - } - - /** - * @group DBAL-177 - */ - public function testGetSearchPath() - { - $params = $this->_conn->getParams(); - - $paths = $this->_sm->getSchemaSearchPaths(); - $this->assertEquals(array($params['user'], 'public'), $paths); - } - - /** - * @group DBAL-244 - */ - public function testGetSchemaNames() - { - $names = $this->_sm->getSchemaNames(); - - $this->assertInternalType('array', $names); - $this->assertTrue(count($names) > 0); - $this->assertTrue(in_array('public', $names), "The public schema should be found."); - } - - /** - * @group DBAL-21 - */ - public function testSupportDomainTypeFallback() - { - $createDomainTypeSQL = "CREATE DOMAIN MyMoney AS DECIMAL(18,2)"; - $this->_conn->exec($createDomainTypeSQL); - - $createTableSQL = "CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)"; - $this->_conn->exec($createTableSQL); - - $table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test'); - $this->assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $table->getColumn('value')->getType()); - - Type::addType('MyMoney', 'Doctrine\Tests\DBAL\Functional\Schema\MoneyType'); - $this->_conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'MyMoney'); - - $table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test'); - $this->assertInstanceOf('Doctrine\Tests\DBAL\Functional\Schema\MoneyType', $table->getColumn('value')->getType()); - } - - /** - * @group DBAL-37 - */ - public function testDetectsAutoIncrement() - { - $autoincTable = new \Doctrine\DBAL\Schema\Table('autoinc_table'); - $column = $autoincTable->addColumn('id', 'integer'); - $column->setAutoincrement(true); - $this->_sm->createTable($autoincTable); - $autoincTable = $this->_sm->listTableDetails('autoinc_table'); - - $this->assertTrue($autoincTable->getColumn('id')->getAutoincrement()); - } - - /** - * @group DBAL-37 - */ - public function testAlterTableAutoIncrementAdd() - { - $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_add'); - $column = $tableFrom->addColumn('id', 'integer'); - $this->_sm->createTable($tableFrom); - $tableFrom = $this->_sm->listTableDetails('autoinc_table_add'); - $this->assertFalse($tableFrom->getColumn('id')->getAutoincrement()); - - $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_add'); - $column = $tableTo->addColumn('id', 'integer'); - $column->setAutoincrement(true); - - $c = new \Doctrine\DBAL\Schema\Comparator(); - $diff = $c->diffTable($tableFrom, $tableTo); - $sql = $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff); - $this->assertEquals(array( - "CREATE SEQUENCE autoinc_table_add_id_seq", - "SELECT setval('autoinc_table_add_id_seq', (SELECT MAX(id) FROM autoinc_table_add))", - "ALTER TABLE autoinc_table_add ALTER id SET DEFAULT nextval('autoinc_table_add_id_seq')", - ), $sql); - - $this->_sm->alterTable($diff); - $tableFinal = $this->_sm->listTableDetails('autoinc_table_add'); - $this->assertTrue($tableFinal->getColumn('id')->getAutoincrement()); - } - - /** - * @group DBAL-37 - */ - public function testAlterTableAutoIncrementDrop() - { - $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop'); - $column = $tableFrom->addColumn('id', 'integer'); - $column->setAutoincrement(true); - $this->_sm->createTable($tableFrom); - $tableFrom = $this->_sm->listTableDetails('autoinc_table_drop'); - $this->assertTrue($tableFrom->getColumn('id')->getAutoincrement()); - - $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop'); - $column = $tableTo->addColumn('id', 'integer'); - - $c = new \Doctrine\DBAL\Schema\Comparator(); - $diff = $c->diffTable($tableFrom, $tableTo); - $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $diff, "There should be a difference and not false being returned from the table comparison"); - $this->assertEquals(array("ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT"), $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff)); - - $this->_sm->alterTable($diff); - $tableFinal = $this->_sm->listTableDetails('autoinc_table_drop'); - $this->assertFalse($tableFinal->getColumn('id')->getAutoincrement()); - } - - /** - * @group DBAL-75 - */ - public function testTableWithSchema() - { - $this->_conn->exec('CREATE SCHEMA nested'); - - $nestedRelatedTable = new \Doctrine\DBAL\Schema\Table('nested.schemarelated'); - $column = $nestedRelatedTable->addColumn('id', 'integer'); - $column->setAutoincrement(true); - $nestedRelatedTable->setPrimaryKey(array('id')); - - $nestedSchemaTable = new \Doctrine\DBAL\Schema\Table('nested.schematable'); - $column = $nestedSchemaTable->addColumn('id', 'integer'); - $column->setAutoincrement(true); - $nestedSchemaTable->setPrimaryKey(array('id')); - $nestedSchemaTable->addUnnamedForeignKeyConstraint($nestedRelatedTable, array('id'), array('id')); - - $this->_sm->createTable($nestedRelatedTable); - $this->_sm->createTable($nestedSchemaTable); - - $tables = $this->_sm->listTableNames(); - $this->assertContains('nested.schematable', $tables, "The table should be detected with its non-public schema."); - - $nestedSchemaTable = $this->_sm->listTableDetails('nested.schematable'); - $this->assertTrue($nestedSchemaTable->hasColumn('id')); - $this->assertEquals(array('id'), $nestedSchemaTable->getPrimaryKey()->getColumns()); - - $relatedFks = $nestedSchemaTable->getForeignKeys(); - $this->assertEquals(1, count($relatedFks)); - $relatedFk = array_pop($relatedFks); - $this->assertEquals("nested.schemarelated", $relatedFk->getForeignTableName()); - } - - /** - * @group DBAL-91 - * @group DBAL-88 - */ - public function testReturnQuotedAssets() - { - $sql = 'create table dbal91_something ( id integer CONSTRAINT id_something PRIMARY KEY NOT NULL ,"table" integer );'; - $this->_conn->exec($sql); - - $sql = 'ALTER TABLE dbal91_something ADD CONSTRAINT something_input FOREIGN KEY( "table" ) REFERENCES dbal91_something ON UPDATE CASCADE;'; - $this->_conn->exec($sql); - - $table = $this->_sm->listTableDetails('dbal91_something'); - - $this->assertEquals( - array( - "CREATE TABLE dbal91_something (id INT NOT NULL, \"table\" INT DEFAULT NULL, PRIMARY KEY(id))", - "CREATE INDEX IDX_A9401304ECA7352B ON dbal91_something (\"table\")", - ), - $this->_conn->getDatabasePlatform()->getCreateTableSQL($table) - ); - } - - /** - * @group DBAL-204 - */ - public function testFilterSchemaExpression() - { - $testTable = new \Doctrine\DBAL\Schema\Table('dbal204_test_prefix'); - $column = $testTable->addColumn('id', 'integer'); - $this->_sm->createTable($testTable); - $testTable = new \Doctrine\DBAL\Schema\Table('dbal204_without_prefix'); - $column = $testTable->addColumn('id', 'integer'); - $this->_sm->createTable($testTable); - - $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_#'); - $names = $this->_sm->listTableNames(); - $this->assertEquals(2, count($names)); - - $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_test#'); - $names = $this->_sm->listTableNames(); - $this->assertEquals(1, count($names)); - } - - public function testListForeignKeys() - { - if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Does not support foreign key constraints.'); - } - - $fkOptions = array('SET NULL', 'SET DEFAULT', 'NO ACTION','CASCADE', 'RESTRICT'); - $foreignKeys = array(); - $fkTable = $this->getTestTable('test_create_fk1'); - for($i = 0; $i < count($fkOptions); $i++) { - $fkTable->addColumn("foreign_key_test$i", 'integer'); - $foreignKeys[] = new \Doctrine\DBAL\Schema\ForeignKeyConstraint( - array("foreign_key_test$i"), 'test_create_fk2', array('id'), "foreign_key_test_$i"."_fk", array('onDelete' => $fkOptions[$i])); - } - $this->_sm->dropAndCreateTable($fkTable); - $this->createTestTable('test_create_fk2'); - - foreach($foreignKeys as $foreignKey) { - $this->_sm->createForeignKey($foreignKey, 'test_create_fk1'); - } - $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1'); - $this->assertEquals(count($foreignKeys), count($fkeys), "Table 'test_create_fk1' has to have " . count($foreignKeys) . " foreign keys."); - for ($i = 0; $i < count($fkeys); $i++) { - $this->assertEquals(array("foreign_key_test$i"), array_map('strtolower', $fkeys[$i]->getLocalColumns())); - $this->assertEquals(array('id'), array_map('strtolower', $fkeys[$i]->getForeignColumns())); - $this->assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName())); - if ($foreignKeys[$i]->getOption('onDelete') == 'NO ACTION') { - $this->assertFalse($fkeys[$i]->hasOption('onDelete'), 'Unexpected option: '. $fkeys[$i]->getOption('onDelete')); - } else { - $this->assertEquals($foreignKeys[$i]->getOption('onDelete'), $fkeys[$i]->getOption('onDelete')); - } - } - } - - /** - * @group DBAL-511 - */ - public function testDefaultValueCharacterVarying() - { - $testTable = new \Doctrine\DBAL\Schema\Table('dbal511_default'); - $testTable->addColumn('id', 'integer'); - $testTable->addColumn('def', 'string', array('default' => 'foo')); - $testTable->setPrimaryKey(array('id')); - - $this->_sm->createTable($testTable); - - $databaseTable = $this->_sm->listTableDetails($testTable->getName()); - - $this->assertEquals('foo', $databaseTable->getColumn('def')->getDefault()); - } -} - -class MoneyType extends Type -{ - - public function getName() - { - return "MyMoney"; - } - - public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) - { - return 'MyMoney'; - } - -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php deleted file mode 100755 index b6372b4a30..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php +++ /dev/null @@ -1,37 +0,0 @@ -addColumn('id', 'integer'); - $table->addColumn('todrop', 'decimal', array('default' => 10.2)); - - $this->_sm->createTable($table); - - $diff = new TableDiff('sqlsrv_drop_column', array(), array(), array( - new Column('todrop', Type::getType('decimal')) - )); - $this->_sm->alterTable($diff); - - $columns = $this->_sm->listTableColumns('sqlsrv_drop_column'); - $this->assertEquals(1, count($columns)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php deleted file mode 100755 index 2f30c3cc58..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ /dev/null @@ -1,647 +0,0 @@ -getPlatformName(); - - if ($this->_conn->getDatabasePlatform()->getName() !== $dbms) { - $this->markTestSkipped(get_class($this) . ' requires the use of ' . $dbms); - } - - $this->_sm = $this->_conn->getSchemaManager(); - } - - /** - * @group DBAL-195 - */ - public function testDropAndCreateSequence() - { - if(!$this->_conn->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped($this->_conn->getDriver()->getName().' does not support sequences.'); - } - - $sequence = new \Doctrine\DBAL\Schema\Sequence('dropcreate_sequences_test_seq', 20, 10); - $this->_sm->dropAndCreateSequence($sequence); - } - - public function testListSequences() - { - if(!$this->_conn->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped($this->_conn->getDriver()->getName().' does not support sequences.'); - } - - $sequence = new \Doctrine\DBAL\Schema\Sequence('list_sequences_test_seq', 20, 10); - $this->_sm->createSequence($sequence); - - $sequences = $this->_sm->listSequences(); - - $this->assertInternalType('array', $sequences, 'listSequences() should return an array.'); - - $foundSequence = null; - foreach($sequences AS $sequence) { - $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $sequence, 'Array elements of listSequences() should be Sequence instances.'); - if(strtolower($sequence->getName()) == 'list_sequences_test_seq') { - $foundSequence = $sequence; - } - } - - $this->assertNotNull($foundSequence, "Sequence with name 'list_sequences_test_seq' was not found."); - $this->assertEquals(20, $foundSequence->getAllocationSize(), "Allocation Size is expected to be 20."); - $this->assertEquals(10, $foundSequence->getInitialValue(), "Initial Value is expected to be 10."); - } - - public function testListDatabases() - { - if (!$this->_sm->getDatabasePlatform()->supportsCreateDropDatabase()) { - $this->markTestSkipped('Cannot drop Database client side with this Driver.'); - } - - $this->_sm->dropAndCreateDatabase('test_create_database'); - $databases = $this->_sm->listDatabases(); - - $databases = \array_map('strtolower', $databases); - - $this->assertEquals(true, \in_array('test_create_database', $databases)); - } - - public function testListTables() - { - $this->createTestTable('list_tables_test'); - $tables = $this->_sm->listTables(); - - $this->assertInternalType('array', $tables); - $this->assertTrue(count($tables) > 0, "List Tables has to find at least one table named 'list_tables_test'."); - - $foundTable = false; - foreach ($tables AS $table) { - $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table); - if (strtolower($table->getName()) == 'list_tables_test') { - $foundTable = true; - - $this->assertTrue($table->hasColumn('id')); - $this->assertTrue($table->hasColumn('test')); - $this->assertTrue($table->hasColumn('foreign_key_test')); - } - } - - $this->assertTrue( $foundTable , "The 'list_tables_test' table has to be found."); - } - - public function createListTableColumns() - { - $table = new \Doctrine\DBAL\Schema\Table('list_table_columns'); - $table->addColumn('id', 'integer', array('notnull' => true)); - $table->addColumn('test', 'string', array('length' => 255, 'notnull' => false, 'default' => 'expected default')); - $table->addColumn('foo', 'text', array('notnull' => true)); - $table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false)); - $table->addColumn('baz1', 'datetime'); - $table->addColumn('baz2', 'time'); - $table->addColumn('baz3', 'date'); - $table->setPrimaryKey(array('id')); - - return $table; - } - - public function testListTableColumns() - { - $table = $this->createListTableColumns(); - - $this->_sm->dropAndCreateTable($table); - - $columns = $this->_sm->listTableColumns('list_table_columns'); - - $this->assertArrayHasKey('id', $columns); - $this->assertEquals('id', strtolower($columns['id']->getname())); - $this->assertInstanceOf('Doctrine\DBAL\Types\IntegerType', $columns['id']->gettype()); - $this->assertEquals(false, $columns['id']->getunsigned()); - $this->assertEquals(true, $columns['id']->getnotnull()); - $this->assertEquals(null, $columns['id']->getdefault()); - $this->assertInternalType('array', $columns['id']->getPlatformOptions()); - - $this->assertArrayHasKey('test', $columns); - $this->assertEquals('test', strtolower($columns['test']->getname())); - $this->assertInstanceOf('Doctrine\DBAL\Types\StringType', $columns['test']->gettype()); - $this->assertEquals(255, $columns['test']->getlength()); - $this->assertEquals(false, $columns['test']->getfixed()); - $this->assertEquals(false, $columns['test']->getnotnull()); - $this->assertEquals('expected default', $columns['test']->getdefault()); - $this->assertInternalType('array', $columns['test']->getPlatformOptions()); - - $this->assertEquals('foo', strtolower($columns['foo']->getname())); - $this->assertInstanceOf('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype()); - $this->assertEquals(false, $columns['foo']->getunsigned()); - $this->assertEquals(false, $columns['foo']->getfixed()); - $this->assertEquals(true, $columns['foo']->getnotnull()); - $this->assertEquals(null, $columns['foo']->getdefault()); - $this->assertInternalType('array', $columns['foo']->getPlatformOptions()); - - $this->assertEquals('bar', strtolower($columns['bar']->getname())); - $this->assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype()); - $this->assertEquals(null, $columns['bar']->getlength()); - $this->assertEquals(10, $columns['bar']->getprecision()); - $this->assertEquals(4, $columns['bar']->getscale()); - $this->assertEquals(false, $columns['bar']->getunsigned()); - $this->assertEquals(false, $columns['bar']->getfixed()); - $this->assertEquals(false, $columns['bar']->getnotnull()); - $this->assertEquals(null, $columns['bar']->getdefault()); - $this->assertInternalType('array', $columns['bar']->getPlatformOptions()); - - $this->assertEquals('baz1', strtolower($columns['baz1']->getname())); - $this->assertInstanceOf('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype()); - $this->assertEquals(true, $columns['baz1']->getnotnull()); - $this->assertEquals(null, $columns['baz1']->getdefault()); - $this->assertInternalType('array', $columns['baz1']->getPlatformOptions()); - - $this->assertEquals('baz2', strtolower($columns['baz2']->getname())); - $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); - $this->assertEquals(true, $columns['baz2']->getnotnull()); - $this->assertEquals(null, $columns['baz2']->getdefault()); - $this->assertInternalType('array', $columns['baz2']->getPlatformOptions()); - - $this->assertEquals('baz3', strtolower($columns['baz3']->getname())); - $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); - $this->assertEquals(true, $columns['baz3']->getnotnull()); - $this->assertEquals(null, $columns['baz3']->getdefault()); - $this->assertInternalType('array', $columns['baz3']->getPlatformOptions()); - } - - public function testListTableColumnsDispatchEvent() - { - $table = $this->createListTableColumns(); - - $this->_sm->dropAndCreateTable($table); - - $listenerMock = $this->getMock('ListTableColumnsDispatchEventListener', array('onSchemaColumnDefinition')); - $listenerMock - ->expects($this->exactly(7)) - ->method('onSchemaColumnDefinition'); - - $oldEventManager = $this->_sm->getDatabasePlatform()->getEventManager(); - - $eventManager = new EventManager(); - $eventManager->addEventListener(array(Events::onSchemaColumnDefinition), $listenerMock); - - $this->_sm->getDatabasePlatform()->setEventManager($eventManager); - - $this->_sm->listTableColumns('list_table_columns'); - - $this->_sm->getDatabasePlatform()->setEventManager($oldEventManager); - } - - public function testListTableIndexesDispatchEvent() - { - $table = $this->getTestTable('list_table_indexes_test'); - $table->addUniqueIndex(array('test'), 'test_index_name'); - $table->addIndex(array('id', 'test'), 'test_composite_idx'); - - $this->_sm->dropAndCreateTable($table); - - $listenerMock = $this->getMock('ListTableIndexesDispatchEventListener', array('onSchemaIndexDefinition')); - $listenerMock - ->expects($this->exactly(3)) - ->method('onSchemaIndexDefinition'); - - $oldEventManager = $this->_sm->getDatabasePlatform()->getEventManager(); - - $eventManager = new EventManager(); - $eventManager->addEventListener(array(Events::onSchemaIndexDefinition), $listenerMock); - - $this->_sm->getDatabasePlatform()->setEventManager($eventManager); - - $this->_sm->listTableIndexes('list_table_indexes_test'); - - $this->_sm->getDatabasePlatform()->setEventManager($oldEventManager); - } - - public function testDiffListTableColumns() - { - if ($this->_sm->getDatabasePlatform()->getName() == 'oracle') { - $this->markTestSkipped('Does not work with Oracle, since it cannot detect DateTime, Date and Time differenecs (at the moment).'); - } - - $offlineTable = $this->createListTableColumns(); - $onlineTable = $this->_sm->listTableDetails('list_table_columns'); - - $comparator = new \Doctrine\DBAL\Schema\Comparator(); - $diff = $comparator->diffTable($offlineTable, $onlineTable); - - $this->assertFalse($diff, "No differences should be detected with the offline vs online schema."); - } - - public function testListTableIndexes() - { - $table = $this->getTestCompositeTable('list_table_indexes_test'); - $table->addUniqueIndex(array('test'), 'test_index_name'); - $table->addIndex(array('id', 'test'), 'test_composite_idx'); - - $this->_sm->dropAndCreateTable($table); - - $tableIndexes = $this->_sm->listTableIndexes('list_table_indexes_test'); - - $this->assertEquals(3, count($tableIndexes)); - - $this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.'); - $this->assertEquals(array('id', 'other_id'), array_map('strtolower', $tableIndexes['primary']->getColumns())); - $this->assertTrue($tableIndexes['primary']->isUnique()); - $this->assertTrue($tableIndexes['primary']->isPrimary()); - - $this->assertEquals('test_index_name', $tableIndexes['test_index_name']->getName()); - $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test_index_name']->getColumns())); - $this->assertTrue($tableIndexes['test_index_name']->isUnique()); - $this->assertFalse($tableIndexes['test_index_name']->isPrimary()); - - $this->assertEquals('test_composite_idx', $tableIndexes['test_composite_idx']->getName()); - $this->assertEquals(array('id', 'test'), array_map('strtolower', $tableIndexes['test_composite_idx']->getColumns())); - $this->assertFalse($tableIndexes['test_composite_idx']->isUnique()); - $this->assertFalse($tableIndexes['test_composite_idx']->isPrimary()); - } - - public function testDropAndCreateIndex() - { - $table = $this->getTestTable('test_create_index'); - $table->addUniqueIndex(array('test'), 'test'); - $this->_sm->dropAndCreateTable($table); - - $this->_sm->dropAndCreateIndex($table->getIndex('test'), $table); - $tableIndexes = $this->_sm->listTableIndexes('test_create_index'); - $this->assertInternalType('array', $tableIndexes); - - $this->assertEquals('test', strtolower($tableIndexes['test']->getName())); - $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns())); - $this->assertTrue($tableIndexes['test']->isUnique()); - $this->assertFalse($tableIndexes['test']->isPrimary()); - } - - public function testCreateTableWithForeignKeys() - { - if(!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); - } - - $tableB = $this->getTestTable('test_foreign'); - - $this->_sm->dropAndCreateTable($tableB); - - $tableA = $this->getTestTable('test_create_fk'); - $tableA->addForeignKeyConstraint('test_foreign', array('foreign_key_test'), array('id')); - - $this->_sm->dropAndCreateTable($tableA); - - $fkTable = $this->_sm->listTableDetails('test_create_fk'); - $fkConstraints = $fkTable->getForeignKeys(); - $this->assertEquals(1, count($fkConstraints), "Table 'test_create_fk1' has to have one foreign key."); - - $fkConstraint = current($fkConstraints); - $this->assertInstanceOf('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint); - $this->assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName())); - $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns())); - $this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns())); - - $this->assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), "The columns of a foreign key constraint should always be indexed."); - } - - public function testListForeignKeys() - { - if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Does not support foreign key constraints.'); - } - - $this->createTestTable('test_create_fk1'); - $this->createTestTable('test_create_fk2'); - - $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint( - array('foreign_key_test'), 'test_create_fk2', array('id'), 'foreign_key_test_fk', array('onDelete' => 'CASCADE') - ); - - $this->_sm->createForeignKey($foreignKey, 'test_create_fk1'); - - $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1'); - - $this->assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key."); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); - $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns())); - $this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns())); - $this->assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName())); - - if($fkeys[0]->hasOption('onDelete')) { - $this->assertEquals('CASCADE', $fkeys[0]->getOption('onDelete')); - } - } - - protected function getCreateExampleViewSql() - { - $this->markTestSkipped('No Create Example View SQL was defined for this SchemaManager'); - } - - public function testCreateSchema() - { - $this->createTestTable('test_table'); - - $schema = $this->_sm->createSchema(); - $this->assertTrue($schema->hasTable('test_table')); - } - - public function testAlterTableScenario() - { - if(!$this->_sm->getDatabasePlatform()->supportsAlterTable()) { - $this->markTestSkipped('Alter Table is not supported by this platform.'); - } - - $this->createTestTable('alter_table'); - $this->createTestTable('alter_table_foreign'); - - $table = $this->_sm->listTableDetails('alter_table'); - $this->assertTrue($table->hasColumn('id')); - $this->assertTrue($table->hasColumn('test')); - $this->assertTrue($table->hasColumn('foreign_key_test')); - $this->assertEquals(0, count($table->getForeignKeys())); - $this->assertEquals(1, count($table->getIndexes())); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); - $tableDiff->addedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', Type::getType('integer')); - $tableDiff->removedColumns['test'] = $table->getColumn('test'); - - $this->_sm->alterTable($tableDiff); - - $table = $this->_sm->listTableDetails('alter_table'); - $this->assertFalse($table->hasColumn('test')); - $this->assertTrue($table->hasColumn('foo')); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); - $tableDiff->addedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo')); - - $this->_sm->alterTable($tableDiff); - - $table = $this->_sm->listTableDetails('alter_table'); - $this->assertEquals(2, count($table->getIndexes())); - $this->assertTrue($table->hasIndex('foo_idx')); - $this->assertEquals(array('foo'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns())); - $this->assertFalse($table->getIndex('foo_idx')->isPrimary()); - $this->assertFalse($table->getIndex('foo_idx')->isUnique()); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); - $tableDiff->changedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test')); - - $this->_sm->alterTable($tableDiff); - - $table = $this->_sm->listTableDetails('alter_table'); - $this->assertEquals(2, count($table->getIndexes())); - $this->assertTrue($table->hasIndex('foo_idx')); - $this->assertEquals(array('foo', 'foreign_key_test'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns())); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); - $tableDiff->removedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test')); - $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('foreign_key_test'), 'alter_table_foreign', array('id')); - $tableDiff->addedForeignKeys[] = $fk; - - $this->_sm->alterTable($tableDiff); - $table = $this->_sm->listTableDetails('alter_table'); - - // dont check for index size here, some platforms automatically add indexes for foreign keys. - $this->assertFalse($table->hasIndex('foo_idx')); - - $this->assertEquals(1, count($table->getForeignKeys())); - $fks = $table->getForeignKeys(); - $foreignKey = current($fks); - $this->assertEquals('alter_table_foreign', strtolower($foreignKey->getForeignTableName())); - $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $foreignKey->getColumns())); - $this->assertEquals(array('id'), array_map('strtolower', $foreignKey->getForeignColumns())); - } - - public function testCreateAndListViews() - { - if (!$this->_sm->getDatabasePlatform()->supportsViews()) { - $this->markTestSkipped('Views is not supported by this platform.'); - } - - $this->createTestTable('view_test_table'); - - $name = "doctrine_test_view"; - $sql = "SELECT * FROM view_test_table"; - - $view = new \Doctrine\DBAL\Schema\View($name, $sql); - - $this->_sm->dropAndCreateView($view); - - $views = $this->_sm->listViews(); - } - - public function testAutoincrementDetection() - { - if (!$this->_sm->getDatabasePlatform()->supportsIdentityColumns()) { - $this->markTestSkipped('This test is only supported on platforms that have autoincrement'); - } - - $table = new \Doctrine\DBAL\Schema\Table('test_autoincrement'); - $table->setSchemaConfig($this->_sm->createSchemaConfig()); - $table->addColumn('id', 'integer', array('autoincrement' => true)); - $table->setPrimaryKey(array('id')); - - $this->_sm->createTable($table); - - $inferredTable = $this->_sm->listTableDetails('test_autoincrement'); - $this->assertTrue($inferredTable->hasColumn('id')); - $this->assertTrue($inferredTable->getColumn('id')->getAutoincrement()); - } - - /** - * @group DDC-887 - */ - public function testUpdateSchemaWithForeignKeyRenaming() - { - if (!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); - } - - $table = new \Doctrine\DBAL\Schema\Table('test_fk_base'); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - - $tableFK = new \Doctrine\DBAL\Schema\Table('test_fk_rename'); - $tableFK->setSchemaConfig($this->_sm->createSchemaConfig()); - $tableFK->addColumn('id', 'integer'); - $tableFK->addColumn('fk_id', 'integer'); - $tableFK->setPrimaryKey(array('id')); - $tableFK->addIndex(array('fk_id'), 'fk_idx'); - $tableFK->addForeignKeyConstraint('test_fk_base', array('fk_id'), array('id')); - - $this->_sm->createTable($table); - $this->_sm->createTable($tableFK); - - $tableFKNew = new \Doctrine\DBAL\Schema\Table('test_fk_rename'); - $tableFKNew->setSchemaConfig($this->_sm->createSchemaConfig()); - $tableFKNew->addColumn('id', 'integer'); - $tableFKNew->addColumn('rename_fk_id', 'integer'); - $tableFKNew->setPrimaryKey(array('id')); - $tableFKNew->addIndex(array('rename_fk_id'), 'fk_idx'); - $tableFKNew->addForeignKeyConstraint('test_fk_base', array('rename_fk_id'), array('id')); - - $c = new \Doctrine\DBAL\Schema\Comparator(); - $tableDiff = $c->diffTable($tableFK, $tableFKNew); - - $this->_sm->alterTable($tableDiff); - } - - /** - * @group DBAL-42 - */ - public function testGetColumnComment() - { - if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) { - $this->markTestSkipped('Database does not support column comments.'); - } - - $table = new \Doctrine\DBAL\Schema\Table('column_comment_test'); - $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); - $table->setPrimaryKey(array('id')); - - $this->_sm->createTable($table); - - $columns = $this->_sm->listTableColumns("column_comment_test"); - $this->assertEquals(1, count($columns)); - $this->assertEquals('This is a comment', $columns['id']->getComment()); - } - - /** - * @group DBAL-42 - */ - public function testAutomaticallyAppendCommentOnMarkedColumns() - { - if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) { - $this->markTestSkipped('Database does not support column comments.'); - } - - $table = new \Doctrine\DBAL\Schema\Table('column_comment_test2'); - $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); - $table->addColumn('obj', 'object', array('comment' => 'This is a comment')); - $table->addColumn('arr', 'array', array('comment' => 'This is a comment')); - $table->setPrimaryKey(array('id')); - - $this->_sm->createTable($table); - - $columns = $this->_sm->listTableColumns("column_comment_test2"); - $this->assertEquals(3, count($columns)); - $this->assertEquals('This is a comment', $columns['id']->getComment()); - $this->assertEquals('This is a comment', $columns['obj']->getComment(), "The Doctrine2 Typehint should be stripped from comment."); - $this->assertInstanceOf('Doctrine\DBAL\Types\ObjectType', $columns['obj']->getType(), "The Doctrine2 should be detected from comment hint."); - $this->assertEquals('This is a comment', $columns['arr']->getComment(), "The Doctrine2 Typehint should be stripped from comment."); - $this->assertInstanceOf('Doctrine\DBAL\Types\ArrayType', $columns['arr']->getType(), "The Doctrine2 should be detected from comment hint."); - } - - /** - * @group DBAL-197 - */ - public function testListTableWithBlob() - { - $table = new \Doctrine\DBAL\Schema\Table('test_blob_table'); - $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); - $table->addColumn('binarydata', 'blob', array()); - $table->setPrimaryKey(array('id')); - - $this->_sm->createTable($table); - $blobTable = $this->_sm->listTableDetails('test_blob_table'); - } - - /** - * @param string $name - * @param array $data - */ - protected function createTestTable($name = 'test_table', $data = array()) - { - $options = array(); - if (isset($data['options'])) { - $options = $data['options']; - } - - $table = $this->getTestTable($name, $options); - - $this->_sm->dropAndCreateTable($table); - } - - protected function getTestTable($name, $options=array()) - { - $table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, $options); - $table->setSchemaConfig($this->_sm->createSchemaConfig()); - $table->addColumn('id', 'integer', array('notnull' => true)); - $table->setPrimaryKey(array('id')); - $table->addColumn('test', 'string', array('length' => 255)); - $table->addColumn('foreign_key_test', 'integer'); - return $table; - } - - protected function getTestCompositeTable($name) - { - $table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, array()); - $table->setSchemaConfig($this->_sm->createSchemaConfig()); - $table->addColumn('id', 'integer', array('notnull' => true)); - $table->addColumn('other_id', 'integer', array('notnull' => true)); - $table->setPrimaryKey(array('id', 'other_id')); - $table->addColumn('test', 'string', array('length' => 255)); - return $table; - } - - protected function assertHasTable($tables, $tableName) - { - $foundTable = false; - foreach ($tables AS $table) { - $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table, 'No Table instance was found in tables array.'); - if (strtolower($table->getName()) == 'list_tables_test_new_name') { - $foundTable = true; - } - } - $this->assertTrue($foundTable, "Could not find new table"); - } - - public function testListForeignKeysComposite() - { - if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Does not support foreign key constraints.'); - } - - $this->_sm->createTable($this->getTestTable('test_create_fk3')); - $this->_sm->createTable($this->getTestCompositeTable('test_create_fk4')); - - $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint( - array('id', 'foreign_key_test'), 'test_create_fk4', array('id', 'other_id'), 'foreign_key_test_fk' - ); - - $this->_sm->createForeignKey($foreignKey, 'test_create_fk3'); - - $fkeys = $this->_sm->listTableForeignKeys('test_create_fk3'); - - $this->assertEquals(1, count($fkeys), "Table 'test_create_fk3' has to have one foreign key."); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); - $this->assertEquals(array('id', 'foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns())); - $this->assertEquals(array('id', 'other_id'), array_map('strtolower', $fkeys[0]->getForeignColumns())); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php deleted file mode 100755 index 2dccb511e0..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ /dev/null @@ -1,46 +0,0 @@ -_sm->listDatabases(); - } - - public function testCreateAndDropDatabase() - { - $path = dirname(__FILE__).'/test_create_and_drop_sqlite_database.sqlite'; - - $this->_sm->createDatabase($path); - $this->assertEquals(true, file_exists($path)); - $this->_sm->dropDatabase($path); - $this->assertEquals(false, file_exists($path)); - } - - /** - * @expectedException \Doctrine\DBAL\DBALException - */ - public function testRenameTable() - { - $this->_sm->renameTable('oldname', 'newname'); - } - - public function testAutoincrementDetection() - { - $this->markTestSkipped( - 'There is currently no reliable way to determine whether an SQLite column is marked as ' - . 'auto-increment. So, while it does support a single identity column, we cannot with ' - . 'certainty determine which it is.'); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php deleted file mode 100755 index ea9ac53330..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php +++ /dev/null @@ -1,59 +0,0 @@ -_conn->getDatabasePlatform(); - if ($platform->getName() == "sqlite") { - $this->markTestSkipped('TableGenerator does not work with SQLite'); - } - - try { - $schema = new \Doctrine\DBAL\Schema\Schema(); - $visitor = new \Doctrine\DBAL\Id\TableGeneratorSchemaVisitor(); - $schema->visit($visitor); - - foreach ($schema->toSql($platform) as $sql) { - $this->_conn->exec($sql); - } - - } catch(\Exception $e) { - } - $this->generator = new TableGenerator($this->_conn); - } - - public function testNextVal() - { - $id1 = $this->generator->nextValue("tbl1"); - $id2 = $this->generator->nextValue("tbl1"); - $id3 = $this->generator->nextValue("tbl2"); - - $this->assertTrue($id1 > 0, "First id has to be larger than 0"); - $this->assertEquals($id1 + 1, $id2, "Second id is one larger than first one."); - $this->assertEquals($id1, $id3, "First ids from different tables are equal."); - } - - public function testNextValNotAffectedByOuterTransactions() - { - $this->_conn->beginTransaction(); - $id1 = $this->generator->nextValue("tbl1"); - $this->_conn->rollBack(); - $id2 = $this->generator->nextValue("tbl1"); - - $this->assertTrue($id1 > 0, "First id has to be larger than 0"); - $this->assertEquals($id1 + 1, $id2, "Second id is one larger than first one."); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php deleted file mode 100755 index 9fa92c7a65..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php +++ /dev/null @@ -1,102 +0,0 @@ -_conn->exec($this->_conn->getDatabasePlatform()->getDropTableSQL("nontemporary")); - } catch(\Exception $e) { - - } - } - - public function tearDown() - { - if ($this->_conn) { - try { - $tempTable = $this->_conn->getDatabasePlatform()->getTemporaryTableName("temporary"); - $this->_conn->exec($this->_conn->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable)); - } catch(\Exception $e) { } - } - } - - /** - * @group DDC-1337 - * @return void - */ - public function testDropTemporaryTableNotAutoCommitTransaction() - { - $platform = $this->_conn->getDatabasePlatform(); - $columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true)); - $tempTable = $platform->getTemporaryTableName("temporary"); - - $createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' - . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')'; - $this->_conn->executeUpdate($createTempTableSQL); - - $table = new Table("nontemporary"); - $table->addColumn("id", "integer"); - $table->setPrimaryKey(array('id')); - - foreach ($platform->getCreateTableSQL($table) AS $sql) { - $this->_conn->executeQuery($sql); - } - - $this->_conn->beginTransaction(); - $this->_conn->insert("nontemporary", array("id" => 1)); - $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable)); - $this->_conn->insert("nontemporary", array("id" => 2)); - - $this->_conn->rollback(); - - $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary'); - $this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit."); - } - - /** - * @group DDC-1337 - * @return void - */ - public function testCreateTemporaryTableNotAutoCommitTransaction() - { - $platform = $this->_conn->getDatabasePlatform(); - $columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true)); - $tempTable = $platform->getTemporaryTableName("temporary"); - - $createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' - . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')'; - - $table = new Table("nontemporary"); - $table->addColumn("id", "integer"); - $table->setPrimaryKey(array('id')); - - foreach ($platform->getCreateTableSQL($table) AS $sql) { - $this->_conn->executeQuery($sql); - } - - $this->_conn->beginTransaction(); - $this->_conn->insert("nontemporary", array("id" => 1)); - - $this->_conn->exec($createTempTableSQL); - $this->_conn->insert("nontemporary", array("id" => 2)); - - $this->_conn->rollback(); - - try { - $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable)); - } catch(\Exception $e) { - - } - - $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary'); - $this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit."); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php deleted file mode 100755 index 1393404b8a..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php +++ /dev/null @@ -1,27 +0,0 @@ -_conn->getDatabasePlatform()->getName() != "postgresql") { - $this->markTestSkipped('PostgreSQL only test'); - } - - $table = new \Doctrine\DBAL\Schema\Table("domains"); - $table->addColumn('id', 'integer'); - $table->addColumn('parent_id', 'integer'); - $table->setPrimaryKey(array('id')); - $table->addForeignKeyConstraint('domains', array('parent_id'), array('id')); - - $this->_conn->getSchemaManager()->createTable($table); - $table = $this->_conn->getSchemaManager()->listTableDetails('domains'); - - $this->assertEquals('domains', $table->getName()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php deleted file mode 100755 index 4448ed73de..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php +++ /dev/null @@ -1,48 +0,0 @@ -_conn->getDatabasePlatform()->getName() != 'oracle') { - $this->markTestSkipped('OCI8 only test'); - } - - if ($this->_conn->getSchemaManager()->tablesExist('DBAL202')) { - $this->_conn->executeQuery('DELETE FROM DBAL202'); - } else { - $table = new \Doctrine\DBAL\Schema\Table('DBAL202'); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - - $this->_conn->getSchemaManager()->createTable($table); - } - } - - public function testStatementRollback() - { - $stmt = $this->_conn->prepare('INSERT INTO DBAL202 VALUES (8)'); - $this->_conn->beginTransaction(); - $stmt->execute(); - $this->_conn->rollback(); - - $this->assertEquals(0, $this->_conn->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn()); - } - - public function testStatementCommit() - { - $stmt = $this->_conn->prepare('INSERT INTO DBAL202 VALUES (8)'); - $this->_conn->beginTransaction(); - $stmt->execute(); - $this->_conn->commit(); - - $this->assertEquals(1, $this->_conn->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn()); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php deleted file mode 100755 index 3eb10ff4f8..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php +++ /dev/null @@ -1,37 +0,0 @@ -_conn->getDatabasePlatform()->getName() !== "postgresql") { - $this->markTestSkipped('PostgreSQL Only test'); - } - } - - public function testSearchPathSchemaChanges() - { - $table = new Table("dbal510tbl"); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - - $this->_conn->getSchemaManager()->createTable($table); - - $onlineTable = $this->_conn->getSchemaManager()->listTableDetails('dbal510tbl'); - - $comparator = new Comparator(); - $diff = $comparator->diffTable($onlineTable, $table); - - $this->assertFalse($diff); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php deleted file mode 100755 index 67e6ddaeab..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php +++ /dev/null @@ -1,101 +0,0 @@ -_conn->getSchemaManager(); - - $table = new \Doctrine\DBAL\Schema\Table("type_conversion"); - $table->addColumn('id', 'integer', array('notnull' => false)); - $table->addColumn('test_string', 'string', array('notnull' => false)); - $table->addColumn('test_boolean', 'boolean', array('notnull' => false)); - $table->addColumn('test_bigint', 'bigint', array('notnull' => false)); - $table->addColumn('test_smallint', 'bigint', array('notnull' => false)); - $table->addColumn('test_datetime', 'datetime', array('notnull' => false)); - $table->addColumn('test_datetimetz', 'datetimetz', array('notnull' => false)); - $table->addColumn('test_date', 'date', array('notnull' => false)); - $table->addColumn('test_time', 'time', array('notnull' => false)); - $table->addColumn('test_text', 'text', array('notnull' => false)); - $table->addColumn('test_array', 'array', array('notnull' => false)); - $table->addColumn('test_object', 'object', array('notnull' => false)); - $table->addColumn('test_float', 'float', array('notnull' => false)); - $table->addColumn('test_decimal', 'decimal', array('notnull' => false, 'scale' => 2, 'precision' => 10)); - $table->setPrimaryKey(array('id')); - - try { - foreach ($this->_conn->getDatabasePlatform()->getCreateTableSQL($table) AS $sql) { - $this->_conn->executeQuery($sql); - } - } catch(\Exception $e) { - - } - } - - static public function dataIdempotentDataConversion() - { - $obj = new \stdClass(); - $obj->foo = "bar"; - $obj->bar = "baz"; - - return array( - array('string', 'ABCDEFGaaaBBB', 'string'), - array('boolean', true, 'bool'), - array('boolean', false, 'bool'), - array('bigint', 12345678, 'string'), - array('smallint', 123, 'int'), - array('datetime', new \DateTime('2010-04-05 10:10:10'), 'DateTime'), - array('datetimetz', new \DateTime('2010-04-05 10:10:10'), 'DateTime'), - array('date', new \DateTime('2010-04-05'), 'DateTime'), - array('time', new \DateTime('10:10:10'), 'DateTime'), - array('text', str_repeat('foo ', 1000), 'string'), - array('array', array('foo' => 'bar'), 'array'), - array('object', $obj, 'object'), - array('float', 1.5, 'float'), - array('decimal', 1.55, 'string'), - ); - } - - /** - * @dataProvider dataIdempotentDataConversion - * @param string $type - * @param mixed $originalValue - * @param string $expectedPhpType - */ - public function testIdempotentDataConversion($type, $originalValue, $expectedPhpType) - { - $columnName = "test_" . $type; - $typeInstance = Type::getType($type); - $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->_conn->getDatabasePlatform()); - - $this->_conn->insert('type_conversion', array('id' => ++self::$typeCounter, $columnName => $insertionValue)); - - $sql = "SELECT " . $columnName . " FROM type_conversion WHERE id = " . self::$typeCounter; - $actualDbValue = $typeInstance->convertToPHPValue($this->_conn->fetchColumn($sql), $this->_conn->getDatabasePlatform()); - - if ($originalValue instanceof \DateTime) { - $this->assertInstanceOf($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType); - } else { - $this->assertInternalType($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType); - } - - if ($type !== "datetimetz") { - $this->assertEquals($originalValue, $actualDbValue, "Conversion between values should produce the same out as in value, but doesnt!"); - - if ($originalValue instanceof \DateTime) { - $this->assertEquals($originalValue->getTimezone()->getName(), $actualDbValue->getTimezone()->getName(), "Timezones should be the same."); - } - } - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php deleted file mode 100755 index f1a3a5983e..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ /dev/null @@ -1,185 +0,0 @@ -addColumn('id', 'integer', array('autoincrement' => true)); - $table->addColumn('test_int', 'integer'); - $table->addColumn('test_string', 'string', array('notnull' => false)); - $table->setPrimaryKey(array('id')); - - foreach ($this->_conn->getDatabasePlatform()->getCreateTableSQL($table) AS $sql) { - $this->_conn->executeQuery($sql); - } - } catch(\Exception $e) { - - } - $this->_conn->executeUpdate('DELETE FROM write_table'); - } - - /** - * @group DBAL-80 - */ - public function testExecuteUpdateFirstTypeIsNull() - { - $sql = "INSERT INTO write_table (test_string, test_int) VALUES (?, ?)"; - $this->_conn->executeUpdate($sql, array("text", 1111), array(null, PDO::PARAM_INT)); - - $sql = "SELECT * FROM write_table WHERE test_string = ? AND test_int = ?"; - $this->assertTrue((bool)$this->_conn->fetchColumn($sql, array("text", 1111))); - } - - public function testExecuteUpdate() - { - $sql = "INSERT INTO write_table (test_int) VALUES ( " . $this->_conn->quote(1) . ")"; - $affected = $this->_conn->executeUpdate($sql); - - $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!"); - } - - public function testExecuteUpdateWithTypes() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $affected = $this->_conn->executeUpdate($sql, array(1, 'foo'), array(\PDO::PARAM_INT, \PDO::PARAM_STR)); - - $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!"); - } - - public function testPrepareRowCountReturnsAffectedRows() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $stmt = $this->_conn->prepare($sql); - - $stmt->bindValue(1, 1); - $stmt->bindValue(2, "foo"); - $stmt->execute(); - - $this->assertEquals(1, $stmt->rowCount()); - } - - public function testPrepareWithPdoTypes() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $stmt = $this->_conn->prepare($sql); - - $stmt->bindValue(1, 1, \PDO::PARAM_INT); - $stmt->bindValue(2, "foo", \PDO::PARAM_STR); - $stmt->execute(); - - $this->assertEquals(1, $stmt->rowCount()); - } - - public function testPrepareWithDbalTypes() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $stmt = $this->_conn->prepare($sql); - - $stmt->bindValue(1, 1, Type::getType('integer')); - $stmt->bindValue(2, "foo", Type::getType('string')); - $stmt->execute(); - - $this->assertEquals(1, $stmt->rowCount()); - } - - public function testPrepareWithDbalTypeNames() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $stmt = $this->_conn->prepare($sql); - - $stmt->bindValue(1, 1, 'integer'); - $stmt->bindValue(2, "foo", 'string'); - $stmt->execute(); - - $this->assertEquals(1, $stmt->rowCount()); - } - - public function insertRows() - { - $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 1, 'test_string' => 'foo'))); - $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 2, 'test_string' => 'bar'))); - } - - public function testInsert() - { - $this->insertRows(); - } - - public function testDelete() - { - $this->insertRows(); - - $this->assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 2))); - $this->assertEquals(1, count($this->_conn->fetchAll('SELECT * FROM write_table'))); - - $this->assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 1))); - $this->assertEquals(0, count($this->_conn->fetchAll('SELECT * FROM write_table'))); - } - - public function testUpdate() - { - $this->insertRows(); - - $this->assertEquals(1, $this->_conn->update('write_table', array('test_string' => 'bar'), array('test_string' => 'foo'))); - $this->assertEquals(2, $this->_conn->update('write_table', array('test_string' => 'baz'), array('test_string' => 'bar'))); - $this->assertEquals(0, $this->_conn->update('write_table', array('test_string' => 'baz'), array('test_string' => 'bar'))); - } - - public function testLastInsertId() - { - if ( ! $this->_conn->getDatabasePlatform()->prefersIdentityColumns()) { - $this->markTestSkipped('Test only works on platforms with identity columns.'); - } - - $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 2, 'test_string' => 'bar'))); - $num = $this->_conn->lastInsertId(); - - $this->assertNotNull($num, "LastInsertId() should not be null."); - $this->assertTrue($num > 0, "LastInsertId() should be non-negative number."); - } - - public function testLastInsertIdSequence() - { - if ( ! $this->_conn->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped('Test only works on platforms with sequences.'); - } - - $sequence = new \Doctrine\DBAL\Schema\Sequence('write_table_id_seq'); - try { - $this->_conn->getSchemaManager()->createSequence($sequence); - } catch(\Exception $e) { - } - - $sequences = $this->_conn->getSchemaManager()->listSequences(); - $this->assertEquals(1, count(array_filter($sequences, function($sequence) { - return $sequence->getName() === 'write_table_id_seq'; - }))); - - $stmt = $this->_conn->query($this->_conn->getDatabasePlatform()->getSequenceNextValSQL('write_table_id_seq')); - $nextSequenceVal = $stmt->fetchColumn(); - - $lastInsertId = $this->_conn->lastInsertId('write_table_id_seq'); - - $this->assertTrue($lastInsertId > 0); - $this->assertEquals($nextSequenceVal, $lastInsertId); - } - - public function testLastInsertIdNoSequenceGiven() - { - if ( ! $this->_conn->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped('Test only works on platforms with sequences.'); - } - - $this->assertFalse($this->_conn->lastInsertId( null )); - - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php deleted file mode 100755 index 00bc0b6fe8..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php +++ /dev/null @@ -1,47 +0,0 @@ -logger = new \Doctrine\DBAL\Logging\DebugStack(); - } - - public function tearDown() - { - unset($this->logger); - } - - public function testLoggedQuery() - { - $this->logger->startQuery('SELECT column FROM table'); - $this->assertEquals( - array( - 1 => array( - 'sql' => 'SELECT column FROM table', - 'params' => null, - 'types' => null, - 'executionMS' => 0, - ), - ), - $this->logger->queries - ); - - $this->logger->stopQuery(); - $this->assertGreaterThan(0, $this->logger->queries[1]['executionMS']); - } - - public function testLoggedQueryDisabled() - { - $this->logger->enabled = false; - $this->logger->startQuery('SELECT column FROM table'); - $this->assertEquals(array(), $this->logger->queries); - - $this->logger->stopQuery(); - $this->assertEquals(array(), $this->logger->queries); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php deleted file mode 100755 index 576430c60b..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php +++ /dev/null @@ -1,49 +0,0 @@ -_platform = $this->createPlatform(); - } - - /** - * @group DDC-1360 - */ - public function testQuoteIdentifier() - { - if ($this->_platform->getName() == "mssql") { - $this->markTestSkipped('Not working this way on mssql.'); - } - - $c = $this->_platform->getIdentifierQuoteCharacter(); - $this->assertEquals($c."test".$c, $this->_platform->quoteIdentifier("test")); - $this->assertEquals($c."test".$c.".".$c."test".$c, $this->_platform->quoteIdentifier("test.test")); - $this->assertEquals(str_repeat($c, 4), $this->_platform->quoteIdentifier($c)); - } - - /** - * @group DDC-1360 - */ - public function testQuoteSingleIdentifier() - { - if ($this->_platform->getName() == "mssql") { - $this->markTestSkipped('Not working this way on mssql.'); - } - - $c = $this->_platform->getIdentifierQuoteCharacter(); - $this->assertEquals($c."test".$c, $this->_platform->quoteSingleIdentifier("test")); - $this->assertEquals($c."test.test".$c, $this->_platform->quoteSingleIdentifier("test.test")); - $this->assertEquals(str_repeat($c, 4), $this->_platform->quoteSingleIdentifier($c)); - } - - public function testGetInvalidtForeignKeyReferentialActionSQL() - { - $this->setExpectedException('InvalidArgumentException'); - $this->_platform->getForeignKeyReferentialActionSQL('unknown'); - } - - public function testGetUnknownDoctrineMappingType() - { - $this->setExpectedException('Doctrine\DBAL\DBALException'); - $this->_platform->getDoctrineTypeMapping('foobar'); - } - - public function testRegisterDoctrineMappingType() - { - $this->_platform->registerDoctrineTypeMapping('foo', 'integer'); - $this->assertEquals('integer', $this->_platform->getDoctrineTypeMapping('foo')); - } - - public function testRegisterUnknownDoctrineMappingType() - { - $this->setExpectedException('Doctrine\DBAL\DBALException'); - $this->_platform->registerDoctrineTypeMapping('foo', 'bar'); - } - - public function testCreateWithNoColumns() - { - $table = new Table('test'); - - $this->setExpectedException('Doctrine\DBAL\DBALException'); - $sql = $this->_platform->getCreateTableSQL($table); - } - - public function testGeneratesTableCreationSql() - { - $table = new Table('test'); - $table->addColumn('id', 'integer', array('notnull' => true, 'autoincrement' => true)); - $table->addColumn('test', 'string', array('notnull' => false, 'length' => 255)); - $table->setPrimaryKey(array('id')); - - $sql = $this->_platform->getCreateTableSQL($table); - $this->assertEquals($this->getGenerateTableSql(), $sql[0]); - } - - abstract public function getGenerateTableSql(); - - public function testGenerateTableWithMultiColumnUniqueIndex() - { - $table = new Table('test'); - $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255)); - $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255)); - $table->addUniqueIndex(array("foo", "bar")); - - $sql = $this->_platform->getCreateTableSQL($table); - $this->assertEquals($this->getGenerateTableWithMultiColumnUniqueIndexSql(), $sql); - } - - abstract public function getGenerateTableWithMultiColumnUniqueIndexSql(); - - public function testGeneratesIndexCreationSql() - { - $indexDef = new \Doctrine\DBAL\Schema\Index('my_idx', array('user_name', 'last_login')); - - $this->assertEquals( - $this->getGenerateIndexSql(), - $this->_platform->getCreateIndexSQL($indexDef, 'mytable') - ); - } - - abstract public function getGenerateIndexSql(); - - public function testGeneratesUniqueIndexCreationSql() - { - $indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true); - - $sql = $this->_platform->getCreateIndexSQL($indexDef, 'test'); - $this->assertEquals($this->getGenerateUniqueIndexSql(), $sql); - } - - abstract public function getGenerateUniqueIndexSql(); - - public function testGeneratesForeignKeyCreationSql() - { - $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), ''); - - $sql = $this->_platform->getCreateForeignKeySQL($fk, 'test'); - $this->assertEquals($sql, $this->getGenerateForeignKeySql()); - } - - abstract public function getGenerateForeignKeySql(); - - public function testGeneratesConstraintCreationSql() - { - $idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false); - $sql = $this->_platform->getCreateConstraintSQL($idx, 'test'); - $this->assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql); - - $pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true); - $sql = $this->_platform->getCreateConstraintSQL($pk, 'test'); - $this->assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql); - - $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk'); - $sql = $this->_platform->getCreateConstraintSQL($fk, 'test'); - $this->assertEquals($this->getGenerateConstraintForeignKeySql(), $sql); - } - - protected function getBitAndComparisonExpressionSql($value1, $value2) - { - return '(' . $value1 . ' & ' . $value2 . ')'; - } - - /** - * @group DDC-1213 - */ - public function testGeneratesBitAndComparisonExpressionSql() - { - $sql = $this->_platform->getBitAndComparisonExpression(2, 4); - $this->assertEquals($this->getBitAndComparisonExpressionSql(2, 4), $sql); - } - - protected function getBitOrComparisonExpressionSql($value1, $value2) - { - return '(' . $value1 . ' | ' . $value2 . ')'; - } - - /** - * @group DDC-1213 - */ - public function testGeneratesBitOrComparisonExpressionSql() - { - $sql = $this->_platform->getBitOrComparisonExpression(2, 4); - $this->assertEquals($this->getBitOrComparisonExpressionSql(2, 4), $sql); - } - - public function getGenerateConstraintUniqueIndexSql() - { - return 'ALTER TABLE test ADD CONSTRAINT constraint_name UNIQUE (test)'; - } - - public function getGenerateConstraintPrimaryIndexSql() - { - return 'ALTER TABLE test ADD CONSTRAINT constraint_name PRIMARY KEY (test)'; - } - - public function getGenerateConstraintForeignKeySql() - { - return 'ALTER TABLE test ADD CONSTRAINT constraint_fk FOREIGN KEY (fk_name) REFERENCES foreign (id)'; - } - - abstract public function getGenerateAlterTableSql(); - - public function testGeneratesTableAlterationSql() - { - $expectedSql = $this->getGenerateAlterTableSql(); - - $tableDiff = new TableDiff('mytable'); - $tableDiff->newName = 'userlist'; - $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('notnull' => false)); - $tableDiff->removedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', \Doctrine\DBAL\Types\Type::getType('integer')); - $tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff( - 'bar', new \Doctrine\DBAL\Schema\Column( - 'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('default' => 'def') - ), - array('type', 'notnull', 'default') - ); - $tableDiff->changedColumns['bloo'] = new \Doctrine\DBAL\Schema\ColumnDiff( - 'bloo', new \Doctrine\DBAL\Schema\Column( - 'bloo', \Doctrine\DBAL\Types\Type::getType('boolean'), array('default' => false) - ), - array('type', 'notnull', 'default') - ); - - $sql = $this->_platform->getAlterTableSQL($tableDiff); - - $this->assertEquals($expectedSql, $sql); - } - - public function testGetCustomColumnDeclarationSql() - { - $field = array('columnDefinition' => 'MEDIUMINT(6) UNSIGNED'); - $this->assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->_platform->getColumnDeclarationSQL('foo', $field)); - } - - public function testGetCreateTableSqlDispatchEvent() - { - $listenerMock = $this->getMock('GetCreateTableSqlDispatchEvenListener', array('onSchemaCreateTable', 'onSchemaCreateTableColumn')); - $listenerMock - ->expects($this->once()) - ->method('onSchemaCreateTable'); - $listenerMock - ->expects($this->exactly(2)) - ->method('onSchemaCreateTableColumn'); - - $eventManager = new EventManager(); - $eventManager->addEventListener(array(Events::onSchemaCreateTable, Events::onSchemaCreateTableColumn), $listenerMock); - - $this->_platform->setEventManager($eventManager); - - $table = new Table('test'); - $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255)); - $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255)); - - $this->_platform->getCreateTableSQL($table); - } - - public function testGetDropTableSqlDispatchEvent() - { - $listenerMock = $this->getMock('GetDropTableSqlDispatchEventListener', array('onSchemaDropTable')); - $listenerMock - ->expects($this->once()) - ->method('onSchemaDropTable'); - - $eventManager = new EventManager(); - $eventManager->addEventListener(array(Events::onSchemaDropTable), $listenerMock); - - $this->_platform->setEventManager($eventManager); - - $this->_platform->getDropTableSQL('TABLE'); - } - - public function testGetAlterTableSqlDispatchEvent() - { - $events = array( - 'onSchemaAlterTable', - 'onSchemaAlterTableAddColumn', - 'onSchemaAlterTableRemoveColumn', - 'onSchemaAlterTableChangeColumn', - 'onSchemaAlterTableRenameColumn' - ); - - $listenerMock = $this->getMock('GetAlterTableSqlDispatchEvenListener', $events); - $listenerMock - ->expects($this->once()) - ->method('onSchemaAlterTable'); - $listenerMock - ->expects($this->once()) - ->method('onSchemaAlterTableAddColumn'); - $listenerMock - ->expects($this->once()) - ->method('onSchemaAlterTableRemoveColumn'); - $listenerMock - ->expects($this->once()) - ->method('onSchemaAlterTableChangeColumn'); - $listenerMock - ->expects($this->once()) - ->method('onSchemaAlterTableRenameColumn'); - - $eventManager = new EventManager(); - $events = array( - Events::onSchemaAlterTable, - Events::onSchemaAlterTableAddColumn, - Events::onSchemaAlterTableRemoveColumn, - Events::onSchemaAlterTableChangeColumn, - Events::onSchemaAlterTableRenameColumn - ); - $eventManager->addEventListener($events, $listenerMock); - - $this->_platform->setEventManager($eventManager); - - $tableDiff = new TableDiff('mytable'); - $tableDiff->addedColumns['added'] = new \Doctrine\DBAL\Schema\Column('added', \Doctrine\DBAL\Types\Type::getType('integer'), array()); - $tableDiff->removedColumns['removed'] = new \Doctrine\DBAL\Schema\Column('removed', \Doctrine\DBAL\Types\Type::getType('integer'), array()); - $tableDiff->changedColumns['changed'] = new \Doctrine\DBAL\Schema\ColumnDiff( - 'changed', new \Doctrine\DBAL\Schema\Column( - 'changed2', \Doctrine\DBAL\Types\Type::getType('string'), array() - ), - array() - ); - $tableDiff->renamedColumns['renamed'] = new \Doctrine\DBAL\Schema\Column('renamed2', \Doctrine\DBAL\Types\Type::getType('integer'), array()); - - $this->_platform->getAlterTableSQL($tableDiff); - } - - /** - * @group DBAL-42 - */ - public function testCreateTableColumnComments() - { - $table = new Table('test'); - $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); - $table->setPrimaryKey(array('id')); - - $this->assertEquals($this->getCreateTableColumnCommentsSQL(), $this->_platform->getCreateTableSQL($table)); - } - - /** - * @group DBAL-42 - */ - public function testAlterTableColumnComments() - { - $tableDiff = new TableDiff('mytable'); - $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('comment' => 'A comment')); - $tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff( - 'bar', new \Doctrine\DBAL\Schema\Column( - 'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('comment' => 'B comment') - ), - array('comment') - ); - - $this->assertEquals($this->getAlterTableColumnCommentsSQL(), $this->_platform->getAlterTableSQL($tableDiff)); - } - - public function testCreateTableColumnTypeComments() - { - $table = new Table('test'); - $table->addColumn('id', 'integer'); - $table->addColumn('data', 'array'); - $table->setPrimaryKey(array('id')); - - $this->assertEquals($this->getCreateTableColumnTypeCommentsSQL(), $this->_platform->getCreateTableSQL($table)); - } - - public function getCreateTableColumnCommentsSQL() - { - $this->markTestSkipped('Platform does not support Column comments.'); - } - - public function getAlterTableColumnCommentsSQL() - { - $this->markTestSkipped('Platform does not support Column comments.'); - } - - public function getCreateTableColumnTypeCommentsSQL() - { - $this->markTestSkipped('Platform does not support Column comments.'); - } - - /** - * @group DBAL-45 - */ - public function testKeywordList() - { - $keywordList = $this->_platform->getReservedKeywordsList(); - $this->assertInstanceOf('Doctrine\DBAL\Platforms\Keywords\KeywordList', $keywordList); - - $this->assertTrue($keywordList->isKeyword('table')); - } - - /** - * @group DBAL-374 - */ - public function testQuotedColumnInPrimaryKeyPropagation() - { - $table = new Table('`quoted`'); - $table->addColumn('`key`', 'string'); - $table->setPrimaryKey(array('key')); - - $sql = $this->_platform->getCreateTableSQL($table); - $this->assertEquals($this->getQuotedColumnInPrimaryKeySQL(), $sql); - } - - abstract protected function getQuotedColumnInPrimaryKeySQL(); - abstract protected function getQuotedColumnInIndexSQL(); - - /** - * @group DBAL-374 - */ - public function testQuotedColumnInIndexPropagation() - { - $this->markTestSkipped('requires big refactoring of Platforms'); - - $table = new Table('`quoted`'); - $table->addColumn('`key`', 'string'); - $table->addIndex(array('key')); - - $sql = $this->_platform->getCreateTableSQL($table); - $this->assertEquals($this->getQuotedColumnInIndexSQL(), $sql); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php deleted file mode 100755 index ab3cc8398d..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php +++ /dev/null @@ -1,243 +0,0 @@ -addColumn("Bar", "integer"); - - $sql = $this->_platform->getCreateTableSQL($table); - $this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB', array_shift($sql)); - } - - public function getGenerateTableSql() - { - return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'; - } - - public function getGenerateTableWithMultiColumnUniqueIndexSql() - { - return array( - 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA (foo, bar)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB' - ); - } - - public function getGenerateAlterTableSql() - { - return array( - "ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL, CHANGE bloo bloo TINYINT(1) DEFAULT '0' NOT NULL" - ); - } - - public function testGeneratesSqlSnippets() - { - $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - $this->assertEquals('`', $this->_platform->getIdentifierQuoteCharacter(), 'Quote character is not correct'); - $this->assertEquals('CONCAT(column1, column2, column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct'); - } - - public function testGeneratesTransactionsCommands() - { - $this->assertEquals( - 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED), - '' - ); - $this->assertEquals( - 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - - public function testGeneratesDDLSnippets() - { - $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); - $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); - $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar')); - $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'INT', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'INT AUTO_INCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) - )); - $this->assertEquals( - 'INT AUTO_INCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true) - )); - } - - public function testGeneratesTypeDeclarationForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true) - )); - $this->assertEquals( - 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'VARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function testPrefersIdentityColumns() - { - $this->assertTrue($this->_platform->prefersIdentityColumns()); - } - - public function testSupportsIdentityColumns() - { - $this->assertTrue($this->_platform->supportsIdentityColumns()); - } - - public function testDoesSupportSavePoints() - { - $this->assertTrue($this->_platform->supportsSavepoints()); - } - - public function getGenerateIndexSql() - { - return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function getGenerateForeignKeySql() - { - return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; - } - - /** - * @group DBAL-126 - */ - public function testUniquePrimaryKey() - { - $keyTable = new Table("foo"); - $keyTable->addColumn("bar", "integer"); - $keyTable->addColumn("baz", "string"); - $keyTable->setPrimaryKey(array("bar")); - $keyTable->addUniqueIndex(array("baz")); - - $oldTable = new Table("foo"); - $oldTable->addColumn("bar", "integer"); - $oldTable->addColumn("baz", "string"); - - $c = new \Doctrine\DBAL\Schema\Comparator; - $diff = $c->diffTable($oldTable, $keyTable); - - $sql = $this->_platform->getAlterTableSQL($diff); - - $this->assertEquals(array( - "ALTER TABLE foo ADD PRIMARY KEY (bar)", - "CREATE UNIQUE INDEX UNIQ_8C73652178240498 ON foo (baz)", - ), $sql); - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); - } - - /** - * @group DDC-118 - */ - public function testGetDateTimeTypeDeclarationSql() - { - $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => false))); - $this->assertEquals("TIMESTAMP", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => true))); - $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array())); - } - - public function getCreateTableColumnCommentsSQL() - { - return array("CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"); - } - - public function getAlterTableColumnCommentsSQL() - { - return array("ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'"); - } - - public function getCreateTableColumnTypeCommentsSQL() - { - return array("CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"); - } - - /** - * @group DBAL-237 - */ - public function testChangeIndexWithForeignKeys() - { - $index = new Index("idx", array("col"), false); - $unique = new Index("uniq", array("col"), true); - - $diff = new TableDiff("test", array(), array(), array(), array($unique), array(), array($index)); - $sql = $this->_platform->getAlterTableSQL($diff); - $this->assertEquals(array("ALTER TABLE test DROP INDEX idx, ADD UNIQUE INDEX uniq (col)"), $sql); - - $diff = new TableDiff("test", array(), array(), array(), array($index), array(), array($unique)); - $sql = $this->_platform->getAlterTableSQL($diff); - $this->assertEquals(array("ALTER TABLE test DROP INDEX uniq, ADD INDEX idx (col)"), $sql); - } - - protected function getQuotedColumnInPrimaryKeySQL() - { - return array( - 'CREATE TABLE `quoted` (`key` VARCHAR(255) NOT NULL, PRIMARY KEY(`key`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB' - ); - } - - protected function getQuotedColumnInIndexSQL() - { - return array( - 'CREATE TABLE `quoted` (`key` VARCHAR(255) NOT NULL, INDEX IDX_22660D028A90ABA9 (`key`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB' - ); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php deleted file mode 100755 index e0f6a5ac31..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ /dev/null @@ -1,285 +0,0 @@ -createPlatform(); - $platform->assertValidIdentifier($identifier); - } - - static public function dataInvalidIdentifiers() - { - return array( - array('1'), - array('abc&'), - array('abc-def'), - array('"'), - array('"foo"bar"'), - ); - } - - /** - * @dataProvider dataInvalidIdentifiers - */ - public function testInvalidIdentifiers($identifier) - { - $this->setExpectedException('Doctrine\DBAL\DBALException'); - $platform = $this->createPlatform(); - $platform->assertValidIdentifier($identifier); - } - - public function createPlatform() - { - return new OraclePlatform; - } - - public function getGenerateTableSql() - { - return 'CREATE TABLE test (id NUMBER(10) NOT NULL, test VARCHAR2(255) DEFAULT NULL, PRIMARY KEY(id))'; - } - - public function getGenerateTableWithMultiColumnUniqueIndexSql() - { - return array( - 'CREATE TABLE test (foo VARCHAR2(255) DEFAULT NULL, bar VARCHAR2(255) DEFAULT NULL)', - 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)', - ); - } - - public function getGenerateAlterTableSql() - { - return array( - 'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL)', - "ALTER TABLE mytable MODIFY (baz VARCHAR2(255) DEFAULT 'def' NOT NULL, bloo NUMBER(1) DEFAULT '0' NOT NULL)", - "ALTER TABLE mytable DROP (foo)", - "ALTER TABLE mytable RENAME TO userlist", - ); - } - - /** - * @expectedException Doctrine\DBAL\DBALException - */ - public function testRLike() - { - $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - } - - public function testGeneratesSqlSnippets() - { - $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); - $this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); - } - - public function testGeneratesTransactionsCommands() - { - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - /** - * @expectedException Doctrine\DBAL\DBALException - */ - public function testShowDatabasesThrowsException() - { - $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); - } - - /** - * @expectedException Doctrine\DBAL\DBALException - */ - public function testCreateDatabaseThrowsException() - { - $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); - } - - public function testDropDatabaseThrowsException() - { - $this->assertEquals('DROP USER foobar CASCADE', $this->_platform->getDropDatabaseSQL('foobar')); - } - - public function testDropTable() - { - $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'NUMBER(10)', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'NUMBER(10)', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) - )); - $this->assertEquals( - 'NUMBER(10)', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true) - )); - } - - public function testGeneratesTypeDeclarationsForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true) - )); - $this->assertEquals( - 'VARCHAR2(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'VARCHAR2(255)', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function testPrefersIdentityColumns() - { - $this->assertFalse($this->_platform->prefersIdentityColumns()); - } - - public function testSupportsIdentityColumns() - { - $this->assertFalse($this->_platform->supportsIdentityColumns()); - } - - public function testSupportsSavePoints() - { - $this->assertTrue($this->_platform->supportsSavepoints()); - } - - public function getGenerateIndexSql() - { - return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function getGenerateForeignKeySql() - { - return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); - } - - public function testModifyLimitQueryWithAscOrderBy() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); - $this->assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username ASC) a WHERE ROWNUM <= 10', $sql); - } - - public function testModifyLimitQueryWithDescOrderBy() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); - $this->assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10', $sql); - } - - public function getCreateTableColumnCommentsSQL() - { - return array( - "CREATE TABLE test (id NUMBER(10) NOT NULL, PRIMARY KEY(id))", - "COMMENT ON COLUMN test.id IS 'This is a comment'", - ); - } - - public function getCreateTableColumnTypeCommentsSQL() - { - return array( - "CREATE TABLE test (id NUMBER(10) NOT NULL, data CLOB NOT NULL, PRIMARY KEY(id))", - "COMMENT ON COLUMN test.data IS '(DC2Type:array)'" - ); - } - - public function getAlterTableColumnCommentsSQL() - { - return array( - "ALTER TABLE mytable ADD (quota NUMBER(10) NOT NULL)", - "ALTER TABLE mytable MODIFY (baz VARCHAR2(255) NOT NULL)", - "COMMENT ON COLUMN mytable.quota IS 'A comment'", - "COMMENT ON COLUMN mytable.baz IS 'B comment'", - ); - } - - public function getBitAndComparisonExpressionSql($value1, $value2) - { - return 'BITAND('.$value1 . ', ' . $value2 . ')'; - } - - public function getBitOrComparisonExpressionSql($value1, $value2) - { - return '(' . $value1 . '-' . - $this->getBitAndComparisonExpressionSql($value1, $value2) - . '+' . $value2 . ')'; - } - - protected function getQuotedColumnInPrimaryKeySQL() - { - return array('CREATE TABLE "quoted" ("key" VARCHAR2(255) NOT NULL, PRIMARY KEY("key"))'); - } - - protected function getQuotedColumnInIndexSQL() - { - return array( - 'CREATE TABLE "quoted" ("key" VARCHAR2(255) NOT NULL)', - 'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")', - ); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php deleted file mode 100755 index 8f967f6096..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php +++ /dev/null @@ -1,243 +0,0 @@ - 'CASCADE') - ); - $this->assertEquals( - "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE", - $this->_platform->getForeignKeyDeclarationSQL($foreignKey) - ); - } - - public function testGeneratesSqlSnippets() - { - $this->assertEquals('SIMILAR TO', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); - $this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); - $this->assertEquals('SUBSTR(column, 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); - $this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); - } - - public function testGeneratesTransactionCommands() - { - $this->assertEquals( - 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) - ); - $this->assertEquals( - 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - public function testGeneratesDDLSnippets() - { - $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); - $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar')); - $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); - } - - public function testGenerateTableWithAutoincrement() - { - $table = new \Doctrine\DBAL\Schema\Table('autoinc_table'); - $column = $table->addColumn('id', 'integer'); - $column->setAutoincrement(true); - - $this->assertEquals(array('CREATE TABLE autoinc_table (id SERIAL NOT NULL)'), $this->_platform->getCreateTableSQL($table)); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'INT', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'SERIAL', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) - )); - $this->assertEquals( - 'SERIAL', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true) - )); - } - - public function testGeneratesTypeDeclarationForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true)) - ); - $this->assertEquals( - 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'VARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function testGeneratesSequenceSqlCommands() - { - $sequence = new \Doctrine\DBAL\Schema\Sequence('myseq', 20, 1); - $this->assertEquals( - 'CREATE SEQUENCE myseq INCREMENT BY 20 MINVALUE 1 START 1', - $this->_platform->getCreateSequenceSQL($sequence) - ); - $this->assertEquals( - 'DROP SEQUENCE myseq CASCADE', - $this->_platform->getDropSequenceSQL('myseq') - ); - $this->assertEquals( - "SELECT NEXTVAL('myseq')", - $this->_platform->getSequenceNextValSQL('myseq') - ); - } - - public function testDoesNotPreferIdentityColumns() - { - $this->assertFalse($this->_platform->prefersIdentityColumns()); - } - - public function testPrefersSequences() - { - $this->assertTrue($this->_platform->prefersSequences()); - } - - public function testSupportsIdentityColumns() - { - $this->assertTrue($this->_platform->supportsIdentityColumns()); - } - - public function testSupportsSavePoints() - { - $this->assertTrue($this->_platform->supportsSavepoints()); - } - - public function testSupportsSequences() - { - $this->assertTrue($this->_platform->supportsSequences()); - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); - } - - public function getCreateTableColumnCommentsSQL() - { - return array( - "CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))", - "COMMENT ON COLUMN test.id IS 'This is a comment'", - ); - } - - public function getAlterTableColumnCommentsSQL() - { - return array( - "ALTER TABLE mytable ADD quota INT NOT NULL", - "COMMENT ON COLUMN mytable.quota IS 'A comment'", - "COMMENT ON COLUMN mytable.baz IS 'B comment'", - ); - } - - public function getCreateTableColumnTypeCommentsSQL() - { - return array( - "CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(id))", - "COMMENT ON COLUMN test.data IS '(DC2Type:array)'" - ); - } - - protected function getQuotedColumnInPrimaryKeySQL() - { - return array( - 'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL, PRIMARY KEY("key"))', - ); - } - - protected function getQuotedColumnInIndexSQL() - { - return array( - 'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL)', - 'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")', - ); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php deleted file mode 100755 index 388115f675..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php +++ /dev/null @@ -1,47 +0,0 @@ -validator = new ReservedKeywordsValidator(array( - new \Doctrine\DBAL\Platforms\Keywords\MySQLKeywords() - )); - } - - public function testReservedTableName() - { - $table = new Table("TABLE"); - $this->validator->acceptTable($table); - - $this->assertEquals( - array('Table TABLE keyword violations: MySQL'), - $this->validator->getViolations() - ); - } - - public function testReservedColumnName() - { - $table = new Table("TABLE"); - $column = $table->addColumn('table', 'string'); - - $this->validator->acceptColumn($table, $column); - - $this->assertEquals( - array('Table TABLE column table keyword violations: MySQL'), - $this->validator->getViolations() - ); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php deleted file mode 100755 index f66a0f8471..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php +++ /dev/null @@ -1,29 +0,0 @@ -platform = new \Doctrine\DBAL\Platforms\SQLAzurePlatform(); - } - - public function testCreateFederatedOnTable() - { - $table = new \Doctrine\DBAL\Schema\Table("tbl"); - $table->addColumn("id", "integer"); - $table->addOption('azure.federatedOnDistributionName', 'TblId'); - $table->addOption('azure.federatedOnColumnName', 'id'); - - $this->assertEquals(array('CREATE TABLE tbl (id INT NOT NULL) FEDERATED ON (TblId = id)'), $this->platform->getCreateTableSQL($table)); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php deleted file mode 100755 index 21c42ad550..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php +++ /dev/null @@ -1,245 +0,0 @@ -assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); - $this->assertEquals('(column1 + column2 + column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); - } - - public function testGeneratesTransactionsCommands() - { - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - public function testGeneratesDDLSnippets() - { - $dropDatabaseExpectation = 'DROP DATABASE foobar'; - - $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); - $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); - $this->assertEquals($dropDatabaseExpectation, $this->_platform->getDropDatabaseSQL('foobar')); - $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'INT', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'INT IDENTITY', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) - )); - $this->assertEquals( - 'INT IDENTITY', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true) - )); - } - - public function testGeneratesTypeDeclarationsForStrings() - { - $this->assertEquals( - 'NCHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true) - )); - $this->assertEquals( - 'NVARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'NVARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function testPrefersIdentityColumns() - { - $this->assertTrue($this->_platform->prefersIdentityColumns()); - } - - public function testSupportsIdentityColumns() - { - $this->assertTrue($this->_platform->supportsIdentityColumns()); - } - - public function testDoesNotSupportSavePoints() - { - $this->assertTrue($this->_platform->supportsSavepoints()); - } - - public function getGenerateIndexSql() - { - return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2) WHERE test IS NOT NULL AND test2 IS NOT NULL'; - } - - public function getGenerateForeignKeySql() - { - return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT TOP 10 * FROM user', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT TOP 10 * FROM user', $sql); - } - - public function testModifyLimitQueryWithOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5); - $this->assertEquals('SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY username DESC) AS doctrine_rownum FROM user) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 6 AND 15', $sql); - } - - public function testModifyLimitQueryWithAscOrderBy() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); - $this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username ASC', $sql); - } - - public function testModifyLimitQueryWithDescOrderBy() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); - $this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username DESC', $sql); - } - - /** - * @group DDC-1360 - */ - public function testQuoteIdentifier() - { - $this->assertEquals('[fo][o]', $this->_platform->quoteIdentifier('fo]o')); - $this->assertEquals('[test]', $this->_platform->quoteIdentifier('test')); - $this->assertEquals('[test].[test]', $this->_platform->quoteIdentifier('test.test')); - } - - /** - * @group DDC-1360 - */ - public function testQuoteSingleIdentifier() - { - $this->assertEquals('[fo][o]', $this->_platform->quoteSingleIdentifier('fo]o')); - $this->assertEquals('[test]', $this->_platform->quoteSingleIdentifier('test')); - $this->assertEquals('[test.test]', $this->_platform->quoteSingleIdentifier('test.test')); - } - - /** - * @group DBAL-220 - */ - public function testCreateClusteredIndex() - { - $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id')); - $idx->addFlag('clustered'); - $this->assertEquals('CREATE CLUSTERED INDEX idx ON tbl (id)', $this->_platform->getCreateIndexSQL($idx, 'tbl')); - } - - /** - * @group DBAL-220 - */ - public function testCreateNonClusteredPrimaryKeyInTable() - { - $table = new \Doctrine\DBAL\Schema\Table("tbl"); - $table->addColumn("id", "integer"); - $table->setPrimaryKey(Array("id")); - $table->getIndex('primary')->addFlag('nonclustered'); - - $this->assertEquals(array('CREATE TABLE tbl (id INT NOT NULL, PRIMARY KEY NONCLUSTERED (id))'), $this->_platform->getCreateTableSQL($table)); - } - - /** - * @group DBAL-220 - */ - public function testCreateNonClusteredPrimaryKey() - { - $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'), false, true); - $idx->addFlag('nonclustered'); - $this->assertEquals('ALTER TABLE tbl ADD PRIMARY KEY NONCLUSTERED (id)', $this->_platform->getCreatePrimaryKeySQL($idx, 'tbl')); - } - - public function testAlterAddPrimaryKey() - { - $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'), false, true); - $this->assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->_platform->getCreateIndexSQL($idx, 'tbl')); - } - - protected function getQuotedColumnInPrimaryKeySQL() - { - return array( - 'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL, PRIMARY KEY ([key]))', - ); - } - - protected function getQuotedColumnInIndexSQL() - { - return array( - 'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL)', - 'CREATE INDEX IDX_22660D028A90ABA9 ON [quoted] ([key])', - ); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php deleted file mode 100755 index aae3465ee9..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ /dev/null @@ -1,170 +0,0 @@ -assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - $this->assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); - $this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); - } - - public function testGeneratesTransactionCommands() - { - $this->assertEquals( - 'PRAGMA read_uncommitted = 0', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) - ); - $this->assertEquals( - 'PRAGMA read_uncommitted = 1', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'PRAGMA read_uncommitted = 1', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'PRAGMA read_uncommitted = 1', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - public function testPrefersIdentityColumns() - { - $this->assertTrue($this->_platform->prefersIdentityColumns()); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'INTEGER', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'INTEGER', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)) - ); - $this->assertEquals( - 'INTEGER', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true)) - ); - } - - public function testGeneratesTypeDeclarationForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true)) - ); - $this->assertEquals( - 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'VARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function getGenerateIndexSql() - { - return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function getGenerateForeignKeySql() - { - $this->markTestSkipped('SQLite does not support ForeignKeys.'); - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); - } - - public function getGenerateAlterTableSql() - { - $this->markTestSkipped('SQlite does not support ALTER Table.'); - } - - public function testGetAlterTableSqlDispatchEvent() - { - $this->markTestSkipped('SQlite does not support ALTER Table.'); - } - - /** - * @group DDC-1845 - */ - public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey() - { - $table = new \Doctrine\DBAL\Schema\Table('test'); - $table->addColumn('"like"', 'integer', array('notnull' => true, 'autoincrement' => true)); - $table->setPrimaryKey(array('"like"')); - - $createTableSQL = $this->_platform->getCreateTableSQL($table); - $this->assertEquals( - 'CREATE TABLE test ("like" INTEGER NOT NULL, PRIMARY KEY("like"))', - $createTableSQL[0] - ); - - $this->assertEquals( - 'ALTER TABLE test ADD PRIMARY KEY ("like")', - $this->_platform->getCreatePrimaryKeySQL($table->getIndex('primary'), 'test') - ); - } - - protected function getQuotedColumnInPrimaryKeySQL() - { - return array( - 'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL, PRIMARY KEY("key"))', - ); - } - - protected function getQuotedColumnInIndexSQL() - { - return array( - 'CREATE TABLE "quoted" ("key" VARCHAR(255) NOT NULL)', - 'CREATE INDEX IDX_22660D028A90ABA9 ON "quoted" ("key")', - ); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php deleted file mode 100755 index 99396598f2..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php +++ /dev/null @@ -1,82 +0,0 @@ -assertEquals(1, count($expr)); - - $expr->add('u.group_id = 2'); - - $this->assertEquals(2, count($expr)); - } - - /** - * @dataProvider provideDataForConvertToString - */ - public function testCompositeUsageAndGeneration($type, $parts, $expects) - { - $expr = new CompositeExpression($type, $parts); - - $this->assertEquals($expects, (string) $expr); - } - - public function provideDataForConvertToString() - { - return array( - array( - CompositeExpression::TYPE_AND, - array('u.user = 1'), - 'u.user = 1' - ), - array( - CompositeExpression::TYPE_AND, - array('u.user = 1', 'u.group_id = 1'), - '(u.user = 1) AND (u.group_id = 1)' - ), - array( - CompositeExpression::TYPE_OR, - array('u.user = 1'), - 'u.user = 1' - ), - array( - CompositeExpression::TYPE_OR, - array('u.group_id = 1', 'u.group_id = 2'), - '(u.group_id = 1) OR (u.group_id = 2)' - ), - array( - CompositeExpression::TYPE_AND, - array( - 'u.user = 1', - new CompositeExpression( - CompositeExpression::TYPE_OR, - array('u.group_id = 1', 'u.group_id = 2') - ) - ), - '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))' - ), - array( - CompositeExpression::TYPE_OR, - array( - 'u.group_id = 1', - new CompositeExpression( - CompositeExpression::TYPE_AND, - array('u.user = 1', 'u.group_id = 2') - ) - ), - '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))' - ), - ); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php deleted file mode 100755 index 1893e97faf..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php +++ /dev/null @@ -1,201 +0,0 @@ -getMock('Doctrine\DBAL\Connection', array(), array(), '', false); - - $this->expr = new ExpressionBuilder($conn); - - $conn->expects($this->any()) - ->method('getExpressionBuilder') - ->will($this->returnValue($this->expr)); - } - - /** - * @dataProvider provideDataForAndX - */ - public function testAndX($parts, $expected) - { - $composite = $this->expr->andX(); - - foreach ($parts as $part) { - $composite->add($part); - } - - $this->assertEquals($expected, (string) $composite); - } - - public function provideDataForAndX() - { - return array( - array( - array('u.user = 1'), - 'u.user = 1' - ), - array( - array('u.user = 1', 'u.group_id = 1'), - '(u.user = 1) AND (u.group_id = 1)' - ), - array( - array('u.user = 1'), - 'u.user = 1' - ), - array( - array('u.group_id = 1', 'u.group_id = 2'), - '(u.group_id = 1) AND (u.group_id = 2)' - ), - array( - array( - 'u.user = 1', - new CompositeExpression( - CompositeExpression::TYPE_OR, - array('u.group_id = 1', 'u.group_id = 2') - ) - ), - '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))' - ), - array( - array( - 'u.group_id = 1', - new CompositeExpression( - CompositeExpression::TYPE_AND, - array('u.user = 1', 'u.group_id = 2') - ) - ), - '(u.group_id = 1) AND ((u.user = 1) AND (u.group_id = 2))' - ), - ); - } - - /** - * @dataProvider provideDataForOrX - */ - public function testOrX($parts, $expected) - { - $composite = $this->expr->orX(); - - foreach ($parts as $part) { - $composite->add($part); - } - - $this->assertEquals($expected, (string) $composite); - } - - public function provideDataForOrX() - { - return array( - array( - array('u.user = 1'), - 'u.user = 1' - ), - array( - array('u.user = 1', 'u.group_id = 1'), - '(u.user = 1) OR (u.group_id = 1)' - ), - array( - array('u.user = 1'), - 'u.user = 1' - ), - array( - array('u.group_id = 1', 'u.group_id = 2'), - '(u.group_id = 1) OR (u.group_id = 2)' - ), - array( - array( - 'u.user = 1', - new CompositeExpression( - CompositeExpression::TYPE_OR, - array('u.group_id = 1', 'u.group_id = 2') - ) - ), - '(u.user = 1) OR ((u.group_id = 1) OR (u.group_id = 2))' - ), - array( - array( - 'u.group_id = 1', - new CompositeExpression( - CompositeExpression::TYPE_AND, - array('u.user = 1', 'u.group_id = 2') - ) - ), - '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))' - ), - ); - } - - /** - * @dataProvider provideDataForComparison - */ - public function testComparison($leftExpr, $operator, $rightExpr, $expected) - { - $part = $this->expr->comparison($leftExpr, $operator, $rightExpr); - - $this->assertEquals($expected, (string) $part); - } - - public function provideDataForComparison() - { - return array( - array('u.user_id', ExpressionBuilder::EQ, '1', 'u.user_id = 1'), - array('u.user_id', ExpressionBuilder::NEQ, '1', 'u.user_id <> 1'), - array('u.salary', ExpressionBuilder::LT, '10000', 'u.salary < 10000'), - array('u.salary', ExpressionBuilder::LTE, '10000', 'u.salary <= 10000'), - array('u.salary', ExpressionBuilder::GT, '10000', 'u.salary > 10000'), - array('u.salary', ExpressionBuilder::GTE, '10000', 'u.salary >= 10000'), - ); - } - - public function testEq() - { - $this->assertEquals('u.user_id = 1', $this->expr->eq('u.user_id', '1')); - } - - public function testNeq() - { - $this->assertEquals('u.user_id <> 1', $this->expr->neq('u.user_id', '1')); - } - - public function testLt() - { - $this->assertEquals('u.salary < 10000', $this->expr->lt('u.salary', '10000')); - } - - public function testLte() - { - $this->assertEquals('u.salary <= 10000', $this->expr->lte('u.salary', '10000')); - } - - public function testGt() - { - $this->assertEquals('u.salary > 10000', $this->expr->gt('u.salary', '10000')); - } - - public function testGte() - { - $this->assertEquals('u.salary >= 10000', $this->expr->gte('u.salary', '10000')); - } - - public function testIsNull() - { - $this->assertEquals('u.deleted IS NULL', $this->expr->isNull('u.deleted')); - } - - public function testIsNotNull() - { - $this->assertEquals('u.updated IS NOT NULL', $this->expr->isNotNull('u.updated')); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php deleted file mode 100755 index 74f208a8be..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php +++ /dev/null @@ -1,587 +0,0 @@ -conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false); - - $expressionBuilder = new ExpressionBuilder($this->conn); - - $this->conn->expects($this->any()) - ->method('getExpressionBuilder') - ->will($this->returnValue($expressionBuilder)); - } - - public function testSimpleSelect() - { - $qb = new QueryBuilder($this->conn); - - $qb->select('u.id') - ->from('users', 'u'); - - $this->assertEquals('SELECT u.id FROM users u', (string) $qb); - } - - public function testSelectWithSimpleWhere() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.id') - ->from('users', 'u') - ->where($expr->andX($expr->eq('u.nickname', '?'))); - - $this->assertEquals("SELECT u.id FROM users u WHERE u.nickname = ?", (string) $qb); - } - - public function testSelectWithLeftJoin() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->leftJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); - - $this->assertEquals('SELECT u.*, p.* FROM users u LEFT JOIN phones p ON p.user_id = u.id', (string) $qb); - } - - public function testSelectWithJoin() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->Join('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); - - $this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb); - } - - public function testSelectWithInnerJoin() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->innerJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); - - $this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb); - } - - public function testSelectWithRightJoin() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->rightJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); - - $this->assertEquals('SELECT u.*, p.* FROM users u RIGHT JOIN phones p ON p.user_id = u.id', (string) $qb); - } - - public function testSelectWithAndWhereConditions() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->where('u.username = ?') - ->andWhere('u.name = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb); - } - - public function testSelectWithOrWhereConditions() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->where('u.username = ?') - ->orWhere('u.name = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); - } - - public function testSelectWithOrOrWhereConditions() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->orWhere('u.username = ?') - ->orWhere('u.name = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); - } - - public function testSelectWithAndOrWhereConditions() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->where('u.username = ?') - ->andWhere('u.username = ?') - ->orWhere('u.name = ?') - ->andWhere('u.name = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb); - } - - public function testSelectGroupBy() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id', (string) $qb); - } - - public function testSelectEmptyGroupBy() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->groupBy(array()) - ->from('users', 'u'); - - $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); - } - - public function testSelectEmptyAddGroupBy() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->addGroupBy(array()) - ->from('users', 'u'); - - $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); - } - - public function testSelectAddGroupBy() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id') - ->addGroupBy('u.foo'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo', (string) $qb); - } - - public function testSelectAddGroupBys() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id') - ->addGroupBy('u.foo', 'u.bar'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo, u.bar', (string) $qb); - } - - public function testSelectHaving() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id') - ->having('u.name = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb); - } - - public function testSelectAndHaving() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id') - ->andHaving('u.name = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb); - } - - public function testSelectHavingAndHaving() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id') - ->having('u.name = ?') - ->andHaving('u.username = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)', (string) $qb); - } - - public function testSelectHavingOrHaving() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id') - ->having('u.name = ?') - ->orHaving('u.username = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); - } - - public function testSelectOrHavingOrHaving() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id') - ->orHaving('u.name = ?') - ->orHaving('u.username = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); - } - - public function testSelectHavingAndOrHaving() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->groupBy('u.id') - ->having('u.name = ?') - ->orHaving('u.username = ?') - ->andHaving('u.username = ?'); - - $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb); - } - - public function testSelectOrderBy() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->orderBy('u.name'); - - $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb); - } - - public function testSelectAddOrderBy() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->orderBy('u.name') - ->addOrderBy('u.username', 'DESC'); - - $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb); - } - - public function testSelectAddAddOrderBy() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*', 'p.*') - ->from('users', 'u') - ->addOrderBy('u.name') - ->addOrderBy('u.username', 'DESC'); - - $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb); - } - - public function testEmptySelect() - { - $qb = new QueryBuilder($this->conn); - $qb2 = $qb->select(); - - $this->assertSame($qb, $qb2); - $this->assertEquals(QueryBuilder::SELECT, $qb->getType()); - } - - public function testSelectAddSelect() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*') - ->addSelect('p.*') - ->from('users', 'u'); - - $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); - } - - public function testEmptyAddSelect() - { - $qb = new QueryBuilder($this->conn); - $qb2 = $qb->addSelect(); - - $this->assertSame($qb, $qb2); - $this->assertEquals(QueryBuilder::SELECT, $qb->getType()); - } - - public function testSelectMultipleFrom() - { - $qb = new QueryBuilder($this->conn); - $expr = $qb->expr(); - - $qb->select('u.*') - ->addSelect('p.*') - ->from('users', 'u') - ->from('phonenumbers', 'p'); - - $this->assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb); - } - - public function testUpdate() - { - $qb = new QueryBuilder($this->conn); - $qb->update('users', 'u') - ->set('u.foo', '?') - ->set('u.bar', '?'); - - $this->assertEquals(QueryBuilder::UPDATE, $qb->getType()); - $this->assertEquals('UPDATE users u SET u.foo = ?, u.bar = ?', (string) $qb); - } - - public function testUpdateWithoutAlias() - { - $qb = new QueryBuilder($this->conn); - $qb->update('users') - ->set('foo', '?') - ->set('bar', '?'); - - $this->assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb); - } - - public function testUpdateWhere() - { - $qb = new QueryBuilder($this->conn); - $qb->update('users', 'u') - ->set('u.foo', '?') - ->where('u.foo = ?'); - - $this->assertEquals('UPDATE users u SET u.foo = ? WHERE u.foo = ?', (string) $qb); - } - - public function testEmptyUpdate() - { - $qb = new QueryBuilder($this->conn); - $qb2 = $qb->update(); - - $this->assertEquals(QueryBuilder::UPDATE, $qb->getType()); - $this->assertSame($qb2, $qb); - } - - public function testDelete() - { - $qb = new QueryBuilder($this->conn); - $qb->delete('users', 'u'); - - $this->assertEquals(QueryBuilder::DELETE, $qb->getType()); - $this->assertEquals('DELETE FROM users u', (string) $qb); - } - - public function testDeleteWithoutAlias() - { - $qb = new QueryBuilder($this->conn); - $qb->delete('users'); - - $this->assertEquals(QueryBuilder::DELETE, $qb->getType()); - $this->assertEquals('DELETE FROM users', (string) $qb); - } - - public function testDeleteWhere() - { - $qb = new QueryBuilder($this->conn); - $qb->delete('users', 'u') - ->where('u.foo = ?'); - - $this->assertEquals('DELETE FROM users u WHERE u.foo = ?', (string) $qb); - } - - public function testEmptyDelete() - { - $qb = new QueryBuilder($this->conn); - $qb2 = $qb->delete(); - - $this->assertEquals(QueryBuilder::DELETE, $qb->getType()); - $this->assertSame($qb2, $qb); - } - - public function testGetConnection() - { - $qb = new QueryBuilder($this->conn); - $this->assertSame($this->conn, $qb->getConnection()); - } - - public function testGetState() - { - $qb = new QueryBuilder($this->conn); - - $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); - - $qb->select('u.*')->from('users', 'u'); - - $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); - - $sql1 = $qb->getSQL(); - - $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); - $this->assertEquals($sql1, $qb->getSQL()); - } - - public function testSetMaxResults() - { - $qb = new QueryBuilder($this->conn); - $qb->setMaxResults(10); - - $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); - $this->assertEQuals(10, $qb->getMaxResults()); - } - - public function testSetFirstResult() - { - $qb = new QueryBuilder($this->conn); - $qb->setFirstResult(10); - - $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); - $this->assertEQuals(10, $qb->getFirstResult()); - } - - public function testResetQueryPart() - { - $qb = new QueryBuilder($this->conn); - - $qb->select('u.*')->from('users', 'u')->where('u.name = ?'); - - $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb); - $qb->resetQueryPart('where'); - $this->assertEquals('SELECT u.* FROM users u', (string)$qb); - } - - public function testResetQueryParts() - { - $qb = new QueryBuilder($this->conn); - - $qb->select('u.*')->from('users', 'u')->where('u.name = ?')->orderBy('u.name'); - - $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ? ORDER BY u.name ASC', (string)$qb); - $qb->resetQueryParts(array('where', 'orderBy')); - $this->assertEquals('SELECT u.* FROM users u', (string)$qb); - } - - public function testCreateNamedParameter() - { - $qb = new QueryBuilder($this->conn); - - $qb->select('u.*')->from('users', 'u')->where( - $qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT)) - ); - - $this->assertEquals('SELECT u.* FROM users u WHERE u.name = :dcValue1', (string)$qb); - $this->assertEquals(10, $qb->getParameter('dcValue1')); - } - - public function testCreateNamedParameterCustomPlaceholder() - { - $qb = new QueryBuilder($this->conn); - - $qb->select('u.*')->from('users', 'u')->where( - $qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT, ':test')) - ); - - $this->assertEquals('SELECT u.* FROM users u WHERE u.name = :test', (string)$qb); - $this->assertEquals(10, $qb->getParameter('test')); - } - - public function testCreatePositionalParameter() - { - $qb = new QueryBuilder($this->conn); - - $qb->select('u.*')->from('users', 'u')->where( - $qb->expr()->eq('u.name', $qb->createPositionalParameter(10, \PDO::PARAM_INT)) - ); - - $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb); - $this->assertEquals(10, $qb->getParameter(1)); - } - - /** - * @group DBAL-172 - */ - public function testReferenceJoinFromJoin() - { - $qb = new QueryBuilder($this->conn); - - $qb->select('COUNT(DISTINCT news.id)') - ->from('cb_newspages', 'news') - ->innerJoin('news', 'nodeversion', 'nv', 'nv.refId = news.id AND nv.refEntityname=\'News\'') - ->innerJoin('invalid', 'nodetranslation', 'nt', 'nv.nodetranslation = nt.id') - ->innerJoin('nt', 'node', 'n', 'nt.node = n.id') - ->where('nt.lang = :lang AND n.deleted != 1'); - - $this->setExpectedException('Doctrine\DBAL\Query\QueryException', "The given alias 'invalid' is not part of any FROM or JOIN clause table. The currently registered aliases are: news, nv, nt, n."); - $this->assertEquals('', $qb->getSQL()); - } - - /** - * @group DBAL-172 - */ - public function testSelectFromMasterWithWhereOnJoinedTables() - { - $qb = new QueryBuilder($this->conn); - - $qb->select('COUNT(DISTINCT news.id)') - ->from('newspages', 'news') - ->innerJoin('news', 'nodeversion', 'nv', "nv.refId = news.id AND nv.refEntityname='Entity\\News'") - ->innerJoin('nv', 'nodetranslation', 'nt', 'nv.nodetranslation = nt.id') - ->innerJoin('nt', 'node', 'n', 'nt.node = n.id') - ->where('nt.lang = ?') - ->andWhere('n.deleted = 0'); - - $this->assertEquals("SELECT COUNT(DISTINCT news.id) FROM newspages news INNER JOIN nodeversion nv ON nv.refId = news.id AND nv.refEntityname='Entity\\News' INNER JOIN nodetranslation nt ON nv.nodetranslation = nt.id INNER JOIN node n ON nt.node = n.id WHERE (nt.lang = ?) AND (n.deleted = 0)", $qb->getSQL()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php deleted file mode 100755 index 96a7c6b1ab..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php +++ /dev/null @@ -1,359 +0,0 @@ - 'foo', 17 => 'bar')), - array('SELECT * FROM Foo WHERE bar IN (:name1, :name2)', false, array(32 => 'name1', 40 => 'name2')), - array('SELECT ":foo" FROM Foo WHERE bar IN (:name1, :name2)', false, array(37 => 'name1', 45 => 'name2')), - array("SELECT ':foo' FROM Foo WHERE bar IN (:name1, :name2)", false, array(37 => 'name1', 45 => 'name2')), - array('SELECT :foo_id', false, array(7 => 'foo_id')), // Ticket DBAL-231 - array('SELECT @rank := 1', false, array()), // Ticket DBAL-398 - array('SELECT @rank := 1 AS rank, :foo AS foo FROM :bar', false, array(27 => 'foo', 44 => 'bar')), // Ticket DBAL-398 - array('SELECT * FROM Foo WHERE bar > :start_date AND baz > :start_date', false, array(30 => 'start_date', 52 => 'start_date')), // Ticket GH-113 - array('SELECT foo::date as date FROM Foo WHERE bar > :start_date AND baz > :start_date', false, array(46 => 'start_date', 68 => 'start_date')) // Ticket GH-259 - ); - } - - /** - * @dataProvider dataGetPlaceholderPositions - * @param type $query - * @param type $isPositional - * @param type $expectedParamPos - */ - public function testGetPlaceholderPositions($query, $isPositional, $expectedParamPos) - { - $actualParamPos = SQLParserUtils::getPlaceholderPositions($query, $isPositional); - $this->assertEquals($expectedParamPos, $actualParamPos); - } - - static public function dataExpandListParameters() - { - return array( - // Positional: Very simple with one needle - array( - "SELECT * FROM Foo WHERE foo IN (?)", - array(array(1, 2, 3)), - array(Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?, ?, ?)', - array(1, 2, 3), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Positional: One non-list before d one after list-needle - array( - "SELECT * FROM Foo WHERE foo = ? AND bar IN (?)", - array("string", array(1, 2, 3)), - array(\PDO::PARAM_STR, Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)', - array("string", 1, 2, 3), - array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Positional: One non-list after list-needle - array( - "SELECT * FROM Foo WHERE bar IN (?) AND baz = ?", - array(array(1, 2, 3), "foo"), - array(Connection::PARAM_INT_ARRAY, \PDO::PARAM_STR), - 'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?', - array(1, 2, 3, "foo"), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR) - ), - // Positional: One non-list before and one after list-needle - array( - "SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ?", - array(1, array(1, 2, 3), 4), - array(\PDO::PARAM_INT, Connection::PARAM_INT_ARRAY, \PDO::PARAM_INT), - 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?', - array(1, 1, 2, 3, 4), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Positional: Two lists - array( - "SELECT * FROM Foo WHERE foo IN (?, ?)", - array(array(1, 2, 3), array(4, 5)), - array(Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)', - array(1, 2, 3, 4, 5), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Positional : Empty "integer" array DDC-1978 - array( - "SELECT * FROM Foo WHERE foo IN (?)", - array('foo'=>array()), - array('foo'=>Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?)', - array(), - array() - ), - // Positional : Empty "str" array DDC-1978 - array( - "SELECT * FROM Foo WHERE foo IN (?)", - array('foo'=>array()), - array('foo'=>Connection::PARAM_STR_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?)', - array(), - array() - ), - // Named parameters : Very simple with param int - array( - "SELECT * FROM Foo WHERE foo = :foo", - array('foo'=>1), - array('foo'=>\PDO::PARAM_INT), - 'SELECT * FROM Foo WHERE foo = ?', - array(1), - array(\PDO::PARAM_INT) - ), - - // Named parameters : Very simple with param int and string - array( - "SELECT * FROM Foo WHERE foo = :foo AND bar = :bar", - array('bar'=>'Some String','foo'=>1), - array('foo'=>\PDO::PARAM_INT,'bar'=>\PDO::PARAM_STR), - 'SELECT * FROM Foo WHERE foo = ? AND bar = ?', - array(1,'Some String'), - array(\PDO::PARAM_INT, \PDO::PARAM_STR) - ), - - // Named parameters : Very simple with one needle - array( - "SELECT * FROM Foo WHERE foo IN (:foo)", - array('foo'=>array(1, 2, 3)), - array('foo'=>Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?, ?, ?)', - array(1, 2, 3), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Named parameters: One non-list before d one after list-needle - array( - "SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar)", - array('foo'=>"string", 'bar'=>array(1, 2, 3)), - array('foo'=>\PDO::PARAM_STR, 'bar'=>Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)', - array("string", 1, 2, 3), - array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Named parameters: One non-list after list-needle - array( - "SELECT * FROM Foo WHERE bar IN (:bar) AND baz = :baz", - array('bar'=>array(1, 2, 3), 'baz'=>"foo"), - array('bar'=>Connection::PARAM_INT_ARRAY, 'baz'=>\PDO::PARAM_STR), - 'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?', - array(1, 2, 3, "foo"), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR) - ), - // Named parameters: One non-list before and one after list-needle - array( - "SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar) AND baz = :baz", - array('bar'=>array(1, 2, 3),'foo'=>1, 'baz'=>4), - array('bar'=>Connection::PARAM_INT_ARRAY, 'foo'=>\PDO::PARAM_INT, 'baz'=>\PDO::PARAM_INT), - 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?', - array(1, 1, 2, 3, 4), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Named parameters: Two lists - array( - "SELECT * FROM Foo WHERE foo IN (:a, :b)", - array('b'=>array(4, 5),'a'=>array(1, 2, 3)), - array('a'=>Connection::PARAM_INT_ARRAY, 'b'=>Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)', - array(1, 2, 3, 4, 5), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Named parameters : With the same name arg type string - array( - "SELECT * FROM Foo WHERE foo <> :arg AND bar = :arg", - array('arg'=>"Some String"), - array('arg'=>\PDO::PARAM_STR), - 'SELECT * FROM Foo WHERE foo <> ? AND bar = ?', - array("Some String","Some String"), - array(\PDO::PARAM_STR,\PDO::PARAM_STR,) - ), - // Named parameters : With the same name arg - array( - "SELECT * FROM Foo WHERE foo IN (:arg) AND NOT bar IN (:arg)", - array('arg'=>array(1, 2, 3)), - array('arg'=>Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?, ?, ?) AND NOT bar IN (?, ?, ?)', - array(1, 2, 3, 1, 2, 3), - array(\PDO::PARAM_INT,\PDO::PARAM_INT, \PDO::PARAM_INT,\PDO::PARAM_INT,\PDO::PARAM_INT, \PDO::PARAM_INT) - ), - - // Named parameters : Same name, other name in between DBAL-299 - array( - "SELECT * FROM Foo WHERE (:foo = 2) AND (:bar = 3) AND (:foo = 2)", - array('foo'=>2,'bar'=>3), - array('foo'=>\PDO::PARAM_INT,'bar'=>\PDO::PARAM_INT), - 'SELECT * FROM Foo WHERE (? = 2) AND (? = 3) AND (? = 2)', - array(2, 3, 2), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) - ), - // Named parameters : Empty "integer" array DDC-1978 - array( - "SELECT * FROM Foo WHERE foo IN (:foo)", - array('foo'=>array()), - array('foo'=>Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?)', - array(), - array() - ), - // Named parameters : Two empty "str" array DDC-1978 - array( - "SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)", - array('foo'=>array(), 'bar'=>array()), - array('foo'=>Connection::PARAM_STR_ARRAY, 'bar'=>Connection::PARAM_STR_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?) OR bar IN (?)', - array(), - array() - ), - array( - "SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar OR baz = :baz", - array('foo' => array(1, 2), 'bar' => 'bar', 'baz' => 'baz'), - array('foo' => Connection::PARAM_INT_ARRAY, 'baz' => 'string'), - 'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ? OR baz = ?', - array(1, 2, 'bar', 'baz'), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR, 'string') - ), - array( - "SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar", - array('foo' => array(1, 2), 'bar' => 'bar'), - array('foo' => Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ?', - array(1, 2, 'bar'), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR) - ), - // Params/types with colons - array( - "SELECT * FROM Foo WHERE foo = :foo OR bar = :bar", - array(':foo' => 'foo', ':bar' => 'bar'), - array(':foo' => \PDO::PARAM_INT), - 'SELECT * FROM Foo WHERE foo = ? OR bar = ?', - array('foo', 'bar'), - array(\PDO::PARAM_INT, \PDO::PARAM_STR) - ), - array( - "SELECT * FROM Foo WHERE foo = :foo OR bar = :bar", - array(':foo' => 'foo', ':bar' => 'bar'), - array(':foo' => \PDO::PARAM_INT, 'bar' => \PDO::PARAM_INT), - 'SELECT * FROM Foo WHERE foo = ? OR bar = ?', - array('foo', 'bar'), - array(\PDO::PARAM_INT, \PDO::PARAM_INT) - ), - array( - "SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar", - array(':foo' => array(1, 2), ':bar' => 'bar'), - array('foo' => Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ?', - array(1, 2, 'bar'), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR) - ), - array( - "SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar", - array('foo' => array(1, 2), 'bar' => 'bar'), - array(':foo' => Connection::PARAM_INT_ARRAY), - 'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ?', - array(1, 2, 'bar'), - array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR) - ), - ); - } - - /** - * @dataProvider dataExpandListParameters - * @param type $q - * @param type $p - * @param type $t - * @param type $expectedQuery - * @param type $expectedParams - * @param type $expectedTypes - */ - public function testExpandListParameters($q, $p, $t, $expectedQuery, $expectedParams, $expectedTypes) - { - list($query, $params, $types) = SQLParserUtils::expandListParameters($q, $p, $t); - - $this->assertEquals($expectedQuery, $query, "Query was not rewritten correctly."); - $this->assertEquals($expectedParams, $params, "Params dont match"); - $this->assertEquals($expectedTypes, $types, "Types dont match"); - } - - public static function dataQueryWithMissingParameters() - { - return array( - array( - "SELECT * FROM foo WHERE bar = :param", - array('other' => 'val'), - array(), - ), - array( - "SELECT * FROM foo WHERE bar = :param", - array(), - array(), - ), - array( - "SELECT * FROM foo WHERE bar = :param", - array(), - array('param' => Connection::PARAM_INT_ARRAY), - ), - array( - "SELECT * FROM foo WHERE bar = :param", - array(), - array(':param' => Connection::PARAM_INT_ARRAY), - ), - array( - "SELECT * FROM foo WHERE bar = :param", - array(), - array('bar' => Connection::PARAM_INT_ARRAY), - ), - array( - "SELECT * FROM foo WHERE bar = :param", - array('bar' => 'value'), - array('bar' => Connection::PARAM_INT_ARRAY), - ), - ); - } - - /** - * @dataProvider dataQueryWithMissingParameters - */ - public function testExceptionIsThrownForMissingParam($query, $params, $types = array()) - { - $this->setExpectedException( - 'Doctrine\DBAL\SQLParserUtilsException', - 'Value for :param not found in params array. Params array key should be "param"' - ); - - SQLParserUtils::expandListParameters($query, $params, $types); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php deleted file mode 100755 index 2051061657..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php +++ /dev/null @@ -1,114 +0,0 @@ -createColumn(); - - $this->assertEquals("foo", $column->getName()); - $this->assertSame(Type::getType('string'), $column->getType()); - - $this->assertEquals(200, $column->getLength()); - $this->assertEquals(5, $column->getPrecision()); - $this->assertEquals(2, $column->getScale()); - $this->assertTrue($column->getUnsigned()); - $this->assertFalse($column->getNotNull()); - $this->assertTrue($column->getFixed()); - $this->assertEquals("baz", $column->getDefault()); - - $this->assertEquals(array('foo' => 'bar'), $column->getPlatformOptions()); - $this->assertTrue($column->hasPlatformOption('foo')); - $this->assertEquals('bar', $column->getPlatformOption('foo')); - $this->assertFalse($column->hasPlatformOption('bar')); - - $this->assertEquals(array('bar' => 'baz'), $column->getCustomSchemaOptions()); - $this->assertTrue($column->hasCustomSchemaOption('bar')); - $this->assertEquals('baz', $column->getCustomSchemaOption('bar')); - $this->assertFalse($column->hasCustomSchemaOption('foo')); - } - - public function testToArray() - { - $expected = array( - 'name' => 'foo', - 'type' => Type::getType('string'), - 'default' => 'baz', - 'notnull' => false, - 'length' => 200, - 'precision' => 5, - 'scale' => 2, - 'fixed' => true, - 'unsigned' => true, - 'autoincrement' => false, - 'columnDefinition' => null, - 'comment' => null, - 'foo' => 'bar', - 'bar' => 'baz' - ); - - $this->assertEquals($expected, $this->createColumn()->toArray()); - } - - /** - * @return Column - */ - public function createColumn() - { - $options = array( - 'length' => 200, - 'precision' => 5, - 'scale' => 2, - 'unsigned' => true, - 'notnull' => false, - 'fixed' => true, - 'default' => 'baz', - 'platformOptions' => array('foo' => 'bar'), - 'customSchemaOptions' => array('bar' => 'baz'), - ); - - $string = Type::getType('string'); - return new Column("foo", $string, $options); - } - - /** - * @group DBAL-64 - */ - public function testQuotedColumnName() - { - $string = Type::getType('string'); - $column = new Column("`bar`", $string, array()); - - $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform(); - $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform(); - - $this->assertEquals('bar', $column->getName()); - $this->assertEquals('`bar`', $column->getQuotedName($mysqlPlatform)); - $this->assertEquals('"bar"', $column->getQuotedName($sqlitePlatform)); - } - - /** - * @group DBAL-42 - */ - public function testColumnComment() - { - $column = new Column("bar", Type::getType('string')); - $this->assertNull($column->getComment()); - - $column->setComment("foo"); - $this->assertEquals("foo", $column->getComment()); - - $columnArray = $column->toArray(); - $this->assertArrayHasKey('comment', $columnArray); - $this->assertEquals('foo', $columnArray['comment']); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php deleted file mode 100755 index 32a303bbdb..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php +++ /dev/null @@ -1,894 +0,0 @@ -. - */ - -namespace Doctrine\Tests\DBAL\Schema; - -require_once __DIR__ . '/../../TestInit.php'; - -use Doctrine\DBAL\Schema\Schema, - Doctrine\DBAL\Schema\SchemaConfig, - Doctrine\DBAL\Schema\Table, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\Index, - Doctrine\DBAL\Schema\Sequence, - Doctrine\DBAL\Schema\SchemaDiff, - Doctrine\DBAL\Schema\TableDiff, - Doctrine\DBAL\Schema\Comparator, - Doctrine\DBAL\Types\Type, - Doctrine\DBAL\Schema\ForeignKeyConstraint; - -/** - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - */ -class ComparatorTest extends \PHPUnit_Framework_TestCase -{ - public function testCompareSame1() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer' ) ), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer') ), - ) - ), - ) ); - - $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareSame2() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - ) - ), - ) ); - $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareMissingTable() - { - $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig; - $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer')))); - $table->setSchemaConfig($schemaConfig); - - $schema1 = new Schema( array($table), array(), $schemaConfig ); - $schema2 = new Schema( array(), array(), $schemaConfig ); - - $expected = new SchemaDiff( array(), array(), array('bugdb' => $table) ); - - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareNewTable() - { - $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig; - $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer')))); - $table->setSchemaConfig($schemaConfig); - - $schema1 = new Schema( array(), array(), $schemaConfig ); - $schema2 = new Schema( array($table), array(), $schemaConfig ); - - $expected = new SchemaDiff( array('bugdb' => $table), array(), array() ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareOnlyAutoincrementChanged() - { - $column1 = new Column('foo', Type::getType('integer'), array('autoincrement' => true)); - $column2 = new Column('foo', Type::getType('integer'), array('autoincrement' => false)); - - $comparator = new Comparator(); - $changedProperties = $comparator->diffColumn($column1, $column2); - - $this->assertEquals(array('autoincrement'), $changedProperties); - } - - public function testCompareMissingField() - { - $missingColumn = new Column('integerfield1', Type::getType('integer')); - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => $missingColumn, - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff( 'bugdb', array(), array(), - array ( - 'integerfield1' => $missingColumn, - ) - ) - ) - ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareNewField() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff ('bugdb', - array ( - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) - ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareChangedColumns_ChangeType() - { - $column1 = new Column('charfield1', Type::getType('string')); - $column2 = new Column('charfield1', Type::getType('integer')); - - $c = new Comparator(); - $this->assertEquals(array('type'), $c->diffColumn($column1, $column2)); - $this->assertEquals(array(), $c->diffColumn($column1, $column1)); - } - - public function testCompareChangedColumns_ChangeCustomSchemaOption() - { - $column1 = new Column('charfield1', Type::getType('string')); - $column2 = new Column('charfield1', Type::getType('string')); - - $column1->setCustomSchemaOption('foo', 'bar'); - $column2->setCustomSchemaOption('foo', 'bar'); - - $column1->setCustomSchemaOption('foo1', 'bar1'); - $column2->setCustomSchemaOption('foo2', 'bar2'); - - $c = new Comparator(); - $this->assertEquals(array('foo1', 'foo2'), $c->diffColumn($column1, $column2)); - $this->assertEquals(array(), $c->diffColumn($column1, $column1)); - } - - public function testCompareChangeColumns_MultipleNewColumnsRename() - { - $tableA = new Table("foo"); - $tableA->addColumn('datefield1', 'datetime'); - - $tableB = new Table("foo"); - $tableB->addColumn('new_datefield1', 'datetime'); - $tableB->addColumn('new_datefield2', 'datetime'); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertCount(1, $tableDiff->renamedColumns, "we should have one rename datefield1 => new_datefield1."); - $this->assertArrayHasKey('datefield1', $tableDiff->renamedColumns, "'datefield1' should be set to be renamed to new_datefield1"); - $this->assertCount(1, $tableDiff->addedColumns, "'new_datefield2' should be added"); - $this->assertArrayHasKey('new_datefield2', $tableDiff->addedColumns, "'new_datefield2' should be added, not created through renaming!"); - $this->assertCount(0, $tableDiff->removedColumns, "Nothing should be removed."); - $this->assertCount(0, $tableDiff->changedColumns, "Nothing should be changed as all fields old & new have diff names."); - } - - public function testCompareRemovedIndex() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), array(), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) - ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareNewIndex() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) - ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareChangedIndex() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', - array('integerfield1', 'integerfield2'), - true - ) - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1', - 'integerfield2' - ), - true - ) - ) - ), - ) - ); - $actual = Comparator::compareSchemas( $schema1, $schema2 ); - $this->assertEquals($expected, $actual); - } - - public function testCompareChangedIndexFieldPositions() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', array('integerfield1', 'integerfield2'), true) - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true) - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff('bugdb', array(), array(), array(), array(), - array ( - 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true) - ) - ), - ) - ); - $actual = Comparator::compareSchemas( $schema1, $schema2 ); - $this->assertEquals($expected, $actual); - } - - public function testCompareSequences() - { - $seq1 = new Sequence('foo', 1, 1); - $seq2 = new Sequence('foo', 1, 2); - $seq3 = new Sequence('foo', 2, 1); - - $c = new Comparator(); - - $this->assertTrue($c->diffSequence($seq1, $seq2)); - $this->assertTrue($c->diffSequence($seq1, $seq3)); - } - - public function testRemovedSequence() - { - $schema1 = new Schema(); - $seq = $schema1->createSequence('foo'); - - $schema2 = new Schema(); - - $c = new Comparator(); - $diffSchema = $c->compare($schema1, $schema2); - - $this->assertEquals(1, count($diffSchema->removedSequences)); - $this->assertSame($seq, $diffSchema->removedSequences[0]); - } - - public function testAddedSequence() - { - $schema1 = new Schema(); - - $schema2 = new Schema(); - $seq = $schema2->createSequence('foo'); - - $c = new Comparator(); - $diffSchema = $c->compare($schema1, $schema2); - - $this->assertEquals(1, count($diffSchema->newSequences)); - $this->assertSame($seq, $diffSchema->newSequences[0]); - } - - public function testTableAddForeignKey() - { - $tableForeign = new Table("bar"); - $tableForeign->addColumn('id', 'integer'); - - $table1 = new Table("foo"); - $table1->addColumn('fk', 'integer'); - - $table2 = new Table("foo"); - $table2->addColumn('fk', 'integer'); - $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($table1, $table2); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertEquals(1, count($tableDiff->addedForeignKeys)); - } - - public function testTableRemoveForeignKey() - { - $tableForeign = new Table("bar"); - $tableForeign->addColumn('id', 'integer'); - - $table1 = new Table("foo"); - $table1->addColumn('fk', 'integer'); - - $table2 = new Table("foo"); - $table2->addColumn('fk', 'integer'); - $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($table2, $table1); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertEquals(1, count($tableDiff->removedForeignKeys)); - } - - public function testTableUpdateForeignKey() - { - $tableForeign = new Table("bar"); - $tableForeign->addColumn('id', 'integer'); - - $table1 = new Table("foo"); - $table1->addColumn('fk', 'integer'); - $table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); - - $table2 = new Table("foo"); - $table2->addColumn('fk', 'integer'); - $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'), array('onUpdate' => 'CASCADE')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($table1, $table2); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertEquals(1, count($tableDiff->changedForeignKeys)); - } - - public function testMovedForeignKeyForeignTable() - { - $tableForeign = new Table("bar"); - $tableForeign->addColumn('id', 'integer'); - - $tableForeign2 = new Table("bar2"); - $tableForeign2->addColumn('id', 'integer'); - - $table1 = new Table("foo"); - $table1->addColumn('fk', 'integer'); - $table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); - - $table2 = new Table("foo"); - $table2->addColumn('fk', 'integer'); - $table2->addForeignKeyConstraint($tableForeign2, array('fk'), array('id')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($table1, $table2); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertEquals(1, count($tableDiff->changedForeignKeys)); - } - - public function testTablesCaseInsensitive() - { - $schemaA = new Schema(); - $schemaA->createTable('foo'); - $schemaA->createTable('bAr'); - $schemaA->createTable('BAZ'); - $schemaA->createTable('new'); - - $schemaB = new Schema(); - $schemaB->createTable('FOO'); - $schemaB->createTable('bar'); - $schemaB->createTable('Baz'); - $schemaB->createTable('old'); - - $c = new Comparator(); - $diff = $c->compare($schemaA, $schemaB); - - $this->assertSchemaTableChangeCount($diff, 1, 0, 1); - } - - public function testSequencesCaseInsenstive() - { - $schemaA = new Schema(); - $schemaA->createSequence('foo'); - $schemaA->createSequence('BAR'); - $schemaA->createSequence('Baz'); - $schemaA->createSequence('new'); - - $schemaB = new Schema(); - $schemaB->createSequence('FOO'); - $schemaB->createSequence('Bar'); - $schemaB->createSequence('baz'); - $schemaB->createSequence('old'); - - $c = new Comparator(); - $diff = $c->compare($schemaA, $schemaB); - - $this->assertSchemaSequenceChangeCount($diff, 1, 0, 1); - } - - public function testCompareColumnCompareCaseInsensitive() - { - $tableA = new Table("foo"); - $tableA->addColumn('id', 'integer'); - - $tableB = new Table("foo"); - $tableB->addColumn('ID', 'integer'); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertFalse($tableDiff); - } - - public function testCompareIndexBasedOnPropertiesNotName() - { - $tableA = new Table("foo"); - $tableA->addColumn('id', 'integer'); - $tableA->addIndex(array("id"), "foo_bar_idx"); - - $tableB = new Table("foo"); - $tableB->addColumn('ID', 'integer'); - $tableB->addIndex(array("id"), "bar_foo_idx"); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertFalse($tableDiff); - } - - public function testCompareForeignKeyBasedOnPropertiesNotName() - { - $tableA = new Table("foo"); - $tableA->addColumn('id', 'integer'); - $tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', array('id'), array('id')); - - $tableB = new Table("foo"); - $tableB->addColumn('ID', 'integer'); - $tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', array('id'), array('id')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertFalse($tableDiff); - } - - public function testCompareForeignKey_RestrictNoAction_AreTheSame() - { - $fk1 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'NO ACTION')); - $fk2 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'RESTRICT')); - - $c = new Comparator(); - $this->assertFalse($c->diffForeignKey($fk1, $fk2)); - } - - /** - * @group DBAL-492 - */ - public function testCompareForeignKeyNamesUnqualified_AsNoSchemaInformationIsAvailable() - { - $fk1 = new ForeignKeyConstraint(array("foo"), "foo.bar", array("baz"), "fk1"); - $fk2 = new ForeignKeyConstraint(array("foo"), "baz.bar", array("baz"), "fk1"); - - $c = new Comparator(); - $this->assertFalse($c->diffForeignKey($fk1, $fk2)); - } - - public function testDetectRenameColumn() - { - $tableA = new Table("foo"); - $tableA->addColumn('foo', 'integer'); - - $tableB = new Table("foo"); - $tableB->addColumn('bar', 'integer'); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertEquals(0, count($tableDiff->addedColumns)); - $this->assertEquals(0, count($tableDiff->removedColumns)); - $this->assertArrayHasKey('foo', $tableDiff->renamedColumns); - $this->assertEquals('bar', $tableDiff->renamedColumns['foo']->getName()); - } - - /** - * You can easily have ambiguouties in the column renaming. If these - * are detected no renaming should take place, instead adding and dropping - * should be used exclusively. - * - * @group DBAL-24 - */ - public function testDetectRenameColumnAmbiguous() - { - $tableA = new Table("foo"); - $tableA->addColumn('foo', 'integer'); - $tableA->addColumn('bar', 'integer'); - - $tableB = new Table("foo"); - $tableB->addColumn('baz', 'integer'); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertEquals(1, count($tableDiff->addedColumns), "'baz' should be added, not created through renaming!"); - $this->assertArrayHasKey('baz', $tableDiff->addedColumns, "'baz' should be added, not created through renaming!"); - $this->assertEquals(2, count($tableDiff->removedColumns), "'foo' and 'bar' should both be dropped, an ambigouty exists which one could be renamed to 'baz'."); - $this->assertArrayHasKey('foo', $tableDiff->removedColumns, "'foo' should be removed."); - $this->assertArrayHasKey('bar', $tableDiff->removedColumns, "'bar' should be removed."); - $this->assertEquals(0, count($tableDiff->renamedColumns), "no renamings should take place."); - } - - public function testDetectChangeIdentifierType() - { - $this->markTestSkipped('DBAL-2 was reopened, this test cannot work anymore.'); - - $tableA = new Table("foo"); - $tableA->addColumn('id', 'integer', array('autoincrement' => false)); - - $tableB = new Table("foo"); - $tableB->addColumn('id', 'integer', array('autoincrement' => true)); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertArrayHasKey('id', $tableDiff->changedColumns); - } - - - /** - * @group DBAL-105 - */ - public function testDiff() - { - $table = new \Doctrine\DBAL\Schema\Table('twitter_users'); - $table->addColumn('id', 'integer', array('autoincrement' => true)); - $table->addColumn('twitterId', 'integer', array('nullable' => false)); - $table->addColumn('displayName', 'string', array('nullable' => false)); - $table->setPrimaryKey(array('id')); - - $newtable = new \Doctrine\DBAL\Schema\Table('twitter_users'); - $newtable->addColumn('id', 'integer', array('autoincrement' => true)); - $newtable->addColumn('twitter_id', 'integer', array('nullable' => false)); - $newtable->addColumn('display_name', 'string', array('nullable' => false)); - $newtable->addColumn('logged_in_at', 'datetime', array('nullable' => true)); - $newtable->setPrimaryKey(array('id')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($table, $newtable); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertEquals(array('twitterid', 'displayname'), array_keys($tableDiff->renamedColumns)); - $this->assertEquals(array('logged_in_at'), array_keys($tableDiff->addedColumns)); - $this->assertEquals(0, count($tableDiff->removedColumns)); - } - - - /** - * @group DBAL-112 - */ - public function testChangedSequence() - { - $schema = new Schema(); - $sequence = $schema->createSequence('baz'); - - $schemaNew = clone $schema; - /* @var $schemaNew Schema */ - $schemaNew->getSequence('baz')->setAllocationSize(20); - - $c = new \Doctrine\DBAL\Schema\Comparator; - $diff = $c->compare($schema, $schemaNew); - - $this->assertSame($diff->changedSequences[0] , $schemaNew->getSequence('baz')); - } - - /** - * @group DBAL-106 - */ - public function testDiffDecimalWithNullPrecision() - { - $column = new Column('foo', Type::getType('decimal')); - $column->setPrecision(null); - - $column2 = new Column('foo', Type::getType('decimal')); - - $c = new Comparator(); - $this->assertEquals(array(), $c->diffColumn($column, $column2)); - } - - /** - * @group DBAL-204 - */ - public function testFqnSchemaComparision() - { - $config = new SchemaConfig(); - $config->setName("foo"); - - $oldSchema = new Schema(array(), array(), $config); - $oldSchema->createTable('bar'); - - $newSchema= new Schema(array(), array(), $config); - $newSchema->createTable('foo.bar'); - - $c = new Comparator(); - $this->assertEquals(new SchemaDiff(), $c->compare($oldSchema, $newSchema)); - } - - /** - * @group DBAL-204 - */ - public function testFqnSchemaComparisionDifferentSchemaNameButSameTableNoDiff() - { - $config = new SchemaConfig(); - $config->setName("foo"); - - $oldSchema = new Schema(array(), array(), $config); - $oldSchema->createTable('foo.bar'); - - $newSchema = new Schema(); - $newSchema->createTable('bar'); - - $c = new Comparator(); - $diff = $c->compare($oldSchema, $newSchema); - $this->assertEquals(new SchemaDiff(), $c->compare($oldSchema, $newSchema)); - } - - /** - * @group DBAL-204 - */ - public function testFqnSchemaComparisionNoSchemaSame() - { - $config = new SchemaConfig(); - $config->setName("foo"); - $oldSchema = new Schema(array(), array(), $config); - $oldSchema->createTable('bar'); - - $newSchema = new Schema(); - $newSchema->createTable('bar'); - - $c = new Comparator(); - $diff = $c->compare($oldSchema, $newSchema); - - $this->assertEquals(new SchemaDiff(), $c->compare($oldSchema, $newSchema)); - } - - /** - * @group DDC-1657 - */ - public function testAutoIncremenetSequences() - { - $oldSchema = new Schema(); - $table = $oldSchema->createTable("foo"); - $table->addColumn("id", "integer", array("autoincrement" => true)); - $table->setPrimaryKey(array("id")); - $oldSchema->createSequence("foo_id_seq"); - - $newSchema = new Schema(); - $table = $newSchema->createTable("foo"); - $table->addColumn("id", "integer", array("autoincrement" => true)); - $table->setPrimaryKey(array("id")); - - $c = new Comparator(); - $diff = $c->compare($oldSchema, $newSchema); - - $this->assertCount(0, $diff->removedSequences); - } - - - /** - * You can get multiple drops for a FK when a table referenced by a foreign - * key is deleted, as this FK is referenced twice, once on the orphanedForeignKeys - * array because of the dropped table, and once on changedTables array. We - * now check that the key is present once. - */ - public function testAvoidMultipleDropForeignKey() - { - $oldSchema = new Schema(); - - $tableForeign = $oldSchema->createTable('foreign'); - $tableForeign->addColumn('id', 'integer'); - - $table = $oldSchema->createTable('foo'); - $table->addColumn('fk', 'integer'); - $table->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); - - - $newSchema = new Schema(); - $table = $newSchema->createTable('foo'); - - $c = new Comparator(); - $diff = $c->compare($oldSchema, $newSchema); - - $this->assertCount(0, $diff->changedTables['foo']->removedForeignKeys); - $this->assertCount(1, $diff->orphanedForeignKeys); - } - - - /** - * @param SchemaDiff $diff - * @param int $newTableCount - * @param int $changeTableCount - * @param int $removeTableCount - */ - public function assertSchemaTableChangeCount($diff, $newTableCount=0, $changeTableCount=0, $removeTableCount=0) - { - $this->assertEquals($newTableCount, count($diff->newTables)); - $this->assertEquals($changeTableCount, count($diff->changedTables)); - $this->assertEquals($removeTableCount, count($diff->removedTables)); - } - - /** - * @param SchemaDiff $diff - * @param int $newSequenceCount - * @param int $changeSequenceCount - * @param int $changeSequenceCount - */ - public function assertSchemaSequenceChangeCount($diff, $newSequenceCount=0, $changeSequenceCount=0, $removeSequenceCount=0) - { - $this->assertEquals($newSequenceCount, count($diff->newSequences), "Expected number of new sequences is wrong."); - $this->assertEquals($changeSequenceCount, count($diff->changedSequences), "Expected number of changed sequences is wrong."); - $this->assertEquals($removeSequenceCount, count($diff->removedSequences), "Expected number of removed sequences is wrong."); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php deleted file mode 100755 index ed6b070f0a..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php +++ /dev/null @@ -1,115 +0,0 @@ -createIndex(); - $this->assertEquals("foo", $idx->getName()); - $columns = $idx->getColumns(); - $this->assertEquals(2, count($columns)); - $this->assertEquals(array("bar", "baz"), $columns); - $this->assertFalse($idx->isUnique()); - $this->assertFalse($idx->isPrimary()); - } - - public function testCreatePrimary() - { - $idx = $this->createIndex(false, true); - $this->assertTrue($idx->isUnique()); - $this->assertTrue($idx->isPrimary()); - } - - public function testCreateUnique() - { - $idx = $this->createIndex(true, false); - $this->assertTrue($idx->isUnique()); - $this->assertFalse($idx->isPrimary()); - } - - /** - * @group DBAL-50 - */ - public function testFullfilledByUnique() - { - $idx1 = $this->createIndex(true, false); - $idx2 = $this->createIndex(true, false); - $idx3 = $this->createIndex(); - - $this->assertTrue($idx1->isFullfilledBy($idx2)); - $this->assertFalse($idx1->isFullfilledBy($idx3)); - } - - /** - * @group DBAL-50 - */ - public function testFullfilledByPrimary() - { - $idx1 = $this->createIndex(true, true); - $idx2 = $this->createIndex(true, true); - $idx3 = $this->createIndex(true, false); - - $this->assertTrue($idx1->isFullfilledBy($idx2)); - $this->assertFalse($idx1->isFullfilledBy($idx3)); - } - - /** - * @group DBAL-50 - */ - public function testFullfilledByIndex() - { - $idx1 = $this->createIndex(); - $idx2 = $this->createIndex(); - $pri = $this->createIndex(true, true); - $uniq = $this->createIndex(true); - - $this->assertTrue($idx1->isFullfilledBy($idx2)); - $this->assertTrue($idx1->isFullfilledBy($pri)); - $this->assertTrue($idx1->isFullfilledBy($uniq)); - } - - /** - * @group DBAL-220 - */ - public function testFlags() - { - $idx1 = $this->createIndex(); - $this->assertFalse($idx1->hasFlag('clustered')); - - $idx1->addFlag('clustered'); - $this->assertTrue($idx1->hasFlag('clustered')); - $this->assertTrue($idx1->hasFlag('CLUSTERED')); - - $idx1->removeFlag('clustered'); - $this->assertFalse($idx1->hasFlag('clustered')); - } - - /** - * @group DBAL-285 - */ - public function testIndexQuotes() - { - $index = new Index("foo", array("`bar`", "`baz`")); - - $this->assertTrue($index->spansColumns(array("bar", "baz"))); - $this->assertTrue($index->hasColumnAtPosition("bar", 0)); - $this->assertTrue($index->hasColumnAtPosition("baz", 1)); - - $this->assertFalse($index->hasColumnAtPosition("bar", 1)); - $this->assertFalse($index->hasColumnAtPosition("baz", 0)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php deleted file mode 100755 index ff093fb99a..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php +++ /dev/null @@ -1,74 +0,0 @@ -getMock('Doctrine\DBAL\Driver'); - $platform = $this->getMock('Doctrine\DBAL\Platforms\MySqlPlatform'); - $this->conn = $this->getMock( - 'Doctrine\DBAL\Connection', - array('fetchAll'), - array(array('platform' => $platform), $driverMock, new Configuration(), $eventManager) - ); - $this->manager = new MySqlSchemaManager($this->conn); - } - - public function testCompositeForeignKeys() - { - $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue($this->getFKDefinition())); - $fkeys = $this->manager->listTableForeignKeys('dummy'); - $this->assertEquals(1, count($fkeys), "Table has to have one foreign key."); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); - $this->assertEquals(array('column_1', 'column_2', 'column_3'), array_map('strtolower', $fkeys[0]->getLocalColumns())); - $this->assertEquals(array('column_1', 'column_2', 'column_3'), array_map('strtolower', $fkeys[0]->getForeignColumns())); - } - - public function getFKDefinition() - { - return array( - array( - "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E", - "COLUMN_NAME" => "column_1", - "REFERENCED_TABLE_NAME" => "dummy", - "REFERENCED_COLUMN_NAME" => "column_1", - "update_rule" => "RESTRICT", - "delete_rule" => "RESTRICT", - ), - array( - "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E", - "COLUMN_NAME" => "column_2", - "REFERENCED_TABLE_NAME" => "dummy", - "REFERENCED_COLUMN_NAME" => "column_2", - "update_rule" => "RESTRICT", - "delete_rule" => "RESTRICT", - ), - array( - "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E", - "COLUMN_NAME" => "column_3", - "REFERENCED_TABLE_NAME" => "dummy", - "REFERENCED_COLUMN_NAME" => "column_3", - "update_rule" => "RESTRICT", - "delete_rule" => "RESTRICT", - ) - ); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php deleted file mode 100755 index 651a5ee23e..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php +++ /dev/null @@ -1,88 +0,0 @@ -comparator = new \Doctrine\DBAL\Schema\Comparator; - $this->platform = new \Doctrine\DBAL\Platforms\MySqlPlatform; - } - - public function testSwitchPrimaryKeyOrder() - { - $tableOld = new Table("test"); - $tableOld->addColumn('foo_id', 'integer'); - $tableOld->addColumn('bar_id', 'integer'); - $tableNew = clone $tableOld; - - $tableOld->setPrimaryKey(array('foo_id', 'bar_id')); - $tableNew->setPrimaryKey(array('bar_id', 'foo_id')); - - $diff = $this->comparator->diffTable($tableOld, $tableNew); - $sql = $this->platform->getAlterTableSQL($diff); - - $this->assertEquals( - array( - 'ALTER TABLE test DROP PRIMARY KEY', - 'ALTER TABLE test ADD PRIMARY KEY (bar_id, foo_id)' - ), $sql - ); - } - - /** - * @group DBAL-132 - */ - public function testGenerateForeignKeySQL() - { - $tableOld = new Table("test"); - $tableOld->addColumn('foo_id', 'integer'); - $tableOld->addUnnamedForeignKeyConstraint('test_foreign', array('foo_id'), array('foo_id')); - - $sqls = array(); - foreach ($tableOld->getForeignKeys() AS $fk) { - $sqls[] = $this->platform->getCreateForeignKeySQL($fk, $tableOld); - } - - $this->assertEquals(array("ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C8E48560F FOREIGN KEY (foo_id) REFERENCES test_foreign (foo_id)"), $sqls); - } - - /** - * @group DDC-1737 - */ - public function testClobNoAlterTable() - { - $tableOld = new Table("test"); - $tableOld->addColumn('id', 'integer'); - $tableOld->addColumn('description', 'string', array('length' => 65536)); - $tableNew = clone $tableOld; - - $tableNew->setPrimaryKey(array('id')); - - $diff = $this->comparator->diffTable($tableOld, $tableNew); - $sql = $this->platform->getAlterTableSQL($diff); - - $this->assertEquals( - array('ALTER TABLE test ADD PRIMARY KEY (id)'), - $sql - ); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php deleted file mode 100755 index 16bf92a224..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php +++ /dev/null @@ -1,109 +0,0 @@ -createSchemaDiff(); - $platform = $this->createPlatform(true); - - $sql = $diff->toSql($platform); - - $expected = array('drop_orphan_fk', 'alter_seq', 'drop_seq', 'create_seq', 'create_table', 'create_foreign_key', 'drop_table', 'alter_table'); - - $this->assertEquals($expected, $sql); - } - - public function testSchemaDiffToSaveSql() - { - $diff = $this->createSchemaDiff(); - $platform = $this->createPlatform(false); - - $sql = $diff->toSaveSql($platform); - - $expected = array('alter_seq', 'create_seq', 'create_table', 'create_foreign_key', 'alter_table'); - - $this->assertEquals($expected, $sql); - } - - public function createPlatform($unsafe = false) - { - $platform = $this->getMock('Doctrine\Tests\DBAL\Mocks\MockPlatform'); - if ($unsafe) { - $platform->expects($this->exactly(1)) - ->method('getDropSequenceSql') - ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) - ->will($this->returnValue('drop_seq')); - } - $platform->expects($this->exactly(1)) - ->method('getAlterSequenceSql') - ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) - ->will($this->returnValue('alter_seq')); - $platform->expects($this->exactly(1)) - ->method('getCreateSequenceSql') - ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) - ->will($this->returnValue('create_seq')); - if ($unsafe) { - $platform->expects($this->exactly(1)) - ->method('getDropTableSql') - ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table')) - ->will($this->returnValue('drop_table')); - } - $platform->expects($this->exactly(1)) - ->method('getCreateTableSql') - ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table')) - ->will($this->returnValue(array('create_table'))); - $platform->expects($this->exactly(1)) - ->method('getCreateForeignKeySQL') - ->with($this->isInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint')) - ->will($this->returnValue('create_foreign_key')); - $platform->expects($this->exactly(1)) - ->method('getAlterTableSql') - ->with($this->isInstanceOf('Doctrine\DBAL\Schema\TableDiff')) - ->will($this->returnValue(array('alter_table'))); - if ($unsafe) { - $platform->expects($this->exactly(1)) - ->method('getDropForeignKeySql') - ->with($this->isInstanceof('Doctrine\DBAL\Schema\ForeignKeyConstraint'), $this->equalTo('local_table')) - ->will($this->returnValue('drop_orphan_fk')); - } - $platform->expects($this->exactly(1)) - ->method('supportsSequences') - ->will($this->returnValue(true)); - $platform->expects($this->exactly(2)) - ->method('supportsForeignKeyConstraints') - ->will($this->returnValue(true)); - return $platform; - } - - public function createSchemaDiff() - { - $diff = new SchemaDiff(); - $diff->changedSequences['foo_seq'] = new Sequence('foo_seq'); - $diff->newSequences['bar_seq'] = new Sequence('bar_seq'); - $diff->removedSequences['baz_seq'] = new Sequence('baz_seq'); - $diff->newTables['foo_table'] = new Table('foo_table'); - $diff->removedTables['bar_table'] = new Table('bar_table'); - $diff->changedTables['baz_table'] = new TableDiff('baz_table'); - $diff->newTables['foo_table']->addColumn('foreign_id', 'integer'); - $diff->newTables['foo_table']->addForeignKeyConstraint('foreign_table', array('foreign_id'), array('id')); - $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('id'), 'foreign_table', array('id')); - $fk->setLocalTable(new Table('local_table')); - $diff->orphanedForeignKeys[] = $fk; - return $diff; - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php deleted file mode 100755 index 096ede7903..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ /dev/null @@ -1,224 +0,0 @@ -assertTrue($schema->hasTable($tableName)); - - $tables = $schema->getTables(); - $this->assertTrue( isset($tables[$tableName]) ); - $this->assertSame($table, $tables[$tableName]); - $this->assertSame($table, $schema->getTable($tableName)); - $this->assertTrue($schema->hasTable($tableName)); - } - - public function testTableMatchingCaseInsenstive() - { - $table = new Table("Foo"); - - $schema = new Schema(array($table)); - $this->assertTrue($schema->hasTable("foo")); - $this->assertTrue($schema->hasTable("FOO")); - - $this->assertSame($table, $schema->getTable('FOO')); - $this->assertSame($table, $schema->getTable('foo')); - $this->assertSame($table, $schema->getTable('Foo')); - } - - public function testGetUnknownTableThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $schema = new Schema(); - $schema->getTable("unknown"); - } - - public function testCreateTableTwiceThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $tableName = "foo"; - $table = new Table($tableName); - $tables = array($table, $table); - - $schema = new Schema($tables); - } - - public function testRenameTable() - { - $tableName = "foo"; - $table = new Table($tableName); - $schema = new Schema(array($table)); - - $this->assertTrue($schema->hasTable("foo")); - $schema->renameTable("foo", "bar"); - $this->assertFalse($schema->hasTable("foo")); - $this->assertTrue($schema->hasTable("bar")); - $this->assertSame($table, $schema->getTable("bar")); - } - - public function testDropTable() - { - $tableName = "foo"; - $table = new Table($tableName); - $schema = new Schema(array($table)); - - $this->assertTrue($schema->hasTable("foo")); - - $schema->dropTable("foo"); - - $this->assertFalse($schema->hasTable("foo")); - } - - public function testCreateTable() - { - $schema = new Schema(); - - $this->assertFalse($schema->hasTable("foo")); - - $table = $schema->createTable("foo"); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table); - $this->assertEquals("foo", $table->getName()); - $this->assertTrue($schema->hasTable("foo")); - } - - public function testAddSequences() - { - $sequence = new Sequence("a_seq", 1, 1); - - $schema = new Schema(array(), array($sequence)); - - $this->assertTrue($schema->hasSequence("a_seq")); - $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq")); - - $sequences = $schema->getSequences(); - $this->assertArrayHasKey('public.a_seq', $sequences); - } - - public function testSequenceAccessCaseInsensitive() - { - $sequence = new Sequence("a_Seq"); - - $schema = new Schema(array(), array($sequence)); - $this->assertTrue($schema->hasSequence('a_seq')); - $this->assertTrue($schema->hasSequence('a_Seq')); - $this->assertTrue($schema->hasSequence('A_SEQ')); - - $this->assertEquals($sequence, $schema->getSequence('a_seq')); - $this->assertEquals($sequence, $schema->getSequence('a_Seq')); - $this->assertEquals($sequence, $schema->getSequence('A_SEQ')); - } - - public function testGetUnknownSequenceThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $schema = new Schema(); - $schema->getSequence("unknown"); - } - - public function testCreateSequence() - { - $schema = new Schema(); - $sequence = $schema->createSequence('a_seq', 10, 20); - - $this->assertEquals('a_seq', $sequence->getName()); - $this->assertEquals(10, $sequence->getAllocationSize()); - $this->assertEquals(20, $sequence->getInitialValue()); - - $this->assertTrue($schema->hasSequence("a_seq")); - $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq")); - - $sequences = $schema->getSequences(); - $this->assertArrayHasKey('public.a_seq', $sequences); - } - - public function testDropSequence() - { - $sequence = new Sequence("a_seq", 1, 1); - - $schema = new Schema(array(), array($sequence)); - - $schema->dropSequence("a_seq"); - $this->assertFalse($schema->hasSequence("a_seq")); - } - - public function testAddSequenceTwiceThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $sequence = new Sequence("a_seq", 1, 1); - - $schema = new Schema(array(), array($sequence, $sequence)); - } - - public function testConfigMaxIdentifierLength() - { - $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig(); - $schemaConfig->setMaxIdentifierLength(5); - - $schema = new Schema(array(), array(), $schemaConfig); - $table = $schema->createTable("smalltable"); - $table->addColumn('long_id', 'integer'); - $table->addIndex(array('long_id')); - - $index = current($table->getIndexes()); - $this->assertEquals(5, strlen($index->getName())); - } - - public function testDeepClone() - { - $schema = new Schema(); - $sequence = $schema->createSequence('baz'); - - $tableA = $schema->createTable('foo'); - $tableA->addColumn('id', 'integer'); - - $tableB = $schema->createTable('bar'); - $tableB->addColumn('id', 'integer'); - $tableB->addColumn('foo_id', 'integer'); - $tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id')); - - $schemaNew = clone $schema; - - $this->assertNotSame($sequence, $schemaNew->getSequence('baz')); - - $this->assertNotSame($tableA, $schemaNew->getTable('foo')); - $this->assertNotSame($tableA->getColumn('id'), $schemaNew->getTable('foo')->getColumn('id')); - - $this->assertNotSame($tableB, $schemaNew->getTable('bar')); - $this->assertNotSame($tableB->getColumn('id'), $schemaNew->getTable('bar')->getColumn('id')); - - $fk = $schemaNew->getTable('bar')->getForeignKeys(); - $fk = current($fk); - $this->assertSame($schemaNew->getTable('bar'), $this->readAttribute($fk, '_localTable')); - } - - /** - * @group DBAL-219 - */ - public function testHasTableForQuotedAsset() - { - $schema = new Schema(); - - $tableA = $schema->createTable('foo'); - $tableA->addColumn('id', 'integer'); - - $this->assertTrue($schema->hasTable('`foo`')); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php deleted file mode 100755 index 3ee093740f..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php +++ /dev/null @@ -1,28 +0,0 @@ -addColumn("id", "integer", array("autoincrement" => true)); - $table->setPrimaryKey(array("id")); - - $sequence = new Sequence("foo_id_seq"); - $sequence2 = new Sequence("bar_id_seq"); - $sequence3 = new Sequence("other.foo_id_seq"); - - $this->assertTrue($sequence->isAutoIncrementsFor($table)); - $this->assertFalse($sequence2->isAutoIncrementsFor($table)); - $this->assertFalse($sequence3->isAutoIncrementsFor($table)); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php deleted file mode 100755 index e2f52c478a..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php +++ /dev/null @@ -1,88 +0,0 @@ -. - */ - -namespace Doctrine\Tests\DBAL\Schema\Synchronizer; - -use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer; - -class SingleDatabaseSynchronizerTest extends \PHPUnit_Framework_TestCase -{ - private $conn; - private $synchronizer; - - public function setUp() - { - $this->conn = DriverManager::getConnection(array( - 'driver' => 'pdo_sqlite', - 'memory' => true, - )); - $this->synchronizer = new SingleDatabaseSynchronizer($this->conn); - } - - public function testGetCreateSchema() - { - $schema = new Schema(); - $table = $schema->createTable('test'); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - - $sql = $this->synchronizer->getCreateSchema($schema); - $this->assertEquals(array('CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'), $sql); - } - - public function testGetUpdateSchema() - { - $schema = new Schema(); - $table = $schema->createTable('test'); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - - $sql = $this->synchronizer->getUpdateSchema($schema); - $this->assertEquals(array('CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'), $sql); - } - - public function testGetDropSchema() - { - $schema = new Schema(); - $table = $schema->createTable('test'); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - - $this->synchronizer->createSchema($schema); - - $sql = $this->synchronizer->getDropSchema($schema); - $this->assertEquals(array('DROP TABLE test'), $sql); - } - - public function testGetDropAllSchema() - { - $schema = new Schema(); - $table = $schema->createTable('test'); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - - $this->synchronizer->createSchema($schema); - - $sql = $this->synchronizer->getDropAllSchema(); - $this->assertEquals(array('DROP TABLE test'), $sql); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php deleted file mode 100755 index 79f2205648..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php +++ /dev/null @@ -1,528 +0,0 @@ -setExpectedException('Doctrine\DBAL\DBALException'); - $table = new \Doctrine\DBAL\Schema\Table(''); - } - - public function testGetName() - { - $table = new Table("foo", array(), array(), array()); - $this->assertEquals("foo", $table->getName()); - } - - public function testColumns() - { - $type = Type::getType('integer'); - $columns = array(); - $columns[] = new Column("foo", $type); - $columns[] = new Column("bar", $type); - $table = new Table("foo", $columns, array(), array()); - - $this->assertTrue($table->hasColumn("foo")); - $this->assertTrue($table->hasColumn("bar")); - $this->assertFalse($table->hasColumn("baz")); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn("foo")); - $this->assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn("bar")); - - $this->assertEquals(2, count($table->getColumns())); - } - - public function testColumnsCaseInsensitive() - { - $table = new Table("foo"); - $column = $table->addColumn('Foo', 'integer'); - - $this->assertTrue($table->hasColumn('Foo')); - $this->assertTrue($table->hasColumn('foo')); - $this->assertTrue($table->hasColumn('FOO')); - - $this->assertSame($column, $table->getColumn('Foo')); - $this->assertSame($column, $table->getColumn('foo')); - $this->assertSame($column, $table->getColumn('FOO')); - } - - public function testCreateColumn() - { - $type = Type::getType('integer'); - - $table = new Table("foo"); - - $this->assertFalse($table->hasColumn("bar")); - $table->addColumn("bar", 'integer'); - $this->assertTrue($table->hasColumn("bar")); - $this->assertSame($type, $table->getColumn("bar")->getType()); - } - - public function testDropColumn() - { - $type = Type::getType('integer'); - $columns = array(); - $columns[] = new Column("foo", $type); - $columns[] = new Column("bar", $type); - $table = new Table("foo", $columns, array(), array()); - - $this->assertTrue($table->hasColumn("foo")); - $this->assertTrue($table->hasColumn("bar")); - - $table->dropColumn("foo")->dropColumn("bar"); - - $this->assertFalse($table->hasColumn("foo")); - $this->assertFalse($table->hasColumn("bar")); - } - - public function testGetUnknownColumnThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo", array(), array(), array()); - $table->getColumn('unknown'); - } - - public function testAddColumnTwiceThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(); - $columns[] = new Column("foo", $type); - $columns[] = new Column("foo", $type); - $table = new Table("foo", $columns, array(), array()); - } - - public function testCreateIndex() - { - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(new Column("foo", $type), new Column("bar", $type), new Column("baz", $type)); - $table = new Table("foo", $columns); - - $table->addIndex(array("foo", "bar"), "foo_foo_bar_idx"); - $table->addUniqueIndex(array("bar", "baz"), "foo_bar_baz_uniq"); - - $this->assertTrue($table->hasIndex("foo_foo_bar_idx")); - $this->assertTrue($table->hasIndex("foo_bar_baz_uniq")); - } - - public function testIndexCaseInsensitive() - { - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array( - new Column("foo", $type), - new Column("bar", $type), - new Column("baz", $type) - ); - $table = new Table("foo", $columns); - - $table->addIndex(array("foo", "bar", "baz"), "Foo_Idx"); - - $this->assertTrue($table->hasIndex('foo_idx')); - $this->assertTrue($table->hasIndex('Foo_Idx')); - $this->assertTrue($table->hasIndex('FOO_IDX')); - } - - public function testAddIndexes() - { - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array( - new Column("foo", $type), - new Column("bar", $type), - ); - $indexes = array( - new Index("the_primary", array("foo"), true, true), - new Index("bar_idx", array("bar"), false, false), - ); - $table = new Table("foo", $columns, $indexes, array()); - - $this->assertTrue($table->hasIndex("the_primary")); - $this->assertTrue($table->hasIndex("bar_idx")); - $this->assertFalse($table->hasIndex("some_idx")); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey()); - $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('the_primary')); - $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('bar_idx')); - } - - public function testGetUnknownIndexThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo", array(), array(), array()); - $table->getIndex("unknownIndex"); - } - - public function testAddTwoPrimaryThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(new Column("foo", $type), new Column("bar", $type)); - $indexes = array( - new Index("the_primary", array("foo"), true, true), - new Index("other_primary", array("bar"), true, true), - ); - $table = new Table("foo", $columns, $indexes, array()); - } - - public function testAddTwoIndexesWithSameNameThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(new Column("foo", $type), new Column("bar", $type)); - $indexes = array( - new Index("an_idx", array("foo"), false, false), - new Index("an_idx", array("bar"), false, false), - ); - $table = new Table("foo", $columns, $indexes, array()); - } - - public function testConstraints() - { - $constraint = new ForeignKeyConstraint(array(), "foo", array()); - - $tableA = new Table("foo", array(), array(), array($constraint)); - $constraints = $tableA->getForeignKeys(); - - $this->assertEquals(1, count($constraints)); - $this->assertSame($constraint, array_shift($constraints)); - } - - public function testOptions() - { - $table = new Table("foo", array(), array(), array(), false, array("foo" => "bar")); - - $this->assertTrue($table->hasOption("foo")); - $this->assertEquals("bar", $table->getOption("foo")); - } - - public function testBuilderSetPrimaryKey() - { - $table = new Table("foo"); - - $table->addColumn("bar", 'integer'); - $table->setPrimaryKey(array("bar")); - - $this->assertTrue($table->hasIndex("primary")); - $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey()); - $this->assertTrue($table->getIndex("primary")->isUnique()); - $this->assertTrue($table->getIndex("primary")->isPrimary()); - } - - public function testBuilderAddUniqueIndex() - { - $table = new Table("foo"); - - $table->addColumn("bar", 'integer'); - $table->addUniqueIndex(array("bar"), "my_idx"); - - $this->assertTrue($table->hasIndex("my_idx")); - $this->assertTrue($table->getIndex("my_idx")->isUnique()); - $this->assertFalse($table->getIndex("my_idx")->isPrimary()); - } - - public function testBuilderAddIndex() - { - $table = new Table("foo"); - - $table->addColumn("bar", 'integer'); - $table->addIndex(array("bar"), "my_idx"); - - $this->assertTrue($table->hasIndex("my_idx")); - $this->assertFalse($table->getIndex("my_idx")->isUnique()); - $this->assertFalse($table->getIndex("my_idx")->isPrimary()); - } - - public function testBuilderAddIndexWithInvalidNameThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo"); - $table->addColumn("bar",'integer'); - $table->addIndex(array("bar"), "invalid name %&/"); - } - - public function testBuilderAddIndexWithUnknownColumnThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo"); - $table->addIndex(array("bar"), "invalidName"); - } - - public function testBuilderOptions() - { - $table = new Table("foo"); - $table->addOption("foo", "bar"); - $this->assertTrue($table->hasOption("foo")); - $this->assertEquals("bar", $table->getOption("foo")); - } - - public function testAddForeignKeyConstraint_UnknownLocalColumn_ThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $foreignTable = new Table("bar"); - $foreignTable->addColumn("id", 'integer'); - - $table->addForeignKeyConstraint($foreignTable, array("foo"), array("id")); - } - - public function testAddForeignKeyConstraint_UnknownForeignColumn_ThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $foreignTable = new Table("bar"); - $foreignTable->addColumn("id", 'integer'); - - $table->addForeignKeyConstraint($foreignTable, array("id"), array("foo")); - } - - public function testAddForeignKeyConstraint() - { - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $foreignTable = new Table("bar"); - $foreignTable->addColumn("id", 'integer'); - - $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar")); - - $constraints = $table->getForeignKeys(); - $this->assertEquals(1, count($constraints)); - $constraint = current($constraints); - - $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $constraint); - - $this->assertTrue($constraint->hasOption("foo")); - $this->assertEquals("bar", $constraint->getOption("foo")); - } - - public function testAddIndexWithCaseSensitiveColumnProblem() - { - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $table->addIndex(array("ID"), "my_idx"); - - $this->assertTrue($table->hasIndex('my_idx')); - $this->assertEquals(array("ID"), $table->getIndex("my_idx")->getColumns()); - $this->assertTrue($table->getIndex('my_idx')->spansColumns(array('id'))); - } - - public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull() - { - $table = new Table("foo"); - $column = $table->addColumn("id", 'integer', array('notnull' => false)); - - $this->assertFalse($column->getNotnull()); - - $table->setPrimaryKey(array('id')); - - $this->assertTrue($column->getNotnull()); - } - - /** - * @group DDC-133 - */ - public function testAllowImplicitSchemaTableInAutogeneratedIndexNames() - { - $table = new Table("foo.bar"); - $table->addColumn('baz', 'integer', array()); - $table->addIndex(array('baz')); - - $this->assertEquals(1, count($table->getIndexes())); - } - - /** - * @group DBAL-50 - */ - public function testAddIndexTwice_IgnoreSecond() - { - $table = new Table("foo.bar"); - $table->addColumn('baz', 'integer', array()); - $table->addIndex(array('baz')); - $table->addIndex(array('baz')); - - $this->assertEquals(1, count($table->getIndexes())); - } - - /** - * @group DBAL-50 - */ - public function testAddForeignKeyIndexImplicitly() - { - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $foreignTable = new Table("bar"); - $foreignTable->addColumn("id", 'integer'); - - $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar")); - - $indexes = $table->getIndexes(); - $this->assertEquals(1, count($indexes)); - $index = current($indexes); - - $this->assertTrue($table->hasIndex($index->getName())); - $this->assertEquals(array('id'), $index->getColumns()); - } - - /** - * @group DBAL-50 - */ - public function testOverruleIndex() - { - $table = new Table("bar"); - $table->addColumn('baz', 'integer', array()); - $table->addIndex(array('baz')); - - $indexes = $table->getIndexes(); - $this->assertEquals(1, count($indexes)); - $index = current($indexes); - - $table->addUniqueIndex(array('baz')); - $this->assertEquals(1, count($table->getIndexes())); - $this->assertFalse($table->hasIndex($index->getName())); - } - - public function testPrimaryKeyOverrulesUniqueIndex() - { - $table = new Table("bar"); - $table->addColumn('baz', 'integer', array()); - $table->addUniqueIndex(array('baz')); - - $table->setPrimaryKey(array('baz')); - - $indexes = $table->getIndexes(); - $this->assertEquals(1, count($indexes), "Table should only contain the primary key table index, not the unique one anymore, because it was overruled."); - - $index = current($indexes); - $this->assertTrue($index->isPrimary()); - } - - /** - * @group DBAL-64 - */ - public function testQuotedTableName() - { - $table = new Table("`bar`"); - - $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform(); - $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform(); - - $this->assertEquals('bar', $table->getName()); - $this->assertEquals('`bar`', $table->getQuotedName($mysqlPlatform)); - $this->assertEquals('"bar"', $table->getQuotedName($sqlitePlatform)); - } - - /** - * @group DBAL-79 - */ - public function testTableHasPrimaryKey() - { - $table = new Table("test"); - - $this->assertFalse($table->hasPrimaryKey()); - - $table->addColumn("foo", "integer"); - $table->setPrimaryKey(array("foo")); - - $this->assertTrue($table->hasPrimaryKey()); - } - - /** - * @group DBAL-91 - */ - public function testAddIndexWithQuotedColumns() - { - $table = new Table("test"); - $table->addColumn('"foo"', 'integer'); - $table->addColumn('bar', 'integer'); - $table->addIndex(array('"foo"', '"bar"')); - } - - /** - * @group DBAL-91 - */ - public function testAddForeignKeyWithQuotedColumnsAndTable() - { - $table = new Table("test"); - $table->addColumn('"foo"', 'integer'); - $table->addColumn('bar', 'integer'); - $table->addForeignKeyConstraint('"boing"', array('"foo"', '"bar"'), array("id")); - } - - /** - * @group DBAL-177 - */ - public function testQuoteSchemaPrefixed() - { - $table = new Table("`test`.`test`"); - $this->assertEquals("test.test", $table->getName()); - $this->assertEquals("`test`.`test`", $table->getQuotedName(new \Doctrine\DBAL\Platforms\MySqlPlatform)); - } - - /** - * @group DBAL-204 - */ - public function testFullQualifiedTableName() - { - $table = new Table("`test`.`test`"); - $this->assertEquals('test.test', $table->getFullQualifiedName("test")); - $this->assertEquals('test.test', $table->getFullQualifiedName("other")); - - $table = new Table("test"); - $this->assertEquals('test.test', $table->getFullQualifiedName("test")); - $this->assertEquals('other.test', $table->getFullQualifiedName("other")); - } - - /** - * @group DBAL-224 - */ - public function testDropIndex() - { - $table = new Table("test"); - $table->addColumn('id', 'integer'); - $table->addIndex(array('id'), 'idx'); - - $this->assertTrue($table->hasIndex('idx')); - - $table->dropIndex('idx'); - $this->assertFalse($table->hasIndex('idx')); - } - - /** - * @group DBAL-224 - */ - public function testDropPrimaryKey() - { - $table = new Table("test"); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - - $this->assertTrue($table->hasPrimaryKey()); - - $table->dropPrimaryKey(); - $this->assertFalse($table->hasPrimaryKey()); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php deleted file mode 100755 index e5b660f6b6..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php +++ /dev/null @@ -1,77 +0,0 @@ -setName("test"); - $schema = new Schema(array(), array(), $config); - - $schema->createTable("test.test"); - $schema->createTable("foo.bar"); - $schema->createTable("baz"); - - $schema->visit(new RemoveNamespacedAssets()); - - $tables = $schema->getTables(); - $this->assertEquals(array("test.test", "test.baz"), array_keys($tables), "Only 2 tables should be present, both in 'test' namespace."); - } - - /** - * @group DBAL-204 - */ - public function testCleanupForeignKeys() - { - $config = new SchemaConfig; - $config->setName("test"); - $schema = new Schema(array(), array(), $config); - - $fooTable = $schema->createTable("foo.bar"); - $fooTable->addColumn('id', 'integer'); - - $testTable = $schema->createTable("test.test"); - $testTable->addColumn('id', 'integer'); - - $testTable->addForeignKeyConstraint("foo.bar", array("id"), array("id")); - - $schema->visit(new RemoveNamespacedAssets()); - - $sql = $schema->toSql(new MySqlPlatform()); - $this->assertEquals(1, count($sql), "Just one CREATE TABLE statement, no foreign key and table to foo.bar"); - } - - /** - * @group DBAL-204 - */ - public function testCleanupForeignKeysDifferentOrder() - { - $config = new SchemaConfig; - $config->setName("test"); - $schema = new Schema(array(), array(), $config); - - $testTable = $schema->createTable("test.test"); - $testTable->addColumn('id', 'integer'); - - $fooTable = $schema->createTable("foo.bar"); - $fooTable->addColumn('id', 'integer'); - - $testTable->addForeignKeyConstraint("foo.bar", array("id"), array("id")); - - $schema->visit(new RemoveNamespacedAssets()); - - $sql = $schema->toSql(new MySqlPlatform()); - $this->assertEquals(1, count($sql), "Just one CREATE TABLE statement, no foreign key and table to foo.bar"); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php deleted file mode 100755 index 8dfd2b2694..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php +++ /dev/null @@ -1,80 +0,0 @@ -getMock( - 'Doctrine\DBAL\Platforms\MySqlPlatform', - array('getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql') - ); - $platformMock->expects($this->exactly(2)) - ->method('getCreateTableSql') - ->will($this->returnValue(array("foo"))); - $platformMock->expects($this->exactly(1)) - ->method('getCreateSequenceSql') - ->will($this->returnValue(array("bar"))); - $platformMock->expects($this->exactly(1)) - ->method('getCreateForeignKeySql') - ->will($this->returnValue(array("baz"))); - - $schema = $this->createFixtureSchema(); - - $sql = $schema->toSql($platformMock); - - $this->assertEquals(array("foo", "foo", "bar", "baz"), $sql); - } - - public function testDropSchema() - { - $platformMock = $this->getMock( - 'Doctrine\DBAL\Platforms\MySqlPlatform', - array('getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql') - ); - $platformMock->expects($this->exactly(2)) - ->method('getDropTableSql') - ->will($this->returnValue("tbl")); - $platformMock->expects($this->exactly(1)) - ->method('getDropSequenceSql') - ->will($this->returnValue("seq")); - $platformMock->expects($this->exactly(1)) - ->method('getDropForeignKeySql') - ->will($this->returnValue("fk")); - - $schema = $this->createFixtureSchema(); - - $sql = $schema->toDropSql($platformMock); - - $this->assertEquals(array("fk", "seq", "tbl", "tbl"), $sql); - } - - /** - * @return Schema - */ - public function createFixtureSchema() - { - $schema = new Schema(); - $tableA = $schema->createTable("foo"); - $tableA->addColumn("id", 'integer'); - $tableA->addColumn("bar", 'string', array('length' => 255)); - $tableA->setPrimaryKey(array("id")); - - $schema->createSequence("foo_seq"); - - $tableB = $schema->createTable("bar"); - $tableB->addColumn("id", 'integer'); - $tableB->setPrimaryKey(array("id")); - - $tableA->addForeignKeyConstraint($tableB, array("bar"), array("id")); - - return $schema; - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php deleted file mode 100755 index 59259fd81c..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php +++ /dev/null @@ -1,182 +0,0 @@ -. - */ - -namespace Doctrine\Tests\DBAL\Sharding; - -use Doctrine\DBAL\DriverManager; - -class PoolingShardConnectionTest extends \PHPUnit_Framework_TestCase -{ - public function testConnect() - { - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'global' => array('memory' => true), - 'shards' => array( - array('id' => 1, 'memory' => true), - array('id' => 2, 'memory' => true), - ), - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', - )); - - $this->assertFalse($conn->isConnected(0)); - $conn->connect(0); - $this->assertEquals(1, $conn->fetchColumn('SELECT 1')); - $this->assertTrue($conn->isConnected(0)); - - $this->assertFalse($conn->isConnected(1)); - $conn->connect(1); - $this->assertEquals(1, $conn->fetchColumn('SELECT 1')); - $this->assertTrue($conn->isConnected(1)); - - $this->assertFalse($conn->isConnected(2)); - $conn->connect(2); - $this->assertEquals(1, $conn->fetchColumn('SELECT 1')); - $this->assertTrue($conn->isConnected(2)); - - $conn->close(); - $this->assertFalse($conn->isConnected(0)); - $this->assertFalse($conn->isConnected(1)); - $this->assertFalse($conn->isConnected(2)); - } - - public function testNoGlobalServerException() - { - $this->setExpectedException('InvalidArgumentException', "Connection Parameters require 'global' and 'shards' configurations."); - - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'shards' => array( - array('id' => 1, 'memory' => true), - array('id' => 2, 'memory' => true), - ), - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', - )); - } - - public function testNoShardsServersExecption() - { - $this->setExpectedException('InvalidArgumentException', "Connection Parameters require 'global' and 'shards' configurations."); - - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'global' => array('memory' => true), - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', - )); - } - - public function testNoShardsChoserExecption() - { - $this->setExpectedException('InvalidArgumentException', "Missing Shard Choser configuration 'shardChoser'"); - - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'global' => array('memory' => true), - 'shards' => array( - array('id' => 1, 'memory' => true), - array('id' => 2, 'memory' => true), - ), - )); - } - - public function testShardChoserWrongInstance() - { - $this->setExpectedException('InvalidArgumentException', "The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser"); - - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'global' => array('memory' => true), - 'shards' => array( - array('id' => 1, 'memory' => true), - array('id' => 2, 'memory' => true), - ), - 'shardChoser' => new \stdClass, - )); - } - - public function testShardNonNumericId() - { - $this->setExpectedException('InvalidArgumentException', "Shard Id has to be a non-negative number."); - - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'global' => array('memory' => true), - 'shards' => array( - array('id' => 'foo', 'memory' => true), - ), - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', - )); - } - - public function testShardMissingId() - { - $this->setExpectedException('InvalidArgumentException', "Missing 'id' for one configured shard. Please specificy a unique shard-id."); - - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'global' => array('memory' => true), - 'shards' => array( - array('memory' => true), - ), - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', - )); - } - - public function testDuplicateShardId() - { - $this->setExpectedException('InvalidArgumentException', "Shard 1 is duplicated in the configuration."); - - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'global' => array('memory' => true), - 'shards' => array( - array('id' => 1, 'memory' => true), - array('id' => 1, 'memory' => true), - ), - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', - )); - } - - public function testSwitchShardWithOpenTransactionException() - { - $conn = DriverManager::getConnection(array( - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', - 'driver' => 'pdo_sqlite', - 'global' => array('memory' => true), - 'shards' => array( - array('id' => 1, 'memory' => true), - ), - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', - )); - - $conn->beginTransaction(); - - $this->setExpectedException('Doctrine\DBAL\Sharding\ShardingException', 'Cannot switch shard when transaction is active.'); - $conn->connect(1); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php deleted file mode 100755 index 002f9f0e23..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php +++ /dev/null @@ -1,108 +0,0 @@ -. - */ -namespace Doctrine\Tests\DBAL\Sharding; - -use Doctrine\DBAL\Sharding\PoolingShardManager; - -class PoolingShardManagerTest extends \PHPUnit_Framework_TestCase -{ - private function createConnectionMock() - { - return $this->getMock('Doctrine\DBAL\Sharding\PoolingShardConnection', array('connect', 'getParams', 'fetchAll'), array(), '', false); - } - - private function createPassthroughShardChoser() - { - $mock = $this->getMock('Doctrine\DBAL\Sharding\ShardChoser\ShardChoser'); - $mock->expects($this->any()) - ->method('pickShard') - ->will($this->returnCallback(function($value) { return $value; })); - return $mock; - } - - public function testSelectGlobal() - { - $conn = $this->createConnectionMock(); - $conn->expects($this->once())->method('connect')->with($this->equalTo(0)); - - $shardManager = new PoolingShardManager($conn, $this->createPassthroughShardChoser()); - $shardManager->selectGlobal(); - - $this->assertNull($shardManager->getCurrentDistributionValue()); - } - - public function testSelectShard() - { - $shardId = 10; - $conn = $this->createConnectionMock(); - $conn->expects($this->at(0))->method('getParams')->will($this->returnValue(array('shardChoser' => $this->createPassthroughShardChoser()))); - $conn->expects($this->at(1))->method('connect')->with($this->equalTo($shardId)); - - $shardManager = new PoolingShardManager($conn); - $shardManager->selectShard($shardId); - - $this->assertEquals($shardId, $shardManager->getCurrentDistributionValue()); - } - - public function testGetShards() - { - $conn = $this->createConnectionMock(); - $conn->expects($this->any())->method('getParams')->will( - $this->returnValue( - array('shards' => array( array('id' => 1), array('id' => 2) ), 'shardChoser' => $this->createPassthroughShardChoser()) - ) - ); - - $shardManager = new PoolingShardManager($conn, $this->createPassthroughShardChoser()); - $shards = $shardManager->getShards(); - - $this->assertEquals(array(array('id' => 1), array('id' => 2)), $shards); - } - - public function testQueryAll() - { - $sql = "SELECT * FROM table"; - $params = array(1); - $types = array(1); - - $conn = $this->createConnectionMock(); - $conn->expects($this->at(0))->method('getParams')->will($this->returnValue( - array('shards' => array( array('id' => 1), array('id' => 2) ), 'shardChoser' => $this->createPassthroughShardChoser()) - )); - $conn->expects($this->at(1))->method('getParams')->will($this->returnValue( - array('shards' => array( array('id' => 1), array('id' => 2) ), 'shardChoser' => $this->createPassthroughShardChoser()) - )); - $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); - $conn->expects($this->at(3)) - ->method('fetchAll') - ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue(array( array('id' => 1) ) )); - $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); - $conn->expects($this->at(5)) - ->method('fetchAll') - ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue(array( array('id' => 2) ) )); - - $shardManager = new PoolingShardManager($conn, $this->createPassthroughShardChoser()); - $result = $shardManager->queryAll($sql, $params, $types); - - $this->assertEquals(array(array('id' => 1), array('id' => 2)), $result); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php deleted file mode 100755 index ccf185c509..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php +++ /dev/null @@ -1,82 +0,0 @@ -markTestSkipped('No driver or sqlserver driver specified.'); - } - - $params = array( - 'driver' => $GLOBALS['db_type'], - 'dbname' => $GLOBALS['db_name'], - 'user' => $GLOBALS['db_username'], - 'password' => $GLOBALS['db_password'], - 'host' => $GLOBALS['db_host'], - 'sharding' => array( - 'federationName' => 'Orders_Federation', - 'distributionKey' => 'CustID', - 'distributionType' => 'integer', - 'filteringEnabled' => false, - ), - 'driverOptions' => array('MultipleActiveResultSets' => false) - ); - $this->conn = DriverManager::getConnection($params); - // assume database is created and schema is: - // Global products table - // Customers, Orders, OrderItems federation tables. - // See http://cloud.dzone.com/articles/using-sql-azure-federations - $this->sm = new SQLAzureShardManager($this->conn); - } - - public function createShopSchema() - { - $schema = new Schema(); - - $products = $schema->createTable('Products'); - $products->addColumn('ProductID', 'integer'); - $products->addColumn('SupplierID', 'integer'); - $products->addColumn('ProductName', 'string'); - $products->addColumn('Price', 'decimal', array('scale' => 2, 'precision' => 12)); - $products->setPrimaryKey(array('ProductID')); - $products->addOption('azure.federated', true); - - $customers = $schema->createTable('Customers'); - $customers->addColumn('CustomerID', 'integer'); - $customers->addColumn('CompanyName', 'string'); - $customers->addColumn('FirstName', 'string'); - $customers->addColumn('LastName', 'string'); - $customers->setPrimaryKey(array('CustomerID')); - $customers->addOption('azure.federated', true); - $customers->addOption('azure.federatedOnColumnName', 'CustomerID'); - - $orders = $schema->createTable('Orders'); - $orders->addColumn('CustomerID', 'integer'); - $orders->addColumn('OrderID', 'integer'); - $orders->addColumn('OrderDate', 'datetime'); - $orders->setPrimaryKey(array('CustomerID', 'OrderID')); - $orders->addOption('azure.federated', true); - $orders->addOption('azure.federatedOnColumnName', 'CustomerID'); - - $orderItems = $schema->createTable('OrderItems'); - $orderItems->addColumn('CustomerID', 'integer'); - $orderItems->addColumn('OrderID', 'integer'); - $orderItems->addColumn('ProductID', 'integer'); - $orderItems->addColumn('Quantity', 'integer'); - $orderItems->setPrimaryKey(array('CustomerID', 'OrderID', 'ProductID')); - $orderItems->addOption('azure.federated', true); - $orderItems->addOption('azure.federatedOnColumnName', 'CustomerID'); - - return $schema; - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php deleted file mode 100755 index 1051efb5dc..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php +++ /dev/null @@ -1,44 +0,0 @@ -createShopSchema(); - - $synchronizer = new SQLAzureSchemaSynchronizer($this->conn, $this->sm); - $synchronizer->dropAllSchema(); - $synchronizer->createSchema($schema); - - $this->sm->selectShard(0); - - $this->conn->insert("Products", array( - "ProductID" => 1, - "SupplierID" => 2, - "ProductName" => "Test", - "Price" => 10.45 - )); - - $this->conn->insert("Customers", array( - "CustomerID" => 1, - "CompanyName" => "Foo", - "FirstName" => "Benjamin", - "LastName" => "E.", - )); - - $query = "SELECT * FROM Products"; - $data = $this->conn->fetchAll($query); - $this->assertTrue(count($data) > 0); - - $query = "SELECT * FROM Customers"; - $data = $this->conn->fetchAll($query); - $this->assertTrue(count($data) > 0); - - $data = $this->sm->queryAll("SELECT * FROM Customers"); - $this->assertTrue(count($data) > 0); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php deleted file mode 100755 index 7eb038fc4c..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -namespace Doctrine\Tests\DBAL\Sharding\SQLAzure; - -use Doctrine\DBAL\Platforms\SQLAzurePlatform; -use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Sharding\SQLAzure\Schema\MultiTenantVisitor; - -class MultiTenantVisitorTest extends \PHPUnit_Framework_TestCase -{ - public function testMultiTenantPrimaryKey() - { - $platform = new SQLAzurePlatform(); - $visitor = new MultiTenantVisitor(); - - $schema = new Schema(); - $foo = $schema->createTable('foo'); - $foo->addColumn('id', 'string'); - $foo->setPrimaryKey(array('id')); - $schema->visit($visitor); - - $this->assertEquals(array('id', 'tenant_id'), $foo->getPrimaryKey()->getColumns()); - $this->assertTrue($foo->hasColumn('tenant_id')); - } - - public function testMultiTenantNonPrimaryKey() - { - $platform = new SQLAzurePlatform(); - $visitor = new MultiTenantVisitor(); - - $schema = new Schema(); - $foo = $schema->createTable('foo'); - $foo->addColumn('id', 'string'); - $foo->addColumn('created', 'datetime'); - $foo->setPrimaryKey(array('id')); - $foo->addIndex(array('created'), 'idx'); - - $foo->getPrimaryKey()->addFlag('nonclustered'); - $foo->getIndex('idx')->addFlag('clustered'); - - $schema->visit($visitor); - - $this->assertEquals(array('id'), $foo->getPrimaryKey()->getColumns()); - $this->assertTrue($foo->hasColumn('tenant_id')); - $this->assertEquals(array('created', 'tenant_id'), $foo->getIndex('idx')->getColumns()); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php deleted file mode 100755 index 091a3636fe..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php +++ /dev/null @@ -1,50 +0,0 @@ -createShopSchema(); - - $synchronizer = new SQLAzureFederationsSynchronizer($this->conn, $this->sm); - $sql = $synchronizer->getCreateSchema($schema); - - $this->assertEquals(array ( - "--Create Federation\nCREATE FEDERATION Orders_Federation (CustID INT RANGE)", - "USE FEDERATION Orders_Federation (CustID = 0) WITH RESET, FILTERING = OFF;", - "CREATE TABLE Products (ProductID INT NOT NULL, SupplierID INT NOT NULL, ProductName NVARCHAR(255) NOT NULL, Price NUMERIC(12, 2) NOT NULL, PRIMARY KEY (ProductID))", - "CREATE TABLE Customers (CustomerID INT NOT NULL, CompanyName NVARCHAR(255) NOT NULL, FirstName NVARCHAR(255) NOT NULL, LastName NVARCHAR(255) NOT NULL, PRIMARY KEY (CustomerID))", - "CREATE TABLE Orders (CustomerID INT NOT NULL, OrderID INT NOT NULL, OrderDate DATETIME2(6) NOT NULL, PRIMARY KEY (CustomerID, OrderID))", - "CREATE TABLE OrderItems (CustomerID INT NOT NULL, OrderID INT NOT NULL, ProductID INT NOT NULL, Quantity INT NOT NULL, PRIMARY KEY (CustomerID, OrderID, ProductID))", - ), $sql); - } - - public function testUpdateSchema() - { - $schema = $this->createShopSchema(); - - $synchronizer = new SQLAzureFederationsSynchronizer($this->conn, $this->sm); - $synchronizer->dropAllSchema(); - - $sql = $synchronizer->getUpdateSchema($schema); - - $this->assertEquals(array(), $sql); - } - - public function testDropSchema() - { - $schema = $this->createShopSchema(); - - $synchronizer = new SQLAzureFederationsSynchronizer($this->conn, $this->sm); - $synchronizer->dropAllSchema(); - $synchronizer->createSchema($schema); - $sql = $synchronizer->getDropSchema($schema); - - $this->assertEQuals(5, count($sql)); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php deleted file mode 100755 index f73e494081..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php +++ /dev/null @@ -1,93 +0,0 @@ -setExpectedException('Doctrine\DBAL\Sharding\ShardingException', 'SQLAzure requires a federation name to be set during sharding configuration.'); - - $conn = $this->createConnection(array('sharding' => array('distributionKey' => 'abc', 'distributionType' => 'integer'))); - $sm = new SQLAzureShardManager($conn); - } - - public function testNoDistributionKey() - { - $this->setExpectedException('Doctrine\DBAL\Sharding\ShardingException', 'SQLAzure requires a distribution key to be set during sharding configuration.'); - - $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionType' => 'integer'))); - $sm = new SQLAzureShardManager($conn); - } - - public function testNoDistributionType() - { - $this->setExpectedException('Doctrine\DBAL\Sharding\ShardingException'); - - $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo'))); - $sm = new SQLAzureShardManager($conn); - } - - public function testGetDefaultDistributionValue() - { - $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer'))); - - $sm = new SQLAzureShardManager($conn); - $this->assertNull($sm->getCurrentDistributionValue()); - } - - public function testSelectGlobalTransactionActive() - { - $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer'))); - $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true)); - - $this->setExpectedException('Doctrine\DBAL\Sharding\ShardingException', 'Cannot switch shard during an active transaction.'); - - $sm = new SQLAzureShardManager($conn); - $sm->selectGlobal(); - } - - public function testSelectGlobal() - { - $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer'))); - $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(false)); - $conn->expects($this->at(2))->method('exec')->with($this->equalTo('USE FEDERATION ROOT WITH RESET')); - - $sm = new SQLAzureShardManager($conn); - $sm->selectGlobal(); - } - - public function testSelectShard() - { - $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer'))); - $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true)); - - $this->setExpectedException('Doctrine\DBAL\Sharding\ShardingException', 'Cannot switch shard during an active transaction.'); - - $sm = new SQLAzureShardManager($conn); - $sm->selectShard(1234); - - $this->assertEquals(1234, $sm->getCurrentDistributionValue()); - } - - public function testSelectShardNoDistriubtionValue() - { - $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer'))); - $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(false)); - - $this->setExpectedException('Doctrine\DBAL\Sharding\ShardingException', 'You have to specify a string or integer as shard distribution value.'); - - $sm = new SQLAzureShardManager($conn); - $sm->selectShard(null); - } - - private function createConnection(array $params) - { - $conn = $this->getMock('Doctrine\DBAL\Connection', array('getParams', 'exec', 'isTransactionActive'), array(), '', false); - $conn->expects($this->at(0))->method('getParams')->will($this->returnValue($params)); - return $conn; - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php deleted file mode 100755 index 4e06f8d451..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -namespace Doctrine\Tests\DBAL\Sharding\ShardChoser; - -use Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser; - -class MultiTenantShardChoserTest extends \PHPUnit_Framework_TestCase -{ - public function testPickShard() - { - $choser = new MultiTenantShardChoser(); - $conn = $this->createConnectionMock(); - - $this->assertEquals(1, $choser->pickShard(1, $conn)); - $this->assertEquals(2, $choser->pickShard(2, $conn)); - } - - private function createConnectionMock() - { - return $this->getMock('Doctrine\DBAL\Sharding\PoolingShardConnection', array('connect', 'getParams', 'fetchAll'), array(), '', false); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php deleted file mode 100755 index ac4244d950..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php +++ /dev/null @@ -1,61 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('array'); - } - - public function tearDown() - { - error_reporting(-1); // reactive all error levels - } - - - public function testArrayConvertsToDatabaseValue() - { - $this->assertTrue( - is_string($this->_type->convertToDatabaseValue(array(), $this->_platform)) - ); - } - - public function testArrayConvertsToPHPValue() - { - $this->assertTrue( - is_array($this->_type->convertToPHPValue(serialize(array()), $this->_platform)) - ); - } - - public function testConversionFailure() - { - error_reporting( (E_ALL | E_STRICT) - \E_NOTICE ); - $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); - $this->_type->convertToPHPValue('abcdefg', $this->_platform); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - /** - * @group DBAL-73 - */ - public function testFalseConversion() - { - $this->assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BlobTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BlobTest.php deleted file mode 100755 index 756487ddb7..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BlobTest.php +++ /dev/null @@ -1,26 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('blob'); - } - - public function testBlobNullConvertsToPHPValue() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php deleted file mode 100755 index 753cfb46dd..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php +++ /dev/null @@ -1,36 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('boolean'); - } - - public function testBooleanConvertsToDatabaseValue() - { - $this->assertInternalType('integer', $this->_type->convertToDatabaseValue(1, $this->_platform)); - } - - public function testBooleanConvertsToPHPValue() - { - $this->assertInternalType('bool', $this->_type->convertToPHPValue(0, $this->_platform)); - } - - public function testBooleanNullConvertsToPHPValue() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTest.php deleted file mode 100755 index e3763fd81b..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTest.php +++ /dev/null @@ -1,81 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('date'); - $this->_tz = date_default_timezone_get(); - } - - public function tearDown() - { - date_default_timezone_set($this->_tz); - } - - public function testDateConvertsToDatabaseValue() - { - $this->assertTrue( - is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform)) - ); - } - - public function testDateConvertsToPHPValue() - { - // Birthday of jwage and also birthday of Doctrine. Send him a present ;) - $this->assertTrue( - $this->_type->convertToPHPValue('1985-09-01', $this->_platform) - instanceof \DateTime - ); - } - - public function testDateResetsNonDatePartsToZeroUnixTimeValues() - { - $date = $this->_type->convertToPHPValue('1985-09-01', $this->_platform); - - $this->assertEquals('00:00:00', $date->format('H:i:s')); - } - - public function testDateRests_SummerTimeAffection() - { - date_default_timezone_set('Europe/Berlin'); - - $date = $this->_type->convertToPHPValue('2009-08-01', $this->_platform); - $this->assertEquals('00:00:00', $date->format('H:i:s')); - $this->assertEquals('2009-08-01', $date->format('Y-m-d')); - - $date = $this->_type->convertToPHPValue('2009-11-01', $this->_platform); - $this->assertEquals('00:00:00', $date->format('H:i:s')); - $this->assertEquals('2009-11-01', $date->format('Y-m-d')); - } - - public function testInvalidDateFormatConversion() - { - $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); - $this->_type->convertToPHPValue('abcdefg', $this->_platform); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - public function testConvertDateTimeToPHPValue() - { - $date = new \DateTime("now"); - $this->assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php deleted file mode 100755 index 58129d2165..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php +++ /dev/null @@ -1,56 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('datetime'); - } - - public function testDateTimeConvertsToDatabaseValue() - { - $date = new \DateTime('1985-09-01 10:10:10'); - - $expected = $date->format($this->_platform->getDateTimeTzFormatString()); - $actual = $this->_type->convertToDatabaseValue($date, $this->_platform); - - $this->assertEquals($expected, $actual); - } - - public function testDateTimeConvertsToPHPValue() - { - // Birthday of jwage and also birthday of Doctrine. Send him a present ;) - $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00', $this->_platform); - $this->assertInstanceOf('DateTime', $date); - $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); - } - - public function testInvalidDateTimeFormatConversion() - { - $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); - $this->_type->convertToPHPValue('abcdefg', $this->_platform); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - public function testConvertDateTimeToPHPValue() - { - $date = new \DateTime("now"); - $this->assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php deleted file mode 100755 index 08c250a702..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php +++ /dev/null @@ -1,56 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('datetimetz'); - } - - public function testDateTimeConvertsToDatabaseValue() - { - $date = new \DateTime('1985-09-01 10:10:10'); - - $expected = $date->format($this->_platform->getDateTimeTzFormatString()); - $actual = $this->_type->convertToDatabaseValue($date, $this->_platform); - - $this->assertEquals($expected, $actual); - } - - public function testDateTimeConvertsToPHPValue() - { - // Birthday of jwage and also birthday of Doctrine. Send him a present ;) - $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00', $this->_platform); - $this->assertInstanceOf('DateTime', $date); - $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); - } - - public function testInvalidDateFormatConversion() - { - $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); - $this->_type->convertToPHPValue('abcdefg', $this->_platform); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - public function testConvertDateTimeToPHPValue() - { - $date = new \DateTime("now"); - $this->assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php deleted file mode 100755 index 983029c1aa..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php +++ /dev/null @@ -1,31 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('decimal'); - } - - public function testDecimalConvertsToPHPValue() - { - $this->assertInternalType('string', $this->_type->convertToPHPValue('5.5', $this->_platform)); - } - - public function testDecimalNullConvertsToPHPValue() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/FloatTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/FloatTest.php deleted file mode 100755 index 38d923751f..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/FloatTest.php +++ /dev/null @@ -1,39 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('float'); - } - - public function testFloatConvertsToPHPValue() - { - $this->assertInternalType('float', $this->_type->convertToPHPValue('5.5', $this->_platform)); - } - - public function testFloatNullConvertsToPHPValue() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - public function testFloatConvertToDatabaseValue() - { - $this->assertInternalType('float', $this->_type->convertToDatabaseValue(5.5, $this->_platform)); - } - - public function testFloatNullConvertToDatabaseValue() - { - $this->assertNull($this->_type->convertToDatabaseValue(null, $this->_platform)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php deleted file mode 100755 index 0f61183941..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php +++ /dev/null @@ -1,31 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('guid'); - } - - public function testConvertToPHPValue() - { - $this->assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform)); - $this->assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform)); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } -} - diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php deleted file mode 100755 index adcde5362a..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php +++ /dev/null @@ -1,32 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('integer'); - } - - public function testIntegerConvertsToPHPValue() - { - $this->assertInternalType('integer', $this->_type->convertToPHPValue('1', $this->_platform)); - $this->assertInternalType('integer', $this->_type->convertToPHPValue('0', $this->_platform)); - } - - public function testIntegerNullConvertsToPHPValue() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php deleted file mode 100755 index d25c49ae03..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php +++ /dev/null @@ -1,56 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('object'); - } - - public function tearDown() - { - error_reporting(-1); // reactive all error levels - } - - public function testObjectConvertsToDatabaseValue() - { - $this->assertInternalType('string', $this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform)); - } - - public function testObjectConvertsToPHPValue() - { - $this->assertInternalType('object', $this->_type->convertToPHPValue(serialize(new \stdClass), $this->_platform)); - } - - public function testConversionFailure() - { - error_reporting( (E_ALL | E_STRICT) - \E_NOTICE ); - $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); - $this->_type->convertToPHPValue('abcdefg', $this->_platform); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - /** - * @group DBAL-73 - */ - public function testFalseConversion() - { - $this->assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php deleted file mode 100755 index 399095cbb1..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php +++ /dev/null @@ -1,32 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('smallint'); - } - - public function testSmallIntConvertsToPHPValue() - { - $this->assertInternalType('integer', $this->_type->convertToPHPValue('1', $this->_platform)); - $this->assertInternalType('integer', $this->_type->convertToPHPValue('0', $this->_platform)); - } - - public function testSmallIntNullConvertsToPHPValue() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/StringTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/StringTest.php deleted file mode 100755 index 52d2955b0e..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/StringTest.php +++ /dev/null @@ -1,49 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('string'); - } - - public function testReturnsSqlDeclarationFromPlatformVarchar() - { - $this->assertEquals("DUMMYVARCHAR()", $this->_type->getSqlDeclaration(array(), $this->_platform)); - } - - public function testReturnsDefaultLengthFromPlatformVarchar() - { - $this->assertEquals(255, $this->_type->getDefaultLength($this->_platform)); - } - - public function testConvertToPHPValue() - { - $this->assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform)); - $this->assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform)); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - public function testSQLConversion() - { - $this->assertFalse($this->_type->canRequireSQLConversion(), "String type can never require SQL conversion to work."); - $this->assertEquals('t.foo', $this->_type->convertToDatabaseValueSQL('t.foo', $this->_platform)); - $this->assertEquals('t.foo', $this->_type->convertToPHPValueSQL('t.foo', $this->_platform)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php deleted file mode 100755 index 8a07b9b922..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php +++ /dev/null @@ -1,53 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('time'); - } - - public function testTimeConvertsToDatabaseValue() - { - $this->assertTrue( - is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform)) - ); - } - - public function testTimeConvertsToPHPValue() - { - $this->assertTrue( - $this->_type->convertToPHPValue('5:30:55', $this->_platform) - instanceof \DateTime - ); - } - - public function testInvalidTimeFormatConversion() - { - $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); - $this->_type->convertToPHPValue('abcdefg', $this->_platform); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - public function testConvertDateTimeToPHPValue() - { - $date = new \DateTime("now"); - $this->assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php deleted file mode 100755 index 329ef8cca5..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php +++ /dev/null @@ -1,68 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - if (!Type::hasType('vardatetime')) { - Type::addType('vardatetime', 'Doctrine\DBAL\Types\VarDateTimeType'); - } - $this->_type = Type::getType('vardatetime'); - } - - public function testDateTimeConvertsToDatabaseValue() - { - $date = new \DateTime('1985-09-01 10:10:10'); - - $expected = $date->format($this->_platform->getDateTimeTzFormatString()); - $actual = $this->_type->convertToDatabaseValue($date, $this->_platform); - - $this->assertEquals($expected, $actual); - } - - public function testDateTimeConvertsToPHPValue() - { - // Birthday of jwage and also birthday of Doctrine. Send him a present ;) - $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00', $this->_platform); - $this->assertInstanceOf('DateTime', $date); - $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); - $this->assertEquals('000000', $date->format('u')); - } - - public function testInvalidDateTimeFormatConversion() - { - $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); - $this->_type->convertToPHPValue('abcdefg', $this->_platform); - } - - public function testConversionWithMicroseconds() - { - $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00.123456', $this->_platform); - $this->assertInstanceOf('DateTime', $date); - $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); - $this->assertEquals('123456', $date->format('u')); - } - - public function testNullConversion() - { - $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); - } - - public function testConvertDateTimeToPHPValue() - { - $date = new \DateTime("now"); - $this->assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform)); - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/UtilTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/UtilTest.php deleted file mode 100755 index b793e35700..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/UtilTest.php +++ /dev/null @@ -1,78 +0,0 @@ - ':param1') - ), - array( - 'SELECT name FROM users WHERE id = ? AND status = ?', - 'SELECT name FROM users WHERE id = :param1 AND status = :param2', - array(1 => ':param1', 2 => ':param2'), - ), - array( - "UPDATE users SET name = '???', status = ?", - "UPDATE users SET name = '???', status = :param1", - array(1 => ':param1'), - ), - array( - "UPDATE users SET status = ?, name = '???'", - "UPDATE users SET status = :param1, name = '???'", - array(1 => ':param1'), - ), - array( - "UPDATE users SET foo = ?, name = '???', status = ?", - "UPDATE users SET foo = :param1, name = '???', status = :param2", - array(1 => ':param1', 2 => ':param2'), - ), - array( - 'UPDATE users SET name = "???", status = ?', - 'UPDATE users SET name = "???", status = :param1', - array(1 => ':param1'), - ), - array( - 'UPDATE users SET status = ?, name = "???"', - 'UPDATE users SET status = :param1, name = "???"', - array(1 => ':param1'), - ), - array( - 'UPDATE users SET foo = ?, name = "???", status = ?', - 'UPDATE users SET foo = :param1, name = "???", status = :param2', - array(1 => ':param1', 2 => ':param2'), - ), - array( - 'SELECT * FROM users WHERE id = ? AND name = "" AND status = ?', - 'SELECT * FROM users WHERE id = :param1 AND name = "" AND status = :param2', - array(1 => ':param1', 2 => ':param2'), - ), - array( - "SELECT * FROM users WHERE id = ? AND name = '' AND status = ?", - "SELECT * FROM users WHERE id = :param1 AND name = '' AND status = :param2", - array(1 => ':param1', 2 => ':param2'), - ) - ); - } - - /** - * @dataProvider dataConvertPositionalToNamedParameters - * @param string $inputSQL - * @param string $expectedOutputSQL - * @param array $expectedOutputParamsMap - */ - public function testConvertPositionalToNamedParameters($inputSQL, $expectedOutputSQL, $expectedOutputParamsMap) - { - list($statement, $params) = \Doctrine\DBAL\Driver\OCI8\OCI8Statement::convertPositionalToNamedPlaceholders($inputSQL); - - $this->assertEquals($expectedOutputSQL, $statement); - $this->assertEquals($expectedOutputParamsMap, $params); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php deleted file mode 100755 index 27dd1495d7..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php +++ /dev/null @@ -1,77 +0,0 @@ -close(); - self::$_sharedConn = null; - } - } - - protected function setUp() - { - if ( ! isset(self::$_sharedConn)) { - self::$_sharedConn = TestUtil::getConnection(); - } - $this->_conn = self::$_sharedConn; - - $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack(); - $this->_conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); - } - - protected function onNotSuccessfulTest(\Exception $e) - { - if ($e instanceof \PHPUnit_Framework_AssertionFailedError) { - throw $e; - } - - if(isset($this->_sqlLoggerStack->queries) && count($this->_sqlLoggerStack->queries)) { - $queries = ""; - $i = count($this->_sqlLoggerStack->queries); - foreach (array_reverse($this->_sqlLoggerStack->queries) AS $query) { - $params = array_map(function($p) { if (is_object($p)) return get_class($p); else return "'".$p."'"; }, $query['params'] ?: array()); - $queries .= ($i+1).". SQL: '".$query['sql']."' Params: ".implode(", ", $params).PHP_EOL; - $i--; - } - - $trace = $e->getTrace(); - $traceMsg = ""; - foreach($trace AS $part) { - if(isset($part['file'])) { - if(strpos($part['file'], "PHPUnit/") !== false) { - // Beginning with PHPUnit files we don't print the trace anymore. - break; - } - - $traceMsg .= $part['file'].":".$part['line'].PHP_EOL; - } - } - - $message = "[".get_class($e)."] ".$e->getMessage().PHP_EOL.PHP_EOL."With queries:".PHP_EOL.$queries.PHP_EOL."Trace:".PHP_EOL.$traceMsg; - - throw new \Exception($message, (int)$e->getCode(), $e); - } - throw $e; - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalTestCase.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalTestCase.php deleted file mode 100755 index 2478e7bcc9..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalTestCase.php +++ /dev/null @@ -1,10 +0,0 @@ -_platformMock = new DatabasePlatformMock(); - - parent::__construct($params, $driver, $config, $eventManager); - - // Override possible assignment of platform to database platform mock - $this->_platform = $this->_platformMock; - } - - /** - * @override - */ - public function getDatabasePlatform() - { - return $this->_platformMock; - } - - /** - * @override - */ - public function insert($tableName, array $data, array $types = array()) - { - $this->_inserts[$tableName][] = $data; - } - - /** - * @override - */ - public function lastInsertId($seqName = null) - { - return $this->_lastInsertId; - } - - /** - * @override - */ - public function fetchColumn($statement, array $params = array(), $colnum = 0) - { - return $this->_fetchOneResult; - } - - /** - * @override - */ - public function quote($input, $type = null) - { - if (is_string($input)) { - return "'" . $input . "'"; - } - return $input; - } - - /* Mock API */ - - public function setFetchOneResult($fetchOneResult) - { - $this->_fetchOneResult = $fetchOneResult; - } - - public function setDatabasePlatform($platform) - { - $this->_platformMock = $platform; - } - - public function setLastInsertId($id) - { - $this->_lastInsertId = $id; - } - - public function getInserts() - { - return $this->_inserts; - } - - public function reset() - { - $this->_inserts = array(); - $this->_lastInsertId = 0; - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php deleted file mode 100755 index 0153f9bb7a..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php +++ /dev/null @@ -1,98 +0,0 @@ -_prefersIdentityColumns; - } - - /** - * @override - */ - public function prefersSequences() - { - return $this->_prefersSequences; - } - - /** @override */ - public function getSequenceNextValSQL($sequenceName) - { - return $this->_sequenceNextValSql; - } - - /** @override */ - public function getBooleanTypeDeclarationSQL(array $field) {} - - /** @override */ - public function getIntegerTypeDeclarationSQL(array $field) {} - - /** @override */ - public function getBigIntTypeDeclarationSQL(array $field) {} - - /** @override */ - public function getSmallIntTypeDeclarationSQL(array $field) {} - - /** @override */ - protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {} - - /** @override */ - public function getVarcharTypeDeclarationSQL(array $field) {} - - /** @override */ - public function getClobTypeDeclarationSQL(array $field) {} - - /* MOCK API */ - - public function setPrefersIdentityColumns($bool) - { - $this->_prefersIdentityColumns = $bool; - } - - public function setPrefersSequences($bool) - { - $this->_prefersSequences = $bool; - } - - public function setSequenceNextValSql($sql) - { - $this->_sequenceNextValSql = $sql; - } - - public function getName() - { - return 'mock'; - } - protected function initializeDoctrineTypeMappings() { - } - protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) - { - - } - /** - * Gets the SQL Snippet used to declare a BLOB column type. - */ - public function getBlobTypeDeclarationSQL(array $field) - { - throw DBALException::notSupported(__METHOD__); - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php deleted file mode 100755 index 03d44caae4..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php +++ /dev/null @@ -1,17 +0,0 @@ -_platformMock) { - $this->_platformMock = new DatabasePlatformMock; - } - return $this->_platformMock; - } - - /** - * @override - */ - public function getSchemaManager(\Doctrine\DBAL\Connection $conn) - { - if($this->_schemaManagerMock == null) { - return new SchemaManagerMock($conn); - } else { - return $this->_schemaManagerMock; - } - } - - /* MOCK API */ - - public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform) - { - $this->_platformMock = $platform; - } - - public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm) - { - $this->_schemaManagerMock = $sm; - } - - public function getName() - { - return 'mock'; - } - - public function getDatabase(\Doctrine\DBAL\Connection $conn) - { - return; - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php deleted file mode 100755 index 629352fbcc..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php +++ /dev/null @@ -1,101 +0,0 @@ - - */ -class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement -{ - private $_resultSet; - - /** - * Creates a new mock statement that will serve the provided fake result set to clients. - * - * @param array $resultSet The faked SQL result set. - */ - public function __construct(array $resultSet) - { - $this->_resultSet = $resultSet; - } - - /** - * Fetches all rows from the result set. - * - * @return array - */ - public function fetchAll($fetchMode = null, $columnIndex = null, array $ctorArgs = null) - { - return $this->_resultSet; - } - - public function fetchColumn($columnNumber = 0) - { - $row = current($this->_resultSet); - if ( ! is_array($row)) return false; - $val = array_shift($row); - return $val !== null ? $val : false; - } - - /** - * Fetches the next row in the result set. - * - */ - public function fetch($fetchMode = null) - { - $current = current($this->_resultSet); - next($this->_resultSet); - return $current; - } - - /** - * Closes the cursor, enabling the statement to be executed again. - * - * @return boolean - */ - public function closeCursor() - { - return true; - } - - public function setResultSet(array $resultSet) - { - reset($resultSet); - $this->_resultSet = $resultSet; - } - - public function bindColumn($column, &$param, $type = null) - { - } - - public function bindValue($param, $value, $type = null) - { - } - - public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()) - { - } - - public function columnCount() - { - } - - public function errorCode() - { - } - - public function errorInfo() - { - } - - public function execute($params = array()) - { - } - - public function rowCount() - { - } -} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php deleted file mode 100755 index d4c3c28c00..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php +++ /dev/null @@ -1,13 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Mocks; - -use Doctrine\Common\Cli\AbstractNamespace; - -/** - * TaskMock used for testing the CLI interface. - * @author Nils Adermann - */ -class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask -{ - /** - * Since instances of this class can be created elsewhere all instances - * register themselves in this array for later inspection. - * - * @var array(TaskMock) - */ - static public $instances = array(); - - private $runCounter = 0; - - /** - * Constructor of Task Mock Object. - * Makes sure the object can be inspected later. - * - * @param AbstractNamespace CLI Namespace, passed to parent constructor - */ - function __construct(AbstractNamespace $namespace) - { - self::$instances[] = $this; - - parent::__construct($namespace); - } - - /** - * Returns the number of times run() was called on this object. - * - * @return int - */ - public function getRunCounter() - { - return $this->runCounter; - } - - /* Mock API */ - - /** - * Method invoked by CLI to run task. - */ - public function run() - { - $this->runCounter++; - } - - /** - * Method supposed to generate the CLI Task Documentation - */ - public function buildDocumentation() - { - } -} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/TestInit.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/TestInit.php deleted file mode 100755 index cb4cc2786a..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/TestInit.php +++ /dev/null @@ -1,17 +0,0 @@ -add('Doctrine\Tests', __DIR__ . '/../../'); diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/TestUtil.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/TestUtil.php deleted file mode 100755 index 8701c0a263..0000000000 --- a/vendor/doctrine/dbal/tests/Doctrine/Tests/TestUtil.php +++ /dev/null @@ -1,130 +0,0 @@ -real database connection using the following parameters - * of the $GLOBALS array: - * - * 'db_type' : The name of the Doctrine DBAL database driver to use. - * 'db_username' : The username to use for connecting. - * 'db_password' : The password to use for connecting. - * 'db_host' : The hostname of the database to connect to. - * 'db_name' : The name of the database to connect to. - * 'db_port' : The port of the database to connect to. - * - * Usually these variables of the $GLOBALS array are filled by PHPUnit based - * on an XML configuration file. If no such parameters exist, an SQLite - * in-memory database is used. - * - * IMPORTANT: - * 1) Each invocation of this method returns a NEW database connection. - * 2) The database is dropped and recreated to ensure it's clean. - * - * @return \Doctrine\DBAL\Connection The database connection instance. - */ - public static function getConnection() - { - if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'], - $GLOBALS['db_host'], $GLOBALS['db_name'], $GLOBALS['db_port']) && - isset($GLOBALS['tmpdb_type'], $GLOBALS['tmpdb_username'], $GLOBALS['tmpdb_password'], - $GLOBALS['tmpdb_host'], $GLOBALS['tmpdb_name'], $GLOBALS['tmpdb_port'])) { - $realDbParams = array( - 'driver' => $GLOBALS['db_type'], - 'user' => $GLOBALS['db_username'], - 'password' => $GLOBALS['db_password'], - 'host' => $GLOBALS['db_host'], - 'dbname' => $GLOBALS['db_name'], - 'port' => $GLOBALS['db_port'] - ); - $tmpDbParams = array( - 'driver' => $GLOBALS['tmpdb_type'], - 'user' => $GLOBALS['tmpdb_username'], - 'password' => $GLOBALS['tmpdb_password'], - 'host' => $GLOBALS['tmpdb_host'], - 'dbname' => $GLOBALS['tmpdb_name'], - 'port' => $GLOBALS['tmpdb_port'] - ); - - if (isset($GLOBALS['db_unix_socket'])) { - $realDbParams['unix_socket'] = $GLOBALS['db_unix_socket']; - } - - if (isset($GLOBALS['tmpdb_unix_socket'])) { - $tmpDbParams['unix_socket'] = $GLOBALS['tmpdb_unix_socket']; - } - - $realConn = \Doctrine\DBAL\DriverManager::getConnection($realDbParams); - - $platform = $realConn->getDatabasePlatform(); - - if ($platform->supportsCreateDropDatabase()) { - $dbname = $realConn->getDatabase(); - // Connect to tmpdb in order to drop and create the real test db. - $tmpConn = \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); - $realConn->close(); - - $tmpConn->getSchemaManager()->dropAndCreateDatabase($dbname); - - $tmpConn->close(); - } else { - $sm = $realConn->getSchemaManager(); - - /* @var $schema Schema */ - $schema = $sm->createSchema(); - $stmts = $schema->toDropSql($realConn->getDatabasePlatform()); - - foreach ($stmts AS $stmt) { - $realConn->exec($stmt); - } - } - - $conn = \Doctrine\DBAL\DriverManager::getConnection($realDbParams, null, null); - } else { - $params = array( - 'driver' => 'pdo_sqlite', - 'memory' => true - ); - if (isset($GLOBALS['db_path'])) { - $params['path'] = $GLOBALS['db_path']; - unlink($GLOBALS['db_path']); - } - $conn = \Doctrine\DBAL\DriverManager::getConnection($params); - } - - if (isset($GLOBALS['db_event_subscribers'])) { - $evm = $conn->getEventManager(); - foreach (explode(",", $GLOBALS['db_event_subscribers']) AS $subscriberClass) { - $subscriberInstance = new $subscriberClass(); - $evm->addEventSubscriber($subscriberInstance); - } - } - - return $conn; - } - - /** - * @return \Doctrine\DBAL\Connection - */ - public static function getTempConnection() - { - $tmpDbParams = array( - 'driver' => $GLOBALS['tmpdb_type'], - 'user' => $GLOBALS['tmpdb_username'], - 'password' => $GLOBALS['tmpdb_password'], - 'host' => $GLOBALS['tmpdb_host'], - 'dbname' => $GLOBALS['tmpdb_name'], - 'port' => $GLOBALS['tmpdb_port'] - ); - - // Connect to tmpdb in order to drop and create the real test db. - return \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); - } -} diff --git a/vendor/doctrine/dbal/tests/README.markdown b/vendor/doctrine/dbal/tests/README.markdown deleted file mode 100755 index c1027acedd..0000000000 --- a/vendor/doctrine/dbal/tests/README.markdown +++ /dev/null @@ -1,25 +0,0 @@ -# Running the Doctrine 2 Testsuite - -## Setting up a PHPUnit Configuration XML - -.. - -## Testing Lock-Support - -The Lock support in Doctrine 2 is tested using Gearman, which allows to run concurrent tasks in parallel. -Install Gearman with PHP as follows: - -1. Go to http://www.gearman.org and download the latest Gearman Server -2. Compile it and then call ldconfig -3. Start it up "gearmand -vvvv" -4. Install pecl/gearman by calling "gearman-beta" - -You can then go into tests/ and start up two workers: - - php Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php - -Then run the locking test-suite: - - phpunit --configuration Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php - -This can run considerable time, because it is using sleep() to test for the timing ranges of locks. \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/travis/mysql.travis.xml b/vendor/doctrine/dbal/tests/travis/mysql.travis.xml deleted file mode 100755 index c80f4d2950..0000000000 --- a/vendor/doctrine/dbal/tests/travis/mysql.travis.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ./../Doctrine/Tests/DBAL - - - - - performance - locking_functional - - - - - diff --git a/vendor/doctrine/dbal/tests/travis/mysqli.travis.xml b/vendor/doctrine/dbal/tests/travis/mysqli.travis.xml deleted file mode 100755 index ace5df463d..0000000000 --- a/vendor/doctrine/dbal/tests/travis/mysqli.travis.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ./../Doctrine/Tests/DBAL - - - - - performance - locking_functional - - - - - diff --git a/vendor/doctrine/dbal/tests/travis/pgsql.travis.xml b/vendor/doctrine/dbal/tests/travis/pgsql.travis.xml deleted file mode 100755 index e3bd7ead59..0000000000 --- a/vendor/doctrine/dbal/tests/travis/pgsql.travis.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - ./../Doctrine/Tests/DBAL - - - - - performance - locking_functional - - - \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/travis/sqlite.travis.xml b/vendor/doctrine/dbal/tests/travis/sqlite.travis.xml deleted file mode 100755 index 944f137a87..0000000000 --- a/vendor/doctrine/dbal/tests/travis/sqlite.travis.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - ./../Doctrine/Tests/DBAL - - - - - performance - locking_functional - - - \ No newline at end of file diff --git a/vendor/doctrine/inflector/README.md b/vendor/doctrine/inflector/README.md new file mode 100644 index 0000000000..f2d18d0f16 --- /dev/null +++ b/vendor/doctrine/inflector/README.md @@ -0,0 +1,4 @@ +# Doctrine Inflector + +Doctrine Inflector is a small library that can perform string manipulations +with regard to upper-/lowercase and singular/plural forms of words. diff --git a/vendor/doctrine/inflector/composer.json b/vendor/doctrine/inflector/composer.json new file mode 100644 index 0000000000..3d3c3f90f3 --- /dev/null +++ b/vendor/doctrine/inflector/composer.json @@ -0,0 +1,21 @@ +{ + "name": "doctrine/inflector", + "type": "library", + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "keywords": ["string", "inflection", "singuarlize", "pluarlize"], + "homepage": "http://www.doctrine-project.org", + "license": "MIT", + "authors": [ + {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, + {"name": "Roman Borschel", "email": "roman@code-factory.org"}, + {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, + {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, + {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} + ], + "require": { + "php": ">=5.3.2" + }, + "autoload": { + "psr-0": { "Doctrine\\Common\\Inflector\\": "lib/" } + } +} diff --git a/vendor/doctrine/inflector/lib/Doctrine/Common/Inflector/Inflector.php b/vendor/doctrine/inflector/lib/Doctrine/Common/Inflector/Inflector.php new file mode 100644 index 0000000000..f4e38e765f --- /dev/null +++ b/vendor/doctrine/inflector/lib/Doctrine/Common/Inflector/Inflector.php @@ -0,0 +1,385 @@ +. + */ + +namespace Doctrine\Common\Inflector; + +/** + * Doctrine inflector has static methods for inflecting text + * + * The methods in these classes are from several different sources collected + * across several different php projects and several different authors. The + * original author names and emails are not known. + * + * Plurialize & Singularize implementation are borrowed from CakePHP with some modifications. + * + * @link www.doctrine-project.org + * @since 1.0 + * @author Konsta Vesterinen + * @author Jonathan H. Wage + */ +class Inflector +{ + /** + * Plural inflector rules + * + * @var array + */ + private static $plural = array( + 'rules' => array( + '/(s)tatus$/i' => '\1\2tatuses', + '/(quiz)$/i' => '\1zes', + '/^(ox)$/i' => '\1\2en', + '/([m|l])ouse$/i' => '\1ice', + '/(matr|vert|ind)(ix|ex)$/i' => '\1ices', + '/(x|ch|ss|sh)$/i' => '\1es', + '/([^aeiouy]|qu)y$/i' => '\1ies', + '/(hive)$/i' => '\1s', + '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', + '/sis$/i' => 'ses', + '/([ti])um$/i' => '\1a', + '/(p)erson$/i' => '\1eople', + '/(m)an$/i' => '\1en', + '/(c)hild$/i' => '\1hildren', + '/(buffal|tomat)o$/i' => '\1\2oes', + '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i', + '/us$/i' => 'uses', + '/(alias)$/i' => '\1es', + '/(ax|cris|test)is$/i' => '\1es', + '/s$/' => 's', + '/^$/' => '', + '/$/' => 's', + ), + 'uninflected' => array( + '.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people', 'cookie' + ), + 'irregular' => array( + 'atlas' => 'atlases', + 'beef' => 'beefs', + 'brother' => 'brothers', + 'cafe' => 'cafes', + 'child' => 'children', + 'cookie' => 'cookies', + 'corpus' => 'corpuses', + 'cow' => 'cows', + 'ganglion' => 'ganglions', + 'genie' => 'genies', + 'genus' => 'genera', + 'graffito' => 'graffiti', + 'hoof' => 'hoofs', + 'loaf' => 'loaves', + 'man' => 'men', + 'money' => 'monies', + 'mongoose' => 'mongooses', + 'move' => 'moves', + 'mythos' => 'mythoi', + 'niche' => 'niches', + 'numen' => 'numina', + 'occiput' => 'occiputs', + 'octopus' => 'octopuses', + 'opus' => 'opuses', + 'ox' => 'oxen', + 'penis' => 'penises', + 'person' => 'people', + 'sex' => 'sexes', + 'soliloquy' => 'soliloquies', + 'testis' => 'testes', + 'trilby' => 'trilbys', + 'turf' => 'turfs' + ) + ); + + /** + * Singular inflector rules + * + * @var array + */ + private static $singular = array( + 'rules' => array( + '/(s)tatuses$/i' => '\1\2tatus', + '/^(.*)(menu)s$/i' => '\1\2', + '/(quiz)zes$/i' => '\\1', + '/(matr)ices$/i' => '\1ix', + '/(vert|ind)ices$/i' => '\1ex', + '/^(ox)en/i' => '\1', + '/(alias)(es)*$/i' => '\1', + '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us', + '/([ftw]ax)es/i' => '\1', + '/(cris|ax|test)es$/i' => '\1is', + '/(shoe|slave)s$/i' => '\1', + '/(o)es$/i' => '\1', + '/ouses$/' => 'ouse', + '/([^a])uses$/' => '\1us', + '/([m|l])ice$/i' => '\1ouse', + '/(x|ch|ss|sh)es$/i' => '\1', + '/(m)ovies$/i' => '\1\2ovie', + '/(s)eries$/i' => '\1\2eries', + '/([^aeiouy]|qu)ies$/i' => '\1y', + '/([lr])ves$/i' => '\1f', + '/(tive)s$/i' => '\1', + '/(hive)s$/i' => '\1', + '/(drive)s$/i' => '\1', + '/([^fo])ves$/i' => '\1fe', + '/(^analy)ses$/i' => '\1sis', + '/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis', + '/([ti])a$/i' => '\1um', + '/(p)eople$/i' => '\1\2erson', + '/(m)en$/i' => '\1an', + '/(c)hildren$/i' => '\1\2hild', + '/(n)ews$/i' => '\1\2ews', + '/eaus$/' => 'eau', + '/^(.*us)$/' => '\\1', + '/s$/i' => '' + ), + 'uninflected' => array( + '.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', '.*ss' + ), + 'irregular' => array( + 'foes' => 'foe', + 'waves' => 'wave', + 'curves' => 'curve' + ) + ); + + /** + * Words that should not be inflected + * + * @var array + */ + private static $uninflected = array( + 'Amoyese', 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus', + 'carp', 'chassis', 'clippers', 'cod', 'coitus', 'Congoese', 'contretemps', 'corps', + 'debris', 'diabetes', 'djinn', 'eland', 'elk', 'equipment', 'Faroese', 'flounder', + 'Foochowese', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti', + 'headquarters', 'herpes', 'hijinks', 'Hottentotese', 'information', 'innings', + 'jackanapes', 'Kiplingese', 'Kongoese', 'Lucchese', 'mackerel', 'Maltese', '.*?media', + 'mews', 'moose', 'mumps', 'Nankingese', 'news', 'nexus', 'Niasese', + 'Pekingese', 'Piedmontese', 'pincers', 'Pistoiese', 'pliers', 'Portuguese', + 'proceedings', 'rabies', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors', + 'sea[- ]bass', 'series', 'Shavese', 'shears', 'siemens', 'species', 'swine', 'testes', + 'trousers', 'trout', 'tuna', 'Vermontese', 'Wenchowese', 'whiting', 'wildebeest', + 'Yengeese' + ); + + /** + * Method cache array. + * + * @var array + */ + private static $cache = array(); + + /** + * The initial state of Inflector so reset() works. + * + * @var array + */ + private static $initialState = array(); + + /** + * Convert word in to the format for a Doctrine table name. Converts 'ModelName' to 'model_name' + * + * @param string $word Word to tableize + * @return string $word Tableized word + */ + public static function tableize($word) + { + return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word)); + } + + /** + * Convert a word in to the format for a Doctrine class name. Converts 'table_name' to 'TableName' + * + * @param string $word Word to classify + * @return string $word Classified word + */ + public static function classify($word) + { + return str_replace(" ", "", ucwords(strtr($word, "_-", " "))); + } + + /** + * Camelize a word. This uses the classify() method and turns the first character to lowercase + * + * @param string $word + * @return string $word + */ + public static function camelize($word) + { + return lcfirst(self::classify($word)); + } + + /** + * Clears Inflectors inflected value caches. And resets the inflection + * rules to the initial values. + * + * @return void + */ + public static function reset() + { + if (empty(self::$initialState)) { + self::$initialState = get_class_vars('Inflector'); + return; + } + foreach (self::$initialState as $key => $val) { + if ($key != 'initialState') { + self::${$key} = $val; + } + } + } + + /** + * Adds custom inflection $rules, of either 'plural' or 'singular' $type. + * + * ### Usage: + * + * {{{ + * Inflector::rules('plural', array('/^(inflect)or$/i' => '\1ables')); + * Inflector::rules('plural', array( + * 'rules' => array('/^(inflect)ors$/i' => '\1ables'), + * 'uninflected' => array('dontinflectme'), + * 'irregular' => array('red' => 'redlings') + * )); + * }}} + * + * @param string $type The type of inflection, either 'plural' or 'singular' + * @param array $rules Array of rules to be added. + * @param boolean $reset If true, will unset default inflections for all + * new rules that are being defined in $rules. + * @return void + */ + public static function rules($type, $rules, $reset = false) + { + foreach ($rules as $rule => $pattern) { + if (is_array($pattern)) { + if ($reset) { + self::${$type}[$rule] = $pattern; + } else { + if ($rule === 'uninflected') { + self::${$type}[$rule] = array_merge($pattern, self::${$type}[$rule]); + } else { + self::${$type}[$rule] = $pattern + self::${$type}[$rule]; + } + } + unset($rules[$rule], self::${$type}['cache' . ucfirst($rule)]); + if (isset(self::${$type}['merged'][$rule])) { + unset(self::${$type}['merged'][$rule]); + } + if ($type === 'plural') { + self::$cache['pluralize'] = self::$cache['tableize'] = array(); + } elseif ($type === 'singular') { + self::$cache['singularize'] = array(); + } + } + } + self::${$type}['rules'] = $rules + self::${$type}['rules']; + } + + /** + * Return $word in plural form. + * + * @param string $word Word in singular + * @return string Word in plural + */ + public static function pluralize($word) + { + if (isset(self::$cache['pluralize'][$word])) { + return self::$cache['pluralize'][$word]; + } + + if (!isset(self::$plural['merged']['irregular'])) { + self::$plural['merged']['irregular'] = self::$plural['irregular']; + } + + if (!isset(self::$plural['merged']['uninflected'])) { + self::$plural['merged']['uninflected'] = array_merge(self::$plural['uninflected'], self::$uninflected); + } + + if (!isset(self::$plural['cacheUninflected']) || !isset(self::$plural['cacheIrregular'])) { + self::$plural['cacheUninflected'] = '(?:' . implode('|', self::$plural['merged']['uninflected']) . ')'; + self::$plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$plural['merged']['irregular'])) . ')'; + } + + if (preg_match('/(.*)\\b(' . self::$plural['cacheIrregular'] . ')$/i', $word, $regs)) { + self::$cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1); + return self::$cache['pluralize'][$word]; + } + + if (preg_match('/^(' . self::$plural['cacheUninflected'] . ')$/i', $word, $regs)) { + self::$cache['pluralize'][$word] = $word; + return $word; + } + + foreach (self::$plural['rules'] as $rule => $replacement) { + if (preg_match($rule, $word)) { + self::$cache['pluralize'][$word] = preg_replace($rule, $replacement, $word); + return self::$cache['pluralize'][$word]; + } + } + } + + /** + * Return $word in singular form. + * + * @param string $word Word in plural + * @return string Word in singular + */ + public static function singularize($word) + { + if (isset(self::$cache['singularize'][$word])) { + return self::$cache['singularize'][$word]; + } + + if (!isset(self::$singular['merged']['uninflected'])) { + self::$singular['merged']['uninflected'] = array_merge( + self::$singular['uninflected'], + self::$uninflected + ); + } + + if (!isset(self::$singular['merged']['irregular'])) { + self::$singular['merged']['irregular'] = array_merge( + self::$singular['irregular'], + array_flip(self::$plural['irregular']) + ); + } + + if (!isset(self::$singular['cacheUninflected']) || !isset(self::$singular['cacheIrregular'])) { + self::$singular['cacheUninflected'] = '(?:' . join('|', self::$singular['merged']['uninflected']) . ')'; + self::$singular['cacheIrregular'] = '(?:' . join('|', array_keys(self::$singular['merged']['irregular'])) . ')'; + } + + if (preg_match('/(.*)\\b(' . self::$singular['cacheIrregular'] . ')$/i', $word, $regs)) { + self::$cache['singularize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$singular['merged']['irregular'][strtolower($regs[2])], 1); + return self::$cache['singularize'][$word]; + } + + if (preg_match('/^(' . self::$singular['cacheUninflected'] . ')$/i', $word, $regs)) { + self::$cache['singularize'][$word] = $word; + return $word; + } + + foreach (self::$singular['rules'] as $rule => $replacement) { + if (preg_match($rule, $word)) { + self::$cache['singularize'][$word] = preg_replace($rule, $replacement, $word); + return self::$cache['singularize'][$word]; + } + } + self::$cache['singularize'][$word] = $word; + return $word; + } +} diff --git a/vendor/doctrine/inflector/phpunit.xml.dist b/vendor/doctrine/inflector/phpunit.xml.dist new file mode 100644 index 0000000000..ef07faa53c --- /dev/null +++ b/vendor/doctrine/inflector/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + ./tests/Doctrine/ + + + + + + ./lib/Doctrine/ + + + + + + performance + + + diff --git a/vendor/doctrine/inflector/tests/Doctrine/Tests/Common/Inflector/InflectorTest.php b/vendor/doctrine/inflector/tests/Doctrine/Tests/Common/Inflector/InflectorTest.php new file mode 100644 index 0000000000..487c2cd449 --- /dev/null +++ b/vendor/doctrine/inflector/tests/Doctrine/Tests/Common/Inflector/InflectorTest.php @@ -0,0 +1,185 @@ +assertEquals($singular, Inflector::singularize($plural), "'$plural' should be singularized to '$singular'"); + } + + /** + * testInflectingPlurals method + * + * @dataProvider dataSampleWords + * @return void + */ + public function testInflectingPlurals($singular, $plural) { + $this->assertEquals($plural, Inflector::pluralize($singular), "'$singular' should be pluralized to '$plural'"); + } + + /** + * testCustomPluralRule method + * + * @return void + */ + public function testCustomPluralRule() { + Inflector::reset(); + Inflector::rules('plural', array('/^(custom)$/i' => '\1izables')); + $this->assertEquals(Inflector::pluralize('custom'), 'customizables'); + + Inflector::rules('plural', array('uninflected' => array('uninflectable'))); + $this->assertEquals(Inflector::pluralize('uninflectable'), 'uninflectable'); + + Inflector::rules('plural', array( + 'rules' => array('/^(alert)$/i' => '\1ables'), + 'uninflected' => array('noflect', 'abtuse'), + 'irregular' => array('amaze' => 'amazable', 'phone' => 'phonezes') + )); + $this->assertEquals(Inflector::pluralize('noflect'), 'noflect'); + $this->assertEquals(Inflector::pluralize('abtuse'), 'abtuse'); + $this->assertEquals(Inflector::pluralize('alert'), 'alertables'); + $this->assertEquals(Inflector::pluralize('amaze'), 'amazable'); + $this->assertEquals(Inflector::pluralize('phone'), 'phonezes'); + } + + /** + * testCustomSingularRule method + * + * @return void + */ + public function testCustomSingularRule() { + Inflector::reset(); + Inflector::rules('singular', array('/(eple)r$/i' => '\1', '/(jente)r$/i' => '\1')); + + $this->assertEquals(Inflector::singularize('epler'), 'eple'); + $this->assertEquals(Inflector::singularize('jenter'), 'jente'); + + Inflector::rules('singular', array( + 'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'), + 'uninflected' => array('singulars'), + 'irregular' => array('spins' => 'spinor') + )); + + $this->assertEquals(Inflector::singularize('inflectors'), 'inflecta'); + $this->assertEquals(Inflector::singularize('contributors'), 'contributa'); + $this->assertEquals(Inflector::singularize('spins'), 'spinor'); + $this->assertEquals(Inflector::singularize('singulars'), 'singulars'); + } + + /** + * test that setting new rules clears the inflector caches. + * + * @return void + */ + public function testRulesClearsCaches() { + Inflector::reset(); + $this->assertEquals(Inflector::singularize('Bananas'), 'Banana'); + $this->assertEquals(Inflector::pluralize('Banana'), 'Bananas'); + + Inflector::rules('singular', array( + 'rules' => array('/(.*)nas$/i' => '\1zzz') + )); + $this->assertEquals('Banazzz', Inflector::singularize('Bananas'), 'Was inflected with old rules.'); + + Inflector::rules('plural', array( + 'rules' => array('/(.*)na$/i' => '\1zzz'), + 'irregular' => array('corpus' => 'corpora') + )); + $this->assertEquals(Inflector::pluralize('Banana'), 'Banazzz', 'Was inflected with old rules.'); + $this->assertEquals(Inflector::pluralize('corpus'), 'corpora', 'Was inflected with old irregular form.'); + } + + /** + * Test resetting inflection rules. + * + * @return void + */ + public function testCustomRuleWithReset() { + Inflector::reset(); + $uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x'); + $pluralIrregular = array('as' => 'ases'); + + Inflector::rules('singular', array( + 'rules' => array('/^(.*)(a|e|o|u)is$/i' => '\1\2l'), + 'uninflected' => $uninflected, + ), true); + + Inflector::rules('plural', array( + 'rules' => array( + '/^(.*)(a|e|o|u)l$/i' => '\1\2is', + ), + 'uninflected' => $uninflected, + 'irregular' => $pluralIrregular + ), true); + + $this->assertEquals(Inflector::pluralize('Alcool'), 'Alcoois'); + $this->assertEquals(Inflector::pluralize('Atlas'), 'Atlas'); + $this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool'); + $this->assertEquals(Inflector::singularize('Atlas'), 'Atlas'); + } +} + diff --git a/vendor/doctrine/inflector/tests/Doctrine/Tests/DoctrineTestCase.php b/vendor/doctrine/inflector/tests/Doctrine/Tests/DoctrineTestCase.php new file mode 100644 index 0000000000..e8323d2940 --- /dev/null +++ b/vendor/doctrine/inflector/tests/Doctrine/Tests/DoctrineTestCase.php @@ -0,0 +1,10 @@ +=5.3.2" + }, + "autoload": { + "psr-0": { "Doctrine\\Common\\Lexer\\": "lib/" } + } +} diff --git a/vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php b/vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php new file mode 100644 index 0000000000..eb6cf7c022 --- /dev/null +++ b/vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php @@ -0,0 +1,265 @@ +. + */ + +namespace Doctrine\Common\Lexer; + +/** + * Base class for writing simple lexers, i.e. for creating small DSLs. + * + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +abstract class AbstractLexer +{ + /** + * @var array Array of scanned tokens + */ + private $tokens = array(); + + /** + * @var integer Current lexer position in input string + */ + private $position = 0; + + /** + * @var integer Current peek of current lexer position + */ + private $peek = 0; + + /** + * @var array The next token in the input. + */ + public $lookahead; + + /** + * @var array The last matched/seen token. + */ + public $token; + + /** + * Sets the input data to be tokenized. + * + * The Lexer is immediately reset and the new input tokenized. + * Any unprocessed tokens from any previous input are lost. + * + * @param string $input The input to be tokenized. + */ + public function setInput($input) + { + $this->tokens = array(); + $this->reset(); + $this->scan($input); + } + + /** + * Resets the lexer. + */ + public function reset() + { + $this->lookahead = null; + $this->token = null; + $this->peek = 0; + $this->position = 0; + } + + /** + * Resets the peek pointer to 0. + */ + public function resetPeek() + { + $this->peek = 0; + } + + /** + * Resets the lexer position on the input to the given position. + * + * @param integer $position Position to place the lexical scanner + */ + public function resetPosition($position = 0) + { + $this->position = $position; + } + + /** + * Checks whether a given token matches the current lookahead. + * + * @param integer|string $token + * @return boolean + */ + public function isNextToken($token) + { + return null !== $this->lookahead && $this->lookahead['type'] === $token; + } + + /** + * Checks whether any of the given tokens matches the current lookahead + * + * @param array $tokens + * @return boolean + */ + public function isNextTokenAny(array $tokens) + { + return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true); + } + + /** + * Moves to the next token in the input string. + * + * A token is an associative array containing three items: + * - 'value' : the string value of the token in the input string + * - 'type' : the type of the token (identifier, numeric, string, input + * parameter, none) + * - 'position' : the position of the token in the input string + * + * @return array|null the next token; null if there is no more tokens left + */ + public function moveNext() + { + $this->peek = 0; + $this->token = $this->lookahead; + $this->lookahead = (isset($this->tokens[$this->position])) + ? $this->tokens[$this->position++] : null; + + return $this->lookahead !== null; + } + + /** + * Tells the lexer to skip input tokens until it sees a token with the given value. + * + * @param string $type The token type to skip until. + */ + public function skipUntil($type) + { + while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { + $this->moveNext(); + } + } + + /** + * Checks if given value is identical to the given token + * + * @param mixed $value + * @param integer $token + * @return boolean + */ + public function isA($value, $token) + { + return $this->getType($value) === $token; + } + + /** + * Moves the lookahead token forward. + * + * @return array | null The next token or NULL if there are no more tokens ahead. + */ + public function peek() + { + if (isset($this->tokens[$this->position + $this->peek])) { + return $this->tokens[$this->position + $this->peek++]; + } else { + return null; + } + } + + /** + * Peeks at the next token, returns it and immediately resets the peek. + * + * @return array|null The next token or NULL if there are no more tokens ahead. + */ + public function glimpse() + { + $peek = $this->peek(); + $this->peek = 0; + return $peek; + } + + /** + * Scans the input string for tokens. + * + * @param string $input a query string + */ + protected function scan($input) + { + static $regex; + + if ( ! isset($regex)) { + $regex = '/(' . implode(')|(', $this->getCatchablePatterns()) . ')|' + . implode('|', $this->getNonCatchablePatterns()) . '/i'; + } + + $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; + $matches = preg_split($regex, $input, -1, $flags); + + foreach ($matches as $match) { + // Must remain before 'value' assignment since it can change content + $type = $this->getType($match[0]); + + $this->tokens[] = array( + 'value' => $match[0], + 'type' => $type, + 'position' => $match[1], + ); + } + } + + /** + * Gets the literal for a given token. + * + * @param integer $token + * @return string + */ + public function getLiteral($token) + { + $className = get_class($this); + $reflClass = new \ReflectionClass($className); + $constants = $reflClass->getConstants(); + + foreach ($constants as $name => $value) { + if ($value === $token) { + return $className . '::' . $name; + } + } + + return $token; + } + + /** + * Lexical catchable patterns. + * + * @return array + */ + abstract protected function getCatchablePatterns(); + + /** + * Lexical non-catchable patterns. + * + * @return array + */ + abstract protected function getNonCatchablePatterns(); + + /** + * Retrieve token type. Also processes the token value if necessary. + * + * @param string $value + * @return integer + */ + abstract protected function getType(&$value); +} diff --git a/vendor/doctrine/orm/.coveralls.yml b/vendor/doctrine/orm/.coveralls.yml new file mode 100644 index 0000000000..0c08233606 --- /dev/null +++ b/vendor/doctrine/orm/.coveralls.yml @@ -0,0 +1,4 @@ +# for php-coveralls +service_name: travis-ci +src_dir: lib +coverage_clover: build/logs/clover.xml diff --git a/vendor/doctrine/orm/.gitignore b/vendor/doctrine/orm/.gitignore deleted file mode 100755 index b49fac4bf9..0000000000 --- a/vendor/doctrine/orm/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -build/ -logs/ -reports/ -dist/ -download/ -lib/api/ -lib/Doctrine/Common -lib/Doctrine/DBAL -/.settings/ -.buildpath -.project \ No newline at end of file diff --git a/vendor/doctrine/orm/.gitmodules b/vendor/doctrine/orm/.gitmodules deleted file mode 100755 index 2d52e9acde..0000000000 --- a/vendor/doctrine/orm/.gitmodules +++ /dev/null @@ -1,15 +0,0 @@ -[submodule "lib/vendor/doctrine-common"] - path = lib/vendor/doctrine-common - url = git://github.com/doctrine/common.git -[submodule "lib/vendor/doctrine-dbal"] - path = lib/vendor/doctrine-dbal - url = git://github.com/doctrine/dbal.git -[submodule "lib/vendor/Symfony/Component/Console"] - path = lib/vendor/Symfony/Component/Console - url = git://github.com/symfony/Console.git -[submodule "lib/vendor/Symfony/Component/Yaml"] - path = lib/vendor/Symfony/Component/Yaml - url = git://github.com/symfony/Yaml.git -[submodule "lib/vendor/doctrine-build-common"] - path = lib/vendor/doctrine-build-common - url = git://github.com/doctrine/doctrine-build-common.git diff --git a/vendor/doctrine/orm/.travis.yml b/vendor/doctrine/orm/.travis.yml deleted file mode 100755 index 716b9b640e..0000000000 --- a/vendor/doctrine/orm/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 -env: - - DB=mysql - - DB=pgsql - - DB=sqlite - -before_script: - - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS doctrine_tests;' -U postgres; fi" - - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS doctrine_tests_tmp;' -U postgres; fi" - - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database doctrine_tests;' -U postgres; fi" - - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database doctrine_tests_tmp;' -U postgres; fi" - - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS doctrine_tests_tmp;create database IF NOT EXISTS doctrine_tests;'; fi" - - git submodule update --init - -script: phpunit --configuration tests/travis/$DB.travis.xml \ No newline at end of file diff --git a/vendor/doctrine/orm/LICENSE b/vendor/doctrine/orm/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/README.markdown b/vendor/doctrine/orm/README.markdown old mode 100755 new mode 100644 index 54e9e8ecb4..b6b60ac164 --- a/vendor/doctrine/orm/README.markdown +++ b/vendor/doctrine/orm/README.markdown @@ -1,9 +1,15 @@ # Doctrine 2 ORM Master: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=master)](http://travis-ci.org/doctrine/doctrine2) +2.3: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=2.3)](http://travis-ci.org/doctrine/doctrine2) 2.2: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=2.2)](http://travis-ci.org/doctrine/doctrine2) 2.1: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=2.1.x)](http://travis-ci.org/doctrine/doctrine2) +Master: [![Coverage Status](https://coveralls.io/repos/doctrine/doctrine2/badge.png?branch=master)](https://coveralls.io/r/doctrine/doctrine2?branch=master) + +[![Latest Stable Version](https://poser.pugx.org/doctrine/orm/v/stable.png)](https://packagist.org/packages/doctrine/orm) [![Total Downloads](https://poser.pugx.org/doctrine/orm/downloads.png)](https://packagist.org/packages/doctrine/orm) + + Doctrine 2 is an object-relational mapper (ORM) for PHP 5.3.2+ that provides transparent persistence for PHP objects. It sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), diff --git a/vendor/doctrine/orm/UPGRADE.md b/vendor/doctrine/orm/UPGRADE.md old mode 100755 new mode 100644 index 2db87ffe2b..b864d86145 --- a/vendor/doctrine/orm/UPGRADE.md +++ b/vendor/doctrine/orm/UPGRADE.md @@ -1,3 +1,47 @@ +# Upgrade to 2.4 + +## BC BREAK: Compatibility Bugfix in PersistentCollection#matching() + +In Doctrine 2.3 it was possible to use the new ``matching($criteria)`` +functionality by adding constraints for assocations based on ID: + + Criteria::expr()->eq('association', $assocation->getId()); + +This functionality does not work on InMemory collections however, because +in memory criteria compares object values based on reference. +As of 2.4 the above code will throw an exception. You need to change +offending code to pass the ``$assocation`` reference directly: + + Criteria::expr()->eq('association', $assocation); + +## Composer is now the default autoloader + +The test suite now runs with composer autoloading. Support for PEAR, and tarball autoloading is deprecated. +Support for GIT submodules is removed. + +## OnFlush and PostFlush event always called + +Before 2.4 the postFlush and onFlush events were only called when there were +actually entities that changed. Now these events are called no matter if there +are entities in the UoW or changes are found. + +## Parenthesis are now considered in arithmetic expression + +Before 2.4 parenthesis are not considered in arithmetic primary expression. +That's conceptually wrong, since it might result in wrong values. For example: + +The DQL: + + SELECT 100 / ( 2 * 2 ) FROM MyEntity + +Before 2.4 it generates the SQL: + + SELECT 100 / 2 * 2 FROM my_entity + +Now parenthesis are considered, the previous DQL will generate: + + SELECT 100 / (2 * 2) FROM my_entity + # Upgrade to 2.3 ## EntityManager#find() not calls EntityRepository#find() anymore @@ -41,6 +85,12 @@ Also, related functions were affected: Internal changes were made to DQL and SQL generation. If you have implemented your own TreeWalker, you probably need to update it. The method walkJoinVariableDeclaration is now named walkJoin. +## New methods in TreeWalker interface *BC break* + +Two methods getQueryComponents() and setQueryComponent() were added to the TreeWalker interface and all its implementations +including TreeWalkerAdapter, TreeWalkerChain and SqlWalker. If you have your own implementation not inheriting from one of the +above you must implement these new methods. + ## Metadata Drivers Metadata drivers have been rewritten to reuse code from Doctrine\Common. Anyone who is using the @@ -107,7 +157,7 @@ from 2.0 have to configure the annotation driver if they don't use `Configuratio $config->setMetadataDriverImpl($driver); -## Scalar mappings can now be ommitted from DQL result +## Scalar mappings can now be omitted from DQL result You are now allowed to mark scalar SELECT expressions as HIDDEN an they are not hydrated anymore. Example: @@ -288,7 +338,7 @@ them for batch updates like SchemaTool and other commands. However the annotations driver being a default driver does not really help that much anyways. -Therefore we decided to break backwards compability in this issue and drop +Therefore we decided to break backwards compatibility in this issue and drop the support for Annotations as Default Driver and require our users to specify the driver explicitly (which allows us to ask for the path to all entities). @@ -347,7 +397,7 @@ apologize for the inconvenience. ## Default Property for Field Mappings The "default" option for database column defaults has been removed. If desired, database column defaults can -be implemented by using the columnDefinition attribute of the @Column annotation (or the approriate XML and YAML equivalents). +be implemented by using the columnDefinition attribute of the @Column annotation (or the appropriate XML and YAML equivalents). Prefer PHP default values, if possible. ## Selecting Partial Objects @@ -432,7 +482,7 @@ With new required method AbstractTask::buildDocumentation, its implementation de * "doctrine schema-tool --drop" now always drops the complete database instead of only those tables defined by the current database model. The previous method had - problems when foreign keys of orphaned tables pointed to tables that were schedulded + problems when foreign keys of orphaned tables pointed to tables that were scheduled for deletion. * Use "doctrine schema-tool --update" to get a save incremental update for your database schema without deleting any unused tables, sequences or foreign keys. diff --git a/vendor/doctrine/orm/bin/doctrine-pear.php b/vendor/doctrine/orm/bin/doctrine-pear.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/bin/doctrine.bat b/vendor/doctrine/orm/bin/doctrine.bat old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/bin/doctrine.php b/vendor/doctrine/orm/bin/doctrine.php index 81edf294ff..c73556284f 100755 --- a/vendor/doctrine/orm/bin/doctrine.php +++ b/vendor/doctrine/orm/bin/doctrine.php @@ -13,31 +13,47 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ +use Symfony\Component\Console\Helper\HelperSet; +use Doctrine\ORM\Tools\Console\ConsoleRunner; + (@include_once __DIR__ . '/../vendor/autoload.php') || @include_once __DIR__ . '/../../../autoload.php'; -$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; -$helperSet = null; -if (file_exists($configFile)) { - if ( ! is_readable($configFile)) { - trigger_error( - 'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR - ); +$directories = array(getcwd(), getcwd() . DIRECTORY_SEPARATOR . 'config'); + +$configFile = null; +foreach ($directories as $directory) { + $configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php'; + + if (file_exists($configFile)) { + break; } +} - require $configFile; +if ( ! file_exists($configFile)) { + ConsoleRunner::printCliConfigTemplate(); + exit(1); +} +if ( ! is_readable($configFile)) { + echo 'Configuration file [' . $configFile . '] does not have read permission.' . "\n"; + exit(1); +} + +$commands = array(); + +$helperSet = require $configFile; + +if ( ! ($helperSet instanceof HelperSet)) { foreach ($GLOBALS as $helperSetCandidate) { - if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) { + if ($helperSetCandidate instanceof HelperSet) { $helperSet = $helperSetCandidate; break; } } } -$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet(); - -\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet); +\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet, $commands); diff --git a/vendor/doctrine/orm/build.properties b/vendor/doctrine/orm/build.properties deleted file mode 100755 index 37c834c0ec..0000000000 --- a/vendor/doctrine/orm/build.properties +++ /dev/null @@ -1,11 +0,0 @@ -# Project Name -project.name=DoctrineORM - -# Dependency minimum versions -dependencies.common=2.2.0beta1 -dependencies.dbal=2.2.0beta1 -dependencies.sfconsole=2.0.0 - -# Version class and file -project.version_class = Doctrine\ORM\Version -project.version_file = lib/Doctrine/ORM/Version.php diff --git a/vendor/doctrine/orm/build.properties.dev b/vendor/doctrine/orm/build.properties.dev deleted file mode 100755 index 20e91dc372..0000000000 --- a/vendor/doctrine/orm/build.properties.dev +++ /dev/null @@ -1,16 +0,0 @@ -version=2.0.0BETA2 -dependencies.common=2.0.0BETA4 -dependencies.dbal=2.0.0BETA4 -stability=beta -build.dir=build -dist.dir=dist -report.dir=reports -log.archive.dir=logs -project.pirum_dir= -project.download_dir= -project.xsd_dir= -test.phpunit_configuration_file= -test.phpunit_generate_coverage=0 -test.pmd_reports=0 -test.pdepend_exec= -test.phpmd_exec= \ No newline at end of file diff --git a/vendor/doctrine/orm/build.xml b/vendor/doctrine/orm/build.xml deleted file mode 100755 index 890ed05bc8..0000000000 --- a/vendor/doctrine/orm/build.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DoctrineORM - Doctrine Object Relational Mapper - pear.doctrine-project.org - The Doctrine ORM package is the primary package containing the object relational mapper. - - - - - LGPL - - - - - - - - - - - - - script - Doctrine/Common/ - Doctrine/DBAL/ - Symfony/Component/Yaml/ - Symfony/Component/Console/ - - - - - - - - - - diff --git a/vendor/doctrine/orm/composer.json b/vendor/doctrine/orm/composer.json old mode 100755 new mode 100644 index b413385790..25eedef1cd --- a/vendor/doctrine/orm/composer.json +++ b/vendor/doctrine/orm/composer.json @@ -1,6 +1,6 @@ { "name": "doctrine/orm", - "type": "library","version":"2.3.4", + "type": "library", "description": "Object-Relational-Mapper for PHP", "keywords": ["orm", "database"], "homepage": "http://www.doctrine-project.org", @@ -14,19 +14,27 @@ "require": { "php": ">=5.3.2", "ext-pdo": "*", - "doctrine/dbal": "2.3.*", - "symfony/console": "2.*" + "doctrine/collections": "~1.1", + "doctrine/dbal": "~2.4", + "symfony/console": "~2.0" + }, + "require-dev": { + "symfony/yaml": "~2.1", + "satooshi/php-coveralls": "dev-master" }, "suggest": { "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" }, "autoload": { - "psr-0": { "Doctrine\\ORM": "lib/" } + "psr-0": { "Doctrine\\ORM\\": "lib/" } }, "bin": ["bin/doctrine", "bin/doctrine.php"], "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "2.4.x-dev" } + }, + "archive": { + "exclude": ["!vendor", "tests", "*phpunit.xml", ".travis.yml", "build.xml", "build.properties", "composer.phar", "vendor/satooshi", "lib/vendor", "*.swp", "*coveralls.yml"] } } diff --git a/vendor/doctrine/orm/docs/README.md b/vendor/doctrine/orm/docs/README.md new file mode 100644 index 0000000000..4315116f88 --- /dev/null +++ b/vendor/doctrine/orm/docs/README.md @@ -0,0 +1,8 @@ +# Doctrine ORM Documentation + +## How to Generate + +1. Run ./bin/install-dependencies.sh +2. Run ./bin/generate-docs.sh + +It will generate the documentation into the build directory of the checkout. \ No newline at end of file diff --git a/vendor/doctrine/orm/docs/bin/generate-docs.sh b/vendor/doctrine/orm/docs/bin/generate-docs.sh new file mode 100755 index 0000000000..7d06d2a8dd --- /dev/null +++ b/vendor/doctrine/orm/docs/bin/generate-docs.sh @@ -0,0 +1,10 @@ +#!/bin/bash +EXECPATH=`dirname $0` +cd $EXECPATH +cd .. + +rm build -Rf +sphinx-build en build + +sphinx-build -b latex en build/pdf +rubber --into build/pdf --pdf build/pdf/Doctrine2ORM.tex \ No newline at end of file diff --git a/vendor/doctrine/orm/docs/bin/install-dependencies.sh b/vendor/doctrine/orm/docs/bin/install-dependencies.sh new file mode 100644 index 0000000000..86b3bdff7b --- /dev/null +++ b/vendor/doctrine/orm/docs/bin/install-dependencies.sh @@ -0,0 +1,4 @@ +#!/bin/bash +sudo apt-get install python25 python25-dev texlive-full rubber +sudo easy_install pygments +sudo easy_install sphinx \ No newline at end of file diff --git a/vendor/doctrine/orm/docs/en/Makefile b/vendor/doctrine/orm/docs/en/Makefile new file mode 100644 index 0000000000..a6f6fce620 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/Makefile @@ -0,0 +1,89 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Doctrine2ORM.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Doctrine2ORM.qhc" + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/vendor/doctrine/orm/docs/en/_exts/configurationblock.py b/vendor/doctrine/orm/docs/en/_exts/configurationblock.py new file mode 100644 index 0000000000..36ca61f5b1 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/_exts/configurationblock.py @@ -0,0 +1,93 @@ +#Copyright (c) 2010 Fabien Potencier +# +#Permission is hereby granted, free of charge, to any person obtaining a copy +#of this software and associated documentation files (the "Software"), to deal +#in the Software without restriction, including without limitation the rights +#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +#copies of the Software, and to permit persons to whom the Software is furnished +#to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all +#copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +#THE SOFTWARE. + +from docutils.parsers.rst import Directive, directives +from docutils import nodes +from string import upper + +class configurationblock(nodes.General, nodes.Element): + pass + +class ConfigurationBlock(Directive): + has_content = True + required_arguments = 0 + optional_arguments = 0 + final_argument_whitespace = True + option_spec = {} + formats = { + 'html': 'HTML', + 'xml': 'XML', + 'php': 'PHP', + 'yaml': 'YAML', + 'jinja': 'Twig', + 'html+jinja': 'Twig', + 'jinja+html': 'Twig', + 'php+html': 'PHP', + 'html+php': 'PHP', + 'ini': 'INI', + 'php-annotations': 'Annotations', + } + + def run(self): + env = self.state.document.settings.env + + node = nodes.Element() + node.document = self.state.document + self.state.nested_parse(self.content, self.content_offset, node) + + entries = [] + for i, child in enumerate(node): + if isinstance(child, nodes.literal_block): + # add a title (the language name) before each block + #targetid = "configuration-block-%d" % env.new_serialno('configuration-block') + #targetnode = nodes.target('', '', ids=[targetid]) + #targetnode.append(child) + + innernode = nodes.emphasis(self.formats[child['language']], self.formats[child['language']]) + + para = nodes.paragraph() + para += [innernode, child] + + entry = nodes.list_item('') + entry.append(para) + entries.append(entry) + + resultnode = configurationblock() + resultnode.append(nodes.bullet_list('', *entries)) + + return [resultnode] + +def visit_configurationblock_html(self, node): + self.body.append(self.starttag(node, 'div', CLASS='configuration-block')) + +def depart_configurationblock_html(self, node): + self.body.append('\n') + +def visit_configurationblock_latex(self, node): + pass + +def depart_configurationblock_latex(self, node): + pass + +def setup(app): + app.add_node(configurationblock, + html=(visit_configurationblock_html, depart_configurationblock_html), + latex=(visit_configurationblock_latex, depart_configurationblock_latex)) + app.add_directive('configuration-block', ConfigurationBlock) diff --git a/vendor/doctrine/orm/docs/en/conf.py b/vendor/doctrine/orm/docs/en/conf.py new file mode 100644 index 0000000000..5155ac9a6e --- /dev/null +++ b/vendor/doctrine/orm/docs/en/conf.py @@ -0,0 +1,201 @@ +# -*- coding: utf-8 -*- +# +# Doctrine 2 ORM documentation build configuration file, created by +# sphinx-quickstart on Fri Dec 3 18:10:24 2010. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.append(os.path.abspath('_exts')) + +# -- General configuration ----------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['configurationblock'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Doctrine 2 ORM' +copyright = u'2010-12, Doctrine Project Team' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '2' +# The full version, including alpha/beta/rc tags. +release = '2' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +language = 'en' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +show_authors = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'doctrine' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +html_theme_path = ['_theme'] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Doctrine2ORMdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'Doctrine2ORM.tex', u'Doctrine 2 ORM Documentation', + u'Doctrine Project Team', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True + +primary_domain = "dcorm" + +def linkcode_resolve(domain, info): + if domain == 'dcorm': + return 'http://' + return None diff --git a/vendor/doctrine/orm/docs/en/cookbook/advanced-field-value-conversion-using-custom-mapping-types.rst b/vendor/doctrine/orm/docs/en/cookbook/advanced-field-value-conversion-using-custom-mapping-types.rst new file mode 100644 index 0000000000..bc24cd3081 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/advanced-field-value-conversion-using-custom-mapping-types.rst @@ -0,0 +1,256 @@ +Advanced field value conversion using custom mapping types +========================================================== + +.. sectionauthor:: Jan Sorgalla + +When creating entities, you sometimes have the need to transform field values +before they are saved to the database. In Doctrine you can use Custom Mapping +Types to solve this (see: :ref:`reference-basic-mapping-custom-mapping-types`). + +There are several ways to achieve this: converting the value inside the Type +class, converting the value on the database-level or a combination of both. + +This article describes the third way by implementing the MySQL specific column +type `Point `_. + +The ``Point`` type is part of the `Spatial extension `_ +of MySQL and enables you to store a single location in a coordinate space by +using x and y coordinates. You can use the Point type to store a +longitude/latitude pair to represent a geographic location. + +The entity +---------- + +We create a simple entity with a field ``$point`` which holds a value object +``Point`` representing the latitude and longitude of the position. + +The entity class: + +.. code-block:: php + + point = $point; + } + + /** + * @return \Geo\ValueObject\Point + */ + public function getPoint() + { + return $this->point; + } + + /** + * @param string $address + */ + public function setAddress($address) + { + $this->address = $address; + } + + /** + * @return string + */ + public function getAddress() + { + return $this->address; + } + } + +We use the custom type ``point`` in the ``@Column`` docblock annotation of the +``$point`` field. We will create this custom mapping type in the next chapter. + +The point class: + +.. code-block:: php + + latitude = $latitude; + $this->longitude = $longitude; + } + + /** + * @return float + */ + public function getLatitude() + { + return $this->latitude; + } + + /** + * @return float + */ + public function getLongitude() + { + return $this->longitude; + } + } + +The mapping type +---------------- + +Now we're going to create the ``point`` type and implement all required methods. + +.. code-block:: php + + getLongitude(), $value->getLatitude()); + } + + return $value; + } + + public function canRequireSQLConversion() + { + return true; + } + + public function convertToPHPValueSQL($sqlExpr, AbstractPlatform $platform) + { + return sprintf('AsText(%s)', $sqlExpr); + } + + public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) + { + return sprintf('PointFromText(%s)', $sqlExpr); + } + } + +We do a 2-step conversion here. In the first step, we convert the ``Point`` +object into a string representation before saving to the database (in the +``convertToDatabaseValue`` method) and back into an object after fetching the +value from the database (in the ``convertToPHPValue`` method). + +The format of the string representation format is called `Well-known text (WKT) +`_. The advantage of this format +is, that it is both human readable and parsable by MySQL. + +Internally, MySQL stores geometry values in a binary format that is not +identical to the WKT format. So, we need to let MySQL transform the WKT +representation into its internal format. + +This is where the ``convertToPHPValueSQL`` and ``convertToDatabaseValueSQL`` +methods come into play. + +This methods wrap a sql expression (the WKT representation of the Point) into +MySQL functions `PointFromText `_ +and `AsText `_ +which convert WKT strings to and from the internal format of MySQL. + +.. note:: + + When using DQL queries, the ``convertToPHPValueSQL`` and + ``convertToDatabaseValueSQL`` methods only apply to identification variables + and path expressions in SELECT clauses. Expressions in WHERE clauses are + **not** wrapped! + + If you want to use Point values in WHERE clauses, you have to implement a + :doc:`user defined function ` for + ``PointFromText``. + +Example usage +------------- + +.. code-block:: php + + getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point'); + + // Store a Location object + use Geo\Entity\Location; + use Geo\ValueObject\Point; + + $location = new Location(); + + $location->setAddress('1600 Amphitheatre Parkway, Mountain View, CA'); + $location->setPoint(new Point(37.4220761, -122.0845187)); + + $em->persist($location); + $em->flush(); + $em->clear(); + + // Fetch the Location object + $query = $em->createQuery("SELECT l FROM Geo\Entity\Location WHERE l.address = '1600 Amphitheatre Parkway, Mountain View, CA'"); + $location = $query->getSingleResult(); + + /* @var Geo\ValueObject\Point */ + $point = $location->getPoint(); diff --git a/vendor/doctrine/orm/docs/en/cookbook/aggregate-fields.rst b/vendor/doctrine/orm/docs/en/cookbook/aggregate-fields.rst new file mode 100644 index 0000000000..5d0981b06c --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/aggregate-fields.rst @@ -0,0 +1,376 @@ +Aggregate Fields +================ + +.. sectionauthor:: Benjamin Eberlei + +You will often come across the requirement to display aggregate +values of data that can be computed by using the MIN, MAX, COUNT or +SUM SQL functions. For any ORM this is a tricky issue +traditionally. Doctrine 2 offers several ways to get access to +these values and this article will describe all of them from +different perspectives. + +You will see that aggregate fields can become very explicit +features in your domain model and how this potentially complex +business rules can be easily tested. + +An example model +---------------- + +Say you want to model a bank account and all their entries. Entries +into the account can either be of positive or negative money +values. Each account has a credit limit and the account is never +allowed to have a balance below that value. + +For simplicity we live in a world were money is composed of +integers only. Also we omit the receiver/sender name, stated reason +for transfer and the execution date. These all would have to be +added on the ``Entry`` object. + +Our entities look like: + +.. code-block:: php + + no = $no; + $this->maxCredit = $maxCredit; + $this->entries = new \Doctrine\Common\Collections\ArrayCollection(); + } + } + + /** + * @Entity + */ + class Entry + { + /** @Id @GeneratedValue @Column(type="integer") */ + private $id; + + /** + * @ManyToOne(targetEntity="Account", inversedBy="entries") + */ + private $account; + + /** + * @Column(type="integer") + */ + private $amount; + + public function __construct($account, $amount) + { + $this->account = $account; + $this->amount = $amount; + // more stuff here, from/to whom, stated reason, execution date and such + } + + public function getAmount() + { + return $this->amount; + } + } + +Using DQL +--------- + +The Doctrine Query Language allows you to select for aggregate +values computed from fields of your Domain Model. You can select +the current balance of your account by calling: + +.. code-block:: php + + createQuery($dql) + ->setParameter(1, $myAccountId) + ->getSingleScalarResult(); + +The ``$em`` variable in this (and forthcoming) example holds the +Doctrine ``EntityManager``. We create a query for the SUM of all +amounts (negative amounts are withdraws) and retrieve them as a +single scalar result, essentially return only the first column of +the first row. + +This approach is simple and powerful, however it has a serious +drawback. We have to execute a specific query for the balance +whenever we need it. + +To implement a powerful domain model we would rather have access to +the balance from our ``Account`` entity during all times (even if +the Account was not persisted in the database before!). + +Also an additional requirement is the max credit per ``Account`` +rule. + +We cannot reliably enforce this rule in our ``Account`` entity with +the DQL retrieval of the balance. There are many different ways to +retrieve accounts. We cannot guarantee that we can execute the +aggregation query for all these use-cases, let alone that a +userland programmer checks this balance against newly added +entries. + +Using your Domain Model +----------------------- + +``Account`` and all the ``Entry`` instances are connected through a +collection, which means we can compute this value at runtime: + +.. code-block:: php + + entries AS $entry) { + $balance += $entry->getAmount(); + } + return $balance; + } + } + +Now we can always call ``Account::getBalance()`` to access the +current account balance. + +To enforce the max credit rule we have to implement the "Aggregate +Root" pattern as described in Eric Evans book on Domain Driven +Design. Described with one sentence, an aggregate root controls the +instance creation, access and manipulation of its children. + +In our case we want to enforce that new entries can only added to +the ``Account`` by using a designated method. The ``Account`` is +the aggregate root of this relation. We can also enforce the +correctness of the bi-directional ``Account`` <-> ``Entry`` +relation with this method: + +.. code-block:: php + + assertAcceptEntryAllowed($amount); + + $e = new Entry($this, $amount); + $this->entries[] = $e; + return $e; + } + } + +Now look at the following test-code for our entities: + +.. code-block:: php + + assertEquals(0, $account->getBalance()); + + $account->addEntry(500); + $this->assertEquals(500, $account->getBalance()); + + $account->addEntry(-700); + $this->assertEquals(-200, $account->getBalance()); + } + + public function testExceedMaxLimit() + { + $account = new Account("123456", $maxCredit = 200); + + $this->setExpectedException("Exception"); + $account->addEntry(-1000); + } + } + +To enforce our rule we can now implement the assertion in +``Account::addEntry``: + +.. code-block:: php + + getBalance() + $amount; + $allowedMinimalBalance = ($this->maxCredit * -1); + if ($futureBalance < $allowedMinimalBalance) { + throw new Exception("Credit Limit exceeded, entry is not allowed!"); + } + } + } + +We haven't talked to the entity manager for persistence of our +account example before. You can call +``EntityManager::persist($account)`` and then +``EntityManager::flush()`` at any point to save the account to the +database. All the nested ``Entry`` objects are automatically +flushed to the database also. + +.. code-block:: php + + addEntry(500); + $account->addEntry(-200); + $em->persist($account); + $em->flush(); + +The current implementation has a considerable drawback. To get the +balance, we have to initialize the complete ``Account::$entries`` +collection, possibly a very large one. This can considerably hurt +the performance of your application. + +Using an Aggregate Field +------------------------ + +To overcome the previously mentioned issue (initializing the whole +entries collection) we want to add an aggregate field called +"balance" on the Account and adjust the code in +``Account::getBalance()`` and ``Account:addEntry()``: + +.. code-block:: php + + balance; + } + + public function addEntry($amount) + { + $this->assertAcceptEntryAllowed($amount); + + $e = new Entry($this, $amount); + $this->entries[] = $e; + $this->balance += $amount; + return $e; + } + } + +This is a very simple change, but all the tests still pass. Our +account entities return the correct balance. Now calling the +``Account::getBalance()`` method will not occur the overhead of +loading all entries anymore. Adding a new Entry to the +``Account::$entities`` will also not initialize the collection +internally. + +Adding a new entry is therefore very performant and explicitly +hooked into the domain model. It will only update the account with +the current balance and insert the new entry into the database. + +Tackling Race Conditions with Aggregate Fields +---------------------------------------------- + +Whenever you denormalize your database schema race-conditions can +potentially lead to inconsistent state. See this example: + +.. code-block:: php + + find('Bank\Entities\Account', $accId); + + // request 2 account + $account2 = $em->find('Bank\Entities\Account', $accId); + + $account1->addEntry(-200); + $account2->addEntry(-200); + + // now request 1 and 2 both flush the changes. + +The aggregate field ``Account::$balance`` is now -200, however the +SUM over all entries amounts yields -400. A violation of our max +credit rule. + +You can use both optimistic or pessimistic locking to save-guard +your aggregate fields against this kind of race-conditions. Reading +Eric Evans DDD carefully he mentions that the "Aggregate Root" +(Account in our example) needs a locking mechanism. + +Optimistic locking is as easy as adding a version column: + +.. code-block:: php + + find('Bank\Entities\Account', $accId, LockMode::PESSIMISTIC_READ); + +Keeping Updates and Deletes in Sync +----------------------------------- + +The example shown in this article does not allow changes to the +value in ``Entry``, which considerably simplifies the effort to +keep ``Account::$balance`` in sync. If your use-case allows fields +to be updated or related entities to be removed you have to +encapsulate this logic in your "Aggregate Root" entity and adjust +the aggregate field accordingly. + +Conclusion +---------- + +This article described how to obtain aggregate values using DQL or +your domain model. It showed how you can easily add an aggregate +field that offers serious performance benefits over iterating all +the related objects that make up an aggregate value. Finally I +showed how you can ensure that your aggregate fields do not get out +of sync due to race-conditions and concurrent access. + + diff --git a/vendor/doctrine/orm/docs/en/cookbook/decorator-pattern.rst b/vendor/doctrine/orm/docs/en/cookbook/decorator-pattern.rst new file mode 100644 index 0000000000..49d13b719e --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/decorator-pattern.rst @@ -0,0 +1,273 @@ +Persisting the Decorator Pattern +================================ + +.. sectionauthor:: Chris Woodford + +This recipe will show you a simple example of how you can use +Doctrine 2 to persist an implementation of the +`Decorator Pattern `_ + +Component +--------- + +The ``Component`` class needs to be persisted, so it's going to +be an ``Entity``. As the top of the inheritance hierarchy, it's going +to have to define the persistent inheritance. For this example, we +will use Single Table Inheritance, but Class Table Inheritance +would work as well. In the discriminator map, we will define two +concrete subclasses, ``ConcreteComponent`` and ``ConcreteDecorator``. + +.. code-block:: php + + id; + } + + /** + * Set name + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * Get name + * @return string $name + */ + public function getName() + { + return $this->name; + } + + } + +ConcreteComponent +----------------- + +The ``ConcreteComponent`` class is pretty simple and doesn't do much +more than extend the abstract ``Component`` class (only for the +purpose of keeping this example simple). + +.. code-block:: php + + setDecorates($c); + } + + /** + * (non-PHPdoc) + * @see Test.Component::getName() + */ + public function getName() + { + return 'Decorated ' . $this->getDecorates()->getName(); + } + + /** + * the component being decorated + * @return Component + */ + protected function getDecorates() + { + return $this->decorates; + } + + /** + * sets the component being decorated + * @param Component $c + */ + protected function setDecorates(Component $c) + { + $this->decorates = $c; + } + + } + +All operations on the ``Decorator`` (i.e. persist, remove, etc) will +cascade from the ``Decorator`` to the ``Component``. This means that +when we persist a ``Decorator``, Doctrine will take care of +persisting the chain of decorated objects for us. A ``Decorator`` can +be treated exactly as a ``Component`` when it comes time to +persisting it. + +The ``Decorator's`` constructor accepts an instance of a +``Component``, as defined by the ``Decorator`` pattern. The +setDecorates/getDecorates methods have been defined as protected to +hide the fact that a ``Decorator`` is decorating a ``Component`` and +keeps the ``Component`` interface and the ``Decorator`` interface +identical. + +To illustrate the intended result of the ``Decorator`` pattern, the +getName() method has been overridden to append a string to the +``Component's`` getName() method. + +ConcreteDecorator +----------------- + +The final class required to complete a simple implementation of the +Decorator pattern is the ``ConcreteDecorator``. In order to further +illustrate how the ``Decorator`` can alter data as it moves through +the chain of decoration, a new field, "special", has been added to +this class. The getName() has been overridden and appends the value +of the getSpecial() method to its return value. + +.. code-block:: php + + special = $special; + } + + /** + * Get special + * @return string $special + */ + public function getSpecial() + { + return $this->special; + } + + /** + * (non-PHPdoc) + * @see Test.Component::getName() + */ + public function getName() + { + return '[' . $this->getSpecial() + . '] ' . parent::getName(); + } + + } + +Examples +-------- + +Here is an example of how to persist and retrieve your decorated +objects + +.. code-block:: php + + setName('Test Component 1'); + $em->persist($c); // assigned unique ID = 1 + + // create a new concrete decorator + $c = new ConcreteComponent(); + $c->setName('Test Component 2'); + + $d = new ConcreteDecorator($c); + $d->setSpecial('Really'); + $em->persist($d); + // assigns c as unique ID = 2, and d as unique ID = 3 + + $em->flush(); + + $c = $em->find('Test\Component', 1); + $d = $em->find('Test\Component', 3); + + echo get_class($c); + // prints: Test\Component\ConcreteComponent + + echo $c->getName(); + // prints: Test Component 1 + + echo get_class($d) + // prints: Test\Component\ConcreteDecorator + + echo $d->getName(); + // prints: [Really] Decorated Test Component 2 + diff --git a/vendor/doctrine/orm/docs/en/cookbook/dql-custom-walkers.rst b/vendor/doctrine/orm/docs/en/cookbook/dql-custom-walkers.rst new file mode 100644 index 0000000000..2887a5d685 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/dql-custom-walkers.rst @@ -0,0 +1,217 @@ +Extending DQL in Doctrine 2: Custom AST Walkers +=============================================== + +.. sectionauthor:: Benjamin Eberlei + +The Doctrine Query Language (DQL) is a proprietary sql-dialect that +substitutes tables and columns for Entity names and their fields. +Using DQL you write a query against the database using your +entities. With the help of the metadata you can write very concise, +compact and powerful queries that are then translated into SQL by +the Doctrine ORM. + +In Doctrine 1 the DQL language was not implemented using a real +parser. This made modifications of the DQL by the user impossible. +Doctrine 2 in contrast has a real parser for the DQL language, +which transforms the DQL statement into an +`Abstract Syntax Tree `_ +and generates the appropriate SQL statement for it. Since this +process is deterministic Doctrine heavily caches the SQL that is +generated from any given DQL query, which reduces the performance +overhead of the parsing process to zero. + +You can modify the Abstract syntax tree by hooking into DQL parsing +process by adding a Custom Tree Walker. A walker is an interface +that walks each node of the Abstract syntax tree, thereby +generating the SQL statement. + +There are two types of custom tree walkers that you can hook into +the DQL parser: + + +- An output walker. This one actually generates the SQL, and there + is only ever one of them. We implemented the default SqlWalker + implementation for it. +- A tree walker. There can be many tree walkers, they cannot + generate the sql, however they can modify the AST before its + rendered to sql. + +Now this is all awfully technical, so let me come to some use-cases +fast to keep you motivated. Using walker implementation you can for +example: + + +- Modify the AST to generate a Count Query to be used with a + paginator for any given DQL query. +- Modify the Output Walker to generate vendor-specific SQL + (instead of ANSI). +- Modify the AST to add additional where clauses for specific + entities (example ACL, country-specific content...) +- Modify the Output walker to pretty print the SQL for debugging + purposes. + +In this cookbook-entry I will show examples on the first two +points. There are probably much more use-cases. + +Generic count query for pagination +---------------------------------- + +Say you have a blog and posts all with one category and one author. +A query for the front-page or any archive page might look something +like: + +.. code-block:: sql + + SELECT p, c, a FROM BlogPost p JOIN p.category c JOIN p.author a WHERE ... + +Now in this query the blog post is the root entity, meaning its the +one that is hydrated directly from the query and returned as an +array of blog posts. In contrast the comment and author are loaded +for deeper use in the object tree. + +A pagination for this query would want to approximate the number of +posts that match the WHERE clause of this query to be able to +predict the number of pages to show to the user. A draft of the DQL +query for pagination would look like: + +.. code-block:: sql + + SELECT count(DISTINCT p.id) FROM BlogPost p JOIN p.category c JOIN p.author a WHERE ... + +Now you could go and write each of these queries by hand, or you +can use a tree walker to modify the AST for you. Lets see how the +API would look for this use-case: + +.. code-block:: php + + createQuery($dql); + $query->setFirstResult( ($pageNum-1) * 20)->setMaxResults(20); + + $totalResults = Paginate::count($query); + $results = $query->getResult(); + +The ``Paginate::count(Query $query)`` looks like: + +.. code-block:: php + + setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('DoctrineExtensions\Paginate\CountSqlWalker')); + $countQuery->setFirstResult(null)->setMaxResults(null); + + return $countQuery->getSingleScalarResult(); + } + } + +It clones the query, resets the limit clause first and max results +and registers the ``CountSqlWalker`` customer tree walker which +will modify the AST to execute a count query. The walkers +implementation is: + +.. code-block:: php + + _getQueryComponents() AS $dqlAlias => $qComp) { + if ($qComp['parent'] === null && $qComp['nestingLevel'] == 0) { + $parent = $qComp; + $parentName = $dqlAlias; + break; + } + } + + $pathExpression = new PathExpression( + PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $parentName, + $parent['metadata']->getSingleIdentifierFieldName() + ); + $pathExpression->type = PathExpression::TYPE_STATE_FIELD; + + $AST->selectClause->selectExpressions = array( + new SelectExpression( + new AggregateExpression('count', $pathExpression, true), null + ) + ); + } + } + +This will delete any given select expressions and replace them with +a distinct count query for the root entities primary key. This will +only work if your entity has only one identifier field (composite +keys won't work). + +Modify the Output Walker to generate Vendor specific SQL +-------------------------------------------------------- + +Most RMDBS have vendor-specific features for optimizing select +query execution plans. You can write your own output walker to +introduce certain keywords using the Query Hint API. A query hint +can be set via ``Query::setHint($name, $value)`` as shown in the +previous example with the ``HINT_CUSTOM_TREE_WALKERS`` query hint. + +We will implement a custom Output Walker that allows to specify the +SQL\_NO\_CACHE query hint. + +.. code-block:: php + + createQuery($dql); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'DoctrineExtensions\Query\MysqlWalker'); + $query->setHint("mysqlWalker.sqlNoCache", true); + $results = $query->getResult(); + +Our ``MysqlWalker`` will extend the default ``SqlWalker``. We will +modify the generation of the SELECT clause, adding the +SQL\_NO\_CACHE on those queries that need it: + +.. code-block:: php + + getQuery()->getHint('mysqlWalker.sqlNoCache') === true) { + if ($selectClause->isDistinct) { + $sql = str_replace('SELECT DISTINCT', 'SELECT DISTINCT SQL_NO_CACHE', $sql); + } else { + $sql = str_replace('SELECT', 'SELECT SQL_NO_CACHE', $sql); + } + } + + return $sql; + } + } + +Writing extensions to the Output Walker requires a very deep +understanding of the DQL Parser and Walkers, but may offer your +huge benefits with using vendor specific features. This would still +allow you write DQL queries instead of NativeQueries to make use of +vendor specific features. + diff --git a/vendor/doctrine/orm/docs/en/cookbook/dql-user-defined-functions.rst b/vendor/doctrine/orm/docs/en/cookbook/dql-user-defined-functions.rst new file mode 100644 index 0000000000..77d66ad822 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/dql-user-defined-functions.rst @@ -0,0 +1,240 @@ +DQL User Defined Functions +========================== + +.. sectionauthor:: Benjamin Eberlei + +By default DQL supports a limited subset of all the vendor-specific +SQL functions common between all the vendors. However in many cases +once you have decided on a specific database vendor, you will never +change it during the life of your project. This decision for a +specific vendor potentially allows you to make use of powerful SQL +features that are unique to the vendor. + +It is worth to mention that Doctrine 2 also allows you to handwrite +your SQL instead of extending the DQL parser. Extending DQL is sort of an +advanced extension point. You can map arbitrary SQL to your objects +and gain access to vendor specific functionalities using the +``EntityManager#createNativeQuery()`` API as described in +the :doc:`Native Query <../reference/native-sql>` chapter. + + +The DQL Parser has hooks to register functions that can then be +used in your DQL queries and transformed into SQL, allowing to +extend Doctrines Query capabilities to the vendors strength. This +post explains the Used-Defined Functions API (UDF) of the Dql +Parser and shows some examples to give you some hints how you would +extend DQL. + +There are three types of functions in DQL, those that return a +numerical value, those that return a string and those that return a +Date. Your custom method has to be registered as either one of +those. The return type information is used by the DQL parser to +check possible syntax errors during the parsing process, for +example using a string function return value in a math expression. + +Registering your own DQL functions +---------------------------------- + +You can register your functions adding them to the ORM +configuration: + +.. code-block:: php + + addCustomStringFunction($name, $class); + $config->addCustomNumericFunction($name, $class); + $config->addCustomDatetimeFunction($name, $class); + + $em = EntityManager::create($dbParams, $config); + +The ``$name`` is the name the function will be referred to in the +DQL query. ``$class`` is a string of a class-name which has to +extend ``Doctrine\ORM\Query\Node\FunctionNode``. This is a class +that offers all the necessary API and methods to implement a UDF. + +In this post we will implement some MySql specific Date calculation +methods, which are quite handy in my opinion: + +Date Diff +--------- + +`Mysql's DateDiff function `_ +takes two dates as argument and calculates the difference in days +with ``date1-date2``. + +The DQL parser is a top-down recursive descent parser to generate +the Abstract-Syntax Tree (AST) and uses a TreeWalker approach to +generate the appropriate SQL from the AST. This makes reading the +Parser/TreeWalker code manageable in a finite amount of time. + +The ``FunctionNode`` class I referred to earlier requires you to +implement two methods, one for the parsing process (obviously) +called ``parse`` and one for the TreeWalker process called +``getSql()``. I show you the code for the DateDiff method and +discuss it step by step: + +.. code-block:: php + + match(Lexer::T_IDENTIFIER); // (2) + $parser->match(Lexer::T_OPEN_PARENTHESIS); // (3) + $this->firstDateExpression = $parser->ArithmeticPrimary(); // (4) + $parser->match(Lexer::T_COMMA); // (5) + $this->secondDateExpression = $parser->ArithmeticPrimary(); // (6) + $parser->match(Lexer::T_CLOSE_PARENTHESIS); // (3) + } + + public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) + { + return 'DATEDIFF(' . + $this->firstDateExpression->dispatch($sqlWalker) . ', ' . + $this->secondDateExpression->dispatch($sqlWalker) . + ')'; // (7) + } + } + +The Parsing process of the DATEDIFF function is going to find two +expressions the date1 and the date2 values, whose AST Node +representations will be saved in the variables of the DateDiff +FunctionNode instance at (1). + +The parse() method has to cut the function call "DATEDIFF" and its +argument into pieces. Since the parser detects the function using a +lookahead the T\_IDENTIFIER of the function name has to be taken +from the stack (2), followed by a detection of the arguments in +(4)-(6). The opening and closing parenthesis have to be detected +also. This happens during the Parsing process and leads to the +generation of a DateDiff FunctionNode somewhere in the AST of the +dql statement. + +The ``ArithmeticPrimary`` method call is the most common +denominator of valid EBNF tokens taken from the +`DQL EBNF grammar `_ +that matches our requirements for valid input into the DateDiff Dql +function. Picking the right tokens for your methods is a tricky +business, but the EBNF grammar is pretty helpful finding it, as is +looking at the Parser source code. + +Now in the TreeWalker process we have to pick up this node and +generate SQL from it, which apparently is quite easy looking at the +code in (7). Since we don't know which type of AST Node the first +and second Date expression are we are just dispatching them back to +the SQL Walker to generate SQL from and then wrap our DATEDIFF +function call around this output. + +Now registering this DateDiff FunctionNode with the ORM using: + +.. code-block:: php + + addCustomStringFunction('DATEDIFF', 'DoctrineExtensions\Query\MySql\DateDiff'); + +We can do fancy stuff like: + +.. code-block:: sql + + SELECT p FROM DoctrineExtensions\Query\BlogPost p WHERE DATEDIFF(CURRENT_TIME(), p.created) < 7 + +Date Add +-------- + +Often useful it the ability to do some simple date calculations in +your DQL query using +`MySql's DATE\_ADD function `_. + +I'll skip the blah and show the code for this function: + +.. code-block:: php + + match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OPEN_PARENTHESIS); + + $this->firstDateExpression = $parser->ArithmeticPrimary(); + + $parser->match(Lexer::T_COMMA); + $parser->match(Lexer::T_IDENTIFIER); + + $this->intervalExpression = $parser->ArithmeticPrimary(); + + $parser->match(Lexer::T_IDENTIFIER); + + /* @var $lexer Lexer */ + $lexer = $parser->getLexer(); + $this->unit = $lexer->token['value']; + + $parser->match(Lexer::T_CLOSE_PARENTHESIS); + } + + public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) + { + return 'DATE_ADD(' . + $this->firstDateExpression->dispatch($sqlWalker) . ', INTERVAL ' . + $this->intervalExpression->dispatch($sqlWalker) . ' ' . $this->unit . + ')'; + } + } + +The only difference compared to the DATEDIFF here is, we +additionally need the ``Lexer`` to access the value of the +``T_IDENTIFIER`` token for the Date Interval unit, for example the +MONTH in: + +.. code-block:: sql + + SELECT p FROM DoctrineExtensions\Query\BlogPost p WHERE DATE_ADD(CURRENT_TIME(), INTERVAL 4 MONTH) > p.created + +The above method now only supports the specification using +``INTERVAL``, to also allow a real date in DATE\_ADD we need to add +some decision logic to the parsing process (makes up for a nice +exercise). + +Now as you see, the Parsing process doesn't catch all the possible +SQL errors, here we don't match for all the valid inputs for the +interval unit. However where necessary we rely on the database +vendors SQL parser to show us further errors in the parsing +process, for example if the Unit would not be one of the supported +values by MySql. + +Conclusion +---------- + +Now that you all know how you can implement vendor specific SQL +functionalities in DQL, we would be excited to see user extensions +that add vendor specific function packages, for example more math +functions, XML + GIS Support, Hashing functions and so on. + +For 2.0 we will come with the current set of functions, however for +a future version we will re-evaluate if we can abstract even more +vendor sql functions and extend the DQL languages scope. + +Code for this Extension to DQL and other Doctrine Extensions can be +found +`in my Github DoctrineExtensions repository `_. + + diff --git a/vendor/doctrine/orm/docs/en/cookbook/entities-in-session.rst b/vendor/doctrine/orm/docs/en/cookbook/entities-in-session.rst new file mode 100644 index 0000000000..664cff53f5 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/entities-in-session.rst @@ -0,0 +1,68 @@ +Entities in the Session +======================= + +There are several use-cases to save entities in the session, for example: + +1. User object +2. Multi-step forms + +To achieve this with Doctrine you have to pay attention to some details to get +this working. + +Merging entity into an EntityManager +------------------------------------ + +In Doctrine an entity objects has to be "managed" by an EntityManager to be +updateable. Entities saved into the session are not managed in the next request +anymore. This means that you have to register these entities with an +EntityManager again if you want to change them or use them as part of +references between other entities. You can achieve this by calling +``EntityManager#merge()``. + +For a representative User object the code to get turn an instance from +the session into a managed Doctrine object looks like this: + +.. code-block:: php + + merge($user); + } + +.. note:: + + A frequent mistake is not to get the merged user object from the return + value of ``EntityManager#merge()``. The entity object passed to merge is + not necessarily the same object that is returned from the method. + +Serializing entity into the session +----------------------------------- + +Entities that are serialized into the session normally contain references to +other entities as well. Think of the user entity has a reference to his +articles, groups, photos or many other different entities. If you serialize +this object into the session then you don't want to serialize the related +entities as well. This is why you should call ``EntityManager#detach()`` on this +object or implement the __sleep() magic method on your entity. + +.. code-block:: php + + find("User", 1); + $em->detach($user); + $_SESSION['user'] = $user; + +.. note:: + + When you called detach on your objects they get "unmanaged" with that + entity manager. This means you cannot use them as part of write operations + during ``EntityManager#flush()`` anymore in this request. + diff --git a/vendor/doctrine/orm/docs/en/cookbook/implementing-arrayaccess-for-domain-objects.rst b/vendor/doctrine/orm/docs/en/cookbook/implementing-arrayaccess-for-domain-objects.rst new file mode 100644 index 0000000000..4eb2b717bf --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/implementing-arrayaccess-for-domain-objects.rst @@ -0,0 +1,112 @@ +Implementing ArrayAccess for Domain Objects +=========================================== + +.. sectionauthor:: Roman Borschel (roman@code-factory.org) + +This recipe will show you how to implement ArrayAccess for your +domain objects in order to allow more uniform access, for example +in templates. In these examples we will implement ArrayAccess on a +`Layer Supertype `_ +for all our domain objects. + +Option 1 +-------- + +In this implementation we will make use of PHPs highly dynamic +nature to dynamically access properties of a subtype in a supertype +at runtime. Note that this implementation has 2 main caveats: + + +- It will not work with private fields +- It will not go through any getters/setters + +.. code-block:: php + + $offset); + } + + public function offsetSet($offset, $value) { + $this->$offset = $value; + } + + public function offsetGet($offset) { + return $this->$offset; + } + + public function offsetUnset($offset) { + $this->$offset = null; + } + } + +Option 2 +-------- + +In this implementation we will dynamically invoke getters/setters. +Again we use PHPs dynamic nature to invoke methods on a subtype +from a supertype at runtime. This implementation has the following +caveats: + + +- It relies on a naming convention +- The semantics of offsetExists can differ +- offsetUnset will not work with typehinted setters + +.. code-block:: php + + {"get$offset"}(); + return $value !== null; + } + + public function offsetSet($offset, $value) { + $this->{"set$offset"}($value); + } + + public function offsetGet($offset) { + return $this->{"get$offset"}(); + } + + public function offsetUnset($offset) { + $this->{"set$offset"}(null); + } + } + +Read-only +--------- + +You can slightly tweak option 1 or option 2 in order to make array +access read-only. This will also circumvent some of the caveats of +each option. Simply make offsetSet and offsetUnset throw an +exception (i.e. BadMethodCallException). + +.. code-block:: php + + `_ +for all our domain objects. + +Implementing NotifyPropertyChanged +---------------------------------- + +The NOTIFY policy is based on the assumption that the entities +notify interested listeners of changes to their properties. For +that purpose, a class that wants to use this policy needs to +implement the ``NotifyPropertyChanged`` interface from the +``Doctrine\Common`` namespace. + +.. code-block:: php + + listeners[] = $listener; + } + + /** Notifies listeners of a change. */ + protected function onPropertyChanged($propName, $oldValue, $newValue) { + if ($this->listeners) { + foreach ($this->listeners as $listener) { + $listener->propertyChanged($this, $propName, $oldValue, $newValue); + } + } + } + } + +Then, in each property setter of concrete, derived domain classes, +you need to invoke onPropertyChanged as follows to notify +listeners: + +.. code-block:: php + + data) { // check: is it actually modified? + $this->onPropertyChanged('data', $this->data, $data); + $this->data = $data; + } + } + } + +The check whether the new value is different from the old one is +not mandatory but recommended. That way you can avoid unnecessary +updates and also have full control over when you consider a +property changed. + + diff --git a/vendor/doctrine/orm/docs/en/cookbook/implementing-wakeup-or-clone.rst b/vendor/doctrine/orm/docs/en/cookbook/implementing-wakeup-or-clone.rst new file mode 100644 index 0000000000..6a8ef9c91a --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/implementing-wakeup-or-clone.rst @@ -0,0 +1,78 @@ +Implementing Wakeup or Clone +============================ + +.. sectionauthor:: Roman Borschel (roman@code-factory.org) + +As explained in the +`restrictions for entity classes in the manual `_, +it is usually not allowed for an entity to implement ``__wakeup`` +or ``__clone``, because Doctrine makes special use of them. +However, it is quite easy to make use of these methods in a safe +way by guarding the custom wakeup or clone code with an entity +identity check, as demonstrated in the following sections. + +Safely implementing \_\_wakeup +------------------------------ + +To safely implement ``__wakeup``, simply enclose your +implementation code in an identity check as follows: + +.. code-block:: php + + id) { + // ... Your code here as normal ... + } + // otherwise do nothing, do NOT throw an exception! + } + + //... + } + +Safely implementing \_\_clone +----------------------------- + +Safely implementing ``__clone`` is pretty much the same: + +.. code-block:: php + + id) { + // ... Your code here as normal ... + } + // otherwise do nothing, do NOT throw an exception! + } + + //... + } + +Summary +------- + +As you have seen, it is quite easy to safely make use of +``__wakeup`` and ``__clone`` in your entities without adding any +really Doctrine-specific or Doctrine-dependant code. + +These implementations are possible and safe because when Doctrine +invokes these methods, the entities never have an identity (yet). +Furthermore, it is possibly a good idea to check for the identity +in your code anyway, since it's rarely the case that you want to +unserialize or clone an entity with no identity. + + diff --git a/vendor/doctrine/orm/docs/en/cookbook/integrating-with-codeigniter.rst b/vendor/doctrine/orm/docs/en/cookbook/integrating-with-codeigniter.rst new file mode 100644 index 0000000000..1c06a34e2c --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/integrating-with-codeigniter.rst @@ -0,0 +1,140 @@ +Integrating with CodeIgniter +============================ + +This is recipe for using Doctrine 2 in your +`CodeIgniter `_ framework. + +.. note:: + + This might not work for all CodeIgniter versions and may require + slight adjustments. + + +Here is how to set it up: + +Make a CodeIgniter library that is both a wrapper and a bootstrap +for Doctrine 2. + +Setting up the file structure +----------------------------- + +Here are the steps: + + +- Add a php file to your system/application/libraries folder + called Doctrine.php. This is going to be your wrapper/bootstrap for + the D2 entity manager. +- Put the Doctrine folder (the one that contains Common, DBAL, and + ORM) inside that same libraries folder. +- Your system/application/libraries folder now looks like this: + + system/applications/libraries -Doctrine -Doctrine.php -index.html + +- If you want, open your config/autoload.php file and autoload + your Doctrine library. + + register(); + $entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/" )); + $entitiesClassLoader->register(); + $proxiesClassLoader = new ClassLoader('Proxies', APPPATH.'models/proxies'); + $proxiesClassLoader->register(); + + // Set up caches + $config = new Configuration; + $cache = new ArrayCache; + $config->setMetadataCacheImpl($cache); + $driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH.'models/Entities')); + $config->setMetadataDriverImpl($driverImpl); + $config->setQueryCacheImpl($cache); + + $config->setQueryCacheImpl($cache); + + // Proxy configuration + $config->setProxyDir(APPPATH.'/models/proxies'); + $config->setProxyNamespace('Proxies'); + + // Set up logger + $logger = new EchoSQLLogger; + $config->setSQLLogger($logger); + + $config->setAutoGenerateProxyClasses( TRUE ); + + // Database connection information + $connectionOptions = array( + 'driver' => 'pdo_mysql', + 'user' => $db['default']['username'], + 'password' => $db['default']['password'], + 'host' => $db['default']['hostname'], + 'dbname' => $db['default']['database'] + ); + + // Create EntityManager + $this->em = EntityManager::create($connectionOptions, $config); + } + } + +Please note that this is a development configuration; for a +production system you'll want to use a real caching system like +APC, get rid of EchoSqlLogger, and turn off +autoGenerateProxyClasses. + +For more details, consult the +`Doctrine 2 Configuration documentation `_. + +Now to use it +------------- + +Whenever you need a reference to the entity manager inside one of +your controllers, views, or models you can do this: + +.. code-block:: php + + doctrine->em; + +That's all there is to it. Once you get the reference to your +EntityManager do your Doctrine 2.0 voodoo as normal. + +Note: If you do not choose to autoload the Doctrine library, you +will need to put this line before you get a reference to it: + +.. code-block:: php + + load->library('doctrine'); + +Good luck! + + diff --git a/vendor/doctrine/orm/docs/en/cookbook/mysql-enums.rst b/vendor/doctrine/orm/docs/en/cookbook/mysql-enums.rst new file mode 100644 index 0000000000..69f0a351b6 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/mysql-enums.rst @@ -0,0 +1,189 @@ +Mysql Enums +=========== + +The type system of Doctrine 2 consists of flyweights, which means there is only +one instance of any given type. Additionally types do not contain state. Both +assumptions make it rather complicated to work with the Enum Type of MySQL that +is used quite a lot by developers. + +When using Enums with a non-tweaked Doctrine 2 application you will get +errors from the Schema-Tool commands due to the unknown database type "enum". +By default Doctrine does not map the MySQL enum type to a Doctrine type. +This is because Enums contain state (their allowed values) and Doctrine +types don't. + +This cookbook entry shows two possible solutions to work with MySQL enums. +But first a word of warning. The MySQL Enum type has considerable downsides: + +- Adding new values requires to rebuild the whole table, which can take hours + depending on the size. +- Enums are ordered in the way the values are specified, not in their "natural" order. +- Enums validation mechanism for allowed values is not necessarily good, + specifying invalid values leads to an empty enum for the default MySQL error + settings. You can easily replicate the "allow only some values" requirement + in your Doctrine entities. + +Solution 1: Mapping to Varchars +------------------------------- + +You can map ENUMs to varchars. You can register MySQL ENUMs to map to Doctrine +varchars. This way Doctrine always resolves ENUMs to Doctrine varchars. It +will even detect this match correctly when using SchemaTool update commands. + +.. code-block:: php + + getConnection(); + $conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); + +In this case you have to ensure that each varchar field that is an enum in the +database only gets passed the allowed values. You can easily enforce this in your +entities: + +.. code-block:: php + + status = $status; + } + } + +If you want to actively create enums through the Doctrine Schema-Tool by using +the **columnDefinition** attribute. + +.. code-block:: php + + values); + + return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'"; + } + + public function convertToPHPValue($value, AbstractPlatform $platform) + { + return $value; + } + + public function convertToDatabaseValue($value, AbstractPlatform $platform) + { + if (!in_array($value, $this->values)) { + throw new \InvalidArgumentException("Invalid '".$this->name."' value."); + } + return $value; + } + + public function getName() + { + return $this->name; + } + } + +With this base class you can define an enum as easily as: + +.. code-block:: php + + addResolveTargetEntity('Acme\\InvoiceModule\\Model\\InvoiceSubjectInterface', 'Acme\\CustomerModule\\Entity\\Customer', array()); + + // Add the ResolveTargetEntityListener + $evm->addEventSubscriber($rtel); + + $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $evm); + +Final Thoughts +-------------- + +With the ``ResolveTargetEntityListener``, we are able to decouple our +bundles, keeping them usable by themselves, but still being able to +define relationships between different objects. By using this method, +I've found my bundles end up being easier to maintain independently. + + diff --git a/vendor/doctrine/orm/docs/en/cookbook/sql-table-prefixes.rst b/vendor/doctrine/orm/docs/en/cookbook/sql-table-prefixes.rst new file mode 100644 index 0000000000..6ca73c2751 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/sql-table-prefixes.rst @@ -0,0 +1,80 @@ +SQL-Table Prefixes +================== + +This recipe is intended as an example of implementing a +loadClassMetadata listener to provide a Table Prefix option for +your application. The method used below is not a hack, but fully +integrates into the Doctrine system, all SQL generated will include +the appropriate table prefix. + +In most circumstances it is desirable to separate different +applications into individual databases, but in certain cases, it +may be beneficial to have a table prefix for your Entities to +separate them from other vendor products in the same database. + +Implementing the listener +------------------------- + +The listener in this example has been set up with the +DoctrineExtensions namespace. You create this file in your +library/DoctrineExtensions directory, but will need to set up +appropriate autoloaders. + +.. code-block:: php + + prefix = (string) $prefix; + } + + public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) + { + $classMetadata = $eventArgs->getClassMetadata(); + $classMetadata->setTableName($this->prefix . $classMetadata->getTableName()); + foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { + if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY) { + $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; + $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName; + } + } + } + + } + +Telling the EntityManager about our listener +-------------------------------------------- + +A listener of this type must be set up before the EntityManager has +been initialised, otherwise an Entity might be created or cached +before the prefix has been set. + +.. note:: + + If you set this listener up, be aware that you will need + to clear your caches and drop then recreate your database schema. + + +.. code-block:: php + + addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $tablePrefix); + + $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $evm); + + diff --git a/vendor/doctrine/orm/docs/en/cookbook/strategy-cookbook-introduction.rst b/vendor/doctrine/orm/docs/en/cookbook/strategy-cookbook-introduction.rst new file mode 100644 index 0000000000..d9934f577d --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/strategy-cookbook-introduction.rst @@ -0,0 +1,254 @@ +Strategy-Pattern +================ + +This recipe will give you a short introduction on how to design +similar entities without using expensive (i.e. slow) inheritance +but with not more than \* the well-known strategy pattern \* event +listeners + +Scenario / Problem +------------------ + +Given a Content-Management-System, we probably want to add / edit +some so-called "blocks" and "panels". What are they for? + + +- A block might be a registration form, some text content, a table + with information. A good example might also be a small calendar. +- A panel is by definition a block that can itself contain blocks. + A good example for a panel might be a sidebar box: You could easily + add a small calendar into it. + +So, in this scenario, when building your CMS, you will surely add +lots of blocks and panels to your pages and you will find yourself +highly uncomfortable because of the following: + + +- Every existing page needs to know about the panels it contains - + therefore, you'll have an association to your panels. But if you've + got several types of panels - what do you do? Add an association to + every panel-type? This wouldn't be flexible. You might be tempted + to add an AbstractPanelEntity and an AbstractBlockEntity that use + class inheritance. Your page could then only confer to the + AbstractPanelType and Doctrine 2 would do the rest for you, i.e. + load the right entities. But - you'll for sure have lots of panels + and blocks, and even worse, you'd have to edit the discriminator + map *manually* every time you or another developer implements a new + block / entity. This would tear down any effort of modular + programming. + +Therefore, we need something that's far more flexible. + +Solution +-------- + +The solution itself is pretty easy. We will have one base class +that will be loaded via the page and that has specific behaviour - +a Block class might render the front-end and even the backend, for +example. Now, every block that you'll write might look different or +need different data - therefore, we'll offer an API to these +methods but internally, we use a strategy that exactly knows what +to do. + +First of all, we need to make sure that we have an interface that +contains every needed action. Such actions would be rendering the +front-end or the backend, solving dependencies (blocks that are +supposed to be placed in the sidebar could refuse to be placed in +the middle of your page, for example). + +Such an interface could look like this: + + +.. code-block:: php + + blockStrategy. Will not be persisted by Doctrine 2. + * + * @var BlockStrategyInterface + */ + protected $strategyInstance; + + /** + * Returns the strategy that is used for this blockitem. + * + * The strategy itself defines how this block can be rendered etc. + * + * @return string + */ + public function getStrategyClassName() { + return $this->strategyClassName; + } + + /** + * Returns the instantiated strategy + * + * @return BlockStrategyInterface + */ + public function getStrategyInstance() { + return $this->strategyInstance; + } + + /** + * Sets the strategy this block / panel should work as. Make sure that you've used + * this method before persisting the block! + * + * @param BlockStrategyInterface $strategy + */ + public function setStrategy(BlockStrategyInterface $strategy) { + $this->strategyInstance = $strategy; + $this->strategyClassName = get_class($strategy); + $strategy->setBlockEntity($this); + } + +Now, the important point is that $strategyClassName is a Doctrine 2 +field, i.e. Doctrine will persist this value. This is only the +class name of your strategy and not an instance! + +Finishing your strategy pattern, we hook into the Doctrine postLoad +event and check whether a block has been loaded. If so, you will +initialize it - i.e. get the strategies classname, create an +instance of it and set it via setStrategyBlock(). + +This might look like this: + +.. code-block:: php + + view = $view; + } + + public function getSubscribedEvents() { + return array(ORM\Events::postLoad); + } + + public function postLoad(ORM\Event\LifecycleEventArgs $args) { + $blockItem = $args->getEntity(); + + // Both blocks and panels are instances of Block\AbstractBlock + if ($blockItem instanceof Block\AbstractBlock) { + $strategy = $blockItem->getStrategyClassName(); + $strategyInstance = new $strategy(); + if (null !== $blockItem->getConfig()) { + $strategyInstance->setConfig($blockItem->getConfig()); + } + $strategyInstance->setView($this->view); + $blockItem->setStrategy($strategyInstance); + } + } + } + +In this example, even some variables are set - like a view object +or a specific configuration object. + + diff --git a/vendor/doctrine/orm/docs/en/cookbook/validation-of-entities.rst b/vendor/doctrine/orm/docs/en/cookbook/validation-of-entities.rst new file mode 100644 index 0000000000..a09b218e07 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/validation-of-entities.rst @@ -0,0 +1,137 @@ +Validation of Entities +====================== + +.. sectionauthor:: Benjamin Eberlei + +Doctrine 2 does not ship with any internal validators, the reason +being that we think all the frameworks out there already ship with +quite decent ones that can be integrated into your Domain easily. +What we offer are hooks to execute any kind of validation. + +.. note:: + + You don't need to validate your entities in the lifecycle + events. Its only one of many options. Of course you can also + perform validations in value setters or any other method of your + entities that are used in your code. + + +Entities can register lifecycle event methods with Doctrine that +are called on different occasions. For validation we would need to +hook into the events called before persisting and updating. Even +though we don't support validation out of the box, the +implementation is even simpler than in Doctrine 1 and you will get +the additional benefit of being able to re-use your validation in +any other part of your domain. + +Say we have an ``Order`` with several ``OrderLine`` instances. We +never want to allow any customer to order for a larger sum than he +is allowed to: + +.. code-block:: php + + customer->getOrderLimit(); + + $amount = 0; + foreach ($this->orderLines AS $line) { + $amount += $line->getAmount(); + } + + if ($amount > $orderLimit) { + throw new CustomerOrderLimitExceededException(); + } + } + } + +Now this is some pretty important piece of business logic in your +code, enforcing it at any time is important so that customers with +a unknown reputation don't owe your business too much money. + +We can enforce this constraint in any of the metadata drivers. +First Annotations: + +.. code-block:: php + + + + + + + + + + +YAML needs some little change yet, to allow multiple lifecycle +events for one method, this will happen before Beta 1 though. + +Now validation is performed whenever you call +``EntityManager#persist($order)`` or when you call +``EntityManager#flush()`` and an order is about to be updated. Any +Exception that happens in the lifecycle callbacks will be cached by +the EntityManager and the current transaction is rolled back. + +Of course you can do any type of primitive checks, not null, +email-validation, string size, integer and date ranges in your +validation callbacks. + +.. code-block:: php + + plannedShipDate instanceof DateTime)) { + throw new ValidateException(); + } + + if ($this->plannedShipDate->format('U') < time()) { + throw new ValidateException(); + } + + if ($this->customer == null) { + throw new OrderRequiresCustomerException(); + } + } + } + +What is nice about lifecycle events is, you can also re-use the +methods at other places in your domain, for example in combination +with your form library. Additionally there is no limitation in the +number of methods you register on one particular event, i.e. you +can register multiple methods for validation in "PrePersist" or +"PreUpdate" or mix and share them in any combinations between those +two events. + +There is no limit to what you can and can't validate in +"PrePersist" and "PreUpdate" as long as you don't create new entity +instances. This was already discussed in the previous blog post on +the Versionable extension, which requires another type of event +called "onFlush". + +Further readings: :doc:`Lifecycle Events <../reference/events>` diff --git a/vendor/doctrine/orm/docs/en/cookbook/working-with-datetime.rst b/vendor/doctrine/orm/docs/en/cookbook/working-with-datetime.rst new file mode 100644 index 0000000000..fc548dac0f --- /dev/null +++ b/vendor/doctrine/orm/docs/en/cookbook/working-with-datetime.rst @@ -0,0 +1,168 @@ +Working with DateTime Instances +=============================== + +There are many nitty gritty details when working with PHPs DateTime instances. You have know their inner +workings pretty well not to make mistakes with date handling. This cookbook entry holds several +interesting pieces of information on how to work with PHP DateTime instances in Doctrine 2. + +DateTime changes are detected by Reference +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When calling ``EntityManager#flush()`` Doctrine computes the changesets of all the currently managed entities +and saves the differences to the database. In case of object properties (@Column(type="datetime") or @Column(type="object")) +these comparisons are always made **BY REFERENCE**. That means the following change will **NOT** be saved into the database: + +.. code-block:: php + + updated->modify("now"); + } + } + +The way to go would be: + +.. code-block:: php + + updated = new \DateTime("now"); + } + } + +Default Timezone Gotcha +~~~~~~~~~~~~~~~~~~~~~~~ + +By default Doctrine assumes that you are working with a default timezone. Each DateTime instance that +is created by Doctrine will be assigned the timezone that is currently the default, either through +the ``date.timezone`` ini setting or by calling ``date_default_timezone_set()``. + +This is very important to handle correctly if your application runs on different serves or is moved from one to another server +(with different timezone settings). You have to make sure that the timezone is the correct one +on all this systems. + +Handling different Timezones with the DateTime Type +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you first come across the requirement to save different you are still optimistic to manage this mess, +however let me crush your expectations fast. There is not a single database out there (supported by Doctrine 2) +that supports timezones correctly. Correctly here means that you can cover all the use-cases that +can come up with timezones. If you don't believe me you should read up on `Storing DateTime +in Databases `_. + +The problem is simple. Not a single database vendor saves the timezone, only the differences to UTC. +However with frequent daylight saving and political timezone changes you can have a UTC offset that moves +in different offset directions depending on the real location. + +The solution for this dilemma is simple. Don't use timezones with DateTime and Doctrine 2. However there is a workaround +that even allows correct date-time handling with timezones: + +1. Always convert any DateTime instance to UTC. +2. Only set Timezones for displaying purposes +3. Save the Timezone in the Entity for persistence. + +Say we have an application for an international postal company and employees insert events regarding postal-package +around the world, in their current timezones. To determine the exact time an event occurred means to save both +the UTC time at the time of the booking and the timezone the event happened in. + +.. code-block:: php + + format($platform->getDateTimeFormatString(), + (self::$utc) ? self::$utc : (self::$utc = new \DateTimeZone('UTC')) + ); + } + + public function convertToPHPValue($value, AbstractPlatform $platform) + { + if ($value === null) { + return null; + } + + $val = \DateTime::createFromFormat( + $platform->getDateTimeFormatString(), + $value, + (self::$utc) ? self::$utc : (self::$utc = new \DateTimeZone('UTC')) + ); + if (!$val) { + throw ConversionException::conversionFailed($value, $this->getName()); + } + return $val; + } + } + +This database type makes sure that every DateTime instance is always saved in UTC, relative +to the current timezone that the passed DateTime instance has. To be able to transform these values +back into their real timezone you have to save the timezone in a separate field of the entity +requiring timezoned datetimes: + +.. code-block:: php + + localized = true; + $this->created = $createDate; + $this->timezone = $createDate->getTimeZone()->getName(); + } + + public function getCreated() + { + if (!$this->localized) { + $this->created->setTimeZone(new \DateTimeZone($this->timezone)); + } + return $this->created; + } + } + +This snippet makes use of the previously discussed "changeset by reference only" property of +objects. That means a new DateTime will only be used during updating if the reference +changes between retrieval and flush operation. This means we can easily go and modify +the instance by setting the previous local timezone. diff --git a/vendor/doctrine/orm/docs/en/index.rst b/vendor/doctrine/orm/docs/en/index.rst new file mode 100644 index 0000000000..e71ea7a432 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/index.rst @@ -0,0 +1,122 @@ +Welcome to Doctrine 2 ORM's documentation! +========================================== + +The Doctrine documentation is comprised of tutorials, a reference section and +cookbook articles that explain different parts of the Object Relational mapper. + +Doctrine DBAL and Doctrine Common both have their own documentation. + +Getting Help +------------ + +If this documentation is not helping to answer questions you have about +Doctrine ORM don't panic. You can get help from different sources: + +- There is a :doc:`FAQ ` with answers to frequent questions. +- The `Doctrine Mailing List `_ +- Internet Relay Chat (IRC) in `#doctrine on Freenode `_ +- Report a bug on `JIRA `_. +- On `Twitter `_ with ``#doctrine2`` +- On `StackOverflow `_ + +If you need more structure over the different topics you can browse the :doc:`table +of contents `. + +Getting Started +--------------- + +* **Tutorial**: + :doc:`Getting Started with Doctrine ` + +* **Setup**: + :doc:`Installation & Configuration ` + +Mapping Objects onto a Database +------------------------------- + +* **Mapping**: + :doc:`Objects ` | + :doc:`Associations ` | + :doc:`Inheritance ` + +* **Drivers**: + :doc:`Docblock Annotations ` | + :doc:`XML ` | + :doc:`YAML ` | + :doc:`PHP ` + +Working with Objects +-------------------- + +* **Basic Reference**: + :doc:`Entities ` | + :doc:`Associations ` | + :doc:`Events ` + +* **Query Reference**: + :doc:`DQL ` | + :doc:`QueryBuilder ` | + :doc:`Native SQL ` + +* **Internals**: + :doc:`Internals explained ` | + :doc:`Associations ` + +Advanced Topics +--------------- + + * :doc:`Architecture ` + * :doc:`Advanced Configuration ` + * :doc:`Limitations and knowns issues ` + * :doc:`Commandline Tools ` + * :doc:`Transactions and Concurrency ` + * :doc:`Filters ` + * :doc:`NamingStrategy ` + * :doc:`Improving Performance ` + * :doc:`Caching ` + * :doc:`Partial Objects ` + * :doc:`Change Tracking Policies ` + * :doc:`Best Practices ` + * :doc:`Metadata Drivers ` + +Tutorials +--------- + + * :doc:`Indexed associations ` + * :doc:`Extra Lazy Associations ` + * :doc:`Composite Primary Keys ` + * :doc:`Ordered associations ` + * :doc:`Pagination ` + * :doc:`Override Field/Association Mappings In Subclasses ` + +Cookbook +-------- + +* **Patterns**: + :doc:`Aggregate Fields ` | + :doc:`Decorator Pattern ` | + :doc:`Strategy Pattern ` + +* **DQL Extension Points**: + :doc:`DQL Custom Walkers ` | + :doc:`DQL User-Defined-Functions ` + +* **Implementation**: + :doc:`Array Access ` | + :doc:`Notify ChangeTracking Example ` | + :doc:`Using Wakeup Or Clone ` | + :doc:`Working with DateTime ` | + :doc:`Validation ` | + :doc:`Entities in the Session ` | + :doc:`Keeping your Modules independent ` + +* **Integration into Frameworks/Libraries** + :doc:`CodeIgniter ` + +* **Hidden Gems** + :doc:`Prefixing Table Name ` + +* **Custom Datatypes** + :doc:`MySQL Enums ` + :doc:`Advanced Field Value Conversion ` + diff --git a/vendor/doctrine/orm/docs/en/make.bat b/vendor/doctrine/orm/docs/en/make.bat new file mode 100644 index 0000000000..53c40c9129 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/make.bat @@ -0,0 +1,113 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +set SPHINXBUILD=sphinx-build +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Doctrine2ORM.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Doctrine2ORM.ghc + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end diff --git a/vendor/doctrine/orm/docs/en/reference/advanced-configuration.rst b/vendor/doctrine/orm/docs/en/reference/advanced-configuration.rst new file mode 100644 index 0000000000..5c8ad01d10 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/advanced-configuration.rst @@ -0,0 +1,432 @@ +Advanced Configuration +====================== + +The configuration of the EntityManager requires a +``Doctrine\ORM\Configuration`` instance as well as some database +connection parameters. This example shows all the potential +steps of configuration. + +.. code-block:: php + + setMetadataCacheImpl($cache); + $driverImpl = $config->newDefaultAnnotationDriver('/path/to/lib/MyProject/Entities'); + $config->setMetadataDriverImpl($driverImpl); + $config->setQueryCacheImpl($cache); + $config->setProxyDir('/path/to/myproject/lib/MyProject/Proxies'); + $config->setProxyNamespace('MyProject\Proxies'); + + if ($applicationMode == "development") { + $config->setAutoGenerateProxyClasses(true); + } else { + $config->setAutoGenerateProxyClasses(false); + } + + $connectionOptions = array( + 'driver' => 'pdo_sqlite', + 'path' => 'database.sqlite' + ); + + $em = EntityManager::create($connectionOptions, $config); + +.. note:: + + Do not use Doctrine without a metadata and query cache! + Doctrine is optimized for working with caches. The main + parts in Doctrine that are optimized for caching are the metadata + mapping information with the metadata cache and the DQL to SQL + conversions with the query cache. These 2 caches require only an + absolute minimum of memory yet they heavily improve the runtime + performance of Doctrine. The recommended cache driver to use with + Doctrine is `APC `_. APC provides you with + an opcode-cache (which is highly recommended anyway) and a very + fast in-memory cache storage that you can use for the metadata and + query caches as seen in the previous code snippet. + +Configuration Options +--------------------- + +The following sections describe all the configuration options +available on a ``Doctrine\ORM\Configuration`` instance. + +Proxy Directory (***REQUIRED***) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + setProxyDir($dir); + $config->getProxyDir(); + +Gets or sets the directory where Doctrine generates any proxy +classes. For a detailed explanation on proxy classes and how they +are used in Doctrine, refer to the "Proxy Objects" section further +down. + +Proxy Namespace (***REQUIRED***) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + setProxyNamespace($namespace); + $config->getProxyNamespace(); + +Gets or sets the namespace to use for generated proxy classes. For +a detailed explanation on proxy classes and how they are used in +Doctrine, refer to the "Proxy Objects" section further down. + +Metadata Driver (***REQUIRED***) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + setMetadataDriverImpl($driver); + $config->getMetadataDriverImpl(); + +Gets or sets the metadata driver implementation that is used by +Doctrine to acquire the object-relational metadata for your +classes. + +There are currently 4 available implementations: + + +- ``Doctrine\ORM\Mapping\Driver\AnnotationDriver`` +- ``Doctrine\ORM\Mapping\Driver\XmlDriver`` +- ``Doctrine\ORM\Mapping\Driver\YamlDriver`` +- ``Doctrine\ORM\Mapping\Driver\DriverChain`` + +Throughout the most part of this manual the AnnotationDriver is +used in the examples. For information on the usage of the XmlDriver +or YamlDriver please refer to the dedicated chapters +``XML Mapping`` and ``YAML Mapping``. + +The annotation driver can be configured with a factory method on +the ``Doctrine\ORM\Configuration``: + +.. code-block:: php + + newDefaultAnnotationDriver('/path/to/lib/MyProject/Entities'); + $config->setMetadataDriverImpl($driverImpl); + +The path information to the entities is required for the annotation +driver, because otherwise mass-operations on all entities through +the console could not work correctly. All of metadata drivers +accept either a single directory as a string or an array of +directories. With this feature a single driver can support multiple +directories of Entities. + +Metadata Cache (***RECOMMENDED***) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + setMetadataCacheImpl($cache); + $config->getMetadataCacheImpl(); + +Gets or sets the cache implementation to use for caching metadata +information, that is, all the information you supply via +annotations, xml or yaml, so that they do not need to be parsed and +loaded from scratch on every single request which is a waste of +resources. The cache implementation must implement the +``Doctrine\Common\Cache\Cache`` interface. + +Usage of a metadata cache is highly recommended. + +The recommended implementations for production are: + + +- ``Doctrine\Common\Cache\ApcCache`` +- ``Doctrine\Common\Cache\MemcacheCache`` +- ``Doctrine\Common\Cache\XcacheCache`` +- ``Doctrine\Common\Cache\RedisCache`` + +For development you should use the +``Doctrine\Common\Cache\ArrayCache`` which only caches data on a +per-request basis. + +Query Cache (***RECOMMENDED***) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + setQueryCacheImpl($cache); + $config->getQueryCacheImpl(); + +Gets or sets the cache implementation to use for caching DQL +queries, that is, the result of a DQL parsing process that includes +the final SQL as well as meta information about how to process the +SQL result set of a query. Note that the query cache does not +affect query results. You do not get stale data. This is a pure +optimization cache without any negative side-effects (except some +minimal memory usage in your cache). + +Usage of a query cache is highly recommended. + +The recommended implementations for production are: + + +- ``Doctrine\Common\Cache\ApcCache`` +- ``Doctrine\Common\Cache\MemcacheCache`` +- ``Doctrine\Common\Cache\XcacheCache`` +- ``Doctrine\Common\Cache\RedisCache`` + +For development you should use the +``Doctrine\Common\Cache\ArrayCache`` which only caches data on a +per-request basis. + +SQL Logger (***Optional***) +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + setSQLLogger($logger); + $config->getSQLLogger(); + +Gets or sets the logger to use for logging all SQL statements +executed by Doctrine. The logger class must implement the +``Doctrine\DBAL\Logging\SQLLogger`` interface. A simple default +implementation that logs to the standard output using ``echo`` and +``var_dump`` can be found at +``Doctrine\DBAL\Logging\EchoSQLLogger``. + +Auto-generating Proxy Classes (***OPTIONAL***) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + setAutoGenerateProxyClasses($bool); + $config->getAutoGenerateProxyClasses(); + +Gets or sets whether proxy classes should be generated +automatically at runtime by Doctrine. If set to ``FALSE``, proxy +classes must be generated manually through the doctrine command +line task ``generate-proxies``. The strongly recommended value for +a production environment is ``FALSE``. + +Development vs Production Configuration +--------------------------------------- + +You should code your Doctrine2 bootstrapping with two different +runtime models in mind. There are some serious benefits of using +APC or Memcache in production. In development however this will +frequently give you fatal errors, when you change your entities and +the cache still keeps the outdated metadata. That is why we +recommend the ``ArrayCache`` for development. + +Furthermore you should have the Auto-generating Proxy Classes +option to true in development and to false in production. If this +option is set to ``TRUE`` it can seriously hurt your script +performance if several proxy classes are re-generated during script +execution. Filesystem calls of that magnitude can even slower than +all the database queries Doctrine issues. Additionally writing a +proxy sets an exclusive file lock which can cause serious +performance bottlenecks in systems with regular concurrent +requests. + +Connection Options +------------------ + +The ``$connectionOptions`` passed as the first argument to +``EntityManager::create()`` has to be either an array or an +instance of ``Doctrine\DBAL\Connection``. If an array is passed it +is directly passed along to the DBAL Factory +``Doctrine\DBAL\DriverManager::getConnection()``. The DBAL +configuration is explained in the +`DBAL section <./../../../../../dbal/2.0/docs/reference/configuration/en>`_. + +Proxy Objects +------------- + +A proxy object is an object that is put in place or used instead of +the "real" object. A proxy object can add behavior to the object +being proxied without that object being aware of it. In Doctrine 2, +proxy objects are used to realize several features but mainly for +transparent lazy-loading. + +Proxy objects with their lazy-loading facilities help to keep the +subset of objects that are already in memory connected to the rest +of the objects. This is an essential property as without it there +would always be fragile partial objects at the outer edges of your +object graph. + +Doctrine 2 implements a variant of the proxy pattern where it +generates classes that extend your entity classes and adds +lazy-loading capabilities to them. Doctrine can then give you an +instance of such a proxy class whenever you request an object of +the class being proxied. This happens in two situations: + +Reference Proxies +~~~~~~~~~~~~~~~~~ + +The method ``EntityManager#getReference($entityName, $identifier)`` +lets you obtain a reference to an entity for which the identifier +is known, without loading that entity from the database. This is +useful, for example, as a performance enhancement, when you want to +establish an association to an entity for which you have the +identifier. You could simply do this: + +.. code-block:: php + + getReference('MyProject\Model\Item', $itemId); + $cart->addItem($item); + +Here, we added an Item to a Cart without loading the Item from the +database. If you invoke any method on the Item instance, it would +fully initialize its state transparently from the database. Here +$item is actually an instance of the proxy class that was generated +for the Item class but your code does not need to care. In fact it +**should not care**. Proxy objects should be transparent to your +code. + +Association proxies +~~~~~~~~~~~~~~~~~~~ + +The second most important situation where Doctrine uses proxy +objects is when querying for objects. Whenever you query for an +object that has a single-valued association to another object that +is configured LAZY, without joining that association in the same +query, Doctrine puts proxy objects in place where normally the +associated object would be. Just like other proxies it will +transparently initialize itself on first access. + +.. note:: + + Joining an association in a DQL or native query + essentially means eager loading of that association in that query. + This will override the 'fetch' option specified in the mapping for + that association, but only for that query. + + +Generating Proxy classes +~~~~~~~~~~~~~~~~~~~~~~~~ + +Proxy classes can either be generated manually through the Doctrine +Console or automatically by Doctrine. The configuration option that +controls this behavior is: + +.. code-block:: php + + setAutoGenerateProxyClasses($bool); + $config->getAutoGenerateProxyClasses(); + +The default value is ``TRUE`` for convenient development. However, +this setting is not optimal for performance and therefore not +recommended for a production environment. To eliminate the overhead +of proxy class generation during runtime, set this configuration +option to ``FALSE``. When you do this in a development environment, +note that you may get class/file not found errors if certain proxy +classes are not available or failing lazy-loads if new methods were +added to the entity class that are not yet in the proxy class. In +such a case, simply use the Doctrine Console to (re)generate the +proxy classes like so: + +.. code-block:: php + + $ ./doctrine orm:generate-proxies + +Autoloading Proxies +------------------- + +When you deserialize proxy objects from the session or any other storage +it is necessary to have an autoloading mechanism in place for these classes. +For implementation reasons Proxy class names are not PSR-0 compliant. This +means that you have to register a special autoloader for these classes: + +.. code-block:: php + + addDriver($xmlDriver, 'Doctrine\Tests\Models\Company'); + $chain->addDriver($yamlDriver, 'Doctrine\Tests\ORM\Mapping'); + +Based on the namespace of the entity the loading of entities is +delegated to the appropriate driver. The chain semantics come from +the fact that the driver loops through all namespaces and matches +the entity class name against the namespace using a +``strpos() === 0`` call. This means you need to order the drivers +correctly if sub-namespaces use different metadata driver +implementations. + + +Default Repository (***OPTIONAL***) +----------------------------------- + +Specifies the FQCN of a subclass of the EntityRepository. +That will be available for all entities without a custom repository class. + +.. code-block:: php + + setDefaultRepositoryClassName($fqcn); + $config->getDefaultRepositoryClassName(); + +The default value is ``Doctrine\ORM\EntityRepository``. +Any repository class must be a subclass of EntityRepository otherwise you got an ORMException + +Setting up the Console +---------------------- + +Doctrine uses the Symfony Console component for generating the command +line interface. You can take a look at the ``vendor/bin/doctrine.php`` +script and the ``Doctrine\ORM\Tools\Console\ConsoleRunner`` command +for inspiration how to setup the cli. + +In general the required code looks like this: + +.. code-block:: php + + setCatchExceptions(true); + $cli->setHelperSet($helperSet); + Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli); + $cli->run(); + diff --git a/vendor/doctrine/orm/docs/en/reference/annotations-reference.rst b/vendor/doctrine/orm/docs/en/reference/annotations-reference.rst new file mode 100644 index 0000000000..d42fda4e4a --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/annotations-reference.rst @@ -0,0 +1,1114 @@ +Annotations Reference +===================== + +In this chapter a reference of every Doctrine 2 Annotation is given +with short explanations on their context and usage. + +Index +----- + +- :ref:`@Column ` +- :ref:`@ColumnResult ` +- :ref:`@ChangeTrackingPolicy ` +- :ref:`@DiscriminatorColumn ` +- :ref:`@DiscriminatorMap ` +- :ref:`@Entity ` +- :ref:`@EntityResult ` +- :ref:`@FieldResult ` +- :ref:`@GeneratedValue ` +- :ref:`@HasLifecycleCallbacks ` +- :ref:`@Index ` +- :ref:`@Id ` +- :ref:`@InheritanceType ` +- :ref:`@JoinColumn ` +- :ref:`@JoinColumns ` +- :ref:`@JoinTable ` +- :ref:`@ManyToOne ` +- :ref:`@ManyToMany ` +- :ref:`@MappedSuperclass ` +- :ref:`@NamedNativeQuery ` +- :ref:`@OneToOne ` +- :ref:`@OneToMany ` +- :ref:`@OrderBy ` +- :ref:`@PostLoad ` +- :ref:`@PostPersist ` +- :ref:`@PostRemove ` +- :ref:`@PostUpdate ` +- :ref:`@PrePersist ` +- :ref:`@PreRemove ` +- :ref:`@PreUpdate ` +- :ref:`@SequenceGenerator ` +- :ref:`@SqlResultSetMapping ` +- :ref:`@Table ` +- :ref:`@UniqueConstraint ` +- :ref:`@Version ` + +Reference +--------- + +.. _annref_column: + +@Column +~~~~~~~ + +Marks an annotated instance variable as "persistent". It has to be +inside the instance variables PHP DocBlock comment. Any value hold +inside this variable will be saved to and loaded from the database +as part of the lifecycle of the instance variables entity-class. + +Required attributes: + +- **type**: Name of the Doctrine Type which is converted between PHP + and Database representation. + +Optional attributes: + +- **name**: By default the property name is used for the database + column name also, however the 'name' attribute allows you to + determine the column name. + +- **length**: Used by the "string" type to determine its maximum + length in the database. Doctrine does not validate the length of a + string values for you. + +- **precision**: The precision for a decimal (exact numeric) column + (Applies only for decimal column) + +- **scale**: The scale for a decimal (exact numeric) column (Applies + only for decimal column) + +- **unique**: Boolean value to determine if the value of the column + should be unique across all rows of the underlying entities table. + +- **nullable**: Determines if NULL values allowed for this column. + +- **columnDefinition**: DDL SQL snippet that starts after the column + name and specifies the complete (non-portable!) column definition. + This attribute allows to make use of advanced RMDBS features. + However you should make careful use of this feature and the + consequences. SchemaTool will not detect changes on the column correctly + anymore if you use "columnDefinition". + + Additionally you should remember that the "type" + attribute still handles the conversion between PHP and Database + values. If you use this attribute on a column that is used for + joins between tables you should also take a look at + :ref:`@JoinColumn `. + +Examples: + +.. code-block:: php + + ` +can be found in the configuration section. + +Example: + +.. code-block:: php + + = 2.1) Specifies that this entity is marked as read only and not + considered for change-tracking. Entities of this type can be persisted + and removed though. + +Example: + +.. code-block:: php + + `. This +annotation is optional and only has meaning when used in +conjunction with @Id. + +If this annotation is not specified with @Id the NONE strategy is +used as default. + +Required attributes: + + +- **strategy**: Set the name of the identifier generation strategy. + Valid values are AUTO, SEQUENCE, TABLE, IDENTITY, UUID, CUSTOM and NONE. + +Example: + +.. code-block:: php + + ` annotation on +the entity-class level. It allows to hint the SchemaTool to +generate a database index on the specified table columns. It only +has meaning in the SchemaTool schema generation context. + +Required attributes: + + +- **name**: Name of the Index +- **columns**: Array of columns. + +Example: + +.. code-block:: php + + ` and +:ref:`@DiscriminatorColumn ` annotations. + +Examples: + +.. code-block:: php + + `, :ref:`@OneToOne ` fields +and in the Context of :ref:`@JoinTable ` nested inside +a @ManyToMany. This annotation is not required. If its not +specified the attributes *name* and *referencedColumnName* are +inferred from the table and primary key names. + +Required attributes: + + +- **name**: Column name that holds the foreign key identifier for + this relation. In the context of @JoinTable it specifies the column + name in the join table. +- **referencedColumnName**: Name of the primary key identifier that + is used for joining of this relation. + +Optional attributes: + + +- **unique**: Determines if this relation exclusive between the + affected entities and should be enforced so on the database + constraint level. Defaults to false. +- **nullable**: Determine if the related entity is required, or if + null is an allowed state for the relation. Defaults to true. +- **onDelete**: Cascade Action (Database-level) +- **columnDefinition**: DDL SQL snippet that starts after the column + name and specifies the complete (non-portable!) column definition. + This attribute allows to make use of advanced RMDBS features. Using + this attribute on @JoinColumn is necessary if you need slightly + different column definitions for joining columns, for example + regarding NULL/NOT NULL defaults. However by default a + "columnDefinition" attribute on :ref:`@Column ` also sets + the related @JoinColumn's columnDefinition. This is necessary to + make foreign keys work. + +Example: + +.. code-block:: php + + ` or :ref:`@OneToOne ` +relation with an entity that has multiple identifiers. + +.. _annref_jointable: + +@JoinTable +~~~~~~~~~~~~~~ + +Using :ref:`@OneToMany ` or +:ref:`@ManyToMany ` on the owning side of the relation +requires to specify the @JoinTable annotation which describes the +details of the database join table. If you do not specify +@JoinTable on these relations reasonable mapping defaults apply +using the affected table and the column names. + +Required attributes: + + +- **name**: Database name of the join-table +- **joinColumns**: An array of @JoinColumn annotations describing the + join-relation between the owning entities table and the join table. +- **inverseJoinColumns**: An array of @JoinColumn annotations + describing the join-relation between the inverse entities table and + the join table. + +Example: + +.. code-block:: php + + ` is an +additional, optional annotation that has reasonable default +configuration values using the table and names of the two related +entities. + +Required attributes: + + +- **targetEntity**: FQCN of the referenced target entity. Can be the + unqualified class name if both classes are in the same namespace. + *IMPORTANT:* No leading backslash! + +Optional attributes: + + +- **mappedBy**: This option specifies the property name on the + targetEntity that is the owning side of this relation. Its a + required attribute for the inverse side of a relationship. +- **inversedBy**: The inversedBy attribute designates the field in the + entity that is the inverse side of the relationship. +- **cascade**: Cascade Option +- **fetch**: One of LAZY, EXTRA_LAZY or EAGER +- **indexBy**: Index the collection by a field on the target entity. + +.. note:: + + For ManyToMany bidirectional relationships either side may + be the owning side (the side that defines the @JoinTable and/or + does not make use of the mappedBy attribute, thus using a default + join table). + +Example: + +.. code-block:: php + + `. + +Optional attributes: + + +- **repositoryClass**: (>= 2.2) Specifies the FQCN of a subclass of the EntityRepository. + That will be inherited for all subclasses of that Mapped Superclass. + +Example: + +.. code-block:: php + + ` with one additional option that can +be specified. The configuration defaults for +:ref:`@JoinColumn ` using the target entity table and +primary key column names apply here too. + +Required attributes: + + +- **targetEntity**: FQCN of the referenced target entity. Can be the + unqualified class name if both classes are in the same namespace. + *IMPORTANT:* No leading backslash! + +Optional attributes: + + +- **cascade**: Cascade Option +- **fetch**: One of LAZY or EAGER +- **orphanRemoval**: Boolean that specifies if orphans, inverse + OneToOne entities that are not connected to any owning instance, + should be removed by Doctrine. Defaults to false. +- **inversedBy**: The inversedBy attribute designates the field in the + entity that is the inverse side of the relationship. + +Example: + +.. code-block:: php + + ` or :ref:`@OneToMany ` +annotation to specify by which criteria the collection should be +retrieved from the database by using an ORDER BY clause. + +This annotation requires a single non-attributed value with an DQL +snippet: + +Example: + +.. code-block:: php + + ` annotation on +the entity-class level. It allows to hint the SchemaTool to +generate a database unique constraint on the specified table +columns. It only has meaning in the SchemaTool schema generation +context. + +Required attributes: + + +- **name**: Name of the Index +- **columns**: Array of columns. + +Example: + +.. code-block:: php + + ` annotations that have the type integer or +datetime. Combining @Version with :ref:`@Id ` is not supported. + +Example: + +.. code-block:: php + + `. +- An entity class must not implement ``__wakeup`` or + :doc:`do so safely <../cookbook/implementing-wakeup-or-clone>`. + Also consider implementing + `Serializable `_ + instead. +- Any two entity classes in a class hierarchy that inherit + directly or indirectly from one another must not have a mapped + property with the same name. That is, if B inherits from A then B + must not have a mapped field with the same name as an already + mapped field that is inherited from A. +- An entity cannot make use of func_get_args() to implement variable parameters. + Generated proxies do not support this for performance reasons and your code might + actually fail to work when violating this restriction. + +Entities support inheritance, polymorphic associations, and +polymorphic queries. Both abstract and concrete classes can be +entities. Entities may extend non-entity classes as well as entity +classes, and non-entity classes may extend entity classes. + +.. note:: + + The constructor of an entity is only ever invoked when + *you* construct a new instance with the *new* keyword. Doctrine + never calls entity constructors, thus you are free to use them as + you wish and even have it require arguments of any type. + + +Entity states +~~~~~~~~~~~~~ + +An entity instance can be characterized as being NEW, MANAGED, +DETACHED or REMOVED. + + +- A NEW entity instance has no persistent identity, and is not yet + associated with an EntityManager and a UnitOfWork (i.e. those just + created with the "new" operator). +- A MANAGED entity instance is an instance with a persistent + identity that is associated with an EntityManager and whose + persistence is thus managed. +- A DETACHED entity instance is an instance with a persistent + identity that is not (or no longer) associated with an + EntityManager and a UnitOfWork. +- A REMOVED entity instance is an instance with a persistent + identity, associated with an EntityManager, that will be removed + from the database upon transaction commit. + +.. _architecture_persistent_fields: + +Persistent fields +~~~~~~~~~~~~~~~~~ + +The persistent state of an entity is represented by instance +variables. An instance variable must be directly accessed only from +within the methods of the entity by the entity instance itself. +Instance variables must not be accessed by clients of the entity. +The state of the entity is available to clients only through the +entity’s methods, i.e. accessor methods (getter/setter methods) or +other business methods. + +Collection-valued persistent fields and properties must be defined +in terms of the ``Doctrine\Common\Collections\Collection`` +interface. The collection implementation type may be used by the +application to initialize fields or properties before the entity is +made persistent. Once the entity becomes managed (or detached), +subsequent access must be through the interface type. + +Serializing entities +~~~~~~~~~~~~~~~~~~~~ + +Serializing entities can be problematic and is not really +recommended, at least not as long as an entity instance still holds +references to proxy objects or is still managed by an +EntityManager. If you intend to serialize (and unserialize) entity +instances that still hold references to proxy objects you may run +into problems with private properties because of technical +limitations. Proxy objects implement ``__sleep`` and it is not +possible for ``__sleep`` to return names of private properties in +parent classes. On the other hand it is not a solution for proxy +objects to implement ``Serializable`` because Serializable does not +work well with any potential cyclic object references (at least we +did not find a way yet, if you did, please contact us). + +The EntityManager +~~~~~~~~~~~~~~~~~ + +The ``EntityManager`` class is a central access point to the ORM +functionality provided by Doctrine 2. The ``EntityManager`` API is +used to manage the persistence of your objects and to query for +persistent objects. + +Transactional write-behind +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +An ``EntityManager`` and the underlying ``UnitOfWork`` employ a +strategy called "transactional write-behind" that delays the +execution of SQL statements in order to execute them in the most +efficient way and to execute them at the end of a transaction so +that all write locks are quickly released. You should see Doctrine +as a tool to synchronize your in-memory objects with the database +in well defined units of work. Work with your objects and modify +them as usual and when you're done call ``EntityManager#flush()`` +to make your changes persistent. + +The Unit of Work +~~~~~~~~~~~~~~~~ + +Internally an ``EntityManager`` uses a ``UnitOfWork``, which is a +typical implementation of the +`Unit of Work pattern `_, +to keep track of all the things that need to be done the next time +``flush`` is invoked. You usually do not directly interact with a +``UnitOfWork`` but with the ``EntityManager`` instead. + + diff --git a/vendor/doctrine/orm/docs/en/reference/association-mapping.rst b/vendor/doctrine/orm/docs/en/reference/association-mapping.rst new file mode 100644 index 0000000000..f41bb610f5 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/association-mapping.rst @@ -0,0 +1,1145 @@ +Association Mapping +=================== + +This chapter introduces association mappings which are used to explain +references between objects and are mapped to a relational database using +foreign keys. + +Instead of working with the foreign keys directly you will always work with +references to objects: + +- A reference to a single object is represented by a foreign key. +- A collection of objects is represented by many foreign keys pointing to the object holding the collection + +This chapter is split into three different sections. + +- A list of all the possible association mapping use-cases is given. +- :ref:`association_mapping_defaults` are explained that simplify the use-case examples. +- :ref:`collections` are introduced that contain entities in associations. + +To master associations you should also learn about :doc:`owning and inverse sides of associations ` + +One-To-One, Unidirectional +-------------------------- + +A unidirectional one-to-one association is very common. Here is an +example of a ``Product`` that has one ``Shipping`` object +associated to it. The ``Shipping`` side does not reference back to +the ``Product`` so it is unidirectional. + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + .. code-block:: yaml + + Product: + type: entity + oneToOne: + shipping: + targetEntity: Shipping + joinColumn: + name: shipping_id + referencedColumnName: id + +Note that the @JoinColumn is not really necessary in this example, +as the defaults would be the same. + +Generated MySQL Schema: + +.. code-block:: sql + + CREATE TABLE Product ( + id INT AUTO_INCREMENT NOT NULL, + shipping_id INT DEFAULT NULL, + UNIQUE INDEX UNIQ_6FBC94267FE4B2B (shipping_id), + PRIMARY KEY(id) + ) ENGINE = InnoDB; + CREATE TABLE Shipping ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + ALTER TABLE Product ADD FOREIGN KEY (shipping_id) REFERENCES Shipping(id); + +One-To-One, Bidirectional +------------------------- + +Here is a one-to-one relationship between a ``Customer`` and a +``Cart``. The ``Cart`` has a reference back to the ``Customer`` so +it is bidirectional. + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + + + .. code-block:: yaml + + Customer: + oneToOne: + cart: + targetEntity: Cart + mappedBy: customer + Cart: + oneToOne: + customer: + targetEntity: Customer + inversedBy: cart + joinColumn: + name: customer_id + referencedColumnName: id + +Note that the @JoinColumn is not really necessary in this example, +as the defaults would be the same. + +Generated MySQL Schema: + +.. code-block:: sql + + CREATE TABLE Cart ( + id INT AUTO_INCREMENT NOT NULL, + customer_id INT DEFAULT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + CREATE TABLE Customer ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + ALTER TABLE Cart ADD FOREIGN KEY (customer_id) REFERENCES Customer(id); + +See how the foreign key is defined on the owning side of the +relation, the table ``Cart``. + +One-To-One, Self-referencing +---------------------------- + +You can easily have self referencing one-to-one relationships like +below. + +.. code-block:: php + + phonenumbers = new \Doctrine\Common\Collections\ArrayCollection(); + } + + // ... + } + + /** @Entity **/ + class Phonenumber + { + // ... + } + + .. code-block:: xml + + + + + + + + + + + + + + + + + .. code-block:: yaml + + User: + type: entity + manyToMany: + phonenumbers: + targetEntity: Phonenumber + joinTable: + name: users_phonenumbers + joinColumns: + user_id: + referencedColumnName: id + inverseJoinColumns: + phonenumber_id: + referencedColumnName: id + unique: true + + +Generates the following MySQL Schema: + +.. code-block:: sql + + CREATE TABLE User ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + + CREATE TABLE users_phonenumbers ( + user_id INT NOT NULL, + phonenumber_id INT NOT NULL, + UNIQUE INDEX users_phonenumbers_phonenumber_id_uniq (phonenumber_id), + PRIMARY KEY(user_id, phonenumber_id) + ) ENGINE = InnoDB; + + CREATE TABLE Phonenumber ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + + ALTER TABLE users_phonenumbers ADD FOREIGN KEY (user_id) REFERENCES User(id); + ALTER TABLE users_phonenumbers ADD FOREIGN KEY (phonenumber_id) REFERENCES Phonenumber(id); + + +Many-To-One, Unidirectional +--------------------------- + +You can easily implement a many-to-one unidirectional association +with the following: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + .. code-block:: yaml + + User: + type: entity + manyToOne: + address: + targetEntity: Address + joinColumn: + name: address_id + referencedColumnName: id + + +.. note:: + + The above ``@JoinColumn`` is optional as it would default + to ``address_id`` and ``id`` anyways. You can omit it and let it + use the defaults. + + +Generated MySQL Schema: + +.. code-block:: sql + + CREATE TABLE User ( + id INT AUTO_INCREMENT NOT NULL, + address_id INT DEFAULT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + + CREATE TABLE Address ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + + ALTER TABLE User ADD FOREIGN KEY (address_id) REFERENCES Address(id); + +One-To-Many, Bidirectional +-------------------------- + +Bidirectional one-to-many associations are very common. The +following code shows an example with a Product and a Feature +class: + +.. configuration-block:: + + .. code-block:: php + + features = new \Doctrine\Common\Collections\ArrayCollection(); + } + } + + /** @Entity **/ + class Feature + { + // ... + /** + * @ManyToOne(targetEntity="Product", inversedBy="features") + * @JoinColumn(name="product_id", referencedColumnName="id") + **/ + private $product; + // ... + } + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: yaml + + Product: + type: entity + oneToMany: + features: + targetEntity: Feature + mappedBy: product + Feature: + type: entity + manyToOne: + product: + targetEntity: Product + inversedBy: features + joinColumn: + name: product_id + referencedColumnName: id + + +Note that the @JoinColumn is not really necessary in this example, +as the defaults would be the same. + +Generated MySQL Schema: + +.. code-block:: sql + + CREATE TABLE Product ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + CREATE TABLE Feature ( + id INT AUTO_INCREMENT NOT NULL, + product_id INT DEFAULT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + ALTER TABLE Feature ADD FOREIGN KEY (product_id) REFERENCES Product(id); + +One-To-Many, Self-referencing +----------------------------- + +You can also setup a one-to-many association that is +self-referencing. In this example we setup a hierarchy of +``Category`` objects by creating a self referencing relationship. +This effectively models a hierarchy of categories and from the +database perspective is known as an adjacency list approach. + +.. configuration-block:: + + .. code-block:: php + + children = new \Doctrine\Common\Collections\ArrayCollection(); + } + } + + .. code-block:: xml + + + + + + + + + .. code-block:: yaml + + Category: + type: entity + oneToMany: + children: + targetEntity: Category + mappedBy: parent + manyToOne: + parent: + targetEntity: Category + inversedBy: children + +Note that the @JoinColumn is not really necessary in this example, +as the defaults would be the same. + +Generated MySQL Schema: + +.. code-block:: sql + + CREATE TABLE Category ( + id INT AUTO_INCREMENT NOT NULL, + parent_id INT DEFAULT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + ALTER TABLE Category ADD FOREIGN KEY (parent_id) REFERENCES Category(id); + +Many-To-Many, Unidirectional +---------------------------- + +Real many-to-many associations are less common. The following +example shows a unidirectional association between User and Group +entities: + +.. configuration-block:: + + .. code-block:: php + + groups = new \Doctrine\Common\Collections\ArrayCollection(); + } + } + + /** @Entity **/ + class Group + { + // ... + } + + .. code-block:: xml + + + + + + + + + + + + + + + + + .. code-block:: yaml + + User: + type: entity + manyToMany: + groups: + targetEntity: Group + joinTable: + name: users_groups + joinColumns: + user_id: + referencedColumnName: id + inverseJoinColumns: + group_id: + referencedColumnName: id + +Generated MySQL Schema: + +.. code-block:: sql + + CREATE TABLE User ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + CREATE TABLE users_groups ( + user_id INT NOT NULL, + group_id INT NOT NULL, + PRIMARY KEY(user_id, group_id) + ) ENGINE = InnoDB; + CREATE TABLE Group ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + ALTER TABLE users_groups ADD FOREIGN KEY (user_id) REFERENCES User(id); + ALTER TABLE users_groups ADD FOREIGN KEY (group_id) REFERENCES Group(id); + +.. note:: + + Why are many-to-many associations less common? Because + frequently you want to associate additional attributes with an + association, in which case you introduce an association class. + Consequently, the direct many-to-many association disappears and is + replaced by one-to-many/many-to-one associations between the 3 + participating classes. + +Many-To-Many, Bidirectional +--------------------------- + +Here is a similar many-to-many relationship as above except this +one is bidirectional. + +.. configuration-block:: + + .. code-block:: php + + groups = new \Doctrine\Common\Collections\ArrayCollection(); + } + + // ... + } + + /** @Entity **/ + class Group + { + // ... + /** + * @ManyToMany(targetEntity="User", mappedBy="groups") + **/ + private $users; + + public function __construct() { + $this->users = new \Doctrine\Common\Collections\ArrayCollection(); + } + + // ... + } + + .. code-block:: xml + + + + + + + + + + + + + + + + + + + + + .. code-block:: yaml + + User: + type: entity + manyToMany: + groups: + targetEntity: Group + inversedBy: users + joinTable: + name: users_groups + joinColumns: + user_id: + referencedColumnName: id + inverseJoinColumns: + group_id: + referencedColumnName: id + + Group: + type: entity + manyToMany: + users: + targetEntity: User + mappedBy: groups + +The MySQL schema is exactly the same as for the Many-To-Many +uni-directional case above. + +Picking Owning and Inverse Side +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For Many-To-Many associations you can chose which entity is the +owning and which the inverse side. There is a very simple semantic +rule to decide which side is more suitable to be the owning side +from a developers perspective. You only have to ask yourself, which +entity is responsible for the connection management and pick that +as the owning side. + +Take an example of two entities ``Article`` and ``Tag``. Whenever +you want to connect an Article to a Tag and vice-versa, it is +mostly the Article that is responsible for this relation. Whenever +you add a new article, you want to connect it with existing or new +tags. Your create Article form will probably support this notion +and allow to specify the tags directly. This is why you should pick +the Article as owning side, as it makes the code more +understandable: + +.. code-block:: php + + addArticle($this); // synchronously updating inverse side + $this->tags[] = $tag; + } + } + + class Tag + { + private $articles; + + public function addArticle(Article $article) + { + $this->articles[] = $article; + } + } + +This allows to group the tag adding on the ``Article`` side of the +association: + +.. code-block:: php + + addTag($tagA); + $article->addTag($tagB); + +Many-To-Many, Self-referencing +------------------------------ + +You can even have a self-referencing many-to-many association. A +common scenario is where a ``User`` has friends and the target +entity of that relationship is a ``User`` so it is self +referencing. In this example it is bidirectional so ``User`` has a +field named ``$friendsWithMe`` and ``$myFriends``. + +.. code-block:: php + + friendsWithMe = new \Doctrine\Common\Collections\ArrayCollection(); + $this->myFriends = new \Doctrine\Common\Collections\ArrayCollection(); + } + + // ... + } + +Generated MySQL Schema: + +.. code-block:: sql + + CREATE TABLE User ( + id INT AUTO_INCREMENT NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + CREATE TABLE friends ( + user_id INT NOT NULL, + friend_user_id INT NOT NULL, + PRIMARY KEY(user_id, friend_user_id) + ) ENGINE = InnoDB; + ALTER TABLE friends ADD FOREIGN KEY (user_id) REFERENCES User(id); + ALTER TABLE friends ADD FOREIGN KEY (friend_user_id) REFERENCES User(id); + +.. _association_mapping_defaults: + +Mapping Defaults +---------------- + +Before we introduce all the association mappings in detail, you +should note that the @JoinColumn and @JoinTable definitions are +usually optional and have sensible default values. The defaults for +a join column in a one-to-one/many-to-one association is as +follows: + +:: + + name: "_id" + referencedColumnName: "id" + +As an example, consider this mapping: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + .. code-block:: yaml + + Product: + type: entity + oneToOne: + shipping: + targetEntity: Shipping + +This is essentially the same as the following, more verbose, +mapping: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + .. code-block:: yaml + + Product: + type: entity + oneToOne: + shipping: + targetEntity: Shipping + joinColumn: + name: shipping_id + referencedColumnName: id + +The @JoinTable definition used for many-to-many mappings has +similar defaults. As an example, consider this mapping: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + .. code-block:: yaml + + User: + type: entity + manyToMany: + groups: + targetEntity: Group + +This is essentially the same as the following, more verbose, +mapping: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + + + + + + + .. code-block:: yaml + + User: + type: entity + manyToMany: + groups: + targetEntity: Group + joinTable: + name: User_Group + joinColumns: + User_id: + referencedColumnName: id + inverseJoinColumns: + Group_id: + referencedColumnName: id + +In that case, the name of the join table defaults to a combination +of the simple, unqualified class names of the participating +classes, separated by an underscore character. The names of the +join columns default to the simple, unqualified class name of the +targeted class followed by "\_id". The referencedColumnName always +defaults to "id", just as in one-to-one or many-to-one mappings. + +If you accept these defaults, you can reduce the mapping code to a +minimum. + +.. _collections: + +Collections +----------- + +In all the examples of many-valued associations in this manual we +will make use of a ``Collection`` interface and a corresponding +default implementation ``ArrayCollection`` that are defined in the +``Doctrine\Common\Collections`` namespace. Why do we need that? +Doesn't that couple my domain model to Doctrine? Unfortunately, PHP +arrays, while being great for many things, do not make up for good +collections of business objects, especially not in the context of +an ORM. The reason is that plain PHP arrays can not be +transparently extended / instrumented in PHP code, which is +necessary for a lot of advanced ORM features. The classes / +interfaces that come closest to an OO collection are ArrayAccess +and ArrayObject but until instances of these types can be used in +all places where a plain array can be used (something that may +happen in PHP6) their usability is fairly limited. You "can" +type-hint on ``ArrayAccess`` instead of ``Collection``, since the +Collection interface extends ``ArrayAccess``, but this will +severely limit you in the way you can work with the collection, +because the ``ArrayAccess`` API is (intentionally) very primitive +and more importantly because you can not pass this collection to +all the useful PHP array functions, which makes it very hard to +work with. + +.. warning:: + + The Collection interface and ArrayCollection class, + like everything else in the Doctrine namespace, are neither part of + the ORM, nor the DBAL, it is a plain PHP class that has no outside + dependencies apart from dependencies on PHP itself (and the SPL). + Therefore using this class in your domain classes and elsewhere + does not introduce a coupling to the persistence layer. The + Collection class, like everything else in the Common namespace, is + not part of the persistence layer. You could even copy that class + over to your project if you want to remove Doctrine from your + project and all your domain classes will work the same as before. + + + +Initializing Collections +------------------------ + +You have to be careful when using entity fields that contain a +collection of related entities. Say we have a User entity that +contains a collection of groups: + +.. code-block:: php + + groups; + } + } + +With this code alone the ``$groups`` field only contains an +instance of ``Doctrine\Common\Collections\Collection`` if the user +is retrieved from Doctrine, however not after you instantiated a +fresh instance of the User. When your user entity is still new +``$groups`` will obviously be null. + +This is why we recommend to initialize all collection fields to an +empty ``ArrayCollection`` in your entities constructor: + +.. code-block:: php + + groups = new ArrayCollection(); + } + + public function getGroups() + { + return $this->groups; + } + } + +Now the following code will work even if the Entity hasn't +been associated with an EntityManager yet: + +.. code-block:: php + + find('Group', $groupId); + $user = new User(); + $user->getGroups()->add($group); + diff --git a/vendor/doctrine/orm/docs/en/reference/basic-mapping.rst b/vendor/doctrine/orm/docs/en/reference/basic-mapping.rst new file mode 100644 index 0000000000..2909048dd4 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/basic-mapping.rst @@ -0,0 +1,683 @@ +Basic Mapping +============= + +This chapter explains the basic mapping of objects and properties. +Mapping of associations will be covered in the next chapter +"Association Mapping". + +Mapping Drivers +--------------- + +Doctrine provides several different ways for specifying +object-relational mapping metadata: + + +- Docblock Annotations +- XML +- YAML + +This manual usually mentions docblock annotations in all the examples +that are spread throughout all chapters, however for many examples +alternative YAML and XML examples are given as well. There are dedicated +reference chapters for XML and YAML mapping, respectively that explain them +in more detail. There is also an Annotation reference chapter. + +.. note:: + + If you're wondering which mapping driver gives the best + performance, the answer is: They all give exactly the same performance. + Once the metadata of a class has + been read from the source (annotations, xml or yaml) it is stored + in an instance of the ``Doctrine\ORM\Mapping\ClassMetadata`` class + and these instances are stored in the metadata cache. Therefore at + the end of the day all drivers perform equally well. If you're not + using a metadata cache (not recommended!) then the XML driver might + have a slight edge in performance due to the powerful native XML + support in PHP. + + +Introduction to Docblock Annotations +------------------------------------ + +You've probably used docblock annotations in some form already, +most likely to provide documentation metadata for a tool like +``PHPDocumentor`` (@author, @link, ...). Docblock annotations are a +tool to embed metadata inside the documentation section which can +then be processed by some tool. Doctrine 2 generalizes the concept +of docblock annotations so that they can be used for any kind of +metadata and so that it is easy to define new docblock annotations. +In order to allow more involved annotation values and to reduce the +chances of clashes with other docblock annotations, the Doctrine 2 +docblock annotations feature an alternative syntax that is heavily +inspired by the Annotation syntax introduced in Java 5. + +The implementation of these enhanced docblock annotations is +located in the ``Doctrine\Common\Annotations`` namespace and +therefore part of the Common package. Doctrine 2 docblock +annotations support namespaces and nested annotations among other +things. The Doctrine 2 ORM defines its own set of docblock +annotations for supplying object-relational mapping metadata. + +.. note:: + + If you're not comfortable with the concept of docblock + annotations, don't worry, as mentioned earlier Doctrine 2 provides + XML and YAML alternatives and you could easily implement your own + favourite mechanism for defining ORM metadata. + + +Persistent classes +------------------ + +In order to mark a class for object-relational persistence it needs +to be designated as an entity. This can be done through the +``@Entity`` marker annotation. + +.. configuration-block:: + + .. code-block:: php + + + + + + + + .. code-block:: yaml + + MyPersistentClass: + type: entity + # ... + +By default, the entity will be persisted to a table with the same +name as the class name. In order to change that, you can use the +``@Table`` annotation as follows: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + .. code-block:: yaml + + MyPersistentClass: + type: entity + table: my_persistent_class + # ... + +Now instances of MyPersistentClass will be persisted into a table +named ``my_persistent_class``. + +Doctrine Mapping Types +---------------------- + +A Doctrine Mapping Type defines the mapping between a PHP type and +a SQL type. All Doctrine Mapping Types that ship with Doctrine are +fully portable between different RDBMS. You can even write your own +custom mapping types that might or might not be portable, which is +explained later in this chapter. + +For example, the Doctrine Mapping Type ``string`` defines the +mapping from a PHP string to a SQL VARCHAR (or VARCHAR2 etc. +depending on the RDBMS brand). Here is a quick overview of the +built-in mapping types: + + +- ``string``: Type that maps a SQL VARCHAR to a PHP string. +- ``integer``: Type that maps a SQL INT to a PHP integer. +- ``smallint``: Type that maps a database SMALLINT to a PHP + integer. +- ``bigint``: Type that maps a database BIGINT to a PHP string. +- ``boolean``: Type that maps a SQL boolean to a PHP boolean. +- ``decimal``: Type that maps a SQL DECIMAL to a PHP string. +- ``date``: Type that maps a SQL DATETIME to a PHP DateTime + object. +- ``time``: Type that maps a SQL TIME to a PHP DateTime object. +- ``datetime``: Type that maps a SQL DATETIME/TIMESTAMP to a PHP + DateTime object. +- ``datetimetz``: Type that maps a SQL DATETIME/TIMESTAMP to a PHP + DateTime object with timezone. +- ``text``: Type that maps a SQL CLOB to a PHP string. +- ``object``: Type that maps a SQL CLOB to a PHP object using + ``serialize()`` and ``unserialize()`` +- ``array``: Type that maps a SQL CLOB to a PHP array using + ``serialize()`` and ``unserialize()`` +- ``simple_array``: Type that maps a SQL CLOB to a PHP array using + ``implode()`` and ``explode()``, with a comma as delimiter. *IMPORTANT* + Only use this type if you are sure that your values cannot contain a ",". +- ``json_array``: Type that maps a SQL CLOB to a PHP array using + ``json_encode()`` and ``json_decode()`` +- ``float``: Type that maps a SQL Float (Double Precision) to a + PHP double. *IMPORTANT*: Works only with locale settings that use + decimal points as separator. +- ``guid``: Type that maps a database GUID/UUID to a PHP string. Defaults to + varchar but uses a specific type if the platform supports it. +- ``blob``: Type that maps a SQL BLOB to a PHP resource stream + +.. note:: + + Doctrine Mapping Types are NOT SQL types and NOT PHP + types! They are mapping types between 2 types. + Additionally Mapping types are *case-sensitive*. For example, using + a DateTime column will NOT match the datetime type that ships with + Doctrine 2. + +.. note:: + + DateTime and Object types are compared by reference, not by value. Doctrine updates this values + if the reference changes and therefore behaves as if these objects are immutable value objects. + +.. warning:: + + All Date types assume that you are exclusively using the default timezone + set by `date_default_timezone_set() `_ + or by the php.ini configuration ``date.timezone``. Working with + different timezones will cause troubles and unexpected behavior. + + If you need specific timezone handling you have to handle this + in your domain, converting all the values back and forth from UTC. + There is also a :doc:`cookbook entry <../cookbook/working-with-datetime>` + on working with datetimes that gives hints for implementing + multi timezone applications. + + +Property Mapping +---------------- + +After a class has been marked as an entity it can specify mappings +for its instance fields. Here we will only look at simple fields +that hold scalar values like strings, numbers, etc. Associations to +other objects are covered in the chapter "Association Mapping". + +To mark a property for relational persistence the ``@Column`` +docblock annotation is used. This annotation usually requires at +least 1 attribute to be set, the ``type``. The ``type`` attribute +specifies the Doctrine Mapping Type to use for the field. If the +type is not specified, 'string' is used as the default mapping type +since it is the most flexible. + +Example: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + .. code-block:: yaml + + MyPersistentClass: + type: entity + fields: + id: + type: integer + name: + length: 50 + +In that example we mapped the field ``id`` to the column ``id`` +using the mapping type ``integer`` and the field ``name`` is mapped +to the column ``name`` with the default mapping type ``string``. As +you can see, by default the column names are assumed to be the same +as the field names. To specify a different name for the column, you +can use the ``name`` attribute of the Column annotation as +follows: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + .. code-block:: yaml + + MyPersistentClass: + type: entity + fields: + name: + length: 50 + column: db_name + +The Column annotation has some more attributes. Here is a complete +list: + + +- ``type``: (optional, defaults to 'string') The mapping type to + use for the column. +- ``column``: (optional, defaults to field name) The name of the + column in the database. +- ``length``: (optional, default 255) The length of the column in + the database. (Applies only if a string-valued column is used). +- ``unique``: (optional, default FALSE) Whether the column is a + unique key. +- ``nullable``: (optional, default FALSE) Whether the database + column is nullable. +- ``precision``: (optional, default 0) The precision for a decimal + (exact numeric) column. (Applies only if a decimal column is used.) +- ``scale``: (optional, default 0) The scale for a decimal (exact + numeric) column. (Applies only if a decimal column is used.) + +.. _reference-basic-mapping-custom-mapping-types: + +Custom Mapping Types +-------------------- + +Doctrine allows you to create new mapping types. This can come in +handy when you're missing a specific mapping type or when you want +to replace the existing implementation of a mapping type. + +In order to create a new mapping type you need to subclass +``Doctrine\DBAL\Types\Type`` and implement/override the methods as +you wish. Here is an example skeleton of such a custom type class: + +.. code-block:: php + + getConnection(); + $conn->getDatabasePlatform()->registerDoctrineTypeMapping('db_mytype', 'mytype'); + +Now using Schema-Tool, whenever it detects a column having the +``db_mytype`` it will convert it into a ``mytype`` Doctrine Type +instance for Schema representation. Keep in mind that you can +easily produce clashes this way, each database type can only map to +exactly one Doctrine mapping type. + +Custom ColumnDefinition +----------------------- + +You can define a custom definition for each column using the "columnDefinition" +attribute of ``@Column``. You have to define all the definitions that follow +the name of a column here. + +.. note:: + + Using columnDefinition will break change-detection in SchemaTool. + +Identifiers / Primary Keys +-------------------------- + +Every entity class needs an identifier/primary key. You designate +the field that serves as the identifier with the ``@Id`` marker +annotation. Here is an example: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + .. code-block:: yaml + + MyPersistentClass: + type: entity + id: + id: + type: integer + fields: + name: + length: 50 + +Without doing anything else, the identifier is assumed to be +manually assigned. That means your code would need to properly set +the identifier property before passing a new entity to +``EntityManager#persist($entity)``. + +A common alternative strategy is to use a generated value as the +identifier. To do this, you use the ``@GeneratedValue`` annotation +like this: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + .. code-block:: yaml + + MyPersistentClass: + type: entity + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + length: 50 + +This tells Doctrine to automatically generate a value for the +identifier. How this value is generated is specified by the +``strategy`` attribute, which is optional and defaults to 'AUTO'. A +value of ``AUTO`` tells Doctrine to use the generation strategy +that is preferred by the currently used database platform. See +below for details. + +Identifier Generation Strategies +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The previous example showed how to use the default identifier +generation strategy without knowing the underlying database with +the AUTO-detection strategy. It is also possible to specify the +identifier generation strategy more explicitly, which allows to +make use of some additional features. + +Here is the list of possible generation strategies: + + +- ``AUTO`` (default): Tells Doctrine to pick the strategy that is + preferred by the used database platform. The preferred strategies + are IDENTITY for MySQL, SQLite and MsSQL and SEQUENCE for Oracle + and PostgreSQL. This strategy provides full portability. +- ``SEQUENCE``: Tells Doctrine to use a database sequence for ID + generation. This strategy does currently not provide full + portability. Sequences are supported by Oracle and PostgreSql. +- ``IDENTITY``: Tells Doctrine to use special identity columns in + the database that generate a value on insertion of a row. This + strategy does currently not provide full portability and is + supported by the following platforms: MySQL/SQLite + (AUTO\_INCREMENT), MSSQL (IDENTITY) and PostgreSQL (SERIAL). +- ``TABLE``: Tells Doctrine to use a separate table for ID + generation. This strategy provides full portability. + ***This strategy is not yet implemented!*** +- ``NONE``: Tells Doctrine that the identifiers are assigned (and + thus generated) by your code. The assignment must take place before + a new entity is passed to ``EntityManager#persist``. NONE is the + same as leaving off the @GeneratedValue entirely. + +Sequence Generator +^^^^^^^^^^^^^^^^^^ + +The Sequence Generator can currently be used in conjunction with +Oracle or Postgres and allows some additional configuration options +besides specifying the sequence's name: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + .. code-block:: yaml + + MyPersistentClass: + type: entity + id: + id: + type: integer + generator: + strategy: SEQUENCE + sequenceGenerator: + sequenceName: tablename_seq + allocationSize: 100 + initialValue: 1 + +The initial value specifies at which value the sequence should +start. + +The allocationSize is a powerful feature to optimize INSERT +performance of Doctrine. The allocationSize specifies by how much +values the sequence is incremented whenever the next value is +retrieved. If this is larger than 1 (one) Doctrine can generate +identifier values for the allocationSizes amount of entities. In +the above example with ``allocationSize=100`` Doctrine 2 would only +need to access the sequence once to generate the identifiers for +100 new entities. + +*The default allocationSize for a @SequenceGenerator is currently 10.* + +.. caution:: + + The allocationSize is detected by SchemaTool and + transformed into an "INCREMENT BY " clause in the CREATE SEQUENCE + statement. For a database schema created manually (and not + SchemaTool) you have to make sure that the allocationSize + configuration option is never larger than the actual sequences + INCREMENT BY value, otherwise you may get duplicate keys. + + +.. note:: + + It is possible to use strategy="AUTO" and at the same time + specifying a @SequenceGenerator. In such a case, your custom + sequence settings are used in the case where the preferred strategy + of the underlying platform is SEQUENCE, such as for Oracle and + PostgreSQL. + + +Composite Keys +~~~~~~~~~~~~~~ + +Doctrine 2 allows to use composite primary keys. There are however +some restrictions opposed to using a single identifier. The use of +the ``@GeneratedValue`` annotation is only supported for simple +(not composite) primary keys, which means you can only use +composite keys if you generate the primary key values yourself +before calling ``EntityManager#persist()`` on the entity. + +To designate a composite primary key / identifier, simply put the +@Id marker annotation on all fields that make up the primary key. + +Quoting Reserved Words +---------------------- + +It may sometimes be necessary to quote a column or table name +because it conflicts with a reserved word of the particular RDBMS +in use. This is often referred to as "Identifier Quoting". To let +Doctrine know that you would like a table or column name to be +quoted in all SQL statements, enclose the table or column name in +backticks. Here is an example: + +.. code-block:: php + + setStatus('user'); + $user->setUsername('user' . $i); + $user->setName('Mr.Smith-' . $i); + $em->persist($user); + if (($i % $batchSize) === 0) { + $em->flush(); + $em->clear(); // Detaches all objects from Doctrine! + } + } + +Bulk Updates +------------ + +There are 2 possibilities for bulk updates with Doctrine. + +DQL UPDATE +~~~~~~~~~~ + +The by far most efficient way for bulk updates is to use a DQL +UPDATE query. Example: + +.. code-block:: php + + createQuery('update MyProject\Model\Manager m set m.salary = m.salary * 0.9'); + $numUpdated = $q->execute(); + +Iterating results +~~~~~~~~~~~~~~~~~ + +An alternative solution for bulk updates is to use the +``Query#iterate()`` facility to iterate over the query results step +by step instead of loading the whole result into memory at once. +The following example shows how to do this, combining the iteration +with the batching strategy that was already used for bulk inserts: + +.. code-block:: php + + createQuery('select u from MyProject\Model\User u'); + $iterableResult = $q->iterate(); + foreach($iterableResult AS $row) { + $user = $row[0]; + $user->increaseCredit(); + $user->calculateNewBonuses(); + if (($i % $batchSize) === 0) { + $em->flush(); // Executes all updates. + $em->clear(); // Detaches all objects from Doctrine! + } + ++$i; + } + $em->flush(); + +.. note:: + + Iterating results is not possible with queries that + fetch-join a collection-valued association. The nature of such SQL + result sets is not suitable for incremental hydration. + + +Bulk Deletes +------------ + +There are two possibilities for bulk deletes with Doctrine. You can +either issue a single DQL DELETE query or you can iterate over +results removing them one at a time. + +DQL DELETE +~~~~~~~~~~ + +The by far most efficient way for bulk deletes is to use a DQL +DELETE query. + +Example: + +.. code-block:: php + + createQuery('delete from MyProject\Model\Manager m where m.salary > 100000'); + $numDeleted = $q->execute(); + +Iterating results +~~~~~~~~~~~~~~~~~ + +An alternative solution for bulk deletes is to use the +``Query#iterate()`` facility to iterate over the query results step +by step instead of loading the whole result into memory at once. +The following example shows how to do this: + +.. code-block:: php + + createQuery('select u from MyProject\Model\User u'); + $iterableResult = $q->iterate(); + while (($row = $iterableResult->next()) !== false) { + $em->remove($row[0]); + if (($i % $batchSize) === 0) { + $em->flush(); // Executes all deletions. + $em->clear(); // Detaches all objects from Doctrine! + } + ++$i; + } + $em->flush(); + +.. note:: + + Iterating results is not possible with queries that + fetch-join a collection-valued association. The nature of such SQL + result sets is not suitable for incremental hydration. + + +Iterating Large Results for Data-Processing +------------------------------------------- + +You can use the ``iterate()`` method just to iterate over a large +result and no UPDATE or DELETE intention. The ``IterableResult`` +instance returned from ``$query->iterate()`` implements the +Iterator interface so you can process a large result without memory +problems using the following approach: + +.. code-block:: php + + _em->createQuery('select u from MyProject\Model\User u'); + $iterableResult = $q->iterate(); + foreach ($iterableResult AS $row) { + // do stuff with the data in the row, $row[0] is always the object + + // detach from Doctrine, so that it can be Garbage-Collected immediately + $this->_em->detach($row[0]); + } + +.. note:: + + Iterating results is not possible with queries that + fetch-join a collection-valued association. The nature of such SQL + result sets is not suitable for incremental hydration. + + + diff --git a/vendor/doctrine/orm/docs/en/reference/best-practices.rst b/vendor/doctrine/orm/docs/en/reference/best-practices.rst new file mode 100644 index 0000000000..f58291d187 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/best-practices.rst @@ -0,0 +1,127 @@ +Best Practices +============== + +The best practices mentioned here that affect database +design generally refer to best practices when working with Doctrine +and do not necessarily reflect best practices for database design +in general. + + +Don't use public properties on entities +--------------------------------------- + +It is very important that you don't map public properties on +entities, but only protected or private ones. The reason for this +is simple, whenever you access a public property of a proxy object +that hasn't been initialized yet the return value will be null. +Doctrine cannot hook into this process and magically make the +entity lazy load. + +This can create situations where it is very hard to debug the +current failure. We therefore urge you to map only private and +protected properties on entities and use getter methods or magic +\_\_get() to access them. + +Constrain relationships as much as possible +------------------------------------------- + +It is important to constrain relationships as much as possible. +This means: + + +- Impose a traversal direction (avoid bidirectional associations + if possible) +- Eliminate nonessential associations + +This has several benefits: + + +- Reduced coupling in your domain model +- Simpler code in your domain model (no need to maintain + bidirectionality properly) +- Less work for Doctrine + +Avoid composite keys +-------------------- + +Even though Doctrine fully supports composite keys it is best not +to use them if possible. Composite keys require additional work by +Doctrine and thus have a higher probability of errors. + +Use events judiciously +---------------------- + +The event system of Doctrine is great and fast. Even though making +heavy use of events, especially lifecycle events, can have a +negative impact on the performance of your application. Thus you +should use events judiciously. + +Use cascades judiciously +------------------------ + +Automatic cascades of the persist/remove/merge/etc. operations are +very handy but should be used wisely. Do NOT simply add all +cascades to all associations. Think about which cascades actually +do make sense for you for a particular association, given the +scenarios it is most likely used in. + +Don't use special characters +---------------------------- + +Avoid using any non-ASCII characters in class, field, table or +column names. Doctrine itself is not unicode-safe in many places +and will not be until PHP itself is fully unicode-aware (PHP6). + +Don't use identifier quoting +---------------------------- + +Identifier quoting is a workaround for using reserved words that +often causes problems in edge cases. Do not use identifier quoting +and avoid using reserved words as table or column names. + +Initialize collections in the constructor +----------------------------------------- + +It is recommended best practice to initialize any business +collections in entities in the constructor. Example: + +.. code-block:: php + + addresses = new ArrayCollection; + $this->articles = new ArrayCollection; + } + } + +Don't map foreign keys to fields in an entity +--------------------------------------------- + +Foreign keys have no meaning whatsoever in an object model. Foreign +keys are how a relational database establishes relationships. Your +object model establishes relationships through object references. +Thus mapping foreign keys to object fields heavily leaks details of +the relational model into the object model, something you really +should not do. + +Use explicit transaction demarcation +------------------------------------ + +While Doctrine will automatically wrap all DML operations in a +transaction on flush(), it is considered best practice to +explicitly set the transaction boundaries yourself. Otherwise every +single query is wrapped in a small transaction (Yes, SELECT +queries, too) since you can not talk to your database outside of a +transaction. While such short transactions for read-only (SELECT) +queries generally don't have any noticeable performance impact, it +is still preferable to use fewer, well-defined transactions that +are established through explicit transaction boundaries. + + diff --git a/vendor/doctrine/orm/docs/en/reference/caching.rst b/vendor/doctrine/orm/docs/en/reference/caching.rst new file mode 100644 index 0000000000..1e87efaffe --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/caching.rst @@ -0,0 +1,439 @@ +Caching +======= + +Doctrine provides cache drivers in the ``Common`` package for some +of the most popular caching implementations such as APC, Memcache +and Xcache. We also provide an ``ArrayCache`` driver which stores +the data in a PHP array. Obviously, the cache does not live between +requests but this is useful for testing in a development +environment. + +Cache Drivers +------------- + +The cache drivers follow a simple interface that is defined in +``Doctrine\Common\Cache\Cache``. All the cache drivers extend a +base class ``Doctrine\Common\Cache\AbstractCache`` which implements +the before mentioned interface. + +The interface defines the following methods for you to publicly +use. + + +- fetch($id) - Fetches an entry from the cache. +- contains($id) - Test if an entry exists in the cache. +- save($id, $data, $lifeTime = false) - Puts data into the cache. +- delete($id) - Deletes a cache entry. + +Each driver extends the ``AbstractCache`` class which defines a few +abstract protected methods that each of the drivers must +implement. + + +- \_doFetch($id) +- \_doContains($id) +- \_doSave($id, $data, $lifeTime = false) +- \_doDelete($id) + +The public methods ``fetch()``, ``contains()``, etc. utilize the +above protected methods that are implemented by the drivers. The +code is organized this way so that the protected methods in the +drivers do the raw interaction with the cache implementation and +the ``AbstractCache`` can build custom functionality on top of +these methods. + +APC +~~~ + +In order to use the APC cache driver you must have it compiled and +enabled in your php.ini. You can read about APC +`in the PHP Documentation `_. It will give +you a little background information about what it is and how you +can use it as well as how to install it. + +Below is a simple example of how you could use the APC cache driver +by itself. + +.. code-block:: php + + save('cache_id', 'my_data'); + +Memcache +~~~~~~~~ + +In order to use the Memcache cache driver you must have it compiled +and enabled in your php.ini. You can read about Memcache +` on the PHP website `_. It will +give you a little background information about what it is and how +you can use it as well as how to install it. + +Below is a simple example of how you could use the Memcache cache +driver by itself. + +.. code-block:: php + + connect('memcache_host', 11211); + + $cacheDriver = new \Doctrine\Common\Cache\MemcacheCache(); + $cacheDriver->setMemcache($memcache); + $cacheDriver->save('cache_id', 'my_data'); + +Xcache +~~~~~~ + +In order to use the Xcache cache driver you must have it compiled +and enabled in your php.ini. You can read about Xcache +`here `_. It will give you a little +background information about what it is and how you can use it as +well as how to install it. + +Below is a simple example of how you could use the Xcache cache +driver by itself. + +.. code-block:: php + + save('cache_id', 'my_data'); + +Redis +~~~~~ + +In order to use the Redis cache driver you must have it compiled +and enabled in your php.ini. You can read about what is Redis +`from here `_. Also check +`here `_ for how you can use +and install Redis PHP extension. + +Below is a simple example of how you could use the Redis cache +driver by itself. + +.. code-block:: php + + connect('redis_host', 6379); + + $cacheDriver = new \Doctrine\Common\Cache\RedisCache(); + $cacheDriver->setRedis($redis); + $cacheDriver->save('cache_id', 'my_data'); + +Using Cache Drivers +------------------- + +In this section we'll describe how you can fully utilize the API of +the cache drivers to save cache, check if some cache exists, fetch +the cached data and delete the cached data. We'll use the +``ArrayCache`` implementation as our example here. + +.. code-block:: php + + save('cache_id', 'my_data'); + +The ``save()`` method accepts three arguments which are described +below. + + +- ``$id`` - The cache id +- ``$data`` - The cache entry/data. +- ``$lifeTime`` - The lifetime. If != false, sets a specific + lifetime for this cache entry (null => infinite lifeTime). + +You can save any type of data whether it be a string, array, +object, etc. + +.. code-block:: php + + 'value1', + 'key2' => 'value2' + ); + $cacheDriver->save('my_array', $array); + +Checking +~~~~~~~~ + +Checking whether some cache exists is very simple, just use the +``contains()`` method. It accepts a single argument which is the ID +of the cache entry. + +.. code-block:: php + + contains('cache_id')) { + echo 'cache exists'; + } else { + echo 'cache does not exist'; + } + +Fetching +~~~~~~~~ + +Now if you want to retrieve some cache entry you can use the +``fetch()`` method. It also accepts a single argument just like +``contains()`` which is the ID of the cache entry. + +.. code-block:: php + + fetch('my_array'); + +Deleting +~~~~~~~~ + +As you might guess, deleting is just as easy as saving, checking +and fetching. We have a few ways to delete cache entries. You can +delete by an individual ID, regular expression, prefix, suffix or +you can delete all entries. + +By Cache ID +^^^^^^^^^^^ + +.. code-block:: php + + delete('my_array'); + +All +^^^ + +If you simply want to delete all cache entries you can do so with +the ``deleteAll()`` method. + +.. code-block:: php + + deleteAll(); + +Namespaces +~~~~~~~~~~ + +If you heavily use caching in your application and utilize it in +multiple parts of your application, or use it in different +applications on the same server you may have issues with cache +naming collisions. This can be worked around by using namespaces. +You can set the namespace a cache driver should use by using the +``setNamespace()`` method. + +.. code-block:: php + + setNamespace('my_namespace_'); + +Integrating with the ORM +------------------------ + +The Doctrine ORM package is tightly integrated with the cache +drivers to allow you to improve performance of various aspects of +Doctrine by just simply making some additional configurations and +method calls. + +Query Cache +~~~~~~~~~~~ + +It is highly recommended that in a production environment you cache +the transformation of a DQL query to its SQL counterpart. It +doesn't make sense to do this parsing multiple times as it doesn't +change unless you alter the DQL query. + +This can be done by configuring the query cache implementation to +use on your ORM configuration. + +.. code-block:: php + + setQueryCacheImpl(new \Doctrine\Common\Cache\ApcCache()); + +Result Cache +~~~~~~~~~~~~ + +The result cache can be used to cache the results of your queries +so that we don't have to query the database or hydrate the data +again after the first time. You just need to configure the result +cache implementation. + +.. code-block:: php + + setResultCacheImpl(new \Doctrine\Common\Cache\ApcCache()); + +Now when you're executing DQL queries you can configure them to use +the result cache. + +.. code-block:: php + + createQuery('select u from \Entities\User u'); + $query->useResultCache(true); + +You can also configure an individual query to use a different +result cache driver. + +.. code-block:: php + + setResultCacheDriver(new \Doctrine\Common\Cache\ApcCache()); + +.. note:: + + Setting the result cache driver on the query will + automatically enable the result cache for the query. If you want to + disable it pass false to ``useResultCache()``. + + :: + + useResultCache(false); + + +If you want to set the time the cache has to live you can use the +``setResultCacheLifetime()`` method. + +.. code-block:: php + + setResultCacheLifetime(3600); + +The ID used to store the result set cache is a hash which is +automatically generated for you if you don't set a custom ID +yourself with the ``setResultCacheId()`` method. + +.. code-block:: php + + setResultCacheId('my_custom_id'); + +You can also set the lifetime and cache ID by passing the values as +the second and third argument to ``useResultCache()``. + +.. code-block:: php + + useResultCache(true, 3600, 'my_custom_id'); + +Metadata Cache +~~~~~~~~~~~~~~ + +Your class metadata can be parsed from a few different sources like +YAML, XML, Annotations, etc. Instead of parsing this information on +each request we should cache it using one of the cache drivers. + +Just like the query and result cache we need to configure it +first. + +.. code-block:: php + + setMetadataCacheImpl(new \Doctrine\Common\Cache\ApcCache()); + +Now the metadata information will only be parsed once and stored in +the cache driver. + +Clearing the Cache +------------------ + +We've already shown you previously how you can use the API of the +cache drivers to manually delete cache entries. For your +convenience we offer a command line task for you to help you with +clearing the query, result and metadata cache. + +From the Doctrine command line you can run the following command. + +.. code-block:: php + + $ ./doctrine clear-cache + +Running this task with no arguments will clear all the cache for +all the configured drivers. If you want to be more specific about +what you clear you can use the following options. + +To clear the query cache use the ``--query`` option. + +.. code-block:: php + + $ ./doctrine clear-cache --query + +To clear the metadata cache use the ``--metadata`` option. + +.. code-block:: php + + $ ./doctrine clear-cache --metadata + +To clear the result cache use the ``--result`` option. + +.. code-block:: php + + $ ./doctrine clear-cache --result + +When you use the ``--result`` option you can use some other options +to be more specific about what queries result sets you want to +clear. + +Just like the API of the cache drivers you can clear based on an +ID, regular expression, prefix or suffix. + +.. code-block:: php + + $ ./doctrine clear-cache --result --id=cache_id + +Or if you want to clear based on a regular expressions. + +.. code-block:: php + + $ ./doctrine clear-cache --result --regex=users_.* + +Or with a prefix. + +.. code-block:: php + + $ ./doctrine clear-cache --result --prefix=users_ + +And finally with a suffix. + +.. code-block:: php + + $ ./doctrine clear-cache --result --suffix=_my_account + +.. note:: + + Using the ``--id``, ``--regex``, etc. options with the + ``--query`` and ``--metadata`` are not allowed as it is not + necessary to be specific about what you clear. You only ever need + to completely clear the cache to remove stale entries. + + +Cache Slams +----------- + +Something to be careful of when utilizing the cache drivers is +cache slams. If you have a heavily trafficked website with some +code that checks for the existence of a cache record and if it does +not exist it generates the information and saves it to the cache. +Now if 100 requests were issued all at the same time and each one +sees the cache does not exist and they all try and insert the same +cache entry it could lock up APC, Xcache, etc. and cause problems. +Ways exist to work around this, like pre-populating your cache and +not letting your users requests populate the cache. + +You can read more about cache slams +`in this blog post `_. + + diff --git a/vendor/doctrine/orm/docs/en/reference/change-tracking-policies.rst b/vendor/doctrine/orm/docs/en/reference/change-tracking-policies.rst new file mode 100644 index 0000000000..d0f099895f --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/change-tracking-policies.rst @@ -0,0 +1,151 @@ +Change Tracking Policies +======================== + +Change tracking is the process of determining what has changed in +managed entities since the last time they were synchronized with +the database. + +Doctrine provides 3 different change tracking policies, each having +its particular advantages and disadvantages. The change tracking +policy can be defined on a per-class basis (or more precisely, +per-hierarchy). + +Deferred Implicit +~~~~~~~~~~~~~~~~~ + +The deferred implicit policy is the default change tracking policy +and the most convenient one. With this policy, Doctrine detects the +changes by a property-by-property comparison at commit time and +also detects changes to entities or new entities that are +referenced by other managed entities ("persistence by +reachability"). Although the most convenient policy, it can have +negative effects on performance if you are dealing with large units +of work (see "Understanding the Unit of Work"). Since Doctrine +can't know what has changed, it needs to check all managed entities +for changes every time you invoke EntityManager#flush(), making +this operation rather costly. + +Deferred Explicit +~~~~~~~~~~~~~~~~~ + +The deferred explicit policy is similar to the deferred implicit +policy in that it detects changes through a property-by-property +comparison at commit time. The difference is that Doctrine 2 only +considers entities that have been explicitly marked for change detection +through a call to EntityManager#persist(entity) or through a save +cascade. All other entities are skipped. This policy therefore +gives improved performance for larger units of work while +sacrificing the behavior of "automatic dirty checking". + +Therefore, flush() operations are potentially cheaper with this +policy. The negative aspect this has is that if you have a rather +large application and you pass your objects through several layers +for processing purposes and business tasks you may need to track +yourself which entities have changed on the way so you can pass +them to EntityManager#persist(). + +This policy can be configured as follows: + +.. code-block:: php + + _listeners[] = $listener; + } + } + +Then, in each property setter of this class or derived classes, you +need to notify all the ``PropertyChangedListener`` instances. As an +example we add a convenience method on ``MyEntity`` that shows this +behaviour: + +.. code-block:: php + + _listeners) { + foreach ($this->_listeners as $listener) { + $listener->propertyChanged($this, $propName, $oldValue, $newValue); + } + } + } + + public function setData($data) + { + if ($data != $this->data) { + $this->_onPropertyChanged('data', $this->data, $data); + $this->data = $data; + } + } + } + +You have to invoke ``_onPropertyChanged`` inside every method that +changes the persistent state of ``MyEntity``. + +The check whether the new value is different from the old one is +not mandatory but recommended. That way you also have full control +over when you consider a property changed. + +The negative point of this policy is obvious: You need implement an +interface and write some plumbing code. But also note that we tried +hard to keep this notification functionality abstract. Strictly +speaking, it has nothing to do with the persistence layer and the +Doctrine ORM or DBAL. You may find that property notification +events come in handy in many other scenarios as well. As mentioned +earlier, the ``Doctrine\Common`` namespace is not that evil and +consists solely of very small classes and interfaces that have +almost no external dependencies (none to the DBAL and none to the +ORM) and that you can easily take with you should you want to swap +out the persistence layer. This change tracking policy does not +introduce a dependency on the Doctrine DBAL/ORM or the persistence +layer. + +The positive point and main advantage of this policy is its +effectiveness. It has the best performance characteristics of the 3 +policies with larger units of work and a flush() operation is very +cheap when nothing has changed. + + diff --git a/vendor/doctrine/orm/docs/en/reference/configuration.rst b/vendor/doctrine/orm/docs/en/reference/configuration.rst new file mode 100644 index 0000000000..d8e718b5ca --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/configuration.rst @@ -0,0 +1,140 @@ +Installation and Configuration +============================== + +Doctrine can be installed with `Composer `_. For +older versions we still have `PEAR packages +`_. + +Define the following requirement in your ``composer.json`` file: + +:: + + { + "require": { + "doctrine/orm": "*" + } + } + +Then call ``composer install`` from your command line. If you don't know +how Composer works, check out their `Getting Started +`_ to set up. + +Class loading +------------- + +Autoloading is taken care of by Composer. You just have to include the composer autoload file in your project: + +.. code-block:: php + + 'pdo_mysql', + 'user' => 'root', + 'password' => '', + 'dbname' => 'foo', + ); + + $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode); + $entityManager = EntityManager::create($dbParams, $config); + +Or if you prefer XML: + +.. code-block:: php + + ` section. + +.. note:: + + You can learn more about the database connection configuration in the + `Doctrine DBAL connection configuration reference `_. + +Setting up the Commandline Tool +------------------------------- + +Doctrine ships with a number of command line tools that are very helpful +during development. You can call this command from the Composer binary +directory: + +.. code-block:: + + $ php vendor/bin/doctrine + +You need to register your applications EntityManager to the console tool +to make use of the tasks by creating a ``cli-config.php`` file with the +following content: + +On Doctrine 2.4 and above: + +.. code-block:: php + + new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), + 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) + )); diff --git a/vendor/doctrine/orm/docs/en/reference/dql-doctrine-query-language.rst b/vendor/doctrine/orm/docs/en/reference/dql-doctrine-query-language.rst new file mode 100644 index 0000000000..856a4b0775 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/dql-doctrine-query-language.rst @@ -0,0 +1,1672 @@ +Doctrine Query Language +=========================== + +DQL stands for Doctrine Query Language and is an Object +Query Language derivate that is very similar to the Hibernate +Query Language (HQL) or the Java Persistence Query Language (JPQL). + +In essence, DQL provides powerful querying capabilities over your +object model. Imagine all your objects lying around in some storage +(like an object database). When writing DQL queries, think about +querying that storage to pick a certain subset of your objects. + +.. note:: + + A common mistake for beginners is to mistake DQL for + being just some form of SQL and therefore trying to use table names + and column names or join arbitrary tables together in a query. You + need to think about DQL as a query language for your object model, + not for your relational schema. + + +DQL is case in-sensitive, except for namespace, class and field +names, which are case sensitive. + +Types of DQL queries +-------------------- + +DQL as a query language has SELECT, UPDATE and DELETE constructs +that map to their corresponding SQL statement types. INSERT +statements are not allowed in DQL, because entities and their +relations have to be introduced into the persistence context +through ``EntityManager#persist()`` to ensure consistency of your +object model. + +DQL SELECT statements are a very powerful way of retrieving parts +of your domain model that are not accessible via associations. +Additionally they allow to retrieve entities and their associations +in one single SQL select statement which can make a huge difference +in performance in contrast to using several queries. + +DQL UPDATE and DELETE statements offer a way to execute bulk +changes on the entities of your domain model. This is often +necessary when you cannot load all the affected entities of a bulk +update into memory. + +SELECT queries +-------------- + +DQL SELECT clause +~~~~~~~~~~~~~~~~~ + +The select clause of a DQL query specifies what appears in the +query result. The composition of all the expressions in the select +clause also influences the nature of the query result. + +Here is an example that selects all users with an age > 20: + +.. code-block:: php + + createQuery('SELECT u FROM MyProject\Model\User u WHERE u.age > 20'); + $users = $query->getResult(); + +Lets examine the query: + + +- ``u`` is a so called identification variable or alias that + refers to the ``MyProject\Model\User`` class. By placing this alias + in the SELECT clause we specify that we want all instances of the + User class that are matched by this query to appear in the query + result. +- The FROM keyword is always followed by a fully-qualified class + name which in turn is followed by an identification variable or + alias for that class name. This class designates a root of our + query from which we can navigate further via joins (explained + later) and path expressions. +- The expression ``u.age`` in the WHERE clause is a path + expression. Path expressions in DQL are easily identified by the + use of the '.' operator that is used for constructing paths. The + path expression ``u.age`` refers to the ``age`` field on the User + class. + +The result of this query would be a list of User objects where all +users are older than 20. + +The SELECT clause allows to specify both class identification +variables that signal the hydration of a complete entity class or +just fields of the entity using the syntax ``u.name``. Combinations +of both are also allowed and it is possible to wrap both fields and +identification values into aggregation and DQL functions. Numerical +fields can be part of computations using mathematical operations. +See the sub-section on `Functions, Operators, Aggregates`_ for +more information. + +Joins +~~~~~ + +A SELECT query can contain joins. There are 2 types of JOINs: +"Regular" Joins and "Fetch" Joins. + +**Regular Joins**: Used to limit the results and/or compute +aggregate values. + +**Fetch Joins**: In addition to the uses of regular joins: Used to +fetch related entities and include them in the hydrated result of a +query. + +There is no special DQL keyword that distinguishes a regular join +from a fetch join. A join (be it an inner or outer join) becomes a +"fetch join" as soon as fields of the joined entity appear in the +SELECT part of the DQL query outside of an aggregate function. +Otherwise its a "regular join". + +Example: + +Regular join of the address: + +.. code-block:: php + + createQuery("SELECT u FROM User u JOIN u.address a WHERE a.city = 'Berlin'"); + $users = $query->getResult(); + +Fetch join of the address: + +.. code-block:: php + + createQuery("SELECT u, a FROM User u JOIN u.address a WHERE a.city = 'Berlin'"); + $users = $query->getResult(); + +When Doctrine hydrates a query with fetch-join it returns the class +in the FROM clause on the root level of the result array. In the +previous example an array of User instances is returned and the +address of each user is fetched and hydrated into the +``User#address`` variable. If you access the address Doctrine does +not need to lazy load the association with another query. + +.. note:: + + Doctrine allows you to walk all the associations between + all the objects in your domain model. Objects that were not already + loaded from the database are replaced with lazy load proxy + instances. Non-loaded Collections are also replaced by lazy-load + instances that fetch all the contained objects upon first access. + However relying on the lazy-load mechanism leads to many small + queries executed against the database, which can significantly + affect the performance of your application. **Fetch Joins** are the + solution to hydrate most or all of the entities that you need in a + single SELECT query. + + +Named and Positional Parameters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +DQL supports both named and positional parameters, however in +contrast to many SQL dialects positional parameters are specified +with numbers, for example "?1", "?2" and so on. Named parameters +are specified with ":name1", ":name2" and so on. + +When referencing the parameters in ``Query#setParameter($param, $value)`` +both named and positional parameters are used **without** their prefixes. + +DQL SELECT Examples +~~~~~~~~~~~~~~~~~~~ + +This section contains a large set of DQL queries and some +explanations of what is happening. The actual result also depends +on the hydration mode. + +Hydrate all User entities: + +.. code-block:: php + + createQuery('SELECT u FROM MyProject\Model\User u'); + $users = $query->getResult(); // array of User objects + +Retrieve the IDs of all CmsUsers: + +.. code-block:: php + + createQuery('SELECT u.id FROM CmsUser u'); + $ids = $query->getResult(); // array of CmsUser ids + +Retrieve the IDs of all users that have written an article: + +.. code-block:: php + + createQuery('SELECT DISTINCT u.id FROM CmsArticle a JOIN a.user u'); + $ids = $query->getResult(); // array of CmsUser ids + +Retrieve all articles and sort them by the name of the articles +users instance: + +.. code-block:: php + + createQuery('SELECT a FROM CmsArticle a JOIN a.user u ORDER BY u.name ASC'); + $articles = $query->getResult(); // array of CmsArticle objects + +Retrieve the Username and Name of a CmsUser: + +.. code-block:: php + + createQuery('SELECT u.username, u.name FROM CmsUser u'); + $users = $query->getResult(); // array of CmsUser username and name values + echo $users[0]['username']; + +Retrieve a ForumUser and his single associated entity: + +.. code-block:: php + + createQuery('SELECT u, a FROM ForumUser u JOIN u.avatar a'); + $users = $query->getResult(); // array of ForumUser objects with the avatar association loaded + echo get_class($users[0]->getAvatar()); + +Retrieve a CmsUser and fetch join all the phonenumbers he has: + +.. code-block:: php + + createQuery('SELECT u, p FROM CmsUser u JOIN u.phonenumbers p'); + $users = $query->getResult(); // array of CmsUser objects with the phonenumbers association loaded + $phonenumbers = $users[0]->getPhonenumbers(); + +Hydrate a result in Ascending: + +.. code-block:: php + + createQuery('SELECT u FROM ForumUser u ORDER BY u.id ASC'); + $users = $query->getResult(); // array of ForumUser objects + +Or in Descending Order: + +.. code-block:: php + + createQuery('SELECT u FROM ForumUser u ORDER BY u.id DESC'); + $users = $query->getResult(); // array of ForumUser objects + +Using Aggregate Functions: + +.. code-block:: php + + createQuery('SELECT COUNT(u.id) FROM Entities\User u'); + $count = $query->getSingleScalarResult(); + + $query = $em->createQuery('SELECT u, count(g.id) FROM Entities\User u JOIN u.groups g GROUP BY u.id'); + $result = $query->getResult(); + +With WHERE Clause and Positional Parameter: + +.. code-block:: php + + createQuery('SELECT u FROM ForumUser u WHERE u.id = ?1'); + $query->setParameter(1, 321); + $users = $query->getResult(); // array of ForumUser objects + +With WHERE Clause and Named Parameter: + +.. code-block:: php + + createQuery('SELECT u FROM ForumUser u WHERE u.username = :name'); + $query->setParameter('name', 'Bob'); + $users = $query->getResult(); // array of ForumUser objects + +With Nested Conditions in WHERE Clause: + +.. code-block:: php + + createQuery('SELECT u from ForumUser u WHERE (u.username = :name OR u.username = :name2) AND u.id = :id'); + $query->setParameters(array( + 'name' => 'Bob', + 'name2' => 'Alice', + 'id' => 321, + )); + $users = $query->getResult(); // array of ForumUser objects + +With COUNT DISTINCT: + +.. code-block:: php + + createQuery('SELECT COUNT(DISTINCT u.name) FROM CmsUser'); + $users = $query->getResult(); // array of ForumUser objects + +With Arithmetic Expression in WHERE clause: + +.. code-block:: php + + createQuery('SELECT u FROM CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000'); + $users = $query->getResult(); // array of ForumUser objects + +Using a LEFT JOIN to hydrate all user-ids and optionally associated +article-ids: + +.. code-block:: php + + createQuery('SELECT u.id, a.id as article_id FROM CmsUser u LEFT JOIN u.articles a'); + $results = $query->getResult(); // array of user ids and every article_id for each user + +Restricting a JOIN clause by additional conditions: + +.. code-block:: php + + createQuery("SELECT u FROM CmsUser u LEFT JOIN u.articles a WITH a.topic LIKE :foo"); + $query->setParameter('foo', '%foo%'); + $users = $query->getResult(); + +Using several Fetch JOINs: + +.. code-block:: php + + createQuery('SELECT u, a, p, c FROM CmsUser u JOIN u.articles a JOIN u.phonenumbers p JOIN a.comments c'); + $users = $query->getResult(); + +BETWEEN in WHERE clause: + +.. code-block:: php + + createQuery('SELECT u.name FROM CmsUser u WHERE u.id BETWEEN ?1 AND ?2'); + $query->setParameter(1, 123); + $query->setParameter(2, 321); + $usernames = $query->getResult(); + +DQL Functions in WHERE clause: + +.. code-block:: php + + createQuery("SELECT u.name FROM CmsUser u WHERE TRIM(u.name) = 'someone'"); + $usernames = $query->getResult(); + +IN() Expression: + +.. code-block:: php + + createQuery('SELECT u.name FROM CmsUser u WHERE u.id IN(46)'); + $usernames = $query->getResult(); + + $query = $em->createQuery('SELECT u FROM CmsUser u WHERE u.id IN (1, 2)'); + $users = $query->getResult(); + + $query = $em->createQuery('SELECT u FROM CmsUser u WHERE u.id NOT IN (1)'); + $users = $query->getResult(); + +CONCAT() DQL Function: + +.. code-block:: php + + createQuery("SELECT u.id FROM CmsUser u WHERE CONCAT(u.name, 's') = ?1"); + $query->setParameter(1, 'Jess'); + $ids = $query->getResult(); + + $query = $em->createQuery('SELECT CONCAT(u.id, u.name) FROM CmsUser u WHERE u.id = ?1'); + $query->setParameter(1, 321); + $idUsernames = $query->getResult(); + +EXISTS in WHERE clause with correlated Subquery + +.. code-block:: php + + createQuery('SELECT u.id FROM CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM CmsPhonenumber p WHERE p.user = u.id)'); + $ids = $query->getResult(); + +Get all users who are members of $group. + +.. code-block:: php + + createQuery('SELECT u.id FROM CmsUser u WHERE :groupId MEMBER OF u.groups'); + $query->setParameter('groupId', $group); + $ids = $query->getResult(); + +Get all users that have more than 1 phonenumber + +.. code-block:: php + + createQuery('SELECT u FROM CmsUser u WHERE SIZE(u.phonenumbers) > 1'); + $users = $query->getResult(); + +Get all users that have no phonenumber + +.. code-block:: php + + createQuery('SELECT u FROM CmsUser u WHERE u.phonenumbers IS EMPTY'); + $users = $query->getResult(); + +Get all instances of a specific type, for use with inheritance +hierarchies: + +.. versionadded:: 2.1 + +.. code-block:: php + + createQuery('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee'); + $query = $em->createQuery('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1'); + $query = $em->createQuery('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u NOT INSTANCE OF ?1'); + +Get all users visible on a given website that have chosen certain gender: + +.. versionadded:: 2.2 + +.. code-block:: php + + createQuery('SELECT u FROM User u WHERE u.gender IN (SELECT IDENTITY(agl.gender) FROM Site s JOIN s.activeGenderList agl WHERE s.id = ?1)'); + +Starting with 2.4, the IDENTITY() DQL function also works for composite primary keys: + +.. code-block:: php + + createQuery('SELECT IDENTITY(c.location, 'latitude') AS latitude, IDENTITY(c.location, 'longitude') AS longitude FROM Checkpoint c WHERE c.user = ?1'); + + +Partial Object Syntax +^^^^^^^^^^^^^^^^^^^^^ + +By default when you run a DQL query in Doctrine and select only a +subset of the fields for a given entity, you do not receive objects +back. Instead, you receive only arrays as a flat rectangular result +set, similar to how you would if you were just using SQL directly +and joining some data. + +If you want to select partial objects you can use the ``partial`` +DQL keyword: + +.. code-block:: php + + createQuery('SELECT partial u.{id, username} FROM CmsUser u'); + $users = $query->getResult(); // array of partially loaded CmsUser objects + +You use the partial syntax when joining as well: + +.. code-block:: php + + createQuery('SELECT partial u.{id, username}, partial a.{id, name} FROM CmsUser u JOIN u.articles a'); + $users = $query->getResult(); // array of partially loaded CmsUser objects + +"NEW" Operator Syntax +^^^^^^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.4 + +Using the ``NEW`` operator you can construct Data Transfer Objects (DTOs) directly from DQL queries. + +- When using ``SELECT NEW`` you don't need to specify a mapped entity. +- You can specify any PHP class, it's only require that the constructor of this class matches the ``NEW`` statement. +- This approach involves determining exactly which columns you really need, + and instantiating data-transfer object that containing a constructor with those arguments. + +If you want to select data-transfer objects you should create a class: + +.. code-block:: php + + createQuery('SELECT NEW CustomerDTO(c.name, e.email, a.city) FROM Customer c JOIN c.email e JOIN c.address a'); + $users = $query->getResult(); // array of CustomerDTO + +.. code-block:: php + + createQuery('SELECT NEW CustomerDTO(c.name, e.email, a.city, SUM(o.value)) FROM Customer c JOIN c.email e JOIN c.address a JOIN c.orders o GROUP BY c'); + $users = $query->getResult(); // array of CustomerDTO + +Using INDEX BY +~~~~~~~~~~~~~~ + +The INDEX BY construct is nothing that directly translates into SQL +but that affects object and array hydration. After each FROM and +JOIN clause you specify by which field this class should be indexed +in the result. By default a result is incremented by numerical keys +starting with 0. However with INDEX BY you can specify any other +column to be the key of your result, it really only makes sense +with primary or unique fields though: + +.. code-block:: sql + + SELECT u.id, u.status, upper(u.name) nameUpper FROM User u INDEX BY u.id + JOIN u.phonenumbers p INDEX BY p.phonenumber + +Returns an array of the following kind, indexed by both user-id +then phonenumber-id: + +.. code-block:: php + + array + 0 => + array + 1 => + object(stdClass)[299] + public '__CLASS__' => string 'Doctrine\Tests\Models\CMS\CmsUser' (length=33) + public 'id' => int 1 + .. + 'nameUpper' => string 'ROMANB' (length=6) + 1 => + array + 2 => + object(stdClass)[298] + public '__CLASS__' => string 'Doctrine\Tests\Models\CMS\CmsUser' (length=33) + public 'id' => int 2 + ... + 'nameUpper' => string 'JWAGE' (length=5) + +UPDATE queries +-------------- + +DQL not only allows to select your Entities using field names, you +can also execute bulk updates on a set of entities using an +DQL-UPDATE query. The Syntax of an UPDATE query works as expected, +as the following example shows: + +.. code-block:: sql + + UPDATE MyProject\Model\User u SET u.password = 'new' WHERE u.id IN (1, 2, 3) + +References to related entities are only possible in the WHERE +clause and using sub-selects. + +.. warning:: + + DQL UPDATE statements are ported directly into a + Database UPDATE statement and therefore bypass any locking scheme, events + and do not increment the version column. Entities that are already + loaded into the persistence context will *NOT* be synced with the + updated database state. It is recommended to call + ``EntityManager#clear()`` and retrieve new instances of any + affected entity. + + +DELETE queries +-------------- + +DELETE queries can also be specified using DQL and their syntax is +as simple as the UPDATE syntax: + +.. code-block:: sql + + DELETE MyProject\Model\User u WHERE u.id = 4 + +The same restrictions apply for the reference of related entities. + +.. warning:: + + DQL DELETE statements are ported directly into a + Database DELETE statement and therefore bypass any events and checks for the + version column if they are not explicitly added to the WHERE clause + of the query. Additionally Deletes of specifies entities are *NOT* + cascaded to related entities even if specified in the metadata. + + +Functions, Operators, Aggregates +-------------------------------- + +DQL Functions +~~~~~~~~~~~~~ + +The following functions are supported in SELECT, WHERE and HAVING +clauses: + + +- IDENTITY(single\_association\_path\_expression [, fieldMapping]) - Retrieve the foreign key column of association of the owning side +- ABS(arithmetic\_expression) +- CONCAT(str1, str2) +- CURRENT\_DATE() - Return the current date +- CURRENT\_TIME() - Returns the current time +- CURRENT\_TIMESTAMP() - Returns a timestamp of the current date + and time. +- LENGTH(str) - Returns the length of the given string +- LOCATE(needle, haystack [, offset]) - Locate the first + occurrence of the substring in the string. +- LOWER(str) - returns the string lowercased. +- MOD(a, b) - Return a MOD b. +- SIZE(collection) - Return the number of elements in the + specified collection +- SQRT(q) - Return the square-root of q. +- SUBSTRING(str, start [, length]) - Return substring of given + string. +- TRIM([LEADING \| TRAILING \| BOTH] ['trchar' FROM] str) - Trim + the string by the given trim char, defaults to whitespaces. +- UPPER(str) - Return the upper-case of the given string. +- DATE_ADD(date, days, unit) - Add the number of days to a given date. (Supported units are DAY, MONTH) +- DATE_SUB(date, days, unit) - Substract the number of days from a given date. (Supported units are DAY, MONTH) +- DATE_DIFF(date1, date2) - Calculate the difference in days between date1-date2. + +Arithmetic operators +~~~~~~~~~~~~~~~~~~~~ + +You can do math in DQL using numeric values, for example: + +.. code-block:: sql + + SELECT person.salary * 1.5 FROM CompanyPerson person WHERE person.salary < 100000 + +Aggregate Functions +~~~~~~~~~~~~~~~~~~~ + +The following aggregate functions are allowed in SELECT and GROUP +BY clauses: AVG, COUNT, MIN, MAX, SUM + +Other Expressions +~~~~~~~~~~~~~~~~~ + +DQL offers a wide-range of additional expressions that are known +from SQL, here is a list of all the supported constructs: + + +- ``ALL/ANY/SOME`` - Used in a WHERE clause followed by a + sub-select this works like the equivalent constructs in SQL. +- ``BETWEEN a AND b`` and ``NOT BETWEEN a AND b`` can be used to + match ranges of arithmetic values. +- ``IN (x1, x2, ...)`` and ``NOT IN (x1, x2, ..)`` can be used to + match a set of given values. +- ``LIKE ..`` and ``NOT LIKE ..`` match parts of a string or text + using % as a wildcard. +- ``IS NULL`` and ``IS NOT NULL`` to check for null values +- ``EXISTS`` and ``NOT EXISTS`` in combination with a sub-select + +Adding your own functions to the DQL language +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +By default DQL comes with functions that are part of a large basis +of underlying databases. However you will most likely choose a +database platform at the beginning of your project and most likely +never change it. For this cases you can easily extend the DQL +parser with own specialized platform functions. + +You can register custom DQL functions in your ORM Configuration: + +.. code-block:: php + + addCustomStringFunction($name, $class); + $config->addCustomNumericFunction($name, $class); + $config->addCustomDatetimeFunction($name, $class); + + $em = EntityManager::create($dbParams, $config); + +The functions have to return either a string, numeric or datetime +value depending on the registered function type. As an example we +will add a MySQL specific FLOOR() functionality. All the given +classes have to implement the base class : + +.. code-block:: php + + walkSimpleArithmeticExpression( + $this->simpleArithmeticExpression + ) . ')'; + } + + public function parse(\Doctrine\ORM\Query\Parser $parser) + { + $lexer = $parser->getLexer(); + + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OPEN_PARENTHESIS); + + $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); + + $parser->match(Lexer::T_CLOSE_PARENTHESIS); + } + } + +We will register the function by calling and can then use it: + +.. code-block:: php + + getConfiguration(); + $config->registerNumericFunction('FLOOR', 'MyProject\Query\MysqlFloor'); + + $dql = "SELECT FLOOR(person.salary * 1.75) FROM CompanyPerson person"; + +Querying Inherited Classes +-------------------------- + +This section demonstrates how you can query inherited classes and +what type of results to expect. + +Single Table +~~~~~~~~~~~~ + +`Single Table Inheritance `_ +is an inheritance mapping strategy where all classes of a hierarchy +are mapped to a single database table. In order to distinguish +which row represents which type in the hierarchy a so-called +discriminator column is used. + +First we need to setup an example set of entities to use. In this +scenario it is a generic Person and Employee example: + +.. code-block:: php + + setName('test'); + $employee->setDepartment('testing'); + $em->persist($employee); + $em->flush(); + +Now lets run a simple query to retrieve the ``Employee`` we just +created: + +.. code-block:: sql + + SELECT e FROM Entities\Employee e WHERE e.name = 'test' + +If we check the generated SQL you will notice it has some special +conditions added to ensure that we will only get back ``Employee`` +entities: + +.. code-block:: sql + + SELECT p0_.id AS id0, p0_.name AS name1, p0_.department AS department2, + p0_.discr AS discr3 FROM Person p0_ + WHERE (p0_.name = ?) AND p0_.discr IN ('employee') + +Class Table Inheritance +~~~~~~~~~~~~~~~~~~~~~~~ + +`Class Table Inheritance `_ +is an inheritance mapping strategy where each class in a hierarchy +is mapped to several tables: its own table and the tables of all +parent classes. The table of a child class is linked to the table +of a parent class through a foreign key constraint. Doctrine 2 +implements this strategy through the use of a discriminator column +in the topmost table of the hierarchy because this is the easiest +way to achieve polymorphic queries with Class Table Inheritance. + +The example for class table inheritance is the same as single +table, you just need to change the inheritance type from +``SINGLE_TABLE`` to ``JOINED``: + +.. code-block:: php + + createQuery('select u from MyProject\Model\User u'); + + // example2: using setDql + $q = $em->createQuery(); + $q->setDql('select u from MyProject\Model\User u'); + +Query Result Formats +~~~~~~~~~~~~~~~~~~~~ + +The format in which the result of a DQL SELECT query is returned +can be influenced by a so-called ``hydration mode``. A hydration +mode specifies a particular way in which a SQL result set is +transformed. Each hydration mode has its own dedicated method on +the Query class. Here they are: + + +- ``Query#getResult()``: Retrieves a collection of objects. The + result is either a plain collection of objects (pure) or an array + where the objects are nested in the result rows (mixed). +- ``Query#getSingleResult()``: Retrieves a single object. If the + result contains more than one or no object, an exception is thrown. The + pure/mixed distinction does not apply. +- ``Query#getOneOrNullResult()``: Retrieve a single object. If no + object is found null will be returned. +- ``Query#getArrayResult()``: Retrieves an array graph (a nested + array) that is largely interchangeable with the object graph + generated by ``Query#getResult()`` for read-only purposes. + + .. note:: + + An array graph can differ from the corresponding object + graph in certain scenarios due to the difference of the identity + semantics between arrays and objects. + + + +- ``Query#getScalarResult()``: Retrieves a flat/rectangular result + set of scalar values that can contain duplicate data. The + pure/mixed distinction does not apply. +- ``Query#getSingleScalarResult()``: Retrieves a single scalar + value from the result returned by the dbms. If the result contains + more than a single scalar value, an exception is thrown. The + pure/mixed distinction does not apply. + +Instead of using these methods, you can alternatively use the +general-purpose method +``Query#execute(array $params = array(), $hydrationMode = Query::HYDRATE_OBJECT)``. +Using this method you can directly supply the hydration mode as the +second parameter via one of the Query constants. In fact, the +methods mentioned earlier are just convenient shortcuts for the +execute method. For example, the method ``Query#getResult()`` +internally invokes execute, passing in ``Query::HYDRATE_OBJECT`` as +the hydration mode. + +The use of the methods mentioned earlier is generally preferred as +it leads to more concise code. + +Pure and Mixed Results +~~~~~~~~~~~~~~~~~~~~~~ + +The nature of a result returned by a DQL SELECT query retrieved +through ``Query#getResult()`` or ``Query#getArrayResult()`` can be +of 2 forms: **pure** and **mixed**. In the previous simple +examples, you already saw a "pure" query result, with only objects. +By default, the result type is **pure** but +**as soon as scalar values, such as aggregate values or other scalar values that do not belong to an entity, appear in the SELECT part of the DQL query, the result becomes mixed**. +A mixed result has a different structure than a pure result in +order to accommodate for the scalar values. + +A pure result usually looks like this: + +.. code-block:: php + + $dql = "SELECT u FROM User u"; + + array + [0] => Object + [1] => Object + [2] => Object + ... + +A mixed result on the other hand has the following general +structure: + +.. code-block:: php + + $dql = "SELECT u, 'some scalar string', count(u.groups) AS num FROM User u JOIN u.groups g GROUP BY u.id"; + + array + [0] + [0] => Object + [1] => "some scalar string" + ['num'] => 42 + // ... more scalar values, either indexed numerically or with a name + [1] + [0] => Object + [1] => "some scalar string" + ['num'] => 42 + // ... more scalar values, either indexed numerically or with a name + +To better understand mixed results, consider the following DQL +query: + +.. code-block:: sql + + SELECT u, UPPER(u.name) nameUpper FROM MyProject\Model\User u + +This query makes use of the ``UPPER`` DQL function that returns a +scalar value and because there is now a scalar value in the SELECT +clause, we get a mixed result. + +Conventions for mixed results are as follows: + + +- The object fetched in the FROM clause is always positioned with the key '0'. +- Every scalar without a name is numbered in the order given in the query, starting with 1. +- Every aliased scalar is given with its alias-name as the key. The case of the name is kept. +- If several objects are fetched from the FROM clause they alternate every row. + + +Here is how the result could look like: + +.. code-block:: php + + array + array + [0] => User (Object) + ['nameUpper'] => "ROMAN" + array + [0] => User (Object) + ['nameUpper'] => "JONATHAN" + ... + +And here is how you would access it in PHP code: + +.. code-block:: php + + getName(); + echo "Name UPPER: " . $row['nameUpper']; + } + +Fetching Multiple FROM Entities +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you fetch multiple entities that are listed in the FROM clause then the hydration +will return the rows iterating the different top-level entities. + +.. code-block:: php + + $dql = "SELECT u, g FROM User u, Group g"; + + array + [0] => Object (User) + [1] => Object (Group) + [2] => Object (User) + [3] => Object (Group) + + +Hydration Modes +~~~~~~~~~~~~~~~ + +Each of the Hydration Modes makes assumptions about how the result +is returned to user land. You should know about all the details to +make best use of the different result formats: + +The constants for the different hydration modes are: + + +- Query::HYDRATE\_OBJECT +- Query::HYDRATE\_ARRAY +- Query::HYDRATE\_SCALAR +- Query::HYDRATE\_SINGLE\_SCALAR + +Object Hydration +^^^^^^^^^^^^^^^^ + +Object hydration hydrates the result set into the object graph: + +.. code-block:: php + + createQuery('SELECT u FROM CmsUser u'); + $users = $query->getResult(Query::HYDRATE_OBJECT); + +Array Hydration +^^^^^^^^^^^^^^^ + +You can run the same query with array hydration and the result set +is hydrated into an array that represents the object graph: + +.. code-block:: php + + createQuery('SELECT u FROM CmsUser u'); + $users = $query->getResult(Query::HYDRATE_ARRAY); + +You can use the ``getArrayResult()`` shortcut as well: + +.. code-block:: php + + getArrayResult(); + +Scalar Hydration +^^^^^^^^^^^^^^^^ + +If you want to return a flat rectangular result set instead of an +object graph you can use scalar hydration: + +.. code-block:: php + + createQuery('SELECT u FROM CmsUser u'); + $users = $query->getResult(Query::HYDRATE_SCALAR); + echo $users[0]['u_id']; + +The following assumptions are made about selected fields using +Scalar Hydration: + + +1. Fields from classes are prefixed by the DQL alias in the result. + A query of the kind 'SELECT u.name ..' returns a key 'u\_name' in + the result rows. + +Single Scalar Hydration +^^^^^^^^^^^^^^^^^^^^^^^ + +If you a query which returns just a single scalar value you can use +single scalar hydration: + +.. code-block:: php + + createQuery('SELECT COUNT(a.id) FROM CmsUser u LEFT JOIN u.articles a WHERE u.username = ?1 GROUP BY u.id'); + $query->setParameter(1, 'jwage'); + $numArticles = $query->getResult(Query::HYDRATE_SINGLE_SCALAR); + +You can use the ``getSingleScalarResult()`` shortcut as well: + +.. code-block:: php + + getSingleScalarResult(); + +Custom Hydration Modes +^^^^^^^^^^^^^^^^^^^^^^ + +You can easily add your own custom hydration modes by first +creating a class which extends ``AbstractHydrator``: + +.. code-block:: php + + _stmt->fetchAll(PDO::FETCH_ASSOC); + } + } + +Next you just need to add the class to the ORM configuration: + +.. code-block:: php + + getConfiguration()->addCustomHydrationMode('CustomHydrator', 'MyProject\Hydrators\CustomHydrator'); + +Now the hydrator is ready to be used in your queries: + +.. code-block:: php + + createQuery('SELECT u FROM CmsUser u'); + $results = $query->getResult('CustomHydrator'); + +Iterating Large Result Sets +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There are situations when a query you want to execute returns a +very large result-set that needs to be processed. All the +previously described hydration modes completely load a result-set +into memory which might not be feasible with large result sets. See +the `Batch Processing `_ section on details how +to iterate large result sets. + +Functions +~~~~~~~~~ + +The following methods exist on the ``AbstractQuery`` which both +``Query`` and ``NativeQuery`` extend from. + +Parameters +^^^^^^^^^^ + +Prepared Statements that use numerical or named wildcards require +additional parameters to be executable against the database. To +pass parameters to the query the following methods can be used: + + +- ``AbstractQuery::setParameter($param, $value)`` - Set the + numerical or named wildcard to the given value. +- ``AbstractQuery::setParameters(array $params)`` - Set an array + of parameter key-value pairs. +- ``AbstractQuery::getParameter($param)`` +- ``AbstractQuery::getParameters()`` + +Both named and positional parameters are passed to these methods without their ? or : prefix. + +Cache related API +^^^^^^^^^^^^^^^^^ + +You can cache query results based either on all variables that +define the result (SQL, Hydration Mode, Parameters and Hints) or on +user-defined cache keys. However by default query results are not +cached at all. You have to enable the result cache on a per query +basis. The following example shows a complete workflow using the +Result Cache API: + +.. code-block:: php + + createQuery('SELECT u FROM MyProject\Model\User u WHERE u.id = ?1'); + $query->setParameter(1, 12); + + $query->setResultCacheDriver(new ApcCache()); + + $query->useResultCache(true) + ->setResultCacheLifeTime($seconds = 3600); + + $result = $query->getResult(); // cache miss + + $query->expireResultCache(true); + $result = $query->getResult(); // forced expire, cache miss + + $query->setResultCacheId('my_query_result'); + $result = $query->getResult(); // saved in given result cache id. + + // or call useResultCache() with all parameters: + $query->useResultCache(true, $seconds = 3600, 'my_query_result'); + $result = $query->getResult(); // cache hit! + + // Introspection + $queryCacheProfile = $query->getQueryCacheProfile(); + $cacheDriver = $query->getResultCacheDriver(); + $lifetime = $query->getLifetime(); + $key = $query->getCacheKey(); + +.. note:: + + You can set the Result Cache Driver globally on the + ``Doctrine\ORM\Configuration`` instance so that it is passed to + every ``Query`` and ``NativeQuery`` instance. + + +Query Hints +^^^^^^^^^^^ + +You can pass hints to the query parser and hydrators by using the +``AbstractQuery::setHint($name, $value)`` method. Currently there +exist mostly internal query hints that are not be consumed in +userland. However the following few hints are to be used in +userland: + + +- Query::HINT\_FORCE\_PARTIAL\_LOAD - Allows to hydrate objects + although not all their columns are fetched. This query hint can be + used to handle memory consumption problems with large result-sets + that contain char or binary data. Doctrine has no way of implicitly + reloading this data. Partially loaded objects have to be passed to + ``EntityManager::refresh()`` if they are to be reloaded fully from + the database. +- Query::HINT\_REFRESH - This query is used internally by + ``EntityManager::refresh()`` and can be used in userland as well. + If you specify this hint and a query returns the data for an entity + that is already managed by the UnitOfWork, the fields of the + existing entity will be refreshed. In normal operation a result-set + that loads data of an already existing entity is discarded in favor + of the already existing entity. +- Query::HINT\_CUSTOM\_TREE\_WALKERS - An array of additional + ``Doctrine\ORM\Query\TreeWalker`` instances that are attached to + the DQL query parsing process. + +Query Cache (DQL Query Only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Parsing a DQL query and converting it into a SQL query against the +underlying database platform obviously has some overhead in +contrast to directly executing Native SQL queries. That is why +there is a dedicated Query Cache for caching the DQL parser +results. In combination with the use of wildcards you can reduce +the number of parsed queries in production to zero. + +The Query Cache Driver is passed from the +``Doctrine\ORM\Configuration`` instance to each +``Doctrine\ORM\Query`` instance by default and is also enabled by +default. This also means you don't regularly need to fiddle with +the parameters of the Query Cache, however if you do there are +several methods to interact with it: + + +- ``Query::setQueryCacheDriver($driver)`` - Allows to set a Cache + instance +- ``Query::setQueryCacheLifeTime($seconds = 3600)`` - Set lifetime + of the query caching. +- ``Query::expireQueryCache($bool)`` - Enforce the expiring of the + query cache if set to true. +- ``Query::getExpireQueryCache()`` +- ``Query::getQueryCacheDriver()`` +- ``Query::getQueryCacheLifeTime()`` + +First and Max Result Items (DQL Query Only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can limit the number of results returned from a DQL query as +well as specify the starting offset, Doctrine then uses a strategy +of manipulating the select query to return only the requested +number of results: + + +- ``Query::setMaxResults($maxResults)`` +- ``Query::setFirstResult($offset)`` + +.. note:: + + If your query contains a fetch-joined collection + specifying the result limit methods are not working as you would + expect. Set Max Results restricts the number of database result + rows, however in the case of fetch-joined collections one root + entity might appear in many rows, effectively hydrating less than + the specified number of results. + +.. _dql-temporarily-change-fetch-mode: + +Temporarily change fetch mode in DQL +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +While normally all your associations are marked as lazy or extra lazy you will have cases where you are using DQL and don't want to +fetch join a second, third or fourth level of entities into your result, because of the increased cost of the SQL JOIN. You +can mark a many-to-one or one-to-one association as fetched temporarily to batch fetch these entities using a WHERE .. IN query. + +.. code-block:: php + + createQuery("SELECT u FROM MyProject\User u"); + $query->setFetchMode("MyProject\User", "address", "EAGER"); + $query->execute(); + +Given that there are 10 users and corresponding addresses in the database the executed queries will look something like: + +.. code-block:: sql + + SELECT * FROM users; + SELECT * FROM address WHERE id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + + +EBNF +---- + +The following context-free grammar, written in an EBNF variant, +describes the Doctrine Query Language. You can consult this grammar +whenever you are unsure about what is possible with DQL or what the +correct syntax for a particular query should be. + +Document syntax: +~~~~~~~~~~~~~~~~ + + +- non-terminals begin with an upper case character +- terminals begin with a lower case character +- parentheses (...) are used for grouping +- square brackets [...] are used for defining an optional part, + e.g. zero or one time +- curly brackets {...} are used for repetition, e.g. zero or more + times +- double quotation marks "..." define a terminal string a vertical + bar \| represents an alternative + +Terminals +~~~~~~~~~ + + +- identifier (name, email, ...) +- string ('foo', 'bar''s house', '%ninja%', ...) +- char ('/', '\\', ' ', ...) +- integer (-1, 0, 1, 34, ...) +- float (-0.23, 0.007, 1.245342E+8, ...) +- boolean (false, true) + +Query Language +~~~~~~~~~~~~~~ + +.. code-block:: php + + QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement + +Statements +~~~~~~~~~~ + +.. code-block:: php + + SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] + UpdateStatement ::= UpdateClause [WhereClause] + DeleteStatement ::= DeleteClause [WhereClause] + +Identifiers +~~~~~~~~~~~ + +.. code-block:: php + + /* Alias Identification usage (the "u" of "u.name") */ + IdentificationVariable ::= identifier + + /* Alias Identification declaration (the "u" of "FROM User u") */ + AliasIdentificationVariable :: = identifier + + /* identifier that must be a class name (the "User" of "FROM User u") */ + AbstractSchemaName ::= identifier + + /* identifier that must be a field (the "name" of "u.name") */ + /* This is responsible to know if the field exists in Object, no matter if it's a relation or a simple field */ + FieldIdentificationVariable ::= identifier + + /* identifier that must be a collection-valued association field (to-many) (the "Phonenumbers" of "u.Phonenumbers") */ + CollectionValuedAssociationField ::= FieldIdentificationVariable + + /* identifier that must be a single-valued association field (to-one) (the "Group" of "u.Group") */ + SingleValuedAssociationField ::= FieldIdentificationVariable + + /* identifier that must be an embedded class state field (for the future) */ + EmbeddedClassStateField ::= FieldIdentificationVariable + + /* identifier that must be a simple state field (name, email, ...) (the "name" of "u.name") */ + /* The difference between this and FieldIdentificationVariable is only semantical, because it points to a single field (not mapping to a relation) */ + SimpleStateField ::= FieldIdentificationVariable + + /* Alias ResultVariable declaration (the "total" of "COUNT(*) AS total") */ + AliasResultVariable = identifier + + /* ResultVariable identifier usage of mapped field aliases (the "total" of "COUNT(*) AS total") */ + ResultVariable = identifier + +Path Expressions +~~~~~~~~~~~~~~~~ + +.. code-block:: php + + /* "u.Group" or "u.Phonenumbers" declarations */ + JoinAssociationPathExpression ::= IdentificationVariable "." (CollectionValuedAssociationField | SingleValuedAssociationField) + + /* "u.Group" or "u.Phonenumbers" usages */ + AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression + + /* "u.name" or "u.Group" */ + SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression + + /* "u.name" or "u.Group.name" */ + StateFieldPathExpression ::= IdentificationVariable "." StateField + + /* "u.Group" */ + SingleValuedAssociationPathExpression ::= IdentificationVariable "." SingleValuedAssociationField + + /* "u.Group.Permissions" */ + CollectionValuedPathExpression ::= IdentificationVariable "." CollectionValuedAssociationField + + /* "name" */ + StateField ::= {EmbeddedClassStateField "."}* SimpleStateField + +Clauses +~~~~~~~ + +.. code-block:: php + + SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}* + SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression + UpdateClause ::= "UPDATE" AbstractSchemaName ["AS"] AliasIdentificationVariable "SET" UpdateItem {"," UpdateItem}* + DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName ["AS"] AliasIdentificationVariable + FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}* + SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}* + WhereClause ::= "WHERE" ConditionalExpression + HavingClause ::= "HAVING" ConditionalExpression + GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}* + OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}* + Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] + +Items +~~~~~ + +.. code-block:: php + + UpdateItem ::= SingleValuedPathExpression "=" NewValue + OrderByItem ::= (SimpleArithmeticExpression | SingleValuedPathExpression | ScalarExpression | ResultVariable) ["ASC" | "DESC"] + GroupByItem ::= IdentificationVariable | ResultVariable | SingleValuedPathExpression + NewValue ::= SimpleArithmeticExpression | "NULL" + +From, Join and Index by +~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}* + SubselectIdentificationVariableDeclaration ::= IdentificationVariableDeclaration | (AssociationPathExpression ["AS"] AliasIdentificationVariable) + JoinVariableDeclaration ::= Join [IndexBy] + RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable + Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression ["AS"] AliasIdentificationVariable ["WITH" ConditionalExpression] + IndexBy ::= "INDEX" "BY" StateFieldPathExpression + +Select Expressions +~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + SelectExpression ::= (IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression) [["AS"] ["HIDDEN"] AliasResultVariable] + SimpleSelectExpression ::= (StateFieldPathExpression | IdentificationVariable | FunctionDeclaration | AggregateExpression | "(" Subselect ")" | ScalarExpression) [["AS"] AliasResultVariable] + PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet + PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}" + +Conditional Expressions +~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}* + ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}* + ConditionalFactor ::= ["NOT"] ConditionalPrimary + ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")" + SimpleConditionalExpression ::= ComparisonExpression | BetweenExpression | LikeExpression | + InExpression | NullComparisonExpression | ExistsExpression | + EmptyCollectionComparisonExpression | CollectionMemberExpression | + InstanceOfExpression + + +Collection Expressions +~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY" + CollectionMemberExpression ::= EntityExpression ["NOT"] "MEMBER" ["OF"] CollectionValuedPathExpression + +Literal Values +~~~~~~~~~~~~~~ + +.. code-block:: php + + Literal ::= string | char | integer | float | boolean + InParameter ::= Literal | InputParameter + +Input Parameter +~~~~~~~~~~~~~~~ + +.. code-block:: php + + InputParameter ::= PositionalParameter | NamedParameter + PositionalParameter ::= "?" integer + NamedParameter ::= ":" string + +Arithmetic Expressions +~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")" + SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}* + ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}* + ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary + ArithmeticPrimary ::= SingleValuedPathExpression | Literal | "(" SimpleArithmeticExpression ")" + | FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings + | FunctionsReturningDatetime | IdentificationVariable | ResultVariable + | InputParameter | CaseExpression + +Scalar and Type Expressions +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + ScalarExpression ::= SimpleArithmeticExpression | StringPrimary | DateTimePrimary | StateFieldPathExpression | BooleanPrimary | CaseExpression | InstanceOfExpression + StringExpression ::= StringPrimary | "(" Subselect ")" + StringPrimary ::= StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression | CaseExpression + BooleanExpression ::= BooleanPrimary | "(" Subselect ")" + BooleanPrimary ::= StateFieldPathExpression | boolean | InputParameter + EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression + SimpleEntityExpression ::= IdentificationVariable | InputParameter + DatetimeExpression ::= DatetimePrimary | "(" Subselect ")" + DatetimePrimary ::= StateFieldPathExpression | InputParameter | FunctionsReturningDatetime | AggregateExpression + +.. note:: + + Parts of CASE expressions are not yet implemented. + +Aggregate Expressions +~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: php + + AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] StateFieldPathExpression ")" | + "COUNT" "(" ["DISTINCT"] (IdentificationVariable | SingleValuedPathExpression) ")" + +Case Expressions +~~~~~~~~~~~~~~~~ + +.. code-block:: php + + CaseExpression ::= GeneralCaseExpression | SimpleCaseExpression | CoalesceExpression | NullifExpression + GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END" + WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression + SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" + CaseOperand ::= StateFieldPathExpression | TypeDiscriminator + SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression + CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")" + NullifExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")" + +Other Expressions +~~~~~~~~~~~~~~~~~ + +QUANTIFIED/BETWEEN/COMPARISON/LIKE/NULL/EXISTS + +.. code-block:: php + + QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")" + BetweenExpression ::= ArithmeticExpression ["NOT"] "BETWEEN" ArithmeticExpression "AND" ArithmeticExpression + ComparisonExpression ::= ArithmeticExpression ComparisonOperator ( QuantifiedExpression | ArithmeticExpression ) + InExpression ::= SingleValuedPathExpression ["NOT"] "IN" "(" (InParameter {"," InParameter}* | Subselect) ")" + InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")") + InstanceOfParameter ::= AbstractSchemaName | InputParameter + LikeExpression ::= StringExpression ["NOT"] "LIKE" StringPrimary ["ESCAPE" char] + NullComparisonExpression ::= (SingleValuedPathExpression | InputParameter) "IS" ["NOT"] "NULL" + ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")" + ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!=" + +Functions +~~~~~~~~~ + +.. code-block:: php + + FunctionDeclaration ::= FunctionsReturningStrings | FunctionsReturningNumerics | FunctionsReturningDateTime + + FunctionsReturningNumerics ::= + "LENGTH" "(" StringPrimary ")" | + "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")" | + "ABS" "(" SimpleArithmeticExpression ")" | + "SQRT" "(" SimpleArithmeticExpression ")" | + "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | + "SIZE" "(" CollectionValuedPathExpression ")" | + "DATE_DIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | + "BIT_AND" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | + "BIT_OR" "(" ArithmeticPrimary "," ArithmeticPrimary ")" + + FunctionsReturningDateTime ::= + "CURRENT_DATE" | + "CURRENT_TIME" | + "CURRENT_TIMESTAMP" | + "DATE_ADD" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")" | + "DATE_SUB" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")" + + FunctionsReturningStrings ::= + "CONCAT" "(" StringPrimary "," StringPrimary ")" | + "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | + "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" | + "LOWER" "(" StringPrimary ")" | + "UPPER" "(" StringPrimary ")" | + "IDENTITY" "(" SingleValuedAssociationPathExpression ")" + + diff --git a/vendor/doctrine/orm/docs/en/reference/events.rst b/vendor/doctrine/orm/docs/en/reference/events.rst new file mode 100644 index 0000000000..517f2ec5b3 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/events.rst @@ -0,0 +1,955 @@ +Events +====== + +Doctrine 2 features a lightweight event system that is part of the +Common package. Doctrine uses it to dispatch system events, mainly +:ref:`lifecycle events `. +You can also use it for your own custom events. + +The Event System +---------------- + +The event system is controlled by the ``EventManager``. It is the +central point of Doctrine's event listener system. Listeners are +registered on the manager and events are dispatched through the +manager. + +.. code-block:: php + + addEventListener(array(self::preFoo, self::postFoo), $this); + } + + public function preFoo(EventArgs $e) + { + $this->preFooInvoked = true; + } + + public function postFoo(EventArgs $e) + { + $this->postFooInvoked = true; + } + } + + // Create a new instance + $test = new EventTest($evm); + +Events can be dispatched by using the ``dispatchEvent()`` method. + +.. code-block:: php + + dispatchEvent(EventTest::preFoo); + $evm->dispatchEvent(EventTest::postFoo); + +You can easily remove a listener with the ``removeEventListener()`` +method. + +.. code-block:: php + + removeEventListener(array(self::preFoo, self::postFoo), $this); + +The Doctrine 2 event system also has a simple concept of event +subscribers. We can define a simple ``TestEventSubscriber`` class +which implements the ``\Doctrine\Common\EventSubscriber`` interface +and implements a ``getSubscribedEvents()`` method which returns an +array of events it should be subscribed to. + +.. code-block:: php + + preFooInvoked = true; + } + + public function getSubscribedEvents() + { + return array(TestEvent::preFoo); + } + } + + $eventSubscriber = new TestEventSubscriber(); + $evm->addEventSubscriber($eventSubscriber); + +.. note:: + + The array to return in the ``getSubscribedEvents`` method is a simple array + with the values being the event names. The subscriber must have a method + that is named exactly like the event. + +Now when you dispatch an event, any event subscribers will be +notified for that event. + +.. code-block:: php + + dispatchEvent(TestEvent::preFoo); + +Now you can test the ``$eventSubscriber`` instance to see if the +``preFoo()`` method was invoked. + +.. code-block:: php + + preFooInvoked) { + echo 'pre foo invoked!'; + } + +Naming convention +~~~~~~~~~~~~~~~~~ + +Events being used with the Doctrine 2 EventManager are best named +with camelcase and the value of the corresponding constant should +be the name of the constant itself, even with spelling. This has +several reasons: + + +- It is easy to read. +- Simplicity. +- Each method within an EventSubscriber is named after the + corresponding constant. If constant name and constant value differ, + you MUST use the new value and thus, your code might be subject to + codechanges when the value changes. This contradicts the intention + of a constant. + +An example for a correct notation can be found in the example +``EventTest`` above. + +.. _reference-events-lifecycle-events: + +Lifecycle Events +---------------- + +The EntityManager and UnitOfWork trigger a bunch of events during +the life-time of their registered entities. + + +- preRemove - The preRemove event occurs for a given entity before + the respective EntityManager remove operation for that entity is + executed. It is not called for a DQL DELETE statement. +- postRemove - The postRemove event occurs for an entity after the + entity has been deleted. It will be invoked after the database + delete operations. It is not called for a DQL DELETE statement. +- prePersist - The prePersist event occurs for a given entity + before the respective EntityManager persist operation for that + entity is executed. It should be noted that this event is only triggered on + *initial* persist of an entity +- postPersist - The postPersist event occurs for an entity after + the entity has been made persistent. It will be invoked after the + database insert operations. Generated primary key values are + available in the postPersist event. +- preUpdate - The preUpdate event occurs before the database + update operations to entity data. It is not called for a DQL UPDATE statement. +- postUpdate - The postUpdate event occurs after the database + update operations to entity data. It is not called for a DQL UPDATE statement. +- postLoad - The postLoad event occurs for an entity after the + entity has been loaded into the current EntityManager from the + database or after the refresh operation has been applied to it. +- loadClassMetadata - The loadClassMetadata event occurs after the + mapping metadata for a class has been loaded from a mapping source + (annotations/xml/yaml). +- preFlush - The preFlush event occurs at the very beginning of a flush + operation. This event is not a lifecycle callback. +- onFlush - The onFlush event occurs after the change-sets of all + managed entities are computed. This event is not a lifecycle + callback. +- postFlush - The postFlush event occurs at the end of a flush operation. This + event is not a lifecycle callback. +- onClear - The onClear event occurs when the EntityManager#clear() operation is + invoked, after all references to entities have been removed from the unit of + work. + +.. warning:: + + Note that the postLoad event occurs for an entity + before any associations have been initialized. Therefore it is not + safe to access associations in a postLoad callback or event + handler. + + +You can access the Event constants from the ``Events`` class in the +ORM package. + +.. code-block:: php + + createdAt = date('Y-m-d H:i:s'); + } + + /** @PrePersist */ + public function doOtherStuffOnPrePersist() + { + $this->value = 'changed from prePersist callback!'; + } + + /** @PostPersist */ + public function doStuffOnPostPersist() + { + $this->value = 'changed from postPersist callback!'; + } + + /** @PostLoad */ + public function doStuffOnPostLoad() + { + $this->value = 'changed from postLoad callback!'; + } + + /** @PreUpdate */ + public function doStuffOnPreUpdate() + { + $this->value = 'changed from preUpdate callback!'; + } + } + +Note that when using annotations you have to apply the +@HasLifecycleCallbacks marker annotation on the entity class. + +If you want to register lifecycle callbacks from YAML or XML you +can do it with the following. + +.. code-block:: yaml + + User: + type: entity + fields: + # ... + name: + type: string(50) + lifecycleCallbacks: + prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] + postPersist: [ doStuffOnPostPersist ] + +XML would look something like this: + +.. code-block:: xml + + + + + + + + + + + + + + + + +You just need to make sure a public ``doStuffOnPrePersist()`` and +``doStuffOnPostPersist()`` method is defined on your ``User`` +model. + +.. code-block:: php + + hasChangedField('username')) { + // Do something when the username is changed. + } + } + } + +Listening and subscribing to Lifecycle Events +--------------------------------------------- + +Lifecycle event listeners are much more powerful than the simple +lifecycle callbacks that are defined on the entity classes. They +allow to implement re-usable behaviors between different entity +classes, yet require much more detailed knowledge about the inner +workings of the EntityManager and UnitOfWork. Please read the +*Implementing Event Listeners* section carefully if you are trying +to write your own listener. + +For event subscribers, there are no surprises. They declare the +lifecycle events in their ``getSubscribedEvents`` method and provide +public methods that expect the relevant arguments. + +A lifecycle event listener looks like the following: + +.. code-block:: php + + getObject(); + $entityManager = $args->getObjectManager(); + + // perhaps you only want to act on some "Product" entity + if ($entity instanceof Product) { + // do something with the Product + } + } + } + +A lifecycle event subscriber may looks like this: + +.. code-block:: php + + getObject(); + $entityManager = $args->getObjectManager(); + + // perhaps you only want to act on some "Product" entity + if ($entity instanceof Product) { + // do something with the Product + } + } + +.. note:: + + Lifecycle events are triggered for all entities. It is the responsibility + of the listeners and subscribers to check if the entity is of a type + it wants to handle. + +To register an event listener or subscriber, you have to hook it into the +EventManager that is passed to the EntityManager factory: + +.. code-block:: php + + addEventListener(array(Events::preUpdate), new MyEventListener()); + $eventManager->addEventSubscriber(new MyEventSubscriber()); + + $entityManager = EntityManager::create($dbOpts, $config, $eventManager); + +You can also retrieve the event manager instance after the +EntityManager was created: + +.. code-block:: php + + getEventManager()->addEventListener(array(Events::preUpdate), new MyEventListener()); + $entityManager->getEventManager()->addEventSubscriber(new MyEventSubscriber()); + +.. _reference-events-implementing-listeners: + +Implementing Event Listeners +---------------------------- + +This section explains what is and what is not allowed during +specific lifecycle events of the UnitOfWork. Although you get +passed the EntityManager in all of these events, you have to follow +these restrictions very carefully since operations in the wrong +event may produce lots of different errors, such as inconsistent +data and lost updates/persists/removes. + +For the described events that are also lifecycle callback events +the restrictions apply as well, with the additional restriction +that you do not have access to the EntityManager or UnitOfWork APIs +inside these events. + +prePersist +~~~~~~~~~~ + +There are two ways for the ``prePersist`` event to be triggered. +One is obviously when you call ``EntityManager#persist()``. The +event is also called for all cascaded associations. + +There is another way for ``prePersist`` to be called, inside the +``flush()`` method when changes to associations are computed and +this association is marked as cascade persist. Any new entity found +during this operation is also persisted and ``prePersist`` called +on it. This is called "persistence by reachability". + +In both cases you get passed a ``LifecycleEventArgs`` instance +which has access to the entity and the entity manager. + +The following restrictions apply to ``prePersist``: + + +- If you are using a PrePersist Identity Generator such as + sequences the ID value will *NOT* be available within any + PrePersist events. +- Doctrine will not recognize changes made to relations in a pre + persist event called by "reachability" through a cascade persist + unless you use the internal ``UnitOfWork`` API. We do not recommend + such operations in the persistence by reachability context, so do + this at your own risk and possibly supported by unit-tests. + +preRemove +~~~~~~~~~ + +The ``preRemove`` event is called on every entity when its passed +to the ``EntityManager#remove()`` method. It is cascaded for all +associations that are marked as cascade delete. + +There are no restrictions to what methods can be called inside the +``preRemove`` event, except when the remove method itself was +called during a flush operation. + +preFlush +~~~~~~~~ + +``preFlush`` is called at ``EntityManager#flush()`` before +anything else. ``EntityManager#flush()`` can be called safely +inside its listeners. + +.. code-block:: php + + getEntityManager(); + $uow = $em->getUnitOfWork(); + + foreach ($uow->getScheduledEntityInsertions() AS $entity) { + + } + + foreach ($uow->getScheduledEntityUpdates() AS $entity) { + + } + + foreach ($uow->getScheduledEntityDeletions() AS $entity) { + + } + + foreach ($uow->getScheduledCollectionDeletions() AS $col) { + + } + + foreach ($uow->getScheduledCollectionUpdates() AS $col) { + + } + } + } + +The following restrictions apply to the onFlush event: + + +- If you create and persist a new entity in "onFlush", then + calling ``EntityManager#persist()`` is not enough. + You have to execute an additional call to + ``$unitOfWork->computeChangeSet($classMetadata, $entity)``. +- Changing primitive fields or associations requires you to + explicitly trigger a re-computation of the changeset of the + affected entity. This can be done by either calling + ``$unitOfWork->recomputeSingleEntityChangeSet($classMetadata, $entity)``. + +postFlush +~~~~~~~~~ + +``postFlush`` is called at the end of ``EntityManager#flush()``. +``EntityManager#flush()`` can **NOT** be called safely inside its listeners. + +.. code-block:: php + + getEntity() instanceof User) { + if ($eventArgs->hasChangedField('name') && $eventArgs->getNewValue('name') == 'Alice') { + $eventArgs->setNewValue('name', 'Bob'); + } + } + } + } + +You could also use this listener to implement validation of all the +fields that have changed. This is more efficient than using a +lifecycle callback when there are expensive validations to call: + +.. code-block:: php + + getEntity() instanceof Account) { + if ($eventArgs->hasChangedField('creditCard')) { + $this->validateCreditCard($eventArgs->getNewValue('creditCard')); + } + } + } + + private function validateCreditCard($no) + { + // throw an exception to interrupt flush event. Transaction will be rolled back. + } + } + +Restrictions for this event: + + +- Changes to associations of the passed entities are not + recognized by the flush operation anymore. +- Changes to fields of the passed entities are not recognized by + the flush operation anymore, use the computed change-set passed to + the event to modify primitive field values. +- Any calls to ``EntityManager#persist()`` or + ``EntityManager#remove()``, even in combination with the UnitOfWork + API are strongly discouraged and don't work as expected outside the + flush operation. + +postUpdate, postRemove, postPersist +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The three post events are called inside ``EntityManager#flush()``. +Changes in here are not relevant to the persistence in the +database, but you can use these events to alter non-persistable items, +like non-mapped fields, logging or even associated classes that are +directly mapped by Doctrine. + +postLoad +~~~~~~~~ + +This event is called after an entity is constructed by the +EntityManager. + +Entity listeners +---------------- + +.. versionadded:: 2.4 + +An entity listeners is a lifecycle listener classes used for an entity. + +- The entity listeners mapping may be applied to an entity class or mapped superclass. +- An entity listener is defined by mapping the entity class with the corresponding mapping. + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + .. code-block:: yaml + + MyProject\Entity\User: + type: entity + entityListeners: + UserListener: + # .... + +.. _reference-entity-listeners: + +Entity listeners class +~~~~~~~~~~~~~~~~~~~~~~ + +An ``Entity Listener`` could be any class, by default it should be a class with a no-arg constructor. + +- Different from :ref:`reference-events-implementing-listeners` an ``Entity Listener`` is invoked just to the specified entity +- An entity listener method receives two arguments, the entity instance and the lifecycle event. +- A callback method could be defined by naming convention or specifying a method mapping. +- When the listener mapping is not given the parser will lookup for methods that match with the naming convention. +- When the listener mapping is given the parser won't lookup for any naming convention. + +.. code-block:: php + + + + + + + + + + + + + + + + + + + + + + .. code-block:: yaml + + MyProject\Entity\User: + type: entity + entityListeners: + UserListener: + preFlush: [preFlushHandler] + postLoad: [postLoadHandler] + + postPersist: [postPersistHandler] + prePersist: [prePersistHandler] + + postUpdate: [postUpdateHandler] + preUpdate: [preUpdateHandler] + + postRemove: [postRemoveHandler] + preRemove: [preRemoveHandler] + # .... + + + +Entity listeners resolver +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Doctrine invoke the listener resolver to get the listener instance. + +- An resolver allows you register a specific ``Entity Listener`` instance. +- You can also implement your own resolver by extending ``Doctrine\ORM\Mapping\DefaultEntityListenerResolver`` or implementing ``Doctrine\ORM\Mapping\EntityListenerResolver`` + +Specifying an entity listener instance : + +.. code-block:: php + + service = $service; + } + + public function preUpdate(User $user, PreUpdateEventArgs $event) + { + $this->service->doSomething($user); + } + } + + // register a entity listener. + $listener = $container->get('user_listener'); + $em->getConfiguration()->getEntityListenerResolver()->register($listener); + +Implementing your own resolver : + +.. code-block:: php + + container = $container; + } + + public function resolve($className) + { + // resolve the service id by the given class name; + $id = 'user_listener'; + + return $this->container->get($id); + } + } + + // configure the listener resolver. + $em->getConfiguration()->setEntityListenerResolver($container->get('my_resolver')); + +Load ClassMetadata Event +------------------------ + +When the mapping information for an entity is read, it is populated +in to a ``ClassMetadataInfo`` instance. You can hook in to this +process and manipulate the instance. + +.. code-block:: php + + getMetadataFactory(); + $evm = $em->getEventManager(); + $evm->addEventListener(Events::loadClassMetadata, $test); + + class EventTest + { + public function loadClassMetadata(\Doctrine\ORM\Event\LoadClassMetadataEventArgs $eventArgs) + { + $classMetadata = $eventArgs->getClassMetadata(); + $fieldMapping = array( + 'fieldName' => 'about', + 'type' => 'string', + 'length' => 255 + ); + $classMetadata->mapField($fieldMapping); + } + } + + diff --git a/vendor/doctrine/orm/docs/en/reference/faq.rst b/vendor/doctrine/orm/docs/en/reference/faq.rst new file mode 100644 index 0000000000..28e3a42c49 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/faq.rst @@ -0,0 +1,224 @@ +Frequently Asked Questions +========================== + +.. note:: + + This FAQ is a work in progress. We will add lots of questions and not answer them right away just to remember + what is often asked. If you stumble across an unanswered question please write a mail to the mailing-list or + join the #doctrine channel on Freenode IRC. + +Database Schema +--------------- + +How do I set the charset and collation for MySQL tables? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can't set these values inside the annotations, yml or xml mapping files. To make a database +work with the default charset and collation you should configure MySQL to use it as default charset, +or create the database with charset and collation details. This way they get inherited to all newly +created database tables and columns. + +Entity Classes +-------------- + +I access a variable and its null, what is wrong? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If this variable is a public variable then you are violating one of the criteria for entities. +All properties have to be protected or private for the proxy object pattern to work. + +How can I add default values to a column? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Doctrine does not support to set the default values in columns through the "DEFAULT" keyword in SQL. +This is not necessary however, you can just use your class properties as default values. These are then used +upon insert: + +.. code-block:: php + + class User + { + const STATUS_DISABLED = 0; + const STATUS_ENABLED = 1; + + private $algorithm = "sha1"; + private $status = self:STATUS_DISABLED; + } + +. + +Mapping +------- + +Why do I get exceptions about unique constraint failures during ``$em->flush()``? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Doctrine does not check if you are re-adding entities with a primary key that already exists +or adding entities to a collection twice. You have to check for both conditions yourself +in the code before calling ``$em->flush()`` if you know that unique constraint failures +can occur. + +In `Symfony2 `_ for example there is a Unique Entity Validator +to achieve this task. + +For collections you can check with ``$collection->contains($entity)`` if an entity is already +part of this collection. For a FETCH=LAZY collection this will initialize the collection, +however for FETCH=EXTRA_LAZY this method will use SQL to determine if this entity is already +part of the collection. + +Associations +------------ + +What is wrong when I get an InvalidArgumentException "A new entity was found through the relationship.."? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This exception is thrown during ``EntityManager#flush()`` when there exists an object in the identity map +that contains a reference to an object that Doctrine does not know about. Say for example you grab +a "User"-entity from the database with a specific id and set a completely new object into one of the associations +of the User object. If you then call ``EntityManager#flush()`` without letting Doctrine know about +this new object using ``EntityManager#persist($newObject)`` you will see this exception. + +You can solve this exception by: + +* Calling ``EntityManager#persist($newObject)`` on the new object +* Using cascade=persist on the association that contains the new object + +How can I filter an association? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Natively you can't filter associations in 2.0 and 2.1. You should use DQL queries to query for the filtered set of entities. + +I call clear() on a One-To-Many collection but the entities are not deleted +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This is an expected behavior that has to do with the inverse/owning side handling of Doctrine. +By definition a One-To-Many association is on the inverse side, that means changes to it +will not be recognized by Doctrine. + +If you want to perform the equivalent of the clear operation you have to iterate the +collection and set the owning side many-to-one reference to NULL as well to detach all entities +from the collection. This will trigger the appropriate UPDATE statements on the database. + +How can I add columns to a many-to-many table? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The many-to-many association is only supporting foreign keys in the table definition +To work with many-to-many tables containing extra columns you have to use the +foreign keys as primary keys feature of Doctrine introduced in version 2.1. + +See :doc:`the tutorial on composite primary keys for more information<../tutorials/composite-primary-keys>`. + + +How can i paginate fetch-joined collections? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you are issuing a DQL statement that fetches a collection as well you cannot easily iterate +over this collection using a LIMIT statement (or vendor equivalent). + +Doctrine does not offer a solution for this out of the box but there are several extensions +that do: + +* `DoctrineExtensions `_ +* `Pagerfanta `_ + +Why does pagination not work correctly with fetch joins? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Pagination in Doctrine uses a LIMIT clause (or vendor equivalent) to restrict the results. +However when fetch-joining this is not returning the correct number of results since joining +with a one-to-many or many-to-many association multiplies the number of rows by the number +of associated entities. + +See the previous question for a solution to this task. + +Inheritance +----------- + +Can I use Inheritance with Doctrine 2? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Yes, you can use Single- or Joined-Table Inheritance in Doctrine 2. + +See the documentation chapter on :doc:`inheritance mapping ` for +the details. + +Why does Doctrine not create proxy objects for my inheritance hierarchy? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you set a many-to-one or one-to-one association target-entity to any parent class of +an inheritance hierarchy Doctrine does not know what PHP class the foreign is actually of. +To find this out it has to execute a SQL query to look this information up in the database. + +EntityGenerator +--------------- + +Why does the EntityGenerator not do X? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The EntityGenerator is not a full fledged code-generator that solves all tasks. Code-Generation +is not a first-class priority in Doctrine 2 anymore (compared to Doctrine 1). The EntityGenerator +is supposed to kick-start you, but not towards 100%. + +Why does the EntityGenerator not generate inheritance correctly? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Just from the details of the discriminator map the EntityGenerator cannot guess the inheritance hierarchy. +This is why the generation of inherited entities does not fully work. You have to adjust some additional +code to get this one working correctly. + +Performance +----------- + +Why is an extra SQL query executed every time I fetch an entity with a one-to-one relation? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If Doctrine detects that you are fetching an inverse side one-to-one association +it has to execute an additional query to load this object, because it cannot know +if there is no such object (setting null) or if it should set a proxy and which id this proxy has. + +To solve this problem currently a query has to be executed to find out this information. + +Doctrine Query Language +----------------------- + +What is DQL? +~~~~~~~~~~~~ + +DQL stands for Doctrine Query Language, a query language that very much looks like SQL +but has some important benefits when using Doctrine: + +- It uses class names and fields instead of tables and columns, separating concerns between backend and your object model. +- It utilizes the metadata defined to offer a range of shortcuts when writing. For example you do not have to specify the ON clause of joins, since Doctrine already knows about them. +- It adds some functionality that is related to object management and transforms them into SQL. + +It also has some drawbacks of course: + +- The syntax is slightly different to SQL so you have to learn and remember the differences. +- To be vendor independent it can only implement a subset of all the existing SQL dialects. Vendor specific functionality and optimizations cannot be used through DQL unless implemented by you explicitly. +- For some DQL constructs subselects are used which are known to be slow in MySQL. + +Can I sort by a function (for example ORDER BY RAND()) in DQL? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +No, it is not supported to sort by function in DQL. If you need this functionality you should either +use a native-query or come up with another solution. As a side note: Sorting with ORDER BY RAND() is painfully slow +starting with 1000 rows. + +A Query fails, how can I debug it? +---------------------------------- + +First, if you are using the QueryBuilder you can use +``$queryBuilder->getDQL()`` to get the DQL string of this query. The +corresponding SQL you can get from the Query instance by calling +``$query->getSQL()``. + +.. code-block:: php + + createQuery($dql); + var_dump($query->getSQL()); + + $qb = $entityManager->createQueryBuilder(); + $qb->select('u')->from('User', 'u'); + var_dump($qb->getDQL()); diff --git a/vendor/doctrine/orm/docs/en/reference/filters.rst b/vendor/doctrine/orm/docs/en/reference/filters.rst new file mode 100644 index 0000000000..a5c0ee4cf1 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/filters.rst @@ -0,0 +1,93 @@ +Filters +======= + +.. versionadded:: 2.2 + +Doctrine 2.2 features a filter system that allows the developer to add SQL to +the conditional clauses of queries, regardless the place where the SQL is +generated (e.g. from a DQL query, or by loading associated entities). + +The filter functionality works on SQL level. Whether a SQL query is generated +in a Persister, during lazy loading, in extra lazy collections or from DQL. +Each time the system iterates over all the enabled filters, adding a new SQL +part as a filter returns. + +By adding SQL to the conditional clauses of queries, the filter system filters +out rows belonging to the entities at the level of the SQL result set. This +means that the filtered entities are never hydrated (which can be expensive). + + +Example filter class +-------------------- +Throughout this document the example ``MyLocaleFilter`` class will be used to +illustrate how the filter feature works. A filter class must extend the base +``Doctrine\ORM\Query\Filter\SQLFilter`` class and implement the ``addFilterConstraint`` +method. The method receives the ``ClassMetadata`` of the filtered entity and the +table alias of the SQL table of the entity. + +.. note:: + + In the case of joined or single table inheritance, you always get passed the ClassMetadata of the + inheritance root. This is necessary to avoid edge cases that would break the SQL when applying the filters. + +Parameters for the query should be set on the filter object by +``SQLFilter#setParameter()``. Only parameters set via this function can be used +in filters. The ``SQLFilter#getParameter()`` function takes care of the +proper quoting of parameters. + +.. code-block:: php + + reflClass->implementsInterface('LocaleAware')) { + return ""; + } + + return $targetTableAlias.'.locale = ' . $this->getParameter('locale'); // getParameter applies quoting automatically + } + } + + +Configuration +------------- +Filter classes are added to the configuration as following: + +.. code-block:: php + + addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter"); + + +The ``Configuration#addFilter()`` method takes a name for the filter and the name of the +class responsible for the actual filtering. + + +Disabling/Enabling Filters and Setting Parameters +--------------------------------------------------- +Filters can be disabled and enabled via the ``FilterCollection`` which is +stored in the ``EntityManager``. The ``FilterCollection#enable($name)`` method +will retrieve the filter object. You can set the filter parameters on that +object. + +.. code-block:: php + + getFilters()->enable("locale"); + $filter->setParameter('locale', 'en'); + + // Disable it + $filter = $em->getFilters()->disable("locale"); + +.. warning:: + Disabling and enabling filters has no effect on managed entities. If you + want to refresh or reload an object after having modified a filter or the + FilterCollection, then you should clear the EntityManager and re-fetch your + entities, having the new rules for filtering applied. diff --git a/vendor/doctrine/orm/docs/en/reference/improving-performance.rst b/vendor/doctrine/orm/docs/en/reference/improving-performance.rst new file mode 100644 index 0000000000..9bc4c8632e --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/improving-performance.rst @@ -0,0 +1,64 @@ +Improving Performance +===================== + +Bytecode Cache +-------------- + +It is highly recommended to make use of a bytecode cache like APC. +A bytecode cache removes the need for parsing PHP code on every +request and can greatly improve performance. + + "If you care about performance and don't use a bytecode + cache then you don't really care about performance. Please get one + and start using it." + + *Stas Malyshev, Core Contributor to PHP and Zend Employee* + + +Metadata and Query caches +------------------------- + +As already mentioned earlier in the chapter about configuring +Doctrine, it is strongly discouraged to use Doctrine without a +Metadata and Query cache (preferably with APC or Memcache as the +cache driver). Operating Doctrine without these caches means +Doctrine will need to load your mapping information on every single +request and has to parse each DQL query on every single request. +This is a waste of resources. + +Alternative Query Result Formats +-------------------------------- + +Make effective use of the available alternative query result +formats like nested array graphs or pure scalar results, especially +in scenarios where data is loaded for read-only purposes. + +Read-Only Entities +------------------ + +Starting with Doctrine 2.1 you can mark entities as read only (See metadata mapping +references for details). This means that the entity marked as read only is never considered +for updates, which means when you call flush on the EntityManager these entities are skipped +even if properties changed. Read-Only allows to persist new entities of a kind and remove existing +ones, they are just not considered for updates. + +Extra-Lazy Collections +---------------------- + +If entities hold references to large collections you will get performance and memory problems initializing them. +To solve this issue you can use the EXTRA_LAZY fetch-mode feature for collections. See the :doc:`tutorial <../tutorials/extra-lazy-associations>` +for more information on how this fetch mode works. + +Temporarily change fetch mode in DQL +------------------------------------ + +See :ref:`Doctrine Query Language chapter ` + + +Apply Best Practices +-------------------- + +A lot of the points mentioned in the Best Practices chapter will +also positively affect the performance of Doctrine. + + diff --git a/vendor/doctrine/orm/docs/en/reference/inheritance-mapping.rst b/vendor/doctrine/orm/docs/en/reference/inheritance-mapping.rst new file mode 100644 index 0000000000..1bc92f3f38 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/inheritance-mapping.rst @@ -0,0 +1,559 @@ +Inheritance Mapping +=================== + +Mapped Superclasses +------------------- + +A mapped superclass is an abstract or concrete class that provides +persistent entity state and mapping information for its subclasses, +but which is not itself an entity. Typically, the purpose of such a +mapped superclass is to define state and mapping information that +is common to multiple entity classes. + +Mapped superclasses, just as regular, non-mapped classes, can +appear in the middle of an otherwise mapped inheritance hierarchy +(through Single Table Inheritance or Class Table Inheritance). + +.. note:: + + A mapped superclass cannot be an entity, it is not query-able and + persistent relationships defined by a mapped superclass must be + unidirectional (with an owning side only). This means that One-To-Many + associations are not possible on a mapped superclass at all. + Furthermore Many-To-Many associations are only possible if the + mapped superclass is only used in exactly one entity at the moment. + For further support of inheritance, the single or + joined table inheritance features have to be used. + + +Example: + +.. code-block:: php + + `_ +is an inheritance mapping strategy where all classes of a hierarchy +are mapped to a single database table. In order to distinguish +which row represents which type in the hierarchy a so-called +discriminator column is used. + +Example: + +.. code-block:: php + + `_ +is an inheritance mapping strategy where each class in a hierarchy +is mapped to several tables: its own table and the tables of all +parent classes. The table of a child class is linked to the table +of a parent class through a foreign key constraint. Doctrine 2 +implements this strategy through the use of a discriminator column +in the topmost table of the hierarchy because this is the easiest +way to achieve polymorphic queries with Class Table Inheritance. + +Example: + +.. code-block:: php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .. code-block:: yaml + + # user mapping + MyProject\Model\User: + type: mappedSuperclass + # other fields mapping + manyToOne: + address: + targetEntity: Address + joinColumn: + name: address_id + referencedColumnName: id + cascade: [ persist, merge ] + manyToMany: + groups: + targetEntity: Group + joinTable: + name: users_groups + joinColumns: + user_id: + referencedColumnName: id + inverseJoinColumns: + group_id: + referencedColumnName: id + cascade: [ persist, merge, detach ] + + # admin mapping + MyProject\Model\Admin: + type: entity + associationOverride: + address: + joinColumn: + adminaddress_id: + name: adminaddress_id + referencedColumnName: id + groups: + joinTable: + name: users_admingroups + joinColumns: + adminuser_id: + referencedColumnName: id + inverseJoinColumns: + admingroup_id: + referencedColumnName: id + + +Things to note: + +- The "association override" specifies the overrides base on the property name. +- This feature is available for all kind of associations. (OneToOne, OneToMany, ManyToOne, ManyToMany) +- The association type *CANNOT* be changed. +- The override could redefine the joinTables or joinColumns depending on the association type. + +Attribute Override +~~~~~~~~~~~~~~~~~~~~ +Override the mapping of a field. + +Could be used by an entity that extends a mapped superclass to override a field mapping defined by the mapped superclass. + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .. code-block:: yaml + + # user mapping + MyProject\Model\User: + type: mappedSuperclass + id: + id: + type: integer + column: user_id + length: 150 + generator: + strategy: AUTO + fields: + name: + type: string + column: user_name + length: 250 + nullable: true + unique: false + #other fields mapping + + + # guest mapping + MyProject\Model\Guest: + type: entity + attributeOverride: + id: + column: guest_id + type: integer + length: 140 + name: + column: guest_name + type: string + length: 240 + nullable: false + unique: true + +Things to note: + +- The "attribute override" specifies the overrides base on the property name. +- The column type *CANNOT* be changed. if the column type is not equals you got a ``MappingException`` +- The override can redefine all the column except the type. diff --git a/vendor/doctrine/orm/docs/en/reference/installation.rst b/vendor/doctrine/orm/docs/en/reference/installation.rst new file mode 100644 index 0000000000..8b732ad605 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/installation.rst @@ -0,0 +1,5 @@ +Installation +============ + +The installation chapter has moved to `Installation and Configuration +`_. diff --git a/vendor/doctrine/orm/docs/en/reference/limitations-and-known-issues.rst b/vendor/doctrine/orm/docs/en/reference/limitations-and-known-issues.rst new file mode 100644 index 0000000000..e3eb498a06 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/limitations-and-known-issues.rst @@ -0,0 +1,189 @@ +Limitations and Known Issues +============================ + +We try to make using Doctrine2 a very pleasant experience. +Therefore we think it is very important to be honest about the +current limitations to our users. Much like every other piece of +software Doctrine2 is not perfect and far from feature complete. +This section should give you an overview of current limitations of +Doctrine 2 as well as critical known issues that you should know +about. + +Current Limitations +------------------- + +There is a set of limitations that exist currently which might be +solved in the future. Any of this limitations now stated has at +least one ticket in the Tracker and is discussed for future +releases. + +Join-Columns with non-primary keys +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It is not possible to use join columns pointing to non-primary keys. Doctrine will think these are the primary +keys and create lazy-loading proxies with the data, which can lead to unexpected results. Doctrine can for performance +reasons not validate the correctness of this settings at runtime but only through the Validate Schema command. + +Mapping Arrays to a Join Table +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Related to the previous limitation with "Foreign Keys as +Identifier" you might be interested in mapping the same table +structure as given above to an array. However this is not yet +possible either. See the following example: + +.. code-block:: sql + + CREATE TABLE product ( + id INTEGER, + name VARCHAR, + PRIMARY KEY(id) + ); + + CREATE TABLE product_attributes ( + product_id INTEGER, + attribute_name VARCHAR, + attribute_value VARCHAR, + PRIMARY KEY (product_id, attribute_name) + ); + +This schema should be mapped to a Product Entity as follows: + +.. code-block:: php + + class Product + { + private $id; + private $name; + private $attributes = array(); + } + +Where the ``attribute_name`` column contains the key and +``attribute_value`` contains the value of each array element in +``$attributes``. + +The feature request for persistence of primitive value arrays +`is described in the DDC-298 ticket `_. + +Value Objects +~~~~~~~~~~~~~ + +There is currently no native support value objects in Doctrine +other than for ``DateTime`` instances or if you serialize the +objects using ``serialize()/deserialize()`` which the DBAL Type +"object" supports. + +The feature request for full value-object support +`is described in the DDC-93 ticket `_. + + +Cascade Merge with Bi-directional Associations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There are two bugs now that concern the use of cascade merge in combination with bi-directional associations. +Make sure to study the behavior of cascade merge if you are using it: + +- `DDC-875 `_ Merge can sometimes add the same entity twice into a collection +- `DDC-763 `_ Cascade merge on associated entities can insert too many rows through "Persistence by Reachability" + +Custom Persisters +~~~~~~~~~~~~~~~~~ + +A Persister in Doctrine is an object that is responsible for the +hydration and write operations of an entity against the database. +Currently there is no way to overwrite the persister implementation +for a given entity, however there are several use-cases that can +benefit from custom persister implementations: + + +- `Add Upsert Support `_ +- `Evaluate possible ways in which stored-procedures can be used `_ +- The previous Filter Rules Feature Request + +Persist Keys of Collections +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +PHP Arrays are ordered hash-maps and so should be the +``Doctrine\Common\Collections\Collection`` interface. We plan to +evaluate a feature that optionally persists and hydrates the keys +of a Collection instance. + +`Ticket DDC-213 `_ + +Mapping many tables to one entity +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It is not possible to map several equally looking tables onto one +entity. For example if you have a production and an archive table +of a certain business concept then you cannot have both tables map +to the same entity. + +Behaviors +~~~~~~~~~ + +Doctrine 2 will **never** include a behavior system like Doctrine 1 +in the core library. We don't think behaviors add more value than +they cost pain and debugging hell. Please see the many different +blog posts we have written on this topics: + +- `Doctrine2 "Behaviors" in a Nutshell `_ +- `A re-usable Versionable behavior for Doctrine2 `_ +- `Write your own ORM on top of Doctrine2 `_ +- `Doctrine 2 Behavioral Extensions `_ +- `Doctrator _ + +Doctrine 2 has enough hooks and extension points so that **you** can +add whatever you want on top of it. None of this will ever become +core functionality of Doctrine2 however, you will have to rely on +third party extensions for magical behaviors. + +Nested Set +~~~~~~~~~~ + +NestedSet was offered as a behavior in Doctrine 1 and will not be +included in the core of Doctrine 2. However there are already two +extensions out there that offer support for Nested Set with +Doctrine 2: + + +- `Doctrine2 Hierarchical-Structural Behavior `_ +- `Doctrine2 NestedSet `_ + +Known Issues +------------ + +The Known Issues section describes critical/blocker bugs and other +issues that are either complicated to fix, not fixable due to +backwards compatibility issues or where no simple fix exists (yet). +We don't plan to add every bug in the tracker there, just those +issues that can potentially cause nightmares or pain of any sort. + +See the Open Bugs on Jira for more details on `bugs, improvement and feature +requests +`_. + +Identifier Quoting and Legacy Databases +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For compatibility reasons between all the supported vendors and +edge case problems Doctrine 2 does **NOT** do automatic identifier +quoting. This can lead to problems when trying to get +legacy-databases to work with Doctrine 2. + + +- You can quote column-names as described in the + :doc:`Basic-Mapping ` section. +- You cannot quote join column names. +- You cannot use non [a-zA-Z0-9\_]+ characters, they will break + several SQL statements. + +Having problems with these kind of column names? Many databases +support all CRUD operations on views that semantically map to +certain tables. You can create views for all your problematic +tables and column names to avoid the legacy quoting nightmare. + +Microsoft SQL Server and Doctrine "datetime" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Doctrine assumes that you use ``DateTime2`` data-types. If your legacy database contains DateTime +datatypes then you have to add your own data-type (see Basic Mapping for an example). diff --git a/vendor/doctrine/orm/docs/en/reference/metadata-drivers.rst b/vendor/doctrine/orm/docs/en/reference/metadata-drivers.rst new file mode 100644 index 0000000000..6b9cb31e42 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/metadata-drivers.rst @@ -0,0 +1,194 @@ +Metadata Drivers +================ + +The heart of an object relational mapper is the mapping information +that glues everything together. It instructs the EntityManager how +it should behave when dealing with the different entities. + +Core Metadata Drivers +--------------------- + +Doctrine provides a few different ways for you to specify your +metadata: + + +- **XML files** (XmlDriver) +- **Class DocBlock Annotations** (AnnotationDriver) +- **YAML files** (YamlDriver) +- **PHP Code in files or static functions** (PhpDriver) + +Something important to note about the above drivers is they are all +an intermediate step to the same end result. The mapping +information is populated to ``Doctrine\ORM\Mapping\ClassMetadata`` +instances. So in the end, Doctrine only ever has to work with the +API of the ``ClassMetadata`` class to get mapping information for +an entity. + +.. note:: + + The populated ``ClassMetadata`` instances are also cached + so in a production environment the parsing and populating only ever + happens once. You can configure the metadata cache implementation + using the ``setMetadataCacheImpl()`` method on the + ``Doctrine\ORM\Configuration`` class: + + .. code-block:: php + + getConfiguration()->setMetadataCacheImpl(new ApcCache()); + + +If you want to use one of the included core metadata drivers you +just need to configure it. All the drivers are in the +``Doctrine\ORM\Mapping\Driver`` namespace: + +.. code-block:: php + + getConfiguration()->setMetadataDriverImpl($driver); + +Implementing Metadata Drivers +----------------------------- + +In addition to the included metadata drivers you can very easily +implement your own. All you need to do is define a class which +implements the ``Driver`` interface: + +.. code-block:: php + + _loadMappingFile($file); + + // populate ClassMetadataInfo instance from $data + } + + /** + * {@inheritdoc} + */ + protected function _loadMappingFile($file) + { + // parse contents of $file and return php data structure + } + } + +.. note:: + + When using the ``AbstractFileDriver`` it requires that you + only have one entity defined per file and the file named after the + class described inside where namespace separators are replaced by + periods. So if you have an entity named ``Entities\User`` and you + wanted to write a mapping file for your driver above you would need + to name the file ``Entities.User.dcm.ext`` for it to be + recognized. + + +Now you can use your ``MyMetadataDriver`` implementation by setting +it with the ``setMetadataDriverImpl()`` method: + +.. code-block:: php + + getConfiguration()->setMetadataDriverImpl($driver); + +ClassMetadata +------------- + +The last piece you need to know and understand about metadata in +Doctrine 2 is the API of the ``ClassMetadata`` classes. You need to +be familiar with them in order to implement your own drivers but +more importantly to retrieve mapping information for a certain +entity when needed. + +You have all the methods you need to manually specify the mapping +information instead of using some mapping file to populate it from. +The base ``ClassMetadataInfo`` class is responsible for only data +storage and is not meant for runtime use. It does not require that +the class actually exists yet so it is useful for describing some +entity before it exists and using that information to generate for +example the entities themselves. The class ``ClassMetadata`` +extends ``ClassMetadataInfo`` and adds some functionality required +for runtime usage and requires that the PHP class is present and +can be autoloaded. + +You can read more about the API of the ``ClassMetadata`` classes in +the PHP Mapping chapter. + +Getting ClassMetadata Instances +------------------------------- + +If you want to get the ``ClassMetadata`` instance for an entity in +your project to programmatically use some mapping information to +generate some HTML or something similar you can retrieve it through +the ``ClassMetadataFactory``: + +.. code-block:: php + + getMetadataFactory(); + $class = $cmf->getMetadataFor('MyEntityName'); + +Now you can learn about the entity and use the data stored in the +``ClassMetadata`` instance to get all mapped fields for example and +iterate over them: + +.. code-block:: php + + fieldMappings as $fieldMapping) { + echo $fieldMapping['fieldName'] . "\n"; + } + + diff --git a/vendor/doctrine/orm/docs/en/reference/namingstrategy.rst b/vendor/doctrine/orm/docs/en/reference/namingstrategy.rst new file mode 100644 index 0000000000..e1a29cd3e9 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/namingstrategy.rst @@ -0,0 +1,150 @@ +Implementing a NamingStrategy +============================== + +.. versionadded:: 2.3 + +Using a naming strategy you can provide rules for automatically generating +database identifiers, columns and tables names +when the table/column name is not given. +This feature helps reduce the verbosity of the mapping document, +eliminating repetitive noise (eg: ``TABLE_``). + + +Configuring a naming strategy +----------------------------- +The default strategy used by Doctrine is quite minimal. + +By default the ``Doctrine\ORM\Mapping\DefaultNamingStrategy`` +uses the simple class name and the attributes names to generate tables and columns + +You can specify a different strategy by calling ``Doctrine\ORM\Configuration#setNamingStrategy()`` : + +.. code-block:: php + + setNamingStrategy($namingStrategy); + +Underscore naming strategy +--------------------------- + +``\Doctrine\ORM\Mapping\UnderscoreNamingStrategy`` is a built-in strategy +that might be a useful if you want to use a underlying convention. + +.. code-block:: php + + setNamingStrategy($namingStrategy); + +Then SomeEntityName will generate the table SOME_ENTITY_NAME when CASE_UPPER +or some_entity_name using CASE_LOWER is given. + + +Naming strategy interface +------------------------- +The interface ``Doctrine\ORM\Mapping\NamingStrategy`` allows you to specify +a "naming standard" for database tables and columns. + +.. code-block:: php + + referenceColumnName(); + } + public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) + { + return strtolower($this->classToTableName($sourceEntity) . '_' . + $this->classToTableName($targetEntity)); + } + public function joinKeyColumnName($entityName, $referencedColumnName = null) + { + return strtolower($this->classToTableName($entityName) . '_' . + ($referencedColumnName ?: $this->referenceColumnName())); + } + } + +Configuring the namingstrategy is easy if. +Just set your naming strategy calling ``Doctrine\ORM\Configuration#setNamingStrategy()`` :. + +.. code-block:: php + + setNamingStrategy($namingStrategy); diff --git a/vendor/doctrine/orm/docs/en/reference/native-sql.rst b/vendor/doctrine/orm/docs/en/reference/native-sql.rst new file mode 100644 index 0000000000..89eb2850bf --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/native-sql.rst @@ -0,0 +1,905 @@ +Native SQL +========== + +With ``NativeQuery`` you can execute native SELECT SQL statements +and map the results to Doctrine entities or any other result format +supported by Doctrine. + +In order to make this mapping possible, you need to describe +to Doctrine what columns in the result map to which entity property. +This description is represented by a ``ResultSetMapping`` object. + +With this feature you can map arbitrary SQL code to objects, such as highly +vendor-optimized SQL or stored-procedures. + +Writing ``ResultSetMapping`` from scratch is complex, but there is a convenience +wrapper around it called a ``ResultSetMappingBuilder``. It can generate +the mappings for you based on Entities and even generates the ``SELECT`` +clause based on this information for you. + +.. note:: + + If you want to execute DELETE, UPDATE or INSERT statements + the Native SQL API cannot be used and will probably throw errors. + Use ``EntityManager#getConnection()`` to access the native database + connection and call the ``executeUpdate()`` method for these + queries. + +The NativeQuery class +--------------------- + +To create a ``NativeQuery`` you use the method +``EntityManager#createNativeQuery($sql, $resultSetMapping)``. As you can see in +the signature of this method, it expects 2 ingredients: The SQL you want to +execute and the ``ResultSetMapping`` that describes how the results will be +mapped. + +Once you obtained an instance of a ``NativeQuery``, you can bind parameters to +it with the same API that ``Query`` has and execute it. + +.. code-block:: php + + createNativeQuery('SELECT id, name, discr FROM users WHERE name = ?', $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + +ResultSetMappingBuilder +----------------------- + +An easy start into ResultSet mapping is the ``ResultSetMappingBuilder`` object. +This has several benefits: + +- The builder takes care of automatically updating your ``ResultSetMapping`` + when the fields or associations change on the metadata of an entity. +- You can generate the required ``SELECT`` expression for a builder + by converting it to a string. +- The API is much simpler than the usual ``ResultSetMapping`` API. + +One downside is that the builder API does not yet support entities +with inheritance hierachies. + +.. code-block:: php + + addRootEntityFromClassMetadata('MyProject\User', 'u'); + $rsm->addJoinedEntityFromClassMetadata('MyProject\Address', 'a', 'u', 'address', array('id' => 'address_id')); + +The builder extends the ``ResultSetMapping`` class and as such has all the functionality of it as well. + +..versionadded:: 2.4 + +Starting with Doctrine ORM 2.4 you can generate the ``SELECT`` clause +from a ``ResultSetMappingBuilder``. You can either cast the builder +object to ``(string)`` and the DQL aliases are used as SQL table aliases +or use the ``generateSelectClause($tableAliases)`` method and pass +a mapping from DQL alias (key) to SQL alias (value) + +.. code-block:: php + + generateSelectClause(array( + 'u' => 't1', + 'g' => 't2' + )); + $sql = "SELECT " . $selectClause . " FROM users t1 JOIN groups t2 ON t1.group_id = t2.id"; + + +The ResultSetMapping +-------------------- + +Understanding the ``ResultSetMapping`` is the key to using a +``NativeQuery``. A Doctrine result can contain the following +components: + + +- Entity results. These represent root result elements. +- Joined entity results. These represent joined entities in + associations of root entity results. +- Field results. These represent a column in the result set that + maps to a field of an entity. A field result always belongs to an + entity result or joined entity result. +- Scalar results. These represent scalar values in the result set + that will appear in each result row. Adding scalar results to a + ResultSetMapping can also cause the overall result to become + **mixed** (see DQL - Doctrine Query Language) if the same + ResultSetMapping also contains entity results. +- Meta results. These represent columns that contain + meta-information, such as foreign keys and discriminator columns. + When querying for objects (``getResult()``), all meta columns of + root entities or joined entities must be present in the SQL query + and mapped accordingly using ``ResultSetMapping#addMetaResult``. + +.. note:: + + It might not surprise you that Doctrine uses + ``ResultSetMapping`` internally when you create DQL queries. As + the query gets parsed and transformed to SQL, Doctrine fills a + ``ResultSetMapping`` that describes how the results should be + processed by the hydration routines. + + +We will now look at each of the result types that can appear in a +ResultSetMapping in detail. + +Entity results +~~~~~~~~~~~~~~ + +An entity result describes an entity type that appears as a root +element in the transformed result. You add an entity result through +``ResultSetMapping#addEntityResult()``. Let's take a look at the +method signature in detail: + +.. code-block:: php + + addEntityResult('User', 'u'); + $rsm->addFieldResult('u', 'id', 'id'); + $rsm->addFieldResult('u', 'name', 'name'); + + $query = $this->_em->createNativeQuery('SELECT id, name FROM users WHERE name = ?', $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + +The result would look like this: + +.. code-block:: php + + array( + [0] => User (Object) + ) + +Note that this would be a partial object if the entity has more +fields than just id and name. In the example above the column and +field names are identical but that is not necessary, of course. +Also note that the query string passed to createNativeQuery is +**real native SQL**. Doctrine does not touch this SQL in any way. + +In the previous basic example, a User had no relations and the +table the class is mapped to owns no foreign keys. The next example +assumes User has a unidirectional or bidirectional one-to-one +association to a CmsAddress, where the User is the owning side and +thus owns the foreign key. + +.. code-block:: php + + addEntityResult('User', 'u'); + $rsm->addFieldResult('u', 'id', 'id'); + $rsm->addFieldResult('u', 'name', 'name'); + $rsm->addMetaResult('u', 'address_id', 'address_id'); + + $query = $this->_em->createNativeQuery('SELECT id, name, address_id FROM users WHERE name = ?', $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + +Foreign keys are used by Doctrine for lazy-loading purposes when +querying for objects. In the previous example, each user object in +the result will have a proxy (a "ghost") in place of the address +that contains the address\_id. When the ghost proxy is accessed, it +loads itself based on this key. + +Consequently, associations that are *fetch-joined* do not require +the foreign keys to be present in the SQL result set, only +associations that are lazy. + +.. code-block:: php + + addEntityResult('User', 'u'); + $rsm->addFieldResult('u', 'id', 'id'); + $rsm->addFieldResult('u', 'name', 'name'); + $rsm->addJoinedEntityResult('Address' , 'a', 'u', 'address'); + $rsm->addFieldResult('a', 'address_id', 'id'); + $rsm->addFieldResult('a', 'street', 'street'); + $rsm->addFieldResult('a', 'city', 'city'); + + $sql = 'SELECT u.id, u.name, a.id AS address_id, a.street, a.city FROM users u ' . + 'INNER JOIN address a ON u.address_id = a.id WHERE u.name = ?'; + $query = $this->_em->createNativeQuery($sql, $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + +In this case the nested entity ``Address`` is registered with the +``ResultSetMapping#addJoinedEntityResult`` method, which notifies +Doctrine that this entity is not hydrated at the root level, but as +a joined entity somewhere inside the object graph. In this case we +specify the alias 'u' as third parameter and ``address`` as fourth +parameter, which means the ``Address`` is hydrated into the +``User::$address`` property. + +If a fetched entity is part of a mapped hierarchy that requires a +discriminator column, this column must be present in the result set +as a meta column so that Doctrine can create the appropriate +concrete type. This is shown in the following example where we +assume that there are one or more subclasses that extend User and +either Class Table Inheritance or Single Table Inheritance is used +to map the hierarchy (both use a discriminator column). + +.. code-block:: php + + addEntityResult('User', 'u'); + $rsm->addFieldResult('u', 'id', 'id'); + $rsm->addFieldResult('u', 'name', 'name'); + $rsm->addMetaResult('u', 'discr', 'discr'); // discriminator column + $rsm->setDiscriminatorColumn('u', 'discr'); + + $query = $this->_em->createNativeQuery('SELECT id, name, discr FROM users WHERE name = ?', $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + +Note that in the case of Class Table Inheritance, an example as +above would result in partial objects if any objects in the result +are actually a subtype of User. When using DQL, Doctrine +automatically includes the necessary joins for this mapping +strategy but with native SQL it is your responsibility. + +Named Native Query +------------------ + +You can also map a native query using a named native query mapping. + +To achieve that, you must describe the SQL resultset structure +using named native query (and sql resultset mappings if is a several resultset mappings). + +Like named query, a named native query can be defined at class level or in a XML or YAML file. + + +A resultSetMapping parameter is defined in @NamedNativeQuery, +it represents the name of a defined @SqlResultSetMapping. + +.. configuration-block:: + + .. code-block:: php + + + + + + SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM users u INNER JOIN addresses a ON u.id = a.user_id INNER JOIN phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username + + + + + + + + + + + + + + + + + + + + .. code-block:: yaml + + MyProject\Model\User: + type: entity + namedNativeQueries: + fetchMultipleJoinsEntityResults: + name: fetchMultipleJoinsEntityResults + resultSetMapping: mappingMultipleJoinsEntityResults + query: SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM users u INNER JOIN addresses a ON u.id = a.user_id INNER JOIN phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username + sqlResultSetMappings: + mappingMultipleJoinsEntityResults: + name: mappingMultipleJoinsEntityResults + columnResult: + 0: + name: numphones + entityResult: + 0: + entityClass: __CLASS__ + fieldResult: + 0: + name: id + column: u_id + 1: + name: name + column: u_name + 2: + name: status + column: u_status + 1: + entityClass: Address + fieldResult: + 0: + name: id + column: a_id + 1: + name: zip + column: a_zip + 2: + name: country + column: a_country + + +Things to note: + - The resultset mapping declares the entities retrieved by this native query. + - Each field of the entity is bound to a SQL alias (or column name). + - All fields of the entity including the ones of subclasses + and the foreign key columns of related entities have to be present in the SQL query. + - Field definitions are optional provided that they map to the same + column name as the one declared on the class property. + - ``__CLASS__`` is an alias for the mapped class + + +In the above example, +the ``fetchJoinedAddress`` named query use the joinMapping result set mapping. +This mapping returns 2 entities, User and Address, each property is declared and associated to a column name, +actually the column name retrieved by the query. + +Let's now see an implicit declaration of the property / column. + +.. configuration-block:: + + .. code-block:: php + + + + + + SELECT * FROM addresses + + + + + + + + + + .. code-block:: yaml + + MyProject\Model\Address: + type: entity + namedNativeQueries: + findAll: + resultSetMapping: mappingFindAll + query: SELECT * FROM addresses + sqlResultSetMappings: + mappingFindAll: + name: mappingFindAll + entityResult: + address: + entityClass: Address + + +In this example, we only describe the entity member of the result set mapping. +The property / column mappings is done using the entity mapping values. +In this case the model property is bound to the model_txt column. +If the association to a related entity involve a composite primary key, +a @FieldResult element should be used for each foreign key column. +The @FieldResult name is composed of the property name for the relationship, +followed by a dot ("."), followed by the name or the field or property of the primary key. + + +.. configuration-block:: + + .. code-block:: php + + + + + + SELECT u.id, u.name, u.status, a.id AS a_id, a.country AS a_country, a.zip AS a_zip, a.city AS a_city FROM users u INNER JOIN addresses a ON u.id = a.user_id WHERE u.username = ? + + + + + + + + + + + + + + + + + + .. code-block:: yaml + + MyProject\Model\User: + type: entity + namedNativeQueries: + fetchJoinedAddress: + name: fetchJoinedAddress + resultSetMapping: mappingJoinedAddress + query: SELECT u.id, u.name, u.status, a.id AS a_id, a.country AS a_country, a.zip AS a_zip, a.city AS a_city FROM users u INNER JOIN addresses a ON u.id = a.user_id WHERE u.username = ? + sqlResultSetMappings: + mappingJoinedAddress: + entityResult: + 0: + entityClass: __CLASS__ + fieldResult: + 0: + name: id + 1: + name: name + 2: + name: status + 3: + name: address.id + column: a_id + 4: + name: address.zip + column: a_zip + 5: + name: address.city + column: a_city + 6: + name: address.country + column: a_country + + + +If you retrieve a single entity and if you use the default mapping, +you can use the resultClass attribute instead of resultSetMapping: + +.. configuration-block:: + + .. code-block:: php + + + + + + SELECT * FROM addresses WHERE id = ? + + + + + .. code-block:: yaml + + MyProject\Model\Address: + type: entity + namedNativeQueries: + findAll: + name: findAll + resultClass: Address + query: SELECT * FROM addresses + + +In some of your native queries, you'll have to return scalar values, +for example when building report queries. +You can map them in the @SqlResultsetMapping through @ColumnResult. +You actually can even mix, entities and scalar returns in the same native query (this is probably not that common though). + +.. configuration-block:: + + .. code-block:: php + + + + + SELECT COUNT(*) AS count FROM addresses + + + + + + + + + .. code-block:: yaml + + MyProject\Model\Address: + type: entity + namedNativeQueries: + count: + name: count + resultSetMapping: mappingCount + query: SELECT COUNT(*) AS count FROM addresses + sqlResultSetMappings: + mappingCount: + name: mappingCount + columnResult: + count: + name: count diff --git a/vendor/doctrine/orm/docs/en/reference/partial-objects.rst b/vendor/doctrine/orm/docs/en/reference/partial-objects.rst new file mode 100644 index 0000000000..396eecce3d --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/partial-objects.rst @@ -0,0 +1,90 @@ +Partial Objects +=============== + +A partial object is an object whose state is not fully initialized +after being reconstituted from the database and that is +disconnected from the rest of its data. The following section will +describe why partial objects are problematic and what the approach +of Doctrine2 to this problem is. + +.. note:: + + The partial object problem in general does not apply to + methods or queries where you do not retrieve the query result as + objects. Examples are: ``Query#getArrayResult()``, + ``Query#getScalarResult()``, ``Query#getSingleScalarResult()``, + etc. + +.. warning:: + + Use of partial objects is tricky. Fields that are not retrieved + from the database will not be updated by the UnitOfWork even if they + get changed in your objects. You can only promote a partial object + to a fully-loaded object by calling ``EntityManager#refresh()`` + or a DQL query with the refresh flag. + + +What is the problem? +-------------------- + +In short, partial objects are problematic because they are usually +objects with broken invariants. As such, code that uses these +partial objects tends to be very fragile and either needs to "know" +which fields or methods can be safely accessed or add checks around +every field access or method invocation. The same holds true for +the internals, i.e. the method implementations, of such objects. +You usually simply assume the state you need in the method is +available, after all you properly constructed this object before +you pushed it into the database, right? These blind assumptions can +quickly lead to null reference errors when working with such +partial objects. + +It gets worse with the scenario of an optional association (0..1 to +1). When the associated field is NULL, you don't know whether this +object does not have an associated object or whether it was simply +not loaded when the owning object was loaded from the database. + +These are reasons why many ORMs do not allow partial objects at all +and instead you always have to load an object with all its fields +(associations being proxied). One secure way to allow partial +objects is if the programming language/platform allows the ORM tool +to hook deeply into the object and instrument it in such a way that +individual fields (not only associations) can be loaded lazily on +first access. This is possible in Java, for example, through +bytecode instrumentation. In PHP though this is not possible, so +there is no way to have "secure" partial objects in an ORM with +transparent persistence. + +Doctrine, by default, does not allow partial objects. That means, +any query that only selects partial object data and wants to +retrieve the result as objects (i.e. ``Query#getResult()``) will +raise an exception telling you that partial objects are dangerous. +If you want to force a query to return you partial objects, +possibly as a performance tweak, you can use the ``partial`` +keyword as follows: + +.. code-block:: php + + createQuery("select partial u.{id,name} from MyApp\Domain\User u"); + +You can also get a partial reference instead of a proxy reference by +calling: + +.. code-block:: php + + getPartialReference('MyApp\Domain\User', 1); + +Partial references are objects with only the identifiers set as they +are passed to the second argument of the ``getPartialReference()`` method. +All other fields are null. + +When should I force partial objects? +------------------------------------ + +Mainly for optimization purposes, but be careful of premature +optimization as partial objects lead to potentially more fragile +code. + + diff --git a/vendor/doctrine/orm/docs/en/reference/php-mapping.rst b/vendor/doctrine/orm/docs/en/reference/php-mapping.rst new file mode 100644 index 0000000000..90f00d9bcb --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/php-mapping.rst @@ -0,0 +1,310 @@ +PHP Mapping +=========== + +Doctrine 2 also allows you to provide the ORM metadata in the form +of plain PHP code using the ``ClassMetadata`` API. You can write +the code in PHP files or inside of a static function named +``loadMetadata($class)`` on the entity class itself. + +PHP Files +--------- + +If you wish to write your mapping information inside PHP files that +are named after the entity and included to populate the metadata +for an entity you can do so by using the ``PHPDriver``: + +.. code-block:: php + + getConfiguration()->setMetadataDriverImpl($driver); + +Now imagine we had an entity named ``Entities\User`` and we wanted +to write a mapping file for it using the above configured +``PHPDriver`` instance: + +.. code-block:: php + + mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'type' => 'integer' + )); + + $metadata->mapField(array( + 'fieldName' => 'username', + 'type' => 'string' + )); + +Now we can easily retrieve the populated ``ClassMetadata`` instance +where the ``PHPDriver`` includes the file and the +``ClassMetadataFactory`` caches it for later retrieval: + +.. code-block:: php + + getClassMetadata('Entities\User'); + // or + $class = $em->getMetadataFactory()->getMetadataFor('Entities\User'); + +Static Function +--------------- + +In addition to the PHP files you can also specify your mapping +information inside of a static function defined on the entity class +itself. This is useful for cases where you want to keep your entity +and mapping information together but don't want to use annotations. +For this you just need to use the ``StaticPHPDriver``: + +.. code-block:: php + + getConfiguration()->setMetadataDriverImpl($driver); + +Now you just need to define a static function named +``loadMetadata($metadata)`` on your entity: + +.. code-block:: php + + mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'type' => 'integer' + )); + + $metadata->mapField(array( + 'fieldName' => 'username', + 'type' => 'string' + )); + } + } + +ClassMetadataBuilder +-------------------- + +To ease the use of the ClassMetadata API (which is very raw) there is a ``ClassMetadataBuilder`` that you can use. + +.. code-block:: php + + createField('id', 'integer')->isPrimaryKey()->generatedValue()->build(); + $builder->addField('username', 'string'); + } + } + +The API of the ClassMetadataBuilder has the following methods with a fluent interface: + +- ``addField($name, $type, array $mapping)`` +- ``setMappedSuperclass()`` +- ``setReadOnly()`` +- ``setCustomRepositoryClass($className)`` +- ``setTable($name)`` +- ``addIndex(array $columns, $indexName)`` +- ``addUniqueConstraint(array $columns, $constraintName)`` +- ``addNamedQuery($name, $dqlQuery)`` +- ``setJoinedTableInheritance()`` +- ``setSingleTableInheritance()`` +- ``setDiscriminatorColumn($name, $type = 'string', $length = 255)`` +- ``addDiscriminatorMapClass($name, $class)`` +- ``setChangeTrackingPolicyDeferredExplicit()`` +- ``setChangeTrackingPolicyNotify()`` +- ``addLifecycleEvent($methodName, $event)`` +- ``addManyToOne($name, $targetEntity, $inversedBy = null)`` +- ``addInverseOneToOne($name, $targetEntity, $mappedBy)`` +- ``addOwningOneToOne($name, $targetEntity, $inversedBy = null)`` +- ``addOwningManyToMany($name, $targetEntity, $inversedBy = null)`` +- ``addInverseManyToMany($name, $targetEntity, $mappedBy)`` +- ``addOneToMany($name, $targetEntity, $mappedBy)`` + +It also has several methods that create builders (which are necessary for advanced mappings): + +- ``createField($name, $type)`` returns a ``FieldBuilder`` instance +- ``createManyToOne($name, $targetEntity)`` returns an ``AssociationBuilder`` instance +- ``createOneToOne($name, $targetEntity)`` returns an ``AssociationBuilder`` instance +- ``createManyToMany($name, $targetEntity)`` returns an ``ManyToManyAssociationBuilder`` instance +- ``createOneToMany($name, $targetEntity)`` returns an ``OneToManyAssociationBuilder`` instance + +ClassMetadataInfo API +--------------------- + +The ``ClassMetadataInfo`` class is the base data object for storing +the mapping metadata for a single entity. It contains all the +getters and setters you need populate and retrieve information for +an entity. + +General Setters +~~~~~~~~~~~~~~~ + + +- ``setTableName($tableName)`` +- ``setPrimaryTable(array $primaryTableDefinition)`` +- ``setCustomRepositoryClass($repositoryClassName)`` +- ``setIdGeneratorType($generatorType)`` +- ``setIdGenerator($generator)`` +- ``setSequenceGeneratorDefinition(array $definition)`` +- ``setChangeTrackingPolicy($policy)`` +- ``setIdentifier(array $identifier)`` + +Inheritance Setters +~~~~~~~~~~~~~~~~~~~ + + +- ``setInheritanceType($type)`` +- ``setSubclasses(array $subclasses)`` +- ``setParentClasses(array $classNames)`` +- ``setDiscriminatorColumn($columnDef)`` +- ``setDiscriminatorMap(array $map)`` + +Field Mapping Setters +~~~~~~~~~~~~~~~~~~~~~ + + +- ``mapField(array $mapping)`` +- ``mapOneToOne(array $mapping)`` +- ``mapOneToMany(array $mapping)`` +- ``mapManyToOne(array $mapping)`` +- ``mapManyToMany(array $mapping)`` + +Lifecycle Callback Setters +~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +- ``addLifecycleCallback($callback, $event)`` +- ``setLifecycleCallbacks(array $callbacks)`` + +Versioning Setters +~~~~~~~~~~~~~~~~~~ + + +- ``setVersionMapping(array &$mapping)`` +- ``setVersioned($bool)`` +- ``setVersionField()`` + +General Getters +~~~~~~~~~~~~~~~ + + +- ``getTableName()`` +- ``getTemporaryIdTableName()`` + +Identifier Getters +~~~~~~~~~~~~~~~~~~ + + +- ``getIdentifierColumnNames()`` +- ``usesIdGenerator()`` +- ``isIdentifier($fieldName)`` +- ``isIdGeneratorIdentity()`` +- ``isIdGeneratorSequence()`` +- ``isIdGeneratorTable()`` +- ``isIdentifierNatural()`` +- ``getIdentifierFieldNames()`` +- ``getSingleIdentifierFieldName()`` +- ``getSingleIdentifierColumnName()`` + +Inheritance Getters +~~~~~~~~~~~~~~~~~~~ + + +- ``isInheritanceTypeNone()`` +- ``isInheritanceTypeJoined()`` +- ``isInheritanceTypeSingleTable()`` +- ``isInheritanceTypeTablePerClass()`` +- ``isInheritedField($fieldName)`` +- ``isInheritedAssociation($fieldName)`` + +Change Tracking Getters +~~~~~~~~~~~~~~~~~~~~~~~ + + +- ``isChangeTrackingDeferredExplicit()`` +- ``isChangeTrackingDeferredImplicit()`` +- ``isChangeTrackingNotify()`` + +Field & Association Getters +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +- ``isUniqueField($fieldName)`` +- ``isNullable($fieldName)`` +- ``getColumnName($fieldName)`` +- ``getFieldMapping($fieldName)`` +- ``getAssociationMapping($fieldName)`` +- ``getAssociationMappings()`` +- ``getFieldName($columnName)`` +- ``hasField($fieldName)`` +- ``getColumnNames(array $fieldNames = null)`` +- ``getTypeOfField($fieldName)`` +- ``getTypeOfColumn($columnName)`` +- ``hasAssociation($fieldName)`` +- ``isSingleValuedAssociation($fieldName)`` +- ``isCollectionValuedAssociation($fieldName)`` + +Lifecycle Callback Getters +~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +- ``hasLifecycleCallbacks($lifecycleEvent)`` +- ``getLifecycleCallbacks($event)`` + +ClassMetadata API +----------------- + +The ``ClassMetadata`` class extends ``ClassMetadataInfo`` and adds +the runtime functionality required by Doctrine. It adds a few extra +methods related to runtime reflection for working with the entities +themselves. + + +- ``getReflectionClass()`` +- ``getReflectionProperties()`` +- ``getReflectionProperty($name)`` +- ``getSingleIdReflectionProperty()`` +- ``getIdentifierValues($entity)`` +- ``setIdentifierValues($entity, $id)`` +- ``setFieldValue($entity, $field, $value)`` +- ``getFieldValue($entity, $field)`` + + diff --git a/vendor/doctrine/orm/docs/en/reference/query-builder.rst b/vendor/doctrine/orm/docs/en/reference/query-builder.rst new file mode 100644 index 0000000000..8029822b56 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/query-builder.rst @@ -0,0 +1,541 @@ +The QueryBuilder +================ + +A ``QueryBuilder`` provides an API that is designed for +conditionally constructing a DQL query in several steps. + +It provides a set of classes and methods that is able to +programmatically build queries, and also provides a fluent API. +This means that you can change between one methodology to the other +as you want, and also pick one if you prefer. + +Constructing a new QueryBuilder object +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The same way you build a normal Query, you build a ``QueryBuilder`` +object, just providing the correct method name. Here is an example +how to build a ``QueryBuilder`` object: + +.. code-block:: php + + createQueryBuilder(); + +Once you have created an instance of QueryBuilder, it provides a +set of useful informative functions that you can use. One good +example is to inspect what type of object the ``QueryBuilder`` is. + +.. code-block:: php + + getType(); // Prints: 0 + +There're currently 3 possible return values for ``getType()``: + + +- ``QueryBuilder::SELECT``, which returns value 0 +- ``QueryBuilder::DELETE``, returning value 1 +- ``QueryBuilder::UPDATE``, which returns value 2 + +It is possible to retrieve the associated ``EntityManager`` of the +current ``QueryBuilder``, its DQL and also a ``Query`` object when +you finish building your DQL. + +.. code-block:: php + + getEntityManager(); + + // example4: retrieve the DQL string of what was defined in QueryBuilder + $dql = $qb->getDql(); + + // example5: retrieve the associated Query object with the processed DQL + $q = $qb->getQuery(); + +Internally, ``QueryBuilder`` works with a DQL cache to increase +performance. Any changes that may affect the generated DQL actually +modifies the state of ``QueryBuilder`` to a stage we call +STATE\_DIRTY. One ``QueryBuilder`` can be in two different states: + + +- ``QueryBuilder::STATE_CLEAN``, which means DQL haven't been + altered since last retrieval or nothing were added since its + instantiation +- ``QueryBuilder::STATE_DIRTY``, means DQL query must (and will) + be processed on next retrieval + +Working with QueryBuilder +~~~~~~~~~~~~~~~~~~~~~~~~~ + + +High level API methods +^^^^^^^^^^^^^^^^^^^^^^ + +To simplify even more the way you build a query in Doctrine, we can take +advantage of what we call Helper methods. For all base code, there +is a set of useful methods to simplify a programmer's life. To +illustrate how to work with them, here is the same example 6 +re-written using ``QueryBuilder`` helper methods: + +.. code-block:: php + + select('u') + ->from('User', 'u') + ->where('u.id = ?1') + ->orderBy('u.name', 'ASC'); + +``QueryBuilder`` helper methods are considered the standard way to +build DQL queries. Although it is supported, it should be avoided +to use string based queries and greatly encouraged to use +``$qb->expr()->*`` methods. Here is a converted example 8 to +suggested standard way to build queries: + +.. code-block:: php + + select(array('u')) // string 'u' is converted to array internally + ->from('User', 'u') + ->where($qb->expr()->orX( + $qb->expr()->eq('u.id', '?1'), + $qb->expr()->like('u.nickname', '?2') + )) + ->orderBy('u.surname', 'ASC')); + +Here is a complete list of helper methods available in ``QueryBuilder``: + +.. code-block:: php + + select('u') + // Example - $qb->select(array('u', 'p')) + // Example - $qb->select($qb->expr()->select('u', 'p')) + public function select($select = null); + + // Example - $qb->delete('User', 'u') + public function delete($delete = null, $alias = null); + + // Example - $qb->update('Group', 'g') + public function update($update = null, $alias = null); + + // Example - $qb->set('u.firstName', $qb->expr()->literal('Arnold')) + // Example - $qb->set('u.numChilds', 'u.numChilds + ?1') + // Example - $qb->set('u.numChilds', $qb->expr()->sum('u.numChilds', '?1')) + public function set($key, $value); + + // Example - $qb->from('Phonenumber', 'p') + public function from($from, $alias = null); + + // Example - $qb->innerJoin('u.Group', 'g', Expr\Join::WITH, $qb->expr()->eq('u.status_id', '?1')) + // Example - $qb->innerJoin('u.Group', 'g', 'WITH', 'u.status = ?1') + public function innerJoin($join, $alias = null, $conditionType = null, $condition = null); + + // Example - $qb->leftJoin('u.Phonenumbers', 'p', Expr\Join::WITH, $qb->expr()->eq('p.area_code', 55)) + // Example - $qb->leftJoin('u.Phonenumbers', 'p', 'WITH', 'p.area_code = 55') + public function leftJoin($join, $alias = null, $conditionType = null, $condition = null); + + // NOTE: ->where() overrides all previously set conditions + // + // Example - $qb->where('u.firstName = ?1', $qb->expr()->eq('u.surname', '?2')) + // Example - $qb->where($qb->expr()->andX($qb->expr()->eq('u.firstName', '?1'), $qb->expr()->eq('u.surname', '?2'))) + // Example - $qb->where('u.firstName = ?1 AND u.surname = ?2') + public function where($where); + + // Example - $qb->andWhere($qb->expr()->orX($qb->expr()->lte('u.age', 40), 'u.numChild = 0')) + public function andWhere($where); + + // Example - $qb->orWhere($qb->expr()->between('u.id', 1, 10)); + public function orWhere($where); + + // NOTE: -> groupBy() overrides all previously set grouping conditions + // + // Example - $qb->groupBy('u.id') + public function groupBy($groupBy); + + // Example - $qb->addGroupBy('g.name') + public function addGroupBy($groupBy); + + // NOTE: -> having() overrides all previously set having conditions + // + // Example - $qb->having('u.salary >= ?1') + // Example - $qb->having($qb->expr()->gte('u.salary', '?1')) + public function having($having); + + // Example - $qb->andHaving($qb->expr()->gt($qb->expr()->count('u.numChild'), 0)) + public function andHaving($having); + + // Example - $qb->orHaving($qb->expr()->lte('g.managerLevel', '100')) + public function orHaving($having); + + // NOTE: -> orderBy() overrides all previously set ordering conditions + // + // Example - $qb->orderBy('u.surname', 'DESC') + public function orderBy($sort, $order = null); + + // Example - $qb->addOrderBy('u.firstName') + public function addOrderBy($sort, $order = null); // Default $order = 'ASC' + } + +Binding parameters to your query +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Doctrine supports dynamic binding of parameters to your query, +similar to preparing queries. You can use both strings and numbers +as placeholders, although both have a slightly different syntax. +Additionally, you must make your choice: Mixing both styles is not +allowed. Binding parameters can simply be achieved as follows: + +.. code-block:: php + + select('u') + ->from('User u') + ->where('u.id = ?1') + ->orderBy('u.name', 'ASC'); + ->setParameter(1, 100); // Sets ?1 to 100, and thus we will fetch a user with u.id = 100 + +You are not forced to enumerate your placeholders as the +alternative syntax is available: + +.. code-block:: php + + select('u') + ->from('User u') + ->where('u.id = :identifier') + ->orderBy('u.name', 'ASC'); + ->setParameter('identifier', 100); // Sets :identifier to 100, and thus we will fetch a user with u.id = 100 + +Note that numeric placeholders start with a ? followed by a number +while the named placeholders start with a : followed by a string. + +Calling ``setParameter()`` automatically infers which type you are setting as +value. This works for integers, arrays of strings/integers, DateTime instances +and for managed entities. If you want to set a type explicitly you can call +the third argument to ``setParameter()`` explicitly. It accepts either a PDO +type or a DBAL Type name for conversion. + +If you've got several parameters to bind to your query, you can +also use setParameters() instead of setParameter() with the +following syntax: + +.. code-block:: php + + setParameters(array(1 => 'value for ?1', 2 => 'value for ?2')); + +Getting already bound parameters is easy - simply use the above +mentioned syntax with "getParameter()" or "getParameters()": + +.. code-block:: php + + getParameters(); + // $params instanceof \Doctrine\Common\Collections\ArrayCollection + + // Equivalent to + $param = $qb->getParameter(1); + // $param instanceof \Doctrine\ORM\Query\Parameter + +Note: If you try to get a parameter that was not bound yet, +getParameter() simply returns NULL. + +The API of a Query Parameter is: + +.. code-block:: php + + namespace Doctrine\ORM\Query; + + class Parameter + { + public function getName(); + public function getValue(); + public function getType(); + public function setValue($value, $type = null); + } + +Limiting the Result +^^^^^^^^^^^^^^^^^^^ + +To limit a result the query builder has some methods in common with +the Query object which can be retrieved from ``EntityManager#createQuery()``. + +.. code-block:: php + + add('select', 'u') + ->add('from', 'User u') + ->add('orderBy', 'u.name ASC') + ->setFirstResult( $offset ) + ->setMaxResults( $limit ); + +Executing a Query +^^^^^^^^^^^^^^^^^ + +The QueryBuilder is a builder object only, it has no means of actually +executing the Query. Additionally a set of parameters such as query hints +cannot be set on the QueryBuilder itself. This is why you always have to convert +a querybuilder instance into a Query object: + +.. code-block:: php + + getQuery(); + + // Set additional Query options + $query->setQueryHint('foo', 'bar'); + $query->useResultCache('my_cache_id'); + + // Execute Query + $result = $query->getResult(); + $single = $query->getSingleResult(); + $array = $query->getArrayResult(); + $scalar = $query->getScalarResult(); + $singleScalar = $query->getSingleScalarResult(); + +The Expr class +^^^^^^^^^^^^^^ + +To workaround some of the issues that ``add()`` method may cause, +Doctrine created a class that can be considered as a helper for +building expressions. This class is called ``Expr``, which provides a +set of useful methods to help build expressions: + +.. code-block:: php + + add('select', new Expr\Select(array('u'))) + ->add('from', new Expr\From('User', 'u')) + ->add('where', $qb->expr()->orX( + $qb->expr()->eq('u.id', '?1'), + $qb->expr()->like('u.nickname', '?2') + )) + ->add('orderBy', new Expr\OrderBy('u.name', 'ASC')); + +Although it still sounds complex, the ability to programmatically +create conditions are the main feature of ``Expr``. Here it is a +complete list of supported helper methods available: + +.. code-block:: php + + expr()->andX($cond1 [, $condN])->add(...)->... + public function andX($x = null); // Returns Expr\AndX instance + + // Example - $qb->expr()->orX($cond1 [, $condN])->add(...)->... + public function orX($x = null); // Returns Expr\OrX instance + + + /** Comparison objects **/ + + // Example - $qb->expr()->eq('u.id', '?1') => u.id = ?1 + public function eq($x, $y); // Returns Expr\Comparison instance + + // Example - $qb->expr()->neq('u.id', '?1') => u.id <> ?1 + public function neq($x, $y); // Returns Expr\Comparison instance + + // Example - $qb->expr()->lt('u.id', '?1') => u.id < ?1 + public function lt($x, $y); // Returns Expr\Comparison instance + + // Example - $qb->expr()->lte('u.id', '?1') => u.id <= ?1 + public function lte($x, $y); // Returns Expr\Comparison instance + + // Example - $qb->expr()->gt('u.id', '?1') => u.id > ?1 + public function gt($x, $y); // Returns Expr\Comparison instance + + // Example - $qb->expr()->gte('u.id', '?1') => u.id >= ?1 + public function gte($x, $y); // Returns Expr\Comparison instance + + // Example - $qb->expr()->isNull('u.id') => u.id IS NULL + public function isNull($x); // Returns string + + // Example - $qb->expr()->isNotNull('u.id') => u.id IS NOT NULL + public function isNotNull($x); // Returns string + + + /** Arithmetic objects **/ + + // Example - $qb->expr()->prod('u.id', '2') => u.id * 2 + public function prod($x, $y); // Returns Expr\Math instance + + // Example - $qb->expr()->diff('u.id', '2') => u.id - 2 + public function diff($x, $y); // Returns Expr\Math instance + + // Example - $qb->expr()->sum('u.id', '2') => u.id + 2 + public function sum($x, $y); // Returns Expr\Math instance + + // Example - $qb->expr()->quot('u.id', '2') => u.id / 2 + public function quot($x, $y); // Returns Expr\Math instance + + + /** Pseudo-function objects **/ + + // Example - $qb->expr()->exists($qb2->getDql()) + public function exists($subquery); // Returns Expr\Func instance + + // Example - $qb->expr()->all($qb2->getDql()) + public function all($subquery); // Returns Expr\Func instance + + // Example - $qb->expr()->some($qb2->getDql()) + public function some($subquery); // Returns Expr\Func instance + + // Example - $qb->expr()->any($qb2->getDql()) + public function any($subquery); // Returns Expr\Func instance + + // Example - $qb->expr()->not($qb->expr()->eq('u.id', '?1')) + public function not($restriction); // Returns Expr\Func instance + + // Example - $qb->expr()->in('u.id', array(1, 2, 3)) + // Make sure that you do NOT use something similar to $qb->expr()->in('value', array('stringvalue')) as this will cause Doctrine to throw an Exception. + // Instead, use $qb->expr()->in('value', array('?1')) and bind your parameter to ?1 (see section above) + public function in($x, $y); // Returns Expr\Func instance + + // Example - $qb->expr()->notIn('u.id', '2') + public function notIn($x, $y); // Returns Expr\Func instance + + // Example - $qb->expr()->like('u.firstname', $qb->expr()->literal('Gui%')) + public function like($x, $y); // Returns Expr\Comparison instance + + // Example - $qb->expr()->between('u.id', '1', '10') + public function between($val, $x, $y); // Returns Expr\Func + + + /** Function objects **/ + + // Example - $qb->expr()->trim('u.firstname') + public function trim($x); // Returns Expr\Func + + // Example - $qb->expr()->concat('u.firstname', $qb->expr()->concat($qb->expr()->literal(' '), 'u.lastname')) + public function concat($x, $y); // Returns Expr\Func + + // Example - $qb->expr()->substr('u.firstname', 0, 1) + public function substr($x, $from, $len); // Returns Expr\Func + + // Example - $qb->expr()->lower('u.firstname') + public function lower($x); // Returns Expr\Func + + // Example - $qb->expr()->upper('u.firstname') + public function upper($x); // Returns Expr\Func + + // Example - $qb->expr()->length('u.firstname') + public function length($x); // Returns Expr\Func + + // Example - $qb->expr()->avg('u.age') + public function avg($x); // Returns Expr\Func + + // Example - $qb->expr()->max('u.age') + public function max($x); // Returns Expr\Func + + // Example - $qb->expr()->min('u.age') + public function min($x); // Returns Expr\Func + + // Example - $qb->expr()->abs('u.currentBalance') + public function abs($x); // Returns Expr\Func + + // Example - $qb->expr()->sqrt('u.currentBalance') + public function sqrt($x); // Returns Expr\Func + + // Example - $qb->expr()->count('u.firstname') + public function count($x); // Returns Expr\Func + + // Example - $qb->expr()->countDistinct('u.surname') + public function countDistinct($x); // Returns Expr\Func + } + + +Low Level API +^^^^^^^^^^^^^ + +Now we have describe the low level (thought of as the +hardcore method) of creating queries. It may be useful to work at +this level for optimization purposes, but most of the time it is +preferred to work at a higher level of abstraction. + +All helper methods in ``QueryBuilder`` actually rely on a single +one: ``add()``. This method is responsible of building every piece +of DQL. It takes 3 parameters: ``$dqlPartName``, ``$dqlPart`` and +``$append`` (default=false) + + +- ``$dqlPartName``: Where the ``$dqlPart`` should be placed. + Possible values: select, from, where, groupBy, having, orderBy +- ``$dqlPart``: What should be placed in ``$dqlPartName``. Accepts + a string or any instance of ``Doctrine\ORM\Query\Expr\*`` +- ``$append``: Optional flag (default=false) if the ``$dqlPart`` + should override all previously defined items in ``$dqlPartName`` or + not (no effect on the ``where`` and ``having`` DQL query parts, + which always override all previously defined items) + +- + +.. code-block:: php + + add('select', 'u') + ->add('from', 'User u') + ->add('where', 'u.id = ?1') + ->add('orderBy', 'u.name ASC'); + +Expr\* classes +^^^^^^^^^^^^^^ + +When you call ``add()`` with string, it internally evaluates to an +instance of ``Doctrine\ORM\Query\Expr\Expr\*`` class. Here is the +same query of example 6 written using +``Doctrine\ORM\Query\Expr\Expr\*`` classes: + +.. code-block:: php + + add('select', new Expr\Select(array('u'))) + ->add('from', new Expr\From('User', 'u')) + ->add('where', new Expr\Comparison('u.id', '=', '?1')) + ->add('orderBy', new Expr\OrderBy('u.name', 'ASC')); + +Of course this is the hardest way to build a DQL query in Doctrine. +To simplify some of these efforts, we introduce what we call as +``Expr`` helper class. + diff --git a/vendor/doctrine/orm/docs/en/reference/tools.rst b/vendor/doctrine/orm/docs/en/reference/tools.rst new file mode 100644 index 0000000000..a5f99d141c --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/tools.rst @@ -0,0 +1,509 @@ +Tools +===== + +Doctrine Console +---------------- + +The Doctrine Console is a Command Line Interface tool for simplifying common +administration tasks during the development of a project that uses Doctrine 2. + +Take a look at the :doc:`Installation and Configuration ` +chapter for more information how to setup the console command. + +Display Help Information +~~~~~~~~~~~~~~~~~~~~~~~~ + +Type ``php vendor/bin/doctrine`` on the command line and you should see an +overview of the available commands or use the --help flag to get +information on the available commands. If you want to know more +about the use of generate entities for example, you can call: + +.. code-block:: php + + $> php vendor/bin/doctrine orm:generate-entities --help + + +Configuration +~~~~~~~~~~~~~ + +Whenever the ``doctrine`` command line tool is invoked, it can +access all Commands that were registered by developer. There is no +auto-detection mechanism at work. The Doctrine binary +already registers all the commands that currently ship with +Doctrine DBAL and ORM. If you want to use additional commands you +have to register them yourself. + +All the commands of the Doctrine Console require access to the EntityManager +or DBAL Connection. You have to inject them into the console application +using so called Helper-Sets. This requires either the ``db`` +or the ``em`` helpers to be defined in order to work correctly. + +Whenever you invoke the Doctrine binary the current folder is searched for a +``cli-config.php`` file. This file contains the project specific configuration: + +.. code-block:: php + + new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($conn) + )); + $cli->setHelperSet($helperSet); + +When dealing with the ORM package, the EntityManagerHelper is +required: + +.. code-block:: php + + new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) + )); + $cli->setHelperSet($helperSet); + +The HelperSet instance has to be generated in a separate file (i.e. +``cli-config.php``) that contains typical Doctrine bootstrap code +and predefines the needed HelperSet attributes mentioned above. A +sample ``cli-config.php`` file looks as follows: + +.. code-block:: php + + new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), + 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) + )); + +It is important to define a correct HelperSet that Doctrine binary +script will ultimately use. The Doctrine Binary will automatically +find the first instance of HelperSet in the global variable +namespace and use this. + +.. note:: + + You have to adjust this snippet for your specific application or framework + and use their facilities to access the Doctrine EntityManager and + Connection Resources. + +Command Overview +~~~~~~~~~~~~~~~~ + +The following Commands are currently available: + + +- ``help`` Displays help for a command (?) +- ``list`` Lists commands +- ``dbal:import`` Import SQL file(s) directly to Database. +- ``dbal:run-sql`` Executes arbitrary SQL directly from the + command line. +- ``orm:clear-cache:metadata`` Clear all metadata cache of the + various cache drivers. +- ``orm:clear-cache:query`` Clear all query cache of the various + cache drivers. +- ``orm:clear-cache:result`` Clear result cache of the various + cache drivers. +- ``orm:convert-d1-schema`` Converts Doctrine 1.X schema into a + Doctrine 2.X schema. +- ``orm:convert-mapping`` Convert mapping information between + supported formats. +- ``orm:ensure-production-settings`` Verify that Doctrine is + properly configured for a production environment. +- ``orm:generate-entities`` Generate entity classes and method + stubs from your mapping information. +- ``orm:generate-proxies`` Generates proxy classes for entity + classes. +- ``orm:generate-repositories`` Generate repository classes from + your mapping information. +- ``orm:run-dql`` Executes arbitrary DQL directly from the command + line. +- ``orm:schema-tool:create`` Processes the schema and either + create it directly on EntityManager Storage Connection or generate + the SQL output. +- ``orm:schema-tool:drop`` Processes the schema and either drop + the database schema of EntityManager Storage Connection or generate + the SQL output. +- ``orm:schema-tool:update`` Processes the schema and either + update the database schema of EntityManager Storage Connection or + generate the SQL output. + +For these commands are also available aliases: + + +- ``orm:convert:d1-schema`` is alias for ``orm:convert-d1-schema``. +- ``orm:convert:mapping`` is alias for ``orm:convert-mapping``. +- ``orm:generate:entities`` is alias for ``orm:generate-entities``. +- ``orm:generate:proxies`` is alias for ``orm:generate-proxies``. +- ``orm:generate:repositories`` is alias for ``orm:generate-repositories``. + +.. note:: + + Console also supports auto completion, for example, instead of + ``orm:clear-cache:query`` you can use just ``o:c:q``. + +Database Schema Generation +-------------------------- + +.. note:: + + SchemaTool can do harm to your database. It will drop or alter + tables, indexes, sequences and such. Please use this tool with + caution in development and not on a production server. It is meant + for helping you develop your Database Schema, but NOT with + migrating schema from A to B in production. A safe approach would + be generating the SQL on development server and saving it into SQL + Migration files that are executed manually on the production + server. + + SchemaTool assumes your Doctrine Project uses the given database on + its own. Update and Drop commands will mess with other tables if + they are not related to the current project that is using Doctrine. + Please be careful! + + +To generate your database schema from your Doctrine mapping files +you can use the ``SchemaTool`` class or the ``schema-tool`` Console +Command. + +When using the SchemaTool class directly, create your schema using +the ``createSchema()`` method. First create an instance of the +``SchemaTool`` and pass it an instance of the ``EntityManager`` +that you want to use to create the schema. This method receives an +array of ``ClassMetadataInfo`` instances. + +.. code-block:: php + + getClassMetadata('Entities\User'), + $em->getClassMetadata('Entities\Profile') + ); + $tool->createSchema($classes); + +To drop the schema you can use the ``dropSchema()`` method. + +.. code-block:: php + + dropSchema($classes); + +This drops all the tables that are currently used by your metadata +model. When you are changing your metadata a lot during development +you might want to drop the complete database instead of only the +tables of the current model to clean up with orphaned tables. + +.. code-block:: php + + dropSchema($classes, \Doctrine\ORM\Tools\SchemaTool::DROP_DATABASE); + +You can also use database introspection to update your schema +easily with the ``updateSchema()`` method. It will compare your +existing database schema to the passed array of +``ClassMetdataInfo`` instances. + +.. code-block:: php + + updateSchema($classes); + +If you want to use this functionality from the command line you can +use the ``schema-tool`` command. + +To create the schema use the ``create`` command: + +.. code-block:: php + + $ php doctrine orm:schema-tool:create + +To drop the schema use the ``drop`` command: + +.. code-block:: php + + $ php doctrine orm:schema-tool:drop + +If you want to drop and then recreate the schema then use both +options: + +.. code-block:: php + + $ php doctrine orm:schema-tool:drop + $ php doctrine orm:schema-tool:create + +As you would think, if you want to update your schema use the +``update`` command: + +.. code-block:: php + + $ php doctrine orm:schema-tool:update + +All of the above commands also accept a ``--dump-sql`` option that +will output the SQL for the ran operation. + +.. code-block:: php + + $ php doctrine orm:schema-tool:create --dump-sql + +Before using the orm:schema-tool commands, remember to configure +your cli-config.php properly. + +.. note:: + + When using the Annotation Mapping Driver you have to either setup + your autoloader in the cli-config.php correctly to find all the + entities, or you can use the second argument of the + ``EntityManagerHelper`` to specify all the paths of your entities + (or mapping files), i.e. + ``new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em, $mappingPaths);`` + +Entity Generation +----------------- + +Generate entity classes and method stubs from your mapping information. + +.. code-block:: php + + $ php doctrine orm:generate-entities + $ php doctrine orm:generate-entities --update-entities + $ php doctrine orm:generate-entities --regenerate-entities + +This command is not suited for constant usage. It is a little helper and does +not support all the mapping edge cases very well. You still have to put work +in your entities after using this command. + +It is possible to use the EntityGenerator on code that you have already written. It will +not be lost. The EntityGenerator will only append new code to your +file and will not delete the old code. However this approach may still be prone +to error and we suggest you use code repositories such as GIT or SVN to make +backups of your code. + +It makes sense to generate the entity code if you are using entities as Data +Access Objects only and don't put much additional logic on them. If you are +however putting much more logic on the entities you should refrain from using +the entity-generator and code your entities manually. + +.. note:: + + Even if you specified Inheritance options in your + XML or YAML Mapping files the generator cannot generate the base and + child classes for you correctly, because it doesn't know which + class is supposed to extend which. You have to adjust the entity + code manually for inheritance to work! + + +Convert Mapping Information +--------------------------- + +Convert mapping information between supported formats. + +This is an **execute one-time** command. It should not be necessary for +you to call this method multiple times, especially when using the ``--from-database`` +flag. + +Converting an existing database schema into mapping files only solves about 70-80% +of the necessary mapping information. Additionally the detection from an existing +database cannot detect inverse associations, inheritance types, +entities with foreign keys as primary keys and many of the +semantical operations on associations such as cascade. + +.. note:: + + There is no need to convert YAML or XML mapping files to annotations + every time you make changes. All mapping drivers are first class citizens + in Doctrine 2 and can be used as runtime mapping for the ORM. See the + docs on XML and YAML Mapping for an example how to register this metadata + drivers as primary mapping source. + +To convert some mapping information between the various supported +formats you can use the ``ClassMetadataExporter`` to get exporter +instances for the different formats: + +.. code-block:: php + + getExporter('yml', '/path/to/export/yml'); + +Now you can export some ``ClassMetadata`` instances: + +.. code-block:: php + + getClassMetadata('Entities\User'), + $em->getClassMetadata('Entities\Profile') + ); + $exporter->setMetadata($classes); + $exporter->export(); + +This functionality is also available from the command line to +convert your loaded mapping information to another format. The +``orm:convert-mapping`` command accepts two arguments, the type to +convert to and the path to generate it: + +.. code-block:: php + + $ php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml + +Reverse Engineering +------------------- + +You can use the ``DatabaseDriver`` to reverse engineer a database +to an array of ``ClassMetadataInfo`` instances and generate YAML, +XML, etc. from them. + +.. note:: + + Reverse Engineering is a **one-time** process that can get you started with a project. + Converting an existing database schema into mapping files only detects about 70-80% + of the necessary mapping information. Additionally the detection from an existing + database cannot detect inverse associations, inheritance types, + entities with foreign keys as primary keys and many of the + semantical operations on associations such as cascade. + +First you need to retrieve the metadata instances with the +``DatabaseDriver``: + +.. code-block:: php + + getConfiguration()->setMetadataDriverImpl( + new \Doctrine\ORM\Mapping\Driver\DatabaseDriver( + $em->getConnection()->getSchemaManager() + ) + ); + + $cmf = new DisconnectedClassMetadataFactory(); + $cmf->setEntityManager($em); + $metadata = $cmf->getAllMetadata(); + +Now you can get an exporter instance and export the loaded metadata +to yml: + +.. code-block:: php + + getExporter('yml', '/path/to/export/yml'); + $exporter->setMetadata($metadata); + $exporter->export(); + +You can also reverse engineer a database using the +``orm:convert-mapping`` command: + +.. code-block:: php + + $ php doctrine orm:convert-mapping --from-database yml /path/to/mapping-path-converted-to-yml + +.. note:: + + Reverse Engineering is not always working perfectly + depending on special cases. It will only detect Many-To-One + relations (even if they are One-To-One) and will try to create + entities from Many-To-Many tables. It also has problems with naming + of foreign keys that have multiple column names. Any Reverse + Engineered Database-Schema needs considerable manual work to become + a useful domain model. + + +Runtime vs Development Mapping Validation +----------------------------------------- + +For performance reasons Doctrine 2 has to skip some of the +necessary validation of metadata mappings. You have to execute +this validation in your development workflow to verify the +associations are correctly defined. + +You can either use the Doctrine Command Line Tool: + +.. code-block:: php + + doctrine orm:validate-schema + +Or you can trigger the validation manually: + +.. code-block:: php + + validateMapping(); + + if (count($errors) > 0) { + // Lots of errors! + echo implode("\n\n", $errors); + } + +If the mapping is invalid the errors array contains a positive +number of elements with error messages. + +.. warning:: + + One mapping option that is not validated is the use of the referenced column name. + It has to point to the equivalent primary key otherwise Doctrine will not work. + +.. note:: + + One common error is to use a backlash in front of the + fully-qualified class-name. Whenever a FQCN is represented inside a + string (such as in your mapping definitions) you have to drop the + prefix backslash. PHP does this with ``get_class()`` or Reflection + methods for backwards compatibility reasons. + + +Adding own commands +------------------- + +You can also add your own commands on-top of the Doctrine supported +tools if you are using a manually built console script. + +To include a new command on Doctrine Console, you need to do modify the +``doctrine.php`` file a little: + +.. code-block:: php + + setCatchExceptions(true); + $cli->setHelperSet($helperSet); + + // Register All Doctrine Commands + ConsoleRunner::addCommands($cli); + + // Register your own command + $cli->addCommand(new \MyProject\Tools\Console\Commands\MyCustomCommand); + + // Runs console application + $cli->run(); + +Additionally, include multiple commands (and overriding previously +defined ones) is possible through the command: + +.. code-block:: php + + addCommands(array( + new \MyProject\Tools\Console\Commands\MyCustomCommand(), + new \MyProject\Tools\Console\Commands\SomethingCommand(), + new \MyProject\Tools\Console\Commands\AnotherCommand(), + new \MyProject\Tools\Console\Commands\OneMoreCommand(), + )); diff --git a/vendor/doctrine/orm/docs/en/reference/transactions-and-concurrency.rst b/vendor/doctrine/orm/docs/en/reference/transactions-and-concurrency.rst new file mode 100644 index 0000000000..1b06156e90 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/transactions-and-concurrency.rst @@ -0,0 +1,353 @@ +Transactions and Concurrency +============================ + +Transaction Demarcation +----------------------- + +Transaction demarcation is the task of defining your transaction +boundaries. Proper transaction demarcation is very important +because if not done properly it can negatively affect the +performance of your application. Many databases and database +abstraction layers like PDO by default operate in auto-commit mode, +which means that every single SQL statement is wrapped in a small +transaction. Without any explicit transaction demarcation from your +side, this quickly results in poor performance because transactions +are not cheap. + +For the most part, Doctrine 2 already takes care of proper +transaction demarcation for you: All the write operations +(INSERT/UPDATE/DELETE) are queued until ``EntityManager#flush()`` +is invoked which wraps all of these changes in a single +transaction. + +However, Doctrine 2 also allows (and encourages) you to take over +and control transaction demarcation yourself. + +These are two ways to deal with transactions when using the +Doctrine ORM and are now described in more detail. + +Approach 1: Implicitly +~~~~~~~~~~~~~~~~~~~~~~ + +The first approach is to use the implicit transaction handling +provided by the Doctrine ORM EntityManager. Given the following +code snippet, without any explicit transaction demarcation: + +.. code-block:: php + + setName('George'); + $em->persist($user); + $em->flush(); + +Since we do not do any custom transaction demarcation in the above +code, ``EntityManager#flush()`` will begin and commit/rollback a +transaction. This behavior is made possible by the aggregation of +the DML operations by the Doctrine ORM and is sufficient if all the +data manipulation that is part of a unit of work happens through +the domain model and thus the ORM. + +Approach 2: Explicitly +~~~~~~~~~~~~~~~~~~~~~~ + +The explicit alternative is to use the ``Doctrine\DBAL\Connection`` +API directly to control the transaction boundaries. The code then +looks like this: + +.. code-block:: php + + getConnection()->beginTransaction(); // suspend auto-commit + try { + //... do some work + $user = new User; + $user->setName('George'); + $em->persist($user); + $em->flush(); + $em->getConnection()->commit(); + } catch (Exception $e) { + $em->getConnection()->rollback(); + $em->close(); + throw $e; + } + +Explicit transaction demarcation is required when you want to +include custom DBAL operations in a unit of work or when you want +to make use of some methods of the ``EntityManager`` API that +require an active transaction. Such methods will throw a +``TransactionRequiredException`` to inform you of that +requirement. + +A more convenient alternative for explicit transaction demarcation +is the use of provided control abstractions in the form of +``Connection#transactional($func)`` and +``EntityManager#transactional($func)``. When used, these control +abstractions ensure that you never forget to rollback the +transaction or close the ``EntityManager``, apart from the obvious +code reduction. An example that is functionally equivalent to the +previously shown code looks as follows: + +.. code-block:: php + + transactional(function($em) { + //... do some work + $user = new User; + $user->setName('George'); + $em->persist($user); + }); + +The difference between ``Connection#transactional($func)`` and +``EntityManager#transactional($func)`` is that the latter +abstraction flushes the ``EntityManager`` prior to transaction +commit and also closes the ``EntityManager`` properly when an +exception occurs (in addition to rolling back the transaction). + +Exception Handling +~~~~~~~~~~~~~~~~~~ + +When using implicit transaction demarcation and an exception occurs +during ``EntityManager#flush()``, the transaction is automatically +rolled back and the ``EntityManager`` closed. + +When using explicit transaction demarcation and an exception +occurs, the transaction should be rolled back immediately and the +``EntityManager`` closed by invoking ``EntityManager#close()`` and +subsequently discarded, as demonstrated in the example above. This +can be handled elegantly by the control abstractions shown earlier. +Note that when catching ``Exception`` you should generally re-throw +the exception. If you intend to recover from some exceptions, catch +them explicitly in earlier catch blocks (but do not forget to +rollback the transaction and close the ``EntityManager`` there as +well). All other best practices of exception handling apply +similarly (i.e. either log or re-throw, not both, etc.). + +As a result of this procedure, all previously managed or removed +instances of the ``EntityManager`` become detached. The state of +the detached objects will be the state at the point at which the +transaction was rolled back. The state of the objects is in no way +rolled back and thus the objects are now out of synch with the +database. The application can continue to use the detached objects, +knowing that their state is potentially no longer accurate. + +If you intend to start another unit of work after an exception has +occurred you should do that with a new ``EntityManager``. + +Locking Support +--------------- + +Doctrine 2 offers support for Pessimistic- and Optimistic-locking +strategies natively. This allows to take very fine-grained control +over what kind of locking is required for your Entities in your +application. + +Optimistic Locking +~~~~~~~~~~~~~~~~~~ + +Database transactions are fine for concurrency control during a +single request. However, a database transaction should not span +across requests, the so-called "user think time". Therefore a +long-running "business transaction" that spans multiple requests +needs to involve several database transactions. Thus, database +transactions alone can no longer control concurrency during such a +long-running business transaction. Concurrency control becomes the +partial responsibility of the application itself. + +Doctrine has integrated support for automatic optimistic locking +via a version field. In this approach any entity that should be +protected against concurrent modifications during long-running +business transactions gets a version field that is either a simple +number (mapping type: integer) or a timestamp (mapping type: +datetime). When changes to such an entity are persisted at the end +of a long-running conversation the version of the entity is +compared to the version in the database and if they don't match, an +``OptimisticLockException`` is thrown, indicating that the entity +has been modified by someone else already. + +You designate a version field in an entity as follows. In this +example we'll use an integer. + +.. code-block:: php + + find('User', $theEntityId, LockMode::OPTIMISTIC, $expectedVersion); + + // do the work + + $em->flush(); + } catch(OptimisticLockException $e) { + echo "Sorry, but someone else has already changed this entity. Please apply the changes again!"; + } + +Or you can use ``EntityManager#lock()`` to find out: + +.. code-block:: php + + find('User', $theEntityId); + + try { + // assert version + $em->lock($entity, LockMode::OPTIMISTIC, $expectedVersion); + + } catch(OptimisticLockException $e) { + echo "Sorry, but someone else has already changed this entity. Please apply the changes again!"; + } + +Important Implementation Notes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can easily get the optimistic locking workflow wrong if you +compare the wrong versions. Say you have Alice and Bob editing a +hypothetical blog post: + +- Alice reads the headline of the blog post being "Foo", at + optimistic lock version 1 (GET Request) +- Bob reads the headline of the blog post being "Foo", at + optimistic lock version 1 (GET Request) +- Bob updates the headline to "Bar", upgrading the optimistic lock + version to 2 (POST Request of a Form) +- Alice updates the headline to "Baz", ... (POST Request of a + Form) + +Now at the last stage of this scenario the blog post has to be read +again from the database before Alice's headline can be applied. At +this point you will want to check if the blog post is still at +version 1 (which it is not in this scenario). + +Using optimistic locking correctly, you *have* to add the version +as an additional hidden field (or into the SESSION for more +safety). Otherwise you cannot verify the version is still the one +being originally read from the database when Alice performed her +GET request for the blog post. If this happens you might see lost +updates you wanted to prevent with Optimistic Locking. + +See the example code, The form (GET Request): + +.. code-block:: php + + find('BlogPost', 123456); + + echo ''; + echo ''; + +And the change headline action (POST Request): + +.. code-block:: php + + find('BlogPost', $postId, \Doctrine\DBAL\LockMode::OPTIMISTIC, $postVersion); + +Pessimistic Locking +~~~~~~~~~~~~~~~~~~~ + +Doctrine 2 supports Pessimistic Locking at the database level. No +attempt is being made to implement pessimistic locking inside +Doctrine, rather vendor-specific and ANSI-SQL commands are used to +acquire row-level locks. Every Entity can be part of a pessimistic +lock, there is no special metadata required to use this feature. + +However for Pessimistic Locking to work you have to disable the +Auto-Commit Mode of your Database and start a transaction around +your pessimistic lock use-case using the "Approach 2: Explicit +Transaction Demarcation" described above. Doctrine 2 will throw an +Exception if you attempt to acquire an pessimistic lock and no +transaction is running. + +Doctrine 2 currently supports two pessimistic lock modes: + + +- Pessimistic Write + (``Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE``), locks the + underlying database rows for concurrent Read and Write Operations. +- Pessimistic Read (``Doctrine\DBAL\LockMode::PESSIMISTIC_READ``), + locks other concurrent requests that attempt to update or lock rows + in write mode. + +You can use pessimistic locks in three different scenarios: + + +1. Using + ``EntityManager#find($className, $id, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE)`` + or + ``EntityManager#find($className, $id, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ)`` +2. Using + ``EntityManager#lock($entity, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE)`` + or + ``EntityManager#lock($entity, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ)`` +3. Using + ``Query#setLockMode(\Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE)`` + or + ``Query#setLockMode(\Doctrine\DBAL\LockMode::PESSIMISTIC_READ)`` + + diff --git a/vendor/doctrine/orm/docs/en/reference/unitofwork-associations.rst b/vendor/doctrine/orm/docs/en/reference/unitofwork-associations.rst new file mode 100644 index 0000000000..da3cc9dc88 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/unitofwork-associations.rst @@ -0,0 +1,60 @@ +Association Updates: Owning Side and Inverse Side +================================================= + +When mapping bidirectional associations it is important to +understand the concept of the owning and inverse sides. The +following general rules apply: + +- Relationships may be bidirectional or unidirectional. +- A bidirectional relationship has both an owning side and an inverse side +- A unidirectional relationship only has an owning side. +- Doctrine will **only** check the owning side of an association for changes. + +Bidirectional Associations +-------------------------- + +The following rules apply to **bidirectional** associations: + +- The inverse side has to use the ``mappedBy`` attribute of the OneToOne, + OneToMany, or ManyToMany mapping declaration. The mappedBy + attribute contains the name of the association-field on the owning side. +- The owning side has to use the ``inversedBy`` attribute of the + OneToOne, ManyToOne, or ManyToMany mapping declaration. + The inversedBy attribute contains the name of the association-field + on the inverse-side. +- ManyToOne is always the owning side of a bidirectional association. +- OneToMany is always the inverse side of a bidirectional association. +- The owning side of a OneToOne association is the entity with the table + containing the foreign key. +- You can pick the owning side of a many-to-many association yourself. + +Important concepts +------------------ + +**Doctrine will only check the owning side of an association for changes.** + +To fully understand this, remember how bidirectional associations +are maintained in the object world. There are 2 references on each +side of the association and these 2 references both represent the +same association but can change independently of one another. Of +course, in a correct application the semantics of the bidirectional +association are properly maintained by the application developer +(that's his responsibility). Doctrine needs to know which of these +two in-memory references is the one that should be persisted and +which not. This is what the owning/inverse concept is mainly used +for. + +**Changes made only to the inverse side of an association are ignored. Make sure to update both sides of a bidirectional association (or at least the owning side, from Doctrine's point of view)** + +The owning side of a bidirectional association is the side Doctrine +"looks at" when determining the state of the association, and +consequently whether there is anything to do to update the +association in the database. + +.. note:: + + "Owning side" and "inverse side" are technical concepts of + the ORM technology, not concepts of your domain model. What you + consider as the owning side in your domain model can be different + from what the owning side is for Doctrine. These are unrelated. + diff --git a/vendor/doctrine/orm/docs/en/reference/unitofwork.rst b/vendor/doctrine/orm/docs/en/reference/unitofwork.rst new file mode 100644 index 0000000000..f01c3f91db --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/unitofwork.rst @@ -0,0 +1,201 @@ +Doctrine Internals explained +============================ + +Object relational mapping is a complex topic and sufficiently understanding how Doctrine works internally helps you use its full power. + +How Doctrine keeps track of Objects +----------------------------------- + +Doctrine uses the Identity Map pattern to track objects. Whenever you fetch an +object from the database, Doctrine will keep a reference to this object inside +its UnitOfWork. The array holding all the entity references is two-levels deep +and has the keys "root entity name" and "id". Since Doctrine allows composite +keys the id is a sorted, serialized version of all the key columns. + +This allows Doctrine room for optimizations. If you call the EntityManager and +ask for an entity with a specific ID twice, it will return the same instance: + +.. code-block:: php + + public function testIdentityMap() + { + $objectA = $this->entityManager->find('EntityName', 1); + $objectB = $this->entityManager->find('EntityName', 1); + + $this->assertSame($objectA, $objectB) + } + +Only one SELECT query will be fired against the database here. In the second +``EntityManager#find()`` call Doctrine will check the identity map first and +doesn't need to make that database roundtrip. + +Even if you get a proxy object first then fetch the object by the same id you +will still end up with the same reference: + +.. code-block:: php + + public function testIdentityMapReference() + { + $objectA = $this->entityManager->getReference('EntityName', 1); + // check for proxyinterface + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $objectA); + + $objectB = $this->entityManager->find('EntityName', 1); + + $this->assertSame($objectA, $objectB) + } + +The identity map being indexed by primary keys only allows shortcuts when you +ask for objects by primary key. Assume you have the following ``persons`` +table: + +:: + + id | name + ------------- + 1 | Benjamin + 2 | Bud + +Take the following example where two +consecutive calls are made against a repository to fetch an entity by a set of +criteria: + +.. code-block:: php + + public function testIdentityMapRepositoryFindBy() + { + $repository = $this->entityManager->getRepository('Person'); + $objectA = $repository->findOneBy(array('name' => 'Benjamin')); + $objectB = $repository->findOneBy(array('name' => 'Benjamin')); + + $this->assertSame($objectA, $objectB); + } + +This query will still return the same references and `$objectA` and `$objectB` +are indeed referencing the same object. However when checking your SQL logs you +will realize that two queries have been executed against the database. Doctrine +only knows objects by id, so a query for different criteria has to go to the +database, even if it was executed just before. + +But instead of creating a second Person object Doctrine first gets the primary +key from the row and check if it already has an object inside the UnitOfWork +with that primary key. In our example it finds an object and decides to return +this instead of creating a new one. + +The identity map has a second use-case. When you call ``EntityManager#flush`` +Doctrine will ask the identity map for all objects that are currently managed. +This means you don't have to call ``EntityManager#persist`` over and over again +to pass known objects to the EntityManager. This is a NO-OP for known entities, +but leads to much code written that is confusing to other developers. + +The following code WILL update your database with the changes made to the +``Person`` object, even if you did not call ``EntityManager#persist``: + +.. code-block:: php + + find("Person", 1); + $user->setName("Guilherme"); + $entityManager->flush(); + +How Doctrine Detects Changes +---------------------------- + +Doctrine is a data-mapper that tries to achieve persistence-ignorance (PI). +This means you map php objects into a relational database that don't +necessarily know about the database at all. A natural question would now be, +"how does Doctrine even detect objects have changed?". + +For this Doctrine keeps a second map inside the UnitOfWork. Whenever you fetch +an object from the database Doctrine will keep a copy of all the properties and +associations inside the UnitOfWork. Because variables in the PHP language are +subject to "copy-on-write" the memory usage of a PHP request that only reads +objects from the database is the same as if Doctrine did not keep this variable +copy. Only if you start changing variables PHP will create new variables internally +that consume new memory. + +Now whenever you call ``EntityManager#flush`` Doctrine will iterate over the +Identity Map and for each object compares the original property and association +values with the values that are currently set on the object. If changes are +detected then the object is queued for a SQL UPDATE operation. Only the fields +that actually changed are updated. + +This process has an obvious performance impact. The larger the size of the +UnitOfWork is, the longer this computation takes. There are several ways to +optimize the performance of the Flush Operation: + +- Mark entities as read only. These entities can only be inserted or removed, + but are never updated. They are omitted in the changeset calculation. +- Temporarily mark entities as read only. If you have a very large UnitOfWork + but know that a large set of entities has not changed, just mark them as read + only with ``$entityManager->getUnitOfWork()->markReadOnly($entity)``. +- Flush only a single entity with ``$entityManager->flush($entity)``. +- Use :doc:`Change Tracking Policies ` to use more + explicit strategies of notifying the UnitOfWork what objects/properties + changed. + + +Query Internals +--------------- + +The different ORM Layers +------------------------ + +Doctrine ships with a set of layers with different responsibilities. This +section gives a short explanation of each layer. + +Hydration +~~~~~~~~~ + +Responsible for creating a final result from a raw database statement and a +result-set mapping object. The developer can choose which kind of result he +wishes to be hydrated. Default result-types include: + +- SQL to Entities +- SQL to structured Arrays +- SQL to simple scalar result arrays +- SQL to a single result variable + +Hydration to entities and arrays is one of most complex parts of Doctrine +algorithm-wise. It can built results with for example: + +- Single table selects +- Joins with n:1 or 1:n cardinality, grouping belonging to the same parent. +- Mixed results of objects and scalar values +- Hydration of results by a given scalar value as key. + +Persisters +~~~~~~~~~~ + +tbr + +UnitOfWork +~~~~~~~~~~ + +tbr + +ResultSetMapping +~~~~~~~~~~~~~~~~ + +tbr + +DQL Parser +~~~~~~~~~~ + +tbr + +SQLWalker +~~~~~~~~~ + +tbr + +EntityManager +~~~~~~~~~~~~~ + +tbr + +ClassMetadataFactory +~~~~~~~~~~~~~~~~~~~~ + +tbr + diff --git a/vendor/doctrine/orm/docs/en/reference/working-with-associations.rst b/vendor/doctrine/orm/docs/en/reference/working-with-associations.rst new file mode 100644 index 0000000000..0efba84f25 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/working-with-associations.rst @@ -0,0 +1,712 @@ +Working with Associations +========================= + +Associations between entities are represented just like in regular +object-oriented PHP, with references to other objects or +collections of objects. When it comes to persistence, it is +important to understand three main things: + + +- The :doc:`concept of owning and inverse sides ` + in bidirectional associations. +- If an entity is removed from a collection, the association is + removed, not the entity itself. A collection of entities always + only represents the association to the containing entities, not the + entity itself. +- Collection-valued :ref:`persistent fields ` have to be instances of the + ``Doctrine\Common\Collections\Collection`` interface. + +Changes to associations in your code are not synchronized to the +database directly, but upon calling ``EntityManager#flush()``. + +To describe all the concepts of working with associations we +introduce a specific set of example entities that show all the +different flavors of association management in Doctrine. + +Association Example Entities +---------------------------- + +We will use a simple comment system with Users and Comments as +entities to show examples of association management. See the PHP +docblocks of each association in the following example for +information about its type and if it's the owning or inverse side. + +.. code-block:: php + + commentsRead; + } + + public function setFirstComment(Comment $c) { + $this->firstComment = $c; + } + } + +The interaction code would then look like in the following snippet +(``$em`` here is an instance of the EntityManager): + +.. code-block:: php + + find('User', $userId); + + // unidirectional many to many + $comment = $em->find('Comment', $readCommentId); + $user->getReadComments()->add($comment); + + $em->flush(); + + // unidirectional many to one + $myFirstComment = new Comment(); + $user->setFirstComment($myFirstComment); + + $em->persist($myFirstComment); + $em->flush(); + +In the case of bi-directional associations you have to update the +fields on both sides: + +.. code-block:: php + + commentsAuthored; + } + + public function getFavoriteComments() { + return $this->favorites; + } + } + + class Comment + { + // ... + + public function getUserFavorites() { + return $this->userFavorites; + } + + public function setAuthor(User $author = null) { + $this->author = $author; + } + } + + // Many-to-Many + $user->getFavorites()->add($favoriteComment); + $favoriteComment->getUserFavorites()->add($user); + + $em->flush(); + + // Many-To-One / One-To-Many Bidirectional + $newComment = new Comment(); + $user->getAuthoredComments()->add($newComment); + $newComment->setAuthor($user); + + $em->persist($newComment); + $em->flush(); + +Notice how always both sides of the bidirectional association are +updated. The previous unidirectional associations were simpler to +handle. + +Removing Associations +--------------------- + +Removing an association between two entities is similarly +straight-forward. There are two strategies to do so, by key and by +element. Here are some examples: + +.. code-block:: php + + getComments()->removeElement($comment); + $comment->setAuthor(null); + + $user->getFavorites()->removeElement($comment); + $comment->getUserFavorites()->removeElement($user); + + // Remove by Key + $user->getComments()->remove($ithComment); + $comment->setAuthor(null); + +You need to call ``$em->flush()`` to make persist these changes in +the database permanently. + +Notice how both sides of the bidirectional association are always +updated. Unidirectional associations are consequently simpler to +handle. Also note that if you use type-hinting in your methods, i.e. +``setAddress(Address $address)``, PHP will only allow null +values if ``null`` is set as default value. Otherwise +setAddress(null) will fail for removing the association. If you +insist on type-hinting a typical way to deal with this is to +provide a special method, like ``removeAddress()``. This can also +provide better encapsulation as it hides the internal meaning of +not having an address. + +When working with collections, keep in mind that a Collection is +essentially an ordered map (just like a PHP array). That is why the +``remove`` operation accepts an index/key. ``removeElement`` is a +separate method that has O(n) complexity using ``array_search``, +where n is the size of the map. + +.. note:: + + Since Doctrine always only looks at the owning side of a + bidirectional association for updates, it is not necessary for + write operations that an inverse collection of a bidirectional + one-to-many or many-to-many association is updated. This knowledge + can often be used to improve performance by avoiding the loading of + the inverse collection. + + +You can also clear the contents of a whole collection using the +``Collections::clear()`` method. You should be aware that using +this method can lead to a straight and optimized database delete or +update call during the flush operation that is not aware of +entities that have been re-added to the collection. + +Say you clear a collection of tags by calling +``$post->getTags()->clear();`` and then call +``$post->getTags()->add($tag)``. This will not recognize the tag having +already been added previously and will consequently issue two separate database +calls. + +Association Management Methods +------------------------------ + +It is generally a good idea to encapsulate proper association +management inside the entity classes. This makes it easier to use +the class correctly and can encapsulate details about how the +association is maintained. + +The following code shows updates to the previous User and Comment +example that encapsulate much of the association management code: + +.. code-block:: php + + commentsRead[] = $comment; + } + + public function addComment(Comment $comment) { + if (count($this->commentsAuthored) == 0) { + $this->setFirstComment($comment); + } + $this->comments[] = $comment; + $comment->setAuthor($this); + } + + private function setFirstComment(Comment $c) { + $this->firstComment = $c; + } + + public function addFavorite(Comment $comment) { + $this->favorites->add($comment); + $comment->addUserFavorite($this); + } + + public function removeFavorite(Comment $comment) { + $this->favorites->removeElement($comment); + $comment->removeUserFavorite($this); + } + } + + class Comment + { + // .. + + public function addUserFavorite(User $user) { + $this->userFavorites[] = $user; + } + + public function removeUserFavorite(User $user) { + $this->userFavorites->removeElement($user); + } + } + +You will notice that ``addUserFavorite`` and ``removeUserFavorite`` +do not call ``addFavorite`` and ``removeFavorite``, thus the +bidirectional association is strictly-speaking still incomplete. +However if you would naively add the ``addFavorite`` in +``addUserFavorite``, you end up with an infinite loop, so more work +is needed. As you can see, proper bidirectional association +management in plain OOP is a non-trivial task and encapsulating all +the details inside the classes can be challenging. + +.. note:: + + If you want to make sure that your collections are perfectly + encapsulated you should not return them from a + ``getCollectionName()`` method directly, but call + ``$collection->toArray()``. This way a client programmer for the + entity cannot circumvent the logic you implement on your entity for + association management. For example: + + +.. code-block:: php + + commentsRead->toArray(); + } + } + +This will however always initialize the collection, with all the +performance penalties given the size. In some scenarios of large +collections it might even be a good idea to completely hide the +read access behind methods on the EntityRepository. + +There is no single, best way for association management. It greatly +depends on the requirements of your concrete domain model as well +as your preferences. + +Synchronizing Bidirectional Collections +--------------------------------------- + +In the case of Many-To-Many associations you as the developer have the +responsibility of keeping the collections on the owning and inverse side +in sync when you apply changes to them. Doctrine can only +guarantee a consistent state for the hydration, not for your client +code. + +Using the User-Comment entities from above, a very simple example +can show the possible caveats you can encounter: + +.. code-block:: php + + getFavorites()->add($favoriteComment); + // not calling $favoriteComment->getUserFavorites()->add($user); + + $user->getFavorites()->contains($favoriteComment); // TRUE + $favoriteComment->getUserFavorites()->contains($user); // FALSE + +There are two approaches to handle this problem in your code: + + +1. Ignore updating the inverse side of bidirectional collections, + BUT never read from them in requests that changed their state. In + the next Request Doctrine hydrates the consistent collection state + again. +2. Always keep the bidirectional collections in sync through + association management methods. Reads of the Collections directly + after changes are consistent then. + +Transitive persistence / Cascade Operations +------------------------------------------- + +Persisting, removing, detaching and merging individual entities can +become pretty cumbersome, especially when a highly interweaved object graph +is involved. Therefore Doctrine 2 provides a +mechanism for transitive persistence through cascading of these +operations. Each association to another entity or a collection of +entities can be configured to automatically cascade certain +operations. By default, no operations are cascaded. + +The following cascade options exist: + + +- persist : Cascades persist operations to the associated + entities. +- remove : Cascades remove operations to the associated entities. +- merge : Cascades merge operations to the associated entities. +- detach : Cascades detach operations to the associated entities. +- all : Cascades persist, remove, merge and detach operations to + associated entities. + +.. note:: + + Cascade operations are performed in memory. That means collections and related entities + are fetched into memory, even if they are still marked as lazy when + the cascade operation is about to be performed. However this approach allows + entity lifecycle events to be performed for each of these operations. + + However, pulling objects graph into memory on cascade can cause considerable performance + overhead, especially when cascading collections are large. Makes sure + to weigh the benefits and downsides of each cascade operation that you define. + + To rely on the database level cascade operations for the delete operation instead, you can + configure each join column with the **onDelete** option. See the respective + mapping driver chapters for more information. + +The following example is an extension to the User-Comment example +of this chapter. Suppose in our application a user is created +whenever he writes his first comment. In this case we would use the +following code: + +.. code-block:: php + + addComment($myFirstComment); + + $em->persist($user); + $em->persist($myFirstComment); + $em->flush(); + +Even if you *persist* a new User that contains our new Comment this +code would fail if you removed the call to +``EntityManager#persist($myFirstComment)``. Doctrine 2 does not +cascade the persist operation to all nested entities that are new +as well. + +More complicated is the deletion of all of a user's comments when he is +removed from the system: + +.. code-block:: php + + $user = $em->find('User', $deleteUserId); + + foreach ($user->getAuthoredComments() AS $comment) { + $em->remove($comment); + } + $em->remove($user); + $em->flush(); + +Without the loop over all the authored comments Doctrine would use +an UPDATE statement only to set the foreign key to NULL and only +the User would be deleted from the database during the +flush()-Operation. + +To have Doctrine handle both cases automatically we can change the +``User#commentsAuthored`` property to cascade both the "persist" +and the "remove" operation. + +.. code-block:: php + + addresses = new ArrayCollection(); + } + + public function newStandingData(StandingData $sd) + { + $this->standingData = $sd; + } + + public function removeAddress($pos) + { + unset($this->addresses[$pos]); + } + } + +Now two examples of what happens when you remove the references: + +.. code-block:: php + + find("Addressbook\Contact", $contactId); + $contact->newStandingData(new StandingData("Firstname", "Lastname", "Street")); + $contact->removeAddress(1); + + $em->flush(); + +In this case you have not only changed the ``Contact`` entity itself but +you have also removed the references for standing data and as well as one +address reference. When flush is called not only are the references removed +but both the old standing data and the one address entity are also deleted +from the database. + +Filtering Collections +--------------------- + +.. filtering-collections: + +Collections have a filtering API that allows to slice parts of data from +a collection. If the collection has not been loaded from the database yet, +the filtering API can work on the SQL level to make optimized access to +large collections. + +.. code-block:: php + + find('Group', $groupId); + $userCollection = $group->getUsers(); + + $criteria = Criteria::create() + ->where(Criteria::expr()->eq("birthday", "1982-02-17")) + ->orderBy(array("username" => "ASC")) + ->setFirstResult(0) + ->setMaxResults(20) + ; + + $birthdayUsers = $userCollection->matching($criteria); + +.. tip:: + + You can move the access of slices of collections into dedicated methods of + an entity. For example ``Group#getTodaysBirthdayUsers()``. + +The Criteria has a limited matching language that works both on the +SQL and on the PHP collection level. This means you can use collection matching +interchangeably, independent of in-memory or sql-backed collections. + +.. code-block:: php + + find('CMS\Article', 1234); + $article->setHeadline('Hello World dude!'); + + $article2 = $entityManager->find('CMS\Article', 1234); + echo $article2->getHeadline(); + +In this case the Article is accessed from the entity manager twice, +but modified in between. Doctrine 2 realizes this and will only +ever give you access to one instance of the Article with ID 1234, +no matter how often do you retrieve it from the EntityManager and +even no matter what kind of Query method you are using (find, +Repository Finder or DQL). This is called "Identity Map" pattern, +which means Doctrine keeps a map of each entity and ids that have +been retrieved per PHP request and keeps returning you the same +instances. + +In the previous example the echo prints "Hello World dude!" to the +screen. You can even verify that ``$article`` and ``$article2`` are +indeed pointing to the same instance by running the following +code: + +.. code-block:: php + + comments = new ArrayCollection(); + } + + public function getAuthor() { return $this->author; } + public function getComments() { return $this->comments; } + } + + $article = $em->find('Article', 1); + +This code only retrieves the ``Article`` instance with id 1 executing +a single SELECT statement against the user table in the database. +You can still access the associated properties author and comments +and the associated objects they contain. + +This works by utilizing the lazy loading pattern. Instead of +passing you back a real Author instance and a collection of +comments Doctrine will create proxy instances for you. Only if you +access these proxies for the first time they will go through the +EntityManager and load their state from the database. + +This lazy-loading process happens behind the scenes, hidden from +your code. See the following code: + +.. code-block:: php + + find('Article', 1); + + // accessing a method of the user instance triggers the lazy-load + echo "Author: " . $article->getAuthor()->getName() . "\n"; + + // Lazy Loading Proxies pass instanceof tests: + if ($article->getAuthor() instanceof User) { + // a User Proxy is a generated "UserProxy" class + } + + // accessing the comments as an iterator triggers the lazy-load + // retrieving ALL the comments of this article from the database + // using a single SELECT statement + foreach ($article->getComments() AS $comment) { + echo $comment->getText() . "\n\n"; + } + + // Article::$comments passes instanceof tests for the Collection interface + // But it will NOT pass for the ArrayCollection interface + if ($article->getComments() instanceof \Doctrine\Common\Collections\Collection) { + echo "This will always be true!"; + } + +A slice of the generated proxy classes code looks like the +following piece of code. A real proxy class override ALL public +methods along the lines of the ``getName()`` method shown below: + +.. code-block:: php + + _load(); + return parent::getName(); + } + // .. other public methods of User + } + +.. warning:: + + Traversing the object graph for parts that are lazy-loaded will + easily trigger lots of SQL queries and will perform badly if used + to heavily. Make sure to use DQL to fetch-join all the parts of the + object-graph that you need as efficiently as possible. + + +Persisting entities +------------------- + +An entity can be made persistent by passing it to the +``EntityManager#persist($entity)`` method. By applying the persist +operation on some entity, that entity becomes MANAGED, which means +that its persistence is from now on managed by an EntityManager. As +a result the persistent state of such an entity will subsequently +be properly synchronized with the database when +``EntityManager#flush()`` is invoked. + +.. note:: + + Invoking the ``persist`` method on an entity does NOT + cause an immediate SQL INSERT to be issued on the database. + Doctrine applies a strategy called "transactional write-behind", + which means that it will delay most SQL commands until + ``EntityManager#flush()`` is invoked which will then issue all + necessary SQL statements to synchronize your objects with the + database in the most efficient way and a single, short transaction, + taking care of maintaining referential integrity. + + +Example: + +.. code-block:: php + + setName('Mr.Right'); + $em->persist($user); + $em->flush(); + +.. note:: + + Generated entity identifiers / primary keys are + guaranteed to be available after the next successful flush + operation that involves the entity in question. You can not rely on + a generated identifier to be available directly after invoking + ``persist``. The inverse is also true. You can not rely on a + generated identifier being not available after a failed flush + operation. + + +The semantics of the persist operation, applied on an entity X, are +as follows: + + +- If X is a new entity, it becomes managed. The entity X will be + entered into the database as a result of the flush operation. +- If X is a preexisting managed entity, it is ignored by the + persist operation. However, the persist operation is cascaded to + entities referenced by X, if the relationships from X to these + other entities are mapped with cascade=PERSIST or cascade=ALL (see + "Transitive Persistence"). +- If X is a removed entity, it becomes managed. +- If X is a detached entity, an exception will be thrown on + flush. + +Removing entities +----------------- + +An entity can be removed from persistent storage by passing it to +the ``EntityManager#remove($entity)`` method. By applying the +``remove`` operation on some entity, that entity becomes REMOVED, +which means that its persistent state will be deleted once +``EntityManager#flush()`` is invoked. + +.. note:: + + Just like ``persist``, invoking ``remove`` on an entity + does NOT cause an immediate SQL DELETE to be issued on the + database. The entity will be deleted on the next invocation of + ``EntityManager#flush()`` that involves that entity. This + means that entities scheduled for removal can still be queried + for and appear in query and collection results. See + the section on :ref:`Database and UnitOfWork Out-Of-Sync ` + for more information. + + +Example: + +.. code-block:: php + + remove($user); + $em->flush(); + +The semantics of the remove operation, applied to an entity X are +as follows: + + +- If X is a new entity, it is ignored by the remove operation. + However, the remove operation is cascaded to entities referenced by + X, if the relationship from X to these other entities is mapped + with cascade=REMOVE or cascade=ALL (see "Transitive Persistence"). +- If X is a managed entity, the remove operation causes it to + become removed. The remove operation is cascaded to entities + referenced by X, if the relationships from X to these other + entities is mapped with cascade=REMOVE or cascade=ALL (see + "Transitive Persistence"). +- If X is a detached entity, an InvalidArgumentException will be + thrown. +- If X is a removed entity, it is ignored by the remove operation. +- A removed entity X will be removed from the database as a result + of the flush operation. + +After an entity has been removed its in-memory state is the same as +before the removal, except for generated identifiers. + +Removing an entity will also automatically delete any existing +records in many-to-many join tables that link this entity. The +action taken depends on the value of the ``@joinColumn`` mapping +attribute "onDelete". Either Doctrine issues a dedicated ``DELETE`` +statement for records of each join table or it depends on the +foreign key semantics of onDelete="CASCADE". + +Deleting an object with all its associated objects can be achieved +in multiple ways with very different performance impacts. + + +1. If an association is marked as ``CASCADE=REMOVE`` Doctrine 2 + will fetch this association. If its a Single association it will + pass this entity to + ´EntityManager#remove()``. If the association is a collection, Doctrine will loop over all its elements and pass them to``EntityManager#remove()\`. + In both cases the cascade remove semantics are applied recursively. + For large object graphs this removal strategy can be very costly. +2. Using a DQL ``DELETE`` statement allows you to delete multiple + entities of a type with a single command and without hydrating + these entities. This can be very efficient to delete large object + graphs from the database. +3. Using foreign key semantics ``onDelete="CASCADE"`` can force the + database to remove all associated objects internally. This strategy + is a bit tricky to get right but can be very powerful and fast. You + should be aware however that using strategy 1 (``CASCADE=REMOVE``) + completely by-passes any foreign key ``onDelete=CASCADE`` option, + because Doctrine will fetch and remove all associated entities + explicitly nevertheless. + +Detaching entities +------------------ + +An entity is detached from an EntityManager and thus no longer +managed by invoking the ``EntityManager#detach($entity)`` method on +it or by cascading the detach operation to it. Changes made to the +detached entity, if any (including removal of the entity), will not +be synchronized to the database after the entity has been +detached. + +Doctrine will not hold on to any references to a detached entity. + +Example: + +.. code-block:: php + + detach($entity); + +The semantics of the detach operation, applied to an entity X are +as follows: + + +- If X is a managed entity, the detach operation causes it to + become detached. The detach operation is cascaded to entities + referenced by X, if the relationships from X to these other + entities is mapped with cascade=DETACH or cascade=ALL (see + "Transitive Persistence"). Entities which previously referenced X + will continue to reference X. +- If X is a new or detached entity, it is ignored by the detach + operation. +- If X is a removed entity, the detach operation is cascaded to + entities referenced by X, if the relationships from X to these + other entities is mapped with cascade=DETACH or cascade=ALL (see + "Transitive Persistence"). Entities which previously referenced X + will continue to reference X. + +There are several situations in which an entity is detached +automatically without invoking the ``detach`` method: + + +- When ``EntityManager#clear()`` is invoked, all entities that are + currently managed by the EntityManager instance become detached. +- When serializing an entity. The entity retrieved upon subsequent + unserialization will be detached (This is the case for all entities + that are serialized and stored in some cache, i.e. when using the + Query Result Cache). + +The ``detach`` operation is usually not as frequently needed and +used as ``persist`` and ``remove``. + +Merging entities +---------------- + +Merging entities refers to the merging of (usually detached) +entities into the context of an EntityManager so that they become +managed again. To merge the state of an entity into an +EntityManager use the ``EntityManager#merge($entity)`` method. The +state of the passed entity will be merged into a managed copy of +this entity and this copy will subsequently be returned. + +Example: + +.. code-block:: php + + merge($detachedEntity); + // $entity now refers to the fully managed copy returned by the merge operation. + // The EntityManager $em now manages the persistence of $entity as usual. + +.. note:: + + When you want to serialize/unserialize entities you + have to make all entity properties protected, never private. The + reason for this is, if you serialize a class that was a proxy + instance before, the private variables won't be serialized and a + PHP Notice is thrown. + + +The semantics of the merge operation, applied to an entity X, are +as follows: + + +- If X is a detached entity, the state of X is copied onto a + pre-existing managed entity instance X' of the same identity. +- If X is a new entity instance, a new managed copy X' will be + created and the state of X is copied onto this managed instance. +- If X is a removed entity instance, an InvalidArgumentException + will be thrown. +- If X is a managed entity, it is ignored by the merge operation, + however, the merge operation is cascaded to entities referenced by + relationships from X if these relationships have been mapped with + the cascade element value MERGE or ALL (see "Transitive + Persistence"). +- For all entities Y referenced by relationships from X having the + cascade element value MERGE or ALL, Y is merged recursively as Y'. + For all such Y referenced by X, X' is set to reference Y'. (Note + that if X is managed then X is the same object as X'.) +- If X is an entity merged to X', with a reference to another + entity Y, where cascade=MERGE or cascade=ALL is not specified, then + navigation of the same association from X' yields a reference to a + managed object Y' with the same persistent identity as Y. + +The ``merge`` operation will throw an ``OptimisticLockException`` +if the entity being merged uses optimistic locking through a +version field and the versions of the entity being merged and the +managed copy don't match. This usually means that the entity has +been modified while being detached. + +The ``merge`` operation is usually not as frequently needed and +used as ``persist`` and ``remove``. The most common scenario for +the ``merge`` operation is to reattach entities to an EntityManager +that come from some cache (and are therefore detached) and you want +to modify and persist such an entity. + +.. warning:: + + If you need to perform multiple merges of entities that share certain subparts + of their object-graphs and cascade merge, then you have to call ``EntityManager#clear()`` between the + successive calls to ``EntityManager#merge()``. Otherwise you might end up with + multiple copies of the "same" object in the database, however with different ids. + +.. note:: + + If you load some detached entities from a cache and you do + not need to persist or delete them or otherwise make use of them + without the need for persistence services there is no need to use + ``merge``. I.e. you can simply pass detached objects from a cache + directly to the view. + + +Synchronization with the Database +--------------------------------- + +The state of persistent entities is synchronized with the database +on flush of an ``EntityManager`` which commits the underlying +``UnitOfWork``. The synchronization involves writing any updates to +persistent entities and their relationships to the database. +Thereby bidirectional relationships are persisted based on the +references held by the owning side of the relationship as explained +in the Association Mapping chapter. + +When ``EntityManager#flush()`` is called, Doctrine inspects all +managed, new and removed entities and will perform the following +operations. + +.. _workingobjects_database_uow_outofsync: + +Effects of Database and UnitOfWork being Out-Of-Sync +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +As soon as you begin to change the state of entities, call persist or remove the +contents of the UnitOfWork and the database will drive out of sync. They can +only be synchronized by calling ``EntityManager#flush()``. This section +describes the effects of database and UnitOfWork being out of sync. + +- Entities that are scheduled for removal can still be queried from the database. + They are returned from DQL and Repository queries and are visible in collections. +- Entities that are passed to ``EntityManager#persist`` do not turn up in query + results. +- Entities that have changed will not be overwritten with the state from the database. + This is because the identity map will detect the construction of an already existing + entity and assumes its the most up to date version. + +``EntityManager#flush()`` is never called implicitly by Doctrine. You always have to trigger it manually. + +Synchronizing New and Managed Entities +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The flush operation applies to a managed entity with the following +semantics: + + +- The entity itself is synchronized to the database using a SQL + UPDATE statement, only if at least one persistent field has + changed. +- No SQL updates are executed if the entity did not change. + +The flush operation applies to a new entity with the following +semantics: + + +- The entity itself is synchronized to the database using a SQL + INSERT statement. + +For all (initialized) relationships of the new or managed entity +the following semantics apply to each associated entity X: + + +- If X is new and persist operations are configured to cascade on + the relationship, X will be persisted. +- If X is new and no persist operations are configured to cascade + on the relationship, an exception will be thrown as this indicates + a programming error. +- If X is removed and persist operations are configured to cascade + on the relationship, an exception will be thrown as this indicates + a programming error (X would be re-persisted by the cascade). +- If X is detached and persist operations are configured to + cascade on the relationship, an exception will be thrown (This is + semantically the same as passing X to persist()). + +Synchronizing Removed Entities +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The flush operation applies to a removed entity by deleting its +persistent state from the database. No cascade options are relevant +for removed entities on flush, the cascade remove option is already +executed during ``EntityManager#remove($entity)``. + +The size of a Unit of Work +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The size of a Unit of Work mainly refers to the number of managed +entities at a particular point in time. + +The cost of flushing +~~~~~~~~~~~~~~~~~~~~ + +How costly a flush operation is, mainly depends on two factors: + + +- The size of the EntityManager's current UnitOfWork. +- The configured change tracking policies + +You can get the size of a UnitOfWork as follows: + +.. code-block:: php + + getUnitOfWork()->size(); + +The size represents the number of managed entities in the Unit of +Work. This size affects the performance of flush() operations due +to change tracking (see "Change Tracking Policies") and, of course, +memory consumption, so you may want to check it from time to time +during development. + +.. note:: + + Do not invoke ``flush`` after every change to an entity + or every single invocation of persist/remove/merge/... This is an + anti-pattern and unnecessarily reduces the performance of your + application. Instead, form units of work that operate on your + objects and call ``flush`` when you are done. While serving a + single HTTP request there should be usually no need for invoking + ``flush`` more than 0-2 times. + + +Direct access to a Unit of Work +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can get direct access to the Unit of Work by calling +``EntityManager#getUnitOfWork()``. This will return the UnitOfWork +instance the EntityManager is currently using. + +.. code-block:: php + + getUnitOfWork(); + +.. note:: + + Directly manipulating a UnitOfWork is not recommended. + When working directly with the UnitOfWork API, respect methods + marked as INTERNAL by not using them and carefully read the API + documentation. + + +Entity State +~~~~~~~~~~~~ + +As outlined in the architecture overview an entity can be in one of +four possible states: NEW, MANAGED, REMOVED, DETACHED. If you +explicitly need to find out what the current state of an entity is +in the context of a certain ``EntityManager`` you can ask the +underlying ``UnitOfWork``: + +.. code-block:: php + + getUnitOfWork()->getEntityState($entity)) { + case UnitOfWork::STATE_MANAGED: + ... + case UnitOfWork::STATE_REMOVED: + ... + case UnitOfWork::STATE_DETACHED: + ... + case UnitOfWork::STATE_NEW: + ... + } + +An entity is in MANAGED state if it is associated with an +``EntityManager`` and it is not REMOVED. + +An entity is in REMOVED state after it has been passed to +``EntityManager#remove()`` until the next flush operation of the +same EntityManager. A REMOVED entity is still associated with an +``EntityManager`` until the next flush operation. + +An entity is in DETACHED state if it has persistent state and +identity but is currently not associated with an +``EntityManager``. + +An entity is in NEW state if has no persistent state and identity +and is not associated with an ``EntityManager`` (for example those +just created via the "new" operator). + +Querying +-------- + +Doctrine 2 provides the following ways, in increasing level of +power and flexibility, to query for persistent objects. You should +always start with the simplest one that suits your needs. + +By Primary Key +~~~~~~~~~~~~~~ + +The most basic way to query for a persistent object is by its +identifier / primary key using the +``EntityManager#find($entityName, $id)`` method. Here is an +example: + +.. code-block:: php + + find('MyProject\Domain\User', $id); + +The return value is either the found entity instance or null if no +instance could be found with the given identifier. + +Essentially, ``EntityManager#find()`` is just a shortcut for the +following: + +.. code-block:: php + + getRepository('MyProject\Domain\User')->find($id); + +``EntityManager#getRepository($entityName)`` returns a repository +object which provides many ways to retrieve entities of the +specified type. By default, the repository instance is of type +``Doctrine\ORM\EntityRepository``. You can also use custom +repository classes as shown later. + +By Simple Conditions +~~~~~~~~~~~~~~~~~~~~ + +To query for one or more entities based on several conditions that +form a logical conjunction, use the ``findBy`` and ``findOneBy`` +methods on a repository as follows: + +.. code-block:: php + + getRepository('MyProject\Domain\User')->findBy(array('age' => 20)); + + // All users that are 20 years old and have a surname of 'Miller' + $users = $em->getRepository('MyProject\Domain\User')->findBy(array('age' => 20, 'surname' => 'Miller')); + + // A single user by its nickname + $user = $em->getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); + +You can also load by owning side associations through the repository: + +.. code-block:: php + + find('MyProject\Domain\Phonenumber', 1234); + $user = $em->getRepository('MyProject\Domain\User')->findOneBy(array('phone' => $number->getId())); + +Be careful that this only works by passing the ID of the associated entity, not yet by passing the associated entity itself. + +The ``EntityRepository#findBy()`` method additionally accepts orderings, limit and offset as second to fourth parameters: + +.. code-block:: php + + getRepository('MyProject\Domain\User')->findBy(array('age' => 20), array('name' => 'ASC'), 10, 0); + +If you pass an array of values Doctrine will convert the query into a WHERE field IN (..) query automatically: + +.. code-block:: php + + getRepository('MyProject\Domain\User')->findBy(array('age' => array(20, 30, 40))); + // translates roughly to: SELECT * FROM users WHERE age IN (20, 30, 40) + +An EntityRepository also provides a mechanism for more concise +calls through its use of ``__call``. Thus, the following two +examples are equivalent: + +.. code-block:: php + + getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); + + // A single user by its nickname (__call magic) + $user = $em->getRepository('MyProject\Domain\User')->findOneByNickname('romanb'); + +By Criteria +~~~~~~~~~~~ + +.. versionadded:: 2.3 + +The Repository implement the ``Doctrine\Common\Collections\Selectable`` +interface. That means you can build ``Doctrine\Common\Collections\Criteria`` +and pass them to the ``matching($criteria)`` method. + +See the :ref:`Working with Associations: Filtering collections +`. + +By Eager Loading +~~~~~~~~~~~~~~~~ + +Whenever you query for an entity that has persistent associations +and these associations are mapped as EAGER, they will automatically +be loaded together with the entity being queried and is thus +immediately available to your application. + +By Lazy Loading +~~~~~~~~~~~~~~~ + +Whenever you have a managed entity instance at hand, you can +traverse and use any associations of that entity that are +configured LAZY as if they were in-memory already. Doctrine will +automatically load the associated objects on demand through the +concept of lazy-loading. + +By DQL +~~~~~~ + +The most powerful and flexible method to query for persistent +objects is the Doctrine Query Language, an object query language. +DQL enables you to query for persistent objects in the language of +objects. DQL understands classes, fields, inheritance and +associations. DQL is syntactically very similar to the familiar SQL +but *it is not SQL*. + +A DQL query is represented by an instance of the +``Doctrine\ORM\Query`` class. You create a query using +``EntityManager#createQuery($dql)``. Here is a simple example: + +.. code-block:: php + + createQuery("select u from MyDomain\Model\User u where u.age >= 20 and u.age <= 30"); + $users = $q->getResult(); + +Note that this query contains no knowledge about the relational +schema, only about the object model. DQL supports positional as +well as named parameters, many functions, (fetch) joins, +aggregates, subqueries and much more. Detailed information about +DQL and its syntax as well as the Doctrine class can be found in +:doc:`the dedicated chapter `. +For programmatically building up queries based on conditions that +are only known at runtime, Doctrine provides the special +``Doctrine\ORM\QueryBuilder`` class. More information on +constructing queries with a QueryBuilder can be found +:doc:`in Query Builder chapter `. + +By Native Queries +~~~~~~~~~~~~~~~~~ + +As an alternative to DQL or as a fallback for special SQL +statements native queries can be used. Native queries are built by +using a hand-crafted SQL query and a ResultSetMapping that +describes how the SQL result set should be transformed by Doctrine. +More information about native queries can be found in +:doc:`the dedicated chapter `. + +Custom Repositories +~~~~~~~~~~~~~~~~~~~ + +By default the EntityManager returns a default implementation of +``Doctrine\ORM\EntityRepository`` when you call +``EntityManager#getRepository($entityClass)``. You can overwrite +this behaviour by specifying the class name of your own Entity +Repository in the Annotation, XML or YAML metadata. In large +applications that require lots of specialized DQL queries using a +custom repository is one recommended way of grouping these queries +in a central location. + +.. code-block:: php + + _em->createQuery('SELECT u FROM MyDomain\Model\User u WHERE u.status = "admin"') + ->getResult(); + } + } + +You can access your repository now by calling: + +.. code-block:: php + + getRepository('MyDomain\Model\User')->getAllAdminUsers(); + + diff --git a/vendor/doctrine/orm/docs/en/reference/xml-mapping.rst b/vendor/doctrine/orm/docs/en/reference/xml-mapping.rst new file mode 100644 index 0000000000..d82c82fab8 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/xml-mapping.rst @@ -0,0 +1,747 @@ +XML Mapping +=========== + +The XML mapping driver enables you to provide the ORM metadata in +form of XML documents. + +The XML driver is backed by an XML Schema document that describes +the structure of a mapping document. The most recent version of the +XML Schema document is available online at +`http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd `_. +In order to point to the latest version of the document of a +particular stable release branch, just append the release number, +i.e.: doctrine-mapping-2.0.xsd The most convenient way to work with +XML mapping files is to use an IDE/editor that can provide +code-completion based on such an XML Schema document. The following +is an outline of a XML mapping document with the proper xmlns/xsi +setup for the latest code in trunk. + +.. code-block:: xml + + + + ... + + + +The XML mapping document of a class is loaded on-demand the first +time it is requested and subsequently stored in the metadata cache. +In order to work, this requires certain conventions: + + +- Each entity/mapped superclass must get its own dedicated XML + mapping document. +- The name of the mapping document must consist of the fully + qualified name of the class, where namespace separators are + replaced by dots (.). For example an Entity with the fully + qualified class-name "MyProject" would require a mapping file + "MyProject.Entities.User.dcm.xml" unless the extension is changed. +- All mapping documents should get the extension ".dcm.xml" to + identify it as a Doctrine mapping file. This is more of a + convention and you are not forced to do this. You can change the + file extension easily enough. + +- + +.. code-block:: php + + setFileExtension('.xml'); + +It is recommended to put all XML mapping documents in a single +folder but you can spread the documents over several folders if you +want to. In order to tell the XmlDriver where to look for your +mapping documents, supply an array of paths as the first argument +of the constructor, like this: + +.. code-block:: php + + setMetadataDriverImpl($driver); + +Simplified XML Driver +~~~~~~~~~~~~~~~~~~~~~ + +The Symfony project sponsored a driver that simplifies usage of the XML Driver. +The changes between the original driver are: + +1. File Extension is .orm.xml +2. Filenames are shortened, "MyProject\Entities\User" will become User.orm.xml +3. You can add a global file and add multiple entities in this file. + +Configuration of this client works a little bit different: + +.. code-block:: php + + '/path/to/files1', + 'OtherProject\Entities' => '/path/to/files2' + ); + $driver = new \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver($namespaces); + $driver->setGlobalBasename('global'); // global.orm.xml + +Example +------- + +As a quick start, here is a small example document that makes use +of several common elements: + +.. code-block:: xml + + // Doctrine.Tests.ORM.Mapping.User.dcm.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Be aware that class-names specified in the XML files should be +fully qualified. + +XML-Element Reference +--------------------- + +The XML-Element reference explains all the tags and attributes that +the Doctrine Mapping XSD Schema defines. You should read the +Basic-, Association- and Inheritance Mapping chapters to understand +what each of this definitions means in detail. + +Defining an Entity +~~~~~~~~~~~~~~~~~~ + +Each XML Mapping File contains the definition of one entity, +specified as the ```` element as a direct child of the +```` element: + +.. code-block:: xml + + + + + + + +Required attributes: + + +- name - The fully qualified class-name of the entity. + +Optional attributes: + + +- **table** - The Table-Name to be used for this entity. Otherwise the + Unqualified Class-Name is used by default. +- **repository-class** - The fully qualified class-name of an + alternative ``Doctrine\ORM\EntityRepository`` implementation to be + used with this entity. +- **inheritance-type** - The type of inheritance, defaults to none. A + more detailed description follows in the + *Defining Inheritance Mappings* section. +- **read-only** - (>= 2.1) Specifies that this entity is marked as read only and not + considered for change-tracking. Entities of this type can be persisted + and removed though. + +Defining Fields +~~~~~~~~~~~~~~~ + +Each entity class can contain zero to infinite fields that are +managed by Doctrine. You can define them using the ```` +element as a children to the ```` element. The field +element is only used for primitive types that are not the ID of the +entity. For the ID mapping you have to use the ```` element. + +.. code-block:: xml + + + + + + + + + + +Required attributes: + + +- name - The name of the Property/Field on the given Entity PHP + class. + +Optional attributes: + + +- type - The ``Doctrine\DBAL\Types\Type`` name, defaults to + "string" +- column - Name of the column in the database, defaults to the + field name. +- length - The length of the given type, for use with strings + only. +- unique - Should this field contain a unique value across the + table? Defaults to false. +- nullable - Should this field allow NULL as a value? Defaults to + false. +- version - Should this field be used for optimistic locking? Only + works on fields with type integer or datetime. +- scale - Scale of a decimal type. +- precision - Precision of a decimal type. +- column-definition - Optional alternative SQL representation for + this column. This definition begin after the field-name and has to + specify the complete column definition. Using this feature will + turn this field dirty for Schema-Tool update commands at all + times. + +Defining Identity and Generator Strategies +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +An entity has to have at least one ```` element. For +composite keys you can specify more than one id-element, however +surrogate keys are recommended for use with Doctrine 2. The Id +field allows to define properties of the identifier and allows a +subset of the ```` element attributes: + +.. code-block:: xml + + + + + +Required attributes: + + +- name - The name of the Property/Field on the given Entity PHP + class. +- type - The ``Doctrine\DBAL\Types\Type`` name, preferably + "string" or "integer". + +Optional attributes: + + +- column - Name of the column in the database, defaults to the + field name. + +Using the simplified definition above Doctrine will use no +identifier strategy for this entity. That means you have to +manually set the identifier before calling +``EntityManager#persist($entity)``. This is the so called +``ASSIGNED`` strategy. + +If you want to switch the identifier generation strategy you have +to nest a ```` element inside the id-element. This of +course only works for surrogate keys. For composite keys you always +have to use the ``ASSIGNED`` strategy. + +.. code-block:: xml + + + + + + + +The following values are allowed for the ```` strategy +attribute: + + +- AUTO - Automatic detection of the identifier strategy based on + the preferred solution of the database vendor. +- IDENTITY - Use of a IDENTIFY strategy such as Auto-Increment IDs + available to Doctrine AFTER the INSERT statement has been executed. +- SEQUENCE - Use of a database sequence to retrieve the + entity-ids. This is possible before the INSERT statement is + executed. + +If you are using the SEQUENCE strategy you can define an additional +element to describe the sequence: + +.. code-block:: xml + + + + + + + + +Required attributes for ````: + + +- sequence-name - The name of the sequence + +Optional attributes for ````: + + +- allocation-size - By how much steps should the sequence be + incremented when a value is retrieved. Defaults to 1 +- initial-value - What should the initial value of the sequence + be. + + **NOTE** + + If you want to implement a cross-vendor compatible application you + have to specify and additionally define the + element, if Doctrine chooses the sequence strategy for a + platform. + + +Defining a Mapped Superclass +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sometimes you want to define a class that multiple entities inherit +from, which itself is not an entity however. The chapter on +*Inheritance Mapping* describes a Mapped Superclass in detail. You +can define it in XML using the ```` tag. + +.. code-block:: xml + + + + + + + + +Required attributes: + + +- name - Class name of the mapped superclass. + +You can nest any number of ```` and unidirectional +```` or ```` associations inside a +mapped superclass. + +Defining Inheritance Mappings +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There are currently two inheritance persistence strategies that you +can choose from when defining entities that inherit from each +other. Single Table inheritance saves the fields of the complete +inheritance hierarchy in a single table, joined table inheritance +creates a table for each entity combining the fields using join +conditions. + +You can specify the inheritance type in the ```` element +and then use the ```` and +```` attributes. + +.. code-block:: xml + + + + + + + + + + +The allowed values for inheritance-type attribute are ``JOINED`` or +``SINGLE_TABLE``. + +.. note:: + + All inheritance related definitions have to be defined on the root + entity of the hierarchy. + + +Defining Lifecycle Callbacks +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can define the lifecycle callback methods on your entities +using the ```` element: + +.. code-block:: xml + + + + + + + + +Defining One-To-One Relations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can define One-To-One Relations/Associations using the +```` element. The required and optional attributes +depend on the associations being on the inverse or owning side. + +For the inverse side the mapping is as simple as: + +.. code-block:: xml + + + + + +Required attributes for inverse One-To-One: + + +- field - Name of the property/field on the entity's PHP class. +- target-entity - Name of the entity associated entity class. If + this is not qualified the namespace of the current class is + prepended. *IMPORTANT:* No leading backslash! +- mapped-by - Name of the field on the owning side (here Address + entity) that contains the owning side association. + +For the owning side this mapping would look like: + +.. code-block:: xml + + + + + +Required attributes for owning One-to-One: + + +- field - Name of the property/field on the entity's PHP class. +- target-entity - Name of the entity associated entity class. If + this is not qualified the namespace of the current class is + prepended. *IMPORTANT:* No leading backslash! + +Optional attributes for owning One-to-One: + + +- inversed-by - If the association is bidirectional the + inversed-by attribute has to be specified with the name of the + field on the inverse entity that contains the back-reference. +- orphan-removal - If true, the inverse side entity is always + deleted when the owning side entity is. Defaults to false. +- fetch - Either LAZY or EAGER, defaults to LAZY. This attribute + makes only sense on the owning side, the inverse side *ALWAYS* has + to use the ``FETCH`` strategy. + +The definition for the owning side relies on a bunch of mapping +defaults for the join column names. Without the nested +```` element Doctrine assumes to foreign key to be +called ``user_id`` on the Address Entities table. This is because +the ``MyProject\Address`` entity is the owning side of this +association, which means it contains the foreign key. + +The completed explicitly defined mapping is: + +.. code-block:: xml + + + + + + + +Defining Many-To-One Associations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The many-to-one association is *ALWAYS* the owning side of any +bidirectional association. This simplifies the mapping compared to +the one-to-one case. The minimal mapping for this association looks +like: + +.. code-block:: xml + + + + + +Required attributes: + + +- field - Name of the property/field on the entity's PHP class. +- target-entity - Name of the entity associated entity class. If + this is not qualified the namespace of the current class is + prepended. *IMPORTANT:* No leading backslash! + +Optional attributes: + + +- inversed-by - If the association is bidirectional the + inversed-by attribute has to be specified with the name of the + field on the inverse entity that contains the back-reference. +- orphan-removal - If true the entity on the inverse side is + always deleted when the owning side entity is and it is not + connected to any other owning side entity anymore. Defaults to + false. +- fetch - Either LAZY or EAGER, defaults to LAZY. + +This definition relies on a bunch of mapping defaults with regards +to the naming of the join-column/foreign key. The explicitly +defined mapping includes a ```` tag nested inside +the many-to-one association tag: + +.. code-block:: xml + + + + + + + +The join-column attribute ``name`` specifies the column name of the +foreign key and the ``referenced-column-name`` attribute specifies +the name of the primary key column on the User entity. + +Defining One-To-Many Associations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The one-to-many association is *ALWAYS* the inverse side of any +association. There exists no such thing as a uni-directional +one-to-many association, which means this association only ever +exists for bi-directional associations. + +.. code-block:: xml + + + + + +Required attributes: + + +- field - Name of the property/field on the entity's PHP class. +- target-entity - Name of the entity associated entity class. If + this is not qualified the namespace of the current class is + prepended. *IMPORTANT:* No leading backslash! +- mapped-by - Name of the field on the owning side (here + Phonenumber entity) that contains the owning side association. + +Optional attributes: + + +- fetch - Either LAZY, EXTRA_LAZY or EAGER, defaults to LAZY. +- index-by: Index the collection by a field on the target entity. + +Defining Many-To-Many Associations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +From all the associations the many-to-many has the most complex +definition. When you rely on the mapping defaults you can omit many +definitions and rely on their implicit values. + +.. code-block:: xml + + + + + +Required attributes: + + +- field - Name of the property/field on the entity's PHP class. +- target-entity - Name of the entity associated entity class. If + this is not qualified the namespace of the current class is + prepended. *IMPORTANT:* No leading backslash! + +Optional attributes: + + +- mapped-by - Name of the field on the owning side that contains + the owning side association if the defined many-to-many association + is on the inverse side. +- inversed-by - If the association is bidirectional the + inversed-by attribute has to be specified with the name of the + field on the inverse entity that contains the back-reference. +- fetch - Either LAZY, EXTRA_LAZY or EAGER, defaults to LAZY. +- index-by: Index the collection by a field on the target entity. + +The mapping defaults would lead to a join-table with the name +"User\_Group" being created that contains two columns "user\_id" +and "group\_id". The explicit definition of this mapping would be: + +.. code-block:: xml + + + + + + + + + + + + + + +Here both the ```` and ```` +tags are necessary to tell Doctrine for which side the specified +join-columns apply. These are nested inside a ```` +attribute which allows to specify the table name of the +many-to-many join-table. + +Cascade Element +~~~~~~~~~~~~~~~ + +Doctrine allows cascading of several UnitOfWork operations to +related entities. You can specify the cascade operations in the +```` element inside any of the association mapping +tags. + +.. code-block:: xml + + + + + + + + + +Besides ```` the following operations can be +specified by their respective tags: + + +- ```` +- ```` +- ```` +- ```` + +Join Column Element +~~~~~~~~~~~~~~~~~~~ + +In any explicitly defined association mapping you will need the +```` tag. It defines how the foreign key and primary +key names are called that are used for joining two entities. + +Required attributes: + + +- name - The column name of the foreign key. +- referenced-column-name - The column name of the associated + entities primary key + +Optional attributes: + + +- unique - If the join column should contain a UNIQUE constraint. + This makes sense for Many-To-Many join-columns only to simulate a + one-to-many unidirectional using a join-table. +- nullable - should the join column be nullable, defaults to true. +- on-delete - Foreign Key Cascade action to perform when entity is + deleted, defaults to NO ACTION/RESTRICT but can be set to + "CASCADE". + +Defining Order of To-Many Associations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can require one-to-many or many-to-many associations to be +retrieved using an additional ``ORDER BY``. + +.. code-block:: xml + + + + + + + + + +Defining Indexes or Unique Constraints +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To define additional indexes or unique constraints on the entities +table you can use the ```` and +```` elements: + +.. code-block:: xml + + + + + + + + + + + + + +You have to specify the column and not the entity-class field names +in the index and unique-constraint definitions. + +Derived Entities ID syntax +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If the primary key of an entity contains a foreign key to another entity we speak of a derived +entity relationship. You can define this in XML with the "association-key" attribute in the ```` tag. + +.. code-block:: xml + + + + + + + + + + + + + diff --git a/vendor/doctrine/orm/docs/en/reference/yaml-mapping.rst b/vendor/doctrine/orm/docs/en/reference/yaml-mapping.rst new file mode 100644 index 0000000000..bc6c64c8f0 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/reference/yaml-mapping.rst @@ -0,0 +1,117 @@ +YAML Mapping +============ + +The YAML mapping driver enables you to provide the ORM metadata in +form of YAML documents. + +The YAML mapping document of a class is loaded on-demand the first +time it is requested and subsequently stored in the metadata cache. +In order to work, this requires certain conventions: + + +- Each entity/mapped superclass must get its own dedicated YAML + mapping document. +- The name of the mapping document must consist of the fully + qualified name of the class, where namespace separators are + replaced by dots (.). +- All mapping documents should get the extension ".dcm.yml" to + identify it as a Doctrine mapping file. This is more of a + convention and you are not forced to do this. You can change the + file extension easily enough. + +.. code-block:: php + + setFileExtension('.yml'); + +It is recommended to put all YAML mapping documents in a single +folder but you can spread the documents over several folders if you +want to. In order to tell the YamlDriver where to look for your +mapping documents, supply an array of paths as the first argument +of the constructor, like this: + +.. code-block:: php + + setMetadataDriverImpl($driver); + +Simplified YAML Driver +~~~~~~~~~~~~~~~~~~~~~~ + +The Symfony project sponsored a driver that simplifies usage of the YAML Driver. +The changes between the original driver are: + +- File Extension is .orm.yml +- Filenames are shortened, "MyProject\\Entities\\User" will become User.orm.yml +- You can add a global file and add multiple entities in this file. + +Configuration of this client works a little bit different: + +.. code-block:: php + + 'MyProject\Entities', + '/path/to/files2' => 'OtherProject\Entities' + ); + $driver = new \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver($namespaces); + $driver->setGlobalBasename('global'); // global.orm.yml + +Example +------- + +As a quick start, here is a small example document that makes use +of several common elements: + +.. code-block:: yaml + + # Doctrine.Tests.ORM.Mapping.User.dcm.yml + Doctrine\Tests\ORM\Mapping\User: + type: entity + table: cms_users + indexes: + name_index: + columns: [ name ] + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + type: string + length: 50 + oneToOne: + address: + targetEntity: Address + joinColumn: + name: address_id + referencedColumnName: id + oneToMany: + phonenumbers: + targetEntity: Phonenumber + mappedBy: user + cascade: ["persist", "merge"] + manyToMany: + groups: + targetEntity: Group + joinTable: + name: cms_users_groups + joinColumns: + user_id: + referencedColumnName: id + inverseJoinColumns: + group_id: + referencedColumnName: id + lifecycleCallbacks: + prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] + postPersist: [ doStuffOnPostPersist ] + +Be aware that class-names specified in the YAML files should be +fully qualified. + + diff --git a/vendor/doctrine/orm/docs/en/toc.rst b/vendor/doctrine/orm/docs/en/toc.rst new file mode 100644 index 0000000000..73f1f25b93 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/toc.rst @@ -0,0 +1,80 @@ +Welcome to Doctrine 2 ORM's documentation! +========================================== + +Tutorials +--------- + +.. toctree:: + :maxdepth: 1 + + tutorials/getting-started + tutorials/working-with-indexed-associations + tutorials/extra-lazy-associations + tutorials/composite-primary-keys + tutorials/ordered-associations + tutorials/in-ten-quick-steps + tutorials/override-field-association-mappings-in-subclasses + +Reference Guide +--------------- + +.. toctree:: + :maxdepth: 1 + :numbered: + + reference/introduction + reference/architecture + reference/configuration + reference/faq + reference/basic-mapping + reference/association-mapping + reference/inheritance-mapping + reference/working-with-objects + reference/working-with-associations + reference/events + reference/unitofwork + reference/unitofwork-associations + reference/transactions-and-concurrency + reference/batch-processing + reference/dql-doctrine-query-language + reference/query-builder + reference/native-sql + reference/change-tracking-policies + reference/partial-objects + reference/xml-mapping + reference/yaml-mapping + reference/annotations-reference + reference/php-mapping + reference/caching + reference/improving-performance + reference/tools + reference/metadata-drivers + reference/best-practices + reference/limitations-and-known-issues + tutorials/pagination.rst + reference/filters.rst + reference/namingstrategy.rst + + +Cookbook +-------- + +.. toctree:: + :maxdepth: 1 + + cookbook/aggregate-fields + cookbook/decorator-pattern + cookbook/dql-custom-walkers + cookbook/dql-user-defined-functions + cookbook/implementing-arrayaccess-for-domain-objects + cookbook/implementing-the-notify-changetracking-policy + cookbook/implementing-wakeup-or-clone + cookbook/integrating-with-codeigniter + cookbook/sql-table-prefixes + cookbook/strategy-cookbook-introduction + cookbook/validation-of-entities + cookbook/working-with-datetime + cookbook/mysql-enums + cookbook/advanced-field-value-conversion-using-custom-mapping-types + cookbook/entities-in-session + diff --git a/vendor/doctrine/orm/docs/en/tutorials/composite-primary-keys.rst b/vendor/doctrine/orm/docs/en/tutorials/composite-primary-keys.rst new file mode 100644 index 0000000000..dd4e49e04a --- /dev/null +++ b/vendor/doctrine/orm/docs/en/tutorials/composite-primary-keys.rst @@ -0,0 +1,375 @@ +Composite and Foreign Keys as Primary Key +========================================= + +.. versionadded:: 2.1 + +Doctrine 2 supports composite primary keys natively. Composite keys are a very powerful relational database concept +and we took good care to make sure Doctrine 2 supports as many of the composite primary key use-cases. +For Doctrine 2.0 composite keys of primitive data-types are supported, for Doctrine 2.1 even foreign keys as +primary keys are supported. + +This tutorial shows how the semantics of composite primary keys work and how they map to the database. + +General Considerations +~~~~~~~~~~~~~~~~~~~~~~ + +Every entity with a composite key cannot use an id generator other than "ASSIGNED". That means +the ID fields have to have their values set before you call ``EntityManager#persist($entity)``. + +Primitive Types only +~~~~~~~~~~~~~~~~~~~~ + +Even in version 2.0 you can have composite keys as long as they only consist of the primitive types +``integer`` and ``string``. Suppose you want to create a database of cars and use the model-name +and year of production as primary keys: + +.. configuration-block:: + + .. code-block:: php + + name = $name; + $this->year = $year; + } + + public function getModelName() + { + return $this->name; + } + + public function getYearOfProduction() + { + return $this->year; + } + } + + .. code-block:: xml + + + + + + + + + + + .. code-block:: yaml + + VehicleCatalogue\Model\Car: + type: entity + id: + name: + type: string + year: + type: integer + +Now you can use this entity: + +.. code-block:: php + + persist($car); + $em->flush(); + +And for querying you can use arrays to both DQL and EntityRepositories: + +.. code-block:: php + + find("VehicleCatalogue\Model\Car", array("name" => "Audi A8", "year" => 2010)); + + $dql = "SELECT c FROM VehicleCatalogue\Model\Car c WHERE c.id = ?1"; + $audi = $em->createQuery($dql) + ->setParameter(1, array("name" => "Audi A8", "year" => 2010)) + ->getSingleResult(); + +You can also use this entity in associations. Doctrine will then generate two foreign keys one for ``name`` +and to ``year`` to the related entities. + +.. note:: + + This example shows how you can nicely solve the requirement for existing + values before ``EntityManager#persist()``: By adding them as mandatory values for the constructor. + +Identity through foreign Entities +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. note:: + + Identity through foreign entities is only supported with Doctrine 2.1 + +There are tons of use-cases where the identity of an Entity should be determined by the entity +of one or many parent entities. + +- Dynamic Attributes of an Entity (for example Article). Each Article has many + attributes with primary key "article_id" and "attribute_name". +- Address object of a Person, the primary key of the address is "user_id". This is not a case of a composite primary + key, but the identity is derived through a foreign entity and a foreign key. +- Join Tables with metadata can be modelled as Entity, for example connections between two articles + with a little description and a score. + +The semantics of mapping identity through foreign entities are easy: + +- Only allowed on Many-To-One or One-To-One associations. +- Plug an ``@Id`` annotation onto every association. +- Set an attribute ``association-key`` with the field name of the association in XML. +- Set a key ``associationKey:`` with the field name of the association in YAML. + +Use-Case 1: Dynamic Attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +We keep up the example of an Article with arbitrary attributes, the mapping looks like this: + +.. configuration-block:: + + .. code-block:: php + + attributes[$name] = new ArticleAttribute($name, $value, $this); + } + } + + /** + * @Entity + */ + class ArticleAttribute + { + /** @Id @ManyToOne(targetEntity="Article", inversedBy="attributes") */ + private $article; + + /** @Id @Column(type="string") */ + private $attribute; + + /** @Column(type="string") */ + private $value; + + public function __construct($name, $value, $article) + { + $this->attribute = $name; + $this->value = $value; + $this->article = $article; + } + } + + .. code-block:: xml + + + + + + + + + + + + + + + .. code-block:: yaml + + Application\Model\ArticleAttribute: + type: entity + id: + article: + associationKey: true + attribute: + type: string + fields: + value: + type: string + manyToOne: + article: + targetEntity: Article + inversedBy: attributes + + +Use-Case 2: Simple Derived Identity +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sometimes you have the requirement that two objects are related by a One-To-One association +and that the dependent class should re-use the primary key of the class it depends on. +One good example for this is a user-address relationship: + +.. configuration-block:: + + .. code-block:: php + + customer = $customer; + $this->items = new ArrayCollection(); + $this->created = new \DateTime("now"); + } + } + + /** @Entity */ + class Product + { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + + /** @Column(type="string") */ + private $name; + + /** @Column(type="decimal") */ + private $currentPrice; + + public function getCurrentPrice() + { + return $this->currentPrice; + } + } + + /** @Entity */ + class OrderItem + { + /** @Id @ManyToOne(targetEntity="Order") */ + private $order; + + /** @Id @ManyToOne(targetEntity="Product") */ + private $product; + + /** @Column(type="integer") */ + private $amount = 1; + + /** @Column(type="decimal") */ + private $offeredPrice; + + public function __construct(Order $order, Product $product, $amount = 1) + { + $this->order = $order; + $this->product = $product; + $this->offeredPrice = $product->getCurrentPrice(); + } + } + + +Performance Considerations +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Using composite keys always comes with a performance hit compared to using entities with +a simple surrogate key. This performance impact is mostly due to additional PHP code that is +necessary to handle this kind of keys, most notably when using derived identifiers. + +On the SQL side there is not much overhead as no additional or unexpected queries have to be +executed to manage entities with derived foreign keys. diff --git a/vendor/doctrine/orm/docs/en/tutorials/extra-lazy-associations.rst b/vendor/doctrine/orm/docs/en/tutorials/extra-lazy-associations.rst new file mode 100644 index 0000000000..7ac88d8c44 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/tutorials/extra-lazy-associations.rst @@ -0,0 +1,84 @@ +Extra Lazy Associations +======================= + +.. versionadded:: 2.1 + +In many cases associations between entities can get pretty large. Even in a simple scenario like a blog. +where posts can be commented, you always have to assume that a post draws hundreds of comments. +In Doctrine 2.0 if you accessed an association it would always get loaded completely into memory. This +can lead to pretty serious performance problems, if your associations contain several hundreds or thousands +of entities. + +With Doctrine 2.1 a feature called **Extra Lazy** is introduced for associations. Associations +are marked as **Lazy** by default, which means the whole collection object for an association is populated +the first time its accessed. If you mark an association as extra lazy the following methods on collections +can be called without triggering a full load of the collection: + +- ``Collection#contains($entity)`` +- ``Collection#count()`` +- ``Collection#slice($offset, $length = null)`` + +For each of this three methods the following semantics apply: + +- For each call, if the Collection is not yet loaded, issue a straight SELECT statement against the database. +- For each call, if the collection is already loaded, fallback to the default functionality for lazy collections. No additional SELECT statements are executed. + +Additionally even with Doctrine 2.0 the following methods do not trigger the collection load: + +- ``Collection#add($entity)`` +- ``Collection#offsetSet($key, $entity)`` - ArrayAccess with no specific key ``$coll[] = $entity``, it does + not work when setting specific keys like ``$coll[0] = $entity``. + +With extra lazy collections you can now not only add entities to large collections but also paginate them +easily using a combination of ``count`` and ``slice``. + + +Enabling Extra-Lazy Associations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The mapping configuration is simple. Instead of using the default value of ``fetch="LAZY"`` you have to +switch to extra lazy as shown in these examples: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + .. code-block:: yaml + + Doctrine\Tests\Models\CMS\CmsGroup: + type: entity + # ... + manyToMany: + users: + targetEntity: CmsUser + mappedBy: groups + fetch: EXTRA_LAZY + diff --git a/vendor/doctrine/orm/docs/en/tutorials/getting-started-database.rst b/vendor/doctrine/orm/docs/en/tutorials/getting-started-database.rst new file mode 100644 index 0000000000..c625193aeb --- /dev/null +++ b/vendor/doctrine/orm/docs/en/tutorials/getting-started-database.rst @@ -0,0 +1,27 @@ +Getting Started: Database First +=============================== + +.. note:: *Development Workflows* + + When you :doc:`Code First `, you + start with developing Objects and then map them onto your database. When + you :doc:`Model First `, you are modelling your application using tools (for + example UML) and generate database schema and PHP code from this model. + When you have a :doc:`Database First `, you already have a database schema + and generate the corresponding PHP code from it. + +.. note:: + + This getting started guide is in development. + +Development of new applications often starts with an existing database schema. +When the database schema is the starting point for your application, then +development is said to use the *Database First* approach to Doctrine. + +In this workflow you would modify the database schema first and then +regenerate the PHP code to use with this schema. You need a flexible +code-generator for this task and up to Doctrine 2.2, the code generator hasn't +been flexible enough to achieve this. + +We spinned off a subproject, Doctrine CodeGenerator, that will fill this gap and +allow you to do *Database First* development. diff --git a/vendor/doctrine/orm/docs/en/tutorials/getting-started-models.rst b/vendor/doctrine/orm/docs/en/tutorials/getting-started-models.rst new file mode 100644 index 0000000000..e844b4d686 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/tutorials/getting-started-models.rst @@ -0,0 +1,24 @@ +Getting Started: Model First +============================ + +.. note:: *Development Workflows* + + When you :doc:`Code First `, you + start with developing Objects and then map them onto your database. When + you :doc:`Model First `, you are modelling your application using tools (for + example UML) and generate database schema and PHP code from this model. + When you have a :doc:`Database First `, then you already have a database schema + and generate the corresponding PHP code from it. + +.. note:: + + This getting started guide is in development. + +There are applications when you start with a high-level description of the +model using modelling tools such as UML. Modelling tools could also be Excel, +XML or CSV files that describe the model in some structured way. If your +application is using a modelling tool, then the development workflow is said to +be a *Model First* approach to Doctrine2. + +In this workflow you always change the model description and then regenerate +both PHP code and database schema from this model. diff --git a/vendor/doctrine/orm/docs/en/tutorials/getting-started.rst b/vendor/doctrine/orm/docs/en/tutorials/getting-started.rst new file mode 100644 index 0000000000..4f169cd947 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/tutorials/getting-started.rst @@ -0,0 +1,1537 @@ +Getting Started with Doctrine +============================= + +This guide covers getting started with the Doctrine ORM. After working +through the guide you should know: + +- How to install and configure Doctrine by connecting it to a database +- Mapping PHP objects to database tables +- Generating a database schema from PHP objects +- Using the ``EntityManager`` to insert, update, delete and find + objects in the database. + +Guide Assumptions +----------------- + +This guide is designed for beginners that haven't worked with Doctrine ORM +before. There are some prerequesites for the tutorial that have to be +installed: + +- PHP 5.3.3 or above +- Composer Package Manager (`Install Composer + `_) + +The code of this tutorial is `available on Github `_. + +.. note:: + + This tutorial assumes you work with Doctrine 2.4 and above. + Some of the code will not work with lower versions. + +What is Doctrine? +----------------- + +Doctrine 2 is an `object-relational mapper (ORM) +`_ for PHP 5.3.3+ that +provides transparent persistence for PHP objects. It uses the Data Mapper +pattern at the heart, aiming for a complete separation of your domain/business +logic from the persistence in a relational database management system. + +The benefit of Doctrine for the programmer is the ability to focus +on the object-oriented business logic and worry about persistence only +as a secondary problem. This doesn't mean persistence is downplayed by Doctrine +2, however it is our belief that there are considerable benefits for +object-oriented programming if persistence and entities are kept +separated. + +What are Entities? +~~~~~~~~~~~~~~~~~~ + +Entities are PHP Objects that can be identified over many requests +by a unique identifier or primary key. These classes don't need to extend any +abstract base class or interface. An entity class must not be final +or contain final methods. Additionally it must not implement +**clone** nor **wakeup** or :doc:`do so safely <../cookbook/implementing-wakeup-or-clone>`. + +An entity contains persistable properties. A persistable property +is an instance variable of the entity that is saved into and retrieved from the database +by Doctrine's data mapping capabilities. + +An Example Model: Bug Tracker +----------------------------- + +For this Getting Started Guide for Doctrine we will implement the +Bug Tracker domain model from the +`Zend\_Db\_Table `_ +documentation. Reading their documentation we can extract the +requirements: + +- A Bugs has a description, creation date, status, reporter and + engineer +- A bug can occur on different products (platforms) +- Products have a name. +- Bug Reporter and Engineers are both Users of the System. +- A user can create new bugs. +- The assigned engineer can close a bug. +- A user can see all his reported or assigned bugs. +- Bugs can be paginated through a list-view. + +Setup Project +------------- + +Create a new empty folder for this tutorial project, for example +``doctrine2-tutorial`` and create a new file ``composer.json`` with +the following contents: + +:: + + { + "require": { + "doctrine/orm": "2.*", + "symfony/yaml": "2.*" + }, + "autoload": { + "psr-0": {"": "src/"} + } + } + +Install Doctrine using the Composer Dependency Management tool, by calling: + +:: + + $ composer install + +This will install the packages Doctrine Common, Doctrine DBAL, Doctrine ORM, +Symfony YAML and Symfony Console. Both Symfony dependencies are optional +but will be used in this tutorial. + +You can prepare the directory structure: + +:: + + project + |-- composer.json + |-- config + | |-- xml + | `-- yaml + `-- src + +Obtaining the EntityManager +--------------------------- + +Doctrine's public interface is the EntityManager, it provides the +access point to the complete lifecycle management of your entities +and transforms entities from and back to persistence. You have to +configure and create it to use your entities with Doctrine 2. I +will show the configuration steps and then discuss them step by +step: + +.. code-block:: php + + 'pdo_sqlite', + 'path' => __DIR__ . '/db.sqlite', + ); + + // obtaining the entity manager + $entityManager = EntityManager::create($conn, $config); + +The first require statement sets up the autoloading capabilities of Doctrine +using the Composer autoload. + +The second block consists of the instantiation of the ORM +``Configuration`` object using the Setup helper. It assumes a bunch +of defaults that you don't have to bother about for now. You can +read up on the configuration details in the +:doc:`reference chapter on configuration <../reference/configuration>`. + +The third block shows the configuration options required to connect +to a database, in my case a file-based sqlite database. All the +configuration options for all the shipped drivers are given in the +`DBAL Configuration section of the manual `_. + +The last block shows how the ``EntityManager`` is obtained from a +factory method. + +Generating the Database Schema +------------------------------ + +Now that we have defined the Metadata Mappings and bootstrapped the +EntityManager we want to generate the relational database schema +from it. Doctrine has a Command-Line-Interface that allows you to +access the SchemaTool, a component that generates the required +tables to work with the metadata. + +For the command-line tool to work a cli-config.php file has to be +present in the project root directory, where you will execute the +doctrine command. Its a fairly simple file: + +.. code-block:: php + + id; + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + } + +Note how the properties have getter and setter methods defined except +``$id``. To access data from entities Doctrine 2 uses the Reflection API, so it +is possible for Doctrine to access the value of ``$id``. You don't have to +take Doctrine into account when designing access to the state of your objects. + +The next step for persistence with Doctrine is to describe the +structure of the ``Product`` entity to Doctrine using a metadata +language. The metadata language describes how entities, their +properties and references should be persisted and what constraints +should be applied to them. + +Metadata for entities are configured using a XML, YAML or Docblock Annotations. +This Getting Started Guide will show the mappings for all Mapping Drivers. +References in the text will be made to the XML mapping. + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + + + + .. code-block:: yaml + + # config/yaml/Product.dcm.yml + Product: + type: entity + table: products + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + type: string + +The top-level ``entity`` definition tag specifies information about +the class and table-name. The primitive type ``Product::$name`` is +defined as ``field`` attributes. The Id property is defined with +the ``id`` tag. The id has a ``generator`` tag nested inside which +defines that the primary key generation mechanism automatically +uses the database platforms native id generation strategy, for +example AUTO INCREMENT in the case of MySql or Sequences in the +case of PostgreSql and Oracle. + +You have to update the database now, because we have a first Entity now: + +:: + + $ php vendor/bin/doctrine orm:schema-tool:update --force --dump-sql + +Specifying both flags ``--force`` and ``-dump-sql`` prints and executes the DDL +statements. + +Now create a new script that will insert products into the database: + +.. code-block:: php + + setName($newProductName); + + $entityManager->persist($product); + $entityManager->flush(); + + echo "Created Product with ID " . $product->getId() . "\n"; + +Call this script from the command line to see how new products are created: + +:: + + $ php create_product.php ORM + $ php create_product.php DBAL + +What is happening here? Using the ``Product`` is pretty standard OOP. +The interesting bits are the use of the ``EntityManager`` service. To +notify the EntityManager that a new entity should be inserted into the database +you have to call ``persist()``. To intiate a transaction to actually perform +the insertion, You have to explicitly call ``flush()`` on the ``EntityManager``. + +This distinction between persist and flush is allows to aggregate all writes +(INSERT, UPDATE, DELETE) into one single transaction, which is executed when +flush is called. Using this approach the write-performance is significantly +better than in a scenario where updates are done for each entity in isolation. + +Doctrine follows the UnitOfWork pattern which additionally detects all entities +that were fetched and have changed during the request. You don't have to keep track of +entities yourself, when Doctrine already knowns about them. + +As a next step we want to fetch a list of all the products. Let's create a +new script for this: + +.. code-block:: php + + getRepository('Product'); + $products = $productRepository->findAll(); + + foreach ($products as $product) { + echo sprintf("-%s\n", $product->getName()); + } + +The ``EntityManager#getRepository()`` method can create a finder object (called +repository) for every entity. It is provided by Doctrine and contains some +finder methods such as ``findAll()``. + +Let's continue with displaying the name of a product based on its ID: + +.. code-block:: php + + + require_once "bootstrap.php"; + + $id = $argv[1]; + $product = $entityManager->find('Product', $id); + + if ($product === null) { + echo "No product found.\n"; + exit(1); + } + + echo sprintf("-%s\n", $product->getName()); + +Updating a product name demonstrates the functionality UnitOfWork of pattern +discussed before. We only need to find a product entity and all changes to its +properties are written to the database: + +.. code-block:: php + + + require_once "bootstrap.php"; + + $id = $argv[1]; + $newName = $argv[2]; + + $product = $entityManager->find('Product', $id); + + if ($product === null) { + echo "Product $id does not exist.\n"; + exit(1); + } + + $product->setName($newName); + + $entityManager->flush(); + +After calling this script on one of the existing products, you can verify the +product name changed by calling the ``show_product.php`` script. + +Adding Bug and User Entities +---------------------------- + +We continue with the bug tracker domain, by creating the missing classes +``Bug`` and ``User`` and putting them into ``src/Bug.php`` and +``src/User.php`` respectively. + +.. code-block:: php + + id; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + } + + public function setCreated(DateTime $created) + { + $this->created = $created; + } + + public function getCreated() + { + return $this->created; + } + + public function setStatus($status) + { + $this->status = $status; + } + + public function getStatus() + { + return $this->status; + } + } + +.. code-block:: php + + id; + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + } + +All of the properties discussed so far are simple string and integer values, +for example the id fields of the entities, their names, description, status and +change dates. With just the scalar values this model cannot describe the dynamics that we want. We +want to model references between entities. + +References between objects are foreign keys in the database. You never have to +work with the foreign keys directly, only with objects that represent the +foreign key through their own identity. + +For every foreign key you either have a Doctrine ManyToOne or OneToOne +association. On the inverse sides of these foreign keys you can have +OneToMany associations. Obviously you can have ManyToMany associations +that connect two tables with each other through a join table with +two foreign keys. + +Now that you know the basics about references in Doctrine, we can extend the +domain model to match the requirements: + +.. code-block:: php + + products = new ArrayCollection(); + } + } + +.. code-block:: php + + reportedBugs = new ArrayCollection(); + $this->assignedBugs = new ArrayCollection(); + } + } + +Whenever an entity is recreated from the database, an Collection +implementation of the type Doctrine is injected into your entity +instead of an array. Compared to the ArrayCollection this +implementation helps the Doctrine ORM understand the changes that +have happened to the collection which are noteworthy for +persistence. + +.. warning:: + + Lazy load proxies always contain an instance of + Doctrine's EntityManager and all its dependencies. Therefore a + var\_dump() will possibly dump a very large recursive structure + which is impossible to render and read. You have to use + ``Doctrine\Common\Util\Debug::dump()`` to restrict the dumping to a + human readable level. Additionally you should be aware that dumping + the EntityManager to a Browser may take several minutes, and the + Debug::dump() method just ignores any occurrences of it in Proxy + instances. + +Because we only work with collections for the references we must be +careful to implement a bidirectional reference in the domain model. +The concept of owning or inverse side of a relation is central to +this notion and should always be kept in mind. The following +assumptions are made about relations and have to be followed to be +able to work with Doctrine 2. These assumptions are not unique to +Doctrine 2 but are best practices in handling database relations +and Object-Relational Mapping. + + +- Changes to Collections are saved or updated, when the entity on + the *owning* side of the collection is saved or updated. +- Saving an Entity at the inverse side of a relation never + triggers a persist operation to changes to the collection. +- In a one-to-one relation the entity holding the foreign key of + the related entity on its own database table is *always* the owning + side of the relation. +- In a many-to-many relation, both sides can be the owning side of + the relation. However in a bi-directional many-to-many relation + only one is allowed to be. +- In a many-to-one relation the Many-side is the owning side by + default, because it holds the foreign key. +- The OneToMany side of a relation is inverse by default, since + the foreign key is saved on the Many side. A OneToMany relation can + only be the owning side, if its implemented using a ManyToMany + relation with join table and restricting the one side to allow only + UNIQUE values per database constraint. + +.. note:: + + Consistency of bi-directional references on the inverse side of a + relation have to be managed in userland application code. Doctrine + cannot magically update your collections to be consistent. + + +In the case of Users and Bugs we have references back and forth to +the assigned and reported bugs from a user, making this relation +bi-directional. We have to change the code to ensure consistency of +the bi-directional reference: + +.. code-block:: php + + assignedToBug($this); + $this->engineer = $engineer; + } + + public function setReporter($reporter) + { + $reporter->addReportedBug($this); + $this->reporter = $reporter; + } + + public function getEngineer() + { + return $this->engineer; + } + + public function getReporter() + { + return $this->reporter; + } + } + +.. code-block:: php + + reportedBugs[] = $bug; + } + + public function assignedToBug($bug) + { + $this->assignedBugs[] = $bug; + } + } + +I chose to name the inverse methods in past-tense, which should +indicate that the actual assigning has already taken place and the +methods are only used for ensuring consistency of the references. +This approach is my personal preference, you can choose whatever +method to make this work. + +You can see from ``User::addReportedBug()`` and +``User::assignedToBug()`` that using this method in userland alone +would not add the Bug to the collection of the owning side in +``Bug::$reporter`` or ``Bug::$engineer``. Using these methods and +calling Doctrine for persistence would not update the collections +representation in the database. + +Only using ``Bug::setEngineer()`` or ``Bug::setReporter()`` +correctly saves the relation information. We also set both +collection instance variables to protected, however with PHP 5.3's +new features Doctrine is still able to use Reflection to set and +get values from protected and private properties. + +The ``Bug::$reporter`` and ``Bug::$engineer`` properties are +Many-To-One relations, which point to a User. In a normalized +relational model the foreign key is saved on the Bug's table, hence +in our object-relation model the Bug is at the owning side of the +relation. You should always make sure that the use-cases of your +domain model should drive which side is an inverse or owning one in +your Doctrine mapping. In our example, whenever a new bug is saved +or an engineer is assigned to the bug, we don't want to update the +User to persist the reference, but the Bug. This is the case with +the Bug being at the owning side of the relation. + +Bugs reference Products by an uni-directional ManyToMany relation in +the database that points from Bugs to Products. + +.. code-block:: php + + products[] = $product; + } + + public function getProducts() + { + return $this->products; + } + } + +We are now finished with the domain model given the requirements. +Now we continue adding metadata mappings for the ``User`` and ``Bug`` +as we did for the ``Product`` before: + +.. configuration-block:: + .. code-block:: php + + + + + + + + + + + + + + + + + + + + + .. code-block:: yaml + + # config/yaml/Bug.dcm.yml + Bug: + type: entity + table: bugs + id: + id: + type: integer + generator: + strategy: AUTO + fields: + description: + type: text + created: + type: datetime + status: + type: string + manyToOne: + reporter: + targetEntity: User + inversedBy: reportedBugs + engineer: + targetEntity: User + inversedBy: assignedBugs + manyToMany: + products: + targetEntity: Product + + +Here we have the entity, id and primitive type definitions. +The column names are used from the Zend\_Db\_Table examples and +have different names than the properties on the Bug class. +Additionally for the "created" field it is specified that it is of +the Type "DATETIME", which translates the YYYY-mm-dd HH:mm:ss +Database format into a PHP DateTime instance and back. + +After the field definitions the two qualified references to the +user entity are defined. They are created by the ``many-to-one`` +tag. The class name of the related entity has to be specified with +the ``target-entity`` attribute, which is enough information for +the database mapper to access the foreign-table. Since +``reporter`` and ``engineer`` are on the owning side of a +bi-directional relation we also have to specify the ``inversed-by`` +attribute. They have to point to the field names on the inverse +side of the relationship. We will see in the next example that the ``inversed-by`` +attribute has a counterpart ``mapped-by`` which makes that +the inverse side. + +The last missing property is the ``Bug::$products`` collection. It +holds all products where the specific bug is occurring in. Again +you have to define the ``target-entity`` and ``field`` attributes +on the ``many-to-many`` tag. Furthermore you have to specify the +details of the many-to-many join-table and its foreign key columns. +The definition is rather complex, however relying on the XML +auto-completion I got it working easily, although I forget the +schema details all the time. + +The last missing definition is that of the User entity: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + + + + + + + .. code-block:: yaml + + # config/xml/User.dcm.yml + User: + type: entity + table: users + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + type: string + oneToMany: + reportedBugs: + targetEntity: Bug + mappedBy: reporter + assignedBugs: + targetEntity: Bug + mappedBy: engineer + +Here are some new things to mention about the ``one-to-many`` tags. +Remember that we discussed about the inverse and owning side. Now +both reportedBugs and assignedBugs are inverse relations, which +means the join details have already been defined on the owning +side. Therefore we only have to specify the property on the Bug +class that holds the owning sides. + +This example has a fair overview of the most basic features of the +metadata definition language. + +Implementing more Requirements +------------------------------ + +For starters we need a create user entities: + +.. code-block:: php + + setName($newUsername); + + $entityManager->persist($user); + $entityManager->flush(); + + echo "Created User with ID " . $user->getId() . "\n"; + +Now call: + +:: + + $ php create_user.php beberlei + +We now have the data to create a bug and the code for this scenario may look +like this: + +.. code-block:: php + + find("User", $theReporterId); + $engineer = $entityManager->find("User", $theDefaultEngineerId); + if (!$reporter || !$engineer) { + echo "No reporter and/or engineer found for the input.\n"; + exit(1); + } + + $bug = new Bug(); + $bug->setDescription("Something does not work!"); + $bug->setCreated(new DateTime("now")); + $bug->setStatus("OPEN"); + + foreach ($productIds AS $productId) { + $product = $entityManager->find("Product", $productId); + $bug->assignToProduct($product); + } + + $bug->setReporter($reporter); + $bug->setEngineer($engineer); + + $entityManager->persist($bug); + $entityManager->flush(); + + echo "Your new Bug Id: ".$bug->getId()."\n"; + +Since we only have one user and product, probably with the ID of 1, we can call this script with: + +:: + + php create_bug.php 1 1 1 + +This is the first contact with the read API of the EntityManager, +showing that a call to ``EntityManager#find($name, $id)`` returns a +single instance of an entity queried by primary key. Besides this +we see the persist + flush pattern again to save the Bug into the +database. + +See how simple relating Bug, Reporter, Engineer and Products is +done by using the discussed methods in the "A first prototype" +section. The UnitOfWork will detect this relations when flush is +called and relate them in the database appropriately. + +Queries for Application Use-Cases +--------------------------------- + +List of Bugs +~~~~~~~~~~~~ + +Using the previous examples we can fill up the database quite a +bit, however we now need to discuss how to query the underlying +mapper for the required view representations. When opening the +application, bugs can be paginated through a list-view, which is +the first read-only use-case: + +.. code-block:: php + + createQuery($dql); + $query->setMaxResults(30); + $bugs = $query->getResult(); + + foreach($bugs AS $bug) { + echo $bug->getDescription()." - ".$bug->getCreated()->format('d.m.Y')."\n"; + echo " Reported by: ".$bug->getReporter()->getName()."\n"; + echo " Assigned to: ".$bug->getEngineer()->getName()."\n"; + foreach($bug->getProducts() AS $product) { + echo " Platform: ".$product->getName()."\n"; + } + echo "\n"; + } + +The DQL Query in this example fetches the 30 most recent bugs with +their respective engineer and reporter in one single SQL statement. +The console output of this script is then: + +:: + + Something does not work! - 02.04.2010 + Reported by: beberlei + Assigned to: beberlei + Platform: My Product + +.. note:: + + **Dql is not Sql** + + You may wonder why we start writing SQL at the beginning of this + use-case. Don't we use an ORM to get rid of all the endless + hand-writing of SQL? Doctrine introduces DQL which is best + described as **object-query-language** and is a dialect of + `OQL `_ and + similar to `HQL `_ or + `JPQL `_. + It does not know the concept of columns and tables, but only those + of Entity-Class and property. Using the Metadata we defined before + it allows for very short distinctive and powerful queries. + + An important reason why DQL is favourable to the Query API of most + ORMs is its similarity to SQL. The DQL language allows query + constructs that most ORMs don't, GROUP BY even with HAVING, + Sub-selects, Fetch-Joins of nested classes, mixed results with + entities and scalar data such as COUNT() results and much more. + Using DQL you should seldom come to the point where you want to + throw your ORM into the dumpster, because it doesn't support some + the more powerful SQL concepts. + + Besides handwriting DQL you can however also use the + ``QueryBuilder`` retrieved by calling + ``$entityManager->createQueryBuilder()`` which is a Query Object + around the DQL language. + + As a last resort you can however also use Native SQL and a + description of the result set to retrieve entities from the + database. DQL boils down to a Native SQL statement and a + ``ResultSetMapping`` instance itself. Using Native SQL you could + even use stored procedures for data retrieval, or make use of + advanced non-portable database queries like PostgreSql's recursive + queries. + + +Array Hydration of the Bug List +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In the previous use-case we retrieved the result as their +respective object instances. We are not limited to retrieving +objects only from Doctrine however. For a simple list view like the +previous one we only need read access to our entities and can +switch the hydration from objects to simple PHP arrays instead. +This can obviously yield considerable performance benefits for +read-only requests. + +Implementing the same list view as before using array hydration we +can rewrite our code: + +.. code-block:: php + + createQuery($dql); + $bugs = $query->getArrayResult(); + + foreach ($bugs AS $bug) { + echo $bug['description'] . " - " . $bug['created']->format('d.m.Y')."\n"; + echo " Reported by: ".$bug['reporter']['name']."\n"; + echo " Assigned to: ".$bug['engineer']['name']."\n"; + foreach($bug['products'] AS $product) { + echo " Platform: ".$product['name']."\n"; + } + echo "\n"; + } + +There is one significant difference in the DQL query however, we +have to add an additional fetch-join for the products connected to +a bug. The resulting SQL query for this single select statement is +pretty large, however still more efficient to retrieve compared to +hydrating objects. + +Find by Primary Key +~~~~~~~~~~~~~~~~~~~ + +The next Use-Case is displaying a Bug by primary key. This could be +done using DQL as in the previous example with a where clause, +however there is a convenience method on the ``EntityManager`` that +handles loading by primary key, which we have already seen in the +write scenarios: + +.. code-block:: php + + find("Bug", (int)$theBugId); + + echo "Bug: ".$bug->getDescription()."\n"; + echo "Engineer: ".$bug->getEngineer()->getName()."\n"; + +The output of the engineers name is fetched from the database! What is happening? + +Since we only retrieved the bug by primary key both the engineer and reporter +are not immediately loaded from the database but are replaced by LazyLoading +proxies. These proxies will load behind the scenes, when the first method +is called on them. + +Sample code of this proxy generated code can be found in the specified Proxy +Directory, it looks like: + +.. code-block:: php + + _load(); + return parent::addReportedBug($bug); + } + + public function assignedToBug($bug) + { + $this->_load(); + return parent::assignedToBug($bug); + } + } + +See how upon each method call the proxy is lazily loaded from the +database? + +The call prints: + +:: + + $ php show_bug.php 1 + Bug: Something does not work! + Engineer: beberlei + +Dashboard of the User +--------------------- + +For the next use-case we want to retrieve the dashboard view, a +list of all open bugs the user reported or was assigned to. This +will be achieved using DQL again, this time with some WHERE clauses +and usage of bound parameters: + +.. code-block:: php + + createQuery($dql) + ->setParameter(1, $theUserId) + ->setMaxResults(15) + ->getResult(); + + echo "You have created or assigned to " . count($myBugs) . " open bugs:\n\n"; + + foreach ($myBugs AS $bug) { + echo $bug->getId() . " - " . $bug->getDescription()."\n"; + } + +Number of Bugs +-------------- + +Until now we only retrieved entities or their array representation. +Doctrine also supports the retrieval of non-entities through DQL. +These values are called "scalar result values" and may even be +aggregate values using COUNT, SUM, MIN, MAX or AVG functions. + +We will need this knowledge to retrieve the number of open bugs +grouped by product: + +.. code-block:: php + + createQuery($dql)->getScalarResult(); + + foreach($productBugs as $productBug) { + echo $productBug['name']." has " . $productBug['openBugs'] . " open bugs!\n"; + } + +Updating Entities +----------------- + +There is a single use-case missing from the requirements, Engineers +should be able to close a bug. This looks like: + +.. code-block:: php + + status = "CLOSE"; + } + } + +.. code-block:: php + + find("Bug", (int)$theBugId); + $bug->close(); + + $entityManager->flush(); + +When retrieving the Bug from the database it is inserted into the +IdentityMap inside the UnitOfWork of Doctrine. This means your Bug +with exactly this id can only exist once during the whole request +no matter how often you call ``EntityManager#find()``. It even +detects entities that are hydrated using DQL and are already +present in the Identity Map. + +When flush is called the EntityManager loops over all the entities +in the identity map and performs a comparison between the values +originally retrieved from the database and those values the entity +currently has. If at least one of these properties is different the +entity is scheduled for an UPDATE against the database. Only the +changed columns are updated, which offers a pretty good performance +improvement compared to updating all the properties. + +Entity Repositories +------------------- + +For now we have not discussed how to separate the Doctrine query logic from your model. +In Doctrine 1 there was the concept of ``Doctrine_Table`` instances for this +separation. The similar concept in Doctrine2 is called Entity Repositories, integrating +the `repository pattern `_ at the heart of Doctrine. + +Every Entity uses a default repository by default and offers a bunch of convenience +methods that you can use to query for instances of that Entity. Take for example +our Product entity. If we wanted to Query by name, we can use: + +.. code-block:: php + + getRepository('Product') + ->findOneBy(array('name' => $productName)); + +The method ``findOneBy()`` takes an array of fields or association keys and the values to match against. + +If you want to find all entities matching a condition you can use ``findBy()``, for +example querying for all closed bugs: + +.. code-block:: php + + getRepository('Bug') + ->findBy(array('status' => 'CLOSED')); + + foreach ($bugs AS $bug) { + // do stuff + } + +Compared to DQL these query methods are falling short of functionality very fast. +Doctrine offers you a convenient way to extend the functionalities of the default ``EntityRepository`` +and put all the specialized DQL query logic on it. For this you have to create a subclass +of ``Doctrine\ORM\EntityRepository``, in our case a ``BugRepository`` and group all +the previously discussed query functionality in it: + +.. code-block:: php + + getEntityManager()->createQuery($dql); + $query->setMaxResults($number); + return $query->getResult(); + } + + public function getRecentBugsArray($number = 30) + { + $dql = "SELECT b, e, r, p FROM Bug b JOIN b.engineer e ". + "JOIN b.reporter r JOIN b.products p ORDER BY b.created DESC"; + $query = $this->getEntityManager()->createQuery($dql); + $query->setMaxResults($number); + return $query->getArrayResult(); + } + + public function getUsersBugs($userId, $number = 15) + { + $dql = "SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter r ". + "WHERE b.status = 'OPEN' AND e.id = ?1 OR r.id = ?1 ORDER BY b.created DESC"; + + return $this->getEntityManager()->createQuery($dql) + ->setParameter(1, $userId) + ->setMaxResults($number) + ->getResult(); + } + + public function getOpenBugsByProduct() + { + $dql = "SELECT p.id, p.name, count(b.id) AS openBugs FROM Bug b ". + "JOIN b.products p WHERE b.status = 'OPEN' GROUP BY p.id"; + return $this->getEntityManager()->createQuery($dql)->getScalarResult(); + } + } + +Don't forget to add a `require_once` call for this class to the bootstrap.php + +To be able to use this query logic through ``$this->getEntityManager()->getRepository('Bug')`` +we have to adjust the metadata slightly. + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + .. code-block:: yaml + + Bug: + type: entity + repositoryClass: BugRepository + +Now we can remove our query logic in all the places and instead use them through the EntityRepository. +As an example here is the code of the first use case "List of Bugs": + +.. code-block:: php + + getRepository('Bug')->getRecentBugs(); + + foreach($bugs AS $bug) { + echo $bug->getDescription()." - ".$bug->getCreated()->format('d.m.Y')."\n"; + echo " Reported by: ".$bug->getReporter()->getName()."\n"; + echo " Assigned to: ".$bug->getEngineer()->getName()."\n"; + foreach($bug->getProducts() AS $product) { + echo " Platform: ".$product->getName()."\n"; + } + echo "\n"; + } + +Using EntityRepositories you can avoid coupling your model with specific query logic. +You can also re-use query logic easily throughout your application. + +Conclusion +---------- + +This tutorial is over here, I hope you had fun. Additional content +will be added to this tutorial incrementally, topics will include: + +- More on Association Mappings +- Lifecycle Events triggered in the UnitOfWork +- Ordering of Collections + +Additional details on all the topics discussed here can be found in +the respective manual chapters. + diff --git a/vendor/doctrine/orm/docs/en/tutorials/ordered-associations.rst b/vendor/doctrine/orm/docs/en/tutorials/ordered-associations.rst new file mode 100644 index 0000000000..121bd145d5 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/tutorials/ordered-associations.rst @@ -0,0 +1,110 @@ +Ordering To-Many Associations +----------------------------- + +There are use-cases when you'll want to sort collections when they are +retrieved from the database. In userland you do this as long as you +haven't initially saved an entity with its associations into the +database. To retrieve a sorted collection from the database you can +use the ``@OrderBy`` annotation with an collection that specifies +an DQL snippet that is appended to all queries with this +collection. + +Additional to any ``@OneToMany`` or ``@ManyToMany`` annotation you +can specify the ``@OrderBy`` in the following way: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + + .. code-block:: yaml + + User: + type: entity + manyToMany: + groups: + orderBy: { 'name': 'ASC' } + targetEntity: Group + joinTable: + name: users_groups + joinColumns: + user_id: + referencedColumnName: id + inverseJoinColumns: + group_id: + referencedColumnName: id + +The DQL Snippet in OrderBy is only allowed to consist of +unqualified, unquoted field names and of an optional ASC/DESC +positional statement. Multiple Fields are separated by a comma (,). +The referenced field names have to exist on the ``targetEntity`` +class of the ``@ManyToMany`` or ``@OneToMany`` annotation. + +The semantics of this feature can be described as follows. + + +- ``@OrderBy`` acts as an implicit ORDER BY clause for the given + fields, that is appended to all the explicitly given ORDER BY + items. +- All collections of the ordered type are always retrieved in an + ordered fashion. +- To keep the database impact low, these implicit ORDER BY items + are only added to an DQL Query if the collection is fetch joined in + the DQL query. + +Given our previously defined example, the following would not add +ORDER BY, since g is not fetch joined: + +.. code-block:: sql + + SELECT u FROM User u JOIN u.groups g WHERE SIZE(g) > 10 + +However the following: + +.. code-block:: sql + + SELECT u, g FROM User u JOIN u.groups g WHERE u.id = 10 + +...would internally be rewritten to: + +.. code-block:: sql + + SELECT u, g FROM User u JOIN u.groups g WHERE u.id = 10 ORDER BY g.name ASC + +You can reverse the order with an explicit DQL ORDER BY: + +.. code-block:: sql + + SELECT u, g FROM User u JOIN u.groups g WHERE u.id = 10 ORDER BY g.name DESC + +...is internally rewritten to: + +.. code-block:: sql + + SELECT u, g FROM User u JOIN u.groups g WHERE u.id = 10 ORDER BY g.name DESC, g.name ASC + + diff --git a/vendor/doctrine/orm/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst b/vendor/doctrine/orm/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst new file mode 100644 index 0000000000..792d978871 --- /dev/null +++ b/vendor/doctrine/orm/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst @@ -0,0 +1,90 @@ +Override Field Association Mappings In Subclasses +------------------------------------------------- + +Sometimes there is a need to persist entities but override all or part of the +mapping metadata. Sometimes also the mapping to override comes from entities +using traits where the traits have mapping metadata. +This tutorial explains how to override mapping metadata, +i.e. attributes and associations metadata in particular. The example here shows +the overriding of a class that uses a trait but is similar when extending a base +class as shown at the end of this tutorial. + +Suppose we have a class ExampleEntityWithOverride. This class uses trait ExampleTrait: + +.. code-block:: php + + createQuery($dql) + ->setFirstResult(0) + ->setMaxResults(100); + + $paginator = new Paginator($query, $fetchJoinCollection = true); + + $c = count($paginator); + foreach ($paginator as $post) { + echo $post->getHeadline() . "\n"; + } + +Paginating Doctrine queries is not as simple as you might think in the +beginning. If you have complex fetch-join scenarios with one-to-many or +many-to-many associations using the "default" LIMIT functionality of database +vendors is not sufficient to get the correct results. + +By default the pagination extension does the following steps to compute the +correct result: + +- Perform a Count query using `DISTINCT` keyword. +- Perform a Limit Subquery with `DISTINCT` to find all ids of the entity in from on the current page. +- Perform a WHERE IN query to get all results for the current page. + +This behavior is only necessary if you actually fetch join a to-many +collection. You can disable this behavior by setting the +``$fetchJoinCollection`` flag to ``false``; in that case only 2 instead of the 3 queries +described are executed. We hope to automate the detection for this in +the future. diff --git a/vendor/doctrine/orm/docs/en/tutorials/working-with-indexed-associations.rst b/vendor/doctrine/orm/docs/en/tutorials/working-with-indexed-associations.rst new file mode 100644 index 0000000000..3536a34f8e --- /dev/null +++ b/vendor/doctrine/orm/docs/en/tutorials/working-with-indexed-associations.rst @@ -0,0 +1,298 @@ +Working with Indexed Associations +================================= + +.. note:: + + This feature is scheduled for version 2.1 of Doctrine and not included in the 2.0.x series. + +Doctrine 2 collections are modelled after PHPs native arrays. PHP arrays are an ordered hashmap, but in +the first version of Doctrine keys retrieved from the database were always numerical unless ``INDEX BY`` +was used. Starting with Doctrine 2.1 you can index your collections by a value in the related entity. +This is a first step towards full ordered hashmap support through the Doctrine ORM. +The feature works like an implicit ``INDEX BY`` for the selected association but has several +downsides also: + +- You have to manage both the key and field if you want to change the index by field value. +- On each request the keys are regenerated from the field value not from the previous collection key. +- Values of the Index-By keys are never considered during persistence, it only exists for accessing purposes. +- Fields that are used for the index by feature **HAVE** to be unique in the database. The behavior for multiple entities + with the same index-by field value is undefined. + +As an example we will design a simple stock exchange list view. The domain consists of the entity ``Stock`` +and ``Market`` where each Stock has a symbol and is traded on a single market. Instead of having a numerical +list of stocks traded on a market they will be indexed by their symbol, which is unique across all markets. + +Mapping Indexed Associations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can map indexed associations by adding: + + * ``indexBy`` attribute to any ``@OneToMany`` or ``@ManyToMany`` annotation. + * ``index-by`` attribute to any ```` or ```` xml element. + * ``indexBy:`` key-value pair to any association defined in ``manyToMany:`` or ``oneToMany:`` YAML mapping files. + +The code and mappings for the Market entity looks like this: + +.. configuration-block:: + .. code-block:: php + + name = $name; + $this->stocks = new ArrayCollection(); + } + + public function getId() + { + return $this->id; + } + + public function getName() + { + return $this->name; + } + + public function addStock(Stock $stock) + { + $this->stocks[$stock->getSymbol()] = $stock; + } + + public function getStock($symbol) + { + if (!isset($this->stocks[$symbol])) { + throw new \InvalidArgumentException("Symbol is not traded on this market."); + } + + return $this->stocks[$symbol]; + } + + public function getStocks() + { + return $this->stocks->toArray(); + } + } + + .. code-block:: xml + + + + + + + + + + + + + + + + .. code-block:: yaml + + Doctrine\Tests\Models\StockExchange\Market: + type: entity + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + type:string + oneToMany: + stocks: + targetEntity: Stock + mappedBy: market + indexBy: symbol + +Inside the ``addStock()`` method you can see how we directly set the key of the association to the symbol, +so that we can work with the indexed association directly after invoking ``addStock()``. Inside ``getStock($symbol)`` +we pick a stock traded on the particular market by symbol. If this stock doesn't exist an exception is thrown. + +The ``Stock`` entity doesn't contain any special instructions that are new, but for completeness +here are the code and mappings for it: + +.. configuration-block:: + .. code-block:: php + + symbol = $symbol; + $this->market = $market; + $market->addStock($this); + } + + public function getSymbol() + { + return $this->symbol; + } + } + + .. code-block:: xml + + + + + + + + + + + + + + + .. code-block:: yaml + + Doctrine\Tests\Models\StockExchange\Stock: + type: entity + id: + id: + type: integer + generator: + strategy: AUTO + fields: + symbol: + type: string + manyToOne: + market: + targetEntity: Market + inversedBy: stocks + +Querying indexed associations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Now that we defined the stocks collection to be indexed by symbol we can take a look at some code, +that makes use of the indexing. + +First we will populate our database with two example stocks traded on a single market: + +.. code-block:: php + + persist($market); + $em->persist($stock1); + $em->persist($stock2); + $em->flush(); + +This code is not particular interesting since the indexing feature is not yet used. In a new request we could +now query for the market: + +.. code-block:: php + + find("Doctrine\Tests\Models\StockExchange\Market", $marketId); + + // Access the stocks by symbol now: + $stock = $market->getStock($symbol); + + echo $stock->getSymbol(); // will print "AAPL" + +The implementation ``Market::addStock()`` in combination with ``indexBy`` allows to access the collection +consistently by the Stock symbol. It does not matter if Stock is managed by Doctrine or not. + +The same applies to DQL queries: The ``indexBy`` configuration acts as implicit "INDEX BY" to a join association. + +.. code-block:: php + + createQuery($dql) + ->setParameter(1, $marketId) + ->getSingleResult(); + + // Access the stocks by symbol now: + $stock = $market->getStock($symbol); + + echo $stock->getSymbol(); // will print "AAPL" + +If you want to use ``INDEX BY`` explicitly on an indexed association you are free to do so. Additionally +indexed associations also work with the ``Collection::slice()`` functionality, no matter if marked as +LAZY or EXTRA_LAZY. + +Outlook into the Future +~~~~~~~~~~~~~~~~~~~~~~~ + +For the inverse side of a many-to-many associations there will be a way to persist the keys and the order +as a third and fourth parameter into the join table. This feature is discussed in `DDC-213 `_ +This feature cannot be implemented for One-To-Many associations, because they are never the owning side. + diff --git a/vendor/doctrine/orm/doctrine-mapping.xsd b/vendor/doctrine/orm/doctrine-mapping.xsd old mode 100755 new mode 100644 index 3a27867bcc..f9c774d572 --- a/vendor/doctrine/orm/doctrine-mapping.xsd +++ b/vendor/doctrine/orm/doctrine-mapping.xsd @@ -37,6 +37,7 @@ + @@ -51,6 +52,7 @@ + @@ -85,8 +87,11 @@ + + + + - @@ -94,7 +99,21 @@ - + + + + + + + + + + + + + + + @@ -112,20 +131,24 @@ + - - - + + + + + + + - @@ -137,8 +160,10 @@ + + @@ -205,6 +230,7 @@ + @@ -364,7 +390,7 @@ - + @@ -489,7 +515,7 @@ - + @@ -505,16 +531,33 @@ - + - - + + + + + + + + + + + + + + + + + + + diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php b/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php old mode 100755 new mode 100644 index ab10395a7e..07b6b9ea95 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php @@ -26,7 +26,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\ORM\Query\QueryException; -use Doctrine\ORM\Mapping; +use Doctrine\ORM\ORMInvalidArgumentException; /** * Base contract for ORM queries. Base class for Query and NativeQuery. @@ -42,18 +42,22 @@ use Doctrine\ORM\Mapping; abstract class AbstractQuery { /* Hydration mode constants */ + /** * Hydrates an object graph. This is the default behavior. */ const HYDRATE_OBJECT = 1; + /** * Hydrates an array graph. */ const HYDRATE_ARRAY = 2; + /** * Hydrates a flat, rectangular result set with scalar values. */ const HYDRATE_SCALAR = 3; + /** * Hydrates a single scalar value. */ @@ -65,27 +69,37 @@ abstract class AbstractQuery const HYDRATE_SIMPLEOBJECT = 5; /** - * @var \Doctrine\Common\Collections\ArrayCollection The parameter map of this query. + * The parameter map of this query. + * + * @var \Doctrine\Common\Collections\ArrayCollection */ protected $parameters; /** - * @var ResultSetMapping The user-specified ResultSetMapping to use. + * The user-specified ResultSetMapping to use. + * + * @var \Doctrine\ORM\Query\ResultSetMapping */ protected $_resultSetMapping; /** - * @var \Doctrine\ORM\EntityManager The entity manager used by this query object. + * The entity manager used by this query object. + * + * @var \Doctrine\ORM\EntityManager */ protected $_em; /** - * @var array The map of query hints. + * The map of query hints. + * + * @var array */ protected $_hints = array(); /** - * @var integer The hydration mode. + * The hydration mode. + * + * @var integer */ protected $_hydrationMode = self::HYDRATE_OBJECT; @@ -95,7 +109,9 @@ abstract class AbstractQuery protected $_queryCacheProfile; /** - * @var boolean Boolean value that indicates whether or not expire the result cache. + * Whether or not expire the result cache. + * + * @var boolean */ protected $_expireResultCache = false; @@ -107,7 +123,7 @@ abstract class AbstractQuery /** * Initializes a new instance of a class derived from AbstractQuery. * - * @param \Doctrine\ORM\EntityManager $entityManager + * @param \Doctrine\ORM\EntityManager $em */ public function __construct(EntityManager $em) { @@ -208,11 +224,11 @@ abstract class AbstractQuery /** * Sets a query parameter. * - * @param string|integer $key The parameter position or name. - * @param mixed $value The parameter value. - * @param string $type The parameter type. If specified, the given value will be run through - * the type conversion of this type. This is usually not needed for - * strings and numeric types. + * @param string|int $key The parameter position or name. + * @param mixed $value The parameter value. + * @param string|null $type The parameter type. If specified, the given value will be run through + * the type conversion of this type. This is usually not needed for + * strings and numeric types. * * @return \Doctrine\ORM\AbstractQuery This query instance. */ @@ -241,54 +257,35 @@ abstract class AbstractQuery } /** - * Process an individual parameter value + * Processes an individual parameter value. * * @param mixed $value + * * @return array + * + * @throws ORMInvalidArgumentException */ public function processParameterValue($value) { - switch (true) { - case is_array($value): - foreach ($value as $key => $paramValue) { - $paramValue = $this->processParameterValue($paramValue); - $value[$key] = is_array($paramValue) ? $paramValue[key($paramValue)] : $paramValue; - } + if (is_array($value)) { + foreach ($value as $key => $paramValue) { + $paramValue = $this->processParameterValue($paramValue); + $value[$key] = is_array($paramValue) ? reset($paramValue) : $paramValue; + } - return $value; - - case is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value)): - return $this->convertObjectParameterToScalarValue($value); - - case ($value instanceof Mapping\ClassMetadata): - return $value->name; - - default: - return $value; - } - } - - private function convertObjectParameterToScalarValue($value) - { - $class = $this->_em->getClassMetadata(get_class($value)); - - if ($class->isIdentifierComposite) { - throw new \InvalidArgumentException( - "Binding an entity with a composite primary key to a query is not supported. " . - "You should split the parameter into the explicit fields and bind them seperately." - ); + return $value; } - $values = ($this->_em->getUnitOfWork()->getEntityState($value) === UnitOfWork::STATE_MANAGED) - ? $this->_em->getUnitOfWork()->getEntityIdentifier($value) - : $class->getIdentifierValues($value); + if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) { + $value = $this->_em->getUnitOfWork()->getSingleIdentifierValue($value); - $value = $values[$class->getSingleIdentifierFieldName()]; + if ($value === null) { + throw ORMInvalidArgumentException::invalidIdentifierBindingEntity(); + } + } - if (null === $value) { - throw new \InvalidArgumentException( - "Binding entities to query parameters only allowed for entities that have an identifier." - ); + if ($value instanceof Mapping\ClassMetadata) { + return $value->name; } return $value; @@ -297,16 +294,37 @@ abstract class AbstractQuery /** * Sets the ResultSetMapping that should be used for hydration. * - * @param ResultSetMapping $rsm + * @param \Doctrine\ORM\Query\ResultSetMapping $rsm + * * @return \Doctrine\ORM\AbstractQuery */ public function setResultSetMapping(Query\ResultSetMapping $rsm) { + $this->translateNamespaces($rsm); $this->_resultSetMapping = $rsm; return $this; } + /** + * Allows to translate entity namespaces to full qualified names. + * + * @param Query\ResultSetMapping $rsm + * + * @return void + */ + private function translateNamespaces(Query\ResultSetMapping $rsm) + { + $entityManager = $this->_em; + + $translate = function ($alias) use ($entityManager) { + return $entityManager->getClassMetadata($alias)->getName(); + }; + + $rsm->aliasMap = array_map($translate, $rsm->aliasMap); + $rsm->declaringClasses = array_map($translate, $rsm->declaringClasses); + } + /** * Set a cache profile for hydration caching. * @@ -326,6 +344,7 @@ abstract class AbstractQuery * $query->setHydrationCacheProfile(new QueryCacheProfile($lifetime, $resultKey)); * * @param \Doctrine\DBAL\Cache\QueryCacheProfile $profile + * * @return \Doctrine\ORM\AbstractQuery */ public function setHydrationCacheProfile(QueryCacheProfile $profile = null) @@ -355,6 +374,7 @@ abstract class AbstractQuery * result cache driver is used from the configuration. * * @param \Doctrine\DBAL\Cache\QueryCacheProfile $profile + * * @return \Doctrine\ORM\AbstractQuery */ public function setResultCacheProfile(QueryCacheProfile $profile = null) @@ -370,10 +390,13 @@ abstract class AbstractQuery } /** - * Defines a cache driver to be used for caching result sets and implictly enables caching. + * Defines a cache driver to be used for caching result sets and implicitly enables caching. + * + * @param \Doctrine\Common\Cache\Cache|null $resultCacheDriver Cache driver * - * @param \Doctrine\Common\Cache\Cache $driver Cache driver * @return \Doctrine\ORM\AbstractQuery + * + * @throws ORMException */ public function setResultCacheDriver($resultCacheDriver = null) { @@ -392,6 +415,7 @@ abstract class AbstractQuery * Returns the cache driver used for caching result sets. * * @deprecated + * * @return \Doctrine\Common\Cache\Cache Cache driver */ public function getResultCacheDriver() @@ -409,7 +433,8 @@ abstract class AbstractQuery * * @param boolean $bool * @param integer $lifetime - * @param string $resultCacheId + * @param string $resultCacheId + * * @return \Doctrine\ORM\AbstractQuery This query instance. */ public function useResultCache($bool, $lifetime = null, $resultCacheId = null) @@ -430,6 +455,7 @@ abstract class AbstractQuery * Defines how long the result cache will be active before expire. * * @param integer $lifetime How long the cache entry is valid. + * * @return \Doctrine\ORM\AbstractQuery This query instance. */ public function setResultCacheLifetime($lifetime) @@ -447,6 +473,7 @@ abstract class AbstractQuery * Retrieves the lifetime of resultset cache. * * @deprecated + * * @return integer */ public function getResultCacheLifetime() @@ -458,6 +485,7 @@ abstract class AbstractQuery * Defines if the result cache is active or not. * * @param boolean $expire Whether or not to force resultset cache expiration. + * * @return \Doctrine\ORM\AbstractQuery This query instance. */ public function expireResultCache($expire = true) @@ -490,9 +518,10 @@ abstract class AbstractQuery * * $fetchMode can be one of ClassMetadata::FETCH_EAGER or ClassMetadata::FETCH_LAZY * - * @param string $class - * @param string $assocName - * @param int $fetchMode + * @param string $class + * @param string $assocName + * @param int $fetchMode + * * @return AbstractQuery */ public function setFetchMode($class, $assocName, $fetchMode) @@ -511,6 +540,7 @@ abstract class AbstractQuery * * @param integer $hydrationMode Doctrine processing mode to be used during hydration process. * One of the Query::HYDRATE_* constants. + * * @return \Doctrine\ORM\AbstractQuery This query instance. */ public function setHydrationMode($hydrationMode) @@ -535,6 +565,8 @@ abstract class AbstractQuery * * Alias for execute(null, $hydrationMode = HYDRATE_OBJECT). * + * @param int $hydrationMode + * * @return array */ public function getResult($hydrationMode = self::HYDRATE_OBJECT) @@ -569,9 +601,11 @@ abstract class AbstractQuery /** * Get exactly one result or null. * - * @throws NonUniqueResultException * @param int $hydrationMode + * * @return mixed + * + * @throws NonUniqueResultException */ public function getOneOrNullResult($hydrationMode = null) { @@ -601,9 +635,11 @@ abstract class AbstractQuery * If there is no result, a NoResultException is thrown. * * @param integer $hydrationMode + * * @return mixed + * * @throws NonUniqueResultException If the query result is not unique. - * @throws NoResultException If the query returned no result. + * @throws NoResultException If the query returned no result. */ public function getSingleResult($hydrationMode = null) { @@ -630,6 +666,7 @@ abstract class AbstractQuery * Alias for getSingleResult(HYDRATE_SINGLE_SCALAR). * * @return mixed + * * @throws QueryException If the query result is not unique. */ public function getSingleScalarResult() @@ -640,8 +677,9 @@ abstract class AbstractQuery /** * Sets a query hint. If the hint name is not recognized, it is silently ignored. * - * @param string $name The name of the hint. - * @param mixed $value The value of the hint. + * @param string $name The name of the hint. + * @param mixed $value The value of the hint. + * * @return \Doctrine\ORM\AbstractQuery */ public function setHint($name, $value) @@ -655,6 +693,7 @@ abstract class AbstractQuery * Gets the value of a query hint. If the hint name is not recognized, FALSE is returned. * * @param string $name The name of the hint. + * * @return mixed The value of the hint or FALSE, if the hint name is not recognized. */ public function getHint($name) @@ -662,6 +701,18 @@ abstract class AbstractQuery return isset($this->_hints[$name]) ? $this->_hints[$name] : false; } + /** + * Check if the query has a hint + * + * @param string $name The name of the hint + * + * @return bool False if the query does not have any hint + */ + public function hasHint($name) + { + return isset($this->_hints[$name]); + } + /** * Return the key value map of query hints that are currently set. * @@ -676,8 +727,9 @@ abstract class AbstractQuery * Executes the query and returns an IterableResult that can be used to incrementally * iterate over the result. * - * @param \Doctrine\Common\Collections\ArrayCollection|array $parameters The query parameters. - * @param integer $hydrationMode The hydration mode to use. + * @param ArrayCollection|array|null $parameters The query parameters. + * @param integer|null $hydrationMode The hydration mode to use. + * * @return \Doctrine\ORM\Internal\Hydration\IterableResult */ public function iterate($parameters = null, $hydrationMode = null) @@ -700,8 +752,9 @@ abstract class AbstractQuery /** * Executes the query. * - * @param \Doctrine\Common\Collections\ArrayCollection|array $parameters Query parameters. - * @param integer $hydrationMode Processing mode to be used during the hydration process. + * @param ArrayCollection|array|null $parameters Query parameters. + * @param integer|null $hydrationMode Processing mode to be used during the hydration process. + * * @return mixed */ public function execute($parameters = null, $hydrationMode = null) @@ -746,7 +799,7 @@ abstract class AbstractQuery return $stmt; } - $data = $this->_em->getHydrator($this->_hydrationMode)->hydrateAll( + $data = $this->_em->newHydrator($this->_hydrationMode)->hydrateAll( $stmt, $this->_resultSetMapping, $this->_hints ); @@ -786,6 +839,7 @@ abstract class AbstractQuery * generated for you. * * @param string $id + * * @return \Doctrine\ORM\AbstractQuery This query instance. */ public function setResultCacheId($id) @@ -801,6 +855,7 @@ abstract class AbstractQuery * Get the result cache id to use to store the result set cache entry if set. * * @deprecated + * * @return string */ public function getResultCacheId() diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Configuration.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Configuration.php old mode 100755 new mode 100644 index a835488015..3a096ba21f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Configuration.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Configuration.php @@ -19,18 +19,22 @@ namespace Doctrine\ORM; -use Doctrine\Common\Cache\Cache, - Doctrine\Common\Cache\ArrayCache, - Doctrine\Common\Annotations\AnnotationRegistry, - Doctrine\Common\Annotations\AnnotationReader, - Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, - Doctrine\ORM\Mapping\Driver\AnnotationDriver, - Doctrine\ORM\Mapping\QuoteStrategy, - Doctrine\ORM\Mapping\DefaultQuoteStrategy, - Doctrine\ORM\Mapping\NamingStrategy, - Doctrine\ORM\Mapping\DefaultNamingStrategy, - Doctrine\Common\Annotations\SimpleAnnotationReader, - Doctrine\Common\Annotations\CachedReader; +use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Annotations\AnnotationRegistry; +use Doctrine\Common\Annotations\CachedReader; +use Doctrine\Common\Annotations\SimpleAnnotationReader; +use Doctrine\Common\Cache\ArrayCache; +use Doctrine\Common\Cache\Cache; +use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; +use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; +use Doctrine\ORM\Mapping\DefaultNamingStrategy; +use Doctrine\ORM\Mapping\DefaultQuoteStrategy; +use Doctrine\ORM\Mapping\Driver\AnnotationDriver; +use Doctrine\ORM\Mapping\EntityListenerResolver; +use Doctrine\ORM\Mapping\NamingStrategy; +use Doctrine\ORM\Mapping\QuoteStrategy; +use Doctrine\ORM\Repository\DefaultRepositoryFactory; +use Doctrine\ORM\Repository\RepositoryFactory; /** * Configuration container for all configuration options of Doctrine. @@ -49,6 +53,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Sets the directory where Doctrine generates any necessary proxy class files. * * @param string $dir + * + * @return void */ public function setProxyDir($dir) { @@ -58,7 +64,7 @@ class Configuration extends \Doctrine\DBAL\Configuration /** * Gets the directory where Doctrine generates any necessary proxy class files. * - * @return string + * @return string|null */ public function getProxyDir() { @@ -85,6 +91,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * during each script execution. * * @param boolean $bool + * + * @return void */ public function setAutoGenerateProxyClasses($bool) { @@ -94,7 +102,7 @@ class Configuration extends \Doctrine\DBAL\Configuration /** * Gets the namespace where proxy classes reside. * - * @return string + * @return string|null */ public function getProxyNamespace() { @@ -107,6 +115,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Sets the namespace where proxy classes reside. * * @param string $ns + * + * @return void */ public function setProxyNamespace($ns) { @@ -117,6 +127,9 @@ class Configuration extends \Doctrine\DBAL\Configuration * Sets the cache driver implementation that is used for metadata caching. * * @param MappingDriver $driverImpl + * + * @return void + * * @todo Force parameter to be a Closure to ensure lazy evaluation * (as soon as a metadata cache is in effect, the driver never needs to initialize). */ @@ -126,11 +139,12 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Add a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader + * Adds a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader * is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported. * * @param array $paths - * @param bool $useSimpleAnnotationReader + * @param bool $useSimpleAnnotationReader + * * @return AnnotationDriver */ public function newDefaultAnnotationDriver($paths = array(), $useSimpleAnnotationReader = true) @@ -157,6 +171,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * * @param string $alias * @param string $namespace + * + * @return void */ public function addEntityNamespace($alias, $namespace) { @@ -167,8 +183,10 @@ class Configuration extends \Doctrine\DBAL\Configuration * Resolves a registered namespace alias to the full namespace. * * @param string $entityNamespaceAlias - * @throws ORMException + * * @return string + * + * @throws ORMException */ public function getEntityNamespace($entityNamespaceAlias) { @@ -180,9 +198,11 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Set the entity alias map + * Sets the entity alias map. * * @param array $entityNamespaces + * + * @return void */ public function setEntityNamespaces(array $entityNamespaces) { @@ -202,8 +222,9 @@ class Configuration extends \Doctrine\DBAL\Configuration /** * Gets the cache driver implementation that is used for the mapping metadata. * + * @return MappingDriver|null + * * @throws ORMException - * @return MappingDriver */ public function getMetadataDriverImpl() { @@ -215,7 +236,7 @@ class Configuration extends \Doctrine\DBAL\Configuration /** * Gets the cache driver implementation that is used for the query cache (SQL cache). * - * @return \Doctrine\Common\Cache\Cache + * @return \Doctrine\Common\Cache\Cache|null */ public function getQueryCacheImpl() { @@ -228,6 +249,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Sets the cache driver implementation that is used for the query cache (SQL cache). * * @param \Doctrine\Common\Cache\Cache $cacheImpl + * + * @return void */ public function setQueryCacheImpl(Cache $cacheImpl) { @@ -237,7 +260,7 @@ class Configuration extends \Doctrine\DBAL\Configuration /** * Gets the cache driver implementation that is used for the hydration cache (SQL cache). * - * @return \Doctrine\Common\Cache\Cache + * @return \Doctrine\Common\Cache\Cache|null */ public function getHydrationCacheImpl() { @@ -250,6 +273,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Sets the cache driver implementation that is used for the hydration cache (SQL cache). * * @param \Doctrine\Common\Cache\Cache $cacheImpl + * + * @return void */ public function setHydrationCacheImpl(Cache $cacheImpl) { @@ -259,7 +284,7 @@ class Configuration extends \Doctrine\DBAL\Configuration /** * Gets the cache driver implementation that is used for metadata caching. * - * @return \Doctrine\Common\Cache\Cache + * @return \Doctrine\Common\Cache\Cache|null */ public function getMetadataCacheImpl() { @@ -272,6 +297,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Sets the cache driver implementation that is used for metadata caching. * * @param \Doctrine\Common\Cache\Cache $cacheImpl + * + * @return void */ public function setMetadataCacheImpl(Cache $cacheImpl) { @@ -282,7 +309,9 @@ class Configuration extends \Doctrine\DBAL\Configuration * Adds a named DQL query to the configuration. * * @param string $name The name of the query. - * @param string $dql The DQL query string. + * @param string $dql The DQL query string. + * + * @return void */ public function addNamedQuery($name, $dql) { @@ -293,8 +322,10 @@ class Configuration extends \Doctrine\DBAL\Configuration * Gets a previously registered named DQL query. * * @param string $name The name of the query. - * @throws ORMException + * * @return string The DQL query. + * + * @throws ORMException */ public function getNamedQuery($name) { @@ -311,6 +342,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * @param string $name The name of the query. * @param string $sql The native SQL query string. * @param Query\ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query. + * + * @return void */ public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm) { @@ -320,10 +353,12 @@ class Configuration extends \Doctrine\DBAL\Configuration /** * Gets the components of a previously registered named native query. * - * @param string $name The name of the query. + * @param string $name The name of the query. + * + * @return array A tuple with the first element being the SQL string and the second + * element being the ResultSetMapping. + * * @throws ORMException - * @return array A tuple with the first element being the SQL string and the second - * element being the ResultSetMapping. */ public function getNamedNativeQuery($name) { @@ -338,6 +373,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Ensures that this Configuration instance contains settings that are * suitable for a production environment. * + * @return void + * * @throws ORMException If a configuration setting has a value that is not * suitable for a production environment. */ @@ -365,6 +402,9 @@ class Configuration extends \Doctrine\DBAL\Configuration * * @param string $name * @param string $className + * + * @return void + * * @throws ORMException */ public function addCustomStringFunction($name, $className) @@ -380,7 +420,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Gets the implementation class name of a registered custom string DQL function. * * @param string $name - * @return string + * + * @return string|null */ public function getCustomStringFunction($name) { @@ -400,6 +441,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Any previously added string functions are discarded. * * @param array $functions The map of custom DQL string functions. + * + * @return void */ public function setCustomStringFunctions(array $functions) { @@ -417,6 +460,9 @@ class Configuration extends \Doctrine\DBAL\Configuration * * @param string $name * @param string $className + * + * @return void + * * @throws ORMException */ public function addCustomNumericFunction($name, $className) @@ -432,7 +478,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Gets the implementation class name of a registered custom numeric DQL function. * * @param string $name - * @return string + * + * @return string|null */ public function getCustomNumericFunction($name) { @@ -452,6 +499,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Any previously added numeric functions are discarded. * * @param array $functions The map of custom DQL numeric functions. + * + * @return void */ public function setCustomNumericFunctions(array $functions) { @@ -469,6 +518,9 @@ class Configuration extends \Doctrine\DBAL\Configuration * * @param string $name * @param string $className + * + * @return void + * * @throws ORMException */ public function addCustomDatetimeFunction($name, $className) @@ -484,7 +536,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Gets the implementation class name of a registered custom date/time DQL function. * * @param string $name - * @return string + * + * @return string|null */ public function getCustomDatetimeFunction($name) { @@ -504,6 +557,8 @@ class Configuration extends \Doctrine\DBAL\Configuration * Any previously added date/time functions are discarded. * * @param array $functions The map of custom DQL date/time functions. + * + * @return void */ public function setCustomDatetimeFunctions(array $functions) { @@ -513,9 +568,11 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Set the custom hydrator modes in one pass. + * Sets the custom hydrator modes in one pass. * - * @param array An array of ($modeName => $hydrator) + * @param array $modes An array of ($modeName => $hydrator). + * + * @return void */ public function setCustomHydrationModes($modes) { @@ -527,10 +584,11 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Get the hydrator class for the given hydration mode name. + * Gets the hydrator class for the given hydration mode name. * * @param string $modeName The hydration mode name. - * @return string $hydrator The hydrator class name. + * + * @return string|null The hydrator class name. */ public function getCustomHydrationMode($modeName) { @@ -540,10 +598,12 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Add a custom hydration mode. + * Adds a custom hydration mode. * * @param string $modeName The hydration mode name. * @param string $hydrator The hydrator class name. + * + * @return void */ public function addCustomHydrationMode($modeName, $hydrator) { @@ -551,9 +611,11 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Set a class metadata factory. + * Sets a class metadata factory. * * @param string $cmfName + * + * @return void */ public function setClassMetadataFactoryName($cmfName) { @@ -573,9 +635,9 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Add a filter to the list of possible filters. + * Adds a filter to the list of possible filters. * - * @param string $name The name of the filter. + * @param string $name The name of the filter. * @param string $className The class name of the filter. */ public function addFilter($name, $className) @@ -599,10 +661,14 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Set default repository class. + * Sets default repository class. * * @since 2.2 + * * @param string $className + * + * @return void + * * @throws ORMException If not is a \Doctrine\Common\Persistence\ObjectRepository */ public function setDefaultRepositoryClassName($className) @@ -620,6 +686,7 @@ class Configuration extends \Doctrine\DBAL\Configuration * Get default repository class. * * @since 2.2 + * * @return string */ public function getDefaultRepositoryClassName() @@ -630,10 +697,13 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Set naming strategy. + * Sets naming strategy. * * @since 2.3 + * * @param NamingStrategy $namingStrategy + * + * @return void */ public function setNamingStrategy(NamingStrategy $namingStrategy) { @@ -641,9 +711,10 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Get naming strategy.. + * Gets naming strategy.. * * @since 2.3 + * * @return NamingStrategy */ public function getNamingStrategy() @@ -656,10 +727,13 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Set quote strategy. + * Sets quote strategy. * * @since 2.3 - * @param Doctrine\ORM\Mapping\QuoteStrategy $quoteStrategy + * + * @param \Doctrine\ORM\Mapping\QuoteStrategy $quoteStrategy + * + * @return void */ public function setQuoteStrategy(QuoteStrategy $quoteStrategy) { @@ -667,10 +741,11 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Get quote strategy. + * Gets quote strategy. * * @since 2.3 - * @return Doctrine\ORM\Mapping\QuoteStrategy + * + * @return \Doctrine\ORM\Mapping\QuoteStrategy */ public function getQuoteStrategy() { @@ -680,4 +755,54 @@ class Configuration extends \Doctrine\DBAL\Configuration return $this->_attributes['quoteStrategy']; } + + /** + * Set the entity listener resolver. + * + * @since 2.4 + * @param \Doctrine\ORM\Mapping\EntityListenerResolver $resolver + */ + public function setEntityListenerResolver(EntityListenerResolver $resolver) + { + $this->_attributes['entityListenerResolver'] = $resolver; + } + + /** + * Get the entity listener resolver. + * + * @since 2.4 + * @return \Doctrine\ORM\Mapping\EntityListenerResolver + */ + public function getEntityListenerResolver() + { + if ( ! isset($this->_attributes['entityListenerResolver'])) { + $this->_attributes['entityListenerResolver'] = new DefaultEntityListenerResolver(); + } + + return $this->_attributes['entityListenerResolver']; + } + + /** + * Set the entity repository factory. + * + * @since 2.4 + * @param \Doctrine\ORM\Repository\RepositoryFactory $repositoryFactory + */ + public function setRepositoryFactory(RepositoryFactory $repositoryFactory) + { + $this->_attributes['repositoryFactory'] = $repositoryFactory; + } + + /** + * Get the entity repository factory. + * + * @since 2.4 + * @return \Doctrine\ORM\Repository\RepositoryFactory + */ + public function getRepositoryFactory() + { + return isset($this->_attributes['repositoryFactory']) + ? $this->_attributes['repositoryFactory'] + : new DefaultRepositoryFactory(); + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php new file mode 100644 index 0000000000..dc123118f5 --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -0,0 +1,271 @@ +. + */ + +namespace Doctrine\ORM\Decorator; + +use Doctrine\DBAL\LockMode; +use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Common\Persistence\ObjectManagerDecorator; + +/** + * Base class for EntityManager decorators + * + * @since 2.4 + * @author Lars Strojny wrapped = $wrapped; + } + + /** + * {@inheritdoc} + */ + public function getConnection() + { + return $this->wrapped->getConnection(); + } + + /** + * {@inheritdoc} + */ + public function getExpressionBuilder() + { + return $this->wrapped->getExpressionBuilder(); + } + + /** + * {@inheritdoc} + */ + public function beginTransaction() + { + return $this->wrapped->beginTransaction(); + } + + /** + * {@inheritdoc} + */ + public function transactional($func) + { + return $this->wrapped->transactional($func); + } + + /** + * {@inheritdoc} + */ + public function commit() + { + return $this->wrapped->commit(); + } + + /** + * {@inheritdoc} + */ + public function rollback() + { + return $this->wrapped->rollback(); + } + + /** + * {@inheritdoc} + */ + public function createQuery($dql = '') + { + return $this->wrapped->createQuery($dql); + } + + /** + * {@inheritdoc} + */ + public function createNamedQuery($name) + { + return $this->wrapped->createNamedQuery($name); + } + + /** + * {@inheritdoc} + */ + public function createNativeQuery($sql, ResultSetMapping $rsm) + { + return $this->wrapped->createNativeQuery($sql, $rsm); + } + + /** + * {@inheritdoc} + */ + public function createNamedNativeQuery($name) + { + return $this->wrapped->createNamedNativeQuery($name); + } + + /** + * {@inheritdoc} + */ + public function createQueryBuilder() + { + return $this->wrapped->createQueryBuilder(); + } + + /** + * {@inheritdoc} + */ + public function getReference($entityName, $id) + { + return $this->wrapped->getReference($entityName, $id); + } + + /** + * {@inheritdoc} + */ + public function getPartialReference($entityName, $identifier) + { + return $this->wrapped->getPartialReference($entityName, $identifier); + } + + /** + * {@inheritdoc} + */ + public function close() + { + return $this->wrapped->close(); + } + + /** + * {@inheritdoc} + */ + public function copy($entity, $deep = false) + { + return $this->wrapped->copy($entity, $deep); + } + + /** + * {@inheritdoc} + */ + public function lock($entity, $lockMode, $lockVersion = null) + { + return $this->wrapped->lock($entity, $lockMode, $lockVersion); + } + + /** + * {@inheritdoc} + */ + public function find($entityName, $id, $lockMode = LockMode::NONE, $lockVersion = null) + { + return $this->wrapped->find($entityName, $id, $lockMode, $lockVersion); + } + + /** + * {@inheritdoc} + */ + public function flush($entity = null) + { + return $this->wrapped->flush($entity); + } + + /** + * {@inheritdoc} + */ + public function getEventManager() + { + return $this->wrapped->getEventManager(); + } + + /** + * {@inheritdoc} + */ + public function getConfiguration() + { + return $this->wrapped->getConfiguration(); + } + + /** + * {@inheritdoc} + */ + public function isOpen() + { + return $this->wrapped->isOpen(); + } + + /** + * {@inheritdoc} + */ + public function getUnitOfWork() + { + return $this->wrapped->getUnitOfWork(); + } + + /** + * {@inheritdoc} + */ + public function getHydrator($hydrationMode) + { + return $this->wrapped->getHydrator($hydrationMode); + } + + /** + * {@inheritdoc} + */ + public function newHydrator($hydrationMode) + { + return $this->wrapped->newHydrator($hydrationMode); + } + + /** + * {@inheritdoc} + */ + public function getProxyFactory() + { + return $this->wrapped->getProxyFactory(); + } + + /** + * {@inheritdoc} + */ + public function getFilters() + { + return $this->wrapped->getFilters(); + } + + /** + * {@inheritdoc} + */ + public function isFiltersStateClean() + { + return $this->wrapped->isFiltersStateClean(); + } + + /** + * {@inheritdoc} + */ + public function hasFilters() + { + return $this->wrapped->hasFilters(); + } +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php b/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php old mode 100755 new mode 100644 index 50e73824ce..d21d3fb86d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php @@ -19,27 +19,50 @@ namespace Doctrine\ORM; -use Exception, - Doctrine\Common\EventManager, - Doctrine\Common\Persistence\ObjectManager, - Doctrine\DBAL\Connection, - Doctrine\DBAL\LockMode, - Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Mapping\ClassMetadataFactory, - Doctrine\ORM\Query\ResultSetMapping, - Doctrine\ORM\Proxy\ProxyFactory, - Doctrine\ORM\Query\FilterCollection; +use Exception; +use Doctrine\Common\EventManager; +use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\LockMode; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadataFactory; +use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\ORM\Proxy\ProxyFactory; +use Doctrine\ORM\Query\FilterCollection; +use Doctrine\Common\Util\ClassUtils; /** * The EntityManager is the central access point to ORM functionality. * + * It is a facade to all different ORM subsystems such as UnitOfWork, + * Query Language and Repository API. Instantiation is done through + * the static create() method. The quickest way to obtain a fully + * configured EntityManager is: + * + * use Doctrine\ORM\Tools\Setup; + * use Doctrine\ORM\EntityManager; + * + * $paths = array('/path/to/entity/mapping/files'); + * + * $config = Setup::createAnnotationMetadataConfiguration($paths); + * $dbParams = array('driver' => 'pdo_sqlite', 'memory' => true); + * $entityManager = EntityManager::create($dbParams, $config); + * + * For more information see + * {@link http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html} + * + * You should never attempt to inherit from the EntityManager: Inheritance + * is not a valid extension point for the EntityManager. Instead you + * should take a look at the {@see \Doctrine\ORM\Decorator\EntityManagerDecorator} + * and wrap your entity manager in a decorator. + * * @since 2.0 * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel */ -class EntityManager implements ObjectManager +/* final */class EntityManager implements EntityManagerInterface { /** * The used Configuration. @@ -62,13 +85,6 @@ class EntityManager implements ObjectManager */ private $metadataFactory; - /** - * The EntityRepository instances. - * - * @var array - */ - private $repositories = array(); - /** * The UnitOfWork used to coordinate object-level transactions. * @@ -83,13 +99,6 @@ class EntityManager implements ObjectManager */ private $eventManager; - /** - * The maintained (cached) hydrators. One instance per type. - * - * @var array - */ - private $hydrators = array(); - /** * The proxy factory used to create dynamic proxies. * @@ -97,6 +106,13 @@ class EntityManager implements ObjectManager */ private $proxyFactory; + /** + * The repository factory used to create dynamic repositories. + * + * @var \Doctrine\ORM\Repository\RepositoryFactory + */ + private $repositoryFactory; + /** * The expression builder instance used to generate query expressions. * @@ -114,7 +130,7 @@ class EntityManager implements ObjectManager /** * Collection of query filters. * - * @var Doctrine\ORM\Query\FilterCollection + * @var \Doctrine\ORM\Query\FilterCollection */ private $filterCollection; @@ -122,15 +138,15 @@ class EntityManager implements ObjectManager * Creates a new EntityManager that operates on the given database connection * and uses the given Configuration and EventManager implementations. * - * @param \Doctrine\DBAL\Connection $conn - * @param \Doctrine\ORM\Configuration $config + * @param \Doctrine\DBAL\Connection $conn + * @param \Doctrine\ORM\Configuration $config * @param \Doctrine\Common\EventManager $eventManager */ protected function __construct(Connection $conn, Configuration $config, EventManager $eventManager) { - $this->conn = $conn; - $this->config = $config; - $this->eventManager = $eventManager; + $this->conn = $conn; + $this->config = $config; + $this->eventManager = $eventManager; $metadataFactoryClassName = $config->getClassMetadataFactoryName(); @@ -138,8 +154,9 @@ class EntityManager implements ObjectManager $this->metadataFactory->setEntityManager($this); $this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl()); - $this->unitOfWork = new UnitOfWork($this); - $this->proxyFactory = new ProxyFactory( + $this->repositoryFactory = $config->getRepositoryFactory(); + $this->unitOfWork = new UnitOfWork($this); + $this->proxyFactory = new ProxyFactory( $this, $config->getProxyDir(), $config->getProxyNamespace(), @@ -192,6 +209,8 @@ class EntityManager implements ObjectManager /** * Starts a transaction on the underlying database connection. + * + * @return void */ public function beginTransaction() { @@ -209,7 +228,8 @@ class EntityManager implements ObjectManager * the transaction is rolled back, the EntityManager closed and the exception re-thrown. * * @param callable $func The function to execute transactionally. - * @return mixed Returns the non-empty value returned from the closure or true instead + * + * @return mixed The non-empty value returned from the closure or true instead. */ public function transactional($func) { @@ -236,6 +256,8 @@ class EntityManager implements ObjectManager /** * Commits a transaction on the underlying database connection. + * + * @return void */ public function commit() { @@ -244,6 +266,8 @@ class EntityManager implements ObjectManager /** * Performs a rollback on the underlying database connection. + * + * @return void */ public function rollback() { @@ -260,7 +284,10 @@ class EntityManager implements ObjectManager * MyProject\Domain\User * sales:PriceRequest * + * @param string $className + * * @return \Doctrine\ORM\Mapping\ClassMetadata + * * @internal Performance-sensitive method. */ public function getClassMetadata($className) @@ -272,9 +299,10 @@ class EntityManager implements ObjectManager * Creates a new Query object. * * @param string $dql The DQL string. + * * @return \Doctrine\ORM\Query */ - public function createQuery($dql = "") + public function createQuery($dql = '') { $query = new Query($this); @@ -289,6 +317,7 @@ class EntityManager implements ObjectManager * Creates a Query from a named query. * * @param string $name + * * @return \Doctrine\ORM\Query */ public function createNamedQuery($name) @@ -299,8 +328,9 @@ class EntityManager implements ObjectManager /** * Creates a native SQL query. * - * @param string $sql + * @param string $sql * @param ResultSetMapping $rsm The ResultSetMapping to use. + * * @return NativeQuery */ public function createNativeQuery($sql, ResultSetMapping $rsm) @@ -317,6 +347,7 @@ class EntityManager implements ObjectManager * Creates a NativeQuery from a named native query. * * @param string $name + * * @return \Doctrine\ORM\NativeQuery */ public function createNamedNativeQuery($name) @@ -329,7 +360,7 @@ class EntityManager implements ObjectManager /** * Create a QueryBuilder instance * - * @return QueryBuilder $qb + * @return QueryBuilder */ public function createQueryBuilder() { @@ -344,7 +375,10 @@ class EntityManager implements ObjectManager * If an entity is explicitly passed to this method only this entity and * the cascade-persist semantics + scheduled inserts/removals are synchronized. * - * @param object $entity + * @param null|object|array $entity + * + * @return void + * * @throws \Doctrine\ORM\OptimisticLockException If a version check on an entity that * makes use of optimistic locking fails. */ @@ -354,21 +388,34 @@ class EntityManager implements ObjectManager $this->unitOfWork->commit($entity); } - + /** * Finds an Entity by its identifier. * - * @param string $entityName - * @param mixed $id - * @param integer $lockMode - * @param integer $lockVersion + * @param string $entityName + * @param mixed $id + * @param integer $lockMode + * @param integer|null $lockVersion * - * @return object + * @return object|null The entity instance or NULL if the entity can not be found. + * + * @throws OptimisticLockException + * @throws ORMInvalidArgumentException + * @throws TransactionRequiredException + * @throws ORMException */ public function find($entityName, $id, $lockMode = LockMode::NONE, $lockVersion = null) { $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); + if (is_object($id) && $this->metadataFactory->hasMetadataFor(ClassUtils::getClass($id))) { + $id = $this->unitOfWork->getSingleIdentifierValue($id); + + if ($id === null) { + throw ORMInvalidArgumentException::invalidIdentifierBindingEntity(); + } + } + if ( ! is_array($id)) { $id = array($class->identifier[0] => $id); } @@ -437,8 +484,11 @@ class EntityManager implements ObjectManager * without actually loading it, if the entity is not yet loaded. * * @param string $entityName The name of the entity type. - * @param mixed $id The entity identifier. + * @param mixed $id The entity identifier. + * * @return object The entity reference. + * + * @throws ORMException */ public function getReference($entityName, $id) { @@ -494,7 +544,8 @@ class EntityManager implements ObjectManager * never be loaded in the first place. * * @param string $entityName The name of the entity type. - * @param mixed $identifier The entity identifier. + * @param mixed $identifier The entity identifier. + * * @return object The (partial) entity reference. */ public function getPartialReference($entityName, $identifier) @@ -524,7 +575,9 @@ class EntityManager implements ObjectManager * Clears the EntityManager. All entities that are currently managed * by this EntityManager become detached. * - * @param string $entityName if given, only entities of this type will get detached + * @param string|null $entityName if given, only entities of this type will get detached + * + * @return void */ public function clear($entityName = null) { @@ -535,6 +588,8 @@ class EntityManager implements ObjectManager * Closes the EntityManager. All entities that are currently managed * by this EntityManager become detached. The EntityManager may no longer * be used after it is closed. + * + * @return void */ public function close() { @@ -552,7 +607,11 @@ class EntityManager implements ObjectManager * NOTE: The persist operation always considers entities that are not yet known to * this EntityManager as NEW. Do not pass detached entities to the persist operation. * - * @param object $object The instance to make managed and persistent. + * @param object $entity The instance to make managed and persistent. + * + * @return void + * + * @throws ORMInvalidArgumentException */ public function persist($entity) { @@ -572,6 +631,10 @@ class EntityManager implements ObjectManager * or as a result of the flush operation. * * @param object $entity The entity instance to remove. + * + * @return void + * + * @throws ORMInvalidArgumentException */ public function remove($entity) { @@ -589,6 +652,10 @@ class EntityManager implements ObjectManager * overriding any local changes that have not yet been persisted. * * @param object $entity The entity to refresh. + * + * @return void + * + * @throws ORMInvalidArgumentException */ public function refresh($entity) { @@ -609,6 +676,10 @@ class EntityManager implements ObjectManager * reference it. * * @param object $entity The entity to detach. + * + * @return void + * + * @throws ORMInvalidArgumentException */ public function detach($entity) { @@ -625,7 +696,10 @@ class EntityManager implements ObjectManager * The entity passed to merge will not become associated/managed with this EntityManager. * * @param object $entity The detached entity to merge into the persistence context. + * * @return object The managed copy of the entity. + * + * @throws ORMInvalidArgumentException */ public function merge($entity) { @@ -641,8 +715,13 @@ class EntityManager implements ObjectManager /** * Creates a copy of the given entity. Can create a shallow or a deep copy. * - * @param object $entity The entity to copy. - * @return object The new entity. + * @param object $entity The entity to copy. + * @param boolean $deep FALSE for a shallow copy, TRUE for a deep copy. + * + * @return object The new entity. + * + * @throws \BadMethodCallException + * * @todo Implementation need. This is necessary since $e2 = clone $e1; throws an E_FATAL when access anything on $e: * Fatal error: Maximum function nesting level of '100' reached, aborting! */ @@ -654,9 +733,12 @@ class EntityManager implements ObjectManager /** * Acquire a lock on the given entity. * - * @param object $entity - * @param int $lockMode - * @param int $lockVersion + * @param object $entity + * @param int $lockMode + * @param int|null $lockVersion + * + * @return void + * * @throws OptimisticLockException * @throws PessimisticLockException */ @@ -669,34 +751,19 @@ class EntityManager implements ObjectManager * Gets the repository for an entity class. * * @param string $entityName The name of the entity. - * @return EntityRepository The repository class. + * + * @return \Doctrine\ORM\EntityRepository The repository class. */ public function getRepository($entityName) { - $entityName = ltrim($entityName, '\\'); - - if (isset($this->repositories[$entityName])) { - return $this->repositories[$entityName]; - } - - $metadata = $this->getClassMetadata($entityName); - $repositoryClassName = $metadata->customRepositoryClassName; - - if ($repositoryClassName === null) { - $repositoryClassName = $this->config->getDefaultRepositoryClassName(); - } - - $repository = new $repositoryClassName($this, $metadata); - - $this->repositories[$entityName] = $repository; - - return $repository; + return $this->repositoryFactory->getRepository($this, $entityName); } /** * Determines whether an entity instance is managed in this EntityManager. * * @param object $entity + * * @return boolean TRUE if this EntityManager currently manages the given entity, FALSE otherwise. */ public function contains($entity) @@ -729,6 +796,8 @@ class EntityManager implements ObjectManager /** * Throws an exception if the EntityManager is closed or currently not active. * + * @return void + * * @throws ORMException If the EntityManager is closed. */ private function errorIfClosed() @@ -764,23 +833,25 @@ class EntityManager implements ObjectManager * This method caches the hydrator instances which is used for all queries that don't * selectively iterate over the result. * + * @deprecated + * * @param int $hydrationMode + * * @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator */ public function getHydrator($hydrationMode) { - if ( ! isset($this->hydrators[$hydrationMode])) { - $this->hydrators[$hydrationMode] = $this->newHydrator($hydrationMode); - } - - return $this->hydrators[$hydrationMode]; + return $this->newHydrator($hydrationMode); } /** * Create a new instance for the given hydration mode. * - * @param int $hydrationMode + * @param int $hydrationMode + * * @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator + * + * @throws ORMException */ public function newHydrator($hydrationMode) { @@ -825,6 +896,8 @@ class EntityManager implements ObjectManager * This method is a no-op for other objects * * @param object $obj + * + * @return void */ public function initializeObject($obj) { @@ -834,11 +907,14 @@ class EntityManager implements ObjectManager /** * Factory method to create EntityManager instances. * - * @param mixed $conn An array with the connection parameters or an existing - * Connection instance. - * @param Configuration $config The Configuration instance to use. - * @param EventManager $eventManager The EventManager instance to use. + * @param mixed $conn An array with the connection parameters or an existing Connection instance. + * @param Configuration $config The Configuration instance to use. + * @param EventManager $eventManager The EventManager instance to use. + * * @return EntityManager The created EntityManager. + * + * @throws \InvalidArgumentException + * @throws ORMException */ public static function create($conn, Configuration $config, EventManager $eventManager = null) { @@ -893,7 +969,7 @@ class EntityManager implements ObjectManager /** * Checks whether the Entity Manager has filters. * - * @return True, if the EM has a filter collection. + * @return boolean True, if the EM has a filter collection. */ public function hasFilters() { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManagerInterface.php b/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManagerInterface.php new file mode 100644 index 0000000000..d72f7cd0cf --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManagerInterface.php @@ -0,0 +1,60 @@ +. + */ + +namespace Doctrine\ORM; + +use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\DBAL\LockMode; +use Doctrine\ORM\Query\ResultSetMapping; + +/** + * EntityManager interface + * + * @since 2.4 + * @author Lars Strojny EntityRepository. * - * @param EntityManager $em The EntityManager to use. - * @param ClassMetadata $classMetadata The class descriptor. + * @param EntityManager $em The EntityManager to use. + * @param Mapping\ClassMetadata $class The class descriptor. */ public function __construct($em, Mapping\ClassMetadata $class) { @@ -71,10 +72,11 @@ class EntityRepository implements ObjectRepository, Selectable } /** - * Create a new QueryBuilder instance that is prepopulated for this entity name + * Creates a new QueryBuilder instance that is prepopulated for this entity name. * * @param string $alias - * @return QueryBuilder $qb + * + * @return QueryBuilder */ public function createQueryBuilder($alias) { @@ -84,9 +86,27 @@ class EntityRepository implements ObjectRepository, Selectable } /** - * Create a new Query instance based on a predefined metadata named query. + * Creates a new result set mapping builder for this entity. + * + * The column naming strategy is "INCREMENT". + * + * @param string $alias + * + * @return ResultSetMappingBuilder + */ + public function createResultSetMappingBuilder($alias) + { + $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); + $rsm->addRootEntityFromClassMetadata($this->_entityName, $alias); + + return $rsm; + } + + /** + * Creates a new Query instance based on a predefined metadata named query. * * @param string $queryName + * * @return Query */ public function createNamedQuery($queryName) @@ -98,6 +118,7 @@ class EntityRepository implements ObjectRepository, Selectable * Creates a native SQL query. * * @param string $queryName + * * @return NativeQuery */ public function createNativeNamedQuery($queryName) @@ -111,6 +132,8 @@ class EntityRepository implements ObjectRepository, Selectable /** * Clears the repository, causing all managed entities to become detached. + * + * @return void */ public function clear() { @@ -120,11 +143,11 @@ class EntityRepository implements ObjectRepository, Selectable /** * Finds an entity by its primary key / identifier. * - * @param mixed $id The identifier. - * @param integer $lockMode - * @param integer $lockVersion + * @param mixed $id The identifier. + * @param int $lockMode The lock mode. + * @param int|null $lockVersion The lock version. * - * @return object The entity. + * @return object|null The entity instance or NULL if the entity can not be found. */ public function find($id, $lockMode = LockMode::NONE, $lockVersion = null) { @@ -144,10 +167,11 @@ class EntityRepository implements ObjectRepository, Selectable /** * Finds entities by a set of criteria. * - * @param array $criteria + * @param array $criteria * @param array|null $orderBy - * @param int|null $limit - * @param int|null $offset + * @param int|null $limit + * @param int|null $offset + * * @return array The objects. */ public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) @@ -162,7 +186,8 @@ class EntityRepository implements ObjectRepository, Selectable * * @param array $criteria * @param array|null $orderBy - * @return object + * + * @return object|null The entity instance or NULL if the entity can not be found. */ public function findOneBy(array $criteria, array $orderBy = null) { @@ -174,8 +199,13 @@ class EntityRepository implements ObjectRepository, Selectable /** * Adds support for magic finders. * + * @param string $method + * @param array $arguments + * * @return array|object The found entity/entities. - * @throws BadMethodCallException If the method called is an invalid find* method + * + * @throws ORMException + * @throws \BadMethodCallException If the method called is an invalid find* method * or no find* method at all and therefore an invalid * method call. */ @@ -274,4 +304,3 @@ class EntityRepository implements ObjectRepository, Selectable return new ArrayCollection($persister->loadCriteria($criteria)); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/LifecycleEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/LifecycleEventArgs.php old mode 100755 new mode 100644 index 4346054b75..8977a3573f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/LifecycleEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/LifecycleEventArgs.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Event; -use Doctrine\Common\EventArgs; use Doctrine\ORM\EntityManager; +use Doctrine\Common\Persistence\Event\LifecycleEventArgs as BaseLifecycleEventArgs; /** * Lifecycle Events are triggered by the UnitOfWork during lifecycle transitions @@ -31,47 +31,25 @@ use Doctrine\ORM\EntityManager; * @author Roman Borschel * @author Benjamin Eberlei */ -class LifecycleEventArgs extends EventArgs +class LifecycleEventArgs extends BaseLifecycleEventArgs { /** - * @var \Doctrine\ORM\EntityManager - */ - private $em; - - /** - * @var object - */ - private $entity; - - /** - * Constructor - * - * @param object $entity - * @param \Doctrine\ORM\EntityManager $em - */ - public function __construct($entity, EntityManager $em) - { - $this->entity = $entity; - $this->em = $em; - } - - /** - * Retrieve associated Entity. + * Retrieves associated Entity. * * @return object */ public function getEntity() { - return $this->entity; + return $this->getObject(); } /** - * Retrieve associated EntityManager. + * Retrieves associated EntityManager. * * @return \Doctrine\ORM\EntityManager */ public function getEntityManager() { - return $this->em; + return $this->getObjectManager(); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/ListenersInvoker.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/ListenersInvoker.php new file mode 100644 index 0000000000..125855befa --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/ListenersInvoker.php @@ -0,0 +1,120 @@ +. + */ + +namespace Doctrine\ORM\Event; + +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\EntityManager; +use Doctrine\Common\EventArgs; + +/** + * A method invoker based on entity lifecycle. + * + * @author Fabio B. Silva + * @since 2.4 + */ +class ListenersInvoker +{ + const INVOKE_NONE = 0; + const INVOKE_LISTENERS = 1; + const INVOKE_CALLBACKS = 2; + const INVOKE_MANAGER = 4; + + /** + * @var \Doctrine\ORM\Mapping\EntityListenerResolver The Entity listener resolver. + */ + private $resolver; + + /** + * The EventManager used for dispatching events. + * + * @var \Doctrine\Common\EventManager + */ + private $eventManager; + + /** + * Initializes a new ListenersInvoker instance. + * + * @param \Doctrine\ORM\EntityManager $em + */ + public function __construct(EntityManager $em) + { + $this->eventManager = $em->getEventManager(); + $this->resolver = $em->getConfiguration()->getEntityListenerResolver(); + } + + /** + * Get the subscribed event systems + * + * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata. + * @param string $eventName The entity lifecycle event. + * + * @return integer Bitmask of subscribed event systems. + */ + public function getSubscribedSystems(ClassMetadata $metadata, $eventName) + { + $invoke = self::INVOKE_NONE; + + if (isset($metadata->lifecycleCallbacks[$eventName])) { + $invoke |= self::INVOKE_CALLBACKS; + } + + if (isset($metadata->entityListeners[$eventName])) { + $invoke |= self::INVOKE_LISTENERS; + } + + if ($this->eventManager->hasListeners($eventName)) { + $invoke |= self::INVOKE_MANAGER; + } + + return $invoke; + } + + /** + * Dispatches the lifecycle event of the given entity. + * + * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata. + * @param string $eventName The entity lifecycle event. + * @param object $entity The Entity on which the event occurred. + * @param \Doctrine\Common\EventArgs $event The Event args. + * @param integer $invoke Bitmask to invoke listeners. + */ + public function invoke(ClassMetadata $metadata, $eventName, $entity, EventArgs $event, $invoke) + { + if($invoke & self::INVOKE_CALLBACKS) { + foreach ($metadata->lifecycleCallbacks[$eventName] as $callback) { + $entity->$callback($event); + } + } + + if($invoke & self::INVOKE_LISTENERS) { + foreach ($metadata->entityListeners[$eventName] as $listener) { + $class = $listener['class']; + $method = $listener['method']; + $instance = $this->resolver->resolve($class); + + $instance->$method($entity, $event); + } + } + + if($invoke & self::INVOKE_MANAGER) { + $this->eventManager->dispatchEvent($eventName, $event); + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php old mode 100755 new mode 100644 index 4c2cb0748a..0111fa38e2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php @@ -22,6 +22,7 @@ namespace Doctrine\ORM\Event; use Doctrine\Common\EventArgs; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\EntityManager; +use Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs as BaseLoadClassMetadataEventArgs; /** * Class that holds event arguments for a loadMetadata event. @@ -29,40 +30,8 @@ use Doctrine\ORM\EntityManager; * @author Jonathan H. Wage * @since 2.0 */ -class LoadClassMetadataEventArgs extends EventArgs +class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs { - /** - * @var \Doctrine\ORM\Mapping\ClassMetadata - */ - private $classMetadata; - - /** - * @var \Doctrine\ORM\EntityManager - */ - private $em; - - /** - * Constructor. - * - * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $classMetadata - * @param \Doctrine\ORM\EntityManager $em - */ - public function __construct(ClassMetadataInfo $classMetadata, EntityManager $em) - { - $this->classMetadata = $classMetadata; - $this->em = $em; - } - - /** - * Retrieve associated ClassMetadata. - * - * @return \Doctrine\ORM\Mapping\ClassMetadataInfo - */ - public function getClassMetadata() - { - return $this->classMetadata; - } - /** * Retrieve associated EntityManager. * @@ -70,7 +39,6 @@ class LoadClassMetadataEventArgs extends EventArgs */ public function getEntityManager() { - return $this->em; + return $this->getObjectManager(); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/OnClearEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/OnClearEventArgs.php old mode 100755 new mode 100644 index 309994f3d6..3a29680f70 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/OnClearEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/OnClearEventArgs.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Event; +use Doctrine\ORM\EntityManager; + /** * Provides event arguments for the onClear event. * @@ -44,16 +46,16 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs * Constructor. * * @param \Doctrine\ORM\EntityManager $em - * @param string $entityClass Optional entity class + * @param string|null $entityClass Optional entity class. */ - public function __construct($em, $entityClass = null) + public function __construct(EntityManager $em, $entityClass = null) { $this->em = $em; $this->entityClass = $entityClass; } /** - * Retrieve associated EntityManager. + * Retrieves associated EntityManager. * * @return \Doctrine\ORM\EntityManager */ @@ -65,7 +67,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs /** * Name of the entity class that is cleared, or empty if all are cleared. * - * @return string + * @return string|null */ public function getEntityClass() { @@ -73,7 +75,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs } /** - * Check if event clears all entities. + * Checks if event clears all entities. * * @return bool */ diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/OnFlushEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/OnFlushEventArgs.php old mode 100755 new mode 100644 index 1e18d2a464..2dd05a5fa6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/OnFlushEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/OnFlushEventArgs.php @@ -19,6 +19,7 @@ namespace Doctrine\ORM\Event; +use Doctrine\Common\EventArgs; use Doctrine\ORM\EntityManager; /** @@ -30,16 +31,13 @@ use Doctrine\ORM\EntityManager; * @author Roman Borschel * @author Benjamin Eberlei */ -class OnFlushEventArgs extends \Doctrine\Common\EventArgs +class OnFlushEventArgs extends EventArgs { /** - * @var Doctirne\ORM\EntityManager + * @var \Doctrine\ORM\EntityManager */ private $em; - //private $entitiesToPersist = array(); - //private $entitiesToRemove = array(); - /** * Constructor. * @@ -60,25 +58,4 @@ class OnFlushEventArgs extends \Doctrine\Common\EventArgs return $this->em; } - /* - public function addEntityToPersist($entity) - { - - } - - public function addEntityToRemove($entity) - { - - } - - public function addEntityToUpdate($entity) - { - - } - - public function getEntitiesToPersist() - { - return $this->_entitiesToPersist; - } - */ } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PostFlushEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PostFlushEventArgs.php old mode 100755 new mode 100644 index 5f9735c0e9..d120600828 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PostFlushEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PostFlushEventArgs.php @@ -47,7 +47,7 @@ class PostFlushEventArgs extends EventArgs } /** - * Retrieve associated EntityManager. + * Retrieves associated EntityManager. * * @return \Doctrine\ORM\EntityManager */ diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreFlushEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreFlushEventArgs.php old mode 100755 new mode 100644 index 82f2b7eaeb..bfee5c76e6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreFlushEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreFlushEventArgs.php @@ -19,6 +19,9 @@ namespace Doctrine\ORM\Event; +use Doctrine\Common\EventArgs; +use Doctrine\ORM\EntityManager; + /** * Provides event arguments for the preFlush event. * @@ -28,23 +31,28 @@ namespace Doctrine\ORM\Event; * @author Roman Borschel * @author Benjamin Eberlei */ -class PreFlushEventArgs extends \Doctrine\Common\EventArgs +class PreFlushEventArgs extends EventArgs { /** - * @var EntityManager + * @var \Doctrine\ORM\EntityManager */ - private $_em; + private $em; - public function __construct($em) + /** + * Constructor. + * + * @param \Doctrine\ORM\EntityManager $em + */ + public function __construct(EntityManager $em) { - $this->_em = $em; + $this->em = $em; } /** - * @return EntityManager + * @return \Doctrine\ORM\EntityManager */ public function getEntityManager() { - return $this->_em; + return $this->em; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php old mode 100755 new mode 100644 index 188417e385..0cae066af0 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Event; -use Doctrine\Common\EventArgs, - Doctrine\ORM\EntityManager; +use Doctrine\Common\EventArgs; +use Doctrine\ORM\EntityManager; /** * Class that holds event arguments for a preInsert/preUpdate event. @@ -40,9 +40,9 @@ class PreUpdateEventArgs extends LifecycleEventArgs /** * Constructor. * - * @param object $entity - * @param \Doctrine\ORM\EntityManager $em - * @param array $changeSet + * @param object $entity + * @param EntityManager $em + * @param array $changeSet */ public function __construct($entity, EntityManager $em, array &$changeSet) { @@ -52,7 +52,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Retrieve entity changeset. + * Retrieves entity changeset. * * @return array */ @@ -62,7 +62,9 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Check if field has a changeset. + * Checks if field has a changeset. + * + * @param string $field * * @return boolean */ @@ -72,9 +74,10 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Get the old value of the changeset of the changed field. + * Gets the old value of the changeset of the changed field. + * + * @param string $field * - * @param string $field * @return mixed */ public function getOldValue($field) @@ -85,9 +88,10 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Get the new value of the changeset of the changed field. + * Gets the new value of the changeset of the changed field. + * + * @param string $field * - * @param string $field * @return mixed */ public function getNewValue($field) @@ -98,10 +102,12 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Set the new value of this field. + * Sets the new value of this field. * * @param string $field - * @param mixed $value + * @param mixed $value + * + * @return void */ public function setNewValue($field, $value) { @@ -111,9 +117,13 @@ class PreUpdateEventArgs extends LifecycleEventArgs } /** - * Assert the field exists in changeset. + * Asserts the field exists in changeset. * * @param string $field + * + * @return void + * + * @throws \InvalidArgumentException */ private function assertValidField($field) { @@ -126,4 +136,3 @@ class PreUpdateEventArgs extends LifecycleEventArgs } } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Events.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Events.php old mode 100755 new mode 100644 index 812a43eab2..8c13fa2d56 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Events.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Events.php @@ -29,7 +29,13 @@ namespace Doctrine\ORM; */ final class Events { - private function __construct() {} + /** + * Private constructor. This class is not meant to be instantiated. + */ + private function __construct() + { + } + /** * The preRemove event occurs for a given entity before the respective * EntityManager remove operation for that entity is executed. @@ -39,6 +45,7 @@ final class Events * @var string */ const preRemove = 'preRemove'; + /** * The postRemove event occurs for an entity after the entity has * been deleted. It will be invoked after the database delete operations. @@ -48,6 +55,7 @@ final class Events * @var string */ const postRemove = 'postRemove'; + /** * The prePersist event occurs for a given entity before the respective * EntityManager persist operation for that entity is executed. @@ -57,6 +65,7 @@ final class Events * @var string */ const prePersist = 'prePersist'; + /** * The postPersist event occurs for an entity after the entity has * been made persistent. It will be invoked after the database insert operations. @@ -67,6 +76,7 @@ final class Events * @var string */ const postPersist = 'postPersist'; + /** * The preUpdate event occurs before the database update operations to * entity data. @@ -76,6 +86,7 @@ final class Events * @var string */ const preUpdate = 'preUpdate'; + /** * The postUpdate event occurs after the database update operations to * entity data. @@ -85,6 +96,7 @@ final class Events * @var string */ const postUpdate = 'postUpdate'; + /** * The postLoad event occurs for an entity after the entity has been loaded * into the current EntityManager from the database or after the refresh operation @@ -99,6 +111,7 @@ final class Events * @var string */ const postLoad = 'postLoad'; + /** * The loadClassMetadata event occurs after the mapping metadata for a class * has been loaded from a mapping source (annotations/xml/yaml). @@ -109,7 +122,7 @@ final class Events /** * The preFlush event occurs when the EntityManager#flush() operation is invoked, - * but before any changes to managed entites have been calculated. This event is + * but before any changes to managed entities have been calculated. This event is * always raised right after EntityManager#flush() call. */ const preFlush = 'preFlush'; diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/AbstractIdGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/AbstractIdGenerator.php old mode 100755 new mode 100644 index ef98caf8d3..b4161b29e3 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/AbstractIdGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/AbstractIdGenerator.php @@ -26,7 +26,9 @@ abstract class AbstractIdGenerator /** * Generates an identifier for an entity. * - * @param \Doctrine\ORM\Entity $entity + * @param \Doctrine\ORM\EntityManager $em + * @param \Doctrine\ORM\Mapping\Entity $entity + * * @return mixed */ abstract public function generate(EntityManager $em, $entity); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/AssignedGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/AssignedGenerator.php old mode 100755 new mode 100644 index 0597c3bc67..4e33215937 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/AssignedGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/AssignedGenerator.php @@ -23,7 +23,7 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\ORMException; /** - * Special generator for application-assigned identifiers (doesnt really generate anything). + * Special generator for application-assigned identifiers (doesn't really generate anything). * * @since 2.0 * @author Benjamin Eberlei @@ -36,8 +36,13 @@ class AssignedGenerator extends AbstractIdGenerator /** * Returns the identifier assigned to the given entity. * - * @param object $entity + * @param EntityManager $em + * @param object $entity + * * @return mixed + * + * @throws \Doctrine\ORM\ORMException + * * @override */ public function generate(EntityManager $em, $entity) @@ -47,7 +52,7 @@ class AssignedGenerator extends AbstractIdGenerator $identifier = array(); foreach ($idFields as $idField) { - $value = $class->reflFields[$idField]->getValue($entity); + $value = $class->getFieldValue($entity, $idField); if ( ! isset($value)) { throw ORMException::entityMissingAssignedIdForField($entity, $idField); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php old mode 100755 new mode 100644 index e387023b4e..1b4ed9a06e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php @@ -38,9 +38,9 @@ class BigIntegerIdentityGenerator extends AbstractIdGenerator /** * Constructor. * - * @param string|null $seqName The name of the sequence to pass to lastInsertId() - * to obtain the last generated identifier within the current - * database session/connection, if any. + * @param string|null $sequenceName The name of the sequence to pass to lastInsertId() + * to obtain the last generated identifier within the current + * database session/connection, if any. */ public function __construct($sequenceName = null) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/IdentityGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/IdentityGenerator.php old mode 100755 new mode 100644 index ad6131280c..7945c6936a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/IdentityGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/IdentityGenerator.php @@ -36,9 +36,11 @@ class IdentityGenerator extends AbstractIdGenerator private $sequenceName; /** - * @param string $seqName The name of the sequence to pass to lastInsertId() - * to obtain the last generated identifier within the current - * database session/connection, if any. + * Constructor. + * + * @param string|null $sequenceName The name of the sequence to pass to lastInsertId() + * to obtain the last generated identifier within the current + * database session/connection, if any. */ public function __construct($sequenceName = null) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/SequenceGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/SequenceGenerator.php old mode 100755 new mode 100644 index 5b5d831654..545152254d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/SequenceGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/SequenceGenerator.php @@ -19,7 +19,8 @@ namespace Doctrine\ORM\Id; -use Serializable, Doctrine\ORM\EntityManager; +use Serializable; +use Doctrine\ORM\EntityManager; /** * Represents an ID generator that uses a database sequence. @@ -29,16 +30,34 @@ use Serializable, Doctrine\ORM\EntityManager; */ class SequenceGenerator extends AbstractIdGenerator implements Serializable { + /** + * The allocation size of the sequence. + * + * @var int + */ private $_allocationSize; + + /** + * The name of the sequence. + * + * @var string + */ private $_sequenceName; + + /** + * @var int + */ private $_nextValue = 0; + + /** + * @var int|null + */ private $_maxValue = null; /** * Initializes a new sequence generator. * - * @param \Doctrine\ORM\EntityManager $em The EntityManager to use. - * @param string $sequenceName The name of the sequence. + * @param string $sequenceName The name of the sequence. * @param integer $allocationSize The allocation size of the sequence. */ public function __construct($sequenceName, $allocationSize) @@ -50,8 +69,11 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable /** * Generates an ID for the given entity. * - * @param object $entity - * @return integer|float The generated value. + * @param EntityManager $em + * @param object $entity + * + * @return integer The generated value. + * * @override */ public function generate(EntityManager $em, $entity) @@ -71,7 +93,7 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable /** * Gets the maximum value of the currently allocated bag of values. * - * @return integer|float + * @return integer|null */ public function getCurrentMaxValue() { @@ -81,13 +103,16 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable /** * Gets the next value that will be returned by generate(). * - * @return integer|float + * @return integer */ public function getNextValue() { return $this->_nextValue; } + /** + * @return string + */ public function serialize() { return serialize(array( @@ -96,6 +121,11 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable )); } + /** + * @param string $serialized + * + * @return void + */ public function unserialize($serialized) { $array = unserialize($serialized); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/TableGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/TableGenerator.php old mode 100755 new mode 100644 index 7e84b0a6bf..34606fb222 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/TableGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/TableGenerator.php @@ -32,12 +32,36 @@ use Doctrine\ORM\EntityManager; */ class TableGenerator extends AbstractIdGenerator { + /** + * @var string + */ private $_tableName; + + /** + * @var string + */ private $_sequenceName; + + /** + * @var int + */ private $_allocationSize; + + /** + * @var int|null + */ private $_nextValue; + + /** + * @var int|null + */ private $_maxValue; + /** + * @param string $tableName + * @param string $sequenceName + * @param int $allocationSize + */ public function __construct($tableName, $sequenceName = 'default', $allocationSize = 10) { $this->_tableName = $tableName; @@ -45,6 +69,9 @@ class TableGenerator extends AbstractIdGenerator $this->_allocationSize = $allocationSize; } + /** + * {@inheritdoc} + */ public function generate(EntityManager $em, $entity) { if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/UuidGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/UuidGenerator.php old mode 100755 new mode 100644 index 3978f1be4c..901af806a2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Id/UuidGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Id/UuidGenerator.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Id; -use Serializable, Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManager; /** * Represents an ID generator that uses the database UUID expression @@ -29,13 +29,14 @@ use Serializable, Doctrine\ORM\EntityManager; */ class UuidGenerator extends AbstractIdGenerator { - /** * Generates an ID for the given entity. * - * @param Doctrine\ORM\EntityManager $em The EntityManager to user - * @param object $entity + * @param EntityManager $em The EntityManager to use. + * @param object $entity + * * @return string The generated value. + * * @override */ public function generate(EntityManager $em, $entity) @@ -44,5 +45,4 @@ class UuidGenerator extends AbstractIdGenerator $sql = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression(); return $conn->query($sql)->fetchColumn(0); } - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php old mode 100755 new mode 100644 index a4ae5f3e0c..b5153e6d34 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php @@ -33,9 +33,26 @@ class CommitOrderCalculator const IN_PROGRESS = 2; const VISITED = 3; + /** + * @var array + */ private $_nodeStates = array(); - private $_classes = array(); // The nodes to sort + + /** + * The nodes to sort. + * + * @var array + */ + private $_classes = array(); + + /** + * @var array + */ private $_relatedClasses = array(); + + /** + * @var array + */ private $_sorted = array(); /** @@ -85,6 +102,11 @@ class CommitOrderCalculator return $sorted; } + /** + * @param \Doctrine\ORM\Mapping\ClassMetadata $node + * + * @return void + */ private function _visitNode($node) { $this->_nodeStates[$node->name] = self::IN_PROGRESS; @@ -101,16 +123,32 @@ class CommitOrderCalculator $this->_sorted[] = $node; } + /** + * @param \Doctrine\ORM\Mapping\ClassMetadata $fromClass + * @param \Doctrine\ORM\Mapping\ClassMetadata $toClass + * + * @return void + */ public function addDependency($fromClass, $toClass) { $this->_relatedClasses[$fromClass->name][] = $toClass; } + /** + * @param string $className + * + * @return bool + */ public function hasClass($className) { return isset($this->_classes[$className]); } + /** + * @param \Doctrine\ORM\Mapping\ClassMetadata $class + * + * @return void + */ public function addClass($class) { $this->_classes[$class->name] = $class; diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php old mode 100755 new mode 100644 index a5eae8b727..afd4b41a12 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -19,12 +19,11 @@ namespace Doctrine\ORM\Internal\Hydration; -use PDO, - Doctrine\DBAL\Connection, - Doctrine\DBAL\Types\Type, - Doctrine\ORM\EntityManager, - Doctrine\ORM\Events, - Doctrine\ORM\Mapping\ClassMetadata; +use PDO; +use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Events; +use Doctrine\ORM\Mapping\ClassMetadata; /** * Base class for all hydrators. A hydrator is a class that provides some form @@ -37,25 +36,53 @@ use PDO, */ abstract class AbstractHydrator { - /** @var \Doctrine\ORM\Query\ResultSetMapping The ResultSetMapping. */ + /** + * The ResultSetMapping. + * + * @var \Doctrine\ORM\Query\ResultSetMapping + */ protected $_rsm; - /** @var EntityManager The EntityManager instance. */ + /** + * The EntityManager instance. + * + * @var EntityManager + */ protected $_em; - /** @var \Doctrine\DBAL\Platforms\AbstractPlatform The dbms Platform instance */ + /** + * The dbms Platform instance. + * + * @var \Doctrine\DBAL\Platforms\AbstractPlatform + */ protected $_platform; - /** @var \Doctrine\ORM\UnitOfWork The UnitOfWork of the associated EntityManager. */ + /** + * The UnitOfWork of the associated EntityManager. + * + * @var \Doctrine\ORM\UnitOfWork + */ protected $_uow; - /** @var array The cache used during row-by-row hydration. */ + /** + * The cache used during row-by-row hydration. + * + * @var array + */ protected $_cache = array(); - /** @var \Doctrine\DBAL\Driver\Statement The statement that provides the data to hydrate. */ + /** + * The statement that provides the data to hydrate. + * + * @var \Doctrine\DBAL\Driver\Statement + */ protected $_stmt; - /** @var array The query hints. */ + /** + * The query hints. + * + * @var array + */ protected $_hints; /** @@ -75,6 +102,7 @@ abstract class AbstractHydrator * * @param object $stmt * @param object $resultSetMapping + * @param array $hints * * @return IterableResult */ @@ -97,8 +125,9 @@ abstract class AbstractHydrator * * @param object $stmt * @param object $resultSetMapping - * @param array $hints - * @return mixed + * @param array $hints + * + * @return array */ public function hydrateAll($stmt, $resultSetMapping, array $hints = array()) { @@ -139,15 +168,20 @@ abstract class AbstractHydrator } /** - * Excutes one-time preparation tasks, once each time hydration is started + * Executes one-time preparation tasks, once each time hydration is started * through {@link hydrateAll} or {@link iterate()}. + * + * @return void */ protected function prepare() - {} + { + } /** - * Excutes one-time cleanup tasks at the end of a hydration that was initiated + * Executes one-time cleanup tasks at the end of a hydration that was initiated * through {@link hydrateAll} or {@link iterate()}. + * + * @return void */ protected function cleanup() { @@ -162,9 +196,13 @@ abstract class AbstractHydrator * * Template method. * - * @param array $data The row data. - * @param array $cache The cache to use. - * @param mixed $result The result to fill. + * @param array $data The row data. + * @param array $cache The cache to use. + * @param array $result The result to fill. + * + * @return void + * + * @throws HydrationException */ protected function hydrateRowData(array $data, array &$cache, array &$result) { @@ -173,6 +211,8 @@ abstract class AbstractHydrator /** * Hydrates all rows from the current statement instance at once. + * + * @return array */ abstract protected function hydrateAllData(); @@ -183,11 +223,11 @@ abstract class AbstractHydrator * Puts the elements of a result row into a new array, grouped by the dql alias * they belong to. The column names in the result set are mapped to their * field names during this procedure as well as any necessary conversions on - * the values applied. Scalar values are kept in a specfic key 'scalars'. + * the values applied. Scalar values are kept in a specific key 'scalars'. * - * @param array $data SQL Result Row - * @param array &$cache Cache for column to field result information - * @param array &$id Dql-Alias => ID-Hash + * @param array $data SQL Result Row. + * @param array &$cache Cache for column to field result information. + * @param array &$id Dql-Alias => ID-Hash. * @param array &$nonemptyComponents Does this DQL-Alias has at least one non NULL value? * * @return array An array with all the fields (name => value) of the data row, @@ -234,6 +274,25 @@ abstract class AbstractHydrator // maybe from an additional column that has not been defined in a NativeQuery ResultSetMapping. continue 2; } + + if (isset($this->_rsm->newObjectMappings[$key])) { + $mapping = $this->_rsm->newObjectMappings[$key]; + + $cache[$key]['isNewObjectParameter'] = true; + $cache[$key]['argIndex'] = $mapping['argIndex']; + $cache[$key]['objIndex'] = $mapping['objIndex']; + $cache[$key]['class'] = new \ReflectionClass($mapping['className']); + } + } + + if (isset($cache[$key]['isNewObjectParameter'])) { + $class = $cache[$key]['class']; + $argIndex = $cache[$key]['argIndex']; + $objIndex = $cache[$key]['objIndex']; + $value = $cache[$key]['type']->convertToPHPValue($value, $this->_platform); + + $rowData['newObjects'][$objIndex]['class'] = $class; + $rowData['newObjects'][$objIndex]['args'][$argIndex] = $value; } if (isset($cache[$key]['isScalar'])) { @@ -262,7 +321,7 @@ abstract class AbstractHydrator } // in an inheritance hierarchy the same field could be defined several times. - // We overwrite this value so long we dont have a non-null value, that value we keep. + // We overwrite this value so long we don't have a non-null value, that value we keep. // Per definition it cannot be that a field is defined several times and has several values. if (isset($rowData[$dqlAlias][$cache[$key]['fieldName']]) && $value === null) { continue; @@ -352,9 +411,11 @@ abstract class AbstractHydrator /** * Register entity as managed in UnitOfWork. * - * @param \Doctrine\ORM\Mapping\ClassMetadata $class - * @param object $entity - * @param array $data + * @param ClassMetadata $class + * @param object $entity + * @param array $data + * + * @return void * * @todo The "$id" generation is the same of UnitOfWork#createEntity. Remove this duplication somehow */ @@ -383,6 +444,10 @@ abstract class AbstractHydrator /** * When executed in a hydrate() loop we have to clear internal state to * decrease memory consumption. + * + * @param mixed $eventArgs + * + * @return void */ public function onClear($eventArgs) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php old mode 100755 new mode 100644 index 8f7178e99a..c336e7a5d1 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -19,7 +19,8 @@ namespace Doctrine\ORM\Internal\Hydration; -use PDO, Doctrine\DBAL\Connection, Doctrine\ORM\Mapping\ClassMetadata; +use PDO; +use Doctrine\ORM\Mapping\ClassMetadata; /** * The ArrayHydrator produces a nested array "graph" that is often (not always) @@ -31,12 +32,39 @@ use PDO, Doctrine\DBAL\Connection, Doctrine\ORM\Mapping\ClassMetadata; */ class ArrayHydrator extends AbstractHydrator { + /** + * @var array + */ private $_ce = array(); + + /** + * @var array + */ private $_rootAliases = array(); + + /** + * @var bool + */ private $_isSimpleQuery = false; + + /** + * @var array + */ private $_identifierMap = array(); + + /** + * @var array + */ private $_resultPointers = array(); + + /** + * @var array + */ private $_idTemplate = array(); + + /** + * @var int + */ private $_resultCounter = 0; /** @@ -118,6 +146,7 @@ class ArrayHydrator extends AbstractHydrator $baseElement =& $this->_resultPointers[$parent]; } else { unset($this->_resultPointers[$dqlAlias]); // Ticket #1228 + continue; } @@ -139,6 +168,7 @@ class ArrayHydrator extends AbstractHydrator if ( ! $indexExists || ! $indexIsValid) { $element = $data; + if (isset($this->_rsm->indexByMap[$dqlAlias])) { $baseElement[$relationAlias][$row[$this->_rsm->indexByMap[$dqlAlias]]] = $element; } else { @@ -155,7 +185,10 @@ class ArrayHydrator extends AbstractHydrator } else { $oneToOne = true; - if ( ! isset($nonemptyComponents[$dqlAlias]) && ! isset($baseElement[$relationAlias])) { + if ( + ( ! isset($nonemptyComponents[$dqlAlias])) && + ( ! isset($baseElement[$relationAlias])) + ) { $baseElement[$relationAlias] = null; } else if ( ! isset($baseElement[$relationAlias])) { $baseElement[$relationAlias] = $data; @@ -164,10 +197,9 @@ class ArrayHydrator extends AbstractHydrator $coll =& $baseElement[$relationAlias]; - if ($coll !== null) { + if (is_array($coll)) { $this->updateResultPointer($coll, $index, $dqlAlias, $oneToOne); } - } else { // It's a root result element @@ -176,22 +208,21 @@ class ArrayHydrator extends AbstractHydrator // if this row has a NULL value for the root result id then make it a null result. if ( ! isset($nonemptyComponents[$dqlAlias]) ) { - if ($this->_rsm->isMixed) { - $result[] = array($entityKey => null); - } else { - $result[] = null; - } + $result[] = $this->_rsm->isMixed + ? array($entityKey => null) + : null; + $resultKey = $this->_resultCounter; ++$this->_resultCounter; + continue; } // Check for an existing element if ($this->_isSimpleQuery || ! isset($this->_identifierMap[$dqlAlias][$id[$dqlAlias]])) { - $element = $rowData[$dqlAlias]; - if ($this->_rsm->isMixed) { - $element = array($entityKey => $element); - } + $element = $this->_rsm->isMixed + ? array($entityKey => $rowData[$dqlAlias]) + : $rowData[$dqlAlias]; if (isset($this->_rsm->indexByMap[$dqlAlias])) { $resultKey = $row[$this->_rsm->indexByMap[$dqlAlias]]; @@ -199,6 +230,7 @@ class ArrayHydrator extends AbstractHydrator } else { $resultKey = $this->_resultCounter; $result[] = $element; + ++$this->_resultCounter; } @@ -206,11 +238,13 @@ class ArrayHydrator extends AbstractHydrator } else { $index = $this->_identifierMap[$dqlAlias][$id[$dqlAlias]]; $resultKey = $index; + /*if ($this->_rsm->isMixed) { $result[] =& $result[$index]; ++$this->_resultCounter; }*/ } + $this->updateResultPointer($result, $index, $dqlAlias, false); } } @@ -219,11 +253,9 @@ class ArrayHydrator extends AbstractHydrator if (isset($scalars)) { if ( ! isset($resultKey) ) { // this only ever happens when no object is fetched (scalar result only) - if (isset($this->_rsm->indexByMap['scalars'])) { - $resultKey = $row[$this->_rsm->indexByMap['scalars']]; - } else { - $resultKey = $this->_resultCounter - 1; - } + $resultKey = isset($this->_rsm->indexByMap['scalars']) + ? $row[$this->_rsm->indexByMap['scalars']] + : $this->_resultCounter - 1; } foreach ($scalars as $name => $value) { @@ -236,10 +268,12 @@ class ArrayHydrator extends AbstractHydrator * Updates the result pointer for an Entity. The result pointers point to the * last seen instance of each Entity type. This is used for graph construction. * - * @param array $coll The element. - * @param boolean|integer $index Index of the element in the collection. - * @param string $dqlAlias - * @param boolean $oneToOne Whether it is a single-valued association or not. + * @param array $coll The element. + * @param boolean|integer $index Index of the element in the collection. + * @param string $dqlAlias + * @param boolean $oneToOne Whether it is a single-valued association or not. + * + * @return void */ private function updateResultPointer(array &$coll, $index, $dqlAlias, $oneToOne) { @@ -249,6 +283,12 @@ class ArrayHydrator extends AbstractHydrator return; } + if ($oneToOne) { + $this->_resultPointers[$dqlAlias] =& $coll; + + return; + } + if ($index !== false) { $this->_resultPointers[$dqlAlias] =& $coll[$index]; @@ -259,12 +299,6 @@ class ArrayHydrator extends AbstractHydrator return; } - if ($oneToOne) { - $this->_resultPointers[$dqlAlias] =& $coll; - - return; - } - end($coll); $this->_resultPointers[$dqlAlias] =& $coll[key($coll)]; diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php old mode 100755 new mode 100644 index 2acc332252..c1c13c1f77 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php @@ -1,24 +1,55 @@ . + */ namespace Doctrine\ORM\Internal\Hydration; class HydrationException extends \Doctrine\ORM\ORMException { + /** + * @return HydrationException + */ public static function nonUniqueResult() { return new self("The result returned by the query was not unique."); } + /** + * @param string $alias + * @param string $parentAlias + * + * @return HydrationException + */ public static function parentObjectOfRelationNotFound($alias, $parentAlias) { return new self("The parent object of entity result with alias '$alias' was not found." . " The parent alias is '$parentAlias'."); } + /** + * @param string $dqlAlias + * + * @return HydrationException + */ public static function emptyDiscriminatorValue($dqlAlias) { return new self("The DQL alias '" . $dqlAlias . "' contains an entity ". - "of an inheritance hierachy with an empty discriminator value. This means " . + "of an inheritance hierarchy with an empty discriminator value. This means " . "that the database contains inconsistent data with an empty " . "discriminator value in a table row." ); @@ -26,10 +57,12 @@ class HydrationException extends \Doctrine\ORM\ORMException /** * @since 2.3 - * @param string $entityName - * @param string $discrColumnName - * @param string $dqlAlias - * @return HydrationException + * + * @param string $entityName + * @param string $discrColumnName + * @param string $dqlAlias + * + * @return HydrationException */ public static function missingDiscriminatorColumn($entityName, $discrColumnName, $dqlAlias) { @@ -41,10 +74,12 @@ class HydrationException extends \Doctrine\ORM\ORMException /** * @since 2.3 - * @param string $entityName - * @param string $discrColumnName - * @param string $dqlAlias - * @return HydrationException + * + * @param string $entityName + * @param string $discrColumnName + * @param string $dqlAlias + * + * @return HydrationException */ public static function missingDiscriminatorMetaMappingColumn($entityName, $discrColumnName, $dqlAlias) { @@ -53,4 +88,4 @@ class HydrationException extends \Doctrine\ORM\ORMException $discrColumnName, $entityName, $dqlAlias )); } -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php old mode 100755 new mode 100644 index d04fe0e84d..3bbf6724d1 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php @@ -44,7 +44,7 @@ class IterableResult implements \Iterator private $_key = -1; /** - * @var object + * @var object|null */ private $_current = null; @@ -56,6 +56,11 @@ class IterableResult implements \Iterator $this->_hydrator = $hydrator; } + /** + * @return void + * + * @throws HydrationException + */ public function rewind() { if ($this->_rewinded == true) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php old mode 100755 new mode 100644 index 5018281449..fafc497c0d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -19,16 +19,13 @@ namespace Doctrine\ORM\Internal\Hydration; -use PDO, - Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\PersistentCollection, - Doctrine\ORM\Query, - Doctrine\ORM\Event\LifecycleEventArgs, - Doctrine\ORM\Events, - Doctrine\Common\Collections\ArrayCollection, - Doctrine\Common\Collections\Collection, - Doctrine\ORM\UnitOfWork, - Doctrine\ORM\Proxy\Proxy; +use Doctrine\ORM\UnitOfWork; +use PDO; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\PersistentCollection; +use Doctrine\ORM\Query; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\Proxy\Proxy; /** * The ObjectHydrator constructs an object graph out of an SQL result set. @@ -36,46 +33,78 @@ use PDO, * @since 2.0 * @author Roman Borschel * @author Guilherme Blanco + * @author Fabio B. Silva * * @internal Highly performance-sensitive code. */ class ObjectHydrator extends AbstractHydrator { - /* Local ClassMetadata cache to avoid going to the EntityManager all the time. + /** + * Local ClassMetadata cache to avoid going to the EntityManager all the time. * This local cache is maintained between hydration runs and not cleared. + * + * @var array */ - private $_ce = array(); + private $ce = array(); /* The following parts are reinitialized on every hydration run. */ - private $_identifierMap; - private $_resultPointers; - private $_idTemplate; - private $_resultCounter; - private $_rootAliases = array(); - private $_initializedCollections = array(); - private $_existingCollections = array(); + /** + * @var array + */ + private $identifierMap; + /** + * @var array + */ + private $resultPointers; - /** @override */ + /** + * @var array + */ + private $idTemplate; + + /** + * @var integer + */ + private $resultCounter; + + /** + * @var array + */ + private $rootAliases = array(); + + /** + * @var array + */ + private $initializedCollections = array(); + + /** + * @var array + */ + private $existingCollections = array(); + + /** + * {@inheritdoc} + */ protected function prepare() { - $this->_identifierMap = - $this->_resultPointers = - $this->_idTemplate = array(); + $this->identifierMap = + $this->resultPointers = + $this->idTemplate = array(); - $this->_resultCounter = 0; + $this->resultCounter = 0; if ( ! isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD])) { $this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] = true; } foreach ($this->_rsm->aliasMap as $dqlAlias => $className) { - $this->_identifierMap[$dqlAlias] = array(); - $this->_idTemplate[$dqlAlias] = ''; + $this->identifierMap[$dqlAlias] = array(); + $this->idTemplate[$dqlAlias] = ''; - if ( ! isset($this->_ce[$className])) { - $this->_ce[$className] = $this->_em->getClassMetadata($className); + if ( ! isset($this->ce[$className])) { + $this->ce[$className] = $this->_em->getClassMetadata($className); } // Remember which associations are "fetch joined", so that we know where to inject @@ -89,7 +118,7 @@ class ObjectHydrator extends AbstractHydrator } $sourceClassName = $this->_rsm->aliasMap[$this->_rsm->parentAliasMap[$dqlAlias]]; - $sourceClass = $this->_getClassMetadata($sourceClassName); + $sourceClass = $this->getClassMetadata($sourceClassName); $assoc = $sourceClass->associationMappings[$this->_rsm->relationMap[$dqlAlias]]; $this->_hints['fetched'][$this->_rsm->parentAliasMap[$dqlAlias]][$assoc['fieldName']] = true; @@ -107,7 +136,7 @@ class ObjectHydrator extends AbstractHydrator // handle fetch-joined owning side bi-directional one-to-one associations if ($assoc['inversedBy']) { - $class = $this->_ce[$className]; + $class = $this->ce[$className]; $inverseAssoc = $class->associationMappings[$assoc['inversedBy']]; if ( ! ($inverseAssoc['type'] & ClassMetadata::TO_ONE)) { @@ -128,10 +157,10 @@ class ObjectHydrator extends AbstractHydrator parent::cleanup(); - $this->_identifierMap = - $this->_initializedCollections = - $this->_existingCollections = - $this->_resultPointers = array(); + $this->identifierMap = + $this->initializedCollections = + $this->existingCollections = + $this->resultPointers = array(); if ($eagerLoad) { $this->_em->getUnitOfWork()->triggerEagerLoads(); @@ -151,7 +180,7 @@ class ObjectHydrator extends AbstractHydrator } // Take snapshots from all newly initialized collections - foreach ($this->_initializedCollections as $coll) { + foreach ($this->initializedCollections as $coll) { $coll->takeSnapshot(); } @@ -165,8 +194,10 @@ class ObjectHydrator extends AbstractHydrator * @param ClassMetadata $class * @param string $fieldName The name of the field on the entity that holds the collection. * @param string $parentDqlAlias Alias of the parent fetch joining this collection. + * + * @return \Doctrine\ORM\PersistentCollection */ - private function _initRelatedCollection($entity, $class, $fieldName, $parentDqlAlias) + private function initRelatedCollection($entity, $class, $fieldName, $parentDqlAlias) { $oid = spl_object_hash($entity); $relation = $class->associationMappings[$fieldName]; @@ -178,14 +209,14 @@ class ObjectHydrator extends AbstractHydrator if ( ! $value instanceof PersistentCollection) { $value = new PersistentCollection( - $this->_em, $this->_ce[$relation['targetEntity']], $value + $this->_em, $this->ce[$relation['targetEntity']], $value ); $value->setOwner($entity, $relation); $class->reflFields[$fieldName]->setValue($entity, $value); $this->_uow->setOriginalEntityProperty($oid, $fieldName, $value); - $this->_initializedCollections[$oid . $fieldName] = $value; + $this->initializedCollections[$oid . $fieldName] = $value; } else if ( isset($this->_hints[Query::HINT_REFRESH]) || isset($this->_hints['fetched'][$parentDqlAlias][$fieldName]) && @@ -196,10 +227,10 @@ class ObjectHydrator extends AbstractHydrator $value->setInitialized(true); $value->unwrap()->clear(); - $this->_initializedCollections[$oid . $fieldName] = $value; + $this->initializedCollections[$oid . $fieldName] = $value; } else { // Is already PersistentCollection, and DON'T REFRESH or FETCH-JOIN! - $this->_existingCollections[$oid . $fieldName] = $value; + $this->existingCollections[$oid . $fieldName] = $value; } return $value; @@ -210,9 +241,12 @@ class ObjectHydrator extends AbstractHydrator * * @param array $data The instance data. * @param string $dqlAlias The DQL alias of the entity's class. + * * @return object The entity. + * + * @throws HydrationException */ - private function _getEntity(array $data, $dqlAlias) + private function getEntity(array $data, $dqlAlias) { $className = $this->_rsm->aliasMap[$dqlAlias]; @@ -232,13 +266,13 @@ class ObjectHydrator extends AbstractHydrator throw HydrationException::emptyDiscriminatorValue($dqlAlias); } - $className = $this->_ce[$className]->discriminatorMap[$data[$discrColumn]]; + $className = $this->ce[$className]->discriminatorMap[$data[$discrColumn]]; unset($data[$discrColumn]); } - if (isset($this->_hints[Query::HINT_REFRESH_ENTITY]) && isset($this->_rootAliases[$dqlAlias])) { - $this->registerManaged($this->_ce[$className], $this->_hints[Query::HINT_REFRESH_ENTITY], $data); + if (isset($this->_hints[Query::HINT_REFRESH_ENTITY]) && isset($this->rootAliases[$dqlAlias])) { + $this->registerManaged($this->ce[$className], $this->_hints[Query::HINT_REFRESH_ENTITY], $data); } $this->_hints['fetchAlias'] = $dqlAlias; @@ -249,12 +283,13 @@ class ObjectHydrator extends AbstractHydrator /** * @param string $className * @param array $data + * * @return mixed */ - private function _getEntityFromIdentityMap($className, array $data) + private function getEntityFromIdentityMap($className, array $data) { // TODO: Abstract this code and UnitOfWork::createEntity() equivalent? - $class = $this->_ce[$className]; + $class = $this->ce[$className]; /* @var $class ClassMetadata */ if ($class->isIdentifierComposite) { @@ -280,15 +315,16 @@ class ObjectHydrator extends AbstractHydrator * local cache. * * @param string $className The name of the class. + * * @return ClassMetadata */ - private function _getClassMetadata($className) + private function getClassMetadata($className) { - if ( ! isset($this->_ce[$className])) { - $this->_ce[$className] = $this->_em->getClassMetadata($className); + if ( ! isset($this->ce[$className])) { + $this->ce[$className] = $this->_em->getClassMetadata($className); } - return $this->_ce[$className]; + return $this->ce[$className]; } /** @@ -311,11 +347,13 @@ class ObjectHydrator extends AbstractHydrator * @param array $row The data of the row to process. * @param array $cache The cache to use. * @param array $result The result array to fill. + * + * @return void */ protected function hydrateRowData(array $row, array &$cache, array &$result) { // Initialize - $id = $this->_idTemplate; // initialize the id-memory + $id = $this->idTemplate; // initialize the id-memory $nonemptyComponents = array(); // Split the row data into chunks of class data. $rowData = $this->gatherRowData($row, $cache, $id, $nonemptyComponents); @@ -327,7 +365,18 @@ class ObjectHydrator extends AbstractHydrator unset($rowData['scalars']); if (empty($rowData)) { - ++$this->_resultCounter; + ++$this->resultCounter; + } + } + + // Extract "new" object constructor arguments. They're appended at the end. + if (isset($rowData['newObjects'])) { + $newObjects = $rowData['newObjects']; + + unset($rowData['newObjects']); + + if (empty($rowData)) { + ++$this->resultCounter; } } @@ -350,21 +399,21 @@ class ObjectHydrator extends AbstractHydrator } // Get a reference to the parent object to which the joined element belongs. - if ($this->_rsm->isMixed && isset($this->_rootAliases[$parentAlias])) { - $first = reset($this->_resultPointers); + if ($this->_rsm->isMixed && isset($this->rootAliases[$parentAlias])) { + $first = reset($this->resultPointers); $parentObject = $first[key($first)]; - } else if (isset($this->_resultPointers[$parentAlias])) { - $parentObject = $this->_resultPointers[$parentAlias]; + } else if (isset($this->resultPointers[$parentAlias])) { + $parentObject = $this->resultPointers[$parentAlias]; } else { // Parent object of relation not found, so skip it. continue; } - $parentClass = $this->_ce[$this->_rsm->aliasMap[$parentAlias]]; - $oid = spl_object_hash($parentObject); - $relationField = $this->_rsm->relationMap[$dqlAlias]; - $relation = $parentClass->associationMappings[$relationField]; - $reflField = $parentClass->reflFields[$relationField]; + $parentClass = $this->ce[$this->_rsm->aliasMap[$parentAlias]]; + $oid = spl_object_hash($parentObject); + $relationField = $this->_rsm->relationMap[$dqlAlias]; + $relation = $parentClass->associationMappings[$relationField]; + $reflField = $parentClass->reflFields[$relationField]; // Check the type of the relation (many or single-valued) if ( ! ($relation['type'] & ClassMetadata::TO_ONE)) { @@ -372,45 +421,45 @@ class ObjectHydrator extends AbstractHydrator // PATH A: Collection-valued association if (isset($nonemptyComponents[$dqlAlias])) { $collKey = $oid . $relationField; - if (isset($this->_initializedCollections[$collKey])) { - $reflFieldValue = $this->_initializedCollections[$collKey]; - } else if ( ! isset($this->_existingCollections[$collKey])) { - $reflFieldValue = $this->_initRelatedCollection($parentObject, $parentClass, $relationField, $parentAlias); + if (isset($this->initializedCollections[$collKey])) { + $reflFieldValue = $this->initializedCollections[$collKey]; + } else if ( ! isset($this->existingCollections[$collKey])) { + $reflFieldValue = $this->initRelatedCollection($parentObject, $parentClass, $relationField, $parentAlias); } - $indexExists = isset($this->_identifierMap[$path][$id[$parentAlias]][$id[$dqlAlias]]); - $index = $indexExists ? $this->_identifierMap[$path][$id[$parentAlias]][$id[$dqlAlias]] : false; - $indexIsValid = $index !== false ? isset($reflFieldValue[$index]) : false; + $indexExists = isset($this->identifierMap[$path][$id[$parentAlias]][$id[$dqlAlias]]); + $index = $indexExists ? $this->identifierMap[$path][$id[$parentAlias]][$id[$dqlAlias]] : false; + $indexIsValid = $index !== false ? isset($reflFieldValue[$index]) : false; if ( ! $indexExists || ! $indexIsValid) { - if (isset($this->_existingCollections[$collKey])) { + if (isset($this->existingCollections[$collKey])) { // Collection exists, only look for the element in the identity map. - if ($element = $this->_getEntityFromIdentityMap($entityName, $data)) { - $this->_resultPointers[$dqlAlias] = $element; + if ($element = $this->getEntityFromIdentityMap($entityName, $data)) { + $this->resultPointers[$dqlAlias] = $element; } else { - unset($this->_resultPointers[$dqlAlias]); + unset($this->resultPointers[$dqlAlias]); } } else { - $element = $this->_getEntity($data, $dqlAlias); + $element = $this->getEntity($data, $dqlAlias); if (isset($this->_rsm->indexByMap[$dqlAlias])) { $indexValue = $row[$this->_rsm->indexByMap[$dqlAlias]]; $reflFieldValue->hydrateSet($indexValue, $element); - $this->_identifierMap[$path][$id[$parentAlias]][$id[$dqlAlias]] = $indexValue; + $this->identifierMap[$path][$id[$parentAlias]][$id[$dqlAlias]] = $indexValue; } else { $reflFieldValue->hydrateAdd($element); $reflFieldValue->last(); - $this->_identifierMap[$path][$id[$parentAlias]][$id[$dqlAlias]] = $reflFieldValue->key(); + $this->identifierMap[$path][$id[$parentAlias]][$id[$dqlAlias]] = $reflFieldValue->key(); } // Update result pointer - $this->_resultPointers[$dqlAlias] = $element; + $this->resultPointers[$dqlAlias] = $element; } } else { // Update result pointer - $this->_resultPointers[$dqlAlias] = $reflFieldValue[$index]; + $this->resultPointers[$dqlAlias] = $reflFieldValue[$index]; } } else if ( ! $reflFieldValue) { - $reflFieldValue = $this->_initRelatedCollection($parentObject, $parentClass, $relationField, $parentAlias); + $reflFieldValue = $this->initRelatedCollection($parentObject, $parentClass, $relationField, $parentAlias); } else if ($reflFieldValue instanceof PersistentCollection && $reflFieldValue->isInitialized() === false) { $reflFieldValue->setInitialized(true); } @@ -422,10 +471,10 @@ class ObjectHydrator extends AbstractHydrator // we only need to take action if this value is null, // we refresh the entity or its an unitialized proxy. if (isset($nonemptyComponents[$dqlAlias])) { - $element = $this->_getEntity($data, $dqlAlias); + $element = $this->getEntity($data, $dqlAlias); $reflField->setValue($parentObject, $element); $this->_uow->setOriginalEntityProperty($oid, $relationField, $element); - $targetClass = $this->_ce[$relation['targetEntity']]; + $targetClass = $this->ce[$relation['targetEntity']]; if ($relation['isOwningSide']) { //TODO: Just check hints['fetched'] here? @@ -446,7 +495,7 @@ class ObjectHydrator extends AbstractHydrator $this->_uow->setOriginalEntityProperty(spl_object_hash($element), $relation['mappedBy'], $parentObject); } // Update result pointer - $this->_resultPointers[$dqlAlias] = $element; + $this->resultPointers[$dqlAlias] = $element; } else { $this->_uow->setOriginalEntityProperty($oid, $relationField, null); $reflField->setValue($parentObject, null); @@ -454,12 +503,12 @@ class ObjectHydrator extends AbstractHydrator // else leave $reflFieldValue null for single-valued associations } else { // Update result pointer - $this->_resultPointers[$dqlAlias] = $reflFieldValue; + $this->resultPointers[$dqlAlias] = $reflFieldValue; } } } else { // PATH C: Its a root result element - $this->_rootAliases[$dqlAlias] = true; // Mark as root alias + $this->rootAliases[$dqlAlias] = true; // Mark as root alias $entityKey = $this->_rsm->entityMappings[$dqlAlias] ?: 0; // if this row has a NULL value for the root result id then make it a null result. @@ -469,14 +518,15 @@ class ObjectHydrator extends AbstractHydrator } else { $result[] = null; } - $resultKey = $this->_resultCounter; - ++$this->_resultCounter; + $resultKey = $this->resultCounter; + ++$this->resultCounter; continue; } // check for existing result from the iterations before - if ( ! isset($this->_identifierMap[$dqlAlias][$id[$dqlAlias]])) { - $element = $this->_getEntity($rowData[$dqlAlias], $dqlAlias); + if ( ! isset($this->identifierMap[$dqlAlias][$id[$dqlAlias]])) { + $element = $this->getEntity($rowData[$dqlAlias], $dqlAlias); + if ($this->_rsm->isMixed) { $element = array($entityKey => $element); } @@ -490,8 +540,8 @@ class ObjectHydrator extends AbstractHydrator $result[$resultKey] = $element; } else { - $resultKey = $this->_resultCounter; - ++$this->_resultCounter; + $resultKey = $this->resultCounter; + ++$this->resultCounter; if (isset($this->_hints['collection'])) { $this->_hints['collection']->hydrateAdd($element); @@ -500,15 +550,15 @@ class ObjectHydrator extends AbstractHydrator $result[] = $element; } - $this->_identifierMap[$dqlAlias][$id[$dqlAlias]] = $resultKey; + $this->identifierMap[$dqlAlias][$id[$dqlAlias]] = $resultKey; // Update result pointer - $this->_resultPointers[$dqlAlias] = $element; + $this->resultPointers[$dqlAlias] = $element; } else { // Update result pointer - $index = $this->_identifierMap[$dqlAlias][$id[$dqlAlias]]; - $this->_resultPointers[$dqlAlias] = $result[$index]; + $index = $this->identifierMap[$dqlAlias][$id[$dqlAlias]]; + $this->resultPointers[$dqlAlias] = $result[$index]; $resultKey = $index; /*if ($this->_rsm->isMixed) { $result[] = $result[$index]; @@ -524,7 +574,7 @@ class ObjectHydrator extends AbstractHydrator if (isset($this->_rsm->indexByMap['scalars'])) { $resultKey = $row[$this->_rsm->indexByMap['scalars']]; } else { - $resultKey = $this->_resultCounter - 1; + $resultKey = $this->resultCounter - 1; } } @@ -532,21 +582,48 @@ class ObjectHydrator extends AbstractHydrator $result[$resultKey][$name] = $value; } } + + // Append new object to mixed result sets + if (isset($newObjects)) { + if ( ! isset($resultKey) ) { + $resultKey = $this->resultCounter - 1; + } + + $count = count($newObjects); + + foreach ($newObjects as $objIndex => $newObject) { + $class = $newObject['class']; + $args = $newObject['args']; + $obj = $class->newInstanceArgs($args); + + if ($count === 1) { + $result[$resultKey] = $obj; + + continue; + } + + $result[$resultKey][$objIndex] = $obj; + } + } } /** * When executed in a hydrate() loop we may have to clear internal state to * decrease memory consumption. + * + * @param mixed $eventArgs + * + * @return void */ public function onClear($eventArgs) { parent::onClear($eventArgs); - $aliases = array_keys($this->_identifierMap); - $this->_identifierMap = array(); + $aliases = array_keys($this->identifierMap); + $this->identifierMap = array(); foreach ($aliases as $alias) { - $this->_identifierMap[$alias] = array(); + $this->identifierMap[$alias] = array(); } } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php old mode 100755 new mode 100644 index 613f94cf0e..eb0982c7d6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -19,12 +19,10 @@ namespace Doctrine\ORM\Internal\Hydration; -use \PDO, - Doctrine\DBAL\Types\Type, - Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Event\LifecycleEventArgs, - Doctrine\ORM\Events, - Doctrine\ORM\Query; +use PDO; +use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Query; class SimpleObjectHydrator extends AbstractHydrator { @@ -116,9 +114,8 @@ class SimpleObjectHydrator extends AbstractHydrator } // Convert field to a valid PHP value - if (isset($cache[$column]['field'])) { - $type = Type::getType($cache[$column]['class']->fieldMappings[$cache[$column]['name']]['type']); - $value = $type->convertToPHPValue($value, $this->_platform); + if (isset($cache[$column]['type'])) { + $value = Type::getType($cache[$column]['type'])->convertToPHPValue($value, $this->_platform); } // Prevent overwrite in case of inherit classes using same property name (See AbstractHydrator) @@ -147,44 +144,36 @@ class SimpleObjectHydrator extends AbstractHydrator */ protected function hydrateColumnInfo($entityName, $column) { - switch (true) { - case (isset($this->_rsm->fieldMappings[$column])): - $class = isset($this->declaringClasses[$column]) - ? $this->declaringClasses[$column] - : $this->class; - // If class is not part of the inheritance, ignore - if ( ! ($class->name === $entityName || is_subclass_of($entityName, $class->name))) { - return null; - } + if (isset($this->_rsm->fieldMappings[$column])) { + $name = $this->_rsm->fieldMappings[$column]; + $class = isset($this->declaringClasses[$column]) + ? $this->declaringClasses[$column] + : $this->class; - return array( - 'class' => $class, - 'name' => $this->_rsm->fieldMappings[$column], - 'field' => true, - ); - - case (isset($this->_rsm->relationMap[$column])): - $class = isset($this->_rsm->relationMap[$column]) - ? $this->_rsm->relationMap[$column] - : $this->class; - - // If class is not self referencing, ignore - if ( ! ($class === $entityName || is_subclass_of($entityName, $class))) { - return null; - } - - // TODO: Decide what to do with associations. It seems original code is incomplete. - // One solution is to load the association, but it might require extra efforts. - return array('name' => $column); - - case (isset($this->_rsm->metaMappings[$column])): - return array( - 'name' => $this->_rsm->metaMappings[$column] - ); - - default: + // If class is not part of the inheritance, ignore + if ( ! ($class->name === $entityName || is_subclass_of($entityName, $class->name))) { return null; + } + + return array( + 'name' => $name, + 'type' => $class->fieldMappings[$name]['type'] + ); } + + if (isset($this->_rsm->metaMappings[$column])) { + return array( + 'name' => $this->_rsm->metaMappings[$column], + 'type' => (isset($this->_rsm->typeMappings[$column]) ? $this->_rsm->typeMappings[$column] : null) + ); + } + + // An ObjectHydrator should be used instead of SimpleObjectHydrator + if (isset($this->_rsm->relationMap[$column])) { + throw new \Exception(sprintf('Unable to retrieve association information for column "%s"', $column)); + } + + return null; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php old mode 100755 new mode 100644 index a23c4cefe3..b94724176e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php @@ -19,9 +19,8 @@ namespace Doctrine\ORM\Internal\Hydration; -use Doctrine\DBAL\Connection, - Doctrine\ORM\NoResultException, - Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\NoResultException; +use Doctrine\ORM\NonUniqueResultException; /** * Hydrator that hydrates a single scalar value from the result set. diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Annotation.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Annotation.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php new file mode 100644 index 0000000000..440c3909f7 --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php @@ -0,0 +1,97 @@ +. + */ + +namespace Doctrine\ORM\Mapping; + +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\DBAL\Platforms\AbstractPlatform; + +/** + * ANSI compliant quote strategy, this strategy does not apply any quote. + * To use this strategy all mapped tables and columns should be ANSI compliant. + * + * @since 2.5 + * @author Fabio B. Silva + */ +class AnsiQuoteStrategy implements QuoteStrategy +{ + /** + * {@inheritdoc} + */ + public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform) + { + return $class->fieldMappings[$fieldName]['columnName']; + } + + /** + * {@inheritdoc} + */ + public function getTableName(ClassMetadata $class, AbstractPlatform $platform) + { + return $class->table['name']; + } + + /** + * {@inheritdoc} + */ + public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform) + { + return $definition['sequenceName']; + } + + /** + * {@inheritdoc} + */ + public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform) + { + return $joinColumn['name']; + } + + /** + * {@inheritdoc} + */ + public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform) + { + return $joinColumn['referencedColumnName']; + } + + /** + * {@inheritdoc} + */ + public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform) + { + return $association['joinTable']['name']; + } + + /** + * {@inheritdoc} + */ + public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform) + { + return $class->identifier; + } + + /** + * {@inheritdoc} + */ + public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = null) + { + return $platform->getSQLResultCasing($columnName . $counter); + } +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AssociationOverride.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AssociationOverride.php old mode 100755 new mode 100644 index 8776be67a9..1a9a31f184 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AssociationOverride.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AssociationOverride.php @@ -30,9 +30,8 @@ namespace Doctrine\ORM\Mapping; */ final class AssociationOverride implements Annotation { - /** - * The name of the relationship property whose mapping is being overridden + * The name of the relationship property whose mapping is being overridden. * * @var string */ @@ -45,12 +44,10 @@ final class AssociationOverride implements Annotation */ public $joinColumns; - /** * The join table that maps the relationship. * * @var \Doctrine\ORM\Mapping\JoinTable */ public $joinTable; - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AssociationOverrides.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AssociationOverrides.php old mode 100755 new mode 100644 index b0a0c13933..217c9e4573 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AssociationOverrides.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AssociationOverrides.php @@ -30,12 +30,10 @@ namespace Doctrine\ORM\Mapping; */ final class AssociationOverrides implements Annotation { - /** - * Mapping overrides of relationship properties + * Mapping overrides of relationship properties. * * @var array<\Doctrine\ORM\Mapping\AssociationOverride> */ public $value; - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AttributeOverride.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AttributeOverride.php old mode 100755 new mode 100644 index ef9e6dd894..f86d3a1521 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AttributeOverride.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AttributeOverride.php @@ -30,7 +30,6 @@ namespace Doctrine\ORM\Mapping; */ final class AttributeOverride implements Annotation { - /** * The name of the property whose mapping is being overridden. * diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AttributeOverrides.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AttributeOverrides.php old mode 100755 new mode 100644 index 41f680d6a4..63b2cc66e7 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AttributeOverrides.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/AttributeOverrides.php @@ -30,12 +30,10 @@ namespace Doctrine\ORM\Mapping; */ final class AttributeOverrides implements Annotation { - /** * One or more field or property mapping overrides. * * @var array<\Doctrine\ORM\Mapping\AttributeOverride> */ public $value; - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php old mode 100755 new mode 100644 index d540774d4b..942a662e44 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php @@ -17,7 +17,6 @@ * . */ - namespace Doctrine\ORM\Mapping\Builder; use Doctrine\ORM\Mapping\ClassMetadata; @@ -35,19 +34,19 @@ class AssociationBuilder protected $mapping; /** - * @var array + * @var array|null */ protected $joinColumns; /** - * * @var int */ protected $type; /** * @param ClassMetadataBuilder $builder - * @param array $mapping + * @param array $mapping + * @param int $type */ public function __construct(ClassMetadataBuilder $builder, array $mapping, $type) { @@ -56,66 +55,103 @@ class AssociationBuilder $this->type = $type; } + /** + * @param string $fieldName + * + * @return AssociationBuilder + */ public function mappedBy($fieldName) { $this->mapping['mappedBy'] = $fieldName; return $this; } + /** + * @param string $fieldName + * + * @return AssociationBuilder + */ public function inversedBy($fieldName) { $this->mapping['inversedBy'] = $fieldName; return $this; } + /** + * @return AssociationBuilder + */ public function cascadeAll() { $this->mapping['cascade'] = array("ALL"); return $this; } + /** + * @return AssociationBuilder + */ public function cascadePersist() { $this->mapping['cascade'][] = "persist"; return $this; } + /** + * @return AssociationBuilder + */ public function cascadeRemove() { $this->mapping['cascade'][] = "remove"; return $this; } + /** + * @return AssociationBuilder + */ public function cascadeMerge() { $this->mapping['cascade'][] = "merge"; return $this; } + /** + * @return AssociationBuilder + */ public function cascadeDetach() { $this->mapping['cascade'][] = "detach"; return $this; } + /** + * @return AssociationBuilder + */ public function cascadeRefresh() { $this->mapping['cascade'][] = "refresh"; return $this; } + /** + * @return AssociationBuilder + */ public function fetchExtraLazy() { $this->mapping['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; return $this; } + /** + * @return AssociationBuilder + */ public function fetchEager() { $this->mapping['fetch'] = ClassMetadata::FETCH_EAGER; return $this; } + /** + * @return AssociationBuilder + */ public function fetchLazy() { $this->mapping['fetch'] = ClassMetadata::FETCH_LAZY; @@ -123,14 +159,16 @@ class AssociationBuilder } /** - * Add Join Columns + * Add Join Columns. * - * @param string $columnName - * @param string $referencedColumnName - * @param bool $nullable - * @param bool $unique - * @param string $onDelete - * @param string $columnDef + * @param string $columnName + * @param string $referencedColumnName + * @param bool $nullable + * @param bool $unique + * @param string|null $onDelete + * @param string|null $columnDef + * + * @return AssociationBuilder */ public function addJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null) { @@ -147,6 +185,8 @@ class AssociationBuilder /** * @return ClassMetadataBuilder + * + * @throws \InvalidArgumentException */ public function build() { @@ -160,7 +200,7 @@ class AssociationBuilder } else if ($this->type == ClassMetadata::ONE_TO_ONE) { $cm->mapOneToOne($mapping); } else { - throw new \InvalidArgumentException("Type should be a ToOne Assocation here"); + throw new \InvalidArgumentException("Type should be a ToOne Association here"); } return $this->builder; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php old mode 100755 new mode 100644 index fb7bbc40aa..774c9e06e3 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Mapping\Builder; -use Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadataInfo; /** * Builder Object for ClassMetadata @@ -55,7 +55,7 @@ class ClassMetadataBuilder } /** - * Mark the class as mapped superclass. + * Marks the class as mapped superclass. * * @return ClassMetadataBuilder */ @@ -67,9 +67,10 @@ class ClassMetadataBuilder } /** - * Set custom Repository class name + * Sets custom Repository class name. * * @param string $repositoryClassName + * * @return ClassMetadataBuilder */ public function setCustomRepositoryClass($repositoryClassName) @@ -80,7 +81,7 @@ class ClassMetadataBuilder } /** - * Mark class read only + * Marks class read only. * * @return ClassMetadataBuilder */ @@ -92,9 +93,10 @@ class ClassMetadataBuilder } /** - * Set the table name + * Sets the table name. * * @param string $name + * * @return ClassMetadataBuilder */ public function setTable($name) @@ -105,10 +107,11 @@ class ClassMetadataBuilder } /** - * Add Index + * Adds Index. * - * @param array $columns + * @param array $columns * @param string $name + * * @return ClassMetadataBuilder */ public function addIndex(array $columns, $name) @@ -123,10 +126,11 @@ class ClassMetadataBuilder } /** - * Add Unique Constraint + * Adds Unique Constraint. * - * @param array $columns + * @param array $columns * @param string $name + * * @return ClassMetadataBuilder */ public function addUniqueConstraint(array $columns, $name) @@ -141,10 +145,11 @@ class ClassMetadataBuilder } /** - * Add named query + * Adds named query. * * @param string $name * @param string $dqlQuery + * * @return ClassMetadataBuilder */ public function addNamedQuery($name, $dqlQuery) @@ -158,7 +163,7 @@ class ClassMetadataBuilder } /** - * Set class as root of a joined table inheritance hierachy. + * Sets class as root of a joined table inheritance hierarchy. * * @return ClassMetadataBuilder */ @@ -170,7 +175,7 @@ class ClassMetadataBuilder } /** - * Set class as root of a single table inheritance hierachy. + * Sets class as root of a single table inheritance hierarchy. * * @return ClassMetadataBuilder */ @@ -182,10 +187,13 @@ class ClassMetadataBuilder } /** - * Set the discriminator column details. + * Sets the discriminator column details. * * @param string $name * @param string $type + * @param int $length + * + * @return ClassMetadataBuilder */ public function setDiscriminatorColumn($name, $type = 'string', $length = 255) { @@ -199,10 +207,11 @@ class ClassMetadataBuilder } /** - * Add a subclass to this inheritance hierachy. + * Adds a subclass to this inheritance hierarchy. * * @param string $name * @param string $class + * * @return ClassMetadataBuilder */ public function addDiscriminatorMapClass($name, $class) @@ -213,7 +222,7 @@ class ClassMetadataBuilder } /** - * Set deferred explicit change tracking policy. + * Sets deferred explicit change tracking policy. * * @return ClassMetadataBuilder */ @@ -225,7 +234,7 @@ class ClassMetadataBuilder } /** - * Set notify change tracking policy. + * Sets notify change tracking policy. * * @return ClassMetadataBuilder */ @@ -237,10 +246,11 @@ class ClassMetadataBuilder } /** - * Add lifecycle event + * Adds lifecycle event. * * @param string $methodName * @param string $event + * * @return ClassMetadataBuilder */ public function addLifecycleEvent($methodName, $event) @@ -251,11 +261,13 @@ class ClassMetadataBuilder } /** - * Add Field + * Adds Field. * * @param string $name * @param string $type - * @param array $mapping + * @param array $mapping + * + * @return ClassMetadataBuilder */ public function addField($name, $type, array $mapping = array()) { @@ -268,10 +280,11 @@ class ClassMetadataBuilder } /** - * Create a field builder. + * Creates a field builder. * * @param string $name * @param string $type + * * @return FieldBuilder */ public function createField($name, $type) @@ -286,11 +299,12 @@ class ClassMetadataBuilder } /** - * Add a simple many to one association, optionally with the inversed by field. + * Adds a simple many to one association, optionally with the inversed by field. * - * @param string $name - * @param string $targetEntity + * @param string $name + * @param string $targetEntity * @param string|null $inversedBy + * * @return ClassMetadataBuilder */ public function addManyToOne($name, $targetEntity, $inversedBy = null) @@ -305,12 +319,13 @@ class ClassMetadataBuilder } /** - * Create a ManyToOne Assocation Builder. + * Creates a ManyToOne Association Builder. * * Note: This method does not add the association, you have to call build() on the AssociationBuilder. * * @param string $name * @param string $targetEntity + * * @return AssociationBuilder */ public function createManyToOne($name, $targetEntity) @@ -326,10 +341,11 @@ class ClassMetadataBuilder } /** - * Create OneToOne Assocation Builder + * Creates a OneToOne Association Builder. * * @param string $name * @param string $targetEntity + * * @return AssociationBuilder */ public function createOneToOne($name, $targetEntity) @@ -345,11 +361,12 @@ class ClassMetadataBuilder } /** - * Add simple inverse one-to-one assocation. + * Adds simple inverse one-to-one association. * * @param string $name * @param string $targetEntity * @param string $mappedBy + * * @return ClassMetadataBuilder */ public function addInverseOneToOne($name, $targetEntity, $mappedBy) @@ -361,11 +378,12 @@ class ClassMetadataBuilder } /** - * Add simple owning one-to-one assocation. + * Adds simple owning one-to-one association. + * + * @param string $name + * @param string $targetEntity + * @param string|null $inversedBy * - * @param string $name - * @param string $targetEntity - * @param string $inversedBy * @return ClassMetadataBuilder */ public function addOwningOneToOne($name, $targetEntity, $inversedBy = null) @@ -380,10 +398,11 @@ class ClassMetadataBuilder } /** - * Create ManyToMany Assocation Builder + * Creates a ManyToMany Association Builder. * * @param string $name * @param string $targetEntity + * * @return ManyToManyAssociationBuilder */ public function createManyToMany($name, $targetEntity) @@ -399,11 +418,12 @@ class ClassMetadataBuilder } /** - * Add a simple owning many to many assocation. + * Adds a simple owning many to many association. * - * @param string $name - * @param string $targetEntity + * @param string $name + * @param string $targetEntity * @param string|null $inversedBy + * * @return ClassMetadataBuilder */ public function addOwningManyToMany($name, $targetEntity, $inversedBy = null) @@ -418,11 +438,12 @@ class ClassMetadataBuilder } /** - * Add a simple inverse many to many assocation. + * Adds a simple inverse many to many association. * * @param string $name * @param string $targetEntity * @param string $mappedBy + * * @return ClassMetadataBuilder */ public function addInverseManyToMany($name, $targetEntity, $mappedBy) @@ -434,10 +455,11 @@ class ClassMetadataBuilder } /** - * Create a one to many assocation builder + * Creates a one to many association builder. * * @param string $name * @param string $targetEntity + * * @return OneToManyAssociationBuilder */ public function createOneToMany($name, $targetEntity) @@ -453,11 +475,12 @@ class ClassMetadataBuilder } /** - * Add simple OneToMany assocation. + * Adds simple OneToMany association. * * @param string $name * @param string $targetEntity * @param string $mappedBy + * * @return ClassMetadataBuilder */ public function addOneToMany($name, $targetEntity, $mappedBy) diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php new file mode 100644 index 0000000000..d17abeac52 --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php @@ -0,0 +1,72 @@ +. + */ + +namespace Doctrine\ORM\Mapping\Builder; + +use Doctrine\ORM\Mapping\MappingException; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Events; + +/** + * Builder for entity listeners. + * + * @since 2.4 + * @author Fabio B. Silva + */ +class EntityListenerBuilder +{ + /** + * @var array Hash-map to handle event names. + */ + static private $events = array( + Events::preRemove => true, + Events::postRemove => true, + Events::prePersist => true, + Events::postPersist => true, + Events::preUpdate => true, + Events::postUpdate => true, + Events::postLoad => true, + Events::preFlush => true + ); + + /** + * Lookup the entity class to find methods that match to event lifecycle names + * + * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata. + * @param string $className The listener class name. + * + * @throws \Doctrine\ORM\Mapping\MappingException When the listener class not found. + */ + static public function bindEntityListener(ClassMetadata $metadata, $className) + { + $class = $metadata->fullyQualifiedClassName($className); + + if ( ! class_exists($class)) { + throw MappingException::entityListenerClassNotFound($class, $className); + } + + foreach (get_class_methods($class) as $method) { + if ( ! isset(self::$events[$method])) { + continue; + } + + $metadata->addEntityListener($method, $class, $method); + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php old mode 100755 new mode 100644 index 49dd54cc81..a4eb8ccede --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php @@ -17,7 +17,6 @@ * . */ - namespace Doctrine\ORM\Mapping\Builder; /** @@ -34,10 +33,12 @@ class FieldBuilder * @var ClassMetadataBuilder */ private $builder; + /** * @var array */ private $mapping; + /** * @var bool */ @@ -54,9 +55,8 @@ class FieldBuilder private $sequenceDef; /** - * * @param ClassMetadataBuilder $builder - * @param array $mapping + * @param array $mapping */ public function __construct(ClassMetadataBuilder $builder, array $mapping) { @@ -65,9 +65,10 @@ class FieldBuilder } /** - * Set length. + * Sets length. * * @param int $length + * * @return FieldBuilder */ public function length($length) @@ -77,9 +78,10 @@ class FieldBuilder } /** - * Set nullable + * Sets nullable. + * + * @param bool $flag * - * @param bool * @return FieldBuilder */ public function nullable($flag = true) @@ -89,9 +91,10 @@ class FieldBuilder } /** - * Set Unique + * Sets Unique. + * + * @param bool $flag * - * @param bool * @return FieldBuilder */ public function unique($flag = true) @@ -101,9 +104,10 @@ class FieldBuilder } /** - * Set column name + * Sets column name. * * @param string $name + * * @return FieldBuilder */ public function columnName($name) @@ -113,9 +117,10 @@ class FieldBuilder } /** - * Set Precision + * Sets Precision. + * + * @param int $p * - * @param int $p * @return FieldBuilder */ public function precision($p) @@ -125,9 +130,10 @@ class FieldBuilder } /** - * Set scale. + * Sets scale. * * @param int $s + * * @return FieldBuilder */ public function scale($s) @@ -137,7 +143,7 @@ class FieldBuilder } /** - * Set field as primary key. + * Sets field as primary key. * * @return FieldBuilder */ @@ -148,7 +154,8 @@ class FieldBuilder } /** - * @param int $strategy + * @param string $strategy + * * @return FieldBuilder */ public function generatedValue($strategy = 'AUTO') @@ -158,7 +165,7 @@ class FieldBuilder } /** - * Set field versioned + * Sets field versioned. * * @return FieldBuilder */ @@ -169,11 +176,12 @@ class FieldBuilder } /** - * Set Sequence Generator + * Sets Sequence Generator. * * @param string $sequenceName - * @param int $allocationSize - * @param int $initialValue + * @param int $allocationSize + * @param int $initialValue + * * @return FieldBuilder */ public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initialValue = 1) @@ -187,9 +195,10 @@ class FieldBuilder } /** - * Set column definition. + * Sets column definition. * * @param string $def + * * @return FieldBuilder */ public function columnDefinition($def) @@ -199,7 +208,7 @@ class FieldBuilder } /** - * Finalize this field and attach it to the ClassMetadata. + * Finalizes this field and attach it to the ClassMetadata. * * Without this call a FieldBuilder has no effect on the ClassMetadata. * diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php old mode 100755 new mode 100644 index 17edeea402..0dc0af4876 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php @@ -17,7 +17,6 @@ * . */ - namespace Doctrine\ORM\Mapping\Builder; /** @@ -30,10 +29,21 @@ namespace Doctrine\ORM\Mapping\Builder; */ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder { + /** + * @var string|null + */ private $joinTableName; + /** + * @var array + */ private $inverseJoinColumns = array(); + /** + * @param string $name + * + * @return ManyToManyAssociationBuilder + */ public function setJoinTable($name) { $this->joinTableName = $name; @@ -41,14 +51,16 @@ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder } /** - * Add Inverse Join Columns + * Adds Inverse Join Columns. * - * @param string $columnName - * @param string $referencedColumnName - * @param bool $nullable - * @param bool $unique - * @param string $onDelete - * @param string $columnDef + * @param string $columnName + * @param string $referencedColumnName + * @param bool $nullable + * @param bool $unique + * @param string|null $onDelete + * @param string|null $columnDef + * + * @return ManyToManyAssociationBuilder */ public function addInverseJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php old mode 100755 new mode 100644 index 6f22fe22f4..d8f4c3953a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php @@ -17,7 +17,6 @@ * . */ - namespace Doctrine\ORM\Mapping\Builder; /** @@ -32,6 +31,7 @@ class OneToManyAssociationBuilder extends AssociationBuilder { /** * @param array $fieldNames + * * @return OneToManyAssociationBuilder */ public function setOrderBy(array $fieldNames) @@ -40,6 +40,11 @@ class OneToManyAssociationBuilder extends AssociationBuilder return $this; } + /** + * @param string $fieldName + * + * @return OneToManyAssociationBuilder + */ public function setIndexBy($fieldName) { $this->mapping['indexBy'] = $fieldName; diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php old mode 100755 new mode 100644 index bab34a6b51..3657b764f1 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php @@ -25,6 +25,12 @@ namespace Doctrine\ORM\Mapping; */ final class ChangeTrackingPolicy implements Annotation { - /** @var string */ + /** + * The change tracking policy. + * + * @var string + * + * @Enum({"DEFERRED_IMPLICIT", "DEFERRED_EXPLICIT", "NOTIFY"}) + */ public $value; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadata.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php old mode 100755 new mode 100644 index bf449a4506..9320d1b6d5 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -103,6 +103,10 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $class->setLifecycleCallbacks($parent->lifecycleCallbacks); $class->setChangeTrackingPolicy($parent->changeTrackingPolicy); + if ( ! empty($parent->customGeneratorDefinition)) { + $class->setCustomGeneratorDefinition($parent->customGeneratorDefinition); + } + if ($parent->isMappedSuperclass) { $class->setCustomRepositoryClass($parent->customRepositoryClassName); } @@ -156,6 +160,10 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $this->addInheritedSqlResultSetMappings($class, $parent); } + if ($parent && !empty($parent->entityListeners) && empty($class->entityListeners)) { + $class->entityListeners = $parent->entityListeners; + } + $class->setParentClasses($nonSuperclassParents); if ( $class->isRootEntity() && ! $class->isInheritanceTypeNone() && ! $class->discriminatorMap) { @@ -167,15 +175,17 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs); } - $this->wakeupReflection($class, $this->getReflectionService()); $this->validateRuntimeMetadata($class, $parent); } /** * Validate runtime metadata is correctly defined. * - * @param ClassMetadata $class - * @param $parent + * @param ClassMetadata $class + * @param ClassMetadataInterface|null $parent + * + * @return void + * * @throws MappingException */ protected function validateRuntimeMetadata($class, $parent) @@ -186,7 +196,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory } $class->validateIdentifier(); - $class->validateAssocations(); + $class->validateAssociations(); $class->validateLifecycleCallbacks($this->getReflectionService()); // verify inheritance @@ -227,6 +237,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory * each class as key. * * @param \Doctrine\ORM\Mapping\ClassMetadata $class + * * @throws MappingException */ private function addDefaultDiscriminatorMap(ClassMetadata $class) @@ -256,9 +267,10 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory } /** - * Get the lower-case short name of a class. + * Gets the lower-case short name of a class. * * @param string $className + * * @return string */ private function getShortName($className) @@ -276,6 +288,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory * * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass + * + * @return void */ private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass) { @@ -298,6 +312,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory * * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass + * + * @return void + * * @throws MappingException */ private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass) @@ -305,7 +322,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory foreach ($parentClass->associationMappings as $field => $mapping) { if ($parentClass->isMappedSuperclass) { if ($mapping['type'] & ClassMetadata::TO_MANY && !$mapping['isOwningSide']) { - throw MappingException::illegalToManyAssocationOnMappedSuperclass($parentClass->name, $field); + throw MappingException::illegalToManyAssociationOnMappedSuperclass($parentClass->name, $field); } $mapping['sourceEntity'] = $subClass->name; } @@ -325,8 +342,11 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory * Adds inherited named queries to the subclass mapping. * * @since 2.2 + * * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass + * + * @return void */ private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata $parentClass) { @@ -344,8 +364,11 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory * Adds inherited named native queries to the subclass mapping. * * @since 2.3 + * * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass + * + * @return void */ private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMetadata $parentClass) { @@ -366,8 +389,11 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory * Adds inherited sql result set mappings to the subclass mapping. * * @since 2.3 + * * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass + * + * @return void */ private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, ClassMetadata $parentClass) { @@ -397,6 +423,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory * most appropriate for the targeted database platform. * * @param ClassMetadataInfo $class + * + * @return void + * * @throws ORMException */ private function completeIdGeneratorMapping(ClassMetadataInfo $class) @@ -436,7 +465,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $sequenceName = $this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->targetPlatform); } - $generator = ($fieldName && $class->fieldMappings[$fieldName]['type'] === "bigint") + $generator = ($fieldName && $class->fieldMappings[$fieldName]['type'] === 'bigint') ? new BigIntegerIdentityGenerator($sequenceName) : new IdentityGenerator($sequenceName); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php old mode 100755 new mode 100644 index f040032a34..9b3b294925 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -26,10 +26,11 @@ use Doctrine\DBAL\Types\Type; use ReflectionClass; use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\ClassLoader; +use Doctrine\Common\EventArgs; /** * A ClassMetadata instance holds all the object-relational mapping metadata - * of an entity and it's associations. + * of an entity and its associations. * * Once populated, ClassMetadata instances are usually cached in a serialized form. * @@ -111,10 +112,12 @@ class ClassMetadataInfo implements ClassMetadata * portability is currently not guaranteed. */ const GENERATOR_TYPE_UUID = 6; + /** * CUSTOM means that customer will use own ID generator that supposedly work */ const GENERATOR_TYPE_CUSTOM = 7; + /** * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time * by doing a property-by-property comparison with the original data. This will @@ -188,6 +191,8 @@ class ClassMetadataInfo implements ClassMetadata /** * READ-ONLY: The name of the entity class. + * + * @var string */ public $name; @@ -195,6 +200,7 @@ class ClassMetadataInfo implements ClassMetadata * READ-ONLY: The namespace the entity class is contained in. * * @var string + * * @todo Not really needed. Usage could be localized. */ public $namespace; @@ -220,6 +226,7 @@ class ClassMetadataInfo implements ClassMetadata * * * @var array + * * @todo Merge with tableGeneratorDefinition into generic generatorDefinition */ public $customGeneratorDefinition; @@ -272,6 +279,8 @@ class ClassMetadataInfo implements ClassMetadata * 'resultSetMapping' => * ) * + * + * @var array */ public $namedNativeQueries = array(); @@ -286,6 +295,8 @@ class ClassMetadataInfo implements ClassMetadata * 'columns' => array() * ) * + * + * @var array */ public $sqlResultSetMappings = array(); @@ -307,7 +318,7 @@ class ClassMetadataInfo implements ClassMetadata /** * READ-ONLY: The Id generator type used by the class. * - * @var string + * @var int */ public $generatorType = self::GENERATOR_TYPE_NONE; @@ -347,7 +358,7 @@ class ClassMetadataInfo implements ClassMetadata * - scale (integer, optional, schema-only) * The scale of a decimal column. Only valid if the column type is decimal. * - [* - 'unique'] (string, optional, schema-only) + * - 'unique' (string, optional, schema-only) * Whether a unique constraint should be generated for the column. * * @var array @@ -369,6 +380,7 @@ class ClassMetadataInfo implements ClassMetadata * This is the reverse lookup map of $_fieldNames. * * @var array + * * @todo We could get rid of this array by just using $fieldMappings[$fieldName]['columnName']. */ public $columnNames = array(); @@ -380,6 +392,7 @@ class ClassMetadataInfo implements ClassMetadata * where a discriminator column is used. * * @var mixed + * * @see discriminatorColumn */ public $discriminatorValue; @@ -391,6 +404,7 @@ class ClassMetadataInfo implements ClassMetadata * where a discriminator column is used. * * @var mixed + * * @see discriminatorColumn */ public $discriminatorMap = array(); @@ -423,6 +437,13 @@ class ClassMetadataInfo implements ClassMetadata */ public $lifecycleCallbacks = array(); + /** + * READ-ONLY: The registered entity listeners. + * + * @var array + */ + public $entityListeners = array(); + /** * READ-ONLY: The association mappings of this class. * @@ -476,7 +497,6 @@ class ClassMetadataInfo implements ClassMetadata * ) * * - * * @var array */ public $associationMappings = array(); @@ -489,7 +509,7 @@ class ClassMetadataInfo implements ClassMetadata public $isIdentifierComposite = false; /** - * READ-ONLY: Flag indicating wheather the identifier/primary key contains at least one foreign key association. + * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. * * This flag is necessary because some code blocks require special treatment of this cases. * @@ -501,6 +521,7 @@ class ClassMetadataInfo implements ClassMetadata * READ-ONLY: The ID generator used for generating IDs for this class. * * @var \Doctrine\ORM\Id\AbstractIdGenerator + * * @todo Remove! */ public $idGenerator; @@ -519,6 +540,7 @@ class ClassMetadataInfo implements ClassMetadata * * * @var array + * * @todo Merge with tableGeneratorDefinition into generic generatorDefinition */ public $sequenceGeneratorDefinition; @@ -528,6 +550,7 @@ class ClassMetadataInfo implements ClassMetadata * TABLE generation strategy. * * @var array + * * @todo Merge with tableGeneratorDefinition into generic generatorDefinition */ public $tableGeneratorDefinition; @@ -543,14 +566,14 @@ class ClassMetadataInfo implements ClassMetadata * READ-ONLY: A flag for whether or not instances of this class are to be versioned * with optimistic locking. * - * @var boolean $isVersioned + * @var boolean */ public $isVersioned; /** * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). * - * @var mixed $versionField + * @var mixed */ public $versionField; @@ -573,7 +596,7 @@ class ClassMetadataInfo implements ClassMetadata public $isReadOnly = false; /** - * NamingStrategy determining the default column and table names + * NamingStrategy determining the default column and table names. * * @var \Doctrine\ORM\Mapping\NamingStrategy */ @@ -582,7 +605,7 @@ class ClassMetadataInfo implements ClassMetadata /** * The ReflectionProperty instances of the mapped class. * - * @var array + * @var \ReflectionProperty[] */ public $reflFields = array(); @@ -597,8 +620,8 @@ class ClassMetadataInfo implements ClassMetadata * Initializes a new ClassMetadata instance that will hold the object-relational mapping * metadata of the class with the given name. * - * @param string $entityName The name of the entity class the new instance is used for. - * @param NamingStrategy $namingStrategy + * @param string $entityName The name of the entity class the new instance is used for. + * @param NamingStrategy|null $namingStrategy */ public function __construct($entityName, NamingStrategy $namingStrategy = null) { @@ -608,7 +631,7 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Gets the ReflectionPropertys of the mapped class. + * Gets the ReflectionProperties of the mapped class. * * @return array An array of ReflectionProperty instances. */ @@ -621,6 +644,7 @@ class ClassMetadataInfo implements ClassMetadata * Gets a ReflectionProperty for a specific field of the mapped class. * * @param string $name + * * @return \ReflectionProperty */ public function getReflectionProperty($name) @@ -632,6 +656,7 @@ class ClassMetadataInfo implements ClassMetadata * Gets the ReflectionProperty for the single identifier field. * * @return \ReflectionProperty + * * @throws BadMethodCallException If the class has a composite identifier. */ public function getSingleIdReflectionProperty() @@ -649,6 +674,7 @@ class ClassMetadataInfo implements ClassMetadata * with the same order as the field order in {@link identifier}. * * @param object $entity + * * @return array */ public function getIdentifierValues($entity) @@ -667,20 +693,24 @@ class ClassMetadataInfo implements ClassMetadata return $id; } - $value = $this->reflFields[$this->identifier[0]]->getValue($entity); + $id = $this->identifier[0]; + $value = $this->reflFields[$id]->getValue($entity); - if ($value !== null) { - return array($this->identifier[0] => $value); + if (null === $value) { + return array(); } - return array(); + return array($id => $value); } /** * Populates the entity identifier of an entity. * * @param object $entity - * @param mixed $id + * @param mixed $id + * + * @return void + * * @todo Rename to assignIdentifier() */ public function setIdentifierValues($entity, array $id) @@ -695,7 +725,9 @@ class ClassMetadataInfo implements ClassMetadata * * @param object $entity * @param string $field - * @param mixed $value + * @param mixed $value + * + * @return void */ public function setFieldValue($entity, $field, $value) { @@ -707,6 +739,8 @@ class ClassMetadataInfo implements ClassMetadata * * @param object $entity * @param string $field + * + * @return mixed */ public function getFieldValue($entity, $field) { @@ -717,6 +751,7 @@ class ClassMetadataInfo implements ClassMetadata * Creates a string representation of this instance. * * @return string The string representation of this instance. + * * @todo Construct meaningful string representation. */ public function __toString() @@ -796,6 +831,10 @@ class ClassMetadataInfo implements ClassMetadata $serialized[] = 'lifecycleCallbacks'; } + if ($this->entityListeners) { + $serialized[] = 'entityListeners'; + } + if ($this->namedQueries) { $serialized[] = 'namedQueries'; } @@ -836,6 +875,7 @@ class ClassMetadataInfo implements ClassMetadata * Restores some state that can not be serialized/unserialized. * * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService + * * @return void */ public function wakeupReflection($reflService) @@ -861,6 +901,8 @@ class ClassMetadataInfo implements ClassMetadata * metadata of the class with the given name. * * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service. + * + * @return void */ public function initializeReflection($reflService) { @@ -875,10 +917,11 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Validate Identifier + * Validates Identifier. + * + * @return void * * @throws MappingException - * @return void */ public function validateIdentifier() { @@ -893,12 +936,13 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Validate association targets actually exist. + * Validates association targets actually exist. + * + * @return void * * @throws MappingException - * @return void */ - public function validateAssocations() + public function validateAssociations() { foreach ($this->associationMappings as $mapping) { if ( ! ClassLoader::classExists($mapping['targetEntity']) ) { @@ -908,11 +952,13 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Validate lifecycle callbacks + * Validates lifecycle callbacks. * * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService - * @throws MappingException + * * @return void + * + * @throws MappingException */ public function validateLifecycleCallbacks($reflService) { @@ -937,6 +983,8 @@ class ClassMetadataInfo implements ClassMetadata * Sets the change tracking policy used by this class. * * @param integer $policy + * + * @return void */ public function setChangeTrackingPolicy($policy) { @@ -976,9 +1024,10 @@ class ClassMetadataInfo implements ClassMetadata /** * Checks whether a field is part of the identifier/primary key field(s). * - * @param string $fieldName The field name - * @return boolean TRUE if the field is part of the table identifier/primary key field(s), - * FALSE otherwise. + * @param string $fieldName The field name. + * + * @return boolean TRUE if the field is part of the table identifier/primary key field(s), + * FALSE otherwise. */ public function isIdentifier($fieldName) { @@ -989,10 +1038,11 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Check if the field is unique. + * Checks if the field is unique. * - * @param string $fieldName The field name - * @return boolean TRUE if the field is unique, FALSE otherwise. + * @param string $fieldName The field name. + * + * @return boolean TRUE if the field is unique, FALSE otherwise. */ public function isUniqueField($fieldName) { @@ -1004,10 +1054,11 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Check if the field is not null. + * Checks if the field is not null. * - * @param string $fieldName The field name - * @return boolean TRUE if the field is not null, FALSE otherwise. + * @param string $fieldName The field name. + * + * @return boolean TRUE if the field is not null, FALSE otherwise. */ public function isNullable($fieldName) { @@ -1024,7 +1075,8 @@ class ClassMetadataInfo implements ClassMetadata * is returned. * * @param string $fieldName The field name. - * @return string The column name. + * + * @return string The column name. */ public function getColumnName($fieldName) { @@ -1036,9 +1088,11 @@ class ClassMetadataInfo implements ClassMetadata * Gets the mapping of a (regular) field that holds some data but not a * reference to another object. * - * @param string $fieldName The field name. - * @throws MappingException + * @param string $fieldName The field name. + * * @return array The field mapping. + * + * @throws MappingException */ public function getFieldMapping($fieldName) { @@ -1052,10 +1106,13 @@ class ClassMetadataInfo implements ClassMetadata * Gets the mapping of an association. * * @see ClassMetadataInfo::$associationMappings - * @param string $fieldName The field name that represents the association in - * the object model. - * @throws MappingException + * + * @param string $fieldName The field name that represents the association in + * the object model. + * * @return array The mapping. + * + * @throws MappingException */ public function getAssociationMapping($fieldName) { @@ -1079,8 +1136,9 @@ class ClassMetadataInfo implements ClassMetadata * Gets the field name for a column name. * If no field name can be found the column name is returned. * - * @param string $columnName column name - * @return string column alias + * @param string $columnName The column name. + * + * @return string The column alias. */ public function getFieldName($columnName) { @@ -1092,9 +1150,12 @@ class ClassMetadataInfo implements ClassMetadata * Gets the named query. * * @see ClassMetadataInfo::$namedQueries - * @throws MappingException - * @param string $queryName The query name + * + * @param string $queryName The query name. + * * @return string + * + * @throws MappingException */ public function getNamedQuery($queryName) { @@ -1118,9 +1179,12 @@ class ClassMetadataInfo implements ClassMetadata * Gets the named native query. * * @see ClassMetadataInfo::$namedNativeQueries - * @throws MappingException - * @param string $queryName The query name - * @return array + * + * @param string $queryName The query name. + * + * @return array + * + * @throws MappingException */ public function getNamedNativeQuery($queryName) { @@ -1145,9 +1209,12 @@ class ClassMetadataInfo implements ClassMetadata * Gets the result set mapping. * * @see ClassMetadataInfo::$sqlResultSetMappings - * @throws MappingException - * @param string $name The result set mapping name - * @return array + * + * @param string $name The result set mapping name. + * + * @return array + * + * @throws MappingException */ public function getSqlResultSetMapping($name) { @@ -1171,9 +1238,11 @@ class ClassMetadataInfo implements ClassMetadata /** * Validates & completes the given field mapping. * - * @param array $mapping The field mapping to validated & complete. - * @throws MappingException + * @param array $mapping The field mapping to validate & complete. + * * @return array The validated and completed field mapping. + * + * @throws MappingException */ protected function _validateAndCompleteFieldMapping(array &$mapping) { @@ -1188,7 +1257,7 @@ class ClassMetadataInfo implements ClassMetadata // Complete fieldName and columnName mapping if ( ! isset($mapping['columnName'])) { - $mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName']); + $mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name); } if ($mapping['columnName'][0] === '`') { @@ -1232,7 +1301,9 @@ class ClassMetadataInfo implements ClassMetadata * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many). * * @param array $mapping The mapping. + * * @return array The updated mapping. + * * @throws MappingException If something is wrong with the mapping. */ protected function _validateAndCompleteAssociationMapping(array $mapping) @@ -1255,10 +1326,7 @@ class ClassMetadataInfo implements ClassMetadata $mapping['sourceEntity'] = $this->name; if (isset($mapping['targetEntity'])) { - if (strlen($this->namespace) > 0 && strpos($mapping['targetEntity'], '\\') === false) { - $mapping['targetEntity'] = $this->namespace . '\\' . $mapping['targetEntity']; - } - + $mapping['targetEntity'] = $this->fullyQualifiedClassName($mapping['targetEntity']); $mapping['targetEntity'] = ltrim($mapping['targetEntity'], '\\'); } @@ -1313,7 +1381,7 @@ class ClassMetadataInfo implements ClassMetadata } if (isset($mapping['id']) && $mapping['id'] === true && $mapping['type'] & self::TO_MANY) { - throw MappingException::illegalToManyIdentifierAssoaction($this->name, $mapping['fieldName']); + throw MappingException::illegalToManyIdentifierAssociation($this->name, $mapping['fieldName']); } // Fetch mode. Default fetch mode to LAZY, if not set. @@ -1349,10 +1417,12 @@ class ClassMetadataInfo implements ClassMetadata /** * Validates & completes a one-to-one association mapping. * - * @param array $mapping The mapping to validate & complete. + * @param array $mapping The mapping to validate & complete. + * + * @return array The validated & completed mapping. + * * @throws RuntimeException * @throws MappingException - * @return array The validated & completed mapping.@override */ protected function _validateAndCompleteOneToOneMapping(array $mapping) { @@ -1371,7 +1441,7 @@ class ClassMetadataInfo implements ClassMetadata )); } - $uniqueContraintColumns = array(); + $uniqueConstraintColumns = array(); foreach ($mapping['joinColumns'] as &$joinColumn) { if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { if (count($mapping['joinColumns']) == 1) { @@ -1379,7 +1449,7 @@ class ClassMetadataInfo implements ClassMetadata $joinColumn['unique'] = true; } } else { - $uniqueContraintColumns[] = $joinColumn['name']; + $uniqueConstraintColumns[] = $joinColumn['name']; } } @@ -1406,12 +1476,12 @@ class ClassMetadataInfo implements ClassMetadata ? $joinColumn['fieldName'] : $joinColumn['name']; } - if ($uniqueContraintColumns) { + if ($uniqueConstraintColumns) { if ( ! $this->table) { throw new RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship."); } $this->table['uniqueConstraints'][$mapping['fieldName']."_uniq"] = array( - 'columns' => $uniqueContraintColumns + 'columns' => $uniqueConstraintColumns ); } @@ -1426,19 +1496,21 @@ class ClassMetadataInfo implements ClassMetadata } if (isset($mapping['id']) && $mapping['id'] === true && !$mapping['isOwningSide']) { - throw MappingException::illegalInverseIdentifierAssocation($this->name, $mapping['fieldName']); + throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']); } return $mapping; } /** - * Validates and completes the mapping. + * Validates & completes a one-to-many association mapping. * * @param array $mapping The mapping to validate and complete. + * + * @return array The validated and completed mapping. + * * @throws MappingException * @throws InvalidArgumentException - * @return array The validated and completed mapping.@override */ protected function _validateAndCompleteOneToManyMapping(array $mapping) { @@ -1461,6 +1533,15 @@ class ClassMetadataInfo implements ClassMetadata return $mapping; } + /** + * Validates & completes a many-to-many association mapping. + * + * @param array $mapping The mapping to validate & complete. + * + * @return array The validated & completed mapping. + * + * @throws \InvalidArgumentException + */ protected function _validateAndCompleteManyToManyMapping(array $mapping) { $mapping = $this->_validateAndCompleteAssociationMapping($mapping); @@ -1469,15 +1550,19 @@ class ClassMetadataInfo implements ClassMetadata if ( ! isset($mapping['joinTable']['name'])) { $mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']); } + + $selfReferencingEntityWithoutJoinColumns = $mapping['sourceEntity'] == $mapping['targetEntity'] + && (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns']))); + if ( ! isset($mapping['joinTable']['joinColumns'])) { $mapping['joinTable']['joinColumns'] = array(array( - 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity']), + 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null), 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), 'onDelete' => 'CASCADE')); } if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) { $mapping['joinTable']['inverseJoinColumns'] = array(array( - 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity']), + 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null), 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), 'onDelete' => 'CASCADE')); } @@ -1563,6 +1648,7 @@ class ClassMetadataInfo implements ClassMetadata * entity classes that have a single-field pk. * * @return string + * * @throws MappingException If the class has a composite primary key. */ public function getSingleIdentifierFieldName() @@ -1578,6 +1664,7 @@ class ClassMetadataInfo implements ClassMetadata * entity classes that have a single-field pk. * * @return string + * * @throws MappingException If the class has a composite primary key. */ public function getSingleIdentifierColumnName() @@ -1591,6 +1678,8 @@ class ClassMetadataInfo implements ClassMetadata * Mainly used by the ClassMetadataFactory to assign inherited identifiers. * * @param array $identifier + * + * @return void */ public function setIdentifier(array $identifier) { @@ -1599,9 +1688,7 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Gets the mapped identifier field of this class. - * - * @return array|string $identifier + * {@inheritDoc} */ public function getIdentifier() { @@ -1619,7 +1706,8 @@ class ClassMetadataInfo implements ClassMetadata /** * Gets an array containing all the column names. * - * @param array $fieldNames + * @param array|null $fieldNames + * * @return array */ public function getColumnNames(array $fieldNames = null) @@ -1663,6 +1751,10 @@ class ClassMetadataInfo implements ClassMetadata /** * Sets the type of Id generator to use for the mapped class. + * + * @param int $generatorType + * + * @return void */ public function setIdGeneratorType($generatorType) { @@ -1743,7 +1835,7 @@ class ClassMetadataInfo implements ClassMetadata /** * Checks whether the class uses a table for id generation. * - * @return boolean TRUE if the class uses the TABLE generator, FALSE otherwise. + * @return boolean TRUE if the class uses the TABLE generator, FALSE otherwise. */ public function isIdGeneratorTable() { @@ -1762,7 +1854,7 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Checks whether the class use a UUID for id generation + * Checks whether the class use a UUID for id generation. * * @return boolean */ @@ -1775,7 +1867,8 @@ class ClassMetadataInfo implements ClassMetadata * Gets the type of a field. * * @param string $fieldName - * @return \Doctrine\DBAL\Types\Type|string + * + * @return \Doctrine\DBAL\Types\Type|string|null */ public function getTypeOfField($fieldName) { @@ -1787,6 +1880,7 @@ class ClassMetadataInfo implements ClassMetadata * Gets the type of a column. * * @param string $columnName + * * @return \Doctrine\DBAL\Types\Type */ public function getTypeOfColumn($columnName) @@ -1819,15 +1913,13 @@ class ClassMetadataInfo implements ClassMetadata * Sets the mapped subclasses of this class. * * @param array $subclasses The names of all mapped subclasses. + * + * @return void */ public function setSubclasses(array $subclasses) { foreach ($subclasses as $subclass) { - if (strpos($subclass, '\\') === false && strlen($this->namespace)) { - $this->subClasses[] = $this->namespace . '\\' . $subclass; - } else { - $this->subClasses[] = $subclass; - } + $this->subClasses[] = $this->fullyQualifiedClassName($subclass); } } @@ -1835,6 +1927,10 @@ class ClassMetadataInfo implements ClassMetadata * Sets the parent class names. * Assumes that the class names in the passed array are in the order: * directParent -> directParentParent -> directParentParentParent ... -> root. + * + * @param array $classNames + * + * @return void */ public function setParentClasses(array $classNames) { @@ -1845,11 +1941,13 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Sets the inheritance type used by the class and it's subclasses. + * Sets the inheritance type used by the class and its subclasses. * * @param integer $type - * @throws MappingException + * * @return void + * + * @throws MappingException */ public function setInheritanceType($type) { @@ -1863,9 +1961,11 @@ class ClassMetadataInfo implements ClassMetadata * Sets the association to override association mapping of property for an entity relationship. * * @param string $fieldName - * @param array $overrideMapping - * @throws MappingException + * @param array $overrideMapping + * * @return void + * + * @throws MappingException */ public function setAssociationOverride($fieldName, array $overrideMapping) { @@ -1911,10 +2011,11 @@ class ClassMetadataInfo implements ClassMetadata * Sets the override for a mapped field. * * @param string $fieldName - * @param array $overrideMapping - * @throws MappingException - * @param array $overrideMapping + * @param array $overrideMapping + * * @return void + * + * @throws MappingException */ public function setAttributeOverride($fieldName, array $overrideMapping) { @@ -1952,6 +2053,7 @@ class ClassMetadataInfo implements ClassMetadata * Checks whether a mapped field is inherited from an entity superclass. * * @param string $fieldName + * * @return bool TRUE if the field is inherited, FALSE otherwise. */ public function isInheritedField($fieldName) @@ -1960,7 +2062,7 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Check if this entity is the root in any entity-inheritance-hierachy. + * Checks if this entity is the root in any entity-inheritance-hierarchy. * * @return bool */ @@ -1973,6 +2075,7 @@ class ClassMetadataInfo implements ClassMetadata * Checks whether a mapped association field is inherited from a superclass. * * @param string $fieldName + * * @return boolean TRUE if the field is inherited, FALSE otherwise. */ public function isInheritedAssociation($fieldName) @@ -1984,6 +2087,9 @@ class ClassMetadataInfo implements ClassMetadata * Sets the name of the primary table the class is mapped to. * * @param string $tableName The table name. + * + * @return void + * * @deprecated Use {@link setPrimaryTable}. */ public function setTableName($tableName) @@ -2002,6 +2108,8 @@ class ClassMetadataInfo implements ClassMetadata * If a key is omitted, the current value is kept. * * @param array $table The table description. + * + * @return void */ public function setPrimaryTable(array $table) { @@ -2031,6 +2139,7 @@ class ClassMetadataInfo implements ClassMetadata * Checks whether the given type identifies an inheritance type. * * @param integer $type + * * @return boolean TRUE if the given type identifies an inheritance type, FALSe otherwise. */ private function _isInheritanceType($type) @@ -2045,8 +2154,10 @@ class ClassMetadataInfo implements ClassMetadata * Adds a mapped field to the class. * * @param array $mapping The field mapping. - * @throws MappingException + * * @return void + * + * @throws MappingException */ public function mapField(array $mapping) { @@ -2063,8 +2174,10 @@ class ClassMetadataInfo implements ClassMetadata * This is mainly used to add inherited association mappings to derived classes. * * @param array $mapping - * @throws MappingException + * * @return void + * + * @throws MappingException */ public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) { @@ -2080,6 +2193,7 @@ class ClassMetadataInfo implements ClassMetadata * This is mainly used to add inherited field mappings to derived classes. * * @param array $fieldMapping + * * @return void */ public function addInheritedFieldMapping(array $fieldMapping) @@ -2093,8 +2207,11 @@ class ClassMetadataInfo implements ClassMetadata * INTERNAL: * Adds a named query to this class. * - * @throws MappingException * @param array $queryMapping + * + * @return void + * + * @throws MappingException */ public function addNamedQuery(array $queryMapping) { @@ -2124,8 +2241,11 @@ class ClassMetadataInfo implements ClassMetadata * INTERNAL: * Adds a named native query to this class. * - * @throws MappingException * @param array $queryMapping + * + * @return void + * + * @throws MappingException */ public function addNamedNativeQuery(array $queryMapping) { @@ -2152,11 +2272,9 @@ class ClassMetadataInfo implements ClassMetadata $queryMapping['isSelfClass'] = true; $queryMapping['resultClass'] = $this->name; - - } else if (strlen($this->namespace) > 0 && strpos($queryMapping['resultClass'], '\\') === false) { - $queryMapping['resultClass'] = $this->namespace . '\\' . $queryMapping['resultClass']; } + $queryMapping['resultClass'] = $this->fullyQualifiedClassName($queryMapping['resultClass']); $queryMapping['resultClass'] = ltrim($queryMapping['resultClass'], '\\'); } @@ -2167,8 +2285,11 @@ class ClassMetadataInfo implements ClassMetadata * INTERNAL: * Adds a sql result set mapping to this class. * - * @throws MappingException * @param array $resultMapping + * + * @return void + * + * @throws MappingException */ public function addSqlResultSetMapping(array $resultMapping) { @@ -2192,10 +2313,10 @@ class ClassMetadataInfo implements ClassMetadata $entityResult['isSelfClass'] = true; $entityResult['entityClass'] = $this->name; - } else if (strlen($this->namespace) > 0 && strpos($entityResult['entityClass'], '\\') === false) { - $entityResult['entityClass'] = $this->namespace . '\\' . $entityResult['entityClass']; } + $entityResult['entityClass'] = $this->fullyQualifiedClassName($entityResult['entityClass']); + $resultMapping['entities'][$key]['entityClass'] = ltrim($entityResult['entityClass'], '\\'); $resultMapping['entities'][$key]['isSelfClass'] = $entityResult['isSelfClass']; @@ -2206,7 +2327,7 @@ class ClassMetadataInfo implements ClassMetadata } if (!isset($field['column'])) { - $fieldName = $field['name']; + $fieldName = $field['name']; if(strpos($fieldName, '.')){ list(, $fieldName) = explode('.', $fieldName); } @@ -2225,6 +2346,8 @@ class ClassMetadataInfo implements ClassMetadata * Adds a one-to-one mapping. * * @param array $mapping The mapping. + * + * @return void */ public function mapOneToOne(array $mapping) { @@ -2237,6 +2360,8 @@ class ClassMetadataInfo implements ClassMetadata * Adds a one-to-many mapping. * * @param array $mapping The mapping. + * + * @return void */ public function mapOneToMany(array $mapping) { @@ -2249,6 +2374,8 @@ class ClassMetadataInfo implements ClassMetadata * Adds a many-to-one mapping. * * @param array $mapping The mapping. + * + * @return void */ public function mapManyToOne(array $mapping) { @@ -2262,6 +2389,8 @@ class ClassMetadataInfo implements ClassMetadata * Adds a many-to-many mapping. * * @param array $mapping The mapping. + * + * @return void */ public function mapManyToMany(array $mapping) { @@ -2274,8 +2403,10 @@ class ClassMetadataInfo implements ClassMetadata * Stores the association mapping. * * @param array $assocMapping - * @throws MappingException + * * @return void + * + * @throws MappingException */ protected function _storeAssociationMapping(array $assocMapping) { @@ -2292,23 +2423,24 @@ class ClassMetadataInfo implements ClassMetadata * Registers a custom repository class for the entity class. * * @param string $repositoryClassName The class name of the custom mapper. + * * @return void */ public function setCustomRepositoryClass($repositoryClassName) { - if ($repositoryClassName !== null && strpos($repositoryClassName, '\\') === false - && strlen($this->namespace) > 0) { - $repositoryClassName = $this->namespace . '\\' . $repositoryClassName; - } - $this->customRepositoryClassName = $repositoryClassName; + $this->customRepositoryClassName = $this->fullyQualifiedClassName($repositoryClassName); } /** * Dispatches the lifecycle event of the given entity to the registered * lifecycle callbacks and lifecycle listeners. * + * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker + * * @param string $lifecycleEvent The lifecycle event. - * @param \Object $entity The Entity on which the event occured. + * @param object $entity The Entity on which the event occurred. + * + * @return void */ public function invokeLifecycleCallbacks($lifecycleEvent, $entity) { @@ -2321,6 +2453,7 @@ class ClassMetadataInfo implements ClassMetadata * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. * * @param string $lifecycleEvent + * * @return boolean */ public function hasLifecycleCallbacks($lifecycleEvent) @@ -2332,6 +2465,7 @@ class ClassMetadataInfo implements ClassMetadata * Gets the registered lifecycle callbacks for an event. * * @param string $event + * * @return array */ public function getLifecycleCallbacks($event) @@ -2344,6 +2478,8 @@ class ClassMetadataInfo implements ClassMetadata * * @param string $callback * @param string $event + * + * @return void */ public function addLifecycleCallback($callback, $event) { @@ -2355,20 +2491,50 @@ class ClassMetadataInfo implements ClassMetadata * Any previously registered callbacks are overwritten. * * @param array $callbacks + * + * @return void */ public function setLifecycleCallbacks(array $callbacks) { $this->lifecycleCallbacks = $callbacks; } + /** + * Adds a entity listener for entities of this class. + * + * @param string $eventName The entity lifecycle event. + * @param string $class The listener class. + * @param string $method The listener callback method. + * + * @throws \Doctrine\ORM\Mapping\MappingException + */ + public function addEntityListener($eventName, $class, $method) + { + $class = $this->fullyQualifiedClassName($class); + + if ( ! class_exists($class)) { + throw MappingException::entityListenerClassNotFound($class, $this->name); + } + + if ( ! method_exists($class, $method)) { + throw MappingException::entityListenerMethodNotFound($class, $method, $this->name); + } + + $this->entityListeners[$eventName][] = array( + 'class' => $class, + 'method' => $method + ); + } + /** * Sets the discriminator column definition. * * @param array $columnDef * - * @param $columnDef - * @throws MappingException * @return void + * + * @throws MappingException + * * @see getDiscriminatorColumn() */ public function setDiscriminatorColumn($columnDef) @@ -2403,6 +2569,8 @@ class ClassMetadataInfo implements ClassMetadata * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. * * @param array $map + * + * @return void */ public function setDiscriminatorMap(array $map) { @@ -2412,19 +2580,18 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Add one entry of the discriminator map with a new class and corresponding name. + * Adds one entry of the discriminator map with a new class and corresponding name. * * @param string $name * @param string $className - * @throws MappingException + * * @return void + * + * @throws MappingException */ public function addDiscriminatorMapClass($name, $className) { - if (strlen($this->namespace) > 0 && strpos($className, '\\') === false) { - $className = $this->namespace . '\\' . $className; - } - + $className = $this->fullyQualifiedClassName($className); $className = ltrim($className, '\\'); $this->discriminatorMap[$name] = $className; @@ -2444,6 +2611,7 @@ class ClassMetadataInfo implements ClassMetadata * Checks whether the class has a named query with the given query name. * * @param string $queryName + * * @return boolean */ public function hasNamedQuery($queryName) @@ -2455,6 +2623,7 @@ class ClassMetadataInfo implements ClassMetadata * Checks whether the class has a named native query with the given query name. * * @param string $queryName + * * @return boolean */ public function hasNamedNativeQuery($queryName) @@ -2466,6 +2635,7 @@ class ClassMetadataInfo implements ClassMetadata * Checks whether the class has a named native query with the given query name. * * @param string $name + * * @return boolean */ public function hasSqlResultSetMapping($name) @@ -2502,7 +2672,8 @@ class ClassMetadataInfo implements ClassMetadata /** * Is this an association that only has a single join column? * - * @param string $fieldName + * @param string $fieldName + * * @return bool */ public function isAssociationWithSingleJoinColumn($fieldName) @@ -2515,11 +2686,13 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Return the single association join column (if any). + * Returns the single association join column (if any). * * @param string $fieldName - * @throws MappingException + * * @return string + * + * @throws MappingException */ public function getSingleAssociationJoinColumnName($fieldName) { @@ -2530,11 +2703,13 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Return the single association referenced join column name (if any). + * Returns the single association referenced join column name (if any). * * @param string $fieldName - * @throws MappingException + * * @return string + * + * @throws MappingException */ public function getSingleAssociationReferencedJoinColumnName($fieldName) { @@ -2545,13 +2720,15 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Used to retrieve a fieldname for either field or association from a given column, + * Used to retrieve a fieldname for either field or association from a given column. * * This method is used in foreign-key as primary-key contexts. * - * @param string $columnName - * @throws MappingException + * @param string $columnName + * * @return string + * + * @throws MappingException */ public function getFieldForColumn($columnName) { @@ -2574,6 +2751,8 @@ class ClassMetadataInfo implements ClassMetadata * Sets the ID generator used to generate IDs for instances of this class. * * @param \Doctrine\ORM\Id\AbstractIdGenerator $generator + * + * @return void */ public function setIdGenerator($generator) { @@ -2581,8 +2760,11 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Sets definition + * Sets definition. + * * @param array $definition + * + * @return void */ public function setCustomGeneratorDefinition(array $definition) { @@ -2603,11 +2785,17 @@ class ClassMetadataInfo implements ClassMetadata * * * @param array $definition + * + * @return void */ public function setSequenceGeneratorDefinition(array $definition) { - if (isset($definition['name']) && $definition['name'] == '`') { - $definition['name'] = trim($definition['name'], '`'); + if ( ! isset($definition['sequenceName'])) { + throw MappingException::missingSequenceName($this->name); + } + + if ($definition['sequenceName'][0] == '`') { + $definition['sequenceName'] = trim($definition['sequenceName'], '`'); $definition['quoted'] = true; } @@ -2618,9 +2806,11 @@ class ClassMetadataInfo implements ClassMetadata * Sets the version field mapping used for versioning. Sets the default * value to use depending on the column type. * - * @param array $mapping The version field mapping array - * @throws MappingException + * @param array $mapping The version field mapping array. + * * @return void + * + * @throws MappingException */ public function setVersionMapping(array &$mapping) { @@ -2642,6 +2832,8 @@ class ClassMetadataInfo implements ClassMetadata * Sets whether this class is to be versioned for optimistic locking. * * @param boolean $bool + * + * @return void */ public function setVersioned($bool) { @@ -2653,6 +2845,8 @@ class ClassMetadataInfo implements ClassMetadata * versioned for optimistic locking. * * @param string $versionField + * + * @return void */ public function setVersionField($versionField) { @@ -2660,7 +2854,7 @@ class ClassMetadataInfo implements ClassMetadata } /** - * Mark this class as read only, no change tracking is applied to it. + * Marks this class as read only, no change tracking is applied to it. * * @return void */ @@ -2687,6 +2881,7 @@ class ClassMetadataInfo implements ClassMetadata /** * {@inheritDoc} + * * @throws InvalidArgumentException */ public function getAssociationTargetClass($assocName) @@ -2712,6 +2907,7 @@ class ClassMetadataInfo implements ClassMetadata * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy * * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return array */ public function getQuotedIdentifierColumnNames($platform) @@ -2749,8 +2945,9 @@ class ClassMetadataInfo implements ClassMetadata * * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy * - * @param string $field + * @param string $field * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return string */ public function getQuotedColumnName($field, $platform) @@ -2766,6 +2963,7 @@ class ClassMetadataInfo implements ClassMetadata * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy * * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return string */ public function getQuotedTableName($platform) @@ -2778,8 +2976,9 @@ class ClassMetadataInfo implements ClassMetadata * * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy * - * @param array $assoc + * @param array $assoc * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform + * * @return string */ public function getQuotedJoinTableName(array $assoc, $platform) @@ -2804,8 +3003,9 @@ class ClassMetadataInfo implements ClassMetadata } /** - * @param string $targetClass - * @return array + * @param string $targetClass + * + * @return array */ public function getAssociationsByTargetClass($targetClass) { @@ -2817,4 +3017,31 @@ class ClassMetadataInfo implements ClassMetadata } return $relations; } + + /** + * @param string $className + * @return string + */ + public function fullyQualifiedClassName($className) + { + if ($className !== null && strpos($className, '\\') === false && strlen($this->namespace) > 0) { + return $this->namespace . '\\' . $className; + } + + return $className; + } + + /** + * @param string $name + * + * @return mixed + */ + public function getMetadataValue($name) { + + if (isset($this->$name)) { + return $this->$name; + } + + return null; + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Column.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Column.php old mode 100755 new mode 100644 index b233566fbd..70337323f6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Column.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Column.php @@ -25,22 +25,52 @@ namespace Doctrine\ORM\Mapping; */ final class Column implements Annotation { - /** @var string */ + /** + * @var string + */ public $name; - /** @var mixed */ + + /** + * @var mixed + */ public $type = 'string'; - /** @var integer */ + + /** + * @var integer + */ public $length; - /** @var integer */ - public $precision = 0; // The precision for a decimal (exact numeric) column (Applies only for decimal column) - /** @var integer */ - public $scale = 0; // The scale for a decimal (exact numeric) column (Applies only for decimal column) - /** @var boolean */ + + /** + * The precision for a decimal (exact numeric) column (Applies only for decimal column). + * + * @var integer + */ + public $precision = 0; + + /** + * The scale for a decimal (exact numeric) column (Applies only for decimal column). + * + * @var integer + */ + public $scale = 0; + + /** + * @var boolean + */ public $unique = false; - /** @var boolean */ + + /** + * @var boolean + */ public $nullable = false; - /** @var array */ + + /** + * @var array + */ public $options = array(); - /** @var string */ + + /** + * @var string + */ public $columnDefinition; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ColumnResult.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ColumnResult.php old mode 100755 new mode 100644 index cf5c2b430d..a164c85c0e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ColumnResult.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ColumnResult.php @@ -31,12 +31,10 @@ namespace Doctrine\ORM\Mapping; */ final class ColumnResult implements Annotation { - /** - * The name of a column in the SELECT clause of a SQL query + * The name of a column in the SELECT clause of a SQL query. * * @var string */ public $name; - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php old mode 100755 new mode 100644 index f31f082247..41e200e12a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php @@ -25,6 +25,8 @@ namespace Doctrine\ORM\Mapping; */ final class CustomIdGenerator implements Annotation { - /** @var string */ + /** + * @var string + */ public $class; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php new file mode 100644 index 0000000000..75658547e1 --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php @@ -0,0 +1,75 @@ +. + */ + +namespace Doctrine\ORM\Mapping; + +/** + * The default DefaultEntityListener + * + * @since 2.4 + * @author Fabio B. Silva + */ +class DefaultEntityListenerResolver implements EntityListenerResolver +{ + /** + * @var array Map to store entity listener instances. + */ + private $instances = array(); + + /** + * {@inheritdoc} + */ + public function clear($className = null) + { + if ($className === null) { + $this->instances = array(); + + return; + } + + if (isset($this->instances[$className = trim($className, '\\')])) { + unset($this->instances[$className]); + } + } + + /** + * {@inheritdoc} + */ + public function register($object) + { + if ( ! is_object($object)) { + throw new \InvalidArgumentException(sprintf('An object was expected, but got "%s".', gettype($object))); + } + + $this->instances[get_class($object)] = $object; + } + + /** + * {@inheritdoc} + */ + public function resolve($className) + { + if (isset($this->instances[$className = trim($className, '\\')])) { + return $this->instances[$className]; + } + + return $this->instances[$className] = new $className(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php old mode 100755 new mode 100644 index 4c64385b3c..2433b4afa8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php @@ -45,7 +45,7 @@ class DefaultNamingStrategy implements NamingStrategy /** * {@inheritdoc} */ - public function propertyToColumnName($propertyName) + public function propertyToColumnName($propertyName, $className = null) { return $propertyName; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php old mode 100755 new mode 100644 index b5a6fc4f11..70359de335 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -127,14 +127,16 @@ class DefaultQuoteStrategy implements QuoteStrategy */ public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = null) { - // Trim the column alias to the maximum identifier length of the platform. - // If the alias is to long, characters are cut off from the beginning. - // And strip non alphanumeric characters + // 1 ) Concatenate column name and counter + // 2 ) Trim the column alias to the maximum identifier length of the platform. + // If the alias is to long, characters are cut off from the beginning. + // 3 ) Strip non alphanumeric characters + // 4 ) Prefix with "_" if the result its numeric $columnName = $columnName . $counter; $columnName = substr($columnName, -$platform->getMaxIdentifierLength()); $columnName = preg_replace('/[^A-Za-z0-9_]/', '', $columnName); + $columnName = is_numeric($columnName) ? '_' . $columnName : $columnName; return $platform->getSQLResultCasing($columnName); } - -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php old mode 100755 new mode 100644 index f5cb0778ab..97ca7e9b57 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php @@ -25,14 +25,30 @@ namespace Doctrine\ORM\Mapping; */ final class DiscriminatorColumn implements Annotation { - /** @var string */ + /** + * @var string + */ public $name; - /** @var string */ + + /** + * @var string + */ public $type; - /** @var integer */ + + /** + * @var integer + */ public $length; - /** @var mixed */ - public $fieldName; // field name used in non-object hydration (array/scalar) - /** @var string */ + + /** + * Field name used in non-object hydration (array/scalar). + * + * @var mixed + */ + public $fieldName; + + /** + * @var string + */ public $columnDefinition; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php old mode 100755 new mode 100644 index d68b85b6dd..09d619465c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php @@ -25,6 +25,8 @@ namespace Doctrine\ORM\Mapping; */ final class DiscriminatorMap implements Annotation { - /** @var array */ + /** + * @var array + */ public $value; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php old mode 100755 new mode 100644 index bb01896202..f9aaddba70 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -19,12 +19,14 @@ namespace Doctrine\ORM\Mapping\Driver; -use Doctrine\Common\Annotations\AnnotationReader, - Doctrine\ORM\Mapping\MappingException, - Doctrine\ORM\Mapping\JoinColumn, - Doctrine\ORM\Mapping\Column, - Doctrine\Common\Persistence\Mapping\ClassMetadata, - Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver as AbstractAnnotationDriver; +use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\ORM\Mapping\MappingException; +use Doctrine\ORM\Mapping\JoinColumn; +use Doctrine\ORM\Mapping\Column; +use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver as AbstractAnnotationDriver; +use Doctrine\ORM\Events; /** * The AnnotationDriver reads the mapping metadata from docblock annotations. @@ -245,7 +247,7 @@ class AnnotationDriver extends AbstractAnnotationDriver $mapping = array(); $mapping['fieldName'] = $property->getName(); - // Check for JoinColummn/JoinColumns annotations + // Check for JoinColumn/JoinColumns annotations $joinColumns = array(); if ($joinColumnAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinColumn')) { @@ -373,7 +375,7 @@ class AnnotationDriver extends AbstractAnnotationDriver $override = array(); $fieldName = $associationOverride->name; - // Check for JoinColummn/JoinColumns annotations + // Check for JoinColumn/JoinColumns annotations if ($associationOverride->joinColumns) { $joinColumns = array(); foreach ($associationOverride->joinColumns as $joinColumn) { @@ -384,9 +386,8 @@ class AnnotationDriver extends AbstractAnnotationDriver // Check for JoinTable annotations if ($associationOverride->joinTable) { - $joinTable = null; $joinTableAnnot = $associationOverride->joinTable; - $joinTable = array( + $joinTable = array( 'name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema ); @@ -415,54 +416,47 @@ class AnnotationDriver extends AbstractAnnotationDriver } } + // Evaluate EntityListeners annotation + if (isset($classAnnotations['Doctrine\ORM\Mapping\EntityListeners'])) { + $entityListenersAnnot = $classAnnotations['Doctrine\ORM\Mapping\EntityListeners']; + + foreach ($entityListenersAnnot->value as $item) { + $listenerClassName = $metadata->fullyQualifiedClassName($item); + + if ( ! class_exists($listenerClassName)) { + throw MappingException::entityListenerClassNotFound($listenerClassName, $className); + } + + $hasMapping = false; + $listenerClass = new \ReflectionClass($listenerClassName); + /* @var $method \ReflectionMethod */ + foreach ($listenerClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { + // find method callbacks. + $callbacks = $this->getMethodCallbacks($method); + $hasMapping = $hasMapping ?: ( ! empty($callbacks)); + + foreach ($callbacks as $value) { + $metadata->addEntityListener($value[1], $listenerClassName, $value[0]); + } + } + // Evaluate the listener using naming convention. + if ( ! $hasMapping ) { + EntityListenerBuilder::bindEntityListener($metadata, $listenerClassName); + } + } + } + // Evaluate @HasLifecycleCallbacks annotation if (isset($classAnnotations['Doctrine\ORM\Mapping\HasLifecycleCallbacks'])) { /* @var $method \ReflectionMethod */ - foreach ($class->getMethods() as $method) { + foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { // filter for the declaring class only, callbacks from parents will already be registered. - if ($method->isPublic() && $method->getDeclaringClass()->getName() == $class->name) { - $annotations = $this->reader->getMethodAnnotations($method); + if ($method->getDeclaringClass()->name !== $class->name) { + continue; + } - if ($annotations) { - foreach ($annotations as $key => $annot) { - if ( ! is_numeric($key)) { - continue; - } - $annotations[get_class($annot)] = $annot; - } - } - - if (isset($annotations['Doctrine\ORM\Mapping\PrePersist'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::prePersist); - } - - if (isset($annotations['Doctrine\ORM\Mapping\PostPersist'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postPersist); - } - - if (isset($annotations['Doctrine\ORM\Mapping\PreUpdate'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preUpdate); - } - - if (isset($annotations['Doctrine\ORM\Mapping\PostUpdate'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postUpdate); - } - - if (isset($annotations['Doctrine\ORM\Mapping\PreRemove'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preRemove); - } - - if (isset($annotations['Doctrine\ORM\Mapping\PostRemove'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postRemove); - } - - if (isset($annotations['Doctrine\ORM\Mapping\PostLoad'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postLoad); - } - - if (isset($annotations['Doctrine\ORM\Mapping\PreFlush'])) { - $metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preFlush); - } + foreach ($this->getMethodCallbacks($method) as $value) { + $metadata->addLifecycleCallback($value[0], $value[1]); } } } @@ -471,10 +465,12 @@ class AnnotationDriver extends AbstractAnnotationDriver /** * Attempts to resolve the fetch mode. * - * @param string $className The class name - * @param string $fetchMode The fetch mode - * @return integer The fetch mode as defined in ClassMetadata - * @throws MappingException If the fetch mode is not valid + * @param string $className The class name. + * @param string $fetchMode The fetch mode. + * + * @return integer The fetch mode as defined in ClassMetadata. + * + * @throws MappingException If the fetch mode is not valid. */ private function getFetchMode($className, $fetchMode) { @@ -485,11 +481,60 @@ class AnnotationDriver extends AbstractAnnotationDriver return constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $fetchMode); } + /** + * Parses the given method. + * + * @param \ReflectionMethod $method + * + * @return array + */ + private function getMethodCallbacks(\ReflectionMethod $method) + { + $callbacks = array(); + $annotations = $this->reader->getMethodAnnotations($method); + + foreach ($annotations as $annot) { + if ($annot instanceof \Doctrine\ORM\Mapping\PrePersist) { + $callbacks[] = array($method->name, Events::prePersist); + } + + if ($annot instanceof \Doctrine\ORM\Mapping\PostPersist) { + $callbacks[] = array($method->name, Events::postPersist); + } + + if ($annot instanceof \Doctrine\ORM\Mapping\PreUpdate) { + $callbacks[] = array($method->name, Events::preUpdate); + } + + if ($annot instanceof \Doctrine\ORM\Mapping\PostUpdate) { + $callbacks[] = array($method->name, Events::postUpdate); + } + + if ($annot instanceof \Doctrine\ORM\Mapping\PreRemove) { + $callbacks[] = array($method->name, Events::preRemove); + } + + if ($annot instanceof \Doctrine\ORM\Mapping\PostRemove) { + $callbacks[] = array($method->name, Events::postRemove); + } + + if ($annot instanceof \Doctrine\ORM\Mapping\PostLoad) { + $callbacks[] = array($method->name, Events::postLoad); + } + + if ($annot instanceof \Doctrine\ORM\Mapping\PreFlush) { + $callbacks[] = array($method->name, Events::preFlush); + } + } + + return $callbacks; + } + /** * Parse the given JoinColumn as array * - * @param JoinColumn $joinColumn - * @return array + * @param JoinColumn $joinColumn + * @return array */ private function joinColumnToArray(JoinColumn $joinColumn) { @@ -506,9 +551,10 @@ class AnnotationDriver extends AbstractAnnotationDriver /** * Parse the given Column as array * - * @param string $fieldName - * @param Column $column - * @return array + * @param string $fieldName + * @param Column $column + * + * @return array */ private function columnToArray($fieldName, Column $column) { @@ -538,10 +584,11 @@ class AnnotationDriver extends AbstractAnnotationDriver } /** - * Factory method for the Annotation Driver + * Factory method for the Annotation Driver. + * + * @param array|string $paths + * @param AnnotationReader|null $reader * - * @param array|string $paths - * @param AnnotationReader $reader * @return AnnotationDriver */ static public function create($paths = array(), AnnotationReader $reader = null) diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php old mode 100755 new mode 100644 index cb5aa22eae..9a12bbc721 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -19,18 +19,20 @@ namespace Doctrine\ORM\Mapping\Driver; -use Doctrine\DBAL\Schema\AbstractSchemaManager, - Doctrine\DBAL\Schema\SchemaException, - Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, - Doctrine\Common\Persistence\Mapping\ClassMetadata, - Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\Common\Util\Inflector, - Doctrine\ORM\Mapping\MappingException; +use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Util\Inflector; +use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\SchemaException; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\ORM\Mapping\MappingException; /** * The DatabaseDriver reverse engineers the mapping metadata from a database. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -45,10 +47,13 @@ class DatabaseDriver implements MappingDriver private $_sm; /** - * @var array + * @var array|null */ private $tables = null; + /** + * @var array + */ private $classToTableNames = array(); /** @@ -69,12 +74,11 @@ class DatabaseDriver implements MappingDriver /** * The namespace for the generated entities. * - * @var string + * @var string|null */ private $namespace; /** - * * @param AbstractSchemaManager $schemaManager */ public function __construct(AbstractSchemaManager $schemaManager) @@ -83,243 +87,15 @@ class DatabaseDriver implements MappingDriver } /** - * Set tables manually instead of relying on the reverse engeneering capabilities of SchemaManager. + * Set the namespace for the generated entities. + * + * @param string $namespace * - * @param array $entityTables - * @param array $manyToManyTables * @return void */ - public function setTables($entityTables, $manyToManyTables) + public function setNamespace($namespace) { - $this->tables = $this->manyToManyTables = $this->classToTableNames = array(); - foreach ($entityTables as $table) { - $className = $this->getClassNameForTable($table->getName()); - $this->classToTableNames[$className] = $table->getName(); - $this->tables[$table->getName()] = $table; - } - foreach ($manyToManyTables as $table) { - $this->manyToManyTables[$table->getName()] = $table; - } - } - - private function reverseEngineerMappingFromDatabase() - { - if ($this->tables !== null) { - return; - } - - $tables = array(); - - foreach ($this->_sm->listTableNames() as $tableName) { - $tables[$tableName] = $this->_sm->listTableDetails($tableName); - } - - $this->tables = $this->manyToManyTables = $this->classToTableNames = array(); - foreach ($tables as $tableName => $table) { - /* @var $table \Doctrine\DBAL\Schema\Table */ - if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $foreignKeys = $table->getForeignKeys(); - } else { - $foreignKeys = array(); - } - - $allForeignKeyColumns = array(); - foreach ($foreignKeys as $foreignKey) { - $allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns()); - } - - if ( ! $table->hasPrimaryKey()) { - throw new MappingException( - "Table " . $table->getName() . " has no primary key. Doctrine does not ". - "support reverse engineering from tables that don't have a primary key." - ); - } - - $pkColumns = $table->getPrimaryKey()->getColumns(); - sort($pkColumns); - sort($allForeignKeyColumns); - - if ($pkColumns == $allForeignKeyColumns && count($foreignKeys) == 2) { - $this->manyToManyTables[$tableName] = $table; - } else { - // lower-casing is necessary because of Oracle Uppercase Tablenames, - // assumption is lower-case + underscore separated. - $className = $this->getClassNameForTable($tableName); - $this->tables[$tableName] = $table; - $this->classToTableNames[$className] = $tableName; - } - } - } - - /** - * {@inheritDoc} - */ - public function loadMetadataForClass($className, ClassMetadata $metadata) - { - $this->reverseEngineerMappingFromDatabase(); - - if (!isset($this->classToTableNames[$className])) { - throw new \InvalidArgumentException("Unknown class " . $className); - } - - $tableName = $this->classToTableNames[$className]; - - $metadata->name = $className; - $metadata->table['name'] = $tableName; - - $columns = $this->tables[$tableName]->getColumns(); - $indexes = $this->tables[$tableName]->getIndexes(); - try { - $primaryKeyColumns = $this->tables[$tableName]->getPrimaryKey()->getColumns(); - } catch(SchemaException $e) { - $primaryKeyColumns = array(); - } - - if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $foreignKeys = $this->tables[$tableName]->getForeignKeys(); - } else { - $foreignKeys = array(); - } - - $allForeignKeyColumns = array(); - foreach ($foreignKeys as $foreignKey) { - $allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns()); - } - - $ids = array(); - $fieldMappings = array(); - foreach ($columns as $column) { - $fieldMapping = array(); - - if (in_array($column->getName(), $allForeignKeyColumns)) { - continue; - } else if ($primaryKeyColumns && in_array($column->getName(), $primaryKeyColumns)) { - $fieldMapping['id'] = true; - } - - $fieldMapping['fieldName'] = $this->getFieldNameForColumn($tableName, $column->getName(), false); - $fieldMapping['columnName'] = $column->getName(); - $fieldMapping['type'] = strtolower((string) $column->getType()); - - if ($column->getType() instanceof \Doctrine\DBAL\Types\StringType) { - $fieldMapping['length'] = $column->getLength(); - $fieldMapping['fixed'] = $column->getFixed(); - } else if ($column->getType() instanceof \Doctrine\DBAL\Types\IntegerType) { - $fieldMapping['unsigned'] = $column->getUnsigned(); - } - $fieldMapping['nullable'] = $column->getNotNull() ? false : true; - - if (isset($fieldMapping['id'])) { - $ids[] = $fieldMapping; - } else { - $fieldMappings[] = $fieldMapping; - } - } - - if ($ids) { - // We need to check for the columns here, because we might have associations as id as well. - if (count($primaryKeyColumns) == 1) { - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - } - - foreach ($ids as $id) { - $metadata->mapField($id); - } - } - - foreach ($fieldMappings as $fieldMapping) { - $metadata->mapField($fieldMapping); - } - - foreach ($this->manyToManyTables as $manyTable) { - foreach ($manyTable->getForeignKeys() as $foreignKey) { - // foreign key maps to the table of the current entity, many to many association probably exists - if (strtolower($tableName) == strtolower($foreignKey->getForeignTableName())) { - $myFk = $foreignKey; - $otherFk = null; - foreach ($manyTable->getForeignKeys() as $foreignKey) { - if ($foreignKey != $myFk) { - $otherFk = $foreignKey; - break; - } - } - - if (!$otherFk) { - // the definition of this many to many table does not contain - // enough foreign key information to continue reverse engeneering. - continue; - } - - $localColumn = current($myFk->getColumns()); - $associationMapping = array(); - $associationMapping['fieldName'] = $this->getFieldNameForColumn($manyTable->getName(), current($otherFk->getColumns()), true); - $associationMapping['targetEntity'] = $this->getClassNameForTable($otherFk->getForeignTableName()); - if (current($manyTable->getColumns())->getName() == $localColumn) { - $associationMapping['inversedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true); - $associationMapping['joinTable'] = array( - 'name' => strtolower($manyTable->getName()), - 'joinColumns' => array(), - 'inverseJoinColumns' => array(), - ); - - $fkCols = $myFk->getForeignColumns(); - $cols = $myFk->getColumns(); - for ($i = 0; $i < count($cols); $i++) { - $associationMapping['joinTable']['joinColumns'][] = array( - 'name' => $cols[$i], - 'referencedColumnName' => $fkCols[$i], - ); - } - - $fkCols = $otherFk->getForeignColumns(); - $cols = $otherFk->getColumns(); - for ($i = 0; $i < count($cols); $i++) { - $associationMapping['joinTable']['inverseJoinColumns'][] = array( - 'name' => $cols[$i], - 'referencedColumnName' => $fkCols[$i], - ); - } - } else { - $associationMapping['mappedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true); - } - $metadata->mapManyToMany($associationMapping); - break; - } - } - } - - foreach ($foreignKeys as $foreignKey) { - $foreignTable = $foreignKey->getForeignTableName(); - $cols = $foreignKey->getColumns(); - $fkCols = $foreignKey->getForeignColumns(); - - $localColumn = current($cols); - $associationMapping = array(); - $associationMapping['fieldName'] = $this->getFieldNameForColumn($tableName, $localColumn, true); - $associationMapping['targetEntity'] = $this->getClassNameForTable($foreignTable); - - if (isset($metadata->fieldMappings[$associationMapping['fieldName']])) { - $associationMapping['fieldName'] = $associationMapping['fieldName'] . "2"; - } - - if ($primaryKeyColumns && in_array($localColumn, $primaryKeyColumns)) { - $associationMapping['id'] = true; - } - - for ($i = 0; $i < count($cols); $i++) { - $associationMapping['joinColumns'][] = array( - 'name' => $cols[$i], - 'referencedColumnName' => $fkCols[$i], - ); - } - - //Here we need to check if $cols are the same as $primaryKeyColums - if (!array_diff($cols,$primaryKeyColumns)) { - $metadata->mapOneToOne($associationMapping); - } else { - $metadata->mapManyToOne($associationMapping); - } - } + $this->namespace = $namespace; } /** @@ -341,10 +117,11 @@ class DatabaseDriver implements MappingDriver } /** - * Set class name for a table. + * Sets class name for a table. * * @param string $tableName * @param string $className + * * @return void */ public function setClassNameForTable($tableName, $className) @@ -353,11 +130,12 @@ class DatabaseDriver implements MappingDriver } /** - * Set field name for a column on a specific table. + * Sets field name for a column on a specific table. * * @param string $tableName * @param string $columnName * @param string $fieldName + * * @return void */ public function setFieldNameForColumn($tableName, $columnName, $fieldName) @@ -366,9 +144,380 @@ class DatabaseDriver implements MappingDriver } /** - * Return the mapped class name for a table if it exists. Otherwise return "classified" version. + * Sets tables manually instead of relying on the reverse engineering capabilities of SchemaManager. + * + * @param array $entityTables + * @param array $manyToManyTables + * + * @return void + */ + public function setTables($entityTables, $manyToManyTables) + { + $this->tables = $this->manyToManyTables = $this->classToTableNames = array(); + + foreach ($entityTables as $table) { + $className = $this->getClassNameForTable($table->getName()); + + $this->classToTableNames[$className] = $table->getName(); + $this->tables[$table->getName()] = $table; + } + + foreach ($manyToManyTables as $table) { + $this->manyToManyTables[$table->getName()] = $table; + } + } + + /** + * {@inheritDoc} + */ + public function loadMetadataForClass($className, ClassMetadata $metadata) + { + $this->reverseEngineerMappingFromDatabase(); + + if ( ! isset($this->classToTableNames[$className])) { + throw new \InvalidArgumentException("Unknown class " . $className); + } + + $tableName = $this->classToTableNames[$className]; + + $metadata->name = $className; + $metadata->table['name'] = $tableName; + + $this->buildIndexes($metadata); + $this->buildFieldMappings($metadata); + $this->buildToOneAssociationMappings($metadata); + + foreach ($this->manyToManyTables as $manyTable) { + foreach ($manyTable->getForeignKeys() as $foreignKey) { + // foreign key maps to the table of the current entity, many to many association probably exists + if ( ! (strtolower($tableName) === strtolower($foreignKey->getForeignTableName()))) { + continue; + } + + $myFk = $foreignKey; + $otherFk = null; + + foreach ($manyTable->getForeignKeys() as $foreignKey) { + if ($foreignKey != $myFk) { + $otherFk = $foreignKey; + break; + } + } + + if ( ! $otherFk) { + // the definition of this many to many table does not contain + // enough foreign key information to continue reverse engineering. + continue; + } + + $localColumn = current($myFk->getColumns()); + + $associationMapping = array(); + $associationMapping['fieldName'] = $this->getFieldNameForColumn($manyTable->getName(), current($otherFk->getColumns()), true); + $associationMapping['targetEntity'] = $this->getClassNameForTable($otherFk->getForeignTableName()); + + if (current($manyTable->getColumns())->getName() == $localColumn) { + $associationMapping['inversedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true); + $associationMapping['joinTable'] = array( + 'name' => strtolower($manyTable->getName()), + 'joinColumns' => array(), + 'inverseJoinColumns' => array(), + ); + + $fkCols = $myFk->getForeignColumns(); + $cols = $myFk->getColumns(); + + for ($i = 0; $i < count($cols); $i++) { + $associationMapping['joinTable']['joinColumns'][] = array( + 'name' => $cols[$i], + 'referencedColumnName' => $fkCols[$i], + ); + } + + $fkCols = $otherFk->getForeignColumns(); + $cols = $otherFk->getColumns(); + + for ($i = 0; $i < count($cols); $i++) { + $associationMapping['joinTable']['inverseJoinColumns'][] = array( + 'name' => $cols[$i], + 'referencedColumnName' => $fkCols[$i], + ); + } + } else { + $associationMapping['mappedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getColumns()), true); + } + + $metadata->mapManyToMany($associationMapping); + + break; + } + } + } + + /** + * @return void + * + * @throws \Doctrine\ORM\Mapping\MappingException + */ + private function reverseEngineerMappingFromDatabase() + { + if ($this->tables !== null) { + return; + } + + $tables = array(); + + foreach ($this->_sm->listTableNames() as $tableName) { + $tables[$tableName] = $this->_sm->listTableDetails($tableName); + } + + $this->tables = $this->manyToManyTables = $this->classToTableNames = array(); + + foreach ($tables as $tableName => $table) { + $foreignKeys = ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) + ? $table->getForeignKeys() + : array(); + + $allForeignKeyColumns = array(); + + foreach ($foreignKeys as $foreignKey) { + $allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns()); + } + + if ( ! $table->hasPrimaryKey()) { + throw new MappingException( + "Table " . $table->getName() . " has no primary key. Doctrine does not ". + "support reverse engineering from tables that don't have a primary key." + ); + } + + $pkColumns = $table->getPrimaryKey()->getColumns(); + + sort($pkColumns); + sort($allForeignKeyColumns); + + if ($pkColumns == $allForeignKeyColumns && count($foreignKeys) == 2) { + $this->manyToManyTables[$tableName] = $table; + } else { + // lower-casing is necessary because of Oracle Uppercase Tablenames, + // assumption is lower-case + underscore separated. + $className = $this->getClassNameForTable($tableName); + + $this->tables[$tableName] = $table; + $this->classToTableNames[$className] = $tableName; + } + } + } + + /** + * Build indexes from a class metadata. + * + * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata + */ + private function buildIndexes(ClassMetadataInfo $metadata) + { + $tableName = $metadata->table['name']; + $indexes = $this->tables[$tableName]->getIndexes(); + + foreach($indexes as $index){ + if ($index->isPrimary()) { + continue; + } + + $indexName = $index->getName(); + $indexColumns = $index->getColumns(); + $constraintType = $index->isUnique() + ? 'uniqueConstraints' + : 'indexes'; + + $metadata->table[$constraintType][$indexName]['columns'] = $indexColumns; + } + } + + /** + * Build field mapping from class metadata. + * + * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata + */ + private function buildFieldMappings(ClassMetadataInfo $metadata) + { + $tableName = $metadata->table['name']; + $columns = $this->tables[$tableName]->getColumns(); + $primaryKeys = $this->getTablePrimaryKeys($this->tables[$tableName]); + $foreignKeys = $this->getTableForeignKeys($this->tables[$tableName]); + $allForeignKeys = array(); + + foreach ($foreignKeys as $foreignKey) { + $allForeignKeys = array_merge($allForeignKeys, $foreignKey->getLocalColumns()); + } + + $ids = array(); + $fieldMappings = array(); + + foreach ($columns as $column) { + if (in_array($column->getName(), $allForeignKeys)) { + continue; + } + + $fieldMapping = $this->buildFieldMapping($tableName, $column); + + if ($primaryKeys && in_array($column->getName(), $primaryKeys)) { + $fieldMapping['id'] = true; + $ids[] = $fieldMapping; + } + + $fieldMappings[] = $fieldMapping; + } + + // We need to check for the columns here, because we might have associations as id as well. + if ($ids && count($primaryKeys) == 1) { + $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); + } + + foreach ($fieldMappings as $fieldMapping) { + $metadata->mapField($fieldMapping); + } + } + + /** + * Build field mapping from a schema column definition + * + * @param string $tableName + * @param \Doctrine\DBAL\Schema\Column $column + * + * @return array + */ + private function buildFieldMapping($tableName, Column $column) + { + $fieldMapping = array( + 'fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false), + 'columnName' => $column->getName(), + 'type' => strtolower((string) $column->getType()), + 'nullable' => ( ! $column->getNotNull()), + ); + + // Type specific elements + switch ($fieldMapping['type']) { + case Type::TARRAY: + case Type::BLOB: + case Type::GUID: + case Type::JSON_ARRAY: + case Type::OBJECT: + case Type::SIMPLE_ARRAY: + case Type::STRING: + case Type::TEXT: + $fieldMapping['length'] = $column->getLength(); + $fieldMapping['fixed'] = $column->getFixed(); + break; + + case Type::DECIMAL: + case Type::FLOAT: + $fieldMapping['precision'] = $column->getPrecision(); + $fieldMapping['scale'] = $column->getScale(); + break; + + case Type::INTEGER: + case Type::BIGINT: + case Type::SMALLINT: + $fieldMapping['unsigned'] = $column->getUnsigned(); + break; + } + + // Comment + if (($comment = $column->getComment()) !== null) { + $fieldMapping['comment'] = $comment; + } + + // Default + if (($default = $column->getDefault()) !== null) { + $fieldMapping['default'] = $default; + } + + return $fieldMapping; + } + + /** + * Build to one (one to one, many to one) association mapping from class metadata. + * + * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata + */ + private function buildToOneAssociationMappings(ClassMetadataInfo $metadata) + { + $tableName = $metadata->table['name']; + $primaryKeys = $this->getTablePrimaryKeys($this->tables[$tableName]); + $foreignKeys = $this->getTableForeignKeys($this->tables[$tableName]); + + foreach ($foreignKeys as $foreignKey) { + $foreignTableName = $foreignKey->getForeignTableName(); + $fkColumns = $foreignKey->getColumns(); + $fkForeignColumns = $foreignKey->getForeignColumns(); + $localColumn = current($fkColumns); + $associationMapping = array( + 'fieldName' => $this->getFieldNameForColumn($tableName, $localColumn, true), + 'targetEntity' => $this->getClassNameForTable($foreignTableName), + ); + + if (isset($metadata->fieldMappings[$associationMapping['fieldName']])) { + $associationMapping['fieldName'] .= '2'; // "foo" => "foo2" + } + + if ($primaryKeys && in_array($localColumn, $primaryKeys)) { + $associationMapping['id'] = true; + } + + for ($i = 0; $i < count($fkColumns); $i++) { + $associationMapping['joinColumns'][] = array( + 'name' => $fkColumns[$i], + 'referencedColumnName' => $fkForeignColumns[$i], + ); + } + + // Here we need to check if $fkColumns are the same as $primaryKeys + if ( ! array_diff($fkColumns, $primaryKeys)) { + $metadata->mapOneToOne($associationMapping); + } else { + $metadata->mapManyToOne($associationMapping); + } + } + } + + /** + * Retreive schema table definition foreign keys. + * + * @param \Doctrine\DBAL\Schema\Table $table + * + * @return array + */ + private function getTableForeignKeys(Table $table) + { + return ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) + ? $table->getForeignKeys() + : array(); + } + + /** + * Retreive schema table definition primary keys. + * + * @param \Doctrine\DBAL\Schema\Table $table + * + * @return array + */ + private function getTablePrimaryKeys(Table $table) + { + try { + return $table->getPrimaryKey()->getColumns(); + } catch(SchemaException $e) { + // Do nothing + } + + return array(); + } + + /** + * Returns the mapped class name for a table if it exists. Otherwise return "classified" version. * * @param string $tableName + * * @return string */ private function getClassNameForTable($tableName) @@ -383,9 +532,10 @@ class DatabaseDriver implements MappingDriver /** * Return the mapped field name for a column, if it exists. Otherwise return camelized version. * - * @param string $tableName - * @param string $columnName + * @param string $tableName + * @param string $columnName * @param boolean $fk Whether the column is a foreignkey or not. + * * @return string */ private function getFieldNameForColumn($tableName, $columnName, $fk = false) @@ -402,15 +552,4 @@ class DatabaseDriver implements MappingDriver } return Inflector::camelize($columnName); } - - /** - * Set the namespace for the generated entities. - * - * @param string $namespace - * @return void - */ - public function setNamespace($namespace) - { - $this->namespace = $namespace; - } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php old mode 100755 new mode 100644 index 04bf2dedcf..14abadb9e4 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php @@ -64,3 +64,4 @@ require_once __DIR__.'/../AssociationOverride.php'; require_once __DIR__.'/../AssociationOverrides.php'; require_once __DIR__.'/../AttributeOverride.php'; require_once __DIR__.'/../AttributeOverrides.php'; +require_once __DIR__.'/../EntityListeners.php'; \ No newline at end of file diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php old mode 100755 new mode 100644 index 02d409d43f..f4cd8cd608 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php @@ -28,4 +28,4 @@ use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain; */ class DriverChain extends MappingDriverChain { -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/EspoPHPDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/EspoPHPDriver.php deleted file mode 100755 index 1e9cdffac0..0000000000 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/EspoPHPDriver.php +++ /dev/null @@ -1,679 +0,0 @@ -getElement($className); - - if ($element['type'] == 'entity') { - if (isset($element['repositoryClass'])) { - $metadata->setCustomRepositoryClass($element['repositoryClass']); - } - if (isset($element['readOnly']) && $element['readOnly'] == true) { - $metadata->markReadOnly(); - } - } else if ($element['type'] == 'mappedSuperclass') { - $metadata->setCustomRepositoryClass( - isset($element['repositoryClass']) ? $element['repositoryClass'] : null - ); - $metadata->isMappedSuperclass = true; - } else { - throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className); - } - - // Evaluate root level properties - $table = array(); - if (isset($element['table'])) { - $table['name'] = $element['table']; - } - $metadata->setPrimaryTable($table); - - // Evaluate named queries - if (isset($element['namedQueries'])) { - foreach ($element['namedQueries'] as $name => $queryMapping) { - if (is_string($queryMapping)) { - $queryMapping = array('query' => $queryMapping); - } - - if ( ! isset($queryMapping['name'])) { - $queryMapping['name'] = $name; - } - - $metadata->addNamedQuery($queryMapping); - } - } - - // Evaluate named native queries - if (isset($element['namedNativeQueries'])) { - foreach ($element['namedNativeQueries'] as $name => $mappingElement) { - if (!isset($mappingElement['name'])) { - $mappingElement['name'] = $name; - } - $metadata->addNamedNativeQuery(array( - 'name' => $mappingElement['name'], - 'query' => isset($mappingElement['query']) ? $mappingElement['query'] : null, - 'resultClass' => isset($mappingElement['resultClass']) ? $mappingElement['resultClass'] : null, - 'resultSetMapping' => isset($mappingElement['resultSetMapping']) ? $mappingElement['resultSetMapping'] : null, - )); - } - } - - // Evaluate sql result set mappings - if (isset($element['sqlResultSetMappings'])) { - foreach ($element['sqlResultSetMappings'] as $name => $resultSetMapping) { - if (!isset($resultSetMapping['name'])) { - $resultSetMapping['name'] = $name; - } - - $entities = array(); - $columns = array(); - if (isset($resultSetMapping['entityResult'])) { - foreach ($resultSetMapping['entityResult'] as $entityResultElement) { - $entityResult = array( - 'fields' => array(), - 'entityClass' => isset($entityResultElement['entityClass']) ? $entityResultElement['entityClass'] : null, - 'discriminatorColumn' => isset($entityResultElement['discriminatorColumn']) ? $entityResultElement['discriminatorColumn'] : null, - ); - - if (isset($entityResultElement['fieldResult'])) { - foreach ($entityResultElement['fieldResult'] as $fieldResultElement) { - $entityResult['fields'][] = array( - 'name' => isset($fieldResultElement['name']) ? $fieldResultElement['name'] : null, - 'column' => isset($fieldResultElement['column']) ? $fieldResultElement['column'] : null, - ); - } - } - - $entities[] = $entityResult; - } - } - - - if (isset($resultSetMapping['columnResult'])) { - foreach ($resultSetMapping['columnResult'] as $columnResultAnnot) { - $columns[] = array( - 'name' => isset($columnResultAnnot['name']) ? $columnResultAnnot['name'] : null, - ); - } - } - - $metadata->addSqlResultSetMapping(array( - 'name' => $resultSetMapping['name'], - 'entities' => $entities, - 'columns' => $columns - )); - } - } - - /* not implemented specially anyway. use table = schema.table - if (isset($element['schema'])) { - $metadata->table['schema'] = $element['schema']; - }*/ - - if (isset($element['inheritanceType'])) { - $metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType']))); - - if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) { - // Evaluate discriminatorColumn - if (isset($element['discriminatorColumn'])) { - $discrColumn = $element['discriminatorColumn']; - $metadata->setDiscriminatorColumn(array( - 'name' => isset($discrColumn['name']) ? (string)$discrColumn['name'] : null, - 'type' => isset($discrColumn['type']) ? (string)$discrColumn['type'] : null, - 'length' => isset($discrColumn['length']) ? (string)$discrColumn['length'] : null, - 'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string)$discrColumn['columnDefinition'] : null - )); - } else { - $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); - } - - // Evaluate discriminatorMap - if (isset($element['discriminatorMap'])) { - $metadata->setDiscriminatorMap($element['discriminatorMap']); - } - } - } - - - // Evaluate changeTrackingPolicy - if (isset($element['changeTrackingPolicy'])) { - $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' - . strtoupper($element['changeTrackingPolicy']))); - } - - // Evaluate indexes - if (isset($element['indexes'])) { - foreach ($element['indexes'] as $name => $index) { - if ( ! isset($index['name'])) { - $index['name'] = $name; - } - - if (is_string($index['columns'])) { - $columns = explode(',', $index['columns']); - $columns = array_map('trim', $columns); - } else { - $columns = $index['columns']; - } - - $metadata->table['indexes'][$index['name']] = array( - 'columns' => $columns - ); - } - } - - // Evaluate uniqueConstraints - if (isset($element['uniqueConstraints'])) { - foreach ($element['uniqueConstraints'] as $name => $unique) { - if ( ! isset($unique['name'])) { - $unique['name'] = $name; - } - - if (is_string($unique['columns'])) { - $columns = explode(',', $unique['columns']); - $columns = array_map('trim', $columns); - } else { - $columns = $unique['columns']; - } - - $metadata->table['uniqueConstraints'][$unique['name']] = array( - 'columns' => $columns - ); - } - } - - if (isset($element['options'])) { - $metadata->table['options'] = $element['options']; - } - - $associationIds = array(); - if (isset($element['id'])) { - // Evaluate identifier settings - foreach ($element['id'] as $name => $idElement) { - if (isset($idElement['associationKey']) && $idElement['associationKey'] == true) { - $associationIds[$name] = true; - continue; - } - - $mapping = array( - 'id' => true, - 'fieldName' => $name - ); - - if (isset($idElement['type'])) { - $mapping['type'] = $idElement['type']; - } - - if (isset($idElement['column'])) { - $mapping['columnName'] = $idElement['column']; - } - - if (isset($idElement['length'])) { - $mapping['length'] = $idElement['length']; - } - - if (isset($idElement['columnDefinition'])) { - $mapping['columnDefinition'] = $idElement['columnDefinition']; - } - - $metadata->mapField($mapping); - - if (isset($idElement['generator'])) { - $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' - . strtoupper($idElement['generator']['strategy']))); - } - // Check for SequenceGenerator/TableGenerator definition - if (isset($idElement['sequenceGenerator'])) { - $metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']); - } else if (isset($idElement['customIdGenerator'])) { - $customGenerator = $idElement['customIdGenerator']; - $metadata->setCustomGeneratorDefinition(array( - 'class' => (string) $customGenerator['class'] - )); - } else if (isset($idElement['tableGenerator'])) { - throw MappingException::tableIdGeneratorNotImplemented($className); - } - } - } - - // Evaluate fields - if (isset($element['fields'])) { - foreach ($element['fields'] as $name => $fieldMapping) { - - $mapping = $this->columnToArray($name, $fieldMapping); - - if (isset($fieldMapping['id'])) { - $mapping['id'] = true; - if (isset($fieldMapping['generator']['strategy'])) { - $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' - . strtoupper($fieldMapping['generator']['strategy']))); - } - } - - if (isset($mapping['version'])) { - $metadata->setVersionMapping($mapping); - unset($mapping['version']); - } - - $metadata->mapField($mapping); - } - } - - // Evaluate oneToOne relationships - if (isset($element['oneToOne'])) { - foreach ($element['oneToOne'] as $name => $oneToOneElement) { - $mapping = array( - 'fieldName' => $name, - 'targetEntity' => $oneToOneElement['targetEntity'] - ); - - if (isset($associationIds[$mapping['fieldName']])) { - $mapping['id'] = true; - } - - if (isset($oneToOneElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $oneToOneElement['fetch']); - } - - if (isset($oneToOneElement['mappedBy'])) { - $mapping['mappedBy'] = $oneToOneElement['mappedBy']; - } else { - if (isset($oneToOneElement['inversedBy'])) { - $mapping['inversedBy'] = $oneToOneElement['inversedBy']; - } - - $joinColumns = array(); - - if (isset($oneToOneElement['joinColumn'])) { - $joinColumns[] = $this->joinColumnToArray($oneToOneElement['joinColumn']); - } else if (isset($oneToOneElement['joinColumns'])) { - foreach ($oneToOneElement['joinColumns'] as $joinColumnName => $joinColumnElement) { - if ( ! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $joinColumnName; - } - - $joinColumns[] = $this->joinColumnToArray($joinColumnElement); - } - } - - $mapping['joinColumns'] = $joinColumns; - } - - if (isset($oneToOneElement['cascade'])) { - $mapping['cascade'] = $oneToOneElement['cascade']; - } - - if (isset($oneToOneElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool)$oneToOneElement['orphanRemoval']; - } - - $metadata->mapOneToOne($mapping); - } - } - - // Evaluate oneToMany relationships - if (isset($element['oneToMany'])) { - foreach ($element['oneToMany'] as $name => $oneToManyElement) { - $mapping = array( - 'fieldName' => $name, - 'targetEntity' => $oneToManyElement['targetEntity'], - 'mappedBy' => $oneToManyElement['mappedBy'] - ); - - if (isset($oneToManyElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $oneToManyElement['fetch']); - } - - if (isset($oneToManyElement['cascade'])) { - $mapping['cascade'] = $oneToManyElement['cascade']; - } - - if (isset($oneToManyElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool)$oneToManyElement['orphanRemoval']; - } - - if (isset($oneToManyElement['orderBy'])) { - $mapping['orderBy'] = $oneToManyElement['orderBy']; - } - - if (isset($oneToManyElement['indexBy'])) { - $mapping['indexBy'] = $oneToManyElement['indexBy']; - } - - $metadata->mapOneToMany($mapping); - } - } - - // Evaluate manyToOne relationships - if (isset($element['manyToOne'])) { - foreach ($element['manyToOne'] as $name => $manyToOneElement) { - $mapping = array( - 'fieldName' => $name, - 'targetEntity' => $manyToOneElement['targetEntity'] - ); - - if (isset($associationIds[$mapping['fieldName']])) { - $mapping['id'] = true; - } - - if (isset($manyToOneElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $manyToOneElement['fetch']); - } - - if (isset($manyToOneElement['inversedBy'])) { - $mapping['inversedBy'] = $manyToOneElement['inversedBy']; - } - - $joinColumns = array(); - - if (isset($manyToOneElement['joinColumn'])) { - $joinColumns[] = $this->joinColumnToArray($manyToOneElement['joinColumn']); - } else if (isset($manyToOneElement['joinColumns'])) { - foreach ($manyToOneElement['joinColumns'] as $joinColumnName => $joinColumnElement) { - if ( ! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $joinColumnName; - } - - $joinColumns[] = $this->joinColumnToArray($joinColumnElement); - } - } - - $mapping['joinColumns'] = $joinColumns; - - if (isset($manyToOneElement['cascade'])) { - $mapping['cascade'] = $manyToOneElement['cascade']; - } - - $metadata->mapManyToOne($mapping); - } - } - - // Evaluate manyToMany relationships - if (isset($element['manyToMany'])) { - foreach ($element['manyToMany'] as $name => $manyToManyElement) { - $mapping = array( - 'fieldName' => $name, - 'targetEntity' => $manyToManyElement['targetEntity'] - ); - - if (isset($manyToManyElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $manyToManyElement['fetch']); - } - - if (isset($manyToManyElement['mappedBy'])) { - $mapping['mappedBy'] = $manyToManyElement['mappedBy']; - } else if (isset($manyToManyElement['joinTable'])) { - - $joinTableElement = $manyToManyElement['joinTable']; - $joinTable = array( - 'name' => $joinTableElement['name'] - ); - - if (isset($joinTableElement['schema'])) { - $joinTable['schema'] = $joinTableElement['schema']; - } - - foreach ($joinTableElement['joinColumns'] as $joinColumnName => $joinColumnElement) { - if ( ! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $joinColumnName; - } - - $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement); - } - - foreach ($joinTableElement['inverseJoinColumns'] as $joinColumnName => $joinColumnElement) { - if ( ! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $joinColumnName; - } - - $joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement); - } - - $mapping['joinTable'] = $joinTable; - } - - if (isset($manyToManyElement['inversedBy'])) { - $mapping['inversedBy'] = $manyToManyElement['inversedBy']; - } - - if (isset($manyToManyElement['cascade'])) { - $mapping['cascade'] = $manyToManyElement['cascade']; - } - - if (isset($manyToManyElement['orderBy'])) { - $mapping['orderBy'] = $manyToManyElement['orderBy']; - } - - if (isset($manyToManyElement['indexBy'])) { - $mapping['indexBy'] = $manyToManyElement['indexBy']; - } - - if (isset($manyToManyElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool)$manyToManyElement['orphanRemoval']; - } - - $metadata->mapManyToMany($mapping); - } - } - - // Evaluate associationOverride - if (isset($element['associationOverride']) && is_array($element['associationOverride'])) { - - foreach ($element['associationOverride'] as $fieldName => $associationOverrideElement) { - $override = array(); - - // Check for joinColumn - if (isset($associationOverrideElement['joinColumn'])) { - $joinColumns = array(); - foreach ($associationOverrideElement['joinColumn'] as $name => $joinColumnElement) { - if ( ! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $name; - } - $joinColumns[] = $this->joinColumnToArray($joinColumnElement); - } - $override['joinColumns'] = $joinColumns; - } - - // Check for joinTable - if (isset($associationOverrideElement['joinTable'])) { - - $joinTableElement = $associationOverrideElement['joinTable']; - $joinTable = array( - 'name' => $joinTableElement['name'] - ); - - if (isset($joinTableElement['schema'])) { - $joinTable['schema'] = $joinTableElement['schema']; - } - - foreach ($joinTableElement['joinColumns'] as $name => $joinColumnElement) { - if ( ! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $name; - } - - $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement); - } - - foreach ($joinTableElement['inverseJoinColumns'] as $name => $joinColumnElement) { - if ( ! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $name; - } - - $joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement); - } - - $override['joinTable'] = $joinTable; - } - - $metadata->setAssociationOverride($fieldName, $override); - } - } - - // Evaluate associationOverride - if (isset($element['attributeOverride']) && is_array($element['attributeOverride'])) { - - foreach ($element['attributeOverride'] as $fieldName => $attributeOverrideElement) { - $mapping = $this->columnToArray($fieldName, $attributeOverrideElement); - $metadata->setAttributeOverride($fieldName, $mapping); - } - } - - // Evaluate lifeCycleCallbacks - if (isset($element['lifecycleCallbacks'])) { - foreach ($element['lifecycleCallbacks'] as $type => $methods) { - foreach ($methods as $method) { - $metadata->addLifecycleCallback($method, constant('Doctrine\ORM\Events::' . $type)); - } - } - } - - // populate ClassMetadataInfo instance from $data - - } - - /** - * Constructs a joinColumn mapping array based on the information - * found in the given join column element. - * - * @param array $joinColumnElement The array join column element - * @return array The mapping array. - */ - private function joinColumnToArray($joinColumnElement) - { - $joinColumn = array(); - if (isset($joinColumnElement['referencedColumnName'])) { - $joinColumn['referencedColumnName'] = (string) $joinColumnElement['referencedColumnName']; - } - - if (isset($joinColumnElement['name'])) { - $joinColumn['name'] = (string) $joinColumnElement['name']; - } - - if (isset($joinColumnElement['fieldName'])) { - $joinColumn['fieldName'] = (string) $joinColumnElement['fieldName']; - } - - if (isset($joinColumnElement['unique'])) { - $joinColumn['unique'] = (bool) $joinColumnElement['unique']; - } - - if (isset($joinColumnElement['nullable'])) { - $joinColumn['nullable'] = (bool) $joinColumnElement['nullable']; - } - - if (isset($joinColumnElement['onDelete'])) { - $joinColumn['onDelete'] = $joinColumnElement['onDelete']; - } - - if (isset($joinColumnElement['columnDefinition'])) { - $joinColumn['columnDefinition'] = $joinColumnElement['columnDefinition']; - } - - return $joinColumn; - } - - /** - * Parse the given column as array - * - * @param string $fieldName - * @param array $column - * @return array - */ - private function columnToArray($fieldName, $column) - { - $mapping = array( - 'fieldName' => $fieldName - ); - - if (isset($column['type'])) { - $params = explode('(', $column['type']); - $column['type'] = $params[0]; - $mapping['type'] = $column['type']; - - if (isset($params[1])) { - $column['length'] = (integer) substr($params[1], 0, strlen($params[1]) - 1); - } - } - - if (isset($column['column'])) { - $mapping['columnName'] = $column['column']; - } - - if (isset($column['length'])) { - $mapping['length'] = $column['length']; - } - - if (isset($column['precision'])) { - $mapping['precision'] = $column['precision']; - } - - if (isset($column['scale'])) { - $mapping['scale'] = $column['scale']; - } - - if (isset($column['unique'])) { - $mapping['unique'] = (bool)$column['unique']; - } - - if (isset($column['options'])) { - $mapping['options'] = $column['options']; - } - - if (isset($column['nullable'])) { - $mapping['nullable'] = $column['nullable']; - } - - if (isset($column['version']) && $column['version']) { - $mapping['version'] = $column['version']; - } - - if (isset($column['columnDefinition'])) { - $mapping['columnDefinition'] = $column['columnDefinition']; - } - - return $mapping; - } - - /** - * {@inheritdoc} - */ - protected function loadMappingFile($file) - { - if (strpos($file, "\n") === false && is_file($file)) { - if (false === is_readable($file)) { - throw new MappingException(sprintf('File "%s" is not readable.', $file)); - } - - return include($file); - } - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php old mode 100755 new mode 100644 index 3d60447f41..28e2dbea22 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php @@ -28,4 +28,4 @@ use Doctrine\Common\Persistence\Mapping\Driver\PHPDriver as CommonPHPDriver; */ class PHPDriver extends CommonPHPDriver { -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php old mode 100755 new mode 100644 index 6d53f778a3..d6c6ead853 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php @@ -28,4 +28,4 @@ use Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver as CommonStaticPH */ class StaticPHPDriver extends CommonStaticPHPDriver { -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php old mode 100755 new mode 100644 index 0be7c36bca..ed4386ac4f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -19,10 +19,11 @@ namespace Doctrine\ORM\Mapping\Driver; -use SimpleXMLElement, - Doctrine\Common\Persistence\Mapping\Driver\FileDriver, - Doctrine\Common\Persistence\Mapping\ClassMetadata, - Doctrine\ORM\Mapping\MappingException; +use SimpleXMLElement; +use Doctrine\Common\Persistence\Mapping\Driver\FileDriver; +use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\MappingException; /** * XmlDriver is a metadata driver that enables mapping through XML files. @@ -223,7 +224,7 @@ class XmlDriver extends FileDriver $metadata->table['options'] = $this->_parseOptions($xmlRoot->options->children()); } - // The mapping assignement is done in 2 times as a bug might occurs on some php/xml lib versions + // The mapping assignment is done in 2 times as a bug might occurs on some php/xml lib versions // The internal SimpleXmlIterator get resetted, to this generate a duplicate field exception $mappings = array(); // Evaluate mappings @@ -557,12 +558,33 @@ class XmlDriver extends FileDriver $metadata->addLifecycleCallback((string)$lifecycleCallback['method'], constant('Doctrine\ORM\Events::' . (string)$lifecycleCallback['type'])); } } + + // Evaluate entity listener + if (isset($xmlRoot->{'entity-listeners'})) { + foreach ($xmlRoot->{'entity-listeners'}->{'entity-listener'} as $listenerElement) { + $className = (string) $listenerElement['class']; + // Evaluate the listener using naming convention. + if($listenerElement->count() === 0) { + EntityListenerBuilder::bindEntityListener($metadata, $className); + + continue; + } + + foreach ($listenerElement as $callbackElement) { + $eventName = (string) $callbackElement['type']; + $methodName = (string) $callbackElement['method']; + + $metadata->addEntityListener($eventName, $className, $methodName); + } + } + } } /** * Parses (nested) option elements. * - * @param SimpleXMLElement $options the XML element. + * @param SimpleXMLElement $options The XML element. + * * @return array The options array. */ private function _parseOptions(SimpleXMLElement $options) @@ -593,7 +615,8 @@ class XmlDriver extends FileDriver * Constructs a joinColumn mapping array based on the information * found in the given SimpleXMLElement. * - * @param SimpleXMLElement $joinColumnElement the XML element. + * @param SimpleXMLElement $joinColumnElement The XML element. + * * @return array The mapping array. */ private function joinColumnToArray(SimpleXMLElement $joinColumnElement) @@ -623,10 +646,11 @@ class XmlDriver extends FileDriver } /** - * Parse the given field as array + * Parses the given field as array. * - * @param SimpleXMLElement $fieldMapping - * @return array + * @param SimpleXMLElement $fieldMapping + * + * @return array */ private function columnToArray(SimpleXMLElement $fieldMapping) { @@ -680,7 +704,8 @@ class XmlDriver extends FileDriver /** * Gathers a list of cascade options found in the given cascade element. * - * @param SimpleXMLElement $cascadeElement the cascade element. + * @param SimpleXMLElement $cascadeElement The cascade element. + * * @return array The list of cascade options. */ private function _getCascadeMappings($cascadeElement) @@ -721,6 +746,11 @@ class XmlDriver extends FileDriver return $result; } + /** + * @param mixed $element + * + * @return bool + */ protected function evaluateBoolean($element) { $flag = (string)$element; @@ -728,4 +758,3 @@ class XmlDriver extends FileDriver return ($flag === true || $flag == "true" || $flag == "1"); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php old mode 100755 new mode 100644 index f339045afe..1e7aa33560 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -19,10 +19,11 @@ namespace Doctrine\ORM\Mapping\Driver; -use Doctrine\Common\Persistence\Mapping\ClassMetadata, - Doctrine\Common\Persistence\Mapping\Driver\FileDriver, - Doctrine\ORM\Mapping\MappingException, - Symfony\Component\Yaml\Yaml; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; +use Doctrine\Common\Persistence\Mapping\Driver\FileDriver; +use Doctrine\ORM\Mapping\MappingException; +use Symfony\Component\Yaml\Yaml; /** * The YamlDriver reads the mapping metadata from yaml schema files. @@ -263,6 +264,10 @@ class YamlDriver extends FileDriver $mapping['columnDefinition'] = $idElement['columnDefinition']; } + if (isset($idElement['options'])) { + $mapping['options'] = $idElement['options']; + } + $metadata->mapField($mapping); if (isset($idElement['generator'])) { @@ -306,6 +311,7 @@ class YamlDriver extends FileDriver } } + // Evaluate oneToOne relationships if (isset($element['oneToOne'])) { foreach ($element['oneToOne'] as $name => $oneToOneElement) { @@ -573,13 +579,32 @@ class YamlDriver extends FileDriver } } } + + // Evaluate entityListeners + if (isset($element['entityListeners'])) { + foreach ($element['entityListeners'] as $className => $entityListener) { + // Evaluate the listener using naming convention. + if (empty($entityListener)) { + EntityListenerBuilder::bindEntityListener($metadata, $className); + + continue; + } + + foreach ($entityListener as $eventName => $callbackElement){ + foreach ($callbackElement as $methodName){ + $metadata->addEntityListener($eventName, $className, $methodName); + } + } + } + } } /** * Constructs a joinColumn mapping array based on the information * found in the given join column element. * - * @param array $joinColumnElement The array join column element + * @param array $joinColumnElement The array join column element. + * * @return array The mapping array. */ private function joinColumnToArray($joinColumnElement) @@ -617,10 +642,11 @@ class YamlDriver extends FileDriver } /** - * Parse the given column as array + * Parses the given column as array. + * + * @param string $fieldName + * @param array $column * - * @param string $fieldName - * @param array $column * @return array */ private function columnToArray($fieldName, $column) diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ElementCollection.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ElementCollection.php old mode 100755 new mode 100644 index f3f4f4cf78..46720d688e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ElementCollection.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ElementCollection.php @@ -26,6 +26,8 @@ namespace Doctrine\ORM\Mapping; */ final class ElementCollection implements Annotation { - /** @var string */ + /** + * @var string + */ public $tableName; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Entity.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Entity.php old mode 100755 new mode 100644 index d1b4eb2ac2..edf6ad5a4b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Entity.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Entity.php @@ -25,8 +25,13 @@ namespace Doctrine\ORM\Mapping; */ final class Entity implements Annotation { - /** @var string */ + /** + * @var string + */ public $repositoryClass; - /** @var boolean */ + + /** + * @var boolean + */ public $readOnly = false; } diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php old mode 100755 new mode 100644 similarity index 52% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php rename to vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php index 7b92e66ac7..2d5ecf714f --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php @@ -14,26 +14,42 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ -namespace Doctrine\Tests\Models\DDC753; +namespace Doctrine\ORM\Mapping; /** - * @Entity(repositoryClass = "Doctrine\Tests\Models\DDC753\DDC753CustomRepository") + * A resolver is used to instantiate an entity listener. + * + * @since 2.4 + * @author Fabio B. Silva */ -class DDC753EntityWithCustomRepository +interface EntityListenerResolver { + /** + * Clear all instances from the set, or a specific class when given. + * + * @param string $className The fully-qualified class name + * + * @return void + */ + function clear($className = null); /** - * @Id - * @Column(type="integer") - * @GeneratedValue + * Returns a entity listener instance for the given class name. + * + * @param string $className The fully-qualified class name + * + * @return object An entity listener */ - protected $id; - - /** @column(type="string") */ - protected $name; + function resolve($className); + /** + * Register a entity listener instance. + * + * @param object $object An entity listener + */ + function register($object); } \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityListeners.php old mode 100755 new mode 100644 similarity index 61% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php rename to vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityListeners.php index d12660cf4a..d9478a4979 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityListeners.php @@ -14,26 +14,28 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT license. For more information, see * . */ -namespace Doctrine\Tests\Models\DDC753; +namespace Doctrine\ORM\Mapping; /** - * @Entity(repositoryClass = "\stdClass") + * The EntityListeners annotation specifies the callback listener classes to be used for an entity or mapped superclass. + * The EntityListeners annotation may be applied to an entity class or mapped superclass. + * + * @author Fabio B. Silva + * @since 2.4 + * + * @Annotation + * @Target("CLASS") */ -class DDC753EntityWithInvalidRepository +final class EntityListeners implements Annotation { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue + * Specifies the names of the entity listeners. + * + * @var array */ - protected $id; - - /** @column(type="string") */ - protected $name; - + public $value = array(); } \ No newline at end of file diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityResult.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityResult.php old mode 100755 new mode 100644 index af26a11c07..63bbed22fa --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityResult.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/EntityResult.php @@ -33,9 +33,8 @@ namespace Doctrine\ORM\Mapping; */ final class EntityResult implements Annotation { - /** - * The class of the result + * The class of the result. * * @var string */ @@ -54,5 +53,4 @@ final class EntityResult implements Annotation * @var string */ public $discriminatorColumn; - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/FieldResult.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/FieldResult.php old mode 100755 new mode 100644 index ee330b2ff6..5e8aa0cd3e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/FieldResult.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/FieldResult.php @@ -30,7 +30,6 @@ namespace Doctrine\ORM\Mapping; */ final class FieldResult implements Annotation { - /** * Name of the column in the SELECT clause. * @@ -39,10 +38,9 @@ final class FieldResult implements Annotation public $name; /** - * Name of the persistent field or property of the class. + * Name of the persistent field or property of the class. * * @var string */ public $column; - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/GeneratedValue.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/GeneratedValue.php old mode 100755 new mode 100644 index d128d16281..27c03d4bee --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/GeneratedValue.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/GeneratedValue.php @@ -25,6 +25,12 @@ namespace Doctrine\ORM\Mapping; */ final class GeneratedValue implements Annotation { - /** @var string */ + /** + * The type of Id generator. + * + * @var string + * + * @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "UUID", "CUSTOM"}) + */ public $strategy = 'AUTO'; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/HasLifecycleCallbacks.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/HasLifecycleCallbacks.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Id.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Id.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Index.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Index.php old mode 100755 new mode 100644 index 51f037ab94..a6696c4b68 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Index.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Index.php @@ -25,8 +25,13 @@ namespace Doctrine\ORM\Mapping; */ final class Index implements Annotation { - /** @var string */ + /** + * @var string + */ public $name; - /** @var array */ + + /** + * @var array + */ public $columns; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/InheritanceType.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/InheritanceType.php old mode 100755 new mode 100644 index d9a2471861..de803369a3 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/InheritanceType.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/InheritanceType.php @@ -25,6 +25,12 @@ namespace Doctrine\ORM\Mapping; */ final class InheritanceType implements Annotation { - /** @var string */ + /** + * The inheritance type used by the class and its subclasses. + * + * @var string + * + * @Enum({"NONE", "JOINED", "SINGLE_TABLE", "TABLE_PER_CLASS"}) + */ public $value; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinColumn.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinColumn.php old mode 100755 new mode 100644 index 8c9bc1045f..febce91748 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinColumn.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinColumn.php @@ -25,18 +25,40 @@ namespace Doctrine\ORM\Mapping; */ final class JoinColumn implements Annotation { - /** @var string */ + /** + * @var string + */ public $name; - /** @var string */ + + /** + * @var string + */ public $referencedColumnName = 'id'; - /** @var boolean */ + + /** + * @var boolean + */ public $unique = false; - /** @var boolean */ + + /** + * @var boolean + */ public $nullable = true; - /** @var mixed */ + + /** + * @var mixed + */ public $onDelete; - /** @var string */ + + /** + * @var string + */ public $columnDefinition; - /** @var string */ - public $fieldName; // field name used in non-object hydration (array/scalar) + + /** + * Field name used in non-object hydration (array/scalar). + * + * @var string + */ + public $fieldName; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinColumns.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinColumns.php old mode 100755 new mode 100644 index 8d4c045072..ae096c2750 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinColumns.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinColumns.php @@ -25,6 +25,8 @@ namespace Doctrine\ORM\Mapping; */ final class JoinColumns implements Annotation { - /** @var array<\Doctrine\ORM\Mapping\JoinColumn> */ + /** + * @var array<\Doctrine\ORM\Mapping\JoinColumn> + */ public $value; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinTable.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinTable.php old mode 100755 new mode 100644 index 7fb69cbf3c..8a440c6143 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinTable.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/JoinTable.php @@ -25,12 +25,23 @@ namespace Doctrine\ORM\Mapping; */ final class JoinTable implements Annotation { - /** @var string */ + /** + * @var string + */ public $name; - /** @var string */ + + /** + * @var string + */ public $schema; - /** @var array<\Doctrine\ORM\Mapping\JoinColumn> */ + + /** + * @var array<\Doctrine\ORM\Mapping\JoinColumn> + */ public $joinColumns = array(); - /** @var array<\Doctrine\ORM\Mapping\JoinColumn> */ + + /** + * @var array<\Doctrine\ORM\Mapping\JoinColumn> + */ public $inverseJoinColumns = array(); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ManyToMany.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ManyToMany.php old mode 100755 new mode 100644 index 9c79689278..ca2f53c9ee --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -25,18 +25,42 @@ namespace Doctrine\ORM\Mapping; */ final class ManyToMany implements Annotation { - /** @var string */ + /** + * @var string + */ public $targetEntity; - /** @var string */ + + /** + * @var string + */ public $mappedBy; - /** @var string */ + + /** + * @var string + */ public $inversedBy; - /** @var array */ + + /** + * @var array + */ public $cascade; - /** @var string */ + + /** + * The fetching strategy to use for the association. + * + * @var string + * + * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) + */ public $fetch = 'LAZY'; - /** @var boolean */ + + /** + * @var boolean + */ public $orphanRemoval = false; - /** @var string */ + + /** + * @var string + */ public $indexBy; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ManyToOne.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ManyToOne.php old mode 100755 new mode 100644 index eb0975575b..d3414e6a95 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ManyToOne.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ManyToOne.php @@ -25,12 +25,27 @@ namespace Doctrine\ORM\Mapping; */ final class ManyToOne implements Annotation { - /** @var string */ + /** + * @var string + */ public $targetEntity; - /** @var array */ + + /** + * @var array + */ public $cascade; - /** @var string */ + + /** + * The fetching strategy to use for the association. + * + * @var string + * + * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) + */ public $fetch = 'LAZY'; - /** @var string */ + + /** + * @var string + */ public $inversedBy; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappedSuperclass.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappedSuperclass.php old mode 100755 new mode 100644 index b55161086b..74588107d8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappedSuperclass.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappedSuperclass.php @@ -25,6 +25,8 @@ namespace Doctrine\ORM\Mapping; */ final class MappedSuperclass implements Annotation { - /** @var string */ + /** + * @var string + */ public $repositoryClass; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php old mode 100755 new mode 100644 index 9b97a1f0bb..987e60917f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php @@ -26,12 +26,20 @@ namespace Doctrine\ORM\Mapping; */ class MappingException extends \Doctrine\ORM\ORMException { + /** + * @return MappingException + */ public static function pathRequired() { return new self("Specifying the paths to your entities is required ". "in the AnnotationDriver to retrieve all class names."); } + /** + * @param string $entityName + * + * @return MappingException + */ public static function identifierRequired($entityName) { if (false !== ($parent = get_parent_class($entityName))) { @@ -48,41 +56,73 @@ class MappingException extends \Doctrine\ORM\ORMException } + /** + * @param string $entityName + * @param string $type + * + * @return MappingException + */ public static function invalidInheritanceType($entityName, $type) { return new self("The inheritance type '$type' specified for '$entityName' does not exist."); } + /** + * @return MappingException + */ public static function generatorNotAllowedWithCompositeId() { return new self("Id generators can't be used with a composite id."); } + /** + * @param string $entity + * + * @return MappingException + */ public static function missingFieldName($entity) { return new self("The field or association mapping misses the 'fieldName' attribute in entity '$entity'."); } + /** + * @param string $fieldName + * + * @return MappingException + */ public static function missingTargetEntity($fieldName) { return new self("The association mapping '$fieldName' misses the 'targetEntity' attribute."); } + /** + * @param string $fieldName + * + * @return MappingException + */ public static function missingSourceEntity($fieldName) { return new self("The association mapping '$fieldName' misses the 'sourceEntity' attribute."); } + /** + * @param string $entityName + * @param string $fileName + * + * @return MappingException + */ public static function mappingFileNotFound($entityName, $fileName) { return new self("No mapping file found named '$fileName' for class '$entityName'."); } - /** + /** * Exception for invalid property name override. * - * @param string $className The entity's name + * @param string $className The entity's name. * @param string $fieldName + * + * @return MappingException */ public static function invalidOverrideFieldName($className, $fieldName) { @@ -92,64 +132,128 @@ class MappingException extends \Doctrine\ORM\ORMException /** * Exception for invalid property type override. * - * @param string $className The entity's name + * @param string $className The entity's name. * @param string $fieldName + * + * @return MappingException */ public static function invalidOverrideFieldType($className, $fieldName) { return new self("The column type of attribute '$fieldName' on class '$className' could not be changed."); } + /** + * @param string $className + * @param string $fieldName + * + * @return MappingException + */ public static function mappingNotFound($className, $fieldName) { return new self("No mapping found for field '$fieldName' on class '$className'."); } + /** + * @param string $className + * @param string $queryName + * + * @return MappingException + */ public static function queryNotFound($className, $queryName) { return new self("No query found named '$queryName' on class '$className'."); } + /** + * @param string $className + * @param string $resultName + * + * @return MappingException + */ public static function resultMappingNotFound($className, $resultName) { return new self("No result set mapping found named '$resultName' on class '$className'."); } + /** + * @param string $entity + * @param string $queryName + * + * @return MappingException + */ public static function emptyQueryMapping($entity, $queryName) { return new self('Query named "'.$queryName.'" in "'.$entity.'" could not be empty.'); } + /** + * @param string $className + * + * @return MappingException + */ public static function nameIsMandatoryForQueryMapping($className) { return new self("Query name on entity class '$className' is not defined."); } + /** + * @param string $entity + * @param string $queryName + * + * @return MappingException + */ public static function missingQueryMapping($entity, $queryName) { return new self('Query named "'.$queryName.'" in "'.$entity.' requires a result class or result set mapping.'); } + /** + * @param string $entity + * @param string $resultName + * + * @return MappingException + */ public static function missingResultSetMappingEntity($entity, $resultName) { return new self('Result set mapping named "'.$resultName.'" in "'.$entity.' requires a entity class name.'); } + /** + * @param string $entity + * @param string $resultName + * + * @return MappingException + */ public static function missingResultSetMappingFieldName($entity, $resultName) { return new self('Result set mapping named "'.$resultName.'" in "'.$entity.' requires a field name.'); } + /** + * @param string $className + * + * @return MappingException + */ public static function nameIsMandatoryForSqlResultSetMapping($className) { return new self("Result set mapping name on entity class '$className' is not defined."); } + /** + * @param string $fieldName + * + * @return MappingException + */ public static function oneToManyRequiresMappedBy($fieldName) { return new self("OneToMany mapping on field '$fieldName' requires the 'mappedBy' attribute."); } + /** + * @param string $fieldName + * + * @return MappingException + */ public static function joinTableRequired($fieldName) { return new self("The mapping of field '$fieldName' requires an the 'joinTable' attribute."); @@ -158,10 +262,11 @@ class MappingException extends \Doctrine\ORM\ORMException /** * Called if a required option was not found but is required * - * @param string $field which field cannot be processed? - * @param string $expectedOption which option is required - * @param string $hint Can optionally be used to supply a tip for common mistakes, - * e.g. "Did you think of the plural s?" + * @param string $field Which field cannot be processed? + * @param string $expectedOption Which option is required + * @param string $hint Can optionally be used to supply a tip for common mistakes, + * e.g. "Did you think of the plural s?" + * * @return MappingException */ static function missingRequiredOption($field, $expectedOption, $hint = '') @@ -179,6 +284,8 @@ class MappingException extends \Doctrine\ORM\ORMException * Generic exception for invalid mappings. * * @param string $fieldName + * + * @return MappingException */ public static function invalidMapping($fieldName) { @@ -190,20 +297,33 @@ class MappingException extends \Doctrine\ORM\ORMException * because there might be long classnames that will be shortened * within the stacktrace * - * @param string $entity The entity's name + * @param string $entity The entity's name * @param \ReflectionException $previousException + * + * @return MappingException */ public static function reflectionFailure($entity, \ReflectionException $previousException) { return new self('An error occurred in ' . $entity, 0, $previousException); } + /** + * @param string $className + * @param string $joinColumn + * + * @return MappingException + */ public static function joinColumnMustPointToMappedField($className, $joinColumn) { return new self('The column ' . $joinColumn . ' must be mapped to a field in class ' . $className . ' since it is referenced by a join column of another class.'); } + /** + * @param string $className + * + * @return MappingException + */ public static function classIsNotAValidEntityOrMappedSuperClass($className) { if (false !== ($parent = get_parent_class($className))) { @@ -219,45 +339,88 @@ class MappingException extends \Doctrine\ORM\ORMException )); } + /** + * @param string $className + * @param string $propertyName + * + * @return MappingException + */ public static function propertyTypeIsRequired($className, $propertyName) { return new self("The attribute 'type' is required for the column description of property ".$className."::\$".$propertyName."."); } + /** + * @param string $className + * + * @return MappingException + */ public static function tableIdGeneratorNotImplemented($className) { return new self("TableIdGenerator is not yet implemented for use with class ".$className); } /** - * @param string $entity The entity's name - * @param string $fieldName The name of the field that was already declared + * @param string $entity The entity's name. + * @param string $fieldName The name of the field that was already declared. + * + * @return MappingException */ public static function duplicateFieldMapping($entity, $fieldName) { return new self('Property "'.$fieldName.'" in "'.$entity.'" was already declared, but it must be declared only once'); } + /** + * @param string $entity + * @param string $fieldName + * + * @return MappingException + */ public static function duplicateAssociationMapping($entity, $fieldName) { return new self('Property "'.$fieldName.'" in "'.$entity.'" was already declared, but it must be declared only once'); } + /** + * @param string $entity + * @param string $queryName + * + * @return MappingException + */ public static function duplicateQueryMapping($entity, $queryName) { return new self('Query named "'.$queryName.'" in "'.$entity.'" was already declared, but it must be declared only once'); } + /** + * @param string $entity + * @param string $resultName + * + * @return MappingException + */ public static function duplicateResultSetMapping($entity, $resultName) { return new self('Result set mapping named "'.$resultName.'" in "'.$entity.'" was already declared, but it must be declared only once'); } + /** + * @param string $entity + * + * @return MappingException + */ public static function singleIdNotAllowedOnCompositePrimaryKey($entity) { return new self('Single id is not allowed on composite primary key in entity '.$entity); } + /** + * @param string $entity + * @param string $fieldName + * @param string $unsupportedType + * + * @return MappingException + */ public static function unsupportedOptimisticLockingType($entity, $fieldName, $unsupportedType) { return new self('Locking type "'.$unsupportedType.'" (specified in "'.$entity.'", field "'.$fieldName.'") ' @@ -265,6 +428,11 @@ class MappingException extends \Doctrine\ORM\ORMException ); } + /** + * @param string|null $path + * + * @return MappingException + */ public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null) { if ( ! empty($path)) { @@ -278,12 +446,13 @@ class MappingException extends \Doctrine\ORM\ORMException } /** - * Throws an exception that indicates that a class used in a discriminator map does not exist. + * Returns an exception that indicates that a class used in a discriminator map does not exist. * An example would be an outdated (maybe renamed) classname. * - * @param string $className The class that could not be found + * @param string $className The class that could not be found * @param string $owningClass The class that declares the discriminator map. - * @return self + * + * @return MappingException */ public static function invalidClassInDiscriminatorMap($className, $owningClass) { @@ -293,6 +462,13 @@ class MappingException extends \Doctrine\ORM\ORMException ); } + /** + * @param string $className + * @param array $entries + * @param array $map + * + * @return MappingException + */ public static function duplicateDiscriminatorEntry($className, array $entries, array $map) { return new self( @@ -304,47 +480,88 @@ class MappingException extends \Doctrine\ORM\ORMException ); } + /** + * @param string $className + * + * @return MappingException + */ public static function missingDiscriminatorMap($className) { return new self("Entity class '$className' is using inheritance but no discriminator map was defined."); } + /** + * @param string $className + * + * @return MappingException + */ public static function missingDiscriminatorColumn($className) { return new self("Entity class '$className' is using inheritance but no discriminator column was defined."); } + /** + * @param string $className + * @param string $type + * + * @return MappingException + */ public static function invalidDiscriminatorColumnType($className, $type) { return new self("Discriminator column type on entity class '$className' is not allowed to be '$type'. 'string' or 'integer' type variables are suggested!"); } + /** + * @param string $className + * + * @return MappingException + */ public static function nameIsMandatoryForDiscriminatorColumns($className) { return new self("Discriminator column name on entity class '$className' is not defined."); } + /** + * @param string $className + * @param string $fieldName + * + * @return MappingException + */ public static function cannotVersionIdField($className, $fieldName) { - return new self("Setting Id field '$fieldName' as versionale in entity class '$className' is not supported."); + return new self("Setting Id field '$fieldName' as versionable in entity class '$className' is not supported."); } + /** + * @param string $className + * @param string $fieldName + * @param string $type + * + * @return MappingException + */ public static function sqlConversionNotAllowedForIdentifiers($className, $fieldName, $type) { return new self("It is not possible to set id field '$fieldName' to type '$type' in entity class '$className'. The type '$type' requires conversion SQL which is not allowed for identifiers."); } /** - * @param string $className - * @param string $columnName - * @return self + * @param string $className + * @param string $columnName + * + * @return MappingException */ public static function duplicateColumnName($className, $columnName) { return new self("Duplicate definition of column '".$columnName."' on entity '".$className."' in a field or discriminator column mapping."); } - public static function illegalToManyAssocationOnMappedSuperclass($className, $field) + /** + * @param string $className + * @param string $field + * + * @return MappingException + */ + public static function illegalToManyAssociationOnMappedSuperclass($className, $field) { return new self("It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass '".$className."#".$field."'."); } @@ -353,7 +570,8 @@ class MappingException extends \Doctrine\ORM\ORMException * @param string $className * @param string $targetEntity * @param string $targetField - * @return self + * + * @return MappingException */ public static function cannotMapCompositePrimaryKeyEntitiesAsForeignId($className, $targetEntity, $targetField) { @@ -361,73 +579,174 @@ class MappingException extends \Doctrine\ORM\ORMException "as part of the primary key of another entity '".$targetEntity."#".$targetField."'."); } + /** + * @param string $className + * @param string $field + * + * @return MappingException + */ public static function noSingleAssociationJoinColumnFound($className, $field) { return new self("'$className#$field' is not an association with a single join column."); } + /** + * @param string $className + * @param string $column + * + * @return MappingException + */ public static function noFieldNameFoundForColumn($className, $column) { return new self("Cannot find a field on '$className' that is mapped to column '$column'. Either the ". "field does not exist or an association exists but it has multiple join columns."); } + /** + * @param string $className + * @param string $field + * + * @return MappingException + */ public static function illegalOrphanRemovalOnIdentifierAssociation($className, $field) { return new self("The orphan removal option is not allowed on an association that is ". "part of the identifier in '$className#$field'."); } + /** + * @param string $className + * @param string $field + * + * @return MappingException + */ public static function illegalOrphanRemoval($className, $field) { return new self("Orphan removal is only allowed on one-to-one and one-to-many ". "associations, but " . $className."#" .$field . " is not."); } - public static function illegalInverseIdentifierAssocation($className, $field) + /** + * @param string $className + * @param string $field + * + * @return MappingException + */ + public static function illegalInverseIdentifierAssociation($className, $field) { return new self("An inverse association is not allowed to be identifier in '$className#$field'."); } - public static function illegalToManyIdentifierAssoaction($className, $field) + /** + * @param string $className + * @param string $field + * + * @return MappingException + */ + public static function illegalToManyIdentifierAssociation($className, $field) { return new self("Many-to-many or one-to-many associations are not allowed to be identifier in '$className#$field'."); } + /** + * @param string $className + * + * @return MappingException + */ public static function noInheritanceOnMappedSuperClass($className) { return new self("Its not supported to define inheritance information on a mapped superclass '" . $className . "'."); } + /** + * @param string $className + * @param string $rootClassName + * + * @return MappingException + */ public static function mappedClassNotPartOfDiscriminatorMap($className, $rootClassName) { return new self( "Entity '" . $className . "' has to be part of the discriminator map of '" . $rootClassName . "' " . - "to be properly mapped in the inheritance hierachy. Alternatively you can make '".$className."' an abstract class " . - "to avoid this exception from occuring." + "to be properly mapped in the inheritance hierarchy. Alternatively you can make '".$className."' an abstract class " . + "to avoid this exception from occurring." ); } + /** + * @param string $className + * @param string $methodName + * + * @return MappingException + */ public static function lifecycleCallbackMethodNotFound($className, $methodName) { return new self("Entity '" . $className . "' has no method '" . $methodName . "' to be registered as lifecycle callback."); } + /** + * @param string $listenerName + * @param string $className + * + * @return \Doctrine\ORM\Mapping\MappingException + */ + public static function entityListenerClassNotFound($listenerName, $className) + { + return new self(sprintf('Entity Listener "%s" declared on "%s" not found.', $listenerName, $className)); + } + + /** + * @param string $listenerName + * @param string $methodName + * @param string $className + * + * @return \Doctrine\ORM\Mapping\MappingException + */ + public static function entityListenerMethodNotFound($listenerName, $methodName, $className) + { + return new self(sprintf('Entity Listener "%s" declared on "%s" has no method "%s".', $listenerName, $className, $methodName)); + } + + /** + * @param string $className + * @param string $annotation + * + * @return MappingException + */ public static function invalidFetchMode($className, $annotation) { return new self("Entity '" . $className . "' has a mapping with invalid fetch mode '" . $annotation . "'"); } + /** + * @param string $className + * + * @return MappingException + */ public static function compositeKeyAssignedIdGeneratorRequired($className) { return new self("Entity '". $className . "' has a composite identifier but uses an ID generator other than manually assigning (Identity, Sequence). This is not supported."); } + /** + * @param string $targetEntity + * @param string $sourceEntity + * @param string $associationName + * + * @return MappingException + */ public static function invalidTargetEntityClass($targetEntity, $sourceEntity, $associationName) { return new self("The target-entity " . $targetEntity . " cannot be found in '" . $sourceEntity."#".$associationName."'."); } + /** + * @param array $cascades + * @param string $className + * @param string $propertyName + * + * @return MappingException + */ public static function invalidCascadeOption(array $cascades, $className, $propertyName) { $cascades = implode(", ", array_map(function ($e) { return "'" . $e . "'"; }, $cascades)); @@ -438,4 +757,16 @@ class MappingException extends \Doctrine\ORM\ORMException $cascades )); } + + /** + * @param string $className + * + * @return MappingException + */ + public static function missingSequenceName($className) + { + return new self( + sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className) + ); + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php old mode 100755 new mode 100644 index f0192ae254..f336c99171 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php @@ -31,7 +31,6 @@ namespace Doctrine\ORM\Mapping; */ final class NamedNativeQuery implements Annotation { - /** * The name used to refer to the query with the EntityManager methods that create query objects. * @@ -59,5 +58,4 @@ final class NamedNativeQuery implements Annotation * @var string */ public $resultSetMapping; - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedQueries.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedQueries.php old mode 100755 new mode 100644 index 14bb479521..5fce0727b2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedQueries.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedQueries.php @@ -25,6 +25,8 @@ namespace Doctrine\ORM\Mapping; */ final class NamedQueries implements Annotation { - /** @var array<\Doctrine\ORM\Mapping\NamedQuery> */ + /** + * @var array<\Doctrine\ORM\Mapping\NamedQuery> + */ public $value; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedQuery.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedQuery.php old mode 100755 new mode 100644 index 2826820828..c4e6cd528f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedQuery.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamedQuery.php @@ -25,8 +25,13 @@ namespace Doctrine\ORM\Mapping; */ final class NamedQuery implements Annotation { - /** @var string */ + /** + * @var string + */ public $name; - /** @var string */ + + /** + * @var string + */ public $query; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamingStrategy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamingStrategy.php old mode 100755 new mode 100644 index a6acac2556..fc66905c50 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamingStrategy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/NamingStrategy.php @@ -31,52 +31,58 @@ namespace Doctrine\ORM\Mapping; interface NamingStrategy { /** - * Return a table name for an entity class + * Returns a table name for an entity class. * - * @param string $className The fully-qualified class name - * @return string A table name + * @param string $className The fully-qualified class name. + * + * @return string A table name. */ function classToTableName($className); /** - * Return a column name for a property + * Returns a column name for a property. * - * @param string $propertyName A property - * @return string A column name + * @param string $propertyName A property name. + * @param string|null $className The fully-qualified class name. + * + * @return string A column name. */ - function propertyToColumnName($propertyName); + function propertyToColumnName($propertyName, $className = null); /** - * Return the default reference column name + * Returns the default reference column name. * - * @return string A column name + * @return string A column name. */ function referenceColumnName(); /** - * Return a join column name for a property + * Returns a join column name for a property. * - * @param string $propertyName A property - * @return string A join column name + * @param string $propertyName A property name. + * + * @return string A join column name. */ function joinColumnName($propertyName); /** - * Return a join table name + * Returns a join table name. * - * @param string $sourceEntity The source entity - * @param string $targetEntity The target entity - * @param string $propertyName A property - * @return string A join table name + * @param string $sourceEntity The source entity. + * @param string $targetEntity The target entity. + * @param string|null $propertyName A property name. + * + * @return string A join table name. */ function joinTableName($sourceEntity, $targetEntity, $propertyName = null); /** - * Return the foreign key column name for the given parameters + * Returns the foreign key column name for the given parameters. * - * @param string $entityName A entity - * @param string $referencedColumnName A property - * @return string A join column name + * @param string $entityName An entity. + * @param string|null $referencedColumnName A property. + * + * @return string A join column name. */ function joinKeyColumnName($entityName, $referencedColumnName = null); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OneToMany.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OneToMany.php old mode 100755 new mode 100644 index 233dc90f88..4b2465718e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OneToMany.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OneToMany.php @@ -25,16 +25,37 @@ namespace Doctrine\ORM\Mapping; */ final class OneToMany implements Annotation { - /** @var string */ + /** + * @var string + */ public $mappedBy; - /** @var string */ + + /** + * @var string + */ public $targetEntity; - /** @var array */ + + /** + * @var array + */ public $cascade; - /** @var string */ + + /** + * The fetching strategy to use for the association. + * + * @var string + * + * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) + */ public $fetch = 'LAZY'; - /** @var boolean */ + + /** + * @var boolean + */ public $orphanRemoval = false; - /** @var string */ + + /** + * @var string + */ public $indexBy; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OneToOne.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OneToOne.php old mode 100755 new mode 100644 index 68689eff3f..b2ab81f88d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OneToOne.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OneToOne.php @@ -25,16 +25,37 @@ namespace Doctrine\ORM\Mapping; */ final class OneToOne implements Annotation { - /** @var string */ + /** + * @var string + */ public $targetEntity; - /** @var string */ + + /** + * @var string + */ public $mappedBy; - /** @var string */ + + /** + * @var string + */ public $inversedBy; - /** @var array */ + + /** + * @var array + */ public $cascade; - /** @var string */ + + /** + * The fetching strategy to use for the association. + * + * @var string + * + * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) + */ public $fetch = 'LAZY'; - /** @var boolean */ + + /** + * @var boolean + */ public $orphanRemoval = false; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OrderBy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OrderBy.php old mode 100755 new mode 100644 index 40419733e1..ad1b7a8f71 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OrderBy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/OrderBy.php @@ -25,6 +25,8 @@ namespace Doctrine\ORM\Mapping; */ final class OrderBy implements Annotation { - /** @var array */ + /** + * @var array + */ public $value; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PostLoad.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PostLoad.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PostPersist.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PostPersist.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PostRemove.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PostRemove.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PostUpdate.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PostUpdate.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PreFlush.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PreFlush.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PrePersist.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PrePersist.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PreRemove.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PreRemove.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PreUpdate.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/PreUpdate.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/QuoteStrategy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/QuoteStrategy.php old mode 100755 new mode 100644 index 52e846d996..2ad7e7c972 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/QuoteStrategy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/QuoteStrategy.php @@ -23,7 +23,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\DBAL\Platforms\AbstractPlatform; /** - * A set of rules for determining the column, alias and table quotes + * A set of rules for determining the column, alias and table quotes. * * @since 2.3 * @author Fabio B. Silva @@ -33,80 +33,88 @@ interface QuoteStrategy /** * Gets the (possibly quoted) column name for safe use in an SQL statement. * - * @param string $fieldName - * @param ClassMetadata $class - * @param AbstractPlatform $platform - * @return string + * @param string $fieldName + * @param ClassMetadata $class + * @param AbstractPlatform $platform + * + * @return string */ function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform); /** * Gets the (possibly quoted) primary table name for safe use in an SQL statement. * - * @param ClassMetadata $class - * @param AbstractPlatform $platform - * @return string + * @param ClassMetadata $class + * @param AbstractPlatform $platform + * + * @return string */ function getTableName(ClassMetadata $class, AbstractPlatform $platform); /** * Gets the (possibly quoted) sequence name for safe use in an SQL statement. * - * @param array $definition - * @param ClassMetadata $class - * @param AbstractPlatform $platform - * @return string + * @param array $definition + * @param ClassMetadata $class + * @param AbstractPlatform $platform + * + * @return string */ function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform); /** * Gets the (possibly quoted) name of the join table. * - * @param array $association - * @param ClassMetadata $class - * @param AbstractPlatform $platform - * @return string + * @param array $association + * @param ClassMetadata $class + * @param AbstractPlatform $platform + * + * @return string */ function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform); /** * Gets the (possibly quoted) join column name. * - * @param array $joinColumn - * @param ClassMetadata $class - * @param AbstractPlatform $platform - * @return string + * @param array $joinColumn + * @param ClassMetadata $class + * @param AbstractPlatform $platform + * + * @return string */ function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform); /** * Gets the (possibly quoted) join column name. * - * @param array $joinColumn - * @param ClassMetadata $class - * @param AbstractPlatform $platform - * @return string + * @param array $joinColumn + * @param ClassMetadata $class + * @param AbstractPlatform $platform + * + * @return string */ function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform); /** * Gets the (possibly quoted) identifier column names for safe use in an SQL statement. * - * @param ClassMetadata $class - * @param AbstractPlatform $platform - * @return array + * @param ClassMetadata $class + * @param AbstractPlatform $platform + * + * @return array */ function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform); /** * Gets the column alias. * - * @param string $columnName - * @param integer $counter - * @param AbstractPlatform $platform - * @param ClassMetadata $class - * @return string + * @param string $columnName + * @param integer $counter + * @param AbstractPlatform $platform + * @param ClassMetadata|null $class + * + * @return string */ function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ClassMetadata $class = null); -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SequenceGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SequenceGenerator.php old mode 100755 new mode 100644 index 1acb498bc1..ba1c45b642 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SequenceGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SequenceGenerator.php @@ -25,10 +25,18 @@ namespace Doctrine\ORM\Mapping; */ final class SequenceGenerator implements Annotation { - /** @var string */ + /** + * @var string + */ public $sequenceName; - /** @var integer */ + + /** + * @var integer + */ public $allocationSize = 1; - /** @var integer */ + + /** + * @var integer + */ public $initialValue = 1; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php old mode 100755 new mode 100644 index 881e873ed9..f5ead7c0f2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php @@ -31,7 +31,6 @@ namespace Doctrine\ORM\Mapping; */ final class SqlResultSetMapping implements Annotation { - /** * The name given to the result set mapping, and used to refer to it in the methods of the Query API. * @@ -52,5 +51,4 @@ final class SqlResultSetMapping implements Annotation * @var array<\Doctrine\ORM\Mapping\ColumnResult> */ public $columns = array(); - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Table.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Table.php old mode 100755 new mode 100644 index 8f94f0c877..f9f8d4a656 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Table.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Table.php @@ -25,14 +25,28 @@ namespace Doctrine\ORM\Mapping; */ final class Table implements Annotation { - /** @var string */ + /** + * @var string + */ public $name; - /** @var string */ + + /** + * @var string + */ public $schema; - /** @var array<\Doctrine\ORM\Mapping\Index> */ + + /** + * @var array<\Doctrine\ORM\Mapping\Index> + */ public $indexes; - /** @var array<\Doctrine\ORM\Mapping\UniqueConstraint> */ + + /** + * @var array<\Doctrine\ORM\Mapping\UniqueConstraint> + */ public $uniqueConstraints; - /** @var array */ + + /** + * @var array + */ public $options = array(); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php old mode 100755 new mode 100644 index 236ab5cfef..5231aaafcd --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php @@ -37,7 +37,7 @@ class UnderscoreNamingStrategy implements NamingStrategy private $case; /** - * Underscore naming strategy construct + * Underscore naming strategy construct. * * @param integer $case CASE_LOWER | CASE_UPPER */ @@ -47,7 +47,7 @@ class UnderscoreNamingStrategy implements NamingStrategy } /** - * @return integer + * @return integer CASE_LOWER | CASE_UPPER */ public function getCase() { @@ -55,10 +55,12 @@ class UnderscoreNamingStrategy implements NamingStrategy } /** - * Sets string case CASE_LOWER | CASE_UPPER - * Alphabetic characters converted to lowercase or uppercase + * Sets string case CASE_LOWER | CASE_UPPER. + * Alphabetic characters converted to lowercase or uppercase. * * @param integer $case + * + * @return void */ public function setCase($case) { @@ -80,7 +82,7 @@ class UnderscoreNamingStrategy implements NamingStrategy /** * {@inheritdoc} */ - public function propertyToColumnName($propertyName) + public function propertyToColumnName($propertyName, $className = null) { return $this->underscore($propertyName); } @@ -120,6 +122,7 @@ class UnderscoreNamingStrategy implements NamingStrategy /** * @param string $string + * * @return string */ private function underscore($string) diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UniqueConstraint.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UniqueConstraint.php old mode 100755 new mode 100644 index 7df2a2ce8b..95d99293f9 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UniqueConstraint.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UniqueConstraint.php @@ -25,8 +25,13 @@ namespace Doctrine\ORM\Mapping; */ final class UniqueConstraint implements Annotation { - /** @var string */ + /** + * @var string + */ public $name; - /** @var array */ + + /** + * @var array + */ public $columns; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Version.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Version.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/NativeQuery.php b/vendor/doctrine/orm/lib/Doctrine/ORM/NativeQuery.php old mode 100755 new mode 100644 index 1b9b02229a..b19f818056 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/NativeQuery.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/NativeQuery.php @@ -27,12 +27,16 @@ namespace Doctrine\ORM; */ final class NativeQuery extends AbstractQuery { + /** + * @var string + */ private $_sql; /** * Sets the SQL of the query. * * @param string $sql + * * @return NativeQuery This query instance. */ public function setSQL($sql) @@ -46,6 +50,7 @@ final class NativeQuery extends AbstractQuery * Gets the SQL query. * * @return mixed The built SQL query or an array of all SQL queries. + * * @override */ public function getSQL() diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/NoResultException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/NoResultException.php old mode 100755 new mode 100644 index 682cb3a645..2cbac8e9d9 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/NoResultException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/NoResultException.php @@ -27,6 +27,9 @@ namespace Doctrine\ORM; */ class NoResultException extends UnexpectedResultException { + /** + * Constructor. + */ public function __construct() { parent::__construct('No result was found for query although at least one row was expected.'); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/NonUniqueResultException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/NonUniqueResultException.php old mode 100755 new mode 100644 index 4523af2122..55b7130005 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/NonUniqueResultException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/NonUniqueResultException.php @@ -27,5 +27,4 @@ namespace Doctrine\ORM; */ class NonUniqueResultException extends UnexpectedResultException { - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php old mode 100755 new mode 100644 index 2776753c5b..99333f034d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php @@ -29,22 +29,41 @@ use Exception; */ class ORMException extends Exception { + /** + * @return ORMException + */ public static function missingMappingDriverImpl() { return new self("It's a requirement to specify a Metadata Driver and pass it ". "to Doctrine\\ORM\\Configuration::setMetadataDriverImpl()."); } + /** + * @param string $queryName + * + * @return ORMException + */ public static function namedQueryNotFound($queryName) { return new self('Could not find a named query by the name "' . $queryName . '"'); } + /** + * @param string $nativeQueryName + * + * @return ORMException + */ public static function namedNativeQueryNotFound($nativeQueryName) { return new self('Could not find a named native query by the name "' . $nativeQueryName . '"'); } + /** + * @param object $entity + * @param object $relatedEntity + * + * @return ORMException + */ public static function entityMissingForeignAssignedId($entity, $relatedEntity) { return new self( @@ -56,6 +75,12 @@ class ORMException extends Exception ); } + /** + * @param object $entity + * @param string $field + * + * @return ORMException + */ public static function entityMissingAssignedIdForField($entity, $field) { return new self("Entity of type " . get_class($entity) . " is missing an assigned ID for field '" . $field . "'. " . @@ -65,6 +90,11 @@ class ORMException extends Exception ); } + /** + * @param string $field + * + * @return ORMException + */ public static function unrecognizedField($field) { return new self("Unrecognized field: $field"); @@ -73,37 +103,67 @@ class ORMException extends Exception /** * @param string $className * @param string $field + * + * @return ORMException */ public static function invalidOrientation($className, $field) { return new self("Invalid order by orientation specified for " . $className . "#" . $field); } + /** + * @param string $mode + * + * @return ORMException + */ public static function invalidFlushMode($mode) { return new self("'$mode' is an invalid flush mode."); } + /** + * @return ORMException + */ public static function entityManagerClosed() { return new self("The EntityManager is closed."); } + /** + * @param string $mode + * + * @return ORMException + */ public static function invalidHydrationMode($mode) { return new self("'$mode' is an invalid hydration mode."); } + /** + * @return ORMException + */ public static function mismatchedEventManager() { return new self("Cannot use different EventManager instances for EntityManager and Connection."); } + /** + * @param string $methodName + * + * @return ORMException + */ public static function findByRequiresParameter($methodName) { return new self("You need to pass a parameter to '".$methodName."'"); } + /** + * @param string $entityName + * @param string $fieldName + * @param string $method + * + * @return ORMException + */ public static function invalidFindByCall($entityName, $fieldName, $method) { return new self( @@ -112,6 +172,12 @@ class ORMException extends Exception ); } + /** + * @param string $entityName + * @param string $associationFieldName + * + * @return ORMException + */ public static function invalidFindByInverseAssociation($entityName, $associationFieldName) { return new self( @@ -120,29 +186,51 @@ class ORMException extends Exception ); } - public static function invalidResultCacheDriver() { + /** + * @return ORMException + */ + public static function invalidResultCacheDriver() + { return new self("Invalid result cache driver; it must implement Doctrine\\Common\\Cache\\Cache."); } - public static function notSupported() { + /** + * @return ORMException + */ + public static function notSupported() + { return new self("This behaviour is (currently) not supported by Doctrine 2"); } + /** + * @return ORMException + */ public static function queryCacheNotConfigured() { return new self('Query Cache is not configured.'); } + /** + * @return ORMException + */ public static function metadataCacheNotConfigured() { return new self('Class Metadata Cache is not configured.'); } + /** + * @return ORMException + */ public static function proxyClassesAlwaysRegenerating() { return new self('Proxy Classes are always regenerating.'); } + /** + * @param string $entityNamespaceAlias + * + * @return ORMException + */ public static function unknownEntityNamespace($entityNamespaceAlias) { return new self( @@ -150,16 +238,32 @@ class ORMException extends Exception ); } + /** + * @param string $className + * + * @return ORMException + */ public static function invalidEntityRepository($className) { return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository."); } + /** + * @param string $className + * @param string $fieldName + * + * @return ORMException + */ public static function missingIdentifierField($className, $fieldName) { return new self("The identifier $fieldName is missing for a query of " . $className); } + /** + * @param string $functionName + * + * @return ORMException + */ public static function overwriteInternalDQLFunctionNotAllowed($functionName) { return new self("It is not allowed to overwrite internal function '$functionName' in the DQL parser through user-defined functions."); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php old mode 100755 new mode 100644 index d889173401..cb50376797 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -26,21 +26,42 @@ namespace Doctrine\ORM; */ class ORMInvalidArgumentException extends \InvalidArgumentException { + /** + * @param object $entity + * + * @return ORMInvalidArgumentException + */ static public function scheduleInsertForManagedEntity($entity) { return new self("A managed+dirty entity " . self::objToStr($entity) . " can not be scheduled for insertion."); } + /** + * @param object $entity + * + * @return ORMInvalidArgumentException + */ static public function scheduleInsertForRemovedEntity($entity) { return new self("Removed entity " . self::objToStr($entity) . " can not be scheduled for insertion."); } + /** + * @param object $entity + * + * @return ORMInvalidArgumentException + */ static public function scheduleInsertTwice($entity) { return new self("Entity " . self::objToStr($entity) . " can not be scheduled for insertion twice."); } + /** + * @param string $className + * @param object $entity + * + * @return ORMInvalidArgumentException + */ static public function entityWithoutIdentity($className, $entity) { return new self( @@ -49,11 +70,22 @@ class ORMInvalidArgumentException extends \InvalidArgumentException ); } + /** + * @param object $entity + * + * @return ORMInvalidArgumentException + */ static public function readOnlyRequiresManagedEntity($entity) { return new self("Only managed entities can be marked or checked as read only. But " . self::objToStr($entity) . " is not"); } + /** + * @param array $assoc + * @param object $entry + * + * @return ORMInvalidArgumentException + */ static public function newEntityFoundThroughRelationship(array $assoc, $entry) { return new self("A new entity was found through the relationship '" @@ -68,6 +100,12 @@ class ORMInvalidArgumentException extends \InvalidArgumentException ." implement '" . $assoc['targetEntity'] . "#__toString()' to get a clue.")); } + /** + * @param array $assoc + * @param object $entry + * + * @return ORMInvalidArgumentException + */ static public function detachedEntityFoundThroughRelationship(array $assoc, $entry) { return new self("A detached entity of type " . $assoc['targetEntity'] . " (" . self::objToStr($entry) . ") " @@ -75,37 +113,85 @@ class ORMInvalidArgumentException extends \InvalidArgumentException . "during cascading a persist operation."); } + /** + * @param object $entity + * + * @return ORMInvalidArgumentException + */ static public function entityNotManaged($entity) { return new self("Entity " . self::objToStr($entity) . " is not managed. An entity is managed if its fetched " . "from the database or registered as new through EntityManager#persist"); } + /** + * @param object $entity + * @param string $operation + * + * @return ORMInvalidArgumentException + */ static public function entityHasNoIdentity($entity, $operation) { return new self("Entity has no identity, therefore " . $operation ." cannot be performed. " . self::objToStr($entity)); } + /** + * @param object $entity + * @param string $operation + * + * @return ORMInvalidArgumentException + */ static public function entityIsRemoved($entity, $operation) { return new self("Entity is removed, therefore " . $operation ." cannot be performed. " . self::objToStr($entity)); } + /** + * @param object $entity + * @param string $operation + * + * @return ORMInvalidArgumentException + */ static public function detachedEntityCannot($entity, $operation) { return new self("A detached entity was found during " . $operation . " " . self::objToStr($entity)); } + /** + * @param string $context + * @param mixed $given + * @param int $parameterIndex + * + * @return ORMInvalidArgumentException + */ public static function invalidObject($context, $given, $parameterIndex = 1) { - return new self($context .' expects parameter ' . $parameterIndex . + return new self($context . ' expects parameter ' . $parameterIndex . ' to be an entity object, '. gettype($given) . ' given.'); } + /** + * @return ORMInvalidArgumentException + */ + public static function invalidCompositeIdentifier() + { + return new self("Binding an entity with a composite primary key to a query is not supported. " . + "You should split the parameter into the explicit fields and bind them separately."); + } + + /** + * @return ORMInvalidArgumentException + */ + public static function invalidIdentifierBindingEntity() + { + return new self("Binding entities to query parameters only allowed for entities that have an identifier."); + } + /** * Helper method to show an object as string. * - * @param object $obj + * @param object $obj + * * @return string */ private static function objToStr($obj) diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/OptimisticLockException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/OptimisticLockException.php old mode 100755 new mode 100644 index b425ac39eb..ecd5445b71 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/OptimisticLockException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/OptimisticLockException.php @@ -29,8 +29,15 @@ namespace Doctrine\ORM; */ class OptimisticLockException extends ORMException { + /** + * @var object|null + */ private $entity; + /** + * @param string $msg + * @param object $entity + */ public function __construct($msg, $entity) { parent::__construct($msg); @@ -40,23 +47,42 @@ class OptimisticLockException extends ORMException /** * Gets the entity that caused the exception. * - * @return object + * @return object|null */ public function getEntity() { return $this->entity; } + /** + * @param object $entity + * + * @return OptimisticLockException + */ public static function lockFailed($entity) { return new self("The optimistic lock on an entity failed.", $entity); } - public static function lockFailedVersionMissmatch($entity, $expectedLockVersion, $actualLockVersion) + /** + * @param object $entity + * @param int $expectedLockVersion + * @param int $actualLockVersion + * + * @return OptimisticLockException + */ + public static function lockFailedVersionMismatch($entity, $expectedLockVersion, $actualLockVersion) { + $expectedLockVersion = ($expectedLockVersion instanceof \DateTime) ? $expectedLockVersion->getTimestamp() : $expectedLockVersion; + $actualLockVersion = ($actualLockVersion instanceof \DateTime) ? $actualLockVersion->getTimestamp() : $actualLockVersion; return new self("The optimistic lock failed, version " . $expectedLockVersion . " was expected, but is actually ".$actualLockVersion, $entity); } + /** + * @param string $entityName + * + * @return OptimisticLockException + */ public static function notVersioned($entityName) { return new self("Cannot obtain optimistic lock on unversioned entity " . $entityName, null); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php b/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php old mode 100755 new mode 100644 index ed5d7dfb7b..8d0fef7578 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php @@ -25,7 +25,6 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Selectable; use Doctrine\Common\Collections\Criteria; -use Doctrine\Common\Collections\ExpressionBuilder; use Closure; @@ -87,6 +86,8 @@ final class PersistentCollection implements Collection, Selectable /** * The class descriptor of the collection's entity type. + * + * @var ClassMetadata */ private $typeClass; @@ -115,9 +116,9 @@ final class PersistentCollection implements Collection, Selectable /** * Creates a new persistent collection. * - * @param EntityManager $em The EntityManager the collection will be associated with. + * @param EntityManager $em The EntityManager the collection will be associated with. * @param ClassMetadata $class The class descriptor of the entity type of this collection. - * @param array The collection elements. + * @param array $coll The collection elements. */ public function __construct(EntityManager $em, $class, $coll) { @@ -132,7 +133,9 @@ final class PersistentCollection implements Collection, Selectable * describes the association between the owner and the elements of the collection. * * @param object $entity - * @param AssociationMapping $assoc + * @param array $assoc + * + * @return void */ public function setOwner($entity, array $assoc) { @@ -152,6 +155,9 @@ final class PersistentCollection implements Collection, Selectable return $this->owner; } + /** + * @return Mapping\ClassMetadata + */ public function getTypeClass() { return $this->typeClass; @@ -163,6 +169,8 @@ final class PersistentCollection implements Collection, Selectable * complete bidirectional associations in the case of a one-to-many association. * * @param mixed $element The element to add. + * + * @return void */ public function hydrateAdd($element) { @@ -186,8 +194,10 @@ final class PersistentCollection implements Collection, Selectable * INTERNAL: * Sets a keyed element in the collection during hydration. * - * @param mixed $key The key to set. - * $param mixed $value The element to set. + * @param mixed $key The key to set. + * @param mixed $element The element to set. + * + * @return void */ public function hydrateSet($key, $element) { @@ -206,6 +216,8 @@ final class PersistentCollection implements Collection, Selectable /** * Initializes the collection by loading its contents from the database * if the collection is not yet initialized. + * + * @return void */ public function initialize() { @@ -239,6 +251,8 @@ final class PersistentCollection implements Collection, Selectable /** * INTERNAL: * Tells this collection to take a snapshot of its current state. + * + * @return void */ public function takeSnapshot() { @@ -299,6 +313,8 @@ final class PersistentCollection implements Collection, Selectable /** * Marks this collection as changed/dirty. + * + * @return void */ private function changed() { @@ -332,6 +348,8 @@ final class PersistentCollection implements Collection, Selectable * Sets a boolean flag, indicating whether this collection is dirty. * * @param boolean $dirty Whether the collection should be marked dirty or not. + * + * @return void */ public function setDirty($dirty) { @@ -342,6 +360,8 @@ final class PersistentCollection implements Collection, Selectable * Sets the initialized flag of the collection, forcing it into that state. * * @param boolean $bool + * + * @return void */ public function setInitialized($bool) { @@ -358,7 +378,9 @@ final class PersistentCollection implements Collection, Selectable return $this->initialized; } - /** {@inheritdoc} */ + /** + * {@inheritdoc} + */ public function first() { $this->initialize(); @@ -366,7 +388,9 @@ final class PersistentCollection implements Collection, Selectable return $this->coll->first(); } - /** {@inheritdoc} */ + /** + * {@inheritdoc} + */ public function last() { $this->initialize(); @@ -493,6 +517,18 @@ final class PersistentCollection implements Collection, Selectable */ public function get($key) { + if ( ! $this->initialized + && $this->association['type'] === Mapping\ClassMetadataInfo::ONE_TO_MANY + && $this->association['fetch'] === Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY + && isset($this->association['indexBy']) + ) { + if (!$this->typeClass->isIdentifierComposite && $this->typeClass->isIdentifier($this->association['indexBy'])) { + return $this->em->find($this->typeClass->name, $key); + } + + return $this->em->getUnitOfWork()->getCollectionPersister($this->association)->get($this, $key); + } + $this->initialize(); return $this->coll->get($key); @@ -668,6 +704,8 @@ final class PersistentCollection implements Collection, Selectable * Called by PHP when this collection is serialized. Ensures that only the * elements are properly serialized. * + * @return array + * * @internal Tried to implement Serializable first but that did not work well * with circular references. This solution seems simpler and works well. */ @@ -679,7 +717,7 @@ final class PersistentCollection implements Collection, Selectable /* ArrayAccess implementation */ /** - * @see containsKey() + * {@inheritdoc} */ public function offsetExists($offset) { @@ -687,7 +725,7 @@ final class PersistentCollection implements Collection, Selectable } /** - * @see get() + * {@inheritdoc} */ public function offsetGet($offset) { @@ -695,8 +733,7 @@ final class PersistentCollection implements Collection, Selectable } /** - * @see add() - * @see set() + * {@inheritdoc} */ public function offsetSet($offset, $value) { @@ -708,31 +745,40 @@ final class PersistentCollection implements Collection, Selectable } /** - * @see remove() + * {@inheritdoc} */ public function offsetUnset($offset) { return $this->remove($offset); } + /** + * {@inheritdoc} + */ public function key() { + $this->initialize(); + return $this->coll->key(); } /** - * Gets the element of the collection at the current iterator position. + * {@inheritdoc} */ public function current() { + $this->initialize(); + return $this->coll->current(); } /** - * Moves the internal iterator position to the next element. + * {@inheritdoc} */ public function next() { + $this->initialize(); + return $this->coll->next(); } @@ -747,14 +793,14 @@ final class PersistentCollection implements Collection, Selectable } /** - * Extract a slice of $length elements starting at position $offset from the Collection. + * Extracts a slice of $length elements starting at position $offset from the Collection. * * If $length is null it returns all elements from $offset to the end of the Collection. * Keys have to be preserved by this method. Calling this method will only return the * selected slice and NOT change the elements contained in the collection slice is called on. * - * @param int $offset - * @param int $length + * @param int $offset + * @param int|null $length * * @return array */ @@ -772,7 +818,7 @@ final class PersistentCollection implements Collection, Selectable } /** - * Cleanup internal state of cloned persistent collection. + * Cleans up internal state of cloned persistent collection. * * The following problems have to be prevented: * 1. Added entities are added to old PC @@ -781,6 +827,8 @@ final class PersistentCollection implements Collection, Selectable * 3. Snapshot leads to invalid diffs being generated. * 4. Lazy loading grabs entities from old owner object. * 5. New collection is connected to old owner and leads to duplicate keys. + * + * @return void */ public function __clone() { @@ -797,11 +845,14 @@ final class PersistentCollection implements Collection, Selectable } /** - * Select all elements from a selectable that match the expression and + * Selects all elements from a selectable that match the expression and * return a new collection containing these elements. * * @param \Doctrine\Common\Collections\Criteria $criteria + * * @return Collection + * + * @throws \RuntimeException */ public function matching(Criteria $criteria) { @@ -814,15 +865,11 @@ final class PersistentCollection implements Collection, Selectable } if ($this->association['type'] !== ClassMetadata::ONE_TO_MANY) { - throw new \RuntimeException("Matching Criteria on PersistentCollection only works on OneToMany assocations at the moment."); + throw new \RuntimeException("Matching Criteria on PersistentCollection only works on OneToMany associations at the moment."); } - $id = $this->em - ->getClassMetadata(get_class($this->owner)) - ->getSingleIdReflectionProperty() - ->getValue($this->owner); $builder = Criteria::expr(); - $ownerExpression = $builder->eq($this->backRefFieldName, $id); + $ownerExpression = $builder->eq($this->backRefFieldName, $this->owner); $expression = $criteria->getWhereExpression(); $expression = $expression ? $builder->andX($expression, $ownerExpression) : $ownerExpression; @@ -833,4 +880,3 @@ final class PersistentCollection implements Collection, Selectable return new ArrayCollection($persister->loadCriteria($criteria)); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php old mode 100755 new mode 100644 index 2728918c0d..fdc54aee12 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Persisters; -use Doctrine\ORM\EntityManager, - Doctrine\ORM\PersistentCollection; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\PersistentCollection; /** * Base class for all collection persisters. @@ -33,17 +33,17 @@ abstract class AbstractCollectionPersister /** * @var EntityManager */ - protected $_em; + protected $em; /** * @var \Doctrine\DBAL\Connection */ - protected $_conn; + protected $conn; /** * @var \Doctrine\ORM\UnitOfWork */ - protected $_uow; + protected $uow; /** * The database platform. @@ -66,17 +66,19 @@ abstract class AbstractCollectionPersister */ public function __construct(EntityManager $em) { - $this->_em = $em; - $this->_uow = $em->getUnitOfWork(); - $this->_conn = $em->getConnection(); - $this->platform = $this->_conn->getDatabasePlatform(); + $this->em = $em; + $this->uow = $em->getUnitOfWork(); + $this->conn = $em->getConnection(); + $this->platform = $this->conn->getDatabasePlatform(); $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); } /** * Deletes the persistent state represented by the given collection. * - * @param PersistentCollection $coll + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return void */ public function delete(PersistentCollection $coll) { @@ -86,30 +88,37 @@ abstract class AbstractCollectionPersister return; // ignore inverse side } - $sql = $this->_getDeleteSQL($coll); - $this->_conn->executeUpdate($sql, $this->_getDeleteSQLParameters($coll)); + $sql = $this->getDeleteSQL($coll); + + $this->conn->executeUpdate($sql, $this->getDeleteSQLParameters($coll)); } /** * Gets the SQL statement for deleting the given collection. * - * @param PersistentCollection $coll + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return string */ - abstract protected function _getDeleteSQL(PersistentCollection $coll); + abstract protected function getDeleteSQL(PersistentCollection $coll); /** * Gets the SQL parameters for the corresponding SQL statement to delete * the given collection. * - * @param PersistentCollection $coll + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return array */ - abstract protected function _getDeleteSQLParameters(PersistentCollection $coll); + abstract protected function getDeleteSQLParameters(PersistentCollection $coll); /** - * Updates the given collection, synchronizing it's state with the database + * Updates the given collection, synchronizing its state with the database * by inserting, updating and deleting individual elements. * - * @param PersistentCollection $coll + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return void */ public function update(PersistentCollection $coll) { @@ -120,63 +129,143 @@ abstract class AbstractCollectionPersister } $this->deleteRows($coll); - //$this->updateRows($coll); $this->insertRows($coll); } + /** + * Deletes rows. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return void + */ public function deleteRows(PersistentCollection $coll) { - $deleteDiff = $coll->getDeleteDiff(); - $sql = $this->_getDeleteRowSQL($coll); + $diff = $coll->getDeleteDiff(); + $sql = $this->getDeleteRowSQL($coll); - foreach ($deleteDiff as $element) { - $this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element)); + foreach ($diff as $element) { + $this->conn->executeUpdate($sql, $this->getDeleteRowSQLParameters($coll, $element)); } } - //public function updateRows(PersistentCollection $coll) - //{} - + /** + * Inserts rows. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return void + */ public function insertRows(PersistentCollection $coll) { - $insertDiff = $coll->getInsertDiff(); - $sql = $this->_getInsertRowSQL($coll); + $diff = $coll->getInsertDiff(); + $sql = $this->getInsertRowSQL($coll); - foreach ($insertDiff as $element) { - $this->_conn->executeUpdate($sql, $this->_getInsertRowSQLParameters($coll, $element)); + foreach ($diff as $element) { + $this->conn->executeUpdate($sql, $this->getInsertRowSQLParameters($coll, $element)); } } + /** + * Counts the size of this persistent collection. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return integer + * + * @throws \BadMethodCallException + */ public function count(PersistentCollection $coll) { throw new \BadMethodCallException("Counting the size of this persistent collection is not supported by this CollectionPersister."); } + /** + * Slices elements. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * @param integer $offset + * @param integer $length + * + * @return array + * + * @throws \BadMethodCallException + */ public function slice(PersistentCollection $coll, $offset, $length = null) { throw new \BadMethodCallException("Slicing elements is not supported by this CollectionPersister."); } + /** + * Checks for existence of an element. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * @param object $element + * + * @return boolean + * + * @throws \BadMethodCallException + */ public function contains(PersistentCollection $coll, $element) { - throw new \BadMethodCallException("Checking for existance of an element is not supported by this CollectionPersister."); + throw new \BadMethodCallException("Checking for existence of an element is not supported by this CollectionPersister."); } + /** + * Checks for existence of a key. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * @param mixed $key + * + * @return boolean + * + * @throws \BadMethodCallException + */ public function containsKey(PersistentCollection $coll, $key) { - throw new \BadMethodCallException("Checking for existance of a key is not supported by this CollectionPersister."); + throw new \BadMethodCallException("Checking for existence of a key is not supported by this CollectionPersister."); } + /** + * Removes an element. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * @param object $element + * + * @return mixed + * + * @throws \BadMethodCallException + */ public function removeElement(PersistentCollection $coll, $element) { throw new \BadMethodCallException("Removing an element is not supported by this CollectionPersister."); } + /** + * Removes an element by key. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * @param mixed $key + * + * @return void + * + * @throws \BadMethodCallException + */ public function removeKey(PersistentCollection $coll, $key) { throw new \BadMethodCallException("Removing a key is not supported by this CollectionPersister."); } + /** + * Gets an element by key. + * + * @param \Doctrine\ORM\PersistentCollection $coll + * @param mixed $index + * + * @return mixed + * + * @throws \BadMethodCallException + */ public function get(PersistentCollection $coll, $index) { throw new \BadMethodCallException("Selecting a collection by index is not supported by this CollectionPersister."); @@ -185,39 +274,49 @@ abstract class AbstractCollectionPersister /** * Gets the SQL statement used for deleting a row from the collection. * - * @param PersistentCollection $coll + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return string */ - abstract protected function _getDeleteRowSQL(PersistentCollection $coll); + abstract protected function getDeleteRowSQL(PersistentCollection $coll); /** * Gets the SQL parameters for the corresponding SQL statement to delete the given * element from the given collection. * - * @param PersistentCollection $coll - * @param mixed $element + * @param \Doctrine\ORM\PersistentCollection $coll + * @param mixed $element + * + * @return array */ - abstract protected function _getDeleteRowSQLParameters(PersistentCollection $coll, $element); + abstract protected function getDeleteRowSQLParameters(PersistentCollection $coll, $element); /** * Gets the SQL statement used for updating a row in the collection. * - * @param PersistentCollection $coll + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return string */ - abstract protected function _getUpdateRowSQL(PersistentCollection $coll); + abstract protected function getUpdateRowSQL(PersistentCollection $coll); /** * Gets the SQL statement used for inserting a row in the collection. * - * @param PersistentCollection $coll + * @param \Doctrine\ORM\PersistentCollection $coll + * + * @return string */ - abstract protected function _getInsertRowSQL(PersistentCollection $coll); + abstract protected function getInsertRowSQL(PersistentCollection $coll); /** * Gets the SQL parameters for the corresponding SQL statement to insert the given * element of the given collection into the database. * - * @param PersistentCollection $coll - * @param mixed $element + * @param \Doctrine\ORM\PersistentCollection $coll + * @param mixed $element + * + * @return array */ - abstract protected function _getInsertRowSQLParameters(PersistentCollection $coll, $element); + abstract protected function getInsertRowSQLParameters(PersistentCollection $coll, $element); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php old mode 100755 new mode 100644 index 19e77a4e75..4222495798 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Persisters; -use Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\DBAL\Types\Type; /** * Base class for entity persisters that implement a certain inheritance mapping strategy. @@ -36,14 +36,14 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister /** * {@inheritdoc} */ - protected function _prepareInsertData($entity) + protected function prepareInsertData($entity) { - $data = parent::_prepareInsertData($entity); + $data = parent::prepareInsertData($entity); // Populate the discriminator column - $discColumn = $this->_class->discriminatorColumn; - $this->_columnTypes[$discColumn['name']] = $discColumn['type']; - $data[$this->_getDiscriminatorColumnTableName()][$discColumn['name']] = $this->_class->discriminatorValue; + $discColumn = $this->class->discriminatorColumn; + $this->columnTypes[$discColumn['name']] = $discColumn['type']; + $data[$this->getDiscriminatorColumnTableName()][$discColumn['name']] = $this->class->discriminatorValue; return $data; } @@ -53,30 +53,40 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister * * @return string The table name. */ - abstract protected function _getDiscriminatorColumnTableName(); + abstract protected function getDiscriminatorColumnTableName(); /** * {@inheritdoc} */ - protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') + protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') { - $columnName = $class->columnNames[$field]; - $sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $this->quoteStrategy->getColumnName($field, $class, $this->_platform); + $tableAlias = $alias == 'r' ? '' : $alias; + $columnName = $class->columnNames[$field]; $columnAlias = $this->getSQLColumnAlias($columnName); - $this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name); + $sql = $this->getSQLTableAlias($class->name, $tableAlias) . '.' + . $this->quoteStrategy->getColumnName($field, $class, $this->platform); + + $this->rsm->addFieldResult($alias, $columnAlias, $field, $class->name); if (isset($class->fieldMappings[$field]['requireSQLConversion'])) { - $type = Type::getType($class->getTypeOfField($field)); - $sql = $type->convertToPHPValueSQL($sql, $this->_platform); + $type = Type::getType($class->getTypeOfField($field)); + $sql = $type->convertToPHPValueSQL($sql, $this->platform); } return $sql . ' AS ' . $columnAlias; } + /** + * @param string $tableAlias + * @param string $joinColumnName + * @param string $className + * + * @return string + */ protected function getSelectJoinColumnSQL($tableAlias, $joinColumnName, $className) { $columnAlias = $this->getSQLColumnAlias($joinColumnName); - $this->_rsm->addMetaResult('r', $columnAlias, $joinColumnName); + $this->rsm->addMetaResult('r', $columnAlias, $joinColumnName); return $tableAlias . '.' . $joinColumnName . ' AS ' . $columnAlias; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php old mode 100755 new mode 100644 index 6620fa97bc..00b00cfa2f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -19,8 +19,6 @@ namespace Doctrine\ORM\Persisters; -use PDO; - use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Connection; @@ -33,15 +31,13 @@ use Doctrine\ORM\Query; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Events; -use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\Common\Util\ClassUtils; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Expr\Comparison; /** - * A BasicEntityPersiter maps an entity to a single table in a relational database. + * A BasicEntityPersister maps an entity to a single table in a relational database. * * A persister is always responsible for a single entity type. * @@ -79,6 +75,7 @@ use Doctrine\Common\Collections\Expr\Comparison; * @author Giorgio Sironi * @author Benjamin Eberlei * @author Alexander + * @author Fabio B. Silva * @since 2.0 */ class BasicEntityPersister @@ -87,15 +84,16 @@ class BasicEntityPersister * @var array */ static private $comparisonMap = array( - Comparison::EQ => '= %s', - Comparison::IS => 'IS %s', - Comparison::NEQ => '!= %s', - Comparison::GT => '> %s', - Comparison::GTE => '>= %s', - Comparison::LT => '< %s', - Comparison::LTE => '<= %s', - Comparison::IN => 'IN (%s)', - Comparison::NIN => 'NOT IN (%s)', + Comparison::EQ => '= %s', + Comparison::IS => '= %s', + Comparison::NEQ => '!= %s', + Comparison::GT => '> %s', + Comparison::GTE => '>= %s', + Comparison::LT => '< %s', + Comparison::LTE => '<= %s', + Comparison::IN => 'IN (%s)', + Comparison::NIN => 'NOT IN (%s)', + Comparison::CONTAINS => 'LIKE %s', ); /** @@ -103,35 +101,35 @@ class BasicEntityPersister * * @var \Doctrine\ORM\Mapping\ClassMetadata */ - protected $_class; + protected $class; /** * The underlying DBAL Connection of the used EntityManager. * * @var \Doctrine\DBAL\Connection $conn */ - protected $_conn; + protected $conn; /** * The database platform. * * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ - protected $_platform; + protected $platform; /** * The EntityManager instance. * * @var \Doctrine\ORM\EntityManager */ - protected $_em; + protected $em; /** * Queued inserts. * * @var array */ - protected $_queuedInserts = array(); + protected $queuedInserts = array(); /** * ResultSetMapping that is used for all queries. Is generated lazily once per request. @@ -140,24 +138,26 @@ class BasicEntityPersister * * @var Query\ResultSetMapping */ - protected $_rsm; + protected $rsm; /** * The map of column names to DBAL mapping types of all prepared columns used * when INSERTing or UPDATEing an entity. * * @var array - * @see _prepareInsertData($entity) - * @see _prepareUpdateData($entity) + * + * @see prepareInsertData($entity) + * @see prepareUpdateData($entity) */ - protected $_columnTypes = array(); + protected $columnTypes = array(); /** * The map of quoted column names. * * @var array - * @see _prepareInsertData($entity) - * @see _prepareUpdateData($entity) + * + * @see prepareInsertData($entity) + * @see prepareUpdateData($entity) */ protected $quotedColumns = array(); @@ -167,7 +167,7 @@ class BasicEntityPersister * * @var string */ - private $_insertSql; + private $insertSql; /** * The SELECT column list SQL fragment used for querying entities by this persister. @@ -175,29 +175,29 @@ class BasicEntityPersister * * @var string */ - protected $_selectColumnListSql; + protected $selectColumnListSql; /** - * The JOIN SQL fragement used to eagerly load all many-to-one and one-to-one - * associations configured as FETCH_EAGER, aswell as all inverse one-to-one associations. + * The JOIN SQL fragment used to eagerly load all many-to-one and one-to-one + * associations configured as FETCH_EAGER, as well as all inverse one-to-one associations. * * @var string */ - protected $_selectJoinSql; + protected $selectJoinSql; /** * Counter for creating unique SQL table and column aliases. * * @var integer */ - protected $_sqlAliasCounter = 0; + protected $sqlAliasCounter = 0; /** * Map from class names (FQCN) to the corresponding generated SQL table aliases. * * @var array */ - protected $_sqlTableAliases = array(); + protected $sqlTableAliases = array(); /** * The quote strategy. @@ -210,15 +210,15 @@ class BasicEntityPersister * Initializes a new BasicEntityPersister that uses the given EntityManager * and persists instances of the class described by the given ClassMetadata descriptor. * - * @param \Doctrine\ORM\EntityManager $em + * @param \Doctrine\ORM\EntityManager $em * @param \Doctrine\ORM\Mapping\ClassMetadata $class */ public function __construct(EntityManager $em, ClassMetadata $class) { - $this->_em = $em; - $this->_class = $class; - $this->_conn = $em->getConnection(); - $this->_platform = $this->_conn->getDatabasePlatform(); + $this->em = $em; + $this->class = $class; + $this->conn = $em->getConnection(); + $this->platform = $this->conn->getDatabasePlatform(); $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); } @@ -227,7 +227,7 @@ class BasicEntityPersister */ public function getClassMetadata() { - return $this->_class; + return $this->class; } /** @@ -235,10 +235,12 @@ class BasicEntityPersister * The entity remains queued until {@link executeInserts} is invoked. * * @param object $entity The entity to queue for insertion. + * + * @return void */ public function addInsert($entity) { - $this->_queuedInserts[spl_object_hash($entity)] = $entity; + $this->queuedInserts[spl_object_hash($entity)] = $entity; } /** @@ -252,44 +254,44 @@ class BasicEntityPersister */ public function executeInserts() { - if ( ! $this->_queuedInserts) { - return; + if ( ! $this->queuedInserts) { + return array(); } - $postInsertIds = array(); - $idGen = $this->_class->idGenerator; - $isPostInsertId = $idGen->isPostInsertGenerator(); + $postInsertIds = array(); + $idGenerator = $this->class->idGenerator; + $isPostInsertId = $idGenerator->isPostInsertGenerator(); - $stmt = $this->_conn->prepare($this->_getInsertSQL()); - $tableName = $this->_class->getTableName(); + $stmt = $this->conn->prepare($this->getInsertSQL()); + $tableName = $this->class->getTableName(); - foreach ($this->_queuedInserts as $entity) { - $insertData = $this->_prepareInsertData($entity); + foreach ($this->queuedInserts as $entity) { + $insertData = $this->prepareInsertData($entity); if (isset($insertData[$tableName])) { $paramIndex = 1; foreach ($insertData[$tableName] as $column => $value) { - $stmt->bindValue($paramIndex++, $value, $this->_columnTypes[$column]); + $stmt->bindValue($paramIndex++, $value, $this->columnTypes[$column]); } } $stmt->execute(); if ($isPostInsertId) { - $id = $idGen->generate($this->_em, $entity); + $id = $idGenerator->generate($this->em, $entity); $postInsertIds[$id] = $entity; } else { - $id = $this->_class->getIdentifierValues($entity); + $id = $this->class->getIdentifierValues($entity); } - if ($this->_class->isVersioned) { + if ($this->class->isVersioned) { $this->assignDefaultVersionValue($entity, $id); } } $stmt->closeCursor(); - $this->_queuedInserts = array(); + $this->queuedInserts = array(); return $postInsertIds; } @@ -300,66 +302,76 @@ class BasicEntityPersister * entities version field. * * @param object $entity - * @param mixed $id + * @param mixed $id + * + * @return void */ protected function assignDefaultVersionValue($entity, $id) { - $value = $this->fetchVersionValue($this->_class, $id); - $this->_class->setFieldValue($entity, $this->_class->versionField, $value); + $value = $this->fetchVersionValue($this->class, $id); + + $this->class->setFieldValue($entity, $this->class->versionField, $value); } /** - * Fetch the current version value of a versioned entity. + * Fetches the current version value of a versioned entity. * * @param \Doctrine\ORM\Mapping\ClassMetadata $versionedClass - * @param mixed $id + * @param mixed $id + * * @return mixed */ protected function fetchVersionValue($versionedClass, $id) { - $versionField = $versionedClass->versionField; - $identifier = $this->quoteStrategy->getIdentifierColumnNames($versionedClass, $this->_platform); - - $versionFieldColumnName = $this->quoteStrategy->getColumnName($versionField, $versionedClass, $this->_platform); + $versionField = $versionedClass->versionField; + $tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform); + $identifier = $this->quoteStrategy->getIdentifierColumnNames($versionedClass, $this->platform); + $columnName = $this->quoteStrategy->getColumnName($versionField, $versionedClass, $this->platform); //FIXME: Order with composite keys might not be correct - $sql = 'SELECT ' . $versionFieldColumnName - . ' FROM ' . $this->quoteStrategy->getTableName($versionedClass, $this->_platform) + $sql = 'SELECT ' . $columnName + . ' FROM ' . $tableName . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?'; - $value = $this->_conn->fetchColumn($sql, array_values((array)$id)); - return Type::getType($versionedClass->fieldMappings[$versionField]['type'])->convertToPHPValue($value, $this->_platform); + $value = $this->conn->fetchColumn($sql, array_values((array) $id)); + + return Type::getType($versionedClass->fieldMappings[$versionField]['type'])->convertToPHPValue($value, $this->platform); } /** * Updates a managed entity. The entity is updated according to its current changeset * in the running UnitOfWork. If there is no changeset, nothing is updated. * - * The data to update is retrieved through {@link _prepareUpdateData}. + * The data to update is retrieved through {@link prepareUpdateData}. * Subclasses that override this method are supposed to obtain the update data - * in the same way, through {@link _prepareUpdateData}. + * in the same way, through {@link prepareUpdateData}. * * Subclasses are also supposed to take care of versioning when overriding this method, - * if necessary. The {@link _updateTable} method can be used to apply the data retrieved - * from {@_prepareUpdateData} on the target tables, thereby optionally applying versioning. + * if necessary. The {@link updateTable} method can be used to apply the data retrieved + * from {@prepareUpdateData} on the target tables, thereby optionally applying versioning. * * @param object $entity The entity to update. + * + * @return void */ public function update($entity) { - $updateData = $this->_prepareUpdateData($entity); - $tableName = $this->_class->getTableName(); + $tableName = $this->class->getTableName(); + $updateData = $this->prepareUpdateData($entity); - if (isset($updateData[$tableName]) && $updateData[$tableName]) { - $this->_updateTable( - $entity, $this->quoteStrategy->getTableName($this->_class, $this->_platform), - $updateData[$tableName], $this->_class->isVersioned - ); + if ( ! isset($updateData[$tableName]) || ! ($data = $updateData[$tableName])) { + return; + } - if ($this->_class->isVersioned) { - $id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity); - $this->assignDefaultVersionValue($entity, $id); - } + $isVersioned = $this->class->isVersioned; + $quotedTableName = $this->quoteStrategy->getTableName($this->class, $this->platform); + + $this->updateTable($entity, $quotedTableName, $data, $isVersioned); + + if ($isVersioned) { + $id = $this->em->getUnitOfWork()->getEntityIdentifier($entity); + + $this->assignDefaultVersionValue($entity, $id); } } @@ -367,84 +379,106 @@ class BasicEntityPersister * Performs an UPDATE statement for an entity on a specific table. * The UPDATE can optionally be versioned, which requires the entity to have a version field. * - * @param object $entity The entity object being updated. - * @param string $quotedTableName The quoted name of the table to apply the UPDATE on. - * @param array $updateData The map of columns to update (column => value). - * @param boolean $versioned Whether the UPDATE should be versioned. + * @param object $entity The entity object being updated. + * @param string $quotedTableName The quoted name of the table to apply the UPDATE on. + * @param array $updateData The map of columns to update (column => value). + * @param boolean $versioned Whether the UPDATE should be versioned. + * + * @return void + * + * @throws \Doctrine\ORM\ORMException + * @throws \Doctrine\ORM\OptimisticLockException */ - protected final function _updateTable($entity, $quotedTableName, array $updateData, $versioned = false) + protected final function updateTable($entity, $quotedTableName, array $updateData, $versioned = false) { - $set = $params = $types = array(); + $set = array(); + $types = array(); + $params = array(); foreach ($updateData as $columnName => $value) { - $column = $columnName; $placeholder = '?'; + $column = $columnName; - if (isset($this->_class->fieldNames[$columnName])) { - $column = $this->quoteStrategy->getColumnName($this->_class->fieldNames[$columnName], $this->_class, $this->_platform); + switch (true) { + case isset($this->class->fieldNames[$columnName]): + $fieldName = $this->class->fieldNames[$columnName]; + $column = $this->quoteStrategy->getColumnName($fieldName, $this->class, $this->platform); - if (isset($this->_class->fieldMappings[$this->_class->fieldNames[$columnName]]['requireSQLConversion'])) { - $type = Type::getType($this->_columnTypes[$columnName]); - $placeholder = $type->convertToDatabaseValueSQL('?', $this->_platform); - } - } else if (isset($this->quotedColumns[$columnName])) { - $column = $this->quotedColumns[$columnName]; + if (isset($this->class->fieldMappings[$fieldName]['requireSQLConversion'])) { + $type = Type::getType($this->columnTypes[$columnName]); + $placeholder = $type->convertToDatabaseValueSQL('?', $this->platform); + } + + break; + + case isset($this->quotedColumns[$columnName]): + $column = $this->quotedColumns[$columnName]; + + break; } - - $set[] = $column . ' = ' . $placeholder; - $params[] = $value; - $types[] = $this->_columnTypes[$columnName]; + + $params[] = $value; + $set[] = $column . ' = ' . $placeholder; + $types[] = $this->columnTypes[$columnName]; } - $where = array(); - $id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity); + $where = array(); + $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); - foreach ($this->_class->identifier as $idField) { - if (isset($this->_class->associationMappings[$idField])) { - $targetMapping = $this->_em->getClassMetadata($this->_class->associationMappings[$idField]['targetEntity']); - $where[] = $this->_class->associationMappings[$idField]['joinColumns'][0]['name']; - $params[] = $id[$idField]; + foreach ($this->class->identifier as $idField) { + if ( ! isset($this->class->associationMappings[$idField])) { - switch (true) { - case (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])): - $types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type']; - break; + $params[] = $identifier[$idField]; + $types[] = $this->class->fieldMappings[$idField]['type']; + $where[] = $this->quoteStrategy->getColumnName($idField, $this->class, $this->platform); - case (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])): - $types[] = $targetMapping->associationMappings[$targetMapping->identifier[0]]['type']; - break; - - default: - throw ORMException::unrecognizedField($targetMapping->identifier[0]); - } - } else { - $where[] = $this->quoteStrategy->getColumnName($idField, $this->_class, $this->_platform); - $params[] = $id[$idField]; - $types[] = $this->_class->fieldMappings[$idField]['type']; + continue; } + + $params[] = $identifier[$idField]; + $where[] = $this->class->associationMappings[$idField]['joinColumns'][0]['name']; + $targetMapping = $this->em->getClassMetadata($this->class->associationMappings[$idField]['targetEntity']); + + switch (true) { + case (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])): + $types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type']; + break; + + case (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])): + $types[] = $targetMapping->associationMappings[$targetMapping->identifier[0]]['type']; + break; + + default: + throw ORMException::unrecognizedField($targetMapping->identifier[0]); + } + } if ($versioned) { - $versionField = $this->_class->versionField; - $versionFieldType = $this->_class->fieldMappings[$versionField]['type']; - $versionColumn = $this->quoteStrategy->getColumnName($versionField, $this->_class, $this->_platform); + $versionField = $this->class->versionField; + $versionFieldType = $this->class->fieldMappings[$versionField]['type']; + $versionColumn = $this->quoteStrategy->getColumnName($versionField, $this->class, $this->platform); - if ($versionFieldType == Type::INTEGER) { - $set[] = $versionColumn . ' = ' . $versionColumn . ' + 1'; - } else if ($versionFieldType == Type::DATETIME) { - $set[] = $versionColumn . ' = CURRENT_TIMESTAMP'; + $where[] = $versionColumn; + $types[] = $this->class->fieldMappings[$versionField]['type']; + $params[] = $this->class->reflFields[$versionField]->getValue($entity); + + switch ($versionFieldType) { + case Type::INTEGER: + $set[] = $versionColumn . ' = ' . $versionColumn . ' + 1'; + break; + + case Type::DATETIME: + $set[] = $versionColumn . ' = CURRENT_TIMESTAMP'; + break; } - - $where[] = $versionColumn; - $params[] = $this->_class->reflFields[$versionField]->getValue($entity); - $types[] = $this->_class->fieldMappings[$versionField]['type']; } $sql = 'UPDATE ' . $quotedTableName . ' SET ' . implode(', ', $set) . ' WHERE ' . implode(' = ? AND ', $where) . ' = ?'; - $result = $this->_conn->executeUpdate($sql, $params, $types); + $result = $this->conn->executeUpdate($sql, $params, $types); if ($versioned && ! $result) { throw OptimisticLockException::lockFailed($entity); @@ -453,55 +487,61 @@ class BasicEntityPersister /** * @todo Add check for platform if it supports foreign keys/cascading. + * * @param array $identifier + * * @return void */ protected function deleteJoinTableRecords($identifier) { - foreach ($this->_class->associationMappings as $mapping) { - if ($mapping['type'] == ClassMetadata::MANY_TO_MANY) { - // @Todo this only covers scenarios with no inheritance or of the same level. Is there something - // like self-referential relationship between different levels of an inheritance hierachy? I hope not! - $selfReferential = ($mapping['targetEntity'] == $mapping['sourceEntity']); - $otherKeys = array(); - $keys = array(); + foreach ($this->class->associationMappings as $mapping) { + if ($mapping['type'] !== ClassMetadata::MANY_TO_MANY) { + continue; + } - if ( ! $mapping['isOwningSide']) { - $relatedClass = $this->_em->getClassMetadata($mapping['targetEntity']); - $mapping = $relatedClass->associationMappings[$mapping['mappedBy']]; + // @Todo this only covers scenarios with no inheritance or of the same level. Is there something + // like self-referential relationship between different levels of an inheritance hierarchy? I hope not! + $selfReferential = ($mapping['targetEntity'] == $mapping['sourceEntity']); + $class = $this->class; + $association = $mapping; + $otherColumns = array(); + $otherKeys = array(); + $keys = array(); - foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) { - $keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass, $this->_platform); - } + if ( ! $mapping['isOwningSide']) { + $class = $this->em->getClassMetadata($mapping['targetEntity']); + $association = $class->associationMappings[$mapping['mappedBy']]; + } - if ($selfReferential) { - foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { - $otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass, $this->_platform); - } - } - } else { + $joinColumns = $mapping['isOwningSide'] + ? $association['joinTable']['joinColumns'] + : $association['joinTable']['inverseJoinColumns']; - foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { - $keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform); - } - if ($selfReferential) { - foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) { - $otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform); - } - } - } + if ($selfReferential) { + $otherColumns = (! $mapping['isOwningSide']) + ? $association['joinTable']['joinColumns'] + : $association['joinTable']['inverseJoinColumns']; + } - if ( ! isset($mapping['isOnDeleteCascade'])) { + foreach ($joinColumns as $joinColumn) { + $keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); + } - $joinTableName = $this->quoteStrategy->getJoinTableName($mapping, $this->_class, $this->_platform); + foreach ($otherColumns as $joinColumn) { + $otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); + } - $this->_conn->delete($joinTableName, array_combine($keys, $identifier)); + if (isset($mapping['isOnDeleteCascade'])) { + continue; + } - if ($selfReferential) { - $this->_conn->delete($joinTableName, array_combine($otherKeys, $identifier)); - } - } + $joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->class, $this->platform); + + $this->conn->delete($joinTableName, array_combine($keys, $identifier)); + + if ($selfReferential) { + $this->conn->delete($joinTableName, array_combine($otherKeys, $identifier)); } } } @@ -515,16 +555,40 @@ class BasicEntityPersister * Subclasses may override this method to customize the semantics of entity deletion. * * @param object $entity The entity to delete. + * + * @return void */ public function delete($entity) { - $identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity); + $class = $this->class; + $em = $this->em; + + $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); + $tableName = $this->quoteStrategy->getTableName($class, $this->platform); + $idColumns = $this->quoteStrategy->getIdentifierColumnNames($class, $this->platform); + $id = array_combine($idColumns, $identifier); + $types = array_map(function ($identifier) use ($class, $em) { + + if (isset($class->fieldMappings[$identifier])) { + return $class->fieldMappings[$identifier]['type']; + } + + $targetMapping = $em->getClassMetadata($class->associationMappings[$identifier]['targetEntity']); + + if (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])) { + return $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type']; + } + + if (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])) { + return $targetMapping->associationMappings[$targetMapping->identifier[0]]['type']; + } + + throw ORMException::unrecognizedField($targetMapping->identifier[0]); + + }, $class->identifier); $this->deleteJoinTableRecords($identifier); - - $id = array_combine($this->quoteStrategy->getIdentifierColumnNames($this->_class, $this->_platform), $identifier); - - $this->_conn->delete($this->quoteStrategy->getTableName($this->_class, $this->_platform), $id); + $this->conn->delete($tableName, $id, $types); } /** @@ -545,15 +609,16 @@ class BasicEntityPersister * * * @param object $entity The entity for which to prepare the data. + * * @return array The prepared data. */ - protected function _prepareUpdateData($entity) + protected function prepareUpdateData($entity) { $result = array(); - $uow = $this->_em->getUnitOfWork(); + $uow = $this->em->getUnitOfWork(); - if (($versioned = $this->_class->isVersioned) != false) { - $versionField = $this->_class->versionField; + if (($versioned = $this->class->isVersioned) != false) { + $versionField = $this->class->versionField; } foreach ($uow->getEntityChangeSet($entity) as $field => $change) { @@ -563,56 +628,65 @@ class BasicEntityPersister $newVal = $change[1]; - if (isset($this->_class->associationMappings[$field])) { - $assoc = $this->_class->associationMappings[$field]; + if ( ! isset($this->class->associationMappings[$field])) { - // Only owning side of x-1 associations can have a FK column. - if ( ! $assoc['isOwningSide'] || ! ($assoc['type'] & ClassMetadata::TO_ONE)) { - continue; - } - - if ($newVal !== null) { - $oid = spl_object_hash($newVal); - - if (isset($this->_queuedInserts[$oid]) || $uow->isScheduledForInsert($newVal)) { - // The associated entity $newVal is not yet persisted, so we must - // set $newVal = null, in order to insert a null value and schedule an - // extra update on the UnitOfWork. - $uow->scheduleExtraUpdate($entity, array( - $field => array(null, $newVal) - )); - $newVal = null; - } - } - - if ($newVal !== null) { - $newValId = $uow->getEntityIdentifier($newVal); - } - - $targetClass = $this->_em->getClassMetadata($assoc['targetEntity']); - $owningTable = $this->getOwningTable($field); - - foreach ($assoc['joinColumns'] as $joinColumn) { - $sourceColumn = $joinColumn['name']; - $targetColumn = $joinColumn['referencedColumnName']; - $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform); - - $this->quotedColumns[$sourceColumn] = $quotedColumn; - - if ($newVal === null) { - $result[$owningTable][$sourceColumn] = null; - } else if ($targetClass->containsForeignIdentifier) { - $result[$owningTable][$sourceColumn] = $newValId[$targetClass->getFieldForColumn($targetColumn)]; - } else { - $result[$owningTable][$sourceColumn] = $newValId[$targetClass->fieldNames[$targetColumn]]; - } - - $this->_columnTypes[$sourceColumn] = $targetClass->getTypeOfColumn($targetColumn); - } - } else { - $columnName = $this->_class->columnNames[$field]; - $this->_columnTypes[$columnName] = $this->_class->fieldMappings[$field]['type']; + $columnName = $this->class->columnNames[$field]; + $this->columnTypes[$columnName] = $this->class->fieldMappings[$field]['type']; $result[$this->getOwningTable($field)][$columnName] = $newVal; + + continue; + } + + $assoc = $this->class->associationMappings[$field]; + + // Only owning side of x-1 associations can have a FK column. + if ( ! $assoc['isOwningSide'] || ! ($assoc['type'] & ClassMetadata::TO_ONE)) { + continue; + } + + if ($newVal !== null) { + $oid = spl_object_hash($newVal); + + if (isset($this->queuedInserts[$oid]) || $uow->isScheduledForInsert($newVal)) { + // The associated entity $newVal is not yet persisted, so we must + // set $newVal = null, in order to insert a null value and schedule an + // extra update on the UnitOfWork. + $uow->scheduleExtraUpdate($entity, array($field => array(null, $newVal))); + + $newVal = null; + } + } + + if ($newVal !== null) { + $newValId = $uow->getEntityIdentifier($newVal); + } + + $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + $owningTable = $this->getOwningTable($field); + + foreach ($assoc['joinColumns'] as $joinColumn) { + $sourceColumn = $joinColumn['name']; + $targetColumn = $joinColumn['referencedColumnName']; + $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); + + $this->quotedColumns[$sourceColumn] = $quotedColumn; + $this->columnTypes[$sourceColumn] = $targetClass->getTypeOfColumn($targetColumn); + + switch (true) { + case $newVal === null: + $value = null; + break; + + case $targetClass->containsForeignIdentifier: + $value = $newValId[$targetClass->getFieldForColumn($targetColumn)]; + break; + + default: + $value = $newValId[$targetClass->fieldNames[$targetColumn]]; + break; + } + + $result[$owningTable][$sourceColumn] = $value; } } @@ -626,12 +700,14 @@ class BasicEntityPersister * The default insert data preparation is the same as for updates. * * @param object $entity The entity for which to prepare the data. + * * @return array The prepared data for the tables to update. - * @see _prepareUpdateData + * + * @see prepareUpdateData */ - protected function _prepareInsertData($entity) + protected function prepareInsertData($entity) { - return $this->_prepareUpdateData($entity); + return $this->prepareUpdateData($entity); } /** @@ -642,40 +718,42 @@ class BasicEntityPersister * is always persisted to a single table with a BasicEntityPersister. * * @param string $fieldName The field name. + * * @return string The table name. */ public function getOwningTable($fieldName) { - return $this->_class->getTableName(); + return $this->class->getTableName(); } /** * Loads an entity by a list of field criteria. * - * @param array $criteria The criteria by which to load the entity. - * @param object $entity The entity to load the data into. If not specified, - * a new entity is created. - * @param $assoc The association that connects the entity to load to another entity, if any. - * @param array $hints Hints for entity creation. - * @param int $lockMode - * @param int $limit Limit number of results - * @param array $orderBy Criteria to order by - * @return object The loaded and managed entity instance or NULL if the entity can not be found. + * @param array $criteria The criteria by which to load the entity. + * @param object|null $entity The entity to load the data into. If not specified, a new entity is created. + * @param array|null $assoc The association that connects the entity to load to another entity, if any. + * @param array $hints Hints for entity creation. + * @param int $lockMode + * @param int|null $limit Limit number of results. + * @param array|null $orderBy Criteria to order by. + * + * @return object|null The loaded and managed entity instance or NULL if the entity can not be found. + * * @todo Check identity map? loadById method? Try to guess whether $criteria is the id? */ public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = 0, $limit = null, array $orderBy = null) { - $sql = $this->_getSelectEntitiesSQL($criteria, $assoc, $lockMode, $limit, null, $orderBy); + $sql = $this->getSelectSQL($criteria, $assoc, $lockMode, $limit, null, $orderBy); list($params, $types) = $this->expandParameters($criteria); - $stmt = $this->_conn->executeQuery($sql, $params, $types); + $stmt = $this->conn->executeQuery($sql, $params, $types); if ($entity !== null) { - $hints[Query::HINT_REFRESH] = true; - $hints[Query::HINT_REFRESH_ENTITY] = $entity; + $hints[Query::HINT_REFRESH] = true; + $hints[Query::HINT_REFRESH_ENTITY] = $entity; } - $hydrator = $this->_em->newHydrator($this->_selectJoinSql ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); - $entities = $hydrator->hydrateAll($stmt, $this->_rsm, $hints); + $hydrator = $this->em->newHydrator($this->selectJoinSql ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); + $entities = $hydrator->hydrateAll($stmt, $this->rsm, $hints); return $entities ? $entities[0] : null; } @@ -684,20 +762,23 @@ class BasicEntityPersister * Loads an entity of this persister's mapped class as part of a single-valued * association from another entity. * - * @param array $assoc The association to load. + * @param array $assoc The association to load. * @param object $sourceEntity The entity that owns the association (not necessarily the "owning side"). - * @param array $identifier The identifier of the entity to load. Must be provided if - * the association to load represents the owning side, otherwise - * the identifier is derived from the $sourceEntity. + * @param array $identifier The identifier of the entity to load. Must be provided if + * the association to load represents the owning side, otherwise + * the identifier is derived from the $sourceEntity. + * * @return object The loaded and managed entity instance or NULL if the entity can not be found. + * + * @throws \Doctrine\ORM\Mapping\MappingException */ public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = array()) { - if (($foundEntity = $this->_em->getUnitOfWork()->tryGetById($identifier, $assoc['targetEntity'])) != false) { + if (($foundEntity = $this->em->getUnitOfWork()->tryGetById($identifier, $assoc['targetEntity'])) != false) { return $foundEntity; } - $targetClass = $this->_em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); if ($assoc['isOwningSide']) { $isInverseSingleValued = $assoc['inversedBy'] && ! $targetClass->isCollectionValuedAssociation($assoc['inversedBy']); @@ -711,7 +792,7 @@ class BasicEntityPersister } /* cascade read-only status - if ($this->_em->getUnitOfWork()->isReadOnly($sourceEntity)) { + if ($this->em->getUnitOfWork()->isReadOnly($sourceEntity)) { $hints[Query::HINT_READ_ONLY] = true; } */ @@ -722,31 +803,33 @@ class BasicEntityPersister if ($targetEntity !== null && $isInverseSingleValued) { $targetClass->reflFields[$assoc['inversedBy']]->setValue($targetEntity, $sourceEntity); } - } else { - $sourceClass = $this->_em->getClassMetadata($assoc['sourceEntity']); - $owningAssoc = $targetClass->getAssociationMapping($assoc['mappedBy']); - // TRICKY: since the association is specular source and target are flipped - foreach ($owningAssoc['targetToSourceKeyColumns'] as $sourceKeyColumn => $targetKeyColumn) { - if ( ! isset($sourceClass->fieldNames[$sourceKeyColumn])) { - throw MappingException::joinColumnMustPointToMappedField( - $sourceClass->name, $sourceKeyColumn - ); - } + return $targetEntity; + } - // unset the old value and set the new sql aliased value here. By definition - // unset($identifier[$targetKeyColumn] works here with how UnitOfWork::createEntity() calls this method. - $identifier[$this->_getSQLTableAlias($targetClass->name) . "." . $targetKeyColumn] = - $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); + $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); + $owningAssoc = $targetClass->getAssociationMapping($assoc['mappedBy']); - unset($identifier[$targetKeyColumn]); + // TRICKY: since the association is specular source and target are flipped + foreach ($owningAssoc['targetToSourceKeyColumns'] as $sourceKeyColumn => $targetKeyColumn) { + if ( ! isset($sourceClass->fieldNames[$sourceKeyColumn])) { + throw MappingException::joinColumnMustPointToMappedField( + $sourceClass->name, $sourceKeyColumn + ); } - $targetEntity = $this->load($identifier, null, $assoc); + // unset the old value and set the new sql aliased value here. By definition + // unset($identifier[$targetKeyColumn] works here with how UnitOfWork::createEntity() calls this method. + $identifier[$this->getSQLTableAlias($targetClass->name) . "." . $targetKeyColumn] = + $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); - if ($targetEntity !== null) { - $targetClass->setFieldValue($targetEntity, $assoc['mappedBy'], $sourceEntity); - } + unset($identifier[$targetKeyColumn]); + } + + $targetEntity = $this->load($identifier, null, $assoc); + + if ($targetEntity !== null) { + $targetClass->setFieldValue($targetEntity, $assoc['mappedBy'], $sourceEntity); } return $targetEntity; @@ -755,22 +838,25 @@ class BasicEntityPersister /** * Refreshes a managed entity. * - * @param array $id The identifier of the entity as an associative array from - * column or field names to values. - * @param object $entity The entity to refresh. + * @param array $id The identifier of the entity as an associative array from + * column or field names to values. + * @param object $entity The entity to refresh. + * @param int $lockMode + * + * @return void */ public function refresh(array $id, $entity, $lockMode = 0) { - $sql = $this->_getSelectEntitiesSQL($id, null, $lockMode); + $sql = $this->getSelectSQL($id, null, $lockMode); list($params, $types) = $this->expandParameters($id); - $stmt = $this->_conn->executeQuery($sql, $params, $types); - - $hydrator = $this->_em->newHydrator(Query::HYDRATE_OBJECT); - $hydrator->hydrateAll($stmt, $this->_rsm, array(Query::HINT_REFRESH => true)); + $stmt = $this->conn->executeQuery($sql, $params, $types); + + $hydrator = $this->em->newHydrator(Query::HYDRATE_OBJECT); + $hydrator->hydrateAll($stmt, $this->rsm, array(Query::HINT_REFRESH => true)); } /** - * Load Entities matching the given Criteria object + * Loads Entities matching the given Criteria object. * * @param \Doctrine\Common\Collections\Criteria $criteria * @@ -781,20 +867,18 @@ class BasicEntityPersister $orderBy = $criteria->getOrderings(); $limit = $criteria->getMaxResults(); $offset = $criteria->getFirstResult(); - - $sql = $this->_getSelectEntitiesSQL($criteria, null, 0, $limit, $offset, $orderBy); + $query = $this->getSelectSQL($criteria, null, 0, $limit, $offset, $orderBy); list($params, $types) = $this->expandCriteriaParameters($criteria); - $stmt = $this->_conn->executeQuery($sql, $params, $types); + $stmt = $this->conn->executeQuery($query, $params, $types); + $hydrator = $this->em->newHydrator(($this->selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); - $hydrator = $this->_em->newHydrator(($this->_selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); - - return $hydrator->hydrateAll($stmt, $this->_rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true)); + return $hydrator->hydrateAll($stmt, $this->rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true)); } /** - * Expand Criteria Parameters by walking the expressions and grabbing all + * Expands Criteria Parameters by walking the expressions and grabbing all * parameters and types from it. * * @param \Doctrine\Common\Collections\Criteria $criteria @@ -810,6 +894,7 @@ class BasicEntityPersister } $valueVisitor = new SqlValueVisitor(); + $valueVisitor->dispatch($expression); list($values, $types) = $valueVisitor->getParamsAndTypes(); @@ -831,30 +916,32 @@ class BasicEntityPersister /** * Loads a list of entities by a list of field criteria. * - * @param array $criteria - * @param array $orderBy - * @param int $limit - * @param int $offset + * @param array $criteria + * @param array|null $orderBy + * @param int|null $limit + * @param int|null $offset + * * @return array */ public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null) { - $sql = $this->_getSelectEntitiesSQL($criteria, null, 0, $limit, $offset, $orderBy); + $sql = $this->getSelectSQL($criteria, null, 0, $limit, $offset, $orderBy); list($params, $types) = $this->expandParameters($criteria); - $stmt = $this->_conn->executeQuery($sql, $params, $types); + $stmt = $this->conn->executeQuery($sql, $params, $types); - $hydrator = $this->_em->newHydrator(($this->_selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); + $hydrator = $this->em->newHydrator(($this->selectJoinSql) ? Query::HYDRATE_OBJECT : Query::HYDRATE_SIMPLEOBJECT); - return $hydrator->hydrateAll($stmt, $this->_rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true)); + return $hydrator->hydrateAll($stmt, $this->rsm, array(UnitOfWork::HINT_DEFEREAGERLOAD => true)); } /** - * Get (sliced or full) elements of the given collection. + * Gets (sliced or full) elements of the given collection. * - * @param array $assoc - * @param object $sourceEntity + * @param array $assoc + * @param object $sourceEntity * @param int|null $offset * @param int|null $limit + * * @return array */ public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = null, $limit = null) @@ -865,62 +952,58 @@ class BasicEntityPersister } /** - * Load an array of entities from a given dbal statement. + * Loads an array of entities from a given DBAL statement. * - * @param array $assoc + * @param array $assoc * @param \Doctrine\DBAL\Statement $stmt * * @return array */ private function loadArrayFromStatement($assoc, $stmt) { - $hints = array(UnitOfWork::HINT_DEFEREAGERLOAD => true); + $rsm = $this->rsm; + $hints = array(UnitOfWork::HINT_DEFEREAGERLOAD => true); if (isset($assoc['indexBy'])) { - $rsm = clone ($this->_rsm); // this is necessary because the "default rsm" should be changed. + $rsm = clone ($this->rsm); // this is necessary because the "default rsm" should be changed. $rsm->addIndexBy('r', $assoc['indexBy']); - } else { - $rsm = $this->_rsm; } - $hydrator = $this->_em->newHydrator(Query::HYDRATE_OBJECT); - - return $hydrator->hydrateAll($stmt, $rsm, $hints); + return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); } /** - * Hydrate a collection from a given dbal statement. + * Hydrates a collection from a given DBAL statement. * - * @param array $assoc + * @param array $assoc * @param \Doctrine\DBAL\Statement $stmt - * @param PersistentCollection $coll + * @param PersistentCollection $coll * * @return array */ private function loadCollectionFromStatement($assoc, $stmt, $coll) { - $hints = array(UnitOfWork::HINT_DEFEREAGERLOAD => true, 'collection' => $coll); + $rsm = $this->rsm; + $hints = array( + UnitOfWork::HINT_DEFEREAGERLOAD => true, + 'collection' => $coll + ); if (isset($assoc['indexBy'])) { - $rsm = clone ($this->_rsm); // this is necessary because the "default rsm" should be changed. + $rsm = clone ($this->rsm); // this is necessary because the "default rsm" should be changed. $rsm->addIndexBy('r', $assoc['indexBy']); - } else { - $rsm = $this->_rsm; } - $hydrator = $this->_em->newHydrator(Query::HYDRATE_OBJECT); - - return $hydrator->hydrateAll($stmt, $rsm, $hints); + return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); } /** * Loads a collection of entities of a many-to-many association. * - * @param ManyToManyMapping $assoc The association mapping of the association being loaded. - * @param object $sourceEntity The entity that owns the collection. - * @param PersistentCollection $coll The collection to fill. - * @param int|null $offset - * @param int|null $limit + * @param array $assoc The association mapping of the association being loaded. + * @param object $sourceEntity The entity that owns the collection. + * @param PersistentCollection $coll The collection to fill. + * * @return array */ public function loadManyToManyCollection(array $assoc, $sourceEntity, PersistentCollection $coll) @@ -930,155 +1013,197 @@ class BasicEntityPersister return $this->loadCollectionFromStatement($assoc, $stmt, $coll); } + /** + * @param array $assoc + * @param object $sourceEntity + * @param int|null $offset + * @param int|null $limit + * + * @return \Doctrine\DBAL\Driver\Statement + * + * @throws \Doctrine\ORM\Mapping\MappingException + */ private function getManyToManyStatement(array $assoc, $sourceEntity, $offset = null, $limit = null) { - $criteria = array(); - $sourceClass = $this->_em->getClassMetadata($assoc['sourceEntity']); + $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); + $class = $sourceClass; + $association = $assoc; + $criteria = array(); - if ($assoc['isOwningSide']) { - $quotedJoinTable = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->_platform); - foreach ($assoc['joinTable']['joinColumns'] as $joinColumn) { - $relationKeyColumn = $joinColumn['name']; - $sourceKeyColumn = $joinColumn['referencedColumnName']; - $quotedKeyColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $sourceClass, $this->_platform); - - if ($sourceClass->containsForeignIdentifier) { - $field = $sourceClass->getFieldForColumn($sourceKeyColumn); - $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); - - if (isset($sourceClass->associationMappings[$field])) { - $value = $this->_em->getUnitOfWork()->getEntityIdentifier($value); - $value = $value[$this->_em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]]; - } - - $criteria[$quotedJoinTable . "." . $quotedKeyColumn] = $value; - } else if (isset($sourceClass->fieldNames[$sourceKeyColumn])) { - $criteria[$quotedJoinTable . "." . $quotedKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); - } else { - throw MappingException::joinColumnMustPointToMappedField( - $sourceClass->name, $sourceKeyColumn - ); - } - } - } else { - $owningAssoc = $this->_em->getClassMetadata($assoc['targetEntity'])->associationMappings[$assoc['mappedBy']]; - $quotedJoinTable = $this->quoteStrategy->getJoinTableName($owningAssoc, $sourceClass, $this->_platform); - - // TRICKY: since the association is inverted source and target are flipped - foreach ($owningAssoc['joinTable']['inverseJoinColumns'] as $joinColumn) { - $relationKeyColumn = $joinColumn['name']; - $sourceKeyColumn = $joinColumn['referencedColumnName']; - $quotedKeyColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $sourceClass, $this->_platform); - - if ($sourceClass->containsForeignIdentifier) { - $field = $sourceClass->getFieldForColumn($sourceKeyColumn); - $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); - - if (isset($sourceClass->associationMappings[$field])) { - $value = $this->_em->getUnitOfWork()->getEntityIdentifier($value); - $value = $value[$this->_em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]]; - } - - $criteria[$quotedJoinTable . "." . $quotedKeyColumn] = $value; - } else if (isset($sourceClass->fieldNames[$sourceKeyColumn])) { - $criteria[$quotedJoinTable . "." . $quotedKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); - } else { - throw MappingException::joinColumnMustPointToMappedField( - $sourceClass->name, $sourceKeyColumn - ); - } - } + if ( ! $assoc['isOwningSide']) { + $class = $this->em->getClassMetadata($assoc['targetEntity']); + $association = $class->associationMappings[$assoc['mappedBy']]; } - $sql = $this->_getSelectEntitiesSQL($criteria, $assoc, 0, $limit, $offset); + $joinColumns = $assoc['isOwningSide'] + ? $association['joinTable']['joinColumns'] + : $association['joinTable']['inverseJoinColumns']; + + $quotedJoinTable = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); + + foreach ($joinColumns as $joinColumn) { + + $sourceKeyColumn = $joinColumn['referencedColumnName']; + $quotedKeyColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); + + switch (true) { + case $sourceClass->containsForeignIdentifier: + $field = $sourceClass->getFieldForColumn($sourceKeyColumn); + $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); + + if (isset($sourceClass->associationMappings[$field])) { + $value = $this->em->getUnitOfWork()->getEntityIdentifier($value); + $value = $value[$this->em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]]; + } + + break; + + case isset($sourceClass->fieldNames[$sourceKeyColumn]): + $field = $sourceClass->fieldNames[$sourceKeyColumn]; + $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); + + break; + + default: + throw MappingException::joinColumnMustPointToMappedField( + $sourceClass->name, $sourceKeyColumn + ); + } + + $criteria[$quotedJoinTable . '.' . $quotedKeyColumn] = $value; + } + + $sql = $this->getSelectSQL($criteria, $assoc, 0, $limit, $offset); list($params, $types) = $this->expandParameters($criteria); - return $this->_conn->executeQuery($sql, $params, $types); + return $this->conn->executeQuery($sql, $params, $types); } /** * Gets the SELECT SQL to select one or more entities by a set of field criteria. * * @param array|\Doctrine\Common\Collections\Criteria $criteria - * @param AssociationMapping $assoc - * @param string $orderBy - * @param int $lockMode - * @param int $limit - * @param int $offset - * @param array $orderBy + * @param array|null $assoc + * @param int $lockMode + * @param int|null $limit + * @param int|null $offset + * @param array|null $orderBy + * * @return string - * @todo Refactor: _getSelectSQL(...) */ - protected function _getSelectEntitiesSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null) + protected function getSelectSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null) { - $joinSql = ($assoc != null && $assoc['type'] == ClassMetadata::MANY_TO_MANY) ? $this->_getSelectManyToManyJoinSQL($assoc) : ''; + $lockSql = ''; + $joinSql = ''; + $orderBySql = ''; + + if ($assoc != null && $assoc['type'] == ClassMetadata::MANY_TO_MANY) { + $joinSql = $this->getSelectManyToManyJoinSQL($assoc); + } + + if (isset($assoc['orderBy'])) { + $orderBy = $assoc['orderBy']; + } + + if ($orderBy) { + $orderBySql = $this->getOrderBySQL($orderBy, $this->getSQLTableAlias($this->class->name)); + } + $conditionSql = ($criteria instanceof Criteria) - ? $this->_getSelectConditionCriteriaSQL($criteria) - : $this->_getSelectConditionSQL($criteria, $assoc); + ? $this->getSelectConditionCriteriaSQL($criteria) + : $this->getSelectConditionSQL($criteria, $assoc); - $orderBy = ($assoc !== null && isset($assoc['orderBy'])) ? $assoc['orderBy'] : $orderBy; - $orderBySql = $orderBy ? $this->_getOrderBySQL($orderBy, $this->_getSQLTableAlias($this->_class->name)) : ''; + switch ($lockMode) { + case LockMode::PESSIMISTIC_READ: + $lockSql = ' ' . $this->platform->getReadLockSql(); + break; - $lockSql = ''; - - if ($lockMode == LockMode::PESSIMISTIC_READ) { - $lockSql = ' ' . $this->_platform->getReadLockSql(); - } else if ($lockMode == LockMode::PESSIMISTIC_WRITE) { - $lockSql = ' ' . $this->_platform->getWriteLockSql(); + case LockMode::PESSIMISTIC_WRITE: + $lockSql = ' ' . $this->platform->getWriteLockSql(); + break; } - $alias = $this->_getSQLTableAlias($this->_class->name); + $columnList = $this->getSelectColumnsSQL(); + $tableAlias = $this->getSQLTableAlias($this->class->name); + $filterSql = $this->generateFilterConditionSQL($this->class, $tableAlias); + $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); - if ($filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) { - if ($conditionSql) { - $conditionSql .= ' AND '; - } - - $conditionSql .= $filterSql; + if ('' !== $filterSql) { + $conditionSql = $conditionSql + ? $conditionSql . ' AND ' . $filterSql + : $filterSql; } - return $this->_platform->modifyLimitQuery('SELECT ' . $this->_getSelectColumnListSQL() - . $this->_platform->appendLockHint(' FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' - . $alias, $lockMode) - . $this->_selectJoinSql . $joinSql - . ($conditionSql ? ' WHERE ' . $conditionSql : '') - . $orderBySql, $limit, $offset) - . $lockSql; + $select = 'SELECT ' . $columnList; + $from = ' FROM ' . $tableName . ' '. $tableAlias; + $join = $this->selectJoinSql . $joinSql; + $where = ($conditionSql ? ' WHERE ' . $conditionSql : ''); + $lock = $this->platform->appendLockHint($from, $lockMode); + $query = $select + . $lock + . $join + . $where + . $orderBySql; + + return $this->platform->modifyLimitQuery($query, $limit, $offset) . $lockSql; } /** * Gets the ORDER BY SQL snippet for ordered collections. * - * @param array $orderBy + * @param array $orderBy * @param string $baseTableAlias + * * @return string + * + * @throws \Doctrine\ORM\ORMException */ - protected final function _getOrderBySQL(array $orderBy, $baseTableAlias) + protected final function getOrderBySQL(array $orderBy, $baseTableAlias) { - $orderBySql = ''; + $orderByList = array(); foreach ($orderBy as $fieldName => $orientation) { - if ( ! isset($this->_class->fieldMappings[$fieldName])) { - throw ORMException::unrecognizedField($fieldName); - } $orientation = strtoupper(trim($orientation)); + if ($orientation != 'ASC' && $orientation != 'DESC') { - throw ORMException::invalidOrientation($this->_class->name, $fieldName); + throw ORMException::invalidOrientation($this->class->name, $fieldName); } - $tableAlias = isset($this->_class->fieldMappings[$fieldName]['inherited']) ? - $this->_getSQLTableAlias($this->_class->fieldMappings[$fieldName]['inherited']) + if (isset($this->class->fieldMappings[$fieldName])) { + $tableAlias = isset($this->class->fieldMappings[$fieldName]['inherited']) + ? $this->getSQLTableAlias($this->class->fieldMappings[$fieldName]['inherited']) : $baseTableAlias; - $columnName = $this->quoteStrategy->getColumnName($fieldName, $this->_class, $this->_platform); + $columnName = $this->quoteStrategy->getColumnName($fieldName, $this->class, $this->platform); + $orderByList[] = $tableAlias . '.' . $columnName . ' ' . $orientation; - $orderBySql .= $orderBySql ? ', ' : ' ORDER BY '; - $orderBySql .= $tableAlias . '.' . $columnName . ' ' . $orientation; + continue; + } + + if (isset($this->class->associationMappings[$fieldName])) { + + if ( ! $this->class->associationMappings[$fieldName]['isOwningSide']) { + throw ORMException::invalidFindByInverseAssociation($this->class->name, $fieldName); + } + + $tableAlias = isset($this->class->associationMappings[$fieldName]['inherited']) + ? $this->getSQLTableAlias($this->class->associationMappings[$fieldName]['inherited']) + : $baseTableAlias; + + foreach ($this->class->associationMappings[$fieldName]['joinColumns'] as $joinColumn) { + $columnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); + $orderByList[] = $tableAlias . '.' . $columnName . ' ' . $orientation; + } + + continue; + } + + throw ORMException::unrecognizedField($fieldName); } - return $orderBySql; + return ' ORDER BY ' . implode(', ', $orderByList); } /** @@ -1087,139 +1212,144 @@ class BasicEntityPersister * * Subclasses should override this method to alter or change the select column * list SQL fragment. Note that in the implementation of BasicEntityPersister - * the resulting SQL fragment is generated only once and cached in {@link _selectColumnListSql}. + * the resulting SQL fragment is generated only once and cached in {@link selectColumnListSql}. * Subclasses may or may not do the same. * * @return string The SQL fragment. - * @todo Rename: _getSelectColumnsSQL() */ - protected function _getSelectColumnListSQL() + protected function getSelectColumnsSQL() { - if ($this->_selectColumnListSql !== null) { - return $this->_selectColumnListSql; + if ($this->selectColumnListSql !== null) { + return $this->selectColumnListSql; } - $columnList = ''; - $this->_rsm = new Query\ResultSetMapping(); - $this->_rsm->addEntityResult($this->_class->name, 'r'); // r for root + $columnList = array(); + $this->rsm = new Query\ResultSetMapping(); + $this->rsm->addEntityResult($this->class->name, 'r'); // r for root // Add regular columns to select list - foreach ($this->_class->fieldNames as $field) { - if ($columnList) $columnList .= ', '; - - $columnList .= $this->_getSelectColumnSQL($field, $this->_class); + foreach ($this->class->fieldNames as $field) { + $columnList[] = $this->getSelectColumnSQL($field, $this->class); } - $this->_selectJoinSql = ''; - $eagerAliasCounter = 0; + $this->selectJoinSql = ''; + $eagerAliasCounter = 0; - foreach ($this->_class->associationMappings as $assocField => $assoc) { - $assocColumnSQL = $this->_getSelectColumnAssociationSQL($assocField, $assoc, $this->_class); + foreach ($this->class->associationMappings as $assocField => $assoc) { + $assocColumnSQL = $this->getSelectColumnAssociationSQL($assocField, $assoc, $this->class); if ($assocColumnSQL) { - if ($columnList) $columnList .= ', '; - - $columnList .= $assocColumnSQL; + $columnList[] = $assocColumnSQL; } - if ($assoc['type'] & ClassMetadata::TO_ONE && ($assoc['fetch'] == ClassMetadata::FETCH_EAGER || !$assoc['isOwningSide'])) { - $eagerEntity = $this->_em->getClassMetadata($assoc['targetEntity']); + if ( ! (($assoc['type'] & ClassMetadata::TO_ONE) && ($assoc['fetch'] == ClassMetadata::FETCH_EAGER || !$assoc['isOwningSide']))) { + continue; + } - if ($eagerEntity->inheritanceType != ClassMetadata::INHERITANCE_TYPE_NONE) { - continue; // now this is why you shouldn't use inheritance - } + $eagerEntity = $this->em->getClassMetadata($assoc['targetEntity']); - $assocAlias = 'e' . ($eagerAliasCounter++); - $this->_rsm->addJoinedEntityResult($assoc['targetEntity'], $assocAlias, 'r', $assocField); + if ($eagerEntity->inheritanceType != ClassMetadata::INHERITANCE_TYPE_NONE) { + continue; // now this is why you shouldn't use inheritance + } - foreach ($eagerEntity->fieldNames as $field) { - if ($columnList) $columnList .= ', '; + $assocAlias = 'e' . ($eagerAliasCounter++); + $this->rsm->addJoinedEntityResult($assoc['targetEntity'], $assocAlias, 'r', $assocField); - $columnList .= $this->_getSelectColumnSQL($field, $eagerEntity, $assocAlias); - } + foreach ($eagerEntity->fieldNames as $field) { + $columnList[] = $this->getSelectColumnSQL($field, $eagerEntity, $assocAlias); + } - foreach ($eagerEntity->associationMappings as $assoc2Field => $assoc2) { - $assoc2ColumnSQL = $this->_getSelectColumnAssociationSQL($assoc2Field, $assoc2, $eagerEntity, $assocAlias); + foreach ($eagerEntity->associationMappings as $eagerAssocField => $eagerAssoc) { + $eagerAssocColumnSQL = $this->getSelectColumnAssociationSQL( + $eagerAssocField, $eagerAssoc, $eagerEntity, $assocAlias + ); - if ($assoc2ColumnSQL) { - if ($columnList) $columnList .= ', '; - $columnList .= $assoc2ColumnSQL; - } - } - $first = true; - - if ($assoc['isOwningSide']) { - $this->_selectJoinSql .= ' ' . $this->getJoinSQLForJoinColumns($assoc['joinColumns']); - $this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity, $this->_platform) . ' ' . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) .' ON '; - - $tableAlias = $this->_getSQLTableAlias($assoc['targetEntity'], $assocAlias); - foreach ($assoc['joinColumns'] as $joinColumn) { - $sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform); - $targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class, $this->_platform); - - if ( ! $first) { - $this->_selectJoinSql .= ' AND '; - } - $this->_selectJoinSql .= $this->_getSQLTableAlias($assoc['sourceEntity']) . '.' . $sourceCol . ' = ' - . $tableAlias . '.' . $targetCol; - $first = false; - } - - // Add filter SQL - if ($filterSql = $this->generateFilterConditionSQL($eagerEntity, $tableAlias)) { - $this->_selectJoinSql .= ' AND ' . $filterSql; - } - } else { - $eagerEntity = $this->_em->getClassMetadata($assoc['targetEntity']); - $owningAssoc = $eagerEntity->getAssociationMapping($assoc['mappedBy']); - - $this->_selectJoinSql .= ' LEFT JOIN'; - $this->_selectJoinSql .= ' ' . $this->quoteStrategy->getTableName($eagerEntity, $this->_platform) . ' ' - . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) . ' ON '; - - foreach ($owningAssoc['sourceToTargetKeyColumns'] as $sourceCol => $targetCol) { - if ( ! $first) { - $this->_selectJoinSql .= ' AND '; - } - - $this->_selectJoinSql .= $this->_getSQLTableAlias($owningAssoc['sourceEntity'], $assocAlias) . '.' . $sourceCol . ' = ' - . $this->_getSQLTableAlias($owningAssoc['targetEntity']) . '.' . $targetCol; - $first = false; - } + if ($eagerAssocColumnSQL) { + $columnList[] = $eagerAssocColumnSQL; } } + + $association = $assoc; + $joinCondition = array(); + + if ( ! $assoc['isOwningSide']) { + $eagerEntity = $this->em->getClassMetadata($assoc['targetEntity']); + $association = $eagerEntity->getAssociationMapping($assoc['mappedBy']); + } + + $joinTableAlias = $this->getSQLTableAlias($eagerEntity->name, $assocAlias); + $joinTableName = $this->quoteStrategy->getTableName($eagerEntity, $this->platform); + + if ($assoc['isOwningSide']) { + $tableAlias = $this->getSQLTableAlias($association['targetEntity'], $assocAlias); + $this->selectJoinSql .= ' ' . $this->getJoinSQLForJoinColumns($association['joinColumns']); + + foreach ($association['joinColumns'] as $joinColumn) { + $sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); + $targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->class, $this->platform); + $joinCondition[] = $this->getSQLTableAlias($association['sourceEntity']) + . '.' . $sourceCol . ' = ' . $tableAlias . '.' . $targetCol; + } + + // Add filter SQL + if ($filterSql = $this->generateFilterConditionSQL($eagerEntity, $tableAlias)) { + $joinCondition[] = $filterSql; + } + + } else { + + $this->selectJoinSql .= ' LEFT JOIN'; + + foreach ($association['joinColumns'] as $joinColumn) { + $sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); + $targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->class, $this->platform); + + $joinCondition[] = $this->getSQLTableAlias($association['sourceEntity'], $assocAlias) . '.' . $sourceCol . ' = ' + . $this->getSQLTableAlias($association['targetEntity']) . '.' . $targetCol; + } + } + + $this->selectJoinSql .= ' ' . $joinTableName . ' ' . $joinTableAlias . ' ON '; + $this->selectJoinSql .= implode(' AND ', $joinCondition); } - $this->_selectColumnListSql = $columnList; + $this->selectColumnListSql = implode(', ', $columnList); - return $this->_selectColumnListSql; + return $this->selectColumnListSql; } /** * Gets the SQL join fragment used when selecting entities from an association. * - * @param string $field - * @param array $assoc + * @param string $field + * @param array $assoc * @param ClassMetadata $class - * @param string $alias + * @param string $alias * * @return string */ - protected function _getSelectColumnAssociationSQL($field, $assoc, ClassMetadata $class, $alias = 'r') + protected function getSelectColumnAssociationSQL($field, $assoc, ClassMetadata $class, $alias = 'r') { - $columnList = array(); + if ( ! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) ) { + return ''; + } - if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { + $columnList = array(); + $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc['joinColumns'] as $joinColumn) { + $type = null; + $isIdentifier = isset($assoc['id']) && $assoc['id'] === true; + $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); + $resultColumnName = $this->getSQLColumnAlias($joinColumn['name']); + $columnList[] = $this->getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias) ) + . '.' . $quotedColumn . ' AS ' . $resultColumnName; - $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform); - $resultColumnName = $this->getSQLColumnAlias($joinColumn['name']); - $columnList[] = $this->_getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias) ) - . '.' . $quotedColumn . ' AS ' . $resultColumnName; - - $this->_rsm->addMetaResult($alias, $resultColumnName, $quotedColumn, isset($assoc['id']) && $assoc['id'] === true); + if (isset($targetClass->fieldNames[$joinColumn['referencedColumnName']])) { + $type = $targetClass->fieldMappings[$targetClass->fieldNames[$joinColumn['referencedColumnName']]]['type']; } + + $this->rsm->addMetaResult($alias, $resultColumnName, $quotedColumn, $isIdentifier, $type); } return implode(', ', $columnList); @@ -1229,28 +1359,29 @@ class BasicEntityPersister * Gets the SQL join fragment used when selecting entities from a * many-to-many association. * - * @param ManyToManyMapping $manyToMany + * @param array $manyToMany + * * @return string */ - protected function _getSelectManyToManyJoinSQL(array $manyToMany) + protected function getSelectManyToManyJoinSQL(array $manyToMany) { $conditions = array(); $association = $manyToMany; - $sourceTableAlias = $this->_getSQLTableAlias($this->_class->name); + $sourceTableAlias = $this->getSQLTableAlias($this->class->name); if ( ! $manyToMany['isOwningSide']) { - $targetEntity = $this->_em->getClassMetadata($manyToMany['targetEntity']); + $targetEntity = $this->em->getClassMetadata($manyToMany['targetEntity']); $association = $targetEntity->associationMappings[$manyToMany['mappedBy']]; } - $joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->_class, $this->_platform); + $joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->class, $this->platform); $joinColumns = ($manyToMany['isOwningSide']) ? $association['joinTable']['inverseJoinColumns'] : $association['joinTable']['joinColumns']; foreach ($joinColumns as $joinColumn) { - $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform); - $quotedTargetColumn = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class, $this->_platform); + $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); + $quotedTargetColumn = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->class, $this->platform); $conditions[] = $sourceTableAlias . '.' . $quotedTargetColumn . ' = ' . $joinTableName . '.' . $quotedSourceColumn; } @@ -1262,42 +1393,45 @@ class BasicEntityPersister * * @return string */ - protected function _getInsertSQL() + protected function getInsertSQL() { - if ($this->_insertSql === null) { - $insertSql = ''; - $columns = $this->_getInsertColumnList(); - - if (empty($columns)) { - $insertSql = $this->_platform->getEmptyIdentityInsertSQL( - $this->quoteStrategy->getTableName($this->_class, $this->_platform), - $this->quoteStrategy->getColumnName($this->_class->identifier[0], $this->_class, $this->_platform) - ); - } else { - $columns = array_unique($columns); - - $values = array(); - foreach ($columns as $column) { - $placeholder = '?'; - - if (isset($this->_class->fieldNames[$column]) && - isset($this->_columnTypes[$this->_class->fieldNames[$column]]) && - isset($this->_class->fieldMappings[$this->_class->fieldNames[$column]]['requireSQLConversion'])) { - $type = Type::getType($this->_columnTypes[$this->_class->fieldNames[$column]]); - $placeholder = $type->convertToDatabaseValueSQL('?', $this->_platform); - } - - $values[] = $placeholder; - } - - $insertSql = 'INSERT INTO ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) - . ' (' . implode(', ', $columns) . ') VALUES (' . implode(', ', $values) . ')'; - } - - $this->_insertSql = $insertSql; + if ($this->insertSql !== null) { + return $this->insertSql; } - return $this->_insertSql; + $columns = $this->getInsertColumnList(); + $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); + + if (empty($columns)) { + $identityColumn = $this->quoteStrategy->getColumnName($this->class->identifier[0], $this->class, $this->platform); + $this->insertSql = $this->platform->getEmptyIdentityInsertSQL($tableName, $identityColumn); + + return $this->insertSql; + } + + $values = array(); + $columns = array_unique($columns); + + foreach ($columns as $column) { + $placeholder = '?'; + + if (isset($this->class->fieldNames[$column]) + && isset($this->columnTypes[$this->class->fieldNames[$column]]) + && isset($this->class->fieldMappings[$this->class->fieldNames[$column]]['requireSQLConversion'])) { + + $type = Type::getType($this->columnTypes[$this->class->fieldNames[$column]]); + $placeholder = $type->convertToDatabaseValueSQL('?', $this->platform); + } + + $values[] = $placeholder; + } + + $columns = implode(', ', $columns); + $values = implode(', ', $values); + + $this->insertSql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $tableName, $columns, $values); + + return $this->insertSql; } /** @@ -1308,25 +1442,29 @@ class BasicEntityPersister * * @return array The list of columns. */ - protected function _getInsertColumnList() + protected function getInsertColumnList() { $columns = array(); - foreach ($this->_class->reflFields as $name => $field) { - if ($this->_class->isVersioned && $this->_class->versionField == $name) { + foreach ($this->class->reflFields as $name => $field) { + if ($this->class->isVersioned && $this->class->versionField == $name) { continue; } - if (isset($this->_class->associationMappings[$name])) { - $assoc = $this->_class->associationMappings[$name]; + if (isset($this->class->associationMappings[$name])) { + $assoc = $this->class->associationMappings[$name]; if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { foreach ($assoc['joinColumns'] as $joinColumn) { - $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform); + $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); } } - } else if ($this->_class->generatorType != ClassMetadata::GENERATOR_TYPE_IDENTITY || $this->_class->identifier[0] != $name) { - $columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform); - $this->_columnTypes[$name] = $this->_class->fieldMappings[$name]['type']; + + continue; + } + + if ($this->class->generatorType != ClassMetadata::GENERATOR_TYPE_IDENTITY || $this->class->identifier[0] != $name) { + $columns[] = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform); + $this->columnTypes[$name] = $this->class->fieldMappings[$name]['type']; } } @@ -1336,22 +1474,26 @@ class BasicEntityPersister /** * Gets the SQL snippet of a qualified column name for the given field name. * - * @param string $field The field name. + * @param string $field The field name. * @param ClassMetadata $class The class that declares this field. The table this class is * mapped to must own the column for the given field. - * @param string $alias + * @param string $alias + * + * @return string */ - protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') + protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') { - $sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) - . '.' . $this->quoteStrategy->getColumnName($field, $class, $this->_platform); - $columnAlias = $this->getSQLColumnAlias($class->columnNames[$field]); - - $this->_rsm->addFieldResult($alias, $columnAlias, $field); + $root = $alias == 'r' ? '' : $alias ; + $tableAlias = $this->getSQLTableAlias($class->name, $root); + $columnName = $this->quoteStrategy->getColumnName($field, $class, $this->platform); + $sql = $tableAlias . '.' . $columnName; + $columnAlias = $this->getSQLColumnAlias($class->columnNames[$field]); + + $this->rsm->addFieldResult($alias, $columnAlias, $field); if (isset($class->fieldMappings[$field]['requireSQLConversion'])) { - $type = Type::getType($class->getTypeOfField($field)); - $sql = $type->convertToPHPValueSQL($sql, $this->_platform); + $type = Type::getType($class->getTypeOfField($field)); + $sql = $type->convertToPHPValueSQL($sql, $this->platform); } return $sql . ' AS ' . $columnAlias; @@ -1361,70 +1503,85 @@ class BasicEntityPersister * Gets the SQL table alias for the given class name. * * @param string $className + * @param string $assocName + * * @return string The SQL table alias. + * * @todo Reconsider. Binding table aliases to class names is not such a good idea. */ - protected function _getSQLTableAlias($className, $assocName = '') + protected function getSQLTableAlias($className, $assocName = '') { if ($assocName) { $className .= '#' . $assocName; } - if (isset($this->_sqlTableAliases[$className])) { - return $this->_sqlTableAliases[$className]; + if (isset($this->sqlTableAliases[$className])) { + return $this->sqlTableAliases[$className]; } - $tableAlias = 't' . $this->_sqlAliasCounter++; + $tableAlias = 't' . $this->sqlAliasCounter++; - $this->_sqlTableAliases[$className] = $tableAlias; + $this->sqlTableAliases[$className] = $tableAlias; return $tableAlias; } /** - * Lock all rows of this entity matching the given criteria with the specified pessimistic lock mode + * Locks all rows of this entity matching the given criteria with the specified pessimistic lock mode. * * @param array $criteria - * @param int $lockMode + * @param int $lockMode + * * @return void */ public function lock(array $criteria, $lockMode) { - $conditionSql = $this->_getSelectConditionSQL($criteria); + $lockSql = ''; + $conditionSql = $this->getSelectConditionSQL($criteria); - if ($lockMode == LockMode::PESSIMISTIC_READ) { - $lockSql = $this->_platform->getReadLockSql(); - } else if ($lockMode == LockMode::PESSIMISTIC_WRITE) { - $lockSql = $this->_platform->getWriteLockSql(); + switch ($lockMode) { + case LockMode::PESSIMISTIC_READ: + $lockSql = $this->platform->getReadLockSql(); + + break; + case LockMode::PESSIMISTIC_WRITE: + + $lockSql = $this->platform->getWriteLockSql(); + break; } + $lock = $this->platform->appendLockHint($this->getLockTablesSql(), $lockMode); + $where = ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' '; $sql = 'SELECT 1 ' - . $this->_platform->appendLockHint($this->getLockTablesSql(), $lockMode) - . ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' ' . $lockSql; + . $lock + . $where + . $lockSql; list($params, $types) = $this->expandParameters($criteria); - $this->_conn->executeQuery($sql, $params, $types); + $this->conn->executeQuery($sql, $params, $types); } /** - * Get the FROM and optionally JOIN conditions to lock the entity managed by this persister. + * Gets the FROM and optionally JOIN conditions to lock the entity managed by this persister. * * @return string */ protected function getLockTablesSql() { - return 'FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' - . $this->_getSQLTableAlias($this->_class->name); + return 'FROM ' + . $this->quoteStrategy->getTableName($this->class, $this->platform) . ' ' + . $this->getSQLTableAlias($this->class->name); } /** - * Get the Select Where Condition from a Criteria object. + * Gets the Select Where Condition from a Criteria object. * * @param \Doctrine\Common\Collections\Criteria $criteria + * * @return string */ - protected function _getSelectConditionCriteriaSQL(Criteria $criteria) + protected function getSelectConditionCriteriaSQL(Criteria $criteria) { $expression = $criteria->getWhereExpression(); @@ -1432,74 +1589,93 @@ class BasicEntityPersister return ''; } - $visitor = new SqlExpressionVisitor($this); + $visitor = new SqlExpressionVisitor($this, $this->class); return $visitor->dispatch($expression); } /** - * Get the SQL WHERE condition for matching a field with a given value. + * Gets the SQL WHERE condition for matching a field with a given value. * - * @param string $field - * @param mixed $value - * @param array|null $assoc - * @param string $comparison + * @param string $field + * @param mixed $value + * @param array|null $assoc + * @param string|null $comparison * * @return string */ public function getSelectConditionStatementSQL($field, $value, $assoc = null, $comparison = null) { - $conditionSql = $this->getSelectConditionStatementColumnSQL($field, $assoc); $placeholder = '?'; + $condition = $this->getSelectConditionStatementColumnSQL($field, $assoc); - if (isset($this->_class->fieldMappings[$field]['requireSQLConversion'])) { - $type = Type::getType($this->_class->getTypeOfField($field)); - $placeholder = $type->convertToDatabaseValueSQL($placeholder, $this->_platform); + if (isset($this->class->fieldMappings[$field]['requireSQLConversion'])) { + $placeholder = Type::getType($this->class->getTypeOfField($field))->convertToDatabaseValueSQL($placeholder, $this->platform); } - $conditionSql .= ($comparison === null) - ? ((is_array($value)) ? ' IN (?)' : (($value === null) ? ' IS NULL' : ' = ' . $placeholder)) - : ' ' . sprintf(self::$comparisonMap[$comparison], $placeholder); + if ($comparison !== null) { + // special case null value handling + if (($comparison === Comparison::EQ || $comparison === Comparison::IS) && $value === null) { + return $condition . ' IS NULL'; + } else if ($comparison === Comparison::NEQ && $value === null) { + return $condition . ' IS NOT NULL'; + } - return $conditionSql; + return $condition . ' ' . sprintf(self::$comparisonMap[$comparison], $placeholder); + } + + if (is_array($value)) { + return sprintf('%s IN (%s)' , $condition, $placeholder); + } + + if ($value === null) { + return sprintf('%s IS NULL' , $condition); + } + + return sprintf('%s = %s' , $condition, $placeholder); } /** - * Build the left-hand-side of a where condition statement. + * Builds the left-hand-side of a where condition statement. * - * @param string $field - * @param array $assoc + * @param string $field + * @param array|null $assoc * * @return string + * + * @throws \Doctrine\ORM\ORMException */ protected function getSelectConditionStatementColumnSQL($field, $assoc = null) { - switch (true) { - case (isset($this->_class->columnNames[$field])): - $className = (isset($this->_class->fieldMappings[$field]['inherited'])) - ? $this->_class->fieldMappings[$field]['inherited'] - : $this->_class->name; + if (isset($this->class->columnNames[$field])) { + $className = (isset($this->class->fieldMappings[$field]['inherited'])) + ? $this->class->fieldMappings[$field]['inherited'] + : $this->class->name; - return $this->_getSQLTableAlias($className) . '.' . $this->quoteStrategy->getColumnName($field, $this->_class, $this->_platform); + return $this->getSQLTableAlias($className) . '.' . $this->quoteStrategy->getColumnName($field, $this->class, $this->platform); + } - case (isset($this->_class->associationMappings[$field])): - if ( ! $this->_class->associationMappings[$field]['isOwningSide']) { - throw ORMException::invalidFindByInverseAssociation($this->_class->name, $field); - } + if (isset($this->class->associationMappings[$field])) { - $className = (isset($this->_class->associationMappings[$field]['inherited'])) - ? $this->_class->associationMappings[$field]['inherited'] - : $this->_class->name; + if ( ! $this->class->associationMappings[$field]['isOwningSide']) { + throw ORMException::invalidFindByInverseAssociation($this->class->name, $field); + } - return $this->_getSQLTableAlias($className) . '.' . $this->_class->associationMappings[$field]['joinColumns'][0]['name']; + $joinColumn = $this->class->associationMappings[$field]['joinColumns'][0]; + $className = (isset($this->class->associationMappings[$field]['inherited'])) + ? $this->class->associationMappings[$field]['inherited'] + : $this->class->name; - case ($assoc !== null && strpos($field, " ") === false && strpos($field, "(") === false): - // very careless developers could potentially open up this normally hidden api for userland attacks, - // therefore checking for spaces and function calls which are not allowed. + return $this->getSQLTableAlias($className) . '.' . $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); + } - // found a join column condition, not really a "field" - return $field; + if ($assoc !== null && strpos($field, " ") === false && strpos($field, "(") === false) { + // very careless developers could potentially open up this normally hidden api for userland attacks, + // therefore checking for spaces and function calls which are not allowed. + + // found a join column condition, not really a "field" + return $field; } throw ORMException::unrecognizedField($field); @@ -1512,29 +1688,30 @@ class BasicEntityPersister * Subclasses are supposed to override this method if they intend to change * or alter the criteria by which entities are selected. * - * @param array $criteria - * @param AssociationMapping $assoc + * @param array $criteria + * @param array|null $assoc + * * @return string */ - protected function _getSelectConditionSQL(array $criteria, $assoc = null) + protected function getSelectConditionSQL(array $criteria, $assoc = null) { - $conditionSql = ''; + $conditions = array(); foreach ($criteria as $field => $value) { - $conditionSql .= $conditionSql ? ' AND ' : ''; - $conditionSql .= $this->getSelectConditionStatementSQL($field, $value, $assoc); + $conditions[] = $this->getSelectConditionStatementSQL($field, $value, $assoc); } - return $conditionSql; + return implode(' AND ', $conditions); } /** - * Return an array with (sliced or full list) of elements in the specified collection. + * Returns an array with (sliced or full list) of elements in the specified collection. + * + * @param array $assoc + * @param object $sourceEntity + * @param int|null $offset + * @param int|null $limit * - * @param array $assoc - * @param object $sourceEntity - * @param int $offset - * @param int $limit * @return array */ public function getOneToManyCollection(array $assoc, $sourceEntity, $offset = null, $limit = null) @@ -1547,11 +1724,11 @@ class BasicEntityPersister /** * Loads a collection of entities in a one-to-many association. * - * @param array $assoc - * @param object $sourceEntity - * @param PersistentCollection $coll The collection to load/fill. - * @param int|null $offset - * @param int|null $limit + * @param array $assoc + * @param object $sourceEntity + * @param PersistentCollection $coll The collection to load/fill. + * + * @return array */ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentCollection $coll) { @@ -1561,21 +1738,22 @@ class BasicEntityPersister } /** - * Build criteria and execute SQL statement to fetch the one to many entities from. + * Builds criteria and execute SQL statement to fetch the one to many entities from. * - * @param array $assoc - * @param object $sourceEntity + * @param array $assoc + * @param object $sourceEntity * @param int|null $offset * @param int|null $limit + * * @return \Doctrine\DBAL\Statement */ private function getOneToManyStatement(array $assoc, $sourceEntity, $offset = null, $limit = null) { $criteria = array(); - $owningAssoc = $this->_class->associationMappings[$assoc['mappedBy']]; - $sourceClass = $this->_em->getClassMetadata($assoc['sourceEntity']); + $owningAssoc = $this->class->associationMappings[$assoc['mappedBy']]; + $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); - $tableAlias = $this->_getSQLTableAlias(isset($owningAssoc['inherited']) ? $owningAssoc['inherited'] : $this->_class->name); + $tableAlias = $this->getSQLTableAlias(isset($owningAssoc['inherited']) ? $owningAssoc['inherited'] : $this->class->name); foreach ($owningAssoc['targetToSourceKeyColumns'] as $sourceKeyColumn => $targetKeyColumn) { if ($sourceClass->containsForeignIdentifier) { @@ -1583,31 +1761,35 @@ class BasicEntityPersister $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); if (isset($sourceClass->associationMappings[$field])) { - $value = $this->_em->getUnitOfWork()->getEntityIdentifier($value); - $value = $value[$this->_em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]]; + $value = $this->em->getUnitOfWork()->getEntityIdentifier($value); + $value = $value[$this->em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]]; } $criteria[$tableAlias . "." . $targetKeyColumn] = $value; - } else { - $criteria[$tableAlias . "." . $targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); + + continue; } + + $criteria[$tableAlias . "." . $targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); } - $sql = $this->_getSelectEntitiesSQL($criteria, $assoc, 0, $limit, $offset); + $sql = $this->getSelectSQL($criteria, $assoc, 0, $limit, $offset); list($params, $types) = $this->expandParameters($criteria); - return $this->_conn->executeQuery($sql, $params, $types); + return $this->conn->executeQuery($sql, $params, $types); } /** - * Expand the parameters from the given criteria and use the correct binding types if found. + * Expands the parameters from the given criteria and use the correct binding types if found. + * + * @param array $criteria * - * @param array $criteria * @return array */ private function expandParameters($criteria) { - $params = $types = array(); + $params = array(); + $types = array(); foreach ($criteria as $field => $value) { if ($value === null) { @@ -1622,27 +1804,30 @@ class BasicEntityPersister } /** - * Infer field type to be used by parameter type casting. + * Infers field type to be used by parameter type casting. * * @param string $field - * @param mixed $value + * @param mixed $value + * * @return integer + * + * @throws \Doctrine\ORM\Query\QueryException */ private function getType($field, $value) { switch (true) { - case (isset($this->_class->fieldMappings[$field])): - $type = $this->_class->fieldMappings[$field]['type']; + case (isset($this->class->fieldMappings[$field])): + $type = $this->class->fieldMappings[$field]['type']; break; - case (isset($this->_class->associationMappings[$field])): - $assoc = $this->_class->associationMappings[$field]; + case (isset($this->class->associationMappings[$field])): + $assoc = $this->class->associationMappings[$field]; if (count($assoc['sourceToTargetKeyColumns']) > 1) { throw Query\QueryException::associationPathCompositeKeyNotSupported(); } - $targetClass = $this->_em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); $targetColumn = $assoc['joinColumns'][0]['referencedColumnName']; $type = null; @@ -1655,8 +1840,9 @@ class BasicEntityPersister default: $type = null; } + if (is_array($value)) { - $type = Type::getType( $type )->getBindingType(); + $type = Type::getType($type)->getBindingType(); $type += Connection::ARRAY_PARAM_OFFSET; } @@ -1664,61 +1850,54 @@ class BasicEntityPersister } /** - * Retrieve parameter value + * Retrieves parameter value. * * @param mixed $value + * * @return mixed */ private function getValue($value) { - if (is_array($value)) { - $newValue = array(); - - foreach ($value as $itemValue) { - $newValue[] = $this->getIndividualValue($itemValue); - } - - return $newValue; + if ( ! is_array($value)) { + return $this->getIndividualValue($value); } - return $this->getIndividualValue($value); + $newValue = array(); + + foreach ($value as $itemValue) { + $newValue[] = $this->getIndividualValue($itemValue); + } + + return $newValue; } /** - * Retrieve an invidiual parameter value + * Retrieves an individual parameter value. * * @param mixed $value + * * @return mixed */ private function getIndividualValue($value) { - if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) { - if ($this->_em->getUnitOfWork()->getEntityState($value) === UnitOfWork::STATE_MANAGED) { - $idValues = $this->_em->getUnitOfWork()->getEntityIdentifier($value); - } else { - $class = $this->_em->getClassMetadata(get_class($value)); - $idValues = $class->getIdentifierValues($value); - } - - $key = key($idValues); - - if (null !== $key){ - $value = $idValues[$key]; - } + if ( ! is_object($value) || ! $this->em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) { + return $value; } - return $value; + return $this->em->getUnitOfWork()->getSingleIdentifierValue($value); } /** * Checks whether the given managed entity exists in the database. * * @param object $entity + * @param array $extraConditions + * * @return boolean TRUE if the entity exists in the database, FALSE otherwise. */ public function exists($entity, array $extraConditions = array()) { - $criteria = $this->_class->getIdentifierValues($entity); + $criteria = $this->class->getIdentifierValues($entity); if ( ! $criteria) { return false; @@ -1728,25 +1907,26 @@ class BasicEntityPersister $criteria = array_merge($criteria, $extraConditions); } - $alias = $this->_getSQLTableAlias($this->_class->name); + $alias = $this->getSQLTableAlias($this->class->name); $sql = 'SELECT 1 ' . $this->getLockTablesSql() - . ' WHERE ' . $this->_getSelectConditionSQL($criteria); + . ' WHERE ' . $this->getSelectConditionSQL($criteria); - if ($filterSql = $this->generateFilterConditionSQL($this->_class, $alias)) { + if ($filterSql = $this->generateFilterConditionSQL($this->class, $alias)) { $sql .= ' AND ' . $filterSql; } list($params) = $this->expandParameters($criteria); - return (bool) $this->_conn->fetchColumn($sql, $params); + return (bool) $this->conn->fetchColumn($sql, $params); } /** * Generates the appropriate join SQL for the given join column. * * @param array $joinColumns The join columns definition of an association. + * * @return string LEFT JOIN if one of the columns is nullable, INNER JOIN otherwise. */ protected function getJoinSQLForJoinColumns($joinColumns) @@ -1765,18 +1945,19 @@ class BasicEntityPersister * Gets an SQL column alias for a column name. * * @param string $columnName + * * @return string */ public function getSQLColumnAlias($columnName) { - return $this->quoteStrategy->getColumnAlias($columnName, $this->_sqlAliasCounter++, $this->_platform); + return $this->quoteStrategy->getColumnAlias($columnName, $this->sqlAliasCounter++, $this->platform); } /** * Generates the filter SQL for a given entity and table alias. * - * @param ClassMetadata $targetEntity Metadata of the target entity. - * @param string $targetTableAlias The table alias of the joined/selected table. + * @param ClassMetadata $targetEntity Metadata of the target entity. + * @param string $targetTableAlias The table alias of the joined/selected table. * * @return string The SQL query part to add to a query. */ @@ -1784,7 +1965,7 @@ class BasicEntityPersister { $filterClauses = array(); - foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) { + foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { if ('' !== $filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { $filterClauses[] = '(' . $filterExpr . ')'; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/ElementCollectionPersister.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/ElementCollectionPersister.php old mode 100755 new mode 100644 index 0b0354af7f..04da1f7dfc --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/ElementCollectionPersister.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/ElementCollectionPersister.php @@ -26,5 +26,4 @@ namespace Doctrine\ORM\Persisters; */ abstract class ElementCollectionPersister extends AbstractCollectionPersister { - //put your code here } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php old mode 100755 new mode 100644 index 2d8967c111..684d30571c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php @@ -19,7 +19,6 @@ namespace Doctrine\ORM\Persisters; -use Doctrine\ORM\ORMException; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\ResultSetMapping; @@ -46,23 +45,23 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister * * @var array */ - private $_owningTableMap = array(); + private $owningTableMap = array(); /** * Map of table to quoted table names. * * @var array */ - private $_quotedTableMap = array(); + private $quotedTableMap = array(); /** * {@inheritdoc} */ - protected function _getDiscriminatorColumnTableName() + protected function getDiscriminatorColumnTableName() { - $class = ($this->_class->name !== $this->_class->rootEntityName) - ? $this->_em->getClassMetadata($this->_class->rootEntityName) - : $this->_class; + $class = ($this->class->name !== $this->class->rootEntityName) + ? $this->em->getClassMetadata($this->class->rootEntityName) + : $this->class; return $class->getTableName(); } @@ -73,42 +72,51 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister * * @return \Doctrine\ORM\Mapping\ClassMetadata */ - private function _getVersionedClassMetadata() + private function getVersionedClassMetadata() { - if (isset($this->_class->fieldMappings[$this->_class->versionField]['inherited'])) { - $definingClassName = $this->_class->fieldMappings[$this->_class->versionField]['inherited']; + if (isset($this->class->fieldMappings[$this->class->versionField]['inherited'])) { + $definingClassName = $this->class->fieldMappings[$this->class->versionField]['inherited']; - return $this->_em->getClassMetadata($definingClassName); + return $this->em->getClassMetadata($definingClassName); } - return $this->_class; + return $this->class; } /** * Gets the name of the table that owns the column the given field is mapped to. * * @param string $fieldName + * * @return string + * * @override */ public function getOwningTable($fieldName) { - if (isset($this->_owningTableMap[$fieldName])) { - return $this->_owningTableMap[$fieldName]; + if (isset($this->owningTableMap[$fieldName])) { + return $this->owningTableMap[$fieldName]; } - if (isset($this->_class->associationMappings[$fieldName]['inherited'])) { - $cm = $this->_em->getClassMetadata($this->_class->associationMappings[$fieldName]['inherited']); - } else if (isset($this->_class->fieldMappings[$fieldName]['inherited'])) { - $cm = $this->_em->getClassMetadata($this->_class->fieldMappings[$fieldName]['inherited']); - } else { - $cm = $this->_class; + switch (true) { + case isset($this->class->associationMappings[$fieldName]['inherited']): + $cm = $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']); + break; + + case isset($this->class->fieldMappings[$fieldName]['inherited']): + $cm = $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]['inherited']); + break; + + default: + $cm = $this->class; + break; } - $tableName = $cm->getTableName(); + $tableName = $cm->getTableName(); + $quotedTableName = $this->quoteStrategy->getTableName($cm, $this->platform); - $this->_owningTableMap[$fieldName] = $tableName; - $this->_quotedTableMap[$tableName] = $this->quoteStrategy->getTableName($cm, $this->_platform); + $this->owningTableMap[$fieldName] = $tableName; + $this->quotedTableMap[$tableName] = $quotedTableName; return $tableName; } @@ -118,73 +126,80 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister */ public function executeInserts() { - if ( ! $this->_queuedInserts) { + if ( ! $this->queuedInserts) { return; } - $postInsertIds = array(); - $idGen = $this->_class->idGenerator; - $isPostInsertId = $idGen->isPostInsertGenerator(); + $postInsertIds = array(); + $idGenerator = $this->class->idGenerator; + $isPostInsertId = $idGenerator->isPostInsertGenerator(); + $rootClass = ($this->class->name !== $this->class->rootEntityName) + ? $this->em->getClassMetadata($this->class->rootEntityName) + : $this->class; // Prepare statement for the root table - $rootClass = ($this->_class->name !== $this->_class->rootEntityName) ? $this->_em->getClassMetadata($this->_class->rootEntityName) : $this->_class; - $rootPersister = $this->_em->getUnitOfWork()->getEntityPersister($rootClass->name); + $rootPersister = $this->em->getUnitOfWork()->getEntityPersister($rootClass->name); $rootTableName = $rootClass->getTableName(); - $rootTableStmt = $this->_conn->prepare($rootPersister->_getInsertSQL()); + $rootTableStmt = $this->conn->prepare($rootPersister->getInsertSQL()); // Prepare statements for sub tables. $subTableStmts = array(); - if ($rootClass !== $this->_class) { - $subTableStmts[$this->_class->getTableName()] = $this->_conn->prepare($this->_getInsertSQL()); + if ($rootClass !== $this->class) { + $subTableStmts[$this->class->getTableName()] = $this->conn->prepare($this->getInsertSQL()); } - foreach ($this->_class->parentClasses as $parentClassName) { - $parentClass = $this->_em->getClassMetadata($parentClassName); + foreach ($this->class->parentClasses as $parentClassName) { + $parentClass = $this->em->getClassMetadata($parentClassName); $parentTableName = $parentClass->getTableName(); if ($parentClass !== $rootClass) { - $parentPersister = $this->_em->getUnitOfWork()->getEntityPersister($parentClassName); - $subTableStmts[$parentTableName] = $this->_conn->prepare($parentPersister->_getInsertSQL()); + $parentPersister = $this->em->getUnitOfWork()->getEntityPersister($parentClassName); + $subTableStmts[$parentTableName] = $this->conn->prepare($parentPersister->getInsertSQL()); } } // Execute all inserts. For each entity: // 1) Insert on root table // 2) Insert on sub tables - foreach ($this->_queuedInserts as $entity) { - $insertData = $this->_prepareInsertData($entity); + foreach ($this->queuedInserts as $entity) { + $insertData = $this->prepareInsertData($entity); // Execute insert on root table $paramIndex = 1; foreach ($insertData[$rootTableName] as $columnName => $value) { - $rootTableStmt->bindValue($paramIndex++, $value, $this->_columnTypes[$columnName]); + $rootTableStmt->bindValue($paramIndex++, $value, $this->columnTypes[$columnName]); } $rootTableStmt->execute(); if ($isPostInsertId) { - $id = $idGen->generate($this->_em, $entity); + $id = $idGenerator->generate($this->em, $entity); $postInsertIds[$id] = $entity; } else { - $id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity); + $id = $this->em->getUnitOfWork()->getEntityIdentifier($entity); } // Execute inserts on subtables. // The order doesn't matter because all child tables link to the root table via FK. foreach ($subTableStmts as $tableName => $stmt) { - $data = isset($insertData[$tableName]) ? $insertData[$tableName] : array(); + /** @var \Doctrine\DBAL\Statement $stmt */ $paramIndex = 1; + $data = isset($insertData[$tableName]) + ? $insertData[$tableName] + : array(); foreach ((array) $id as $idName => $idVal) { - $type = isset($this->_columnTypes[$idName]) ? $this->_columnTypes[$idName] : Type::STRING; + $type = isset($this->columnTypes[$idName]) ? $this->columnTypes[$idName] : Type::STRING; $stmt->bindValue($paramIndex++, $idVal, $type); } foreach ($data as $columnName => $value) { - $stmt->bindValue($paramIndex++, $value, $this->_columnTypes[$columnName]); + if (!is_array($id) || !isset($id[$columnName])) { + $stmt->bindValue($paramIndex++, $value, $this->columnTypes[$columnName]); + } } $stmt->execute(); @@ -197,11 +212,11 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister $stmt->closeCursor(); } - if ($this->_class->isVersioned) { + if ($this->class->isVersioned) { $this->assignDefaultVersionValue($entity, $id); } - $this->_queuedInserts = array(); + $this->queuedInserts = array(); return $postInsertIds; } @@ -211,30 +226,36 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister */ public function update($entity) { - $updateData = $this->_prepareUpdateData($entity); + $updateData = $this->prepareUpdateData($entity); - if (($isVersioned = $this->_class->isVersioned) != false) { - $versionedClass = $this->_getVersionedClassMetadata(); - $versionedTable = $versionedClass->getTableName(); + if ( ! $updateData) { + return; } - if ($updateData) { - foreach ($updateData as $tableName => $data) { - $this->_updateTable( - $entity, $this->_quotedTableMap[$tableName], $data, $isVersioned && $versionedTable == $tableName - ); + if (($isVersioned = $this->class->isVersioned) === false) { + return; + } + + $versionedClass = $this->getVersionedClassMetadata(); + $versionedTable = $versionedClass->getTableName(); + + foreach ($updateData as $tableName => $data) { + $tableName = $this->quotedTableMap[$tableName]; + $versioned = $isVersioned && $versionedTable === $tableName; + + $this->updateTable($entity, $tableName, $data, $versioned); + } + + // Make sure the table with the version column is updated even if no columns on that + // table were affected. + if ($isVersioned) { + if ( ! isset($updateData[$versionedTable])) { + $tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform); + $this->updateTable($entity, $tableName, array(), true); } - // Make sure the table with the version column is updated even if no columns on that - // table were affected. - if ($isVersioned) { - if ( ! isset($updateData[$versionedTable])) { - $this->_updateTable($entity, $this->quoteStrategy->getTableName($versionedClass, $this->_platform), array(), true); - } - - $id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity); - $this->assignDefaultVersionValue($entity, $id); - } + $identifiers = $this->em->getUnitOfWork()->getEntityIdentifier($entity); + $this->assignDefaultVersionValue($entity, $identifiers); } } @@ -243,174 +264,126 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister */ public function delete($entity) { - $identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity); - $this->deleteJoinTableRecords($identifier); + $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); + $id = array_combine($this->class->getIdentifierColumnNames(), $identifier); - $id = array_combine($this->_class->getIdentifierColumnNames(), $identifier); + $this->deleteJoinTableRecords($identifier); // If the database platform supports FKs, just // delete the row from the root table. Cascades do the rest. - if ($this->_platform->supportsForeignKeyConstraints()) { - $this->_conn->delete( - $this->quoteStrategy->getTableName($this->_em->getClassMetadata($this->_class->rootEntityName), $this->_platform), $id - ); - } else { - // Delete from all tables individually, starting from this class' table up to the root table. - $this->_conn->delete($this->quoteStrategy->getTableName($this->_class, $this->_platform), $id); + if ($this->platform->supportsForeignKeyConstraints()) { + $rootClass = $this->em->getClassMetadata($this->class->rootEntityName); + $rootTable = $this->quoteStrategy->getTableName($rootClass, $this->platform); - foreach ($this->_class->parentClasses as $parentClass) { - $this->_conn->delete( - $this->quoteStrategy->getTableName($this->_em->getClassMetadata($parentClass), $this->_platform), $id - ); - } + $this->conn->delete($rootTable, $id); + + return; + } + + // Delete from all tables individually, starting from this class' table up to the root table. + $rootTable = $this->quoteStrategy->getTableName($this->class, $this->platform); + + $this->conn->delete($rootTable, $id); + + foreach ($this->class->parentClasses as $parentClass) { + $parentMetadata = $this->em->getClassMetadata($parentClass); + $parentTable = $this->quoteStrategy->getTableName($parentMetadata, $this->platform); + + $this->conn->delete($parentTable, $id); } } /** * {@inheritdoc} */ - protected function _getSelectEntitiesSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null) + protected function getSelectSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null) { - $idColumns = $this->_class->getIdentifierColumnNames(); - $baseTableAlias = $this->_getSQLTableAlias($this->_class->name); + $joinSql = ''; + $identifierColumn = $this->class->getIdentifierColumnNames(); + $baseTableAlias = $this->getSQLTableAlias($this->class->name); - // Create the column list fragment only once - if ($this->_selectColumnListSql === null) { - - $this->_rsm = new ResultSetMapping(); - $this->_rsm->addEntityResult($this->_class->name, 'r'); - - // Add regular columns - $columnList = ''; - - foreach ($this->_class->fieldMappings as $fieldName => $mapping) { - if ($columnList != '') $columnList .= ', '; - - $columnList .= $this->_getSelectColumnSQL( - $fieldName, - isset($mapping['inherited']) ? $this->_em->getClassMetadata($mapping['inherited']) : $this->_class - ); - } - - // Add foreign key columns - foreach ($this->_class->associationMappings as $assoc2) { - if ($assoc2['isOwningSide'] && $assoc2['type'] & ClassMetadata::TO_ONE) { - $tableAlias = isset($assoc2['inherited']) ? $this->_getSQLTableAlias($assoc2['inherited']) : $baseTableAlias; - - foreach ($assoc2['targetToSourceKeyColumns'] as $srcColumn) { - if ($columnList != '') $columnList .= ', '; - - $columnList .= $this->getSelectJoinColumnSQL( - $tableAlias, - $srcColumn, - isset($assoc2['inherited']) ? $assoc2['inherited'] : $this->_class->name - ); - } - } - } - - // Add discriminator column (DO NOT ALIAS, see AbstractEntityInheritancePersister#_processSQLResult). - $discrColumn = $this->_class->discriminatorColumn['name']; - $tableAlias = ($this->_class->rootEntityName == $this->_class->name) ? $baseTableAlias : $this->_getSQLTableAlias($this->_class->rootEntityName); - $columnList .= ', ' . $tableAlias . '.' . $discrColumn; - - $resultColumnName = $this->_platform->getSQLResultCasing($discrColumn); - - $this->_rsm->setDiscriminatorColumn('r', $resultColumnName); - $this->_rsm->addMetaResult('r', $resultColumnName, $discrColumn); - } // INNER JOIN parent tables - $joinSql = ''; + foreach ($this->class->parentClasses as $parentClassName) { + $conditions = array(); + $parentClass = $this->em->getClassMetadata($parentClassName); + $tableAlias = $this->getSQLTableAlias($parentClassName); + $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; - foreach ($this->_class->parentClasses as $parentClassName) { - $parentClass = $this->_em->getClassMetadata($parentClassName); - $tableAlias = $this->_getSQLTableAlias($parentClassName); - $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->_platform) . ' ' . $tableAlias . ' ON '; - $first = true; - foreach ($idColumns as $idColumn) { - if ($first) $first = false; else $joinSql .= ' AND '; - - $joinSql .= $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn; + foreach ($identifierColumn as $idColumn) { + $conditions[] = $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn; } + + $joinSql .= implode(' AND ', $conditions); } // OUTER JOIN sub tables - foreach ($this->_class->subClasses as $subClassName) { - $subClass = $this->_em->getClassMetadata($subClassName); - $tableAlias = $this->_getSQLTableAlias($subClassName); + foreach ($this->class->subClasses as $subClassName) { + $conditions = array(); + $subClass = $this->em->getClassMetadata($subClassName); + $tableAlias = $this->getSQLTableAlias($subClassName); + $joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON '; - if ($this->_selectColumnListSql === null) { - // Add subclass columns - foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if (isset($mapping['inherited'])) continue; - - $columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass); - } - - // Add join columns (foreign keys) - foreach ($subClass->associationMappings as $assoc2) { - if ($assoc2['isOwningSide'] && $assoc2['type'] & ClassMetadata::TO_ONE && ! isset($assoc2['inherited'])) { - foreach ($assoc2['targetToSourceKeyColumns'] as $srcColumn) { - if ($columnList != '') $columnList .= ', '; - - $columnList .= $this->getSelectJoinColumnSQL( - $tableAlias, - $srcColumn, - isset($assoc2['inherited']) ? $assoc2['inherited'] : $subClass->name - ); - } - } - } + foreach ($identifierColumn as $idColumn) { + $conditions[] = $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn; } - // Add LEFT JOIN - $joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->_platform) . ' ' . $tableAlias . ' ON '; - $first = true; - - foreach ($idColumns as $idColumn) { - if ($first) $first = false; else $joinSql .= ' AND '; - - $joinSql .= $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn; - } + $joinSql .= implode(' AND ', $conditions); } - $joinSql .= ($assoc != null && $assoc['type'] == ClassMetadata::MANY_TO_MANY) ? $this->_getSelectManyToManyJoinSQL($assoc) : ''; + if ($assoc != null && $assoc['type'] == ClassMetadata::MANY_TO_MANY) { + $joinSql .= $this->getSelectManyToManyJoinSQL($assoc); + } $conditionSql = ($criteria instanceof Criteria) - ? $this->_getSelectConditionCriteriaSQL($criteria) - : $this->_getSelectConditionSQL($criteria, $assoc); + ? $this->getSelectConditionCriteriaSQL($criteria) + : $this->getSelectConditionSQL($criteria, $assoc); // If the current class in the root entity, add the filters - if ($filterSql = $this->generateFilterConditionSQL($this->_em->getClassMetadata($this->_class->rootEntityName), $this->_getSQLTableAlias($this->_class->rootEntityName))) { - if ($conditionSql) { - $conditionSql .= ' AND '; - } - - $conditionSql .= $filterSql; + if ($filterSql = $this->generateFilterConditionSQL($this->em->getClassMetadata($this->class->rootEntityName), $this->getSQLTableAlias($this->class->rootEntityName))) { + $conditionSql .= $conditionSql + ? ' AND ' . $filterSql + : $filterSql; } - $orderBy = ($assoc !== null && isset($assoc['orderBy'])) ? $assoc['orderBy'] : $orderBy; - $orderBySql = $orderBy ? $this->_getOrderBySQL($orderBy, $baseTableAlias) : ''; + $orderBySql = ''; - if ($this->_selectColumnListSql === null) { - $this->_selectColumnListSql = $columnList; + if ($assoc !== null && isset($assoc['orderBy'])) { + $orderBy = $assoc['orderBy']; + } + + if ($orderBy) { + $orderBySql = $this->getOrderBySQL($orderBy, $baseTableAlias); } $lockSql = ''; - if ($lockMode == LockMode::PESSIMISTIC_READ) { - $lockSql = ' ' . $this->_platform->getReadLockSql(); - } else if ($lockMode == LockMode::PESSIMISTIC_WRITE) { - $lockSql = ' ' . $this->_platform->getWriteLockSql(); + switch ($lockMode) { + case LockMode::PESSIMISTIC_READ: + + $lockSql = ' ' . $this->platform->getReadLockSql(); + + break; + + case LockMode::PESSIMISTIC_WRITE: + + $lockSql = ' ' . $this->platform->getWriteLockSql(); + + break; } - return $this->_platform->modifyLimitQuery('SELECT ' . $this->_selectColumnListSql - . ' FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' . $baseTableAlias - . $joinSql - . ($conditionSql != '' ? ' WHERE ' . $conditionSql : '') . $orderBySql, $limit, $offset) - . $lockSql; + $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); + $where = $conditionSql != '' ? ' WHERE ' . $conditionSql : ''; + $columnList = $this->getSelectColumnsSQL(); + $query = 'SELECT ' . $columnList + . ' FROM ' + . $tableName . ' ' . $baseTableAlias + . $joinSql + . $where + . $orderBySql; + + return $this->platform->modifyLimitQuery($query, $limit, $offset) . $lockSql; } /** @@ -420,64 +393,157 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister */ public function getLockTablesSql() { - $idColumns = $this->_class->getIdentifierColumnNames(); - $baseTableAlias = $this->_getSQLTableAlias($this->_class->name); + $joinSql = ''; + $identifierColumns = $this->class->getIdentifierColumnNames(); + $baseTableAlias = $this->getSQLTableAlias($this->class->name); + $quotedTableName = $this->quoteStrategy->getTableName($this->class, $this->platform); // INNER JOIN parent tables - $joinSql = ''; + foreach ($this->class->parentClasses as $parentClassName) { + $conditions = array(); + $tableAlias = $this->getSQLTableAlias($parentClassName); + $parentClass = $this->em->getClassMetadata($parentClassName); + $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON '; - foreach ($this->_class->parentClasses as $parentClassName) { - $parentClass = $this->_em->getClassMetadata($parentClassName); - $tableAlias = $this->_getSQLTableAlias($parentClassName); - $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->_platform) . ' ' . $tableAlias . ' ON '; - $first = true; - - foreach ($idColumns as $idColumn) { - if ($first) $first = false; else $joinSql .= ' AND '; - - $joinSql .= $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn; + foreach ($identifierColumns as $idColumn) { + $conditions[] = $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn; } + + $joinSql .= implode(' AND ', $conditions); } - return 'FROM ' .$this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' . $baseTableAlias . $joinSql; + return 'FROM ' . $quotedTableName . ' ' . $baseTableAlias . $joinSql; } - /* Ensure this method is never called. This persister overrides _getSelectEntitiesSQL directly. */ - protected function _getSelectColumnListSQL() + /** + * Ensure this method is never called. This persister overrides getSelectEntitiesSQL directly. + * + * @return string + */ + protected function getSelectColumnsSQL() { - throw new \BadMethodCallException("Illegal invocation of ".__METHOD__."."); - } + // Create the column list fragment only once + if ($this->selectColumnListSql !== null) { + return $this->selectColumnListSql; + } - /** {@inheritdoc} */ - protected function _getInsertColumnList() - { - // Identifier columns must always come first in the column list of subclasses. - $columns = $this->_class->parentClasses ? $this->_class->getIdentifierColumnNames() : array(); + $columnList = array(); + $this->rsm = new ResultSetMapping(); + $discrColumn = $this->class->discriminatorColumn['name']; + $baseTableAlias = $this->getSQLTableAlias($this->class->name); + $resultColumnName = $this->platform->getSQLResultCasing($discrColumn); - foreach ($this->_class->reflFields as $name => $field) { - if (isset($this->_class->fieldMappings[$name]['inherited']) && ! isset($this->_class->fieldMappings[$name]['id']) - || isset($this->_class->associationMappings[$name]['inherited']) - || ($this->_class->isVersioned && $this->_class->versionField == $name)) { + $this->rsm->addEntityResult($this->class->name, 'r'); + $this->rsm->setDiscriminatorColumn('r', $resultColumnName); + $this->rsm->addMetaResult('r', $resultColumnName, $discrColumn); + + // Add regular columns + foreach ($this->class->fieldMappings as $fieldName => $mapping) { + $class = isset($mapping['inherited']) + ? $this->em->getClassMetadata($mapping['inherited']) + : $this->class; + + $columnList[] = $this->getSelectColumnSQL($fieldName, $class); + } + + // Add foreign key columns + foreach ($this->class->associationMappings as $mapping) { + if ( ! $mapping['isOwningSide'] || ! ($mapping['type'] & ClassMetadata::TO_ONE)) { continue; } - if (isset($this->_class->associationMappings[$name])) { - $assoc = $this->_class->associationMappings[$name]; + $tableAlias = isset($mapping['inherited']) + ? $this->getSQLTableAlias($mapping['inherited']) + : $baseTableAlias; + + foreach ($mapping['targetToSourceKeyColumns'] as $srcColumn) { + $className = isset($mapping['inherited']) + ? $mapping['inherited'] + : $this->class->name; + + $columnList[] = $this->getSelectJoinColumnSQL($tableAlias, $srcColumn, $className); + } + } + + // Add discriminator column (DO NOT ALIAS, see AbstractEntityInheritancePersister#processSQLResult). + $tableAlias = ($this->class->rootEntityName == $this->class->name) + ? $baseTableAlias + : $this->getSQLTableAlias($this->class->rootEntityName); + + $columnList[] = $tableAlias . '.' . $discrColumn; + + // sub tables + foreach ($this->class->subClasses as $subClassName) { + $subClass = $this->em->getClassMetadata($subClassName); + $tableAlias = $this->getSQLTableAlias($subClassName); + + // Add subclass columns + foreach ($subClass->fieldMappings as $fieldName => $mapping) { + if (isset($mapping['inherited'])) { + continue; + } + + $columnList[] = $this->getSelectColumnSQL($fieldName, $subClass); + } + + // Add join columns (foreign keys) + foreach ($subClass->associationMappings as $mapping) { + if ( ! $mapping['isOwningSide'] + || ! ($mapping['type'] & ClassMetadata::TO_ONE) + || isset($mapping['inherited'])) { + continue; + } + + foreach ($mapping['targetToSourceKeyColumns'] as $srcColumn) { + $className = isset($mapping['inherited']) + ? $mapping['inherited'] + : $subClass->name; + + $columnList[] = $this->getSelectJoinColumnSQL($tableAlias, $srcColumn, $className); + } + } + } + + $this->selectColumnListSql = implode(', ', $columnList); + + return $this->selectColumnListSql; + } + + /** + * {@inheritdoc} + */ + protected function getInsertColumnList() + { + // Identifier columns must always come first in the column list of subclasses. + $columns = $this->class->parentClasses + ? $this->class->getIdentifierColumnNames() + : array(); + + foreach ($this->class->reflFields as $name => $field) { + if (isset($this->class->fieldMappings[$name]['inherited']) + && ! isset($this->class->fieldMappings[$name]['id']) + || isset($this->class->associationMappings[$name]['inherited']) + || ($this->class->isVersioned && $this->class->versionField == $name)) { + continue; + } + + if (isset($this->class->associationMappings[$name])) { + $assoc = $this->class->associationMappings[$name]; if ($assoc['type'] & ClassMetadata::TO_ONE && $assoc['isOwningSide']) { foreach ($assoc['targetToSourceKeyColumns'] as $sourceCol) { $columns[] = $sourceCol; } } - } else if ($this->_class->name != $this->_class->rootEntityName || - ! $this->_class->isIdGeneratorIdentity() || $this->_class->identifier[0] != $name) { - $columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform); - $this->_columnTypes[$name] = $this->_class->fieldMappings[$name]['type']; + } else if ($this->class->name != $this->class->rootEntityName || + ! $this->class->isIdGeneratorIdentity() || $this->class->identifier[0] != $name) { + $columns[] = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform); + $this->columnTypes[$name] = $this->class->fieldMappings[$name]['type']; } } // Add discriminator column if it is the topmost class. - if ($this->_class->name == $this->_class->rootEntityName) { - $columns[] = $this->_class->discriminatorColumn['name']; + if ($this->class->name == $this->class->rootEntityName) { + $columns[] = $this->class->discriminatorColumn['name']; } return $columns; @@ -488,8 +554,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister */ protected function assignDefaultVersionValue($entity, $id) { - $value = $this->fetchVersionValue($this->_getVersionedClassMetadata(), $id); - $this->_class->setFieldValue($entity, $this->_class->versionField, $value); + $value = $this->fetchVersionValue($this->getVersionedClassMetadata(), $id); + $this->class->setFieldValue($entity, $this->class->versionField, $value); } - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php old mode 100755 new mode 100644 index 9ecafae1c4..1ec6e5e7c1 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php @@ -19,9 +19,9 @@ namespace Doctrine\ORM\Persisters; -use Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\PersistentCollection, - Doctrine\ORM\UnitOfWork; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\PersistentCollection; +use Doctrine\ORM\UnitOfWork; /** * Persister for many-to-many collections. @@ -38,11 +38,12 @@ class ManyToManyPersister extends AbstractCollectionPersister * * @override */ - protected function _getDeleteRowSQL(PersistentCollection $coll) + protected function getDeleteRowSQL(PersistentCollection $coll) { - $columns = array(); - $mapping = $coll->getMapping(); - $class = $this->_em->getClassMetadata(get_class($coll->getOwner())); + $columns = array(); + $mapping = $coll->getMapping(); + $class = $this->em->getClassMetadata(get_class($coll->getOwner())); + $tableName = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); @@ -52,7 +53,7 @@ class ManyToManyPersister extends AbstractCollectionPersister $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } - return 'DELETE FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform) + return 'DELETE FROM ' . $tableName . ' WHERE ' . implode(' = ? AND ', $columns) . ' = ?'; } @@ -60,34 +61,36 @@ class ManyToManyPersister extends AbstractCollectionPersister * {@inheritdoc} * * @override - * @internal Order of the parameters must be the same as the order of the columns in - * _getDeleteRowSql. + * + * @internal Order of the parameters must be the same as the order of the columns in getDeleteRowSql. */ - protected function _getDeleteRowSQLParameters(PersistentCollection $coll, $element) + protected function getDeleteRowSQLParameters(PersistentCollection $coll, $element) { - return $this->_collectJoinTableColumnParameters($coll, $element); + return $this->collectJoinTableColumnParameters($coll, $element); + } + + /** + * {@inheritdoc} + * + * @throws \BadMethodCallException Not used for OneToManyPersister + */ + protected function getUpdateRowSQL(PersistentCollection $coll) + { + throw new \BadMethodCallException("Insert Row SQL is not used for ManyToManyPersister"); } /** * {@inheritdoc} * * @override - */ - protected function _getUpdateRowSQL(PersistentCollection $coll) - {} - - /** - * {@inheritdoc} * - * @override - * @internal Order of the parameters must be the same as the order of the columns in - * _getInsertRowSql. + * @internal Order of the parameters must be the same as the order of the columns in getInsertRowSql. */ - protected function _getInsertRowSQL(PersistentCollection $coll) + protected function getInsertRowSQL(PersistentCollection $coll) { $columns = array(); $mapping = $coll->getMapping(); - $class = $this->_em->getClassMetadata(get_class($coll->getOwner())); + $class = $this->em->getClassMetadata(get_class($coll->getOwner())); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { @@ -106,33 +109,34 @@ class ManyToManyPersister extends AbstractCollectionPersister * {@inheritdoc} * * @override - * @internal Order of the parameters must be the same as the order of the columns in - * _getInsertRowSql. + * + * @internal Order of the parameters must be the same as the order of the columns in getInsertRowSql. */ - protected function _getInsertRowSQLParameters(PersistentCollection $coll, $element) + protected function getInsertRowSQLParameters(PersistentCollection $coll, $element) { - return $this->_collectJoinTableColumnParameters($coll, $element); + return $this->collectJoinTableColumnParameters($coll, $element); } /** * Collects the parameters for inserting/deleting on the join table in the order * of the join table columns as specified in ManyToManyMapping#joinTableColumns. * - * @param $coll - * @param $element + * @param \Doctrine\ORM\PersistentCollection $coll + * @param object $element + * * @return array */ - private function _collectJoinTableColumnParameters(PersistentCollection $coll, $element) + private function collectJoinTableColumnParameters(PersistentCollection $coll, $element) { $params = array(); $mapping = $coll->getMapping(); $isComposite = count($mapping['joinTableColumns']) > 2; - $identifier1 = $this->_uow->getEntityIdentifier($coll->getOwner()); - $identifier2 = $this->_uow->getEntityIdentifier($element); + $identifier1 = $this->uow->getEntityIdentifier($coll->getOwner()); + $identifier2 = $this->uow->getEntityIdentifier($element); if ($isComposite) { - $class1 = $this->_em->getClassMetadata(get_class($coll->getOwner())); + $class1 = $this->em->getClassMetadata(get_class($coll->getOwner())); $class2 = $coll->getTypeClass(); } @@ -162,11 +166,11 @@ class ManyToManyPersister extends AbstractCollectionPersister * * @override */ - protected function _getDeleteSQL(PersistentCollection $coll) + protected function getDeleteSQL(PersistentCollection $coll) { $columns = array(); $mapping = $coll->getMapping(); - $class = $this->_em->getClassMetadata(get_class($coll->getOwner())); + $class = $this->em->getClassMetadata(get_class($coll->getOwner())); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { @@ -181,13 +185,13 @@ class ManyToManyPersister extends AbstractCollectionPersister * {@inheritdoc} * * @override - * @internal Order of the parameters must be the same as the order of the columns in - * _getDeleteSql. + * + * @internal Order of the parameters must be the same as the order of the columns in getDeleteSql. */ - protected function _getDeleteSQLParameters(PersistentCollection $coll) + protected function getDeleteSQLParameters(PersistentCollection $coll) { $mapping = $coll->getMapping(); - $identifier = $this->_uow->getEntityIdentifier($coll->getOwner()); + $identifier = $this->uow->getEntityIdentifier($coll->getOwner()); // Optimization for single column identifier if (count($mapping['relationToSourceKeyColumns']) === 1) { @@ -195,7 +199,7 @@ class ManyToManyPersister extends AbstractCollectionPersister } // Composite identifier - $sourceClass = $this->_em->getClassMetadata(get_class($coll->getOwner())); + $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); $params = array(); foreach ($mapping['relationToSourceKeyColumns'] as $columnName => $refColumnName) { @@ -216,11 +220,11 @@ class ManyToManyPersister extends AbstractCollectionPersister $params = array(); $mapping = $coll->getMapping(); $association = $mapping; - $class = $this->_em->getClassMetadata($mapping['sourceEntity']); - $id = $this->_em->getUnitOfWork()->getEntityIdentifier($coll->getOwner()); + $class = $this->em->getClassMetadata($mapping['sourceEntity']); + $id = $this->em->getUnitOfWork()->getEntityIdentifier($coll->getOwner()); if ( ! $mapping['isOwningSide']) { - $targetEntity = $this->_em->getClassMetadata($mapping['targetEntity']); + $targetEntity = $this->em->getClassMetadata($mapping['targetEntity']); $association = $targetEntity->associationMappings[$mapping['mappedBy']]; } @@ -231,7 +235,7 @@ class ManyToManyPersister extends AbstractCollectionPersister foreach ($joinColumns as $joinColumn) { $columnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); $referencedName = $joinColumn['referencedColumnName']; - $conditions[] = $columnName . ' = ?'; + $conditions[] = 't.' . $columnName . ' = ?'; $params[] = ($class->containsForeignIdentifier) ? $id[$class->getFieldForColumn($referencedName)] : $id[$class->fieldNames[$referencedName]]; @@ -249,30 +253,32 @@ class ManyToManyPersister extends AbstractCollectionPersister . $joinTargetEntitySQL . ' WHERE ' . implode(' AND ', $conditions); - return $this->_conn->fetchColumn($sql, $params); + return $this->conn->fetchColumn($sql, $params); } /** - * @param PersistentCollection $coll - * @param int $offset - * @param int $length + * @param \Doctrine\ORM\PersistentCollection $coll + * @param int $offset + * @param int|null $length + * * @return array */ public function slice(PersistentCollection $coll, $offset, $length = null) { $mapping = $coll->getMapping(); - return $this->_em->getUnitOfWork()->getEntityPersister($mapping['targetEntity'])->getManyToManyCollection($mapping, $coll->getOwner(), $offset, $length); + return $this->em->getUnitOfWork()->getEntityPersister($mapping['targetEntity'])->getManyToManyCollection($mapping, $coll->getOwner(), $offset, $length); } /** - * @param PersistentCollection $coll - * @param object $element + * @param \Doctrine\ORM\PersistentCollection $coll + * @param object $element + * * @return boolean */ public function contains(PersistentCollection $coll, $element) { - $uow = $this->_em->getUnitOfWork(); + $uow = $this->em->getUnitOfWork(); // Shortcut for new entities $entityState = $uow->getEntityState($element, UnitOfWork::STATE_NEW); @@ -290,17 +296,18 @@ class ManyToManyPersister extends AbstractCollectionPersister $sql = 'SELECT 1 FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses); - return (bool) $this->_conn->fetchColumn($sql, $params); + return (bool) $this->conn->fetchColumn($sql, $params); } /** - * @param PersistentCollection $coll - * @param object $element + * @param \Doctrine\ORM\PersistentCollection $coll + * @param object $element + * * @return boolean */ public function removeElement(PersistentCollection $coll, $element) { - $uow = $this->_em->getUnitOfWork(); + $uow = $this->em->getUnitOfWork(); // shortcut for new entities $entityState = $uow->getEntityState($element, UnitOfWork::STATE_NEW); @@ -319,30 +326,32 @@ class ManyToManyPersister extends AbstractCollectionPersister $sql = 'DELETE FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses); - return (bool) $this->_conn->executeUpdate($sql, $params); + return (bool) $this->conn->executeUpdate($sql, $params); } /** * @param \Doctrine\ORM\PersistentCollection $coll - * @param object $element - * @param boolean $addFilters Whether the filter SQL should be included or not. + * @param object $element + * @param boolean $addFilters Whether the filter SQL should be included or not. + * * @return array */ private function getJoinTableRestrictions(PersistentCollection $coll, $element, $addFilters) { - $uow = $this->_em->getUnitOfWork(); - $mapping = $filterMapping = $coll->getMapping(); + $uow = $this->em->getUnitOfWork(); + $filterMapping = $coll->getMapping(); + $mapping = $filterMapping; if ( ! $mapping['isOwningSide']) { - $sourceClass = $this->_em->getClassMetadata($mapping['targetEntity']); - $targetClass = $this->_em->getClassMetadata($mapping['sourceEntity']); + $sourceClass = $this->em->getClassMetadata($mapping['targetEntity']); + $targetClass = $this->em->getClassMetadata($mapping['sourceEntity']); $sourceId = $uow->getEntityIdentifier($element); $targetId = $uow->getEntityIdentifier($coll->getOwner()); $mapping = $sourceClass->associationMappings[$mapping['mappedBy']]; } else { - $sourceClass = $this->_em->getClassMetadata($mapping['sourceEntity']); - $targetClass = $this->_em->getClassMetadata($mapping['targetEntity']); + $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); + $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $sourceId = $uow->getEntityIdentifier($coll->getOwner()); $targetId = $uow->getEntityIdentifier($element); } @@ -352,12 +361,13 @@ class ManyToManyPersister extends AbstractCollectionPersister $params = array(); foreach ($mapping['joinTableColumns'] as $joinTableColumn) { - $whereClauses[] = $joinTableColumn . ' = ?'; + $whereClauses[] = ($addFilters ? 't.' : '') . $joinTableColumn . ' = ?'; if (isset($mapping['relationToTargetKeyColumns'][$joinTableColumn])) { $params[] = ($targetClass->containsForeignIdentifier) ? $targetId[$targetClass->getFieldForColumn($mapping['relationToTargetKeyColumns'][$joinTableColumn])] : $targetId[$targetClass->fieldNames[$mapping['relationToTargetKeyColumns'][$joinTableColumn]]]; + continue; } @@ -368,9 +378,12 @@ class ManyToManyPersister extends AbstractCollectionPersister } if ($addFilters) { + $quotedJoinTable .= ' t'; + list($joinTargetEntitySQL, $filterSql) = $this->getFilterSql($filterMapping); + if ($filterSql) { - $quotedJoinTable .= ' t ' . $joinTargetEntitySQL; + $quotedJoinTable .= ' ' . $joinTargetEntitySQL; $whereClauses[] = $filterSql; } } @@ -393,40 +406,46 @@ class ManyToManyPersister extends AbstractCollectionPersister */ public function getFilterSql($mapping) { - $targetClass = $this->_em->getClassMetadata($mapping['targetEntity']); + $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $rootClass = $this->em->getClassMetadata($targetClass->rootEntityName); + $filterSql = $this->generateFilterConditionSQL($rootClass, 'te'); - if ($mapping['isOwningSide']) { - $joinColumns = $mapping['relationToTargetKeyColumns']; - } else { - $mapping = $targetClass->associationMappings[$mapping['mappedBy']]; - $joinColumns = $mapping['relationToSourceKeyColumns']; + if ('' === $filterSql) { + return array('', ''); } - $targetClass = $this->_em->getClassMetadata($targetClass->rootEntityName); + $conditions = array(); + $association = $mapping; + + if ( ! $mapping['isOwningSide']) { + $class = $this->em->getClassMetadata($mapping['targetEntity']); + $association = $class->associationMappings[$mapping['mappedBy']]; + } // A join is needed if there is filtering on the target entity - $joinTargetEntitySQL = ''; - if ($filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) { - $joinTargetEntitySQL = ' JOIN ' - . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' te' - . ' ON'; + $tableName = $this->quoteStrategy->getTableName($rootClass, $this->platform); + $joinSql = ' JOIN ' . $tableName . ' te' . ' ON'; + $joinColumns = $mapping['isOwningSide'] + ? $association['joinTable']['inverseJoinColumns'] + : $association['joinTable']['joinColumns']; - $joinTargetEntitySQLClauses = array(); - foreach ($joinColumns as $joinTableColumn => $targetTableColumn) { - $joinTargetEntitySQLClauses[] = ' t.' . $joinTableColumn . ' = ' . 'te.' . $targetTableColumn; - } + foreach ($joinColumns as $joinColumn) { + $joinColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); + $refColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $targetClass, $this->platform); - $joinTargetEntitySQL .= implode(' AND ', $joinTargetEntitySQLClauses); + $conditions[] = ' t.' . $joinColumnName . ' = ' . 'te.' . $refColumnName; } - return array($joinTargetEntitySQL, $filterSql); + $joinSql .= implode(' AND ', $conditions); + + return array($joinSql, $filterSql); } /** * Generates the filter SQL for a given entity and table alias. * - * @param ClassMetadata $targetEntity Metadata of the target entity. - * @param string $targetTableAlias The table alias of the joined/selected table. + * @param ClassMetadata $targetEntity Metadata of the target entity. + * @param string $targetTableAlias The table alias of the joined/selected table. * * @return string The SQL query part to add to a query. */ @@ -434,7 +453,7 @@ class ManyToManyPersister extends AbstractCollectionPersister { $filterClauses = array(); - foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) { + foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { if ($filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias)) { $filterClauses[] = '(' . $filterExpr . ')'; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/OneToManyPersister.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/OneToManyPersister.php old mode 100755 new mode 100644 index aa0208fea4..2915fd2ed8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/OneToManyPersister.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/OneToManyPersister.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Persisters; -use Doctrine\ORM\PersistentCollection, - Doctrine\ORM\UnitOfWork; +use Doctrine\ORM\PersistentCollection; +use Doctrine\ORM\UnitOfWork; /** * Persister for one-to-many collections. @@ -32,71 +32,102 @@ use Doctrine\ORM\PersistentCollection, */ class OneToManyPersister extends AbstractCollectionPersister { + /** + * {@inheritdoc} + * + * @override + */ + public function get(PersistentCollection $coll, $index) + { + $mapping = $coll->getMapping(); + $uow = $this->em->getUnitOfWork(); + $persister = $uow->getEntityPersister($mapping['targetEntity']); + + if (!isset($mapping['indexBy'])) { + throw new \BadMethodCallException("Selecting a collection by index is only supported on indexed collections."); + } + + return $persister->load(array($mapping['mappedBy'] => $coll->getOwner(), $mapping['indexBy'] => $index), null, null, array(), 0, 1); + } + /** * Generates the SQL UPDATE that updates a particular row's foreign * key to null. * - * @param PersistentCollection $coll + * @param \Doctrine\ORM\PersistentCollection $coll + * * @return string + * * @override */ - protected function _getDeleteRowSQL(PersistentCollection $coll) + protected function getDeleteRowSQL(PersistentCollection $coll) { - $mapping = $coll->getMapping(); - $class = $this->_em->getClassMetadata($mapping['targetEntity']); + $mapping = $coll->getMapping(); + $class = $this->em->getClassMetadata($mapping['targetEntity']); + $tableName = $this->quoteStrategy->getTableName($class, $this->platform); + $idColumns = $class->getIdentifierColumnNames(); - return 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform) - . ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?'; + return 'DELETE FROM ' . $tableName + . ' WHERE ' . implode('= ? AND ', $idColumns) . ' = ?'; + } + + /** + * {@inheritdoc} + */ + protected function getDeleteRowSQLParameters(PersistentCollection $coll, $element) + { + return array_values($this->uow->getEntityIdentifier($element)); } /** * {@inheritdoc} * + * @throws \BadMethodCallException Not used for OneToManyPersister. */ - protected function _getDeleteRowSQLParameters(PersistentCollection $coll, $element) + protected function getInsertRowSQL(PersistentCollection $coll) { - return array_values($this->_uow->getEntityIdentifier($element)); - } - - protected function _getInsertRowSQL(PersistentCollection $coll) - { - return "UPDATE xxx SET foreign_key = yyy WHERE foreign_key = zzz"; + throw new \BadMethodCallException("Insert Row SQL is not used for OneToManyPersister"); } /** - * Gets the SQL parameters for the corresponding SQL statement to insert the given - * element of the given collection into the database. + * {@inheritdoc} * - * @param PersistentCollection $coll - * @param mixed $element + * @throws \BadMethodCallException Not used for OneToManyPersister. */ - protected function _getInsertRowSQLParameters(PersistentCollection $coll, $element) - {} - - /* Not used for OneToManyPersister */ - protected function _getUpdateRowSQL(PersistentCollection $coll) + protected function getInsertRowSQLParameters(PersistentCollection $coll, $element) { - return; + throw new \BadMethodCallException("Insert Row SQL is not used for OneToManyPersister"); } /** - * Generates the SQL UPDATE that updates all the foreign keys to null. + * {@inheritdoc} * - * @param PersistentCollection $coll + * @throws \BadMethodCallException Not used for OneToManyPersister. */ - protected function _getDeleteSQL(PersistentCollection $coll) + protected function getUpdateRowSQL(PersistentCollection $coll) { - + throw new \BadMethodCallException("Update Row SQL is not used for OneToManyPersister"); } /** - * Gets the SQL parameters for the corresponding SQL statement to delete - * the given collection. + * {@inheritdoc} * - * @param PersistentCollection $coll + * @throws \BadMethodCallException Not used for OneToManyPersister. */ - protected function _getDeleteSQLParameters(PersistentCollection $coll) - {} + protected function getDeleteSQL(PersistentCollection $coll) + { + throw new \BadMethodCallException("Update Row SQL is not used for OneToManyPersister"); + } + + /** + * {@inheritdoc} + * + * @throws \BadMethodCallException Not used for OneToManyPersister. + */ + protected function getDeleteSQLParameters(PersistentCollection $coll) + { + throw new \BadMethodCallException("Update Row SQL is not used for OneToManyPersister"); + } /** * {@inheritdoc} @@ -104,14 +135,15 @@ class OneToManyPersister extends AbstractCollectionPersister public function count(PersistentCollection $coll) { $mapping = $coll->getMapping(); - $targetClass = $this->_em->getClassMetadata($mapping['targetEntity']); - $sourceClass = $this->_em->getClassMetadata($mapping['sourceEntity']); - $id = $this->_em->getUnitOfWork()->getEntityIdentifier($coll->getOwner()); + $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); + $id = $this->em->getUnitOfWork()->getEntityIdentifier($coll->getOwner()); $whereClauses = array(); $params = array(); - foreach ($targetClass->associationMappings[$mapping['mappedBy']]['joinColumns'] as $joinColumn) { + $joinColumns = $targetClass->associationMappings[$mapping['mappedBy']]['joinColumns']; + foreach ($joinColumns as $joinColumn) { $whereClauses[] = $joinColumn['name'] . ' = ?'; $params[] = ($targetClass->containsForeignIdentifier) @@ -119,8 +151,8 @@ class OneToManyPersister extends AbstractCollectionPersister : $id[$sourceClass->fieldNames[$joinColumn['referencedColumnName']]]; } - $filterTargetClass = $this->_em->getClassMetadata($targetClass->rootEntityName); - foreach ($this->_em->getFilters()->getEnabledFilters() as $filter) { + $filterTargetClass = $this->em->getClassMetadata($targetClass->rootEntityName); + foreach ($this->em->getFilters()->getEnabledFilters() as $filter) { if ($filterExpr = $filter->addFilterConstraint($filterTargetClass, 't')) { $whereClauses[] = '(' . $filterExpr . ')'; } @@ -130,33 +162,35 @@ class OneToManyPersister extends AbstractCollectionPersister . ' FROM ' . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' t' . ' WHERE ' . implode(' AND ', $whereClauses); - return $this->_conn->fetchColumn($sql, $params); + return $this->conn->fetchColumn($sql, $params); } /** - * @param PersistentCollection $coll - * @param int $offset - * @param int $length + * @param \Doctrine\ORM\PersistentCollection $coll + * @param int $offset + * @param int|null $length + * * @return \Doctrine\Common\Collections\ArrayCollection */ public function slice(PersistentCollection $coll, $offset, $length = null) { $mapping = $coll->getMapping(); - $uow = $this->_em->getUnitOfWork(); + $uow = $this->em->getUnitOfWork(); $persister = $uow->getEntityPersister($mapping['targetEntity']); return $persister->getOneToManyCollection($mapping, $coll->getOwner(), $offset, $length); } /** - * @param PersistentCollection $coll - * @param object $element + * @param \Doctrine\ORM\PersistentCollection $coll + * @param object $element + * * @return boolean */ public function contains(PersistentCollection $coll, $element) { $mapping = $coll->getMapping(); - $uow = $this->_em->getUnitOfWork(); + $uow = $this->em->getUnitOfWork(); // shortcut for new entities $entityState = $uow->getEntityState($element, UnitOfWork::STATE_NEW); @@ -181,13 +215,14 @@ class OneToManyPersister extends AbstractCollectionPersister } /** - * @param PersistentCollection $coll - * @param object $element + * @param \Doctrine\ORM\PersistentCollection $coll + * @param object $element + * * @return boolean */ public function removeElement(PersistentCollection $coll, $element) { - $uow = $this->_em->getUnitOfWork(); + $uow = $this->em->getUnitOfWork(); // shortcut for new entities $entityState = $uow->getEntityState($element, UnitOfWork::STATE_NEW); @@ -203,10 +238,10 @@ class OneToManyPersister extends AbstractCollectionPersister } $mapping = $coll->getMapping(); - $class = $this->_em->getClassMetadata($mapping['targetEntity']); + $class = $this->em->getClassMetadata($mapping['targetEntity']); $sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform) . ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?'; - return (bool) $this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element)); + return (bool) $this->conn->executeUpdate($sql, $this->getDeleteRowSQLParameters($coll, $element)); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/PersisterException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/PersisterException.php new file mode 100644 index 0000000000..111455e5b8 --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/PersisterException.php @@ -0,0 +1,20 @@ +_class->getTableName(); + return $this->class->getTableName(); } - /** {@inheritdoc} */ - protected function _getSelectColumnListSQL() + /** + * {@inheritdoc} + */ + protected function getSelectColumnsSQL() { - if ($this->_selectColumnListSql !== null) { - return $this->_selectColumnListSql; + if ($this->selectColumnListSql !== null) { + return $this->selectColumnListSql; } - $columnList = parent::_getSelectColumnListSQL(); + $columnList[] = parent::getSelectColumnsSQL(); - $rootClass = $this->_em->getClassMetadata($this->_class->rootEntityName); - $tableAlias = $this->_getSQLTableAlias($rootClass->name); + $rootClass = $this->em->getClassMetadata($this->class->rootEntityName); + $tableAlias = $this->getSQLTableAlias($rootClass->name); // Append discriminator column - $discrColumn = $this->_class->discriminatorColumn['name']; - $columnList .= ', ' . $tableAlias . '.' . $discrColumn; + $discrColumn = $this->class->discriminatorColumn['name']; + $columnList[] = $tableAlias . '.' . $discrColumn; - $resultColumnName = $this->_platform->getSQLResultCasing($discrColumn); + $resultColumnName = $this->platform->getSQLResultCasing($discrColumn); - $this->_rsm->setDiscriminatorColumn('r', $resultColumnName); - $this->_rsm->addMetaResult('r', $resultColumnName, $discrColumn); + $this->rsm->setDiscriminatorColumn('r', $resultColumnName); + $this->rsm->addMetaResult('r', $resultColumnName, $discrColumn); // Append subclass columns - foreach ($this->_class->subClasses as $subClassName) { - $subClass = $this->_em->getClassMetadata($subClassName); + foreach ($this->class->subClasses as $subClassName) { + $subClass = $this->em->getClassMetadata($subClassName); // Regular columns foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if ( ! isset($mapping['inherited'])) { - $columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass); + if (isset($mapping['inherited'])) { + continue; } + + $columnList[] = $this->getSelectColumnSQL($fieldName, $subClass); } // Foreign key columns foreach ($subClass->associationMappings as $assoc) { - if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE && ! isset($assoc['inherited'])) { - foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) { - if ($columnList != '') $columnList .= ', '; + if ( ! $assoc['isOwningSide'] + || ! ($assoc['type'] & ClassMetadata::TO_ONE) + || isset($assoc['inherited'])) { + continue; + } - $columnList .= $this->getSelectJoinColumnSQL( - $tableAlias, - $srcColumn, - isset($assoc['inherited']) ? $assoc['inherited'] : $this->_class->name - ); - } + foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) { + $className = isset($assoc['inherited']) ? $assoc['inherited'] : $this->class->name; + $columnList[] = $this->getSelectJoinColumnSQL($tableAlias, $srcColumn, $className); } } } - $this->_selectColumnListSql = $columnList; - return $this->_selectColumnListSql; + $this->selectColumnListSql = implode(', ', $columnList); + + return $this->selectColumnListSql; } - /** {@inheritdoc} */ - protected function _getInsertColumnList() + /** + * {@inheritdoc} + */ + protected function getInsertColumnList() { - $columns = parent::_getInsertColumnList(); + $columns = parent::getInsertColumnList(); // Add discriminator column to the INSERT SQL - $columns[] = $this->_class->discriminatorColumn['name']; + $columns[] = $this->class->discriminatorColumn['name']; return $columns; } - /** {@inheritdoc} */ - protected function _getSQLTableAlias($className, $assocName = '') + /** + * {@inheritdoc} + */ + protected function getSQLTableAlias($className, $assocName = '') { - return parent::_getSQLTableAlias($this->_class->rootEntityName, $assocName); + return parent::getSQLTableAlias($this->class->rootEntityName, $assocName); } - /** {@inheritdoc} */ - protected function _getSelectConditionSQL(array $criteria, $assoc = null) + /** + * {@inheritdoc} + */ + protected function getSelectConditionSQL(array $criteria, $assoc = null) { - $conditionSql = parent::_getSelectConditionSQL($criteria, $assoc); + $conditionSql = parent::getSelectConditionSQL($criteria, $assoc); if ($conditionSql) { $conditionSql .= ' AND '; } - return $conditionSql . $this->_getSelectConditionDiscriminatorValueSQL(); + return $conditionSql . $this->getSelectConditionDiscriminatorValueSQL(); } - /** {@inheritdoc} */ - protected function _getSelectConditionCriteriaSQL(Criteria $criteria) + /** + * {@inheritdoc} + */ + protected function getSelectConditionCriteriaSQL(Criteria $criteria) { - $conditionSql = parent::_getSelectConditionCriteriaSQL($criteria); + $conditionSql = parent::getSelectConditionCriteriaSQL($criteria); if ($conditionSql) { $conditionSql .= ' AND '; } - return $conditionSql . $this->_getSelectConditionDiscriminatorValueSQL(); + return $conditionSql . $this->getSelectConditionDiscriminatorValueSQL(); } - protected function _getSelectConditionDiscriminatorValueSQL() + /** + * @return string + */ + protected function getSelectConditionDiscriminatorValueSQL() { $values = array(); - if ($this->_class->discriminatorValue !== null) { // discriminators can be 0 - $values[] = $this->_conn->quote($this->_class->discriminatorValue); + if ($this->class->discriminatorValue !== null) { // discriminators can be 0 + $values[] = $this->conn->quote($this->class->discriminatorValue); } - $discrValues = array_flip($this->_class->discriminatorMap); + $discrValues = array_flip($this->class->discriminatorMap); - foreach ($this->_class->subClasses as $subclassName) { - $values[] = $this->_conn->quote($discrValues[$subclassName]); + foreach ($this->class->subClasses as $subclassName) { + $values[] = $this->conn->quote($discrValues[$subclassName]); } - return $this->_getSQLTableAlias($this->_class->name) . '.' . $this->_class->discriminatorColumn['name'] - . ' IN (' . implode(', ', $values) . ')'; + $values = implode(', ', $values); + $discColumn = $this->class->discriminatorColumn['name']; + $tableAlias = $this->getSQLTableAlias($this->class->name); + + return $tableAlias . '.' . $discColumn . ' IN (' . $values . ')'; } - /** {@inheritdoc} */ + /** + * {@inheritdoc} + */ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) { // Ensure that the filters are applied to the root entity of the inheritance tree - $targetEntity = $this->_em->getClassMetadata($targetEntity->rootEntityName); - // we dont care about the $targetTableAlias, in a STI there is only one table. + $targetEntity = $this->em->getClassMetadata($targetEntity->rootEntityName); + // we don't care about the $targetTableAlias, in a STI there is only one table. return parent::generateFilterConditionSQL($targetEntity, $targetTableAlias); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php old mode 100755 new mode 100644 index 2fb685f989..7736943c6f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Persisters; +use Doctrine\ORM\Mapping\ClassMetadata; + use Doctrine\Common\Collections\Expr\ExpressionVisitor; use Doctrine\Common\Collections\Expr\Comparison; use Doctrine\Common\Collections\Expr\Value; @@ -37,16 +39,22 @@ class SqlExpressionVisitor extends ExpressionVisitor */ private $persister; + /** + * @var \Doctrine\ORM\Mapping\ClassMetadata + */ + private $classMetadata; + /** * @param \Doctrine\ORM\Persisters\BasicEntityPersister $persister */ - public function __construct(BasicEntityPersister $persister) + public function __construct(BasicEntityPersister $persister, ClassMetadata $classMetadata) { $this->persister = $persister; + $this->classMetadata = $classMetadata; } /** - * Convert a comparison expression into the target query language output + * Converts a comparison expression into the target query language output. * * @param \Doctrine\Common\Collections\Expr\Comparison $comparison * @@ -57,15 +65,25 @@ class SqlExpressionVisitor extends ExpressionVisitor $field = $comparison->getField(); $value = $comparison->getValue()->getValue(); // shortcut for walkValue() + if (isset($this->classMetadata->associationMappings[$field]) && + $value !== null && + ! is_object($value) && + ! in_array($comparison->getOperator(), array(Comparison::IN, Comparison::NIN))) { + + throw PersisterException::matchingAssocationFieldRequiresObject($this->classMetadata->name, $field); + } + return $this->persister->getSelectConditionStatementSQL($field, $value, null, $comparison->getOperator()); } /** - * Convert a composite expression into the target query language output + * Converts a composite expression into the target query language output. * * @param \Doctrine\Common\Collections\Expr\CompositeExpression $expr * * @return mixed + * + * @throws \RuntimeException */ public function walkCompositeExpression(CompositeExpression $expr) { @@ -88,7 +106,7 @@ class SqlExpressionVisitor extends ExpressionVisitor } /** - * Convert a value expression into the target query language part. + * Converts a value expression into the target query language part. * * @param \Doctrine\Common\Collections\Expr\Value $value * diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php old mode 100755 new mode 100644 index aa4d68d395..0e680ad078 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php @@ -24,11 +24,6 @@ use Doctrine\Common\Collections\Expr\Comparison; use Doctrine\Common\Collections\Expr\Value; use Doctrine\Common\Collections\Expr\CompositeExpression; -use Doctrine\ORM\Mapping\ClassMetadata; - -use Doctrine\DBAL\Types\Type; -use Doctrine\DBAL\Connection; - /** * Extract the values from a criteria/expression * @@ -47,7 +42,7 @@ class SqlValueVisitor extends ExpressionVisitor private $types = array(); /** - * Convert a comparison expression into the target query language output + * Converts a comparison expression into the target query language output. * * @param \Doctrine\Common\Collections\Expr\Comparison $comparison * @@ -55,15 +50,22 @@ class SqlValueVisitor extends ExpressionVisitor */ public function walkComparison(Comparison $comparison) { - $value = $comparison->getValue()->getValue(); + $value = $this->getValueFromComparison($comparison); $field = $comparison->getField(); - + $operator = $comparison->getOperator(); + + if (($operator === Comparison::EQ || $operator === Comparison::IS) && $value === null) { + return; + } else if ($operator === Comparison::NEQ && $value === null) { + return; + } + $this->values[] = $value; $this->types[] = array($field, $value); } /** - * Convert a composite expression into the target query language output + * Converts a composite expression into the target query language output. * * @param \Doctrine\Common\Collections\Expr\CompositeExpression $expr * @@ -77,7 +79,7 @@ class SqlValueVisitor extends ExpressionVisitor } /** - * Convert a value expression into the target query language part. + * Converts a value expression into the target query language part. * * @param \Doctrine\Common\Collections\Expr\Value $value * @@ -89,7 +91,7 @@ class SqlValueVisitor extends ExpressionVisitor } /** - * Return the Parameters and Types necessary for matching the last visited expression. + * Returns the Parameters and Types necessary for matching the last visited expression. * * @return array */ @@ -97,4 +99,20 @@ class SqlValueVisitor extends ExpressionVisitor { return array($this->values, $this->types); } + + /** + * Returns the value from a Comparison. In case of a CONTAINS comparison, + * the value is wrapped in %-signs, because it will be used in a LIKE clause. + * + * @param \Doctrine\Common\Collections\Expr\Comparison $comparison + * @return mixed + */ + protected function getValueFromComparison(Comparison $comparison) + { + $value = $comparison->getValue()->getValue(); + + return $comparison->getOperator() == Comparison::CONTAINS + ? "%{$value}%" + : $value; + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/UnionSubclassPersister.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/UnionSubclassPersister.php old mode 100755 new mode 100644 index ef844a7067..d27dcc9fd1 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/UnionSubclassPersister.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/UnionSubclassPersister.php @@ -1,8 +1,24 @@ . + */ namespace Doctrine\ORM\Persisters; class UnionSubclassPersister extends BasicEntityPersister { - -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/PessimisticLockException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/PessimisticLockException.php old mode 100755 new mode 100644 index 5939e282f3..2bc93bffe5 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/PessimisticLockException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/PessimisticLockException.php @@ -30,6 +30,9 @@ namespace Doctrine\ORM; */ class PessimisticLockException extends ORMException { + /** + * @return PessimisticLockException + */ public static function lockFailed() { return new self("The pessimistic lock failed."); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/Autoloader.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/Autoloader.php old mode 100755 new mode 100644 index 0b4d9a0194..9b2e2cdfa1 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/Autoloader.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/Autoloader.php @@ -19,60 +19,11 @@ namespace Doctrine\ORM\Proxy; +use Doctrine\Common\Proxy\Autoloader as BaseAutoloader; + /** - * Special Autoloader for Proxy classes because them not being PSR-0 compatible. - * - * @author Benjamin Eberlei + * @deprecated use \Doctrine\Common\Proxy\Autoloader instead */ -class Autoloader +class Autoloader extends BaseAutoloader { - /** - * Resolve proxy class name to a filename based on the following pattern. - * - * 1. Remove Proxy namespace from class name - * 2. Remove namespace seperators from remaining class name. - * 3. Return PHP filename from proxy-dir with the result from 2. - * - * @param string $proxyDir - * @param string $proxyNamespace - * @param string $className - * @return string - */ - static public function resolveFile($proxyDir, $proxyNamespace, $className) - { - if (0 !== strpos($className, $proxyNamespace)) { - throw ProxyException::notProxyClass($className, $proxyNamespace); - } - - $className = str_replace('\\', '', substr($className, strlen($proxyNamespace) +1)); - return $proxyDir . DIRECTORY_SEPARATOR . $className.'.php'; - } - - /** - * Register and return autoloader callback for the given proxy dir and - * namespace. - * - * @param string $proxyDir - * @param string $proxyNamespace - * @param Closure $notFoundCallback Invoked when the proxy file is not found. - * @return Closure - */ - static public function register($proxyDir, $proxyNamespace, \Closure $notFoundCallback = null) - { - $proxyNamespace = ltrim($proxyNamespace, "\\"); - $autoloader = function($className) use ($proxyDir, $proxyNamespace, $notFoundCallback) { - if (0 === strpos($className, $proxyNamespace)) { - $file = Autoloader::resolveFile($proxyDir, $proxyNamespace, $className); - - if ($notFoundCallback && ! file_exists($file)) { - $notFoundCallback($proxyDir, $proxyNamespace, $className); - } - - require $file; - } - }; - spl_autoload_register($autoloader); - return $autoloader; - } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/Proxy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/Proxy.php old mode 100755 new mode 100644 index 47cda90270..f478d4905c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/Proxy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/Proxy.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Proxy; -use Doctrine\Common\Persistence\Proxy as BaseProxy; +use Doctrine\Common\Proxy\Proxy as BaseProxy; /** * Interface for proxy classes. @@ -27,4 +27,6 @@ use Doctrine\Common\Persistence\Proxy as BaseProxy; * @author Roman Borschel * @since 2.0 */ -interface Proxy extends BaseProxy {} +interface Proxy extends BaseProxy +{ +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php old mode 100755 new mode 100644 index df74207e7f..dfac9a3e79 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -19,392 +19,200 @@ namespace Doctrine\ORM\Proxy; -use Doctrine\ORM\EntityManager, - Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\Common\Util\ClassUtils; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Proxy\AbstractProxyFactory; +use Doctrine\Common\Proxy\ProxyDefinition; +use Doctrine\Common\Util\ClassUtils; +use Doctrine\Common\Proxy\Proxy as BaseProxy; +use Doctrine\Common\Proxy\ProxyGenerator; +use Doctrine\ORM\ORMInvalidArgumentException; +use Doctrine\ORM\Persisters\BasicEntityPersister; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityNotFoundException; /** * This factory is used to create proxy objects for entities at runtime. * * @author Roman Borschel * @author Giorgio Sironi + * @author Marco Pivetta * @since 2.0 */ -class ProxyFactory +class ProxyFactory extends AbstractProxyFactory { - /** The EntityManager this factory is bound to. */ - private $_em; - /** Whether to automatically (re)generate proxy classes. */ - private $_autoGenerate; - /** The namespace that contains all proxy classes. */ - private $_proxyNamespace; - /** The directory that contains all proxy classes. */ - private $_proxyDir; + /** + * @var \Doctrine\ORM\EntityManager The EntityManager this factory is bound to. + */ + private $em; + + /** + * @var \Doctrine\ORM\UnitOfWork The UnitOfWork this factory uses to retrieve persisters + */ + private $uow; /** - * Used to match very simple id methods that don't need - * to be proxied since the identifier is known. - * * @var string */ - const PATTERN_MATCH_ID_METHOD = '((public\s)?(function\s{1,}%s\s?\(\)\s{1,})\s{0,}{\s{0,}return\s{0,}\$this->%s;\s{0,}})i'; + private $proxyNs; /** * Initializes a new instance of the ProxyFactory class that is * connected to the given EntityManager. * - * @param EntityManager $em The EntityManager the new factory works for. - * @param string $proxyDir The directory to use for the proxy classes. It must exist. - * @param string $proxyNs The namespace to use for the proxy classes. - * @param boolean $autoGenerate Whether to automatically generate proxy classes. + * @param \Doctrine\ORM\EntityManager $em The EntityManager the new factory works for. + * @param string $proxyDir The directory to use for the proxy classes. It must exist. + * @param string $proxyNs The namespace to use for the proxy classes. + * @param boolean $autoGenerate Whether to automatically generate proxy classes. */ public function __construct(EntityManager $em, $proxyDir, $proxyNs, $autoGenerate = false) { - if ( ! $proxyDir) { - throw ProxyException::proxyDirectoryRequired(); - } - if ( ! $proxyNs) { - throw ProxyException::proxyNamespaceRequired(); - } - $this->_em = $em; - $this->_proxyDir = $proxyDir; - $this->_autoGenerate = $autoGenerate; - $this->_proxyNamespace = $proxyNs; + $proxyGenerator = new ProxyGenerator($proxyDir, $proxyNs); + + $proxyGenerator->setPlaceholder('baseProxyInterface', 'Doctrine\ORM\Proxy\Proxy'); + parent::__construct($proxyGenerator, $em->getMetadataFactory(), $autoGenerate); + + $this->em = $em; + $this->uow = $em->getUnitOfWork(); + $this->proxyNs = $proxyNs; + } /** - * Gets a reference proxy instance for the entity of the given type and identified by - * the given identifier. - * - * @param string $className - * @param mixed $identifier - * @return object + * {@inheritDoc} */ - public function getProxy($className, $identifier) + protected function skipClass(ClassMetadata $metadata) { - $fqn = ClassUtils::generateProxyClassName($className, $this->_proxyNamespace); - - if (! class_exists($fqn, false)) { - $fileName = $this->getProxyFileName($className); - if ($this->_autoGenerate) { - $this->_generateProxyClass($this->_em->getClassMetadata($className), $fileName, self::$_proxyClassTemplate); - } - require $fileName; - } - - $entityPersister = $this->_em->getUnitOfWork()->getEntityPersister($className); - - return new $fqn($entityPersister, $identifier); + /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */ + return $metadata->isMappedSuperclass || $metadata->getReflectionClass()->isAbstract(); } /** - * Generate the Proxy file name - * - * @param string $className - * @param string $baseDir Optional base directory for proxy file name generation. - * If not specified, the directory configured on the Configuration of the - * EntityManager will be used by this factory. - * @return string + * {@inheritDoc} */ - private function getProxyFileName($className, $baseDir = null) + protected function createProxyDefinition($className) { - $proxyDir = $baseDir ?: $this->_proxyDir; + $classMetadata = $this->em->getClassMetadata($className); + $entityPersister = $this->uow->getEntityPersister($className); - return $proxyDir . DIRECTORY_SEPARATOR . '__CG__' . str_replace('\\', '', $className) . '.php'; - } - - /** - * Generates proxy classes for all given classes. - * - * @param array $classes The classes (ClassMetadata instances) for which to generate proxies. - * @param string $toDir The target directory of the proxy classes. If not specified, the - * directory configured on the Configuration of the EntityManager used - * by this factory is used. - * @return int Number of generated proxies. - */ - public function generateProxyClasses(array $classes, $toDir = null) - { - $proxyDir = $toDir ?: $this->_proxyDir; - $proxyDir = rtrim($proxyDir, DIRECTORY_SEPARATOR); - $num = 0; - - foreach ($classes as $class) { - /* @var $class ClassMetadata */ - if ($class->isMappedSuperclass || $class->reflClass->isAbstract()) { - continue; - } - - $proxyFileName = $this->getProxyFileName($class->name, $proxyDir); - - $this->_generateProxyClass($class, $proxyFileName, self::$_proxyClassTemplate); - $num++; - } - - return $num; - } - - /** - * Generates a proxy class file. - * - * @param ClassMetadata $class Metadata for the original class - * @param string $fileName Filename (full path) for the generated class - * @param string $file The proxy class template data - */ - private function _generateProxyClass(ClassMetadata $class, $fileName, $file) - { - $methods = $this->_generateMethods($class); - $sleepImpl = $this->_generateSleep($class); - $cloneImpl = $class->reflClass->hasMethod('__clone') ? 'parent::__clone();' : ''; // hasMethod() checks case-insensitive - - $placeholders = array( - '', - '', '', - '', '', '' + return new ProxyDefinition( + ClassUtils::generateProxyClassName($className, $this->proxyNs), + $classMetadata->getIdentifierFieldNames(), + $classMetadata->getReflectionProperties(), + $this->createInitializer($classMetadata, $entityPersister), + $this->createCloner($classMetadata, $entityPersister) ); - - $className = ltrim($class->name, '\\'); - $proxyClassName = ClassUtils::generateProxyClassName($class->name, $this->_proxyNamespace); - $parts = explode('\\', strrev($proxyClassName), 2); - $proxyClassNamespace = strrev($parts[1]); - $proxyClassName = strrev($parts[0]); - - $replacements = array( - $proxyClassNamespace, - $proxyClassName, - $className, - $methods, - $sleepImpl, - $cloneImpl - ); - - $file = str_replace($placeholders, $replacements, $file); - - $parentDirectory = dirname($fileName); - - if ( ! is_dir($parentDirectory)) { - if (false === @mkdir($parentDirectory, 0775, true)) { - throw ProxyException::proxyDirectoryNotWritable(); - } - } else if ( ! is_writable($parentDirectory)) { - throw ProxyException::proxyDirectoryNotWritable(); - } - - $tmpFileName = $fileName . '.' . uniqid("", true); - file_put_contents($tmpFileName, $file); - rename($tmpFileName, $fileName); } /** - * Generates the methods of a proxy class. + * Creates a closure capable of initializing a proxy * - * @param ClassMetadata $class - * @return string The code of the generated methods. + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata + * @param \Doctrine\ORM\Persisters\BasicEntityPersister $entityPersister + * + * @return \Closure + * + * @throws \Doctrine\ORM\EntityNotFoundException */ - private function _generateMethods(ClassMetadata $class) + private function createInitializer(ClassMetadata $classMetadata, BasicEntityPersister $entityPersister) { - $methods = ''; + if ($classMetadata->getReflectionClass()->hasMethod('__wakeup')) { + return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) { + $initializer = $proxy->__getInitializer(); + $cloner = $proxy->__getCloner(); - $methodNames = array(); - foreach ($class->reflClass->getMethods() as $method) { - /* @var $method ReflectionMethod */ - if ($method->isConstructor() || in_array(strtolower($method->getName()), array("__sleep", "__clone")) || isset($methodNames[$method->getName()])) { - continue; - } - $methodNames[$method->getName()] = true; + $proxy->__setInitializer(null); + $proxy->__setCloner(null); - if ($method->isPublic() && ! $method->isFinal() && ! $method->isStatic()) { - $methods .= "\n" . ' public function '; - if ($method->returnsReference()) { - $methods .= '&'; + if ($proxy->__isInitialized()) { + return; } - $methods .= $method->getName() . '('; - $firstParam = true; - $parameterString = $argumentString = ''; - foreach ($method->getParameters() as $param) { - if ($firstParam) { - $firstParam = false; - } else { - $parameterString .= ', '; - $argumentString .= ', '; - } + $properties = $proxy->__getLazyProperties(); - // We need to pick the type hint class too - if (($paramClass = $param->getClass()) !== null) { - $parameterString .= '\\' . $paramClass->getName() . ' '; - } else if ($param->isArray()) { - $parameterString .= 'array '; - } - - if ($param->isPassedByReference()) { - $parameterString .= '&'; - } - - $parameterString .= '$' . $param->getName(); - $argumentString .= '$' . $param->getName(); - - if ($param->isDefaultValueAvailable()) { - $parameterString .= ' = ' . var_export($param->getDefaultValue(), true); + foreach ($properties as $propertyName => $property) { + if (!isset($proxy->$propertyName)) { + $proxy->$propertyName = $properties[$propertyName]; } } - $methods .= $parameterString . ')'; - $methods .= "\n" . ' {' . "\n"; - if ($this->isShortIdentifierGetter($method, $class)) { - $identifier = lcfirst(substr($method->getName(), 3)); + $proxy->__setInitialized(true); + $proxy->__wakeup(); - $cast = in_array($class->fieldMappings[$identifier]['type'], array('integer', 'smallint')) ? '(int) ' : ''; + if (null === $entityPersister->load($classMetadata->getIdentifierValues($proxy), $proxy)) { + $proxy->__setInitializer($initializer); + $proxy->__setCloner($cloner); + $proxy->__setInitialized(false); - $methods .= ' if ($this->__isInitialized__ === false) {' . "\n"; - $methods .= ' return ' . $cast . '$this->_identifier["' . $identifier . '"];' . "\n"; - $methods .= ' }' . "\n"; + throw new EntityNotFoundException(); } - $methods .= ' $this->__load();' . "\n"; - $methods .= ' return parent::' . $method->getName() . '(' . $argumentString . ');'; - $methods .= "\n" . ' }' . "\n"; - } + }; } - return $methods; + return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) { + $initializer = $proxy->__getInitializer(); + $cloner = $proxy->__getCloner(); + + $proxy->__setInitializer(null); + $proxy->__setCloner(null); + + if ($proxy->__isInitialized()) { + return; + } + + $properties = $proxy->__getLazyProperties(); + + foreach ($properties as $propertyName => $property) { + if (!isset($proxy->$propertyName)) { + $proxy->$propertyName = $properties[$propertyName]; + } + } + + $proxy->__setInitialized(true); + + if (null === $entityPersister->load($classMetadata->getIdentifierValues($proxy), $proxy)) { + $proxy->__setInitializer($initializer); + $proxy->__setCloner($cloner); + $proxy->__setInitialized(false); + + throw new EntityNotFoundException(); + } + }; } /** - * Check if the method is a short identifier getter. + * Creates a closure capable of finalizing state a cloned proxy * - * What does this mean? For proxy objects the identifier is already known, - * however accessing the getter for this identifier usually triggers the - * lazy loading, leading to a query that may not be necessary if only the - * ID is interesting for the userland code (for example in views that - * generate links to the entity, but do not display anything else). + * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata + * @param \Doctrine\ORM\Persisters\BasicEntityPersister $entityPersister * - * @param ReflectionMethod $method - * @param ClassMetadata $class - * @return bool + * @return \Closure + * + * @throws \Doctrine\ORM\EntityNotFoundException */ - private function isShortIdentifierGetter($method, ClassMetadata $class) + private function createCloner(ClassMetadata $classMetadata, BasicEntityPersister $entityPersister) { - $identifier = lcfirst(substr($method->getName(), 3)); - $cheapCheck = ( - $method->getNumberOfParameters() == 0 && - substr($method->getName(), 0, 3) == "get" && - in_array($identifier, $class->identifier, true) && - $class->hasField($identifier) && - (($method->getEndLine() - $method->getStartLine()) <= 4) - && in_array($class->fieldMappings[$identifier]['type'], array('integer', 'bigint', 'smallint', 'string')) - ); - - if ($cheapCheck) { - $code = file($method->getDeclaringClass()->getFileName()); - $code = trim(implode(" ", array_slice($code, $method->getStartLine() - 1, $method->getEndLine() - $method->getStartLine() + 1))); - - $pattern = sprintf(self::PATTERN_MATCH_ID_METHOD, $method->getName(), $identifier); - - if (preg_match($pattern, $code)) { - return true; + return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) { + if ($proxy->__isInitialized()) { + return; } - } - return false; - } - /** - * Generates the code for the __sleep method for a proxy class. - * - * @param $class - * @return string - */ - private function _generateSleep(ClassMetadata $class) - { - $sleepImpl = ''; + $proxy->__setInitialized(true); + $proxy->__setInitializer(null); + $class = $entityPersister->getClassMetadata(); + $original = $entityPersister->load($classMetadata->getIdentifierValues($proxy)); - if ($class->reflClass->hasMethod('__sleep')) { - $sleepImpl .= "return array_merge(array('__isInitialized__'), parent::__sleep());"; - } else { - $sleepImpl .= "return array('__isInitialized__', "; - $first = true; + if (null === $original) { + throw new EntityNotFoundException(); + } - foreach ($class->getReflectionProperties() as $name => $prop) { - if ($first) { - $first = false; - } else { - $sleepImpl .= ', '; + foreach ($class->getReflectionClass()->getProperties() as $reflectionProperty) { + $propertyName = $reflectionProperty->getName(); + + if ($class->hasField($propertyName) || $class->hasAssociation($propertyName)) { + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($proxy, $reflectionProperty->getValue($original)); } - - $sleepImpl .= "'" . $name . "'"; } - - $sleepImpl .= ');'; - } - - return $sleepImpl; + }; } - - /** Proxy class code template */ - private static $_proxyClassTemplate = -'; - -/** - * THIS CLASS WAS GENERATED BY THE DOCTRINE ORM. DO NOT EDIT THIS FILE. - */ -class extends \ implements \Doctrine\ORM\Proxy\Proxy -{ - private $_entityPersister; - private $_identifier; - public $__isInitialized__ = false; - public function __construct($entityPersister, $identifier) - { - $this->_entityPersister = $entityPersister; - $this->_identifier = $identifier; - } - /** @private */ - public function __load() - { - if (!$this->__isInitialized__ && $this->_entityPersister) { - $this->__isInitialized__ = true; - - if (method_exists($this, "__wakeup")) { - // call this after __isInitialized__to avoid infinite recursion - // but before loading to emulate what ClassMetadata::newInstance() - // provides. - $this->__wakeup(); - } - - if ($this->_entityPersister->load($this->_identifier, $this) === null) { - throw new \Doctrine\ORM\EntityNotFoundException(); - } - unset($this->_entityPersister, $this->_identifier); - } - } - - /** @private */ - public function __isInitialized() - { - return $this->__isInitialized__; - } - - - - public function __sleep() - { - - } - - public function __clone() - { - if (!$this->__isInitialized__ && $this->_entityPersister) { - $this->__isInitialized__ = true; - $class = $this->_entityPersister->getClassMetadata(); - $original = $this->_entityPersister->load($this->_identifier); - if ($original === null) { - throw new \Doctrine\ORM\EntityNotFoundException(); - } - foreach ($class->reflFields as $field => $reflProperty) { - $reflProperty->setValue($this, $reflProperty->getValue($original)); - } - unset($this->_entityPersister, $this->_identifier); - } - - } -}'; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php old mode 100755 new mode 100644 index 2e1b8178b9..71f5f5550c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php @@ -26,6 +26,8 @@ use Doctrine\DBAL\LockMode; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\ParserResult; use Doctrine\ORM\Query\QueryException; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Query\ParameterTypeInferer; /** * A Query object represents a DQL query. @@ -41,6 +43,7 @@ final class Query extends AbstractQuery * A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts. */ const STATE_CLEAN = 1; + /** * A query object is in state DIRTY when it has DQL parts that have not yet been * parsed/processed. This is automatically defined as DIRTY when addDqlQueryPart @@ -49,6 +52,7 @@ final class Query extends AbstractQuery const STATE_DIRTY = 2; /* Query HINTS */ + /** * The refresh hint turns any query into a refresh query with the result that * any local changes in entities are overridden with the fetched values. @@ -57,7 +61,6 @@ final class Query extends AbstractQuery */ const HINT_REFRESH = 'doctrine.refresh'; - /** * Internal hint: is set to the proxy entity that is currently triggered for loading * @@ -73,6 +76,7 @@ final class Query extends AbstractQuery * @todo Rename: HINT_OPTIMIZE */ const HINT_FORCE_PARTIAL_LOAD = 'doctrine.forcePartialLoad'; + /** * The includeMetaColumns query hint causes meta columns like foreign keys and * discriminator columns to be selected and returned as part of the query result. @@ -111,49 +115,66 @@ final class Query extends AbstractQuery */ const HINT_LOCK_MODE = 'doctrine.lockMode'; - /** - * @var integer $_state The current state of this query. + * The current state of this query. + * + * @var integer */ private $_state = self::STATE_CLEAN; /** - * @var string $_dql Cached DQL query. + * Cached DQL query. + * + * @var string */ private $_dql = null; /** - * @var \Doctrine\ORM\Query\ParserResult The parser result that holds DQL => SQL information. + * The parser result that holds DQL => SQL information. + * + * @var \Doctrine\ORM\Query\ParserResult */ private $_parserResult; /** - * @var integer The first result to return (the "offset"). + * The first result to return (the "offset"). + * + * @var integer */ private $_firstResult = null; /** - * @var integer The maximum number of results to return (the "limit"). + * The maximum number of results to return (the "limit"). + * + * @var integer */ private $_maxResults = null; /** - * @var CacheDriver The cache driver used for caching queries. + * The cache driver used for caching queries. + * + * @var \Doctrine\Common\Cache\Cache|null */ private $_queryCache; /** - * @var boolean Boolean value that indicates whether or not expire the query cache. + * Whether or not expire the query cache. + * + * @var boolean */ private $_expireQueryCache = false; /** - * @var int Query Cache lifetime. + * The query cache lifetime. + * + * @var int */ private $_queryCacheTTL; /** - * @var boolean Whether to use a query cache, if available. Defaults to TRUE. + * Whether to use a query cache, if available. Defaults to TRUE. + * + * @var boolean */ private $_useQueryCache = true; @@ -171,6 +192,7 @@ final class Query extends AbstractQuery * Gets the SQL query/queries that correspond to this DQL query. * * @return mixed The built sql query or an array of all sql queries. + * * @override */ public function getSQL() @@ -248,6 +270,10 @@ final class Query extends AbstractQuery $executor->setQueryCacheProfile($this->_queryCacheProfile); } + if ($this->_resultSetMapping === null) { + $this->_resultSetMapping = $this->_parserResult->getResultSetMapping(); + } + // Prepare parameters $paramMappings = $this->_parserResult->getParameterMappings(); @@ -257,18 +283,17 @@ final class Query extends AbstractQuery list($sqlParams, $types) = $this->processParameterMappings($paramMappings); - if ($this->_resultSetMapping === null) { - $this->_resultSetMapping = $this->_parserResult->getResultSetMapping(); - } - return $executor->execute($this->_em->getConnection(), $sqlParams, $types); } /** - * Processes query parameter mappings + * Processes query parameter mappings. * * @param array $paramMappings + * * @return array + * + * @throws Query\QueryException */ private function processParameterMappings($paramMappings) { @@ -276,16 +301,21 @@ final class Query extends AbstractQuery $types = array(); foreach ($this->parameters as $parameter) { - $key = $parameter->getName(); + $key = $parameter->getName(); + $value = $parameter->getValue(); if ( ! isset($paramMappings[$key])) { throw QueryException::unknownParameter($key); } - $value = $this->processParameterValue($parameter->getValue()); + if (isset($this->_resultSetMapping->metadataParameterMapping[$key]) && $value instanceof ClassMetadata) { + $value = $value->getMetadataValue($this->_resultSetMapping->metadataParameterMapping[$key]); + } + + $value = $this->processParameterValue($value); $type = ($parameter->getValue() === $value) ? $parameter->getType() - : Query\ParameterTypeInferer::inferType($value); + : ParameterTypeInferer::inferType($value); foreach ($paramMappings[$key] as $position) { $types[$position] = $type; @@ -304,7 +334,7 @@ final class Query extends AbstractQuery } if (count($sqlParams) != count($types)) { - throw QueryException::parameterTypeMissmatch(); + throw QueryException::parameterTypeMismatch(); } if ($sqlParams) { @@ -321,7 +351,8 @@ final class Query extends AbstractQuery /** * Defines a cache driver to be used for caching queries. * - * @param Doctrine_Cache_Interface|null $driver Cache driver + * @param \Doctrine\Common\Cache\Cache|null $queryCache Cache driver. + * * @return Query This query instance. */ public function setQueryCacheDriver($queryCache) @@ -335,7 +366,8 @@ final class Query extends AbstractQuery * Defines whether the query should make use of a query cache, if available. * * @param boolean $bool - * @return @return Query This query instance. + * + * @return Query This query instance. */ public function useQueryCache($bool) { @@ -347,8 +379,8 @@ final class Query extends AbstractQuery /** * Returns the cache driver used for query caching. * - * @return CacheDriver The cache driver used for query caching or NULL, if - * this Query does not use query caching. + * @return \Doctrine\Common\Cache\Cache|null The cache driver used for query caching or NULL, if + * this Query does not use query caching. */ public function getQueryCacheDriver() { @@ -362,7 +394,8 @@ final class Query extends AbstractQuery /** * Defines how long the query cache will be active before expire. * - * @param integer $timeToLive How long the cache entry is valid + * @param integer $timeToLive How long the cache entry is valid. + * * @return Query This query instance. */ public function setQueryCacheLifetime($timeToLive) @@ -390,6 +423,7 @@ final class Query extends AbstractQuery * Defines if the query cache is active or not. * * @param boolean $expire Whether or not to force query cache expiration. + * * @return Query This query instance. */ public function expireQueryCache($expire = true) @@ -423,7 +457,8 @@ final class Query extends AbstractQuery /** * Sets a DQL query string. * - * @param string $dqlQuery DQL Query + * @param string $dqlQuery DQL Query. + * * @return \Doctrine\ORM\AbstractQuery */ public function setDQL($dqlQuery) @@ -439,7 +474,7 @@ final class Query extends AbstractQuery /** * Returns the DQL query that is represented by this query object. * - * @return string DQL query + * @return string DQL query. */ public function getDQL() { @@ -454,7 +489,7 @@ final class Query extends AbstractQuery * @see AbstractQuery::STATE_CLEAN * @see AbstractQuery::STATE_DIRTY * - * @return integer Return the query state + * @return integer The query state. */ public function getState() { @@ -464,7 +499,8 @@ final class Query extends AbstractQuery /** * Method to check if an arbitrary piece of DQL exists * - * @param string $dql Arbitrary piece of DQL to check for + * @param string $dql Arbitrary piece of DQL to check for. + * * @return boolean */ public function contains($dql) @@ -476,6 +512,7 @@ final class Query extends AbstractQuery * Sets the position of the first result to retrieve (the "offset"). * * @param integer $firstResult The first result to return. + * * @return Query This query object. */ public function setFirstResult($firstResult) @@ -501,6 +538,7 @@ final class Query extends AbstractQuery * Sets the maximum number of results to retrieve (the "limit"). * * @param integer $maxResults + * * @return Query This query object. */ public function setMaxResults($maxResults) @@ -526,8 +564,9 @@ final class Query extends AbstractQuery * Executes the query and returns an IterableResult that can be used to incrementally * iterated over the result. * - * @param \Doctrine\Common\Collections\ArrayCollection|array $parameters The query parameters. - * @param integer $hydrationMode The hydration mode to use. + * @param ArrayCollection|array|null $parameters The query parameters. + * @param integer $hydrationMode The hydration mode to use. + * * @return \Doctrine\ORM\Internal\Hydration\IterableResult */ public function iterate($parameters = null, $hydrationMode = self::HYDRATE_OBJECT) @@ -561,8 +600,12 @@ final class Query extends AbstractQuery * Set the lock mode for this Query. * * @see \Doctrine\DBAL\LockMode + * * @param int $lockMode + * * @return Query + * + * @throws TransactionRequiredException */ public function setLockMode($lockMode) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ASTException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ASTException.php old mode 100755 new mode 100644 index 4633322a1a..b8f931b45e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ASTException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ASTException.php @@ -26,8 +26,13 @@ use Doctrine\ORM\Query\QueryException; */ class ASTException extends QueryException { + /** + * @param Node $node + * + * @return ASTException + */ public static function noDispatchForNode($node) { return new self("Double-dispatch for node " . get_class($node) . " is not supported."); } -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/AggregateExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/AggregateExpression.php old mode 100755 new mode 100644 index ec91ada24f..0966d902b8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/AggregateExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/AggregateExpression.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\AST; /** - * Description of AggregateExpression + * Description of AggregateExpression. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,10 +30,28 @@ namespace Doctrine\ORM\Query\AST; */ class AggregateExpression extends Node { + /** + * @var string + */ public $functionName; - public $pathExpression; - public $isDistinct = false; // Some aggregate expressions support distinct, eg COUNT + /** + * @var PathExpression|SimpleArithmeticExpression + */ + public $pathExpression; + + /** + * Some aggregate expressions support distinct, eg COUNT. + * + * @var bool + */ + public $isDistinct = false; + + /** + * @param string $functionName + * @param PathExpression|SimpleArithmeticExpression $pathExpression + * @param bool $isDistinct + */ public function __construct($functionName, $pathExpression, $isDistinct) { $this->functionName = $functionName; @@ -42,6 +59,9 @@ class AggregateExpression extends Node $this->isDistinct = $isDistinct; } + /** + * {@inheritdoc} + */ public function dispatch($walker) { return $walker->walkAggregateExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php old mode 100755 new mode 100644 index 55a6b0602b..b586cba308 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")" * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,19 +30,35 @@ namespace Doctrine\ORM\Query\AST; */ class ArithmeticExpression extends Node { + /** + * @var SimpleArithmeticExpression|null + */ public $simpleArithmeticExpression; + + /** + * @var Subselect|null + */ public $subselect; + /** + * @return bool + */ public function isSimpleArithmeticExpression() { return (bool) $this->simpleArithmeticExpression; } + /** + * @return bool + */ public function isSubselect() { return (bool) $this->subselect; } + /** + * {@inheritdoc} + */ public function dispatch($walker) { return $walker->walkArithmeticExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php old mode 100755 new mode 100644 index 8d595efc4a..3120466fd8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -32,31 +31,46 @@ namespace Doctrine\ORM\Query\AST; class ArithmeticFactor extends Node { /** - * @var ArithmeticPrimary + * @var mixed */ public $arithmeticPrimary; /** - * @var null|boolean NULL represents no sign, TRUE means positive and FALSE means negative sign + * NULL represents no sign, TRUE means positive and FALSE means negative sign. + * + * @var null|boolean */ public $sign; + /** + * @param mixed $arithmeticPrimary + * @param null|bool $sign + */ public function __construct($arithmeticPrimary, $sign = null) { $this->arithmeticPrimary = $arithmeticPrimary; $this->sign = $sign; } + /** + * @return bool + */ public function isPositiveSigned() { return $this->sign === true; } + /** + * @return bool + */ public function isNegativeSigned() { return $this->sign === false; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkArithmeticFactor($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php old mode 100755 new mode 100644 index ced25e99f3..e08ae7fbb8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}* * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class ArithmeticTerm extends Node { + /** + * @var array + */ public $arithmeticFactors; + /** + * @param array $arithmeticFactors + */ public function __construct(array $arithmeticFactors) { $this->arithmeticFactors = $arithmeticFactors; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkArithmeticTerm($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/BetweenExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/BetweenExpression.php old mode 100755 new mode 100644 index 83ba6cafd7..1e31fd1a5a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/BetweenExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/BetweenExpression.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\AST; /** - * Description of BetweenExpression + * Description of BetweenExpression. * - * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,11 +30,31 @@ namespace Doctrine\ORM\Query\AST; */ class BetweenExpression extends Node { + /** + * @var ArithmeticExpression + */ public $expression; + + /** + * @var ArithmeticExpression + */ public $leftBetweenExpression; + + /** + * @var ArithmeticExpression + */ public $rightBetweenExpression; + + /** + * @var bool + */ public $not; + /** + * @param ArithmeticExpression $expr + * @param ArithmeticExpression $leftExpr + * @param ArithmeticExpression $rightExpr + */ public function __construct($expr, $leftExpr, $rightExpr) { $this->expression = $expr; @@ -43,9 +62,11 @@ class BetweenExpression extends Node $this->rightBetweenExpression = $rightExpr; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkBetweenExpression($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php old mode 100755 new mode 100644 index 731d45eb8f..194f9ace55 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php @@ -32,14 +32,22 @@ namespace Doctrine\ORM\Query\AST; */ class CoalesceExpression extends Node { + /** + * @var array + */ public $scalarExpressions = array(); - + /** + * @param array $scalarExpressions + */ public function __construct(array $scalarExpressions) { $this->scalarExpressions = $scalarExpressions; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkCoalesceExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php old mode 100755 new mode 100644 index b8c7b53a0e..70989a2678 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php @@ -32,18 +32,32 @@ namespace Doctrine\ORM\Query\AST; class CollectionMemberExpression extends Node { public $entityExpression; + + /** + * @var PathExpression + */ public $collectionValuedPathExpression; + + /** + * @var bool + */ public $not; + /** + * @param mixed $entityExpr + * @param PathExpression $collValuedPathExpr + */ public function __construct($entityExpr, $collValuedPathExpr) { $this->entityExpression = $entityExpr; $this->collectionValuedPathExpression = $collValuedPathExpr; } + /** + * {@inheritdoc} + */ public function dispatch($walker) { return $walker->walkCollectionMemberExpression($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php old mode 100755 new mode 100644 index d3105a1f31..05583920df --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php @@ -27,7 +27,6 @@ namespace Doctrine\ORM\Query\AST; * DatetimeExpression ComparisonOperator (DatetimeExpression | QuantifiedExpression) | * EntityExpression ("=" | "<>") (EntityExpression | QuantifiedExpression) * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -36,10 +35,26 @@ namespace Doctrine\ORM\Query\AST; */ class ComparisonExpression extends Node { + /** + * @var Node + */ public $leftExpression; + + /** + * @var Node + */ public $rightExpression; + + /** + * @var string + */ public $operator; + /** + * @param Node $leftExpr + * @param string $operator + * @param Node $rightExpr + */ public function __construct($leftExpr, $operator, $rightExpr) { $this->leftExpression = $leftExpr; @@ -47,6 +62,9 @@ class ComparisonExpression extends Node $this->operator = $operator; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkComparisonExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php old mode 100755 new mode 100644 index c302aa2049..62c7b2bca2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}* * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class ConditionalExpression extends Node { + /** + * @var array + */ public $conditionalTerms = array(); + /** + * @param array $conditionalTerms + */ public function __construct(array $conditionalTerms) { $this->conditionalTerms = $conditionalTerms; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkConditionalExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php old mode 100755 new mode 100644 index b17089b780..7c89faa420 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * ConditionalFactor ::= ["NOT"] ConditionalPrimary * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,14 +30,27 @@ namespace Doctrine\ORM\Query\AST; */ class ConditionalFactor extends Node { + /** + * @var bool + */ public $not = false; + + /** + * @var ConditionalPrimary + */ public $conditionalPrimary; + /** + * @param ConditionalPrimary $conditionalPrimary + */ public function __construct($conditionalPrimary) { $this->conditionalPrimary = $conditionalPrimary; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkConditionalFactor($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php old mode 100755 new mode 100644 index 8a7c0b7c6a..1eed41dce6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")" * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,19 +30,35 @@ namespace Doctrine\ORM\Query\AST; */ class ConditionalPrimary extends Node { + /** + * @var Node|null + */ public $simpleConditionalExpression; + + /** + * @var ConditionalExpression|null + */ public $conditionalExpression; + /** + * @return bool + */ public function isSimpleConditionalExpression() { return (bool) $this->simpleConditionalExpression; } + /** + * @return bool + */ public function isConditionalExpression() { return (bool) $this->conditionalExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkConditionalPrimary($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php old mode 100755 new mode 100644 index d24defc1a3..bb92db119b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php @@ -21,7 +21,6 @@ namespace Doctrine\ORM\Query\AST; /** * ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}* * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -30,13 +29,22 @@ namespace Doctrine\ORM\Query\AST; */ class ConditionalTerm extends Node { + /** + * @var array + */ public $conditionalFactors = array(); + /** + * @param array $conditionalFactors + */ public function __construct(array $conditionalFactors) { $this->conditionalFactors = $conditionalFactors; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkConditionalTerm($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/DeleteClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/DeleteClause.php old mode 100755 new mode 100644 index a05e52f06d..8ca35c6772 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/DeleteClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/DeleteClause.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName [["AS"] AliasIdentificationVariable] * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,17 +30,29 @@ namespace Doctrine\ORM\Query\AST; */ class DeleteClause extends Node { + /** + * @var string + */ public $abstractSchemaName; + + /** + * @var string + */ public $aliasIdentificationVariable; + /** + * @param string $abstractSchemaName + */ public function __construct($abstractSchemaName) { $this->abstractSchemaName = $abstractSchemaName; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkDeleteClause($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/DeleteStatement.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/DeleteStatement.php old mode 100755 new mode 100644 index f6e8cb31c7..da6859b867 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/DeleteStatement.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/DeleteStatement.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * DeleteStatement = DeleteClause [WhereClause] * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,14 +30,27 @@ namespace Doctrine\ORM\Query\AST; */ class DeleteStatement extends Node { + /** + * @var DeleteClause + */ public $deleteClause; + + /** + * @var WhereClause|null + */ public $whereClause; + /** + * @param DeleteClause $deleteClause + */ public function __construct($deleteClause) { $this->deleteClause = $deleteClause; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkDeleteStatement($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php old mode 100755 new mode 100644 index fbe504c5d4..bd978af04b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY" * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,17 +30,29 @@ namespace Doctrine\ORM\Query\AST; */ class EmptyCollectionComparisonExpression extends Node { + /** + * @var PathExpression + */ public $expression; + + /** + * @var bool + */ public $not; + /** + * @param PathExpression $expression + */ public function __construct($expression) { $this->expression = $expression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkEmptyCollectionComparisonExpression($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ExistsExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ExistsExpression.php old mode 100755 new mode 100644 index 94ee55d132..c53a10775e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ExistsExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ExistsExpression.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")" * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,17 +30,29 @@ namespace Doctrine\ORM\Query\AST; */ class ExistsExpression extends Node { + /** + * @var bool + */ public $not; + + /** + * @var Subselect + */ public $subselect; + /** + * @param Subselect $subselect + */ public function __construct($subselect) { $this->subselect = $subselect; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkExistsExpression($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/FromClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/FromClause.php old mode 100755 new mode 100644 index 32c7a73806..b1d8dfe6b8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/FromClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/FromClause.php @@ -31,13 +31,22 @@ namespace Doctrine\ORM\Query\AST; */ class FromClause extends Node { + /** + * @var array + */ public $identificationVariableDeclarations = array(); + /** + * @param array $identificationVariableDeclarations + */ public function __construct(array $identificationVariableDeclarations) { $this->identificationVariableDeclarations = $identificationVariableDeclarations; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkFromClause($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php old mode 100755 new mode 100644 index d771f050e1..8fade4c7a8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php @@ -34,6 +34,9 @@ use Doctrine\ORM\Query\Lexer; */ class AbsFunction extends FunctionNode { + /** + * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression + */ public $simpleArithmeticExpression; /** @@ -59,4 +62,3 @@ class AbsFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php old mode 100755 new mode 100644 index 39ecd2dc20..421fe9ae7b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php @@ -22,9 +22,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\Lexer; /** - * "CONCAT" "(" StringPrimary "," StringPrimary ")" + * "CONCAT" "(" StringPrimary "," StringPrimary {"," StringPrimary }* ")" + * * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -35,18 +35,25 @@ use Doctrine\ORM\Query\Lexer; class ConcatFunction extends FunctionNode { public $firstStringPrimary; - public $secondStringPriamry; - + + public $secondStringPrimary; + + public $concatExpressions = array(); + /** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); - return $platform->getConcatExpression( - $sqlWalker->walkStringPrimary($this->firstStringPrimary), - $sqlWalker->walkStringPrimary($this->secondStringPrimary) - ); + + $args = array(); + + foreach ($this->concatExpressions as $expression) { + $args[] = $sqlWalker->walkStringPrimary($expression); + } + + return call_user_func_array(array($platform,'getConcatExpression'), $args); } /** @@ -56,10 +63,19 @@ class ConcatFunction extends FunctionNode { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); - + $this->firstStringPrimary = $parser->StringPrimary(); + $this->concatExpressions[] = $this->firstStringPrimary; + $parser->match(Lexer::T_COMMA); - $this->secondStringPrimary = $parser->StringPrimary(); + + $this->secondStringPrimary = $parser->StringPrimary(); + $this->concatExpressions[] = $this->secondStringPrimary; + + while ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { + $parser->match(Lexer::T_COMMA); + $this->concatExpressions[] = $parser->StringPrimary(); + } $parser->match(Lexer::T_CLOSE_PARENTHESIS); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php old mode 100755 new mode 100644 index bf56785685..1c3817fe2a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php @@ -39,6 +39,9 @@ class DateAddFunction extends FunctionNode public $intervalExpression = null; public $unit = null; + /** + * @override + */ public function getSql(SqlWalker $sqlWalker) { switch (strtolower($this->unit->value)) { @@ -61,6 +64,9 @@ class DateAddFunction extends FunctionNode } } + /** + * @override + */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php old mode 100755 new mode 100644 index f21b9a09f8..a33c2d06f3 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php @@ -36,6 +36,9 @@ class DateDiffFunction extends FunctionNode public $date1; public $date2; + /** + * @override + */ public function getSql(SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getDateDiffExpression( @@ -44,6 +47,9 @@ class DateDiffFunction extends FunctionNode ); } + /** + * @override + */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php old mode 100755 new mode 100644 index 0cc0730962..35add0ed69 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php @@ -33,6 +33,9 @@ use Doctrine\ORM\Query\QueryException; */ class DateSubFunction extends DateAddFunction { + /** + * @override + */ public function getSql(SqlWalker $sqlWalker) { switch (strtolower($this->unit->value)) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php old mode 100755 new mode 100644 index bd8b607682..2f33c9da34 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php @@ -22,7 +22,7 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; /** - * Abtract Function Node. + * Abstract Function Node. * * * @link www.doctrine-project.org @@ -34,19 +34,40 @@ use Doctrine\ORM\Query\AST\Node; */ abstract class FunctionNode extends Node { + /** + * @var string + */ public $name; + /** + * @param string $name + */ public function __construct($name) { $this->name = $name; } + /** + * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker + * + * @return string + */ abstract public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker); + /** + * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker + * + * @return string + */ public function dispatch($sqlWalker) { return $sqlWalker->walkFunction($this); } + /** + * @param \Doctrine\ORM\Query\Parser $parser + * + * @return void + */ abstract public function parse(\Doctrine\ORM\Query\Parser $parser); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php old mode 100755 new mode 100644 index 2733399b14..58f0dde139 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -20,9 +20,12 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\Lexer; +use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\QueryException; /** - * "IDENTITY" "(" SingleValuedAssociationPathExpression ")" + * "IDENTITY" "(" SingleValuedAssociationPathExpression {"," string} ")" * * * @link www.doctrine-project.org @@ -32,36 +35,79 @@ use Doctrine\ORM\Query\Lexer; */ class IdentityFunction extends FunctionNode { + /** + * @var \Doctrine\ORM\Query\AST\PathExpression + */ public $pathExpression; /** - * @override + * @var string */ - public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) + public $fieldMapping; + + /** + * {@inheritdoc} + */ + public function getSql(SqlWalker $sqlWalker) { - $dqlAlias = $this->pathExpression->identificationVariable; - $assocField = $this->pathExpression->field; + $platform = $sqlWalker->getEntityManager()->getConnection()->getDatabasePlatform(); + $quoteStrategy = $sqlWalker->getEntityManager()->getConfiguration()->getQuoteStrategy(); + $dqlAlias = $this->pathExpression->identificationVariable; + $assocField = $this->pathExpression->field; + $qComp = $sqlWalker->getQueryComponent($dqlAlias); + $class = $qComp['metadata']; + $assoc = $class->associationMappings[$assocField]; + $targetEntity = $sqlWalker->getEntityManager()->getClassMetadata($assoc['targetEntity']); + $joinColumn = reset($assoc['joinColumns']); - $qComp = $sqlWalker->getQueryComponent($dqlAlias); - $class = $qComp['metadata']; - $assoc = $class->associationMappings[$assocField]; + if ($this->fieldMapping !== null) { + if ( ! isset($targetEntity->fieldMappings[$this->fieldMapping])) { + throw new QueryException(sprintf('Undefined reference field mapping "%s"', $this->fieldMapping)); + } - $tableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); + $field = $targetEntity->fieldMappings[$this->fieldMapping]; + $joinColumn = null; - return $tableAlias . '.' . reset($assoc['targetToSourceKeyColumns']);; + foreach ($assoc['joinColumns'] as $mapping) { + + if($mapping['referencedColumnName'] === $field['columnName']) { + $joinColumn = $mapping; + + break; + } + } + + if ($joinColumn === null) { + throw new QueryException(sprintf('Unable to resolve the reference field mapping "%s"', $this->fieldMapping)); + } + } + + //The table with the relation may be a subclass, so get the table name from the association definition + $tableName = $sqlWalker->getEntityManager()->getClassMetadata($assoc['sourceEntity'])->getTableName(); + + $tableAlias = $sqlWalker->getSQLTableAlias($tableName, $dqlAlias); + $columnName = $quoteStrategy->getJoinColumnName($joinColumn, $targetEntity, $platform); + + return $tableAlias . '.' . $columnName; } /** - * @override + * {@inheritdoc} */ - public function parse(\Doctrine\ORM\Query\Parser $parser) + public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $this->pathExpression = $parser->SingleValuedAssociationPathExpression(); + if ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { + $parser->match(Lexer::T_COMMA); + $parser->match(Lexer::T_STRING); + + $this->fieldMapping = $parser->getLexer()->token['value']; + } + $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php old mode 100755 new mode 100644 index 9c6f770003..deb3066e2a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php @@ -59,4 +59,3 @@ class LengthFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php old mode 100755 new mode 100644 index a189082501..cba45bc1cb --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php @@ -36,6 +36,10 @@ class LocateFunction extends FunctionNode { public $firstStringPrimary; public $secondStringPrimary; + + /** + * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression|bool + */ public $simpleArithmeticExpression = false; /** @@ -78,4 +82,3 @@ class LocateFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php old mode 100755 new mode 100644 index 12c6745e14..ffc86b6f8d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php @@ -59,4 +59,3 @@ class LowerFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php old mode 100755 new mode 100644 index 27d252e27f..cf4cf0c989 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php @@ -34,7 +34,14 @@ use Doctrine\ORM\Query\Lexer; */ class ModFunction extends FunctionNode { + /** + * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression + */ public $firstSimpleArithmeticExpression; + + /** + * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression + */ public $secondSimpleArithmeticExpression; /** @@ -65,4 +72,3 @@ class ModFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php old mode 100755 new mode 100644 index bffff29f12..7970508f17 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -34,6 +34,9 @@ use Doctrine\ORM\Query\Lexer; */ class SizeFunction extends FunctionNode { + /** + * @var \Doctrine\ORM\Query\AST\PathExpression + */ public $collectionPathExpression; /** @@ -118,4 +121,3 @@ class SizeFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php old mode 100755 new mode 100644 index cf8c27b4fc..c9f1038c49 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php @@ -34,6 +34,9 @@ use Doctrine\ORM\Query\Lexer; */ class SqrtFunction extends FunctionNode { + /** + * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression + */ public $simpleArithmeticExpression; /** @@ -59,4 +62,3 @@ class SqrtFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php old mode 100755 new mode 100644 index 6f3dfbef8a..ee80c06acf --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php @@ -35,7 +35,15 @@ use Doctrine\ORM\Query\Lexer; class SubstringFunction extends FunctionNode { public $stringPrimary; + + /** + * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression + */ public $firstSimpleArithmeticExpression; + + /** + * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression|null + */ public $secondSimpleArithmeticExpression = null; /** @@ -79,4 +87,3 @@ class SubstringFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php old mode 100755 new mode 100644 index 0c60ab01e5..0c1f5d86f2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -20,6 +20,8 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\Lexer; +use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\SqlWalker; use Doctrine\DBAL\Platforms\AbstractPlatform; /** @@ -35,56 +37,61 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; */ class TrimFunction extends FunctionNode { + /** + * @var boolean + */ public $leading; + + /** + * @var boolean + */ public $trailing; + + /** + * @var boolean + */ public $both; + + /** + * @var boolean + */ public $trimChar = false; + + /** + * @var \Doctrine\ORM\Query\AST\Node + */ public $stringPrimary; /** - * @override + * {@inheritdoc} */ - public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker) { - $pos = AbstractPlatform::TRIM_UNSPECIFIED; - if ($this->leading) { - $pos = AbstractPlatform::TRIM_LEADING; - } else if ($this->trailing) { - $pos = AbstractPlatform::TRIM_TRAILING; - } else if ($this->both) { - $pos = AbstractPlatform::TRIM_BOTH; - } + $stringPrimary = $sqlWalker->walkStringPrimary($this->stringPrimary); + $platform = $sqlWalker->getConnection()->getDatabasePlatform(); + $trimMode = $this->getTrimMode(); + $trimChar = ($this->trimChar !== false) + ? $sqlWalker->getConnection()->quote($this->trimChar) + : false; - return $sqlWalker->getConnection()->getDatabasePlatform()->getTrimExpression( - $sqlWalker->walkStringPrimary($this->stringPrimary), - $pos, - ($this->trimChar != false) ? $sqlWalker->getConnection()->quote($this->trimChar) : false - ); + return $platform->getTrimExpression($stringPrimary, $trimMode, $trimChar); } /** - * @override + * {@inheritdoc} */ - public function parse(\Doctrine\ORM\Query\Parser $parser) + public function parse(Parser $parser) { $lexer = $parser->getLexer(); $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); - if (strcasecmp('leading', $lexer->lookahead['value']) === 0) { - $parser->match(Lexer::T_LEADING); - $this->leading = true; - } else if (strcasecmp('trailing', $lexer->lookahead['value']) === 0) { - $parser->match(Lexer::T_TRAILING); - $this->trailing = true; - } else if (strcasecmp('both', $lexer->lookahead['value']) === 0) { - $parser->match(Lexer::T_BOTH); - $this->both = true; - } + $this->parseTrimMode($parser); if ($lexer->isNextToken(Lexer::T_STRING)) { $parser->match(Lexer::T_STRING); + $this->trimChar = $lexer->token['value']; } @@ -97,4 +104,60 @@ class TrimFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } + /** + * @param \Doctrine\ORM\Query\Parser $parser + * + * @return integer + */ + private function getTrimMode() + { + if ($this->leading) { + return AbstractPlatform::TRIM_LEADING; + } + + if ($this->trailing) { + return AbstractPlatform::TRIM_TRAILING; + } + + if ($this->both) { + return AbstractPlatform::TRIM_BOTH; + } + + return AbstractPlatform::TRIM_UNSPECIFIED; + } + + /** + * @param \Doctrine\ORM\Query\Parser $parser + * + * @return void + */ + private function parseTrimMode(Parser $parser) + { + $lexer = $parser->getLexer(); + $value = $lexer->lookahead['value']; + + if (strcasecmp('leading', $value) === 0) { + $parser->match(Lexer::T_LEADING); + + $this->leading = true; + + return; + } + + if (strcasecmp('trailing', $value) === 0) { + $parser->match(Lexer::T_TRAILING); + + $this->trailing = true; + + return; + } + + if (strcasecmp('both', $value) === 0) { + $parser->match(Lexer::T_BOTH); + + $this->both = true; + + return; + } + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php old mode 100755 new mode 100644 index 26c8f0d997..888009a7b3 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php @@ -59,4 +59,3 @@ class UpperFunction extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php old mode 100755 new mode 100644 index ee4b418319..a74eed599d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php @@ -32,15 +32,29 @@ namespace Doctrine\ORM\Query\AST; */ class GeneralCaseExpression extends Node { + /** + * @var array + */ public $whenClauses = array(); + + /** + * @var mixed + */ public $elseScalarExpression = null; + /** + * @param array $whenClauses + * @param mixed $elseScalarExpression + */ public function __construct(array $whenClauses, $elseScalarExpression) { $this->whenClauses = $whenClauses; $this->elseScalarExpression = $elseScalarExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkGeneralCaseExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/GroupByClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/GroupByClause.php old mode 100755 new mode 100644 index 06350f02d5..c05fa5863d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/GroupByClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/GroupByClause.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\AST; /** - * Description of GroupByClause + * Description of GroupByClause. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class GroupByClause extends Node { + /** + * @var array + */ public $groupByItems = array(); + /** + * @param array $groupByItems + */ public function __construct(array $groupByItems) { $this->groupByItems = $groupByItems; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkGroupByClause($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/HavingClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/HavingClause.php old mode 100755 new mode 100644 index 971e919bca..1d369fff66 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/HavingClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/HavingClause.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\AST; /** - * Description of HavingClause + * Description of HavingClause. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class HavingClause extends Node { + /** + * @var ConditionalExpression + */ public $conditionalExpression; + /** + * @param ConditionalExpression $conditionalExpression + */ public function __construct($conditionalExpression) { $this->conditionalExpression = $conditionalExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkHavingClause($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php old mode 100755 new mode 100644 index 6bbdaaad68..a8f7f6d350 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}* * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,10 +30,26 @@ namespace Doctrine\ORM\Query\AST; */ class IdentificationVariableDeclaration extends Node { + /** + * @var RangeVariableDeclaration|null + */ public $rangeVariableDeclaration = null; - public $indexBy = null; - public $joins = array(); + /** + * @var IndexBy|null + */ + public $indexBy = null; + + /** + * @var array + */ + public $joins = array(); + + /** + * @param RangeVariableDeclaration|null $rangeVariableDecl + * @param IndexBy|null $indexBy + * @param array $joins + */ public function __construct($rangeVariableDecl, $indexBy, array $joins) { $this->rangeVariableDeclaration = $rangeVariableDecl; @@ -42,6 +57,9 @@ class IdentificationVariableDeclaration extends Node $this->joins = $joins; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkIdentificationVariableDeclaration($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InExpression.php old mode 100755 new mode 100644 index 39501a406e..9d0a8b54ee --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InExpression.php @@ -21,7 +21,6 @@ namespace Doctrine\ORM\Query\AST; /** * InExpression ::= StateFieldPathExpression ["NOT"] "IN" "(" (Literal {"," Literal}* | Subselect) ")" * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -30,19 +29,39 @@ namespace Doctrine\ORM\Query\AST; */ class InExpression extends Node { + /** + * @var bool + */ public $not; + + /** + * @var ArithmeticExpression + */ public $expression; + + /** + * @var array + */ public $literals = array(); + + /** + * @var Subselect|null + */ public $subselect; + /** + * @param ArithmeticExpression $expression + */ public function __construct($expression) { $this->expression = $expression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkInExpression($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/IndexBy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/IndexBy.php old mode 100755 new mode 100644 index 08e9e6a04d..c7874b70a3 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/IndexBy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/IndexBy.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class IndexBy extends Node { + /** + * @var PathExpression + */ public $simpleStateFieldPathExpression = null; + /** + * @param PathExpression $simpleStateFieldPathExpression + */ public function __construct($simpleStateFieldPathExpression) { $this->simpleStateFieldPathExpression = $simpleStateFieldPathExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkIndexBy($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InputParameter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InputParameter.php old mode 100755 new mode 100644 index d575df7188..cf50140be9 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InputParameter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InputParameter.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\AST; /** - * Description of InputParameter + * Description of InputParameter. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,11 +30,20 @@ namespace Doctrine\ORM\Query\AST; */ class InputParameter extends Node { + /** + * @var bool + */ public $isNamed; + + /** + * @var string + */ public $name; /** * @param string $value + * + * @throws \Doctrine\ORM\Query\QueryException */ public function __construct($value) { @@ -48,6 +56,9 @@ class InputParameter extends Node $this->name = $param; } + /** + * {@inheritdoc} + */ public function dispatch($walker) { return $walker->walkInputParameter($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php old mode 100755 new mode 100644 index c022cd6866..c1fd65b8e6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php @@ -23,7 +23,6 @@ namespace Doctrine\ORM\Query\AST; * InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")") * InstanceOfParameter ::= AbstractSchemaName | InputParameter * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -32,18 +31,34 @@ namespace Doctrine\ORM\Query\AST; */ class InstanceOfExpression extends Node { + /** + * @var bool + */ public $not; + + /** + * @var string + */ public $identificationVariable; + + /** + * @var array + */ public $value; + /** + * @param string $identVariable + */ public function __construct($identVariable) { $this->identificationVariable = $identVariable; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkInstanceOfExpression($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Join.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Join.php old mode 100755 new mode 100644 index 6724f9e1d3..5c203aa0b4 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Join.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Join.php @@ -35,16 +35,34 @@ class Join extends Node const JOIN_TYPE_LEFTOUTER = 2; const JOIN_TYPE_INNER = 3; + /** + * @var int + */ public $joinType = self::JOIN_TYPE_INNER; + + /** + * @var Node|null + */ public $joinAssociationDeclaration = null; + + /** + * @var ConditionalExpression|null + */ public $conditionalExpression = null; + /** + * @param int $joinType + * @param Node $joinAssociationDeclaration + */ public function __construct($joinType, $joinAssociationDeclaration) { $this->joinType = $joinType; $this->joinAssociationDeclaration = $joinAssociationDeclaration; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkJoin($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php old mode 100755 new mode 100644 index 8e97353eae..a33900a6d6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php @@ -28,10 +28,26 @@ namespace Doctrine\ORM\Query\AST; */ class JoinAssociationDeclaration extends Node { + /** + * @var JoinAssociationPathExpression + */ public $joinAssociationPathExpression; + + /** + * @var string + */ public $aliasIdentificationVariable; + + /** + * @var IndexBy|null + */ public $indexBy; + /** + * @param JoinAssociationPathExpression $joinAssociationPathExpression + * @param string $aliasIdentificationVariable + * @param IndexBy|null $indexBy + */ public function __construct($joinAssociationPathExpression, $aliasIdentificationVariable, $indexBy) { $this->joinAssociationPathExpression = $joinAssociationPathExpression; @@ -39,6 +55,9 @@ class JoinAssociationDeclaration extends Node $this->indexBy = $indexBy; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkJoinAssociationDeclaration($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php old mode 100755 new mode 100644 index 57bd05277d..946bbb15b7 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php @@ -30,15 +30,29 @@ namespace Doctrine\ORM\Query\AST; */ class JoinAssociationPathExpression extends Node { + /** + * @var string + */ public $identificationVariable; + + /** + * @var string + */ public $associationField; + /** + * @param string $identificationVariable + * @param string $associationField + */ public function __construct($identificationVariable, $associationField) { $this->identificationVariable = $identificationVariable; $this->associationField = $associationField; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkPathExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php old mode 100755 new mode 100644 index a6bafea21d..1c67cb9c42 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php @@ -29,15 +29,29 @@ namespace Doctrine\ORM\Query\AST; */ class JoinClassPathExpression extends Node { + /** + * @var mixed + */ public $abstractSchemaName; + + /** + * @var mixed + */ public $aliasIdentificationVariable; + /** + * @param mixed $abstractSchemaName + * @param mixed $aliasIdentificationVar + */ public function __construct($abstractSchemaName, $aliasIdentificationVar) { $this->abstractSchemaName = $abstractSchemaName; $this->aliasIdentificationVariable = $aliasIdentificationVar; } + /** + * {@inheritdoc} + */ public function dispatch($walker) { return $walker->walkJoinPathExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/LikeExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/LikeExpression.php old mode 100755 new mode 100644 index 68f8635b06..e320c51c88 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/LikeExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/LikeExpression.php @@ -21,7 +21,6 @@ namespace Doctrine\ORM\Query\AST; /** * LikeExpression ::= StringExpression ["NOT"] "LIKE" string ["ESCAPE" char] * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -30,11 +29,31 @@ namespace Doctrine\ORM\Query\AST; */ class LikeExpression extends Node { + /** + * @var bool + */ public $not; + + /** + * @var Node + */ public $stringExpression; + + /** + * @var InputParameter + */ public $stringPattern; + + /** + * @var Literal|null + */ public $escapeChar; + /** + * @param Node $stringExpression + * @param InputParameter $stringPattern + * @param Literal|null $escapeChar + */ public function __construct($stringExpression, $stringPattern, $escapeChar = null) { $this->stringExpression = $stringExpression; @@ -42,6 +61,9 @@ class LikeExpression extends Node $this->escapeChar = $escapeChar; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkLikeExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Literal.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Literal.php old mode 100755 new mode 100644 index 26337cbda0..43d71add08 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Literal.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Literal.php @@ -25,17 +25,31 @@ class Literal extends Node const BOOLEAN = 2; const NUMERIC = 3; + /** + * @var int + */ public $type; + + /** + * @var mixed + */ public $value; + /** + * @param int $type + * @param mixed $value + */ public function __construct($type, $value) { $this->type = $type; $this->value = $value; } + /** + * {@inheritdoc} + */ public function dispatch($walker) { return $walker->walkLiteral($this); } -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php old mode 100755 new mode 100644 similarity index 54% rename from vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php rename to vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php index 5908b674a1..65b94ac63c --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php @@ -13,28 +13,46 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see + * and is licensed under the MIT. For more information, see * . -*/ + */ -namespace Doctrine\Tests\ORM\Mapping\Symfony; - -use \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver; +namespace Doctrine\ORM\Query\AST; /** - * @group DDC-1418 + * NewObjectExpression ::= "NEW" IdentificationVariable "(" NewObjectArg {"," NewObjectArg}* ")" + * + * @link www.doctrine-project.org + * @since 2.4 + * @author Fabio B. Silva */ -class XmlDriverTest extends AbstractDriverTest +class NewObjectExpression extends Node { - protected function getFileExtension() + /** + * @var string + */ + public $className; + + /** + * @var array + */ + public $args; + + /** + * @param string $className + * @param array $args + */ + public function __construct($className, array $args) { - return '.orm.xml'; + $this->className = $className; + $this->args = $args; } - protected function getDriver(array $paths = array()) + /** + * {@inheritdoc} + */ + public function dispatch($sqlWalker) { - $driver = new SimplifiedXmlDriver(array_flip($paths)); - - return $driver; + return $sqlWalker->walkNewObject($this); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Node.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Node.php old mode 100755 new mode 100644 index d50e0d0435..a257dc2d79 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Node.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Node.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\AST; /** - * Abstract class of an AST node + * Abstract class of an AST node. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -36,7 +35,11 @@ abstract class Node * * Implementation is not mandatory for all nodes. * - * @param $walker + * @param \Doctrine\ORM\Query\SqlWalker $walker + * + * @return string + * + * @throws ASTException */ public function dispatch($walker) { @@ -44,7 +47,7 @@ abstract class Node } /** - * Dumps the AST Node into a string representation for information purpose only + * Dumps the AST Node into a string representation for information purpose only. * * @return string */ @@ -53,6 +56,11 @@ abstract class Node return $this->dump($this); } + /** + * @param object $obj + * + * @return string + */ public function dump($obj) { static $ident = 0; diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php old mode 100755 new mode 100644 index d0fb8bfd90..84a199784c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * NullComparisonExpression ::= (SingleValuedPathExpression | InputParameter) "IS" ["NOT"] "NULL" * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,17 +30,29 @@ namespace Doctrine\ORM\Query\AST; */ class NullComparisonExpression extends Node { + /** + * @var bool + */ public $not; + + /** + * @var Node + */ public $expression; + /** + * @param Node $expression + */ public function __construct($expression) { $this->expression = $expression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkNullComparisonExpression($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NullIfExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NullIfExpression.php old mode 100755 new mode 100644 index 2c85ddd906..e33bc72b15 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NullIfExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/NullIfExpression.php @@ -32,16 +32,29 @@ namespace Doctrine\ORM\Query\AST; */ class NullIfExpression extends Node { + /** + * @var mixed + */ public $firstExpression; + /** + * @var mixed + */ public $secondExpression; + /** + * @param mixed $firstExpression + * @param mixed $secondExpression + */ public function __construct($firstExpression, $secondExpression) { $this->firstExpression = $firstExpression; $this->secondExpression = $secondExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkNullIfExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/OrderByClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/OrderByClause.php old mode 100755 new mode 100644 index 311a9edcef..75d16c7319 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/OrderByClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/OrderByClause.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}* * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class OrderByClause extends Node { + /** + * @var array + */ public $orderByItems = array(); + /** + * @param array $orderByItems + */ public function __construct(array $orderByItems) { $this->orderByItems = $orderByItems; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkOrderByClause($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/OrderByItem.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/OrderByItem.php old mode 100755 new mode 100644 index 5d48077edb..bf3288a7b9 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/OrderByItem.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/OrderByItem.php @@ -31,24 +31,43 @@ namespace Doctrine\ORM\Query\AST; */ class OrderByItem extends Node { + /** + * @var mixed + */ public $expression; + + /** + * @var string + */ public $type; + /** + * @param mixed $expression + */ public function __construct($expression) { $this->expression = $expression; } + /** + * @return bool + */ public function isAsc() { return strtoupper($this->type) == 'ASC'; } + /** + * @return bool + */ public function isDesc() { return strtoupper($this->type) == 'DESC'; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkOrderByItem($this); diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/File.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php old mode 100755 new mode 100644 similarity index 59% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/File.php rename to vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php index 35132689a9..f16db0eb74 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/File.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php @@ -1,4 +1,5 @@ . */ - -namespace Doctrine\Tests\Models\DirectoryTree; +namespace Doctrine\ORM\Query\AST; /** - * @Entity - * @Table(name="`file`") + * ParenthesisExpression ::= "(" ArithmeticPrimary ")" + * + * @author Fabio B. Silva + * @since 2.4 */ -class File extends AbstractContentItem +class ParenthesisExpression extends Node { - /** @Column(type="string") */ - protected $extension = "html"; + /** + * @var \Doctrine\ORM\Query\AST\Node + */ + public $expression; - public function __construct(Directory $parent = null) + /** + * @param \Doctrine\ORM\Query\AST\Node $expression + */ + public function __construct(Node $expression) { - parent::__construct($parent); + $this->expression = $expression; } - public function getExtension() + /** + * {@inheritdoc} + */ + public function dispatch($walker) { - return $this->extension; + return $walker->walkParenthesisExpression($this); } - - public function setExtension($ext) - { - $this->extension = $ext; - } -} +} \ No newline at end of file diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php old mode 100755 new mode 100644 index 8a0e0d04e1..e4ffe79b2a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php @@ -21,12 +21,23 @@ namespace Doctrine\ORM\Query\AST; class PartialObjectExpression extends Node { + /** + * @var string + */ public $identificationVariable; + + /** + * @var array + */ public $partialFieldSet; + /** + * @param string $identificationVariable + * @param array $partialFieldSet + */ public function __construct($identificationVariable, array $partialFieldSet) { $this->identificationVariable = $identificationVariable; $this->partialFieldSet = $partialFieldSet; } -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/PathExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/PathExpression.php old mode 100755 new mode 100644 index 1b2774203e..37674b6fd4 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/PathExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/PathExpression.php @@ -39,11 +39,31 @@ class PathExpression extends Node const TYPE_SINGLE_VALUED_ASSOCIATION = 4; const TYPE_STATE_FIELD = 8; + /** + * @var int + */ public $type; + + /** + * @var int + */ public $expectedType; + + /** + * @var string + */ public $identificationVariable; + + /** + * @var string|null + */ public $field; + /** + * @param int $expectedType + * @param string $identificationVariable + * @param string|null $field + */ public function __construct($expectedType, $identificationVariable, $field = null) { $this->expectedType = $expectedType; @@ -51,6 +71,9 @@ class PathExpression extends Node $this->field = $field; } + /** + * {@inheritdoc} + */ public function dispatch($walker) { return $walker->walkPathExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php old mode 100755 new mode 100644 index 64a764e908..15be952347 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php @@ -21,7 +21,6 @@ namespace Doctrine\ORM\Query\AST; /** * QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")" * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -30,35 +29,53 @@ namespace Doctrine\ORM\Query\AST; */ class QuantifiedExpression extends Node { + /** + * @var string + */ public $type; + + /** + * @var Subselect + */ public $subselect; + /** + * @param Subselect $subselect + */ public function __construct($subselect) { $this->subselect = $subselect; } + /** + * @return bool + */ public function isAll() { return strtoupper($this->type) == 'ALL'; } + /** + * @return bool + */ public function isAny() { return strtoupper($this->type) == 'ANY'; } + /** + * @return bool + */ public function isSome() { return strtoupper($this->type) == 'SOME'; } /** - * @override + * {@inheritdoc} */ public function dispatch($sqlWalker) { return $sqlWalker->walkQuantifiedExpression($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php old mode 100755 new mode 100644 index facd0bb3b5..0ca5274d19 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,15 +30,36 @@ namespace Doctrine\ORM\Query\AST; */ class RangeVariableDeclaration extends Node { + /** + * @var string + */ public $abstractSchemaName; + + /** + * @var string + */ public $aliasIdentificationVariable; - public function __construct($abstractSchemaName, $aliasIdentificationVar) + /** + * @var boolean + */ + public $isRoot; + + /** + * @param string $abstractSchemaName + * @param string $aliasIdentificationVar + * @param boolean $isRoot + */ + public function __construct($abstractSchemaName, $aliasIdentificationVar, $isRoot = true) { - $this->abstractSchemaName = $abstractSchemaName; + $this->abstractSchemaName = $abstractSchemaName; $this->aliasIdentificationVariable = $aliasIdentificationVar; + $this->isRoot = $isRoot; } + /** + * {@inheritdoc} + */ public function dispatch($walker) { return $walker->walkRangeVariableDeclaration($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectClause.php old mode 100755 new mode 100644 index be76a4fb6b..1df143677b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectClause.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * SelectClause = "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression} * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,15 +30,29 @@ namespace Doctrine\ORM\Query\AST; */ class SelectClause extends Node { + /** + * @var bool + */ public $isDistinct; + + /** + * @var array + */ public $selectExpressions = array(); + /** + * @param array $selectExpressions + * @param bool $isDistinct + */ public function __construct(array $selectExpressions, $isDistinct) { $this->isDistinct = $isDistinct; $this->selectExpressions = $selectExpressions; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSelectClause($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectExpression.php old mode 100755 new mode 100644 index 14ca85083b..4187013994 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectExpression.php @@ -23,7 +23,6 @@ namespace Doctrine\ORM\Query\AST; * SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression | * (AggregateExpression | "(" Subselect ")") [["AS"] ["HIDDEN"] FieldAliasIdentificationVariable] * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -32,10 +31,26 @@ namespace Doctrine\ORM\Query\AST; */ class SelectExpression extends Node { + /** + * @var mixed + */ public $expression; + + /** + * @var string|null + */ public $fieldIdentificationVariable; + + /** + * @var bool + */ public $hiddenAliasResultVariable; + /** + * @param mixed $expression + * @param string|null $fieldIdentificationVariable + * @param bool $hiddenAliasResultVariable + */ public function __construct($expression, $fieldIdentificationVariable, $hiddenAliasResultVariable = false) { $this->expression = $expression; @@ -43,6 +58,9 @@ class SelectExpression extends Node $this->hiddenAliasResultVariable = $hiddenAliasResultVariable; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSelectExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectStatement.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectStatement.php old mode 100755 new mode 100644 index d91d26f1a9..d84f7258a9 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectStatement.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SelectStatement.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,18 +30,49 @@ namespace Doctrine\ORM\Query\AST; */ class SelectStatement extends Node { + /** + * @var SelectClause + */ public $selectClause; + + /** + * @var FromClause + */ public $fromClause; + + /** + * @var WhereClause|null + */ public $whereClause; + + /** + * @var GroupByClause|null + */ public $groupByClause; + + /** + * @var HavingClause|null + */ public $havingClause; + + /** + * @var OrderByClause|null + */ public $orderByClause; - public function __construct($selectClause, $fromClause) { + /** + * @param SelectClause $selectClause + * @param FromClause $fromClause + */ + public function __construct($selectClause, $fromClause) + { $this->selectClause = $selectClause; $this->fromClause = $fromClause; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSelectStatement($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php old mode 100755 new mode 100644 index 8d91c9b0b8..9bd485045f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}* * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class SimpleArithmeticExpression extends Node { + /** + * @var array + */ public $arithmeticTerms = array(); + /** + * @param array $arithmeticTerms + */ public function __construct(array $arithmeticTerms) { $this->arithmeticTerms = $arithmeticTerms; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSimpleArithmeticExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php old mode 100755 new mode 100644 index bd593ee578..5272f3962a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php @@ -32,10 +32,26 @@ namespace Doctrine\ORM\Query\AST; */ class SimpleCaseExpression extends Node { + /** + * @var PathExpression + */ public $caseOperand = null; + + /** + * @var array + */ public $simpleWhenClauses = array(); + + /** + * @var mixed + */ public $elseScalarExpression = null; + /** + * @param PathExpression $caseOperand + * @param array $simpleWhenClauses + * @param mixed $elseScalarExpression + */ public function __construct($caseOperand, array $simpleWhenClauses, $elseScalarExpression) { $this->caseOperand = $caseOperand; @@ -43,6 +59,9 @@ class SimpleCaseExpression extends Node $this->elseScalarExpression = $elseScalarExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSimpleCaseExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php old mode 100755 new mode 100644 index 95a6198789..92361da45b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,15 +30,29 @@ namespace Doctrine\ORM\Query\AST; */ class SimpleSelectClause extends Node { + /** + * @var bool + */ public $isDistinct = false; + + /** + * @var SimpleSelectExpression + */ public $simpleSelectExpression; + /** + * @param SimpleSelectExpression $simpleSelectExpression + * @param bool $isDistinct + */ public function __construct($simpleSelectExpression, $isDistinct) { $this->simpleSelectExpression = $simpleSelectExpression; $this->isDistinct = $isDistinct; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSimpleSelectClause($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php old mode 100755 new mode 100644 index 25e927e2bd..e556835ed6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php @@ -23,7 +23,6 @@ namespace Doctrine\ORM\Query\AST; * SimpleSelectExpression ::= StateFieldPathExpression | IdentificationVariable * | (AggregateExpression [["AS"] FieldAliasIdentificationVariable]) * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -32,14 +31,27 @@ namespace Doctrine\ORM\Query\AST; */ class SimpleSelectExpression extends Node { + /** + * @var Node + */ public $expression; + + /** + * @var string + */ public $fieldIdentificationVariable; + /** + * @param Node $expression + */ public function __construct($expression) { $this->expression = $expression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSimpleSelectExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php old mode 100755 new mode 100644 index fabe449619..4f60881d42 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php @@ -32,15 +32,29 @@ namespace Doctrine\ORM\Query\AST; */ class SimpleWhenClause extends Node { + /** + * @var mixed + */ public $caseScalarExpression = null; + + /** + * @var mixed + */ public $thenScalarExpression = null; + /** + * @param mixed $caseScalarExpression + * @param mixed $thenScalarExpression + */ public function __construct($caseScalarExpression, $thenScalarExpression) { $this->caseScalarExpression = $caseScalarExpression; $this->thenScalarExpression = $thenScalarExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkWhenClauseExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Subselect.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Subselect.php old mode 100755 new mode 100644 index 46c0e96785..ce08266f08 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Subselect.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/Subselect.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,19 +30,49 @@ namespace Doctrine\ORM\Query\AST; */ class Subselect extends Node { + /** + * @var SimpleSelectClause + */ public $simpleSelectClause; + + /** + * @var SubselectFromClause + */ public $subselectFromClause; + + /** + * @var WhereClause|null + */ public $whereClause; + + /** + * @var GroupByClause|null + */ public $groupByClause; + + /** + * @var HavingClause|null + */ public $havingClause; + + /** + * @var OrderByClause|null + */ public $orderByClause; + /** + * @param SimpleSelectClause $simpleSelectClause + * @param SubselectFromClause $subselectFromClause + */ public function __construct($simpleSelectClause, $subselectFromClause) { $this->simpleSelectClause = $simpleSelectClause; $this->subselectFromClause = $subselectFromClause; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSubselect($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php old mode 100755 new mode 100644 index 3a6b547798..8d009fcfdc --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}* * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class SubselectFromClause extends Node { + /** + * @var array + */ public $identificationVariableDeclarations = array(); + /** + * @param array $identificationVariableDeclarations + */ public function __construct(array $identificationVariableDeclarations) { $this->identificationVariableDeclarations = $identificationVariableDeclarations; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkSubselectFromClause($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateClause.php old mode 100755 new mode 100644 index 4188cf58e0..430ed14eb9 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateClause.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * UpdateClause ::= "UPDATE" AbstractSchemaName [["AS"] AliasIdentificationVariable] "SET" UpdateItem {"," UpdateItem}* * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,19 +30,36 @@ namespace Doctrine\ORM\Query\AST; */ class UpdateClause extends Node { + /** + * @var string + */ public $abstractSchemaName; + + /** + * @var string + */ public $aliasIdentificationVariable; + + /** + * @var array + */ public $updateItems = array(); + /** + * @param string $abstractSchemaName + * @param array $updateItems + */ public function __construct($abstractSchemaName, array $updateItems) { $this->abstractSchemaName = $abstractSchemaName; $this->updateItems = $updateItems; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkUpdateClause($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateItem.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateItem.php old mode 100755 new mode 100644 index 2a13391f36..f1a288cae2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateItem.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateItem.php @@ -24,7 +24,6 @@ namespace Doctrine\ORM\Query\AST; * NewValue ::= SimpleArithmeticExpression | StringPrimary | DatetimePrimary | BooleanPrimary | * EnumPrimary | SimpleEntityExpression | "NULL" * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -33,18 +32,31 @@ namespace Doctrine\ORM\Query\AST; */ class UpdateItem extends Node { + /** + * @var PathExpression + */ public $pathExpression; + + /** + * @var InputParameter|ArithmeticExpression|null + */ public $newValue; + /** + * @param PathExpression $pathExpression + * @param InputParameter|ArithmeticExpression|null $newValue + */ public function __construct($pathExpression, $newValue) { $this->pathExpression = $pathExpression; $this->newValue = $newValue; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkUpdateItem($this); } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateStatement.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateStatement.php old mode 100755 new mode 100644 index 9e25d83cc2..c578efef48 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateStatement.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/UpdateStatement.php @@ -16,12 +16,12 @@ * and is licensed under the MIT license. For more information, see * . */ + namespace Doctrine\ORM\Query\AST; /** * UpdateStatement = UpdateClause [WhereClause] * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -30,14 +30,27 @@ namespace Doctrine\ORM\Query\AST; */ class UpdateStatement extends Node { + /** + * @var UpdateClause + */ public $updateClause; + + /** + * @var WhereClause|null + */ public $whereClause; + /** + * @param UpdateClause $updateClause + */ public function __construct($updateClause) { $this->updateClause = $updateClause; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkUpdateStatement($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/WhenClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/WhenClause.php old mode 100755 new mode 100644 index ca91f575f5..01c0330f48 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/WhenClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/WhenClause.php @@ -32,15 +32,29 @@ namespace Doctrine\ORM\Query\AST; */ class WhenClause extends Node { + /** + * @var ConditionalExpression + */ public $caseConditionExpression = null; + + /** + * @var mixed + */ public $thenScalarExpression = null; + /** + * @param ConditionalExpression $caseConditionExpression + * @param mixed $thenScalarExpression + */ public function __construct($caseConditionExpression, $thenScalarExpression) { $this->caseConditionExpression = $caseConditionExpression; $this->thenScalarExpression = $thenScalarExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkWhenClauseExpression($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/WhereClause.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/WhereClause.php old mode 100755 new mode 100644 index 0b9f160249..e6597752ff --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/WhereClause.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/AST/WhereClause.php @@ -22,7 +22,6 @@ namespace Doctrine\ORM\Query\AST; /** * WhereClause ::= "WHERE" ConditionalExpression * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -31,13 +30,22 @@ namespace Doctrine\ORM\Query\AST; */ class WhereClause extends Node { + /** + * @var ConditionalExpression + */ public $conditionalExpression; + /** + * @param ConditionalExpression $conditionalExpression + */ public function __construct($conditionalExpression) { $this->conditionalExpression = $conditionalExpression; } + /** + * {@inheritdoc} + */ public function dispatch($sqlWalker) { return $sqlWalker->walkWhereClause($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php old mode 100755 new mode 100644 index d20905a09f..3d6ed4353a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php @@ -53,6 +53,11 @@ abstract class AbstractSqlExecutor return $this->_sqlStatements; } + /** + * @param \Doctrine\DBAL\Cache\QueryCacheProfile $qcp + * + * @return void + */ public function setQueryCacheProfile(QueryCacheProfile $qcp) { $this->queryCacheProfile = $qcp; @@ -61,9 +66,10 @@ abstract class AbstractSqlExecutor /** * Executes all sql statements. * - * @param \Doctrine\DBAL\Connection $conn The database connection that is used to execute the queries. - * @param array $params The parameters. - * @param array $types The parameter types. + * @param Connection $conn The database connection that is used to execute the queries. + * @param array $params The parameters. + * @param array $types The parameter types. + * * @return \Doctrine\DBAL\Driver\Statement */ abstract public function execute(Connection $conn, array $params, array $types); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php old mode 100755 new mode 100644 index d40b37edc5..13af55905e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Query\Exec; -use Doctrine\DBAL\Connection, - Doctrine\ORM\Query\AST; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\Query\AST; /** * Executes the SQL statements for bulk DQL DELETE statements on classes in @@ -33,15 +33,27 @@ use Doctrine\DBAL\Connection, */ class MultiTableDeleteExecutor extends AbstractSqlExecutor { + /** + * @var string + */ private $_createTempTableSql; + + /** + * @var string + */ private $_dropTempTableSql; + + /** + * @var string + */ private $_insertSql; /** * Initializes a new MultiTableDeleteExecutor. * - * @param Node $AST The root AST node of the DQL query. - * @param SqlWalker $sqlWalker The walker used for SQL generation from the AST. + * @param \Doctrine\ORM\Query\AST\Node $AST The root AST node of the DQL query. + * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker The walker used for SQL generation from the AST. + * * @internal Any SQL construction and preparation takes place in the constructor for * best performance. With a query cache the executor will be cached. */ diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php old mode 100755 new mode 100644 index 60951eef21..8ceefe3a9a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -34,17 +34,37 @@ use Doctrine\ORM\Query\AST; */ class MultiTableUpdateExecutor extends AbstractSqlExecutor { + /** + * @var string + */ private $_createTempTableSql; + + /** + * @var string + */ private $_dropTempTableSql; + + /** + * @var string + */ private $_insertSql; + + /** + * @var array + */ private $_sqlParameters = array(); + + /** + * @var int + */ private $_numParametersInUpdateClause = 0; /** * Initializes a new MultiTableUpdateExecutor. * - * @param Node $AST The root AST node of the DQL query. - * @param SqlWalker $sqlWalker The walker used for SQL generation from the AST. + * @param \Doctrine\ORM\Query\AST\Node $AST The root AST node of the DQL query. + * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker The walker used for SQL generation from the AST. + * * @internal Any SQL construction and preparation takes place in the constructor for * best performance. With a query cache the executor will be cached. */ diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php old mode 100755 new mode 100644 index 61ae2fac14..f652fbe8c0 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php @@ -19,9 +19,9 @@ namespace Doctrine\ORM\Query\Exec; -use Doctrine\DBAL\Connection, - Doctrine\ORM\Query\AST\SelectStatement, - Doctrine\ORM\Query\SqlWalker; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\SqlWalker; /** * Executor that executes the SQL statement for simple DQL SELECT statements. @@ -33,6 +33,10 @@ use Doctrine\DBAL\Connection, */ class SingleSelectExecutor extends AbstractSqlExecutor { + /** + * @param \Doctrine\ORM\Query\AST\SelectStatement $AST + * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker + */ public function __construct(SelectStatement $AST, SqlWalker $sqlWalker) { $this->_sqlStatements = $sqlWalker->walkSelectStatement($AST); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php old mode 100755 new mode 100644 index b9bfd6fde6..695176d5bb --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Query\Exec; -use Doctrine\DBAL\Connection, - Doctrine\ORM\Query\AST; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\Query\AST; /** * Executor that executes the SQL statements for DQL DELETE/UPDATE statements on classes @@ -34,6 +34,10 @@ use Doctrine\DBAL\Connection, */ class SingleTableDeleteUpdateExecutor extends AbstractSqlExecutor { + /** + * @param \Doctrine\ORM\Query\AST\Node $AST + * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker + */ public function __construct(AST\Node $AST, $sqlWalker) { if ($AST instanceof AST\UpdateStatement) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr.php old mode 100755 new mode 100644 index 5ffedba9f5..48fb790b6b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query; /** - * This class is used to generate DQL expressions via a set of PHP static functions - * - * + * This class is used to generate DQL expressions via a set of PHP static functions. + * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -43,9 +42,10 @@ class Expr * $expr->andX($expr->eq('u.type', ':1'), $expr->eq('u.role', ':2')); * * @param \Doctrine\ORM\Query\Expr\Comparison | - * \Doctrine\ORM\Query\Expr\Func | - * \Doctrine\ORM\Query\Expr\Orx - * $x Optional clause. Defaults = null, but requires at least one defined when converting to string. + * \Doctrine\ORM\Query\Expr\Func | + * \Doctrine\ORM\Query\Expr\Orx + * $x Optional clause. Defaults to null, but requires at least one defined when converting to string. + * * @return Expr\Andx */ public function andX($x = null) @@ -62,8 +62,9 @@ class Expr * // (u.type = ?1) OR (u.role = ?2) * $q->where($q->expr()->orX('u.type = ?1', 'u.role = ?2')); * - * @param mixed $x Optional clause. Defaults = null, but requires + * @param mixed $x Optional clause. Defaults to null, but requires * at least one defined when converting to string. + * * @return Expr\Orx */ public function orX($x = null) @@ -74,7 +75,8 @@ class Expr /** * Creates an ASCending order expression. * - * @param $sort + * @param mixed $expr + * * @return Expr\OrderBy */ public function asc($expr) @@ -85,7 +87,8 @@ class Expr /** * Creates a DESCending order expression. * - * @param $sort + * @param mixed $expr + * * @return Expr\OrderBy */ public function desc($expr) @@ -103,8 +106,9 @@ class Expr * // u.id = ?1 * $expr->eq('u.id', '?1'); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Comparison */ public function eq($x, $y) @@ -121,8 +125,9 @@ class Expr * // u.id <> ?1 * $q->where($q->expr()->neq('u.id', '?1')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Comparison */ public function neq($x, $y) @@ -139,8 +144,9 @@ class Expr * // u.id < ?1 * $q->where($q->expr()->lt('u.id', '?1')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Comparison */ public function lt($x, $y) @@ -157,8 +163,9 @@ class Expr * // u.id <= ?1 * $q->where($q->expr()->lte('u.id', '?1')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Comparison */ public function lte($x, $y) @@ -175,8 +182,9 @@ class Expr * // u.id > ?1 * $q->where($q->expr()->gt('u.id', '?1')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Comparison */ public function gt($x, $y) @@ -193,8 +201,9 @@ class Expr * // u.id >= ?1 * $q->where($q->expr()->gte('u.id', '?1')); * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Comparison */ public function gte($x, $y) @@ -206,6 +215,7 @@ class Expr * Creates an instance of AVG() function, with the given argument. * * @param mixed $x Argument to be used in AVG() function. + * * @return Expr\Func */ public function avg($x) @@ -217,6 +227,7 @@ class Expr * Creates an instance of MAX() function, with the given argument. * * @param mixed $x Argument to be used in MAX() function. + * * @return Expr\Func */ public function max($x) @@ -228,6 +239,7 @@ class Expr * Creates an instance of MIN() function, with the given argument. * * @param mixed $x Argument to be used in MIN() function. + * * @return Expr\Func */ public function min($x) @@ -239,6 +251,7 @@ class Expr * Creates an instance of COUNT() function, with the given argument. * * @param mixed $x Argument to be used in COUNT() function. + * * @return Expr\Func */ public function count($x) @@ -250,6 +263,7 @@ class Expr * Creates an instance of COUNT(DISTINCT) function, with the given argument. * * @param mixed $x Argument to be used in COUNT(DISTINCT) function. + * * @return string */ public function countDistinct($x) @@ -261,6 +275,7 @@ class Expr * Creates an instance of EXISTS() function, with the given DQL Subquery. * * @param mixed $subquery DQL Subquery to be used in EXISTS() function. + * * @return Expr\Func */ public function exists($subquery) @@ -272,6 +287,7 @@ class Expr * Creates an instance of ALL() function, with the given DQL Subquery. * * @param mixed $subquery DQL Subquery to be used in ALL() function. + * * @return Expr\Func */ public function all($subquery) @@ -283,6 +299,7 @@ class Expr * Creates a SOME() function expression with the given DQL subquery. * * @param mixed $subquery DQL Subquery to be used in SOME() function. + * * @return Expr\Func */ public function some($subquery) @@ -294,6 +311,7 @@ class Expr * Creates an ANY() function expression with the given DQL subquery. * * @param mixed $subquery DQL Subquery to be used in ANY() function. + * * @return Expr\Func */ public function any($subquery) @@ -305,6 +323,7 @@ class Expr * Creates a negation expression of the given restriction. * * @param mixed $restriction Restriction to be used in NOT() function. + * * @return Expr\Func */ public function not($restriction) @@ -316,6 +335,7 @@ class Expr * Creates an ABS() function expression with the given argument. * * @param mixed $x Argument to be used in ABS() function. + * * @return Expr\Func */ public function abs($x) @@ -330,11 +350,12 @@ class Expr * When converted to string, it will generated a * . Example: * * [php] - * // u.salary * u.percentAnualSalaryIncrease - * $q->expr()->prod('u.salary', 'u.percentAnualSalaryIncrease') + * // u.salary * u.percentAnnualSalaryIncrease + * $q->expr()->prod('u.salary', 'u.percentAnnualSalaryIncrease') + * + * @param mixed $x Left expression. + * @param mixed $y Right expression. * - * @param mixed $x Left expression - * @param mixed $y Right expression * @return Expr\Math */ public function prod($x, $y) @@ -351,8 +372,9 @@ class Expr * // u.monthlySubscriptionCount - 1 * $q->expr()->diff('u.monthlySubscriptionCount', '1') * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Math */ public function diff($x, $y) @@ -369,8 +391,9 @@ class Expr * // u.numChildren + 1 * $q->expr()->diff('u.numChildren', '1') * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Math */ public function sum($x, $y) @@ -387,8 +410,9 @@ class Expr * // u.total / u.period * $expr->quot('u.total', 'u.period') * - * @param mixed $x Left expression - * @param mixed $y Right expression + * @param mixed $x Left expression. + * @param mixed $y Right expression. + * * @return Expr\Math */ public function quot($x, $y) @@ -400,6 +424,7 @@ class Expr * Creates a SQRT() function expression with the given argument. * * @param mixed $x Argument to be used in SQRT() function. + * * @return Expr\Func */ public function sqrt($x) @@ -410,8 +435,9 @@ class Expr /** * Creates an IN() expression with the given arguments. * - * @param string $x Field in string format to be restricted by IN() function - * @param mixed $y Argument to be used in IN() function. + * @param string $x Field in string format to be restricted by IN() function. + * @param mixed $y Argument to be used in IN() function. + * * @return Expr\Func */ public function in($x, $y) @@ -429,8 +455,9 @@ class Expr /** * Creates a NOT IN() expression with the given arguments. * - * @param string $x Field in string format to be restricted by NOT IN() function + * @param string $x Field in string format to be restricted by NOT IN() function. * @param mixed $y Argument to be used in NOT IN() function. + * * @return Expr\Func */ public function notIn($x, $y) @@ -448,7 +475,8 @@ class Expr /** * Creates an IS NULL expression with the given arguments. * - * @param string $x Field in string format to be restricted by IS NULL + * @param string $x Field in string format to be restricted by IS NULL. + * * @return string */ public function isNull($x) @@ -459,7 +487,8 @@ class Expr /** * Creates an IS NOT NULL expression with the given arguments. * - * @param string $x Field in string format to be restricted by IS NOT NULL + * @param string $x Field in string format to be restricted by IS NOT NULL. + * * @return string */ public function isNotNull($x) @@ -471,7 +500,8 @@ class Expr * Creates a LIKE() comparison expression with the given arguments. * * @param string $x Field in string format to be inspected by LIKE() comparison. - * @param mixed $y Argument to be used in LIKE() comparison. + * @param mixed $y Argument to be used in LIKE() comparison. + * * @return Expr\Comparison */ public function like($x, $y) @@ -479,11 +509,25 @@ class Expr return new Expr\Comparison($x, 'LIKE', $y); } + /** + * Creates a NOT LIKE() comparison expression with the given arguments. + * + * @param string $x Field in string format to be inspected by LIKE() comparison. + * @param mixed $y Argument to be used in LIKE() comparison. + * + * @return Expr\Comparison + */ + public function notLike($x, $y) + { + return new Expr\Comparison($x, 'NOT LIKE', $y); + } + /** * Creates a CONCAT() function expression with the given arguments. * * @param mixed $x First argument to be used in CONCAT() function. - * @param mixed $x Second argument to be used in CONCAT() function. + * @param mixed $y Second argument to be used in CONCAT() function. + * * @return Expr\Func */ public function concat($x, $y) @@ -494,9 +538,10 @@ class Expr /** * Creates a SUBSTRING() function expression with the given arguments. * - * @param mixed $x Argument to be used as string to be cropped by SUBSTRING() function. - * @param integer $from Initial offset to start cropping string. May accept negative values. - * @param integer $len Length of crop. May accept negative values. + * @param mixed $x Argument to be used as string to be cropped by SUBSTRING() function. + * @param int $from Initial offset to start cropping string. May accept negative values. + * @param int|null $len Length of crop. May accept negative values. + * * @return Expr\Func */ public function substring($x, $from, $len = null) @@ -512,6 +557,7 @@ class Expr * Creates a LOWER() function expression with the given argument. * * @param mixed $x Argument to be used in LOWER() function. + * * @return Expr\Func A LOWER function expression. */ public function lower($x) @@ -523,6 +569,7 @@ class Expr * Creates an UPPER() function expression with the given argument. * * @param mixed $x Argument to be used in UPPER() function. + * * @return Expr\Func An UPPER function expression. */ public function upper($x) @@ -534,6 +581,7 @@ class Expr * Creates a LENGTH() function expression with the given argument. * * @param mixed $x Argument to be used as argument of LENGTH() function. + * * @return Expr\Func A LENGTH function expression. */ public function length($x) @@ -545,6 +593,7 @@ class Expr * Creates a literal expression of the given argument. * * @param mixed $literal Argument to be converted to literal. + * * @return Expr\Literal */ public function literal($literal) @@ -556,6 +605,7 @@ class Expr * Quotes a literal value, if necessary, according to the DQL syntax. * * @param mixed $literal The literal value. + * * @return string */ private function _quoteLiteral($literal) @@ -572,9 +622,10 @@ class Expr /** * Creates an instance of BETWEEN() function, with the given argument. * - * @param mixed $val Valued to be inspected by range values. - * @param integer $x Starting range value to be used in BETWEEN() function. - * @param integer $y End point value to be used in BETWEEN() function. + * @param mixed $val Valued to be inspected by range values. + * @param integer $x Starting range value to be used in BETWEEN() function. + * @param integer $y End point value to be used in BETWEEN() function. + * * @return Expr\Func A BETWEEN expression. */ public function between($val, $x, $y) @@ -586,6 +637,7 @@ class Expr * Creates an instance of TRIM() function, with the given argument. * * @param mixed $x Argument to be used as argument of TRIM() function. + * * @return Expr\Func a TRIM expression. */ public function trim($x) diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Andx.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Andx.php old mode 100755 new mode 100644 index 10b5e8e6e2..432f714f6d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Andx.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Andx.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for building DQL and parts + * Expression class for building DQL and parts. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Base.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Base.php old mode 100755 new mode 100644 index 0fee7b2d50..6eac70a27c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Base.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Base.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Abstract base Expr class for building DQL parts + * Abstract base Expr class for building DQL parts. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -65,8 +64,9 @@ abstract class Base } /** - * @param array $args - * @return Base + * @param array $args + * + * @return Base */ public function addMultiple($args = array()) { @@ -78,8 +78,11 @@ abstract class Base } /** - * @param mixed $arg - * @return Base + * @param mixed $arg + * + * @return Base + * + * @throws \InvalidArgumentException */ public function add($arg) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Comparison.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Comparison.php old mode 100755 new mode 100644 index 52070df601..4103dcea9e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Comparison.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Comparison.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for DQL comparison expressions + * Expression class for DQL comparison expressions. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -56,9 +55,9 @@ class Comparison /** * Creates a comparison expression with the given arguments. * - * @param mixed $leftExpr - * @param string $operator - * @param mixed $rightExpr + * @param mixed $leftExpr + * @param string $operator + * @param mixed $rightExpr */ public function __construct($leftExpr, $operator, $rightExpr) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Composite.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Composite.php old mode 100755 new mode 100644 index cc0e0e8f34..4d9a251986 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Composite.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Composite.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for building DQL and parts + * Expression class for building DQL and parts. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -49,10 +48,10 @@ class Composite extends Base return implode($this->separator, $components); } - /** - * @param string $part - * @return string + * @param string $part + * + * @return string */ private function processQueryPart($part) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/From.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/From.php old mode 100755 new mode 100644 index 3a37703d20..9dcce9bbe2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/From.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/From.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for DQL from + * Expression class for DQL from. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -47,9 +46,9 @@ class From protected $indexBy; /** - * @param string $from The class name. - * @param string $alias The alias of the class. - * @param string $indexBy The index for the from. + * @param string $from The class name. + * @param string $alias The alias of the class. + * @param string $indexBy The index for the from. */ public function __construct($from, $alias, $indexBy = null) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Func.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Func.php old mode 100755 new mode 100644 index 6917dd230a..b4ed07cd3b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Func.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Func.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for generating DQL functions + * Expression class for generating DQL functions. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -44,8 +43,8 @@ class Func /** * Creates a function, with the given argument. * - * @param string $name - * @param array $arguments + * @param string $name + * @param array $arguments */ public function __construct($name, $arguments) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/GroupBy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/GroupBy.php old mode 100755 new mode 100644 index 40bb838ff7..efa3582bdb --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/GroupBy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/GroupBy.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for building DQL Group By parts + * Expression class for building DQL Group By parts. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Join.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Join.php old mode 100755 new mode 100644 index 3e6546eb0c..7a59e247ae --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Join.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Join.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for DQL from + * Expression class for DQL join. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -68,12 +67,12 @@ class Join protected $indexBy; /** - * @param string $joinType The condition type constant. Either INNER_JOIN or LEFT_JOIN. - * @param string $join The relationship to join - * @param string $alias The alias of the join - * @param string $conditionType The condition type constant. Either ON or WITH. - * @param string $condition The condition for the join - * @param string $indexBy The index for the join + * @param string $joinType The condition type constant. Either INNER_JOIN or LEFT_JOIN. + * @param string $join The relationship to join. + * @param string|null $alias The alias of the join. + * @param string|null $conditionType The condition type constant. Either ON or WITH. + * @param string|null $condition The condition for the join. + * @param string|null $indexBy The index for the join. */ public function __construct($joinType, $join, $alias = null, $conditionType = null, $condition = null, $indexBy = null) { @@ -133,7 +132,6 @@ class Join return $this->indexBy; } - /** * @return string */ diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Literal.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Literal.php old mode 100755 new mode 100644 index 991b04430b..98cee79d7e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Literal.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Literal.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for generating DQL functions + * Expression class for generating DQL functions. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -48,5 +47,4 @@ class Literal extends Base { return $this->parts; } - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Math.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Math.php old mode 100755 new mode 100644 index a41c848d85..9bf800de8f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Math.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Math.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for DQL math statements + * Expression class for DQL math statements. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -49,9 +48,9 @@ class Math /** * Creates a mathematical expression with the given arguments. * - * @param mixed $leftExpr - * @param string $operator - * @param mixed $rightExpr + * @param mixed $leftExpr + * @param string $operator + * @param mixed $rightExpr */ public function __construct($leftExpr, $operator, $rightExpr) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/OrderBy.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/OrderBy.php old mode 100755 new mode 100644 index e0e7ffcdb6..932548bd60 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/OrderBy.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/OrderBy.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for building DQL Order By parts + * Expression class for building DQL Order By parts. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -57,8 +56,8 @@ class OrderBy protected $parts = array(); /** - * @param string $sort - * @param string $order + * @param string|null $sort + * @param string|null $order */ public function __construct($sort = null, $order = null) { @@ -68,8 +67,10 @@ class OrderBy } /** - * @param string $sort - * @param string $order + * @param string $sort + * @param string|null $order + * + * @return void */ public function add($sort, $order = null) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Orx.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Orx.php old mode 100755 new mode 100644 index caecba6389..c4ff7ae30d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Orx.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Orx.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for building DQL OR clauses + * Expression class for building DQL OR clauses. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Select.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Select.php old mode 100755 new mode 100644 index 804d797d83..21df6c735d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Select.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Select.php @@ -20,9 +20,8 @@ namespace Doctrine\ORM\Query\Expr; /** - * Expression class for building DQL select statements + * Expression class for building DQL select statements. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Filter/SQLFilter.php old mode 100755 new mode 100644 index ce2096edc8..fc749f1514 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -36,12 +36,14 @@ abstract class SQLFilter { /** * The entity manager. + * * @var EntityManager */ private $em; /** * Parameters for the filter. + * * @var array */ private $parameters; @@ -49,7 +51,7 @@ abstract class SQLFilter /** * Constructs the SQLFilter object. * - * @param EntityManager $em The EM + * @param EntityManager $em The entity manager. */ final public function __construct(EntityManager $em) { @@ -59,11 +61,11 @@ abstract class SQLFilter /** * Sets a parameter that can be used by the filter. * - * @param string $name Name of the parameter. - * @param string $value Value of the parameter. - * @param string $type The parameter type. If specified, the given value will be run through - * the type conversion of this type. This is usually not needed for - * strings and numeric types. + * @param string $name Name of the parameter. + * @param string $value Value of the parameter. + * @param string|null $type The parameter type. If specified, the given value will be run through + * the type conversion of this type. This is usually not needed for + * strings and numeric types. * * @return SQLFilter The current SQL filter. */ @@ -93,6 +95,8 @@ abstract class SQLFilter * @param string $name Name of the parameter. * * @return string The SQL escaped parameter to use in a query. + * + * @throws \InvalidArgumentException */ final public function getParameter($name) { @@ -116,7 +120,10 @@ abstract class SQLFilter /** * Gets the SQL query part to add to a query. * - * @return string The constraint SQL if there is available, empty string otherwise + * @param ClassMetaData $targetEntity + * @param string $targetTableAlias + * + * @return string The constraint SQL if there is available, empty string otherwise. */ abstract public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/FilterCollection.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/FilterCollection.php old mode 100755 new mode 100644 index fc47eb1114..e26d093f8a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/FilterCollection.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Query; -use Doctrine\ORM\Configuration, - Doctrine\ORM\EntityManager; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManager; /** * Collection class for all the query filters. @@ -30,6 +30,7 @@ use Doctrine\ORM\Configuration, class FilterCollection { /* Filter STATES */ + /** * A filter object is in CLEAN state when it has no changed parameters. */ @@ -43,14 +44,14 @@ class FilterCollection /** * The used Configuration. * - * @var Doctrine\ORM\Configuration + * @var \Doctrine\ORM\Configuration */ private $config; /** * The EntityManager that "owns" this FilterCollection instance. * - * @var Doctrine\ORM\EntityManager + * @var \Doctrine\ORM\EntityManager */ private $em; @@ -67,7 +68,7 @@ class FilterCollection private $filterHash; /** - * @var integer $state The current state of this filter + * @var integer The current state of this filter. */ private $filtersState = self::FILTERS_STATE_CLEAN; @@ -83,7 +84,7 @@ class FilterCollection } /** - * Get all the enabled filters. + * Gets all the enabled filters. * * @return array The enabled filters. */ @@ -97,9 +98,9 @@ class FilterCollection * * @param string $name Name of the filter. * - * @throws \InvalidArgumentException If the filter does not exist. + * @return \Doctrine\ORM\Query\Filter\SQLFilter The enabled filter. * - * @return SQLFilter The enabled filter. + * @throws \InvalidArgumentException If the filter does not exist. */ public function enable($name) { @@ -125,7 +126,7 @@ class FilterCollection * * @param string $name Name of the filter. * - * @return SQLFilter The disabled filter. + * @return \Doctrine\ORM\Query\Filter\SQLFilter The disabled filter. * * @throws \InvalidArgumentException If the filter does not exist. */ @@ -143,11 +144,11 @@ class FilterCollection } /** - * Get an enabled filter from the collection. + * Gets an enabled filter from the collection. * * @param string $name Name of the filter. * - * @return SQLFilter The filter. + * @return \Doctrine\ORM\Query\Filter\SQLFilter The filter. * * @throws \InvalidArgumentException If the filter is not enabled. */ @@ -160,6 +161,18 @@ class FilterCollection return $this->enabledFilters[$name]; } + /** + * Checks if a filter is enabled. + * + * @param string $name Name of the filter. + * + * @return boolean True if the filter is enabled, false otherwise. + */ + public function isEnabled($name) + { + return isset($this->enabledFilters[$name]); + } + /** * @return boolean True, if the filter collection is clean. */ @@ -189,7 +202,7 @@ class FilterCollection } /** - * Set the filter state to dirty. + * Sets the filter state to dirty. */ public function setFiltersStateDirty() { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Lexer.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Lexer.php old mode 100755 new mode 100644 index beafa7deea..bf0b5f6db0 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Lexer.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Lexer.php @@ -108,11 +108,12 @@ class Lexer extends \Doctrine\Common\Lexer const T_WHERE = 154; const T_WITH = 155; const T_PARTIAL = 156; + const T_NEW = 157; /** * Creates a new query scanner object. * - * @param string $input a query string + * @param string $input A query string. */ public function __construct($input) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parameter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parameter.php old mode 100755 new mode 100644 index 57813cb63c..39e2a7a4f2 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parameter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parameter.php @@ -20,7 +20,7 @@ namespace Doctrine\ORM\Query; /** - * Define a Query Parameter + * Defines a Query Parameter. * * @link www.doctrine-project.org * @since 2.3 @@ -29,36 +29,42 @@ namespace Doctrine\ORM\Query; class Parameter { /** - * @var string Parameter name + * The parameter name. + * + * @var string */ private $name; /** - * @var mixed Parameter value + * The parameter value. + * + * @var mixed */ private $value; /** - * @var mixed Parameter type + * The parameter type. + * + * @var mixed */ private $type; /** * Constructor. * - * @param string $name Parameter name - * @param mixed $value Parameter value - * @param mixed $type Parameter type + * @param string $name Parameter name + * @param mixed $value Parameter value + * @param mixed $type Parameter type */ public function __construct($name, $value, $type = null) { - $this->name = trim($name, ':'); + $this->name = trim($name, ':'); $this->setValue($value, $type); } /** - * Retrieve the Parameter name. + * Retrieves the Parameter name. * * @return string */ @@ -68,7 +74,7 @@ class Parameter } /** - * Retrieve the Parameter value. + * Retrieves the Parameter value. * * @return mixed */ @@ -78,7 +84,7 @@ class Parameter } /** - * Retrieve the Parameter type. + * Retrieves the Parameter type. * * @return mixed */ @@ -88,10 +94,10 @@ class Parameter } /** - * Define the Parameter value. + * Defines the Parameter value. * - * @param mixed $value Parameter value - * @param mixed $type Parameter type + * @param mixed $value Parameter value. + * @param mixed $type Parameter type. */ public function setValue($value, $type = null) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ParameterTypeInferer.php old mode 100755 new mode 100644 index 45a0aab089..462f971ba9 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ParameterTypeInferer.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ParameterTypeInferer.php @@ -23,9 +23,8 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type; /** - * Provides an enclosed support for parameter infering. + * Provides an enclosed support for parameter inferring. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -36,13 +35,13 @@ use Doctrine\DBAL\Types\Type; class ParameterTypeInferer { /** - * Infer type of a given value, returning a compatible constant: + * Infers type of a given value, returning a compatible constant: * - Type (\Doctrine\DBAL\Types\Type::*) * - Connection (\Doctrine\DBAL\Connection::PARAM_*) * - * @param mixed $value Parameter value + * @param mixed $value Parameter value. * - * @return mixed Parameter type constant + * @return mixed Parameter type constant. */ public static function inferType($value) { @@ -50,6 +49,10 @@ class ParameterTypeInferer return Type::INTEGER; } + if (is_bool($value)) { + return Type::BOOLEAN; + } + if ($value instanceof \DateTime) { return Type::DATETIME; } @@ -62,4 +65,4 @@ class ParameterTypeInferer return \PDO::PARAM_STR; } -} \ No newline at end of file +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php old mode 100755 new mode 100644 index 1e1919d542..9a3baad48e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php @@ -2,7 +2,7 @@ /* * 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 MERCHARNTABILITY AND FITNESS FOR + * 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 @@ -31,10 +31,15 @@ use Doctrine\ORM\Mapping\ClassMetadata; * @author Jonathan Wage * @author Roman Borschel * @author Janne Vanhala + * @author Fabio B. Silva */ class Parser { - /** READ-ONLY: Maps BUILT-IN string function names to AST class names. */ + /** + * READ-ONLY: Maps BUILT-IN string function names to AST class names. + * + * @var array + */ private static $_STRING_FUNCTIONS = array( 'concat' => 'Doctrine\ORM\Query\AST\Functions\ConcatFunction', 'substring' => 'Doctrine\ORM\Query\AST\Functions\SubstringFunction', @@ -44,7 +49,11 @@ class Parser 'identity' => 'Doctrine\ORM\Query\AST\Functions\IdentityFunction', ); - /** READ-ONLY: Maps BUILT-IN numeric function names to AST class names. */ + /** + * READ-ONLY: Maps BUILT-IN numeric function names to AST class names. + * + * @var array + */ private static $_NUMERIC_FUNCTIONS = array( 'length' => 'Doctrine\ORM\Query\AST\Functions\LengthFunction', 'locate' => 'Doctrine\ORM\Query\AST\Functions\LocateFunction', @@ -57,7 +66,11 @@ class Parser 'bit_or' => 'Doctrine\ORM\Query\AST\Functions\BitOrFunction', ); - /** READ-ONLY: Maps BUILT-IN datetime function names to AST class names. */ + /** + * READ-ONLY: Maps BUILT-IN datetime function names to AST class names. + * + * @var array + */ private static $_DATETIME_FUNCTIONS = array( 'current_date' => 'Doctrine\ORM\Query\AST\Functions\CurrentDateFunction', 'current_time' => 'Doctrine\ORM\Query\AST\Functions\CurrentTimeFunction', @@ -66,81 +79,103 @@ class Parser 'date_sub' => 'Doctrine\ORM\Query\AST\Functions\DateSubFunction', ); - /** + /* * Expressions that were encountered during parsing of identifiers and expressions * and still need to be validated. */ - private $_deferredIdentificationVariables = array(); - private $_deferredPartialObjectExpressions = array(); - private $_deferredPathExpressions = array(); - private $_deferredResultVariables = array(); + + /** + * @var array + */ + private $deferredIdentificationVariables = array(); + + /** + * @var array + */ + private $deferredPartialObjectExpressions = array(); + + /** + * @var array + */ + private $deferredPathExpressions = array(); + + /** + * @var array + */ + private $deferredResultVariables = array(); + + /** + * @var array + */ + private $deferredNewObjectExpressions = array(); /** * The lexer. * * @var \Doctrine\ORM\Query\Lexer */ - private $_lexer; + private $lexer; /** * The parser result. * * @var \Doctrine\ORM\Query\ParserResult */ - private $_parserResult; + private $parserResult; /** * The EntityManager. * - * @var EnityManager + * @var \Doctrine\ORM\EntityManager */ - private $_em; + private $em; /** * The Query to parse. * * @var Query */ - private $_query; + private $query; /** * Map of declared query components in the parsed query. * * @var array */ - private $_queryComponents = array(); + private $queryComponents = array(); /** - * Keeps the nesting level of defined ResultVariables + * Keeps the nesting level of defined ResultVariables. * * @var integer */ - private $_nestingLevel = 0; + private $nestingLevel = 0; /** * Any additional custom tree walkers that modify the AST. * * @var array */ - private $_customTreeWalkers = array(); + private $customTreeWalkers = array(); /** * The custom last tree walker, if any, that is responsible for producing the output. * * @var TreeWalker */ - private $_customOutputWalker; + private $customOutputWalker; /** * @var array */ - private $_identVariableExpressions = array(); + private $identVariableExpressions = array(); /** - * Check if a function is internally defined. Used to prevent overwriting + * Checks if a function is internally defined. Used to prevent overwriting * of built-in functions through user-defined functions. * * @param string $functionName + * * @return bool */ static public function isInternalFunction($functionName) @@ -159,10 +194,10 @@ class Parser */ public function __construct(Query $query) { - $this->_query = $query; - $this->_em = $query->getEntityManager(); - $this->_lexer = new Lexer($query->getDql()); - $this->_parserResult = new ParserResult(); + $this->query = $query; + $this->em = $query->getEntityManager(); + $this->lexer = new Lexer($query->getDql()); + $this->parserResult = new ParserResult(); } /** @@ -170,20 +205,24 @@ class Parser * This tree walker will be run last over the AST, after any other walkers. * * @param string $className + * + * @return void */ public function setCustomOutputTreeWalker($className) { - $this->_customOutputWalker = $className; + $this->customOutputWalker = $className; } /** * Adds a custom tree walker for modifying the AST. * * @param string $className + * + * @return void */ public function addCustomTreeWalker($className) { - $this->_customTreeWalkers[] = $className; + $this->customTreeWalkers[] = $className; } /** @@ -193,7 +232,7 @@ class Parser */ public function getLexer() { - return $this->_lexer; + return $this->lexer; } /** @@ -203,21 +242,21 @@ class Parser */ public function getParserResult() { - return $this->_parserResult; + return $this->parserResult; } /** * Gets the EntityManager used by the parser. * - * @return EntityManager + * @return \Doctrine\ORM\EntityManager */ public function getEntityManager() { - return $this->_em; + return $this->em; } /** - * Parse and build AST for the given Query. + * Parses and builds AST for the given Query. * * @return \Doctrine\ORM\Query\AST\SelectStatement | * \Doctrine\ORM\Query\AST\UpdateStatement | @@ -230,21 +269,25 @@ class Parser // Process any deferred validations of some nodes in the AST. // This also allows post-processing of the AST for modification purposes. - $this->_processDeferredIdentificationVariables(); + $this->processDeferredIdentificationVariables(); - if ($this->_deferredPartialObjectExpressions) { - $this->_processDeferredPartialObjectExpressions(); + if ($this->deferredPartialObjectExpressions) { + $this->processDeferredPartialObjectExpressions(); } - if ($this->_deferredPathExpressions) { - $this->_processDeferredPathExpressions($AST); + if ($this->deferredPathExpressions) { + $this->processDeferredPathExpressions($AST); } - if ($this->_deferredResultVariables) { - $this->_processDeferredResultVariables(); + if ($this->deferredResultVariables) { + $this->processDeferredResultVariables(); } - $this->_processRootEntityAliasSelected(); + if ($this->deferredNewObjectExpressions) { + $this->processDeferredNewObjectExpressions($AST); + } + + $this->processRootEntityAliasSelected(); // TODO: Is there a way to remove this? It may impact the mixed hydration resultset a lot! $this->fixIdentificationVariableOrder($AST); @@ -258,40 +301,44 @@ class Parser * If they match, updates the lookahead token; otherwise raises a syntax * error. * - * @param int token type + * @param int $token The token type. + * * @return void - * @throws QueryException If the tokens dont match. + * + * @throws QueryException If the tokens don't match. */ public function match($token) { - $lookaheadType = $this->_lexer->lookahead['type']; + $lookaheadType = $this->lexer->lookahead['type']; // short-circuit on first condition, usually types match if ($lookaheadType !== $token && $token !== Lexer::T_IDENTIFIER && $lookaheadType <= Lexer::T_IDENTIFIER) { - $this->syntaxError($this->_lexer->getLiteral($token)); + $this->syntaxError($this->lexer->getLiteral($token)); } - $this->_lexer->moveNext(); + $this->lexer->moveNext(); } /** - * Free this parser enabling it to be reused + * Frees this parser, enabling it to be reused. * - * @param boolean $deep Whether to clean peek and reset errors - * @param integer $position Position to reset + * @param boolean $deep Whether to clean peek and reset errors. + * @param integer $position Position to reset. + * + * @return void */ public function free($deep = false, $position = 0) { // WARNING! Use this method with care. It resets the scanner! - $this->_lexer->resetPosition($position); + $this->lexer->resetPosition($position); // Deep = true cleans peek and also any previously defined errors if ($deep) { - $this->_lexer->resetPeek(); + $this->lexer->resetPeek(); } - $this->_lexer->token = null; - $this->_lexer->lookahead = null; + $this->lexer->token = null; + $this->lexer->lookahead = null; } /** @@ -303,19 +350,19 @@ class Parser { $AST = $this->getAST(); - if (($customWalkers = $this->_query->getHint(Query::HINT_CUSTOM_TREE_WALKERS)) !== false) { - $this->_customTreeWalkers = $customWalkers; + if (($customWalkers = $this->query->getHint(Query::HINT_CUSTOM_TREE_WALKERS)) !== false) { + $this->customTreeWalkers = $customWalkers; } - if (($customOutputWalker = $this->_query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER)) !== false) { - $this->_customOutputWalker = $customOutputWalker; + if (($customOutputWalker = $this->query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER)) !== false) { + $this->customOutputWalker = $customOutputWalker; } // Run any custom tree walkers over the AST - if ($this->_customTreeWalkers) { - $treeWalkerChain = new TreeWalkerChain($this->_query, $this->_parserResult, $this->_queryComponents); + if ($this->customTreeWalkers) { + $treeWalkerChain = new TreeWalkerChain($this->query, $this->parserResult, $this->queryComponents); - foreach ($this->_customTreeWalkers as $walker) { + foreach ($this->customTreeWalkers as $walker) { $treeWalkerChain->addTreeWalker($walker); } @@ -332,39 +379,42 @@ class Parser default: $treeWalkerChain->walkSelectStatement($AST); } + + $this->queryComponents = $treeWalkerChain->getQueryComponents(); } - $outputWalkerClass = $this->_customOutputWalker ?: __NAMESPACE__ . '\SqlWalker'; - $outputWalker = new $outputWalkerClass($this->_query, $this->_parserResult, $this->_queryComponents); + $outputWalkerClass = $this->customOutputWalker ?: __NAMESPACE__ . '\SqlWalker'; + $outputWalker = new $outputWalkerClass($this->query, $this->parserResult, $this->queryComponents); // Assign an SQL executor to the parser result - $this->_parserResult->setSqlExecutor($outputWalker->getExecutor($AST)); + $this->parserResult->setSqlExecutor($outputWalker->getExecutor($AST)); - return $this->_parserResult; + return $this->parserResult; } /** - * Fix order of identification variables. + * Fixes order of identification variables. * * They have to appear in the select clause in the same order as the * declarations (from ... x join ... y join ... z ...) appear in the query * as the hydration process relies on that order for proper operation. * * @param AST\SelectStatement|AST\DeleteStatement|AST\UpdateStatement $AST + * * @return void */ private function fixIdentificationVariableOrder($AST) { - if (count($this->_identVariableExpressions) <= 1) { + if (count($this->identVariableExpressions) <= 1) { return; } - foreach ($this->_queryComponents as $dqlAlias => $qComp) { - if ( ! isset($this->_identVariableExpressions[$dqlAlias])) { + foreach ($this->queryComponents as $dqlAlias => $qComp) { + if ( ! isset($this->identVariableExpressions[$dqlAlias])) { continue; } - $expr = $this->_identVariableExpressions[$dqlAlias]; + $expr = $this->identVariableExpressions[$dqlAlias]; $key = array_search($expr, $AST->selectClause->selectExpressions); unset($AST->selectClause->selectExpressions[$key]); @@ -376,45 +426,49 @@ class Parser /** * Generates a new syntax error. * - * @param string $expected Expected string. - * @param array $token Got token. + * @param string $expected Expected string. + * @param array|null $token Got token. + * + * @return void * * @throws \Doctrine\ORM\Query\QueryException */ public function syntaxError($expected = '', $token = null) { if ($token === null) { - $token = $this->_lexer->lookahead; + $token = $this->lexer->lookahead; } $tokenPos = (isset($token['position'])) ? $token['position'] : '-1'; $message = "line 0, col {$tokenPos}: Error: "; $message .= ($expected !== '') ? "Expected {$expected}, got " : 'Unexpected '; - $message .= ($this->_lexer->lookahead === null) ? 'end of string.' : "'{$token['value']}'"; + $message .= ($this->lexer->lookahead === null) ? 'end of string.' : "'{$token['value']}'"; - throw QueryException::syntaxError($message, QueryException::dqlError($this->_query->getDQL())); + throw QueryException::syntaxError($message, QueryException::dqlError($this->query->getDQL())); } /** * Generates a new semantical error. * - * @param string $message Optional message. - * @param array $token Optional token. + * @param string $message Optional message. + * @param array|null $token Optional token. + * + * @return void * * @throws \Doctrine\ORM\Query\QueryException */ public function semanticalError($message = '', $token = null) { if ($token === null) { - $token = $this->_lexer->lookahead; + $token = $this->lexer->lookahead; } // Minimum exposed chars ahead of token $distance = 12; // Find a position of a final word to display in error string - $dql = $this->_query->getDql(); + $dql = $this->query->getDql(); $length = strlen($dql); $pos = $token['position'] + $distance; $pos = strpos($dql, ' ', ($length > $pos) ? $pos : $length); @@ -426,18 +480,19 @@ class Parser // Building informative message $message = 'line 0, col ' . $tokenPos . " near '" . $tokenStr . "': Error: " . $message; - throw QueryException::semanticalError($message, QueryException::dqlError($this->_query->getDQL())); + throw QueryException::semanticalError($message, QueryException::dqlError($this->query->getDQL())); } /** - * Peek beyond the matched closing parenthesis and return the first token after that one. + * Peeks beyond the matched closing parenthesis and returns the first token after that one. + * + * @param boolean $resetPeek Reset peek after finding the closing parenthesis. * - * @param boolean $resetPeek Reset peek after finding the closing parenthesis * @return array */ - private function _peekBeyondClosingParenthesis($resetPeek = true) + private function peekBeyondClosingParenthesis($resetPeek = true) { - $token = $this->_lexer->peek(); + $token = $this->lexer->peek(); $numUnmatched = 1; while ($numUnmatched > 0 && $token !== null) { @@ -454,11 +509,11 @@ class Parser // Do nothing } - $token = $this->_lexer->peek(); + $token = $this->lexer->peek(); } if ($resetPeek) { - $this->_lexer->resetPeek(); + $this->lexer->resetPeek(); } return $token; @@ -467,9 +522,11 @@ class Parser /** * Checks if the given token indicates a mathematical operator. * + * @param array $token + * * @return boolean TRUE if the token is a mathematical operator, FALSE otherwise. */ - private function _isMathOperator($token) + private function isMathOperator($token) { return in_array($token['type'], array(Lexer::T_PLUS, Lexer::T_MINUS, Lexer::T_DIVIDE, Lexer::T_MULTIPLY)); } @@ -479,23 +536,24 @@ class Parser * * @return boolean TRUE if the next-next tokens start a function, FALSE otherwise. */ - private function _isFunction() + private function isFunction() { - $peek = $this->_lexer->peek(); - $nextpeek = $this->_lexer->peek(); + $lookaheadType = $this->lexer->lookahead['type']; + $peek = $this->lexer->peek(); - $this->_lexer->resetPeek(); + $this->lexer->resetPeek(); - // We deny the COUNT(SELECT * FROM User u) here. COUNT won't be considered a function - return ($peek['type'] === Lexer::T_OPEN_PARENTHESIS && $nextpeek['type'] !== Lexer::T_SELECT); + return ($lookaheadType >= Lexer::T_IDENTIFIER && $peek['type'] === Lexer::T_OPEN_PARENTHESIS); } /** * Checks whether the given token type indicates an aggregate function. * + * @param int $tokenType + * * @return boolean TRUE if the token type is an aggregate function, FALSE otherwise. */ - private function _isAggregateFunction($tokenType) + private function isAggregateFunction($tokenType) { return in_array($tokenType, array(Lexer::T_AVG, Lexer::T_MIN, Lexer::T_MAX, Lexer::T_SUM, Lexer::T_COUNT)); } @@ -505,9 +563,9 @@ class Parser * * @return boolean */ - private function _isNextAllAnySome() + private function isNextAllAnySome() { - return in_array($this->_lexer->lookahead['type'], array(Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME)); + return in_array($this->lexer->lookahead['type'], array(Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME)); } /** @@ -516,19 +574,19 @@ class Parser * * @return void */ - private function _processDeferredIdentificationVariables() + private function processDeferredIdentificationVariables() { - foreach ($this->_deferredIdentificationVariables as $deferredItem) { + foreach ($this->deferredIdentificationVariables as $deferredItem) { $identVariable = $deferredItem['expression']; // Check if IdentificationVariable exists in queryComponents - if ( ! isset($this->_queryComponents[$identVariable])) { + if ( ! isset($this->queryComponents[$identVariable])) { $this->semanticalError( "'$identVariable' is not defined.", $deferredItem['token'] ); } - $qComp = $this->_queryComponents[$identVariable]; + $qComp = $this->queryComponents[$identVariable]; // Check if queryComponent points to an AbstractSchemaName or a ResultVariable if ( ! isset($qComp['metadata'])) { @@ -546,23 +604,78 @@ class Parser } } + /** + * Validates that the given NewObjectExpression. + * + * @param \Doctrine\ORM\Query\AST\SelectClause $AST + * + * @return void + */ + private function processDeferredNewObjectExpressions($AST) + { + foreach ($this->deferredNewObjectExpressions as $deferredItem) { + $expression = $deferredItem['expression']; + $token = $deferredItem['token']; + $className = $expression->className; + $args = $expression->args; + $fromClassName = isset($AST->fromClause->identificationVariableDeclarations[0]->rangeVariableDeclaration->abstractSchemaName) + ? $AST->fromClause->identificationVariableDeclarations[0]->rangeVariableDeclaration->abstractSchemaName + : null; + + // If the namespace is not given then assumes the first FROM entity namespace + if (strpos($className, '\\') === false && ! class_exists($className) && strpos($fromClassName, '\\') !== false) { + $namespace = substr($fromClassName, 0 , strrpos($fromClassName, '\\')); + $fqcn = $namespace . '\\' . $className; + + if (class_exists($fqcn)) { + $expression->className = $fqcn; + $className = $fqcn; + } + } + + if ( ! class_exists($className)) { + $this->semanticalError(sprintf('Class "%s" is not defined.', $className), $token); + } + + $class = new \ReflectionClass($className); + + if ( ! $class->isInstantiable()) { + $this->semanticalError(sprintf('Class "%s" can not be instantiated.', $className), $token); + } + + if ($class->getConstructor() === null) { + $this->semanticalError(sprintf('Class "%s" has not a valid constructor.', $className), $token); + } + + if ($class->getConstructor()->getNumberOfRequiredParameters() > count($args)) { + $this->semanticalError(sprintf('Number of arguments does not match with "%s" constructor declaration.', $className), $token); + } + } + } + /** * Validates that the given PartialObjectExpression is semantically correct. * It must exist in query components list. * * @return void */ - private function _processDeferredPartialObjectExpressions() + private function processDeferredPartialObjectExpressions() { - foreach ($this->_deferredPartialObjectExpressions as $deferredItem) { + foreach ($this->deferredPartialObjectExpressions as $deferredItem) { $expr = $deferredItem['expression']; - $class = $this->_queryComponents[$expr->identificationVariable]['metadata']; + $class = $this->queryComponents[$expr->identificationVariable]['metadata']; foreach ($expr->partialFieldSet as $field) { if (isset($class->fieldMappings[$field])) { continue; } + if (isset($class->associationMappings[$field]) && + $class->associationMappings[$field]['isOwningSide'] && + $class->associationMappings[$field]['type'] & ClassMetadata::TO_ONE) { + continue; + } + $this->semanticalError( "There is no mapped field named '$field' on class " . $class->name . ".", $deferredItem['token'] ); @@ -583,19 +696,19 @@ class Parser * * @return void */ - private function _processDeferredResultVariables() + private function processDeferredResultVariables() { - foreach ($this->_deferredResultVariables as $deferredItem) { + foreach ($this->deferredResultVariables as $deferredItem) { $resultVariable = $deferredItem['expression']; // Check if ResultVariable exists in queryComponents - if ( ! isset($this->_queryComponents[$resultVariable])) { + if ( ! isset($this->queryComponents[$resultVariable])) { $this->semanticalError( "'$resultVariable' is not defined.", $deferredItem['token'] ); } - $qComp = $this->_queryComponents[$resultVariable]; + $qComp = $this->queryComponents[$resultVariable]; // Check if queryComponent points to an AbstractSchemaName or a ResultVariable if ( ! isset($qComp['resultVariable'])) { @@ -622,15 +735,16 @@ class Parser * SingleValuedAssociationPathExpression ::= IdentificationVariable "." SingleValuedAssociationField * CollectionValuedPathExpression ::= IdentificationVariable "." CollectionValuedAssociationField * - * @param array $deferredItem * @param mixed $AST + * + * @return void */ - private function _processDeferredPathExpressions($AST) + private function processDeferredPathExpressions($AST) { - foreach ($this->_deferredPathExpressions as $deferredItem) { + foreach ($this->deferredPathExpressions as $deferredItem) { $pathExpression = $deferredItem['expression']; - $qComp = $this->_queryComponents[$pathExpression->identificationVariable]; + $qComp = $this->queryComponents[$pathExpression->identificationVariable]; $class = $qComp['metadata']; if (($field = $pathExpression->field) === null) { @@ -691,16 +805,19 @@ class Parser } } - private function _processRootEntityAliasSelected() + /** + * @return void + */ + private function processRootEntityAliasSelected() { - if ( ! count($this->_identVariableExpressions)) { + if ( ! count($this->identVariableExpressions)) { return; } $foundRootEntity = false; - foreach ($this->_identVariableExpressions as $dqlAlias => $expr) { - if (isset($this->_queryComponents[$dqlAlias]) && $this->_queryComponents[$dqlAlias]['parent'] === null) { + foreach ($this->identVariableExpressions as $dqlAlias => $expr) { + if (isset($this->queryComponents[$dqlAlias]) && $this->queryComponents[$dqlAlias]['parent'] === null) { $foundRootEntity = true; } } @@ -719,9 +836,9 @@ class Parser */ public function QueryLanguage() { - $this->_lexer->moveNext(); + $this->lexer->moveNext(); - switch ($this->_lexer->lookahead['type']) { + switch ($this->lexer->lookahead['type']) { case Lexer::T_SELECT: $statement = $this->SelectStatement(); break; @@ -740,7 +857,7 @@ class Parser } // Check for end of string - if ($this->_lexer->lookahead !== null) { + if ($this->lexer->lookahead !== null) { $this->syntaxError('end of string'); } @@ -756,10 +873,10 @@ class Parser { $selectStatement = new AST\SelectStatement($this->SelectClause(), $this->FromClause()); - $selectStatement->whereClause = $this->_lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; - $selectStatement->groupByClause = $this->_lexer->isNextToken(Lexer::T_GROUP) ? $this->GroupByClause() : null; - $selectStatement->havingClause = $this->_lexer->isNextToken(Lexer::T_HAVING) ? $this->HavingClause() : null; - $selectStatement->orderByClause = $this->_lexer->isNextToken(Lexer::T_ORDER) ? $this->OrderByClause() : null; + $selectStatement->whereClause = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; + $selectStatement->groupByClause = $this->lexer->isNextToken(Lexer::T_GROUP) ? $this->GroupByClause() : null; + $selectStatement->havingClause = $this->lexer->isNextToken(Lexer::T_HAVING) ? $this->HavingClause() : null; + $selectStatement->orderByClause = $this->lexer->isNextToken(Lexer::T_ORDER) ? $this->OrderByClause() : null; return $selectStatement; } @@ -773,7 +890,7 @@ class Parser { $updateStatement = new AST\UpdateStatement($this->UpdateClause()); - $updateStatement->whereClause = $this->_lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; + $updateStatement->whereClause = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; return $updateStatement; } @@ -787,7 +904,7 @@ class Parser { $deleteStatement = new AST\DeleteStatement($this->DeleteClause()); - $deleteStatement->whereClause = $this->_lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; + $deleteStatement->whereClause = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; return $deleteStatement; } @@ -801,12 +918,12 @@ class Parser { $this->match(Lexer::T_IDENTIFIER); - $identVariable = $this->_lexer->token['value']; + $identVariable = $this->lexer->token['value']; - $this->_deferredIdentificationVariables[] = array( + $this->deferredIdentificationVariables[] = array( 'expression' => $identVariable, - 'nestingLevel' => $this->_nestingLevel, - 'token' => $this->_lexer->token, + 'nestingLevel' => $this->nestingLevel, + 'token' => $this->lexer->token, ); return $identVariable; @@ -821,11 +938,11 @@ class Parser { $this->match(Lexer::T_IDENTIFIER); - $aliasIdentVariable = $this->_lexer->token['value']; - $exists = isset($this->_queryComponents[$aliasIdentVariable]); + $aliasIdentVariable = $this->lexer->token['value']; + $exists = isset($this->queryComponents[$aliasIdentVariable]); if ($exists) { - $this->semanticalError("'$aliasIdentVariable' is already defined.", $this->_lexer->token); + $this->semanticalError("'$aliasIdentVariable' is already defined.", $this->lexer->token); } return $aliasIdentVariable; @@ -840,18 +957,18 @@ class Parser { $this->match(Lexer::T_IDENTIFIER); - $schemaName = ltrim($this->_lexer->token['value'], '\\'); + $schemaName = ltrim($this->lexer->token['value'], '\\'); if (strrpos($schemaName, ':') !== false) { list($namespaceAlias, $simpleClassName) = explode(':', $schemaName); - $schemaName = $this->_em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; + $schemaName = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; } $exists = class_exists($schemaName, true); if ( ! $exists) { - $this->semanticalError("Class '$schemaName' is not defined.", $this->_lexer->token); + $this->semanticalError("Class '$schemaName' is not defined.", $this->lexer->token); } return $schemaName; @@ -866,11 +983,11 @@ class Parser { $this->match(Lexer::T_IDENTIFIER); - $resultVariable = $this->_lexer->token['value']; - $exists = isset($this->_queryComponents[$resultVariable]); + $resultVariable = $this->lexer->token['value']; + $exists = isset($this->queryComponents[$resultVariable]); if ($exists) { - $this->semanticalError("'$resultVariable' is already defined.", $this->_lexer->token); + $this->semanticalError("'$resultVariable' is already defined.", $this->lexer->token); } return $resultVariable; @@ -885,13 +1002,13 @@ class Parser { $this->match(Lexer::T_IDENTIFIER); - $resultVariable = $this->_lexer->token['value']; + $resultVariable = $this->lexer->token['value']; // Defer ResultVariable validation - $this->_deferredResultVariables[] = array( + $this->deferredResultVariables[] = array( 'expression' => $resultVariable, - 'nestingLevel' => $this->_nestingLevel, - 'token' => $this->_lexer->token, + 'nestingLevel' => $this->nestingLevel, + 'token' => $this->lexer->token, ); return $resultVariable; @@ -906,7 +1023,7 @@ class Parser { $identVariable = $this->IdentificationVariable(); - if ( ! isset($this->_queryComponents[$identVariable])) { + if ( ! isset($this->queryComponents[$identVariable])) { $this->semanticalError( 'Identification Variable ' . $identVariable .' used in join path expression but was not defined before.' ); @@ -915,10 +1032,10 @@ class Parser $this->match(Lexer::T_DOT); $this->match(Lexer::T_IDENTIFIER); - $field = $this->_lexer->token['value']; + $field = $this->lexer->token['value']; // Validate association field - $qComp = $this->_queryComponents[$identVariable]; + $qComp = $this->queryComponents[$identVariable]; $class = $qComp['metadata']; if ( ! $class->hasAssociation($field)) { @@ -935,6 +1052,7 @@ class Parser * PathExpression ::= IdentificationVariable "." identifier * * @param integer $expectedTypes + * * @return \Doctrine\ORM\Query\AST\PathExpression */ public function PathExpression($expectedTypes) @@ -942,21 +1060,21 @@ class Parser $identVariable = $this->IdentificationVariable(); $field = null; - if ($this->_lexer->isNextToken(Lexer::T_DOT)) { + if ($this->lexer->isNextToken(Lexer::T_DOT)) { $this->match(Lexer::T_DOT); $this->match(Lexer::T_IDENTIFIER); - $field = $this->_lexer->token['value']; + $field = $this->lexer->token['value']; } // Creating AST node $pathExpr = new AST\PathExpression($expectedTypes, $identVariable, $field); - // Defer PathExpression validation if requested to be defered - $this->_deferredPathExpressions[] = array( + // Defer PathExpression validation if requested to be deferred + $this->deferredPathExpressions[] = array( 'expression' => $pathExpr, - 'nestingLevel' => $this->_nestingLevel, - 'token' => $this->_lexer->token, + 'nestingLevel' => $this->nestingLevel, + 'token' => $this->lexer->token, ); return $pathExpr; @@ -1029,7 +1147,7 @@ class Parser $this->match(Lexer::T_SELECT); // Check for DISTINCT - if ($this->_lexer->isNextToken(Lexer::T_DISTINCT)) { + if ($this->lexer->isNextToken(Lexer::T_DISTINCT)) { $this->match(Lexer::T_DISTINCT); $isDistinct = true; @@ -1039,7 +1157,7 @@ class Parser $selectExpressions = array(); $selectExpressions[] = $this->SelectExpression(); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $selectExpressions[] = $this->SelectExpression(); @@ -1058,7 +1176,7 @@ class Parser $isDistinct = false; $this->match(Lexer::T_SELECT); - if ($this->_lexer->isNextToken(Lexer::T_DISTINCT)) { + if ($this->lexer->isNextToken(Lexer::T_DISTINCT)) { $this->match(Lexer::T_DISTINCT); $isDistinct = true; @@ -1075,16 +1193,16 @@ class Parser public function UpdateClause() { $this->match(Lexer::T_UPDATE); - $token = $this->_lexer->lookahead; + $token = $this->lexer->lookahead; $abstractSchemaName = $this->AbstractSchemaName(); - if ($this->_lexer->isNextToken(Lexer::T_AS)) { + if ($this->lexer->isNextToken(Lexer::T_AS)) { $this->match(Lexer::T_AS); } $aliasIdentificationVariable = $this->AliasIdentificationVariable(); - $class = $this->_em->getClassMetadata($abstractSchemaName); + $class = $this->em->getClassMetadata($abstractSchemaName); // Building queryComponent $queryComponent = array( @@ -1092,18 +1210,18 @@ class Parser 'parent' => null, 'relation' => null, 'map' => null, - 'nestingLevel' => $this->_nestingLevel, + 'nestingLevel' => $this->nestingLevel, 'token' => $token, ); - $this->_queryComponents[$aliasIdentificationVariable] = $queryComponent; + $this->queryComponents[$aliasIdentificationVariable] = $queryComponent; $this->match(Lexer::T_SET); $updateItems = array(); $updateItems[] = $this->UpdateItem(); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $updateItems[] = $this->UpdateItem(); @@ -1124,21 +1242,21 @@ class Parser { $this->match(Lexer::T_DELETE); - if ($this->_lexer->isNextToken(Lexer::T_FROM)) { + if ($this->lexer->isNextToken(Lexer::T_FROM)) { $this->match(Lexer::T_FROM); } - $token = $this->_lexer->lookahead; + $token = $this->lexer->lookahead; $deleteClause = new AST\DeleteClause($this->AbstractSchemaName()); - if ($this->_lexer->isNextToken(Lexer::T_AS)) { + if ($this->lexer->isNextToken(Lexer::T_AS)) { $this->match(Lexer::T_AS); } $aliasIdentificationVariable = $this->AliasIdentificationVariable(); $deleteClause->aliasIdentificationVariable = $aliasIdentificationVariable; - $class = $this->_em->getClassMetadata($deleteClause->abstractSchemaName); + $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName); // Building queryComponent $queryComponent = array( @@ -1146,11 +1264,11 @@ class Parser 'parent' => null, 'relation' => null, 'map' => null, - 'nestingLevel' => $this->_nestingLevel, + 'nestingLevel' => $this->nestingLevel, 'token' => $token, ); - $this->_queryComponents[$aliasIdentificationVariable] = $queryComponent; + $this->queryComponents[$aliasIdentificationVariable] = $queryComponent; return $deleteClause; } @@ -1167,7 +1285,7 @@ class Parser $identificationVariableDeclarations = array(); $identificationVariableDeclarations[] = $this->IdentificationVariableDeclaration(); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $identificationVariableDeclarations[] = $this->IdentificationVariableDeclaration(); @@ -1188,7 +1306,7 @@ class Parser $identificationVariables = array(); $identificationVariables[] = $this->SubselectIdentificationVariableDeclaration(); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $identificationVariables[] = $this->SubselectIdentificationVariableDeclaration(); @@ -1233,7 +1351,7 @@ class Parser $groupByItems = array($this->GroupByItem()); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $groupByItems[] = $this->GroupByItem(); @@ -1255,7 +1373,7 @@ class Parser $orderByItems = array(); $orderByItems[] = $this->OrderByItem(); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $orderByItems[] = $this->OrderByItem(); @@ -1272,17 +1390,17 @@ class Parser public function Subselect() { // Increase query nesting level - $this->_nestingLevel++; + $this->nestingLevel++; $subselect = new AST\Subselect($this->SimpleSelectClause(), $this->SubselectFromClause()); - $subselect->whereClause = $this->_lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; - $subselect->groupByClause = $this->_lexer->isNextToken(Lexer::T_GROUP) ? $this->GroupByClause() : null; - $subselect->havingClause = $this->_lexer->isNextToken(Lexer::T_HAVING) ? $this->HavingClause() : null; - $subselect->orderByClause = $this->_lexer->isNextToken(Lexer::T_ORDER) ? $this->OrderByClause() : null; + $subselect->whereClause = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; + $subselect->groupByClause = $this->lexer->isNextToken(Lexer::T_GROUP) ? $this->GroupByClause() : null; + $subselect->havingClause = $this->lexer->isNextToken(Lexer::T_HAVING) ? $this->HavingClause() : null; + $subselect->orderByClause = $this->lexer->isNextToken(Lexer::T_ORDER) ? $this->OrderByClause() : null; // Decrease query nesting level - $this->_nestingLevel--; + $this->nestingLevel--; return $subselect; } @@ -1311,20 +1429,20 @@ class Parser public function GroupByItem() { // We need to check if we are in a IdentificationVariable or SingleValuedPathExpression - $glimpse = $this->_lexer->glimpse(); + $glimpse = $this->lexer->glimpse(); if ($glimpse['type'] === Lexer::T_DOT) { return $this->SingleValuedPathExpression(); } // Still need to decide between IdentificationVariable or ResultVariable - $lookaheadValue = $this->_lexer->lookahead['value']; + $lookaheadValue = $this->lexer->lookahead['value']; - if ( ! isset($this->_queryComponents[$lookaheadValue])) { + if ( ! isset($this->queryComponents[$lookaheadValue])) { $this->semanticalError('Cannot group by undefined identification or result variable.'); } - return (isset($this->_queryComponents[$lookaheadValue]['metadata'])) + return (isset($this->queryComponents[$lookaheadValue]['metadata'])) ? $this->IdentificationVariable() : $this->ResultVariable(); } @@ -1340,15 +1458,15 @@ class Parser public function OrderByItem() { - $this->_lexer->peek(); // lookahead => '.' - $this->_lexer->peek(); // lookahead => token after '.' - $peek = $this->_lexer->peek(); // lookahead => token after the token after the '.' - $this->_lexer->resetPeek(); - $glimpse = $this->_lexer->glimpse(); + $this->lexer->peek(); // lookahead => '.' + $this->lexer->peek(); // lookahead => token after '.' + $peek = $this->lexer->peek(); // lookahead => token after the token after the '.' + $this->lexer->resetPeek(); + $glimpse = $this->lexer->glimpse(); switch (true) { - case ($this->_isMathOperator($peek)): + case ($this->isMathOperator($peek)): $expr = $this->SimpleArithmeticExpression(); break; @@ -1356,7 +1474,7 @@ class Parser $expr = $this->SingleValuedPathExpression(); break; - case ($this->_lexer->peek() && $this->_isMathOperator($this->_peekBeyondClosingParenthesis())): + case ($this->lexer->peek() && $this->isMathOperator($this->peekBeyondClosingParenthesis())): $expr = $this->ScalarExpression(); break; @@ -1370,12 +1488,12 @@ class Parser $item = new AST\OrderByItem($expr); switch (true) { - case ($this->_lexer->isNextToken(Lexer::T_DESC)): + case ($this->lexer->isNextToken(Lexer::T_DESC)): $this->match(Lexer::T_DESC); $type = 'DESC'; break; - case ($this->_lexer->isNextToken(Lexer::T_ASC)): + case ($this->lexer->isNextToken(Lexer::T_ASC)): $this->match(Lexer::T_ASC); break; @@ -1398,22 +1516,24 @@ class Parser * NewValue ::= SimpleArithmeticExpression | "NULL" * * SimpleArithmeticExpression covers all *Primary grammar rules and also SimpleEntityExpression + * + * @return AST\ArithmeticExpression */ public function NewValue() { - if ($this->_lexer->isNextToken(Lexer::T_NULL)) { + if ($this->lexer->isNextToken(Lexer::T_NULL)) { $this->match(Lexer::T_NULL); return null; } - if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { + if ($this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { $this->match(Lexer::T_INPUT_PARAMETER); - return new AST\InputParameter($this->_lexer->token['value']); + return new AST\InputParameter($this->lexer->token['value']); } - return $this->SimpleArithmeticExpression(); + return $this->ArithmeticExpression(); } /** @@ -1424,13 +1544,16 @@ class Parser public function IdentificationVariableDeclaration() { $rangeVariableDeclaration = $this->RangeVariableDeclaration(); - $indexBy = $this->_lexer->isNextToken(Lexer::T_INDEX) ? $this->IndexBy() : null; + + $rangeVariableDeclaration->isRoot = true; + + $indexBy = $this->lexer->isNextToken(Lexer::T_INDEX) ? $this->IndexBy() : null; $joins = array(); while ( - $this->_lexer->isNextToken(Lexer::T_LEFT) || - $this->_lexer->isNextToken(Lexer::T_INNER) || - $this->_lexer->isNextToken(Lexer::T_JOIN) + $this->lexer->isNextToken(Lexer::T_LEFT) || + $this->lexer->isNextToken(Lexer::T_INNER) || + $this->lexer->isNextToken(Lexer::T_JOIN) ) { $joins[] = $this->Join(); } @@ -1448,7 +1571,7 @@ class Parser */ public function SubselectIdentificationVariableDeclaration() { - $this->_lexer->glimpse(); + $this->lexer->glimpse(); /* NOT YET IMPLEMENTED! @@ -1478,20 +1601,20 @@ class Parser $joinType = AST\Join::JOIN_TYPE_INNER; switch (true) { - case ($this->_lexer->isNextToken(Lexer::T_LEFT)): + case ($this->lexer->isNextToken(Lexer::T_LEFT)): $this->match(Lexer::T_LEFT); $joinType = AST\Join::JOIN_TYPE_LEFT; // Possible LEFT OUTER join - if ($this->_lexer->isNextToken(Lexer::T_OUTER)) { + if ($this->lexer->isNextToken(Lexer::T_OUTER)) { $this->match(Lexer::T_OUTER); $joinType = AST\Join::JOIN_TYPE_LEFTOUTER; } break; - case ($this->_lexer->isNextToken(Lexer::T_INNER)): + case ($this->lexer->isNextToken(Lexer::T_INNER)): $this->match(Lexer::T_INNER); break; @@ -1501,16 +1624,20 @@ class Parser $this->match(Lexer::T_JOIN); - $next = $this->_lexer->glimpse(); - $joinDeclaration = ($next['type'] === Lexer::T_DOT) - ? $this->JoinAssociationDeclaration() - : $this->RangeVariableDeclaration(); + $next = $this->lexer->glimpse(); + $joinDeclaration = ($next['type'] === Lexer::T_DOT) ? $this->JoinAssociationDeclaration() : $this->RangeVariableDeclaration(); + $adhocConditions = $this->lexer->isNextToken(Lexer::T_WITH); + $join = new AST\Join($joinType, $joinDeclaration); - // Create AST node - $join = new AST\Join($joinType, $joinDeclaration); + // Describe non-root join declaration + if ($joinDeclaration instanceof AST\RangeVariableDeclaration) { + $joinDeclaration->isRoot = false; + + $adhocConditions = true; + } // Check for ad-hoc Join conditions - if ($this->_lexer->isNextToken(Lexer::T_WITH) || $joinDeclaration instanceof AST\RangeVariableDeclaration) { + if ($adhocConditions) { $this->match(Lexer::T_WITH); $join->conditionalExpression = $this->ConditionalExpression(); @@ -1528,13 +1655,13 @@ class Parser { $abstractSchemaName = $this->AbstractSchemaName(); - if ($this->_lexer->isNextToken(Lexer::T_AS)) { + if ($this->lexer->isNextToken(Lexer::T_AS)) { $this->match(Lexer::T_AS); } - $token = $this->_lexer->lookahead; + $token = $this->lexer->lookahead; $aliasIdentificationVariable = $this->AliasIdentificationVariable(); - $classMetadata = $this->_em->getClassMetadata($abstractSchemaName); + $classMetadata = $this->em->getClassMetadata($abstractSchemaName); // Building queryComponent $queryComponent = array( @@ -1542,11 +1669,11 @@ class Parser 'parent' => null, 'relation' => null, 'map' => null, - 'nestingLevel' => $this->_nestingLevel, + 'nestingLevel' => $this->nestingLevel, 'token' => $token ); - $this->_queryComponents[$aliasIdentificationVariable] = $queryComponent; + $this->queryComponents[$aliasIdentificationVariable] = $queryComponent; return new AST\RangeVariableDeclaration($abstractSchemaName, $aliasIdentificationVariable); } @@ -1560,18 +1687,18 @@ class Parser { $joinAssociationPathExpression = $this->JoinAssociationPathExpression(); - if ($this->_lexer->isNextToken(Lexer::T_AS)) { + if ($this->lexer->isNextToken(Lexer::T_AS)) { $this->match(Lexer::T_AS); } $aliasIdentificationVariable = $this->AliasIdentificationVariable(); - $indexBy = $this->_lexer->isNextToken(Lexer::T_INDEX) ? $this->IndexBy() : null; + $indexBy = $this->lexer->isNextToken(Lexer::T_INDEX) ? $this->IndexBy() : null; $identificationVariable = $joinAssociationPathExpression->identificationVariable; $field = $joinAssociationPathExpression->associationField; - $class = $this->_queryComponents[$identificationVariable]['metadata']; - $targetClass = $this->_em->getClassMetadata($class->associationMappings[$field]['targetEntity']); + $class = $this->queryComponents[$identificationVariable]['metadata']; + $targetClass = $this->em->getClassMetadata($class->associationMappings[$field]['targetEntity']); // Building queryComponent $joinQueryComponent = array( @@ -1579,11 +1706,11 @@ class Parser 'parent' => $joinAssociationPathExpression->identificationVariable, 'relation' => $class->getAssociationMapping($field), 'map' => null, - 'nestingLevel' => $this->_nestingLevel, - 'token' => $this->_lexer->lookahead + 'nestingLevel' => $this->nestingLevel, + 'token' => $this->lexer->lookahead ); - $this->_queryComponents[$aliasIdentificationVariable] = $joinQueryComponent; + $this->queryComponents[$aliasIdentificationVariable] = $joinQueryComponent; return new AST\JoinAssociationDeclaration($joinAssociationPathExpression, $aliasIdentificationVariable, $indexBy); } @@ -1606,13 +1733,13 @@ class Parser $this->match(Lexer::T_OPEN_CURLY_BRACE); $this->match(Lexer::T_IDENTIFIER); - $partialFieldSet[] = $this->_lexer->token['value']; + $partialFieldSet[] = $this->lexer->token['value']; - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $this->match(Lexer::T_IDENTIFIER); - $partialFieldSet[] = $this->_lexer->token['value']; + $partialFieldSet[] = $this->lexer->token['value']; } $this->match(Lexer::T_CLOSE_CURLY_BRACE); @@ -1620,15 +1747,71 @@ class Parser $partialObjectExpression = new AST\PartialObjectExpression($identificationVariable, $partialFieldSet); // Defer PartialObjectExpression validation - $this->_deferredPartialObjectExpressions[] = array( + $this->deferredPartialObjectExpressions[] = array( 'expression' => $partialObjectExpression, - 'nestingLevel' => $this->_nestingLevel, - 'token' => $this->_lexer->token, + 'nestingLevel' => $this->nestingLevel, + 'token' => $this->lexer->token, ); return $partialObjectExpression; } + /** + * NewObjectExpression ::= "NEW" IdentificationVariable "(" NewObjectArg {"," NewObjectArg}* ")" + * + * @return \Doctrine\ORM\Query\AST\NewObjectExpression + */ + public function NewObjectExpression() + { + $this->match(Lexer::T_NEW); + $this->match(Lexer::T_IDENTIFIER); + + $token = $this->lexer->token; + $className = $token['value']; + + if (strrpos($className, ':') !== false) { + list($namespaceAlias, $simpleClassName) = explode(':', $className); + + $className = $this->em->getConfiguration() + ->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; + } + + $this->match(Lexer::T_OPEN_PARENTHESIS); + + $args[] = $this->NewObjectArg(); + + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { + $this->match(Lexer::T_COMMA); + + $args[] = $this->NewObjectArg(); + } + + $this->match(Lexer::T_CLOSE_PARENTHESIS); + + $expression = new AST\NewObjectExpression($className, $args); + + // Defer NewObjectExpression validation + $this->deferredNewObjectExpressions[] = array( + 'token' => $token, + 'expression' => $expression, + 'nestingLevel' => $this->nestingLevel, + ); + + return $expression; + } + + /** + * NewObjectArg ::= ScalarExpression + * + * @TODO - Maybe you should support other expressions and nested "new" operator + * + * @return \Doctrine\ORM\Query\AST\SimpleSelectExpression + */ + public function NewObjectArg() + { + return $this->ScalarExpression(); + } + /** * IndexBy ::= "INDEX" "BY" StateFieldPathExpression * @@ -1641,7 +1824,7 @@ class Parser $pathExpr = $this->StateFieldPathExpression(); // Add the INDEX BY info to the query component - $this->_queryComponents[$pathExpr->identificationVariable]['map'] = $pathExpr->field; + $this->queryComponents[$pathExpr->identificationVariable]['map'] = $pathExpr->field; return new AST\IndexBy($pathExpr); } @@ -1655,62 +1838,79 @@ class Parser */ public function ScalarExpression() { - $lookahead = $this->_lexer->lookahead['type']; + $lookahead = $this->lexer->lookahead['type']; + $peek = $this->lexer->glimpse(); - switch ($lookahead) { - case Lexer::T_IDENTIFIER: - $this->_lexer->peek(); // lookahead => '.' - $this->_lexer->peek(); // lookahead => token after '.' - $peek = $this->_lexer->peek(); // lookahead => token after the token after the '.' - $this->_lexer->resetPeek(); + switch (true) { + case ($lookahead === Lexer::T_INTEGER): + case ($lookahead === Lexer::T_FLOAT): + // SimpleArithmeticExpression : (- u.value ) or ( + u.value ) or ( - 1 ) or ( + 1 ) + case ($lookahead === Lexer::T_MINUS): + case ($lookahead === Lexer::T_PLUS): + return $this->SimpleArithmeticExpression(); - if ($this->_isMathOperator($peek)) { + case ($lookahead === Lexer::T_STRING): + return $this->StringPrimary(); + + case ($lookahead === Lexer::T_TRUE): + case ($lookahead === Lexer::T_FALSE): + $this->match($lookahead); + + return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token['value']); + + case ($lookahead === Lexer::T_INPUT_PARAMETER): + switch (true) { + case $this->isMathOperator($peek): + // :param + u.value + return $this->SimpleArithmeticExpression(); + + default: + return $this->InputParameter(); + } + + case ($lookahead === Lexer::T_CASE): + case ($lookahead === Lexer::T_COALESCE): + case ($lookahead === Lexer::T_NULLIF): + // Since NULLIF and COALESCE can be identified as a function, + // we need to check these before checking for FunctionDeclaration + return $this->CaseExpression(); + + case ($lookahead === Lexer::T_OPEN_PARENTHESIS): + return $this->SimpleArithmeticExpression(); + + //this check must be done before checking for a filed path expression + case ($this->isFunction()): + $this->lexer->peek(); // "(" + + switch (true) { + case ($this->isMathOperator($this->peekBeyondClosingParenthesis())): + // SUM(u.id) + COUNT(u.id) + return $this->SimpleArithmeticExpression(); + + case ($this->isAggregateFunction($this->lexer->lookahead['type'])): + return $this->AggregateExpression(); + + default: + // IDENTITY(u) + return $this->FunctionDeclaration(); + } + + break; + //it is no function, so it must be a field path + case ($lookahead === Lexer::T_IDENTIFIER): + $this->lexer->peek(); // lookahead => '.' + $this->lexer->peek(); // lookahead => token after '.' + $peek = $this->lexer->peek(); // lookahead => token after the token after the '.' + $this->lexer->resetPeek(); + + if ($this->isMathOperator($peek)) { return $this->SimpleArithmeticExpression(); } return $this->StateFieldPathExpression(); - case Lexer::T_INTEGER: - case Lexer::T_FLOAT: - return $this->SimpleArithmeticExpression(); - - case Lexer::T_STRING: - return $this->StringPrimary(); - - case Lexer::T_TRUE: - case Lexer::T_FALSE: - $this->match($lookahead); - - return new AST\Literal(AST\Literal::BOOLEAN, $this->_lexer->token['value']); - - case Lexer::T_INPUT_PARAMETER: - return $this->InputParameter(); - - case Lexer::T_CASE: - case Lexer::T_COALESCE: - case Lexer::T_NULLIF: - // Since NULLIF and COALESCE can be identified as a function, - // we need to check if before check for FunctionDeclaration - return $this->CaseExpression(); - default: - if ( ! ($this->_isFunction() || $this->_isAggregateFunction($lookahead))) { - $this->syntaxError(); - } - - // We may be in an ArithmeticExpression (find the matching ")" and inspect for Math operator) - $this->_lexer->peek(); // "(" - $peek = $this->_peekBeyondClosingParenthesis(); - - if ($this->_isMathOperator($peek)) { - return $this->SimpleArithmeticExpression(); - } - - if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) { - return $this->AggregateExpression(); - } - - return $this->FunctionDeclaration(); + $this->syntaxError(); } } @@ -1728,7 +1928,7 @@ class Parser */ public function CaseExpression() { - $lookahead = $this->_lexer->lookahead['type']; + $lookahead = $this->lexer->lookahead['type']; switch ($lookahead) { case Lexer::T_NULLIF: @@ -1738,8 +1938,8 @@ class Parser return $this->CoalesceExpression(); case Lexer::T_CASE: - $this->_lexer->resetPeek(); - $peek = $this->_lexer->peek(); + $this->lexer->resetPeek(); + $peek = $this->lexer->peek(); if ($peek['type'] === Lexer::T_WHEN) { return $this->GeneralCaseExpression(); @@ -1769,7 +1969,7 @@ class Parser $scalarExpressions = array(); $scalarExpressions[] = $this->ScalarExpression(); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $scalarExpressions[] = $this->ScalarExpression(); @@ -1802,7 +2002,7 @@ class Parser /** * GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END" * - * @return \Doctrine\ORM\Query\AST\GeneralExpression + * @return \Doctrine\ORM\Query\AST\GeneralCaseExpression */ public function GeneralCaseExpression() { @@ -1813,7 +2013,7 @@ class Parser do { $whenClauses[] = $this->WhenClause(); - } while ($this->_lexer->isNextToken(Lexer::T_WHEN)); + } while ($this->lexer->isNextToken(Lexer::T_WHEN)); $this->match(Lexer::T_ELSE); $scalarExpression = $this->ScalarExpression(); @@ -1825,6 +2025,8 @@ class Parser /** * SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" * CaseOperand ::= StateFieldPathExpression | TypeDiscriminator + * + * @return AST\SimpleCaseExpression */ public function SimpleCaseExpression() { @@ -1836,7 +2038,7 @@ class Parser do { $simpleWhenClauses[] = $this->SimpleWhenClause(); - } while ($this->_lexer->isNextToken(Lexer::T_WHEN)); + } while ($this->lexer->isNextToken(Lexer::T_WHEN)); $this->match(Lexer::T_ELSE); $scalarExpression = $this->ScalarExpression(); @@ -1848,7 +2050,7 @@ class Parser /** * WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression * - * @return \Doctrine\ORM\Query\AST\WhenExpression + * @return \Doctrine\ORM\Query\AST\WhenClause */ public function WhenClause() { @@ -1862,7 +2064,7 @@ class Parser /** * SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression * - * @return \Doctrine\ORM\Query\AST\SimpleWhenExpression + * @return \Doctrine\ORM\Query\AST\SimpleWhenClause */ public function SimpleWhenClause() { @@ -1885,8 +2087,8 @@ class Parser { $expression = null; $identVariable = null; - $peek = $this->_lexer->glimpse(); - $lookaheadType = $this->_lexer->lookahead['type']; + $peek = $this->lexer->glimpse(); + $lookaheadType = $this->lexer->lookahead['type']; switch (true) { // ScalarExpression (u.name) @@ -1907,16 +2109,16 @@ class Parser break; // DQL Function (SUM(u.value) or SUM(u.value) + 1) - case ($this->_isFunction()): - $this->_lexer->peek(); // "(" + case ($this->isFunction()): + $this->lexer->peek(); // "(" switch (true) { - case ($this->_isMathOperator($this->_peekBeyondClosingParenthesis())): + case ($this->isMathOperator($this->peekBeyondClosingParenthesis())): // SUM(u.id) + COUNT(u.id) $expression = $this->ScalarExpression(); break; - case ($this->_isAggregateFunction($lookaheadType)): + case ($this->isAggregateFunction($lookaheadType)): // COUNT(u.id) $expression = $this->AggregateExpression(); break; @@ -1953,22 +2155,27 @@ class Parser $expression = $this->SimpleArithmeticExpression(); break; + // NewObjectExpression (New ClassName(id, name)) + case ($lookaheadType === Lexer::T_NEW): + $expression = $this->NewObjectExpression(); + break; + default: $this->syntaxError( 'IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression', - $this->_lexer->lookahead + $this->lexer->lookahead ); } // [["AS"] ["HIDDEN"] AliasResultVariable] - if ($this->_lexer->isNextToken(Lexer::T_AS)) { + if ($this->lexer->isNextToken(Lexer::T_AS)) { $this->match(Lexer::T_AS); } $hiddenAliasResultVariable = false; - if ($this->_lexer->isNextToken(Lexer::T_HIDDEN)) { + if ($this->lexer->isNextToken(Lexer::T_HIDDEN)) { $this->match(Lexer::T_HIDDEN); $hiddenAliasResultVariable = true; @@ -1976,14 +2183,14 @@ class Parser $aliasResultVariable = null; - if ($this->_lexer->isNextToken(Lexer::T_IDENTIFIER)) { - $token = $this->_lexer->lookahead; + if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER)) { + $token = $this->lexer->lookahead; $aliasResultVariable = $this->AliasResultVariable(); // Include AliasResultVariable in query components. - $this->_queryComponents[$aliasResultVariable] = array( + $this->queryComponents[$aliasResultVariable] = array( 'resultVariable' => $expression, - 'nestingLevel' => $this->_nestingLevel, + 'nestingLevel' => $this->nestingLevel, 'token' => $token, ); } @@ -1993,7 +2200,7 @@ class Parser $expr = new AST\SelectExpression($expression, $aliasResultVariable, $hiddenAliasResultVariable); if ($identVariable) { - $this->_identVariableExpressions[$identVariable] = $expr; + $this->identVariableExpressions[$identVariable] = $expr; } return $expr; @@ -2009,9 +2216,9 @@ class Parser */ public function SimpleSelectExpression() { - $peek = $this->_lexer->glimpse(); + $peek = $this->lexer->glimpse(); - switch ($this->_lexer->lookahead['type']) { + switch ($this->lexer->lookahead['type']) { case Lexer::T_IDENTIFIER: switch (true) { case ($peek['type'] === Lexer::T_DOT): @@ -2024,13 +2231,13 @@ class Parser return new AST\SimpleSelectExpression($expression); - case ($this->_isFunction()): + case ($this->isFunction()): // SUM(u.id) + COUNT(u.id) - if ($this->_isMathOperator($this->_peekBeyondClosingParenthesis())) { + if ($this->isMathOperator($this->peekBeyondClosingParenthesis())) { return new AST\SimpleSelectExpression($this->ScalarExpression()); } // COUNT(u.id) - if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) { + if ($this->isAggregateFunction($this->lexer->lookahead['type'])) { return new AST\SimpleSelectExpression($this->AggregateExpression()); } // IDENTITY(u) @@ -2060,24 +2267,24 @@ class Parser // Do nothing } - $this->_lexer->peek(); + $this->lexer->peek(); $expression = $this->ScalarExpression(); $expr = new AST\SimpleSelectExpression($expression); - if ($this->_lexer->isNextToken(Lexer::T_AS)) { + if ($this->lexer->isNextToken(Lexer::T_AS)) { $this->match(Lexer::T_AS); } - if ($this->_lexer->isNextToken(Lexer::T_IDENTIFIER)) { - $token = $this->_lexer->lookahead; + if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER)) { + $token = $this->lexer->lookahead; $resultVariable = $this->AliasResultVariable(); $expr->fieldIdentificationVariable = $resultVariable; // Include AliasResultVariable in query components. - $this->_queryComponents[$resultVariable] = array( + $this->queryComponents[$resultVariable] = array( 'resultvariable' => $expr, - 'nestingLevel' => $this->_nestingLevel, + 'nestingLevel' => $this->nestingLevel, 'token' => $token, ); } @@ -2095,7 +2302,7 @@ class Parser $conditionalTerms = array(); $conditionalTerms[] = $this->ConditionalTerm(); - while ($this->_lexer->isNextToken(Lexer::T_OR)) { + while ($this->lexer->isNextToken(Lexer::T_OR)) { $this->match(Lexer::T_OR); $conditionalTerms[] = $this->ConditionalTerm(); @@ -2120,7 +2327,7 @@ class Parser $conditionalFactors = array(); $conditionalFactors[] = $this->ConditionalFactor(); - while ($this->_lexer->isNextToken(Lexer::T_AND)) { + while ($this->lexer->isNextToken(Lexer::T_AND)) { $this->match(Lexer::T_AND); $conditionalFactors[] = $this->ConditionalFactor(); @@ -2144,7 +2351,7 @@ class Parser { $not = false; - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; @@ -2173,18 +2380,18 @@ class Parser { $condPrimary = new AST\ConditionalPrimary; - if ( ! $this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { + if ( ! $this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { $condPrimary->simpleConditionalExpression = $this->SimpleConditionalExpression(); return $condPrimary; } - // Peek beyond the matching closing paranthesis ')' - $peek = $this->_peekBeyondClosingParenthesis(); + // Peek beyond the matching closing parenthesis ')' + $peek = $this->peekBeyondClosingParenthesis(); if (in_array($peek['value'], array("=", "<", "<=", "<>", ">", ">=", "!=")) || in_array($peek['type'], array(Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_IN, Lexer::T_IS, Lexer::T_EXISTS)) || - $this->_isMathOperator($peek)) { + $this->isMathOperator($peek)) { $condPrimary->simpleConditionalExpression = $this->SimpleConditionalExpression(); return $condPrimary; @@ -2206,76 +2413,92 @@ class Parser */ public function SimpleConditionalExpression() { - $token = $this->_lexer->lookahead; - - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { - $token = $this->_lexer->glimpse(); - } - - if ($token['type'] === Lexer::T_EXISTS) { + if ($this->lexer->isNextToken(Lexer::T_EXISTS)) { return $this->ExistsExpression(); } - $peek = $this->_lexer->glimpse(); + $token = $this->lexer->lookahead; + $peek = $this->lexer->glimpse(); + $lookahead = $token; - if ($token['type'] === Lexer::T_IDENTIFIER || $token['type'] === Lexer::T_INPUT_PARAMETER) { - if ($peek['value'] == '(') { - // Peek beyond the matching closing paranthesis ')' - $this->_lexer->peek(); - $token = $this->_peekBeyondClosingParenthesis(false); + if ($this->lexer->isNextToken(Lexer::T_NOT)) { + $token = $this->lexer->glimpse(); + } - if ($token['type'] === Lexer::T_NOT) { - $token = $this->_lexer->peek(); - } + if ($token['type'] === Lexer::T_IDENTIFIER || $token['type'] === Lexer::T_INPUT_PARAMETER || $this->isFunction()) { + // Peek beyond the matching closing parenthesis. + $beyond = $this->lexer->peek(); - $this->_lexer->resetPeek(); - } else { - // Peek beyond the PathExpression (or InputParameter) - $peek = $this->_lexer->peek(); + switch ($peek['value']) { + case '(': + //Peeks beyond the matched closing parenthesis. + $token = $this->peekBeyondClosingParenthesis(false); - while ($peek['value'] === '.') { - $this->_lexer->peek(); - $peek = $this->_lexer->peek(); - } + if ($token['type'] === Lexer::T_NOT) { + $token = $this->lexer->peek(); + } - // Also peek beyond a NOT if there is one - if ($peek['type'] === Lexer::T_NOT) { - $peek = $this->_lexer->peek(); - } + if ($token['type'] === Lexer::T_IS) { + $lookahead = $this->lexer->peek(); + } + break; - $token = $peek; + default: + // Peek beyond the PathExpression or InputParameter. + $token = $beyond; - // We need to go even further in case of IS (differenciate between NULL and EMPTY) - $lookahead = $this->_lexer->peek(); + while ($token['value'] === '.') { + $this->lexer->peek(); - // Also peek beyond a NOT if there is one - if ($lookahead['type'] === Lexer::T_NOT) { - $lookahead = $this->_lexer->peek(); - } + $token = $this->lexer->peek(); + } - $this->_lexer->resetPeek(); + // Also peek beyond a NOT if there is one. + if ($token['type'] === Lexer::T_NOT) { + $token = $this->lexer->peek(); + } + + // We need to go even further in case of IS (differentiate between NULL and EMPTY) + $lookahead = $this->lexer->peek(); } + + // Also peek beyond a NOT if there is one. + if ($lookahead['type'] === Lexer::T_NOT) { + $lookahead = $this->lexer->peek(); + } + + $this->lexer->resetPeek(); } - switch ($token['type']) { - case Lexer::T_BETWEEN: - return $this->BetweenExpression(); - case Lexer::T_LIKE: - return $this->LikeExpression(); - case Lexer::T_IN: - return $this->InExpression(); - case Lexer::T_INSTANCE: - return $this->InstanceOfExpression(); - case Lexer::T_IS: - if ($lookahead['type'] == Lexer::T_NULL) { - return $this->NullComparisonExpression(); - } - return $this->EmptyCollectionComparisonExpression(); - case Lexer::T_MEMBER: - return $this->CollectionMemberExpression(); - default: - return $this->ComparisonExpression(); + if ($token['type'] === Lexer::T_BETWEEN) { + return $this->BetweenExpression(); } + + if ($token['type'] === Lexer::T_LIKE) { + return $this->LikeExpression(); + } + + if ($token['type'] === Lexer::T_IN) { + return $this->InExpression(); + } + + if ($token['type'] === Lexer::T_INSTANCE) { + return $this->InstanceOfExpression(); + } + + if ($token['type'] === Lexer::T_MEMBER) { + return $this->CollectionMemberExpression(); + } + + if ($token['type'] === Lexer::T_IS && $lookahead['type'] === Lexer::T_NULL) { + return $this->NullComparisonExpression(); + } + + if ($token['type'] === Lexer::T_IS && $lookahead['type'] === Lexer::T_EMPTY) { + return $this->EmptyCollectionComparisonExpression(); + } + + return $this->ComparisonExpression(); } /** @@ -2285,19 +2508,19 @@ class Parser */ public function EmptyCollectionComparisonExpression() { - $emptyColletionCompExpr = new AST\EmptyCollectionComparisonExpression( + $emptyCollectionCompExpr = new AST\EmptyCollectionComparisonExpression( $this->CollectionValuedPathExpression() ); $this->match(Lexer::T_IS); - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); - $emptyColletionCompExpr->not = true; + $emptyCollectionCompExpr->not = true; } $this->match(Lexer::T_EMPTY); - return $emptyColletionCompExpr; + return $emptyCollectionCompExpr; } /** @@ -2313,7 +2536,7 @@ class Parser $not = false; $entityExpr = $this->EntityExpression(); - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; @@ -2321,7 +2544,7 @@ class Parser $this->match(Lexer::T_MEMBER); - if ($this->_lexer->isNextToken(Lexer::T_OF)) { + if ($this->lexer->isNextToken(Lexer::T_OF)) { $this->match(Lexer::T_OF); } @@ -2340,24 +2563,24 @@ class Parser */ public function Literal() { - switch ($this->_lexer->lookahead['type']) { + switch ($this->lexer->lookahead['type']) { case Lexer::T_STRING: $this->match(Lexer::T_STRING); - return new AST\Literal(AST\Literal::STRING, $this->_lexer->token['value']); + return new AST\Literal(AST\Literal::STRING, $this->lexer->token['value']); case Lexer::T_INTEGER: case Lexer::T_FLOAT: $this->match( - $this->_lexer->isNextToken(Lexer::T_INTEGER) ? Lexer::T_INTEGER : Lexer::T_FLOAT + $this->lexer->isNextToken(Lexer::T_INTEGER) ? Lexer::T_INTEGER : Lexer::T_FLOAT ); - return new AST\Literal(AST\Literal::NUMERIC, $this->_lexer->token['value']); + return new AST\Literal(AST\Literal::NUMERIC, $this->lexer->token['value']); case Lexer::T_TRUE: case Lexer::T_FALSE: $this->match( - $this->_lexer->isNextToken(Lexer::T_TRUE) ? Lexer::T_TRUE : Lexer::T_FALSE + $this->lexer->isNextToken(Lexer::T_TRUE) ? Lexer::T_TRUE : Lexer::T_FALSE ); - return new AST\Literal(AST\Literal::BOOLEAN, $this->_lexer->token['value']); + return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token['value']); default: $this->syntaxError('Literal'); @@ -2371,7 +2594,7 @@ class Parser */ public function InParameter() { - if ($this->_lexer->lookahead['type'] == Lexer::T_INPUT_PARAMETER) { + if ($this->lexer->lookahead['type'] == Lexer::T_INPUT_PARAMETER) { return $this->InputParameter(); } @@ -2387,7 +2610,7 @@ class Parser { $this->match(Lexer::T_INPUT_PARAMETER); - return new AST\InputParameter($this->_lexer->token['value']); + return new AST\InputParameter($this->lexer->token['value']); } /** @@ -2399,8 +2622,8 @@ class Parser { $expr = new AST\ArithmeticExpression; - if ($this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { - $peek = $this->_lexer->glimpse(); + if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { + $peek = $this->lexer->glimpse(); if ($peek['type'] === Lexer::T_SELECT) { $this->match(Lexer::T_OPEN_PARENTHESIS); @@ -2426,10 +2649,10 @@ class Parser $terms = array(); $terms[] = $this->ArithmeticTerm(); - while (($isPlus = $this->_lexer->isNextToken(Lexer::T_PLUS)) || $this->_lexer->isNextToken(Lexer::T_MINUS)) { + while (($isPlus = $this->lexer->isNextToken(Lexer::T_PLUS)) || $this->lexer->isNextToken(Lexer::T_MINUS)) { $this->match(($isPlus) ? Lexer::T_PLUS : Lexer::T_MINUS); - $terms[] = $this->_lexer->token['value']; + $terms[] = $this->lexer->token['value']; $terms[] = $this->ArithmeticTerm(); } @@ -2452,10 +2675,10 @@ class Parser $factors = array(); $factors[] = $this->ArithmeticFactor(); - while (($isMult = $this->_lexer->isNextToken(Lexer::T_MULTIPLY)) || $this->_lexer->isNextToken(Lexer::T_DIVIDE)) { + while (($isMult = $this->lexer->isNextToken(Lexer::T_MULTIPLY)) || $this->lexer->isNextToken(Lexer::T_DIVIDE)) { $this->match(($isMult) ? Lexer::T_MULTIPLY : Lexer::T_DIVIDE); - $factors[] = $this->_lexer->token['value']; + $factors[] = $this->lexer->token['value']; $factors[] = $this->ArithmeticFactor(); } @@ -2477,7 +2700,7 @@ class Parser { $sign = null; - if (($isPlus = $this->_lexer->isNextToken(Lexer::T_PLUS)) || $this->_lexer->isNextToken(Lexer::T_MINUS)) { + if (($isPlus = $this->lexer->isNextToken(Lexer::T_PLUS)) || $this->lexer->isNextToken(Lexer::T_MINUS)) { $this->match(($isPlus) ? Lexer::T_PLUS : Lexer::T_MINUS); $sign = $isPlus; } @@ -2494,30 +2717,31 @@ class Parser } /** - * ArithmeticPrimary ::= SingleValuedPathExpression | Literal | "(" SimpleArithmeticExpression ")" + * ArithmeticPrimary ::= SingleValuedPathExpression | Literal | ParenthesisExpression * | FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings * | FunctionsReturningDatetime | IdentificationVariable | ResultVariable * | InputParameter | CaseExpression */ public function ArithmeticPrimary() { - if ($this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { + if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { $this->match(Lexer::T_OPEN_PARENTHESIS); + $expr = $this->SimpleArithmeticExpression(); $this->match(Lexer::T_CLOSE_PARENTHESIS); - return $expr; + return new AST\ParenthesisExpression($expr); } - switch ($this->_lexer->lookahead['type']) { + switch ($this->lexer->lookahead['type']) { case Lexer::T_COALESCE: case Lexer::T_NULLIF: case Lexer::T_CASE: return $this->CaseExpression(); case Lexer::T_IDENTIFIER: - $peek = $this->_lexer->glimpse(); + $peek = $this->lexer->glimpse(); if ($peek['value'] == '(') { return $this->FunctionDeclaration(); @@ -2527,7 +2751,7 @@ class Parser return $this->SingleValuedPathExpression(); } - if (isset($this->_queryComponents[$this->_lexer->lookahead['value']]['resultVariable'])) { + if (isset($this->queryComponents[$this->lexer->lookahead['value']]['resultVariable'])) { return $this->ResultVariable(); } @@ -2537,10 +2761,10 @@ class Parser return $this->InputParameter(); default: - $peek = $this->_lexer->glimpse(); + $peek = $this->lexer->glimpse(); if ($peek['value'] == '(') { - if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) { + if ($this->isAggregateFunction($this->lexer->lookahead['type'])) { return $this->AggregateExpression(); } @@ -2555,12 +2779,12 @@ class Parser * StringExpression ::= StringPrimary | "(" Subselect ")" * * @return \Doctrine\ORM\Query\AST\StringPrimary | - * \Doctrine]ORM\Query\AST\Subselect + * \Doctrine\ORM\Query\AST\Subselect */ public function StringExpression() { - if ($this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { - $peek = $this->_lexer->glimpse(); + if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { + $peek = $this->lexer->glimpse(); if ($peek['type'] === Lexer::T_SELECT) { $this->match(Lexer::T_OPEN_PARENTHESIS); @@ -2579,18 +2803,18 @@ class Parser */ public function StringPrimary() { - $lookaheadType = $this->_lexer->lookahead['type']; + $lookaheadType = $this->lexer->lookahead['type']; switch ($lookaheadType) { case Lexer::T_IDENTIFIER: - $peek = $this->_lexer->glimpse(); + $peek = $this->lexer->glimpse(); if ($peek['value'] == '.') { return $this->StateFieldPathExpression(); } if ($peek['value'] == '(') { - // do NOT directly go to FunctionsReturningString() because it doesnt check for custom functions. + // do NOT directly go to FunctionsReturningString() because it doesn't check for custom functions. return $this->FunctionDeclaration(); } @@ -2600,7 +2824,7 @@ class Parser case Lexer::T_STRING: $this->match(Lexer::T_STRING); - return new AST\Literal(AST\Literal::STRING, $this->_lexer->token['value']); + return new AST\Literal(AST\Literal::STRING, $this->lexer->token['value']); case Lexer::T_INPUT_PARAMETER: return $this->InputParameter(); @@ -2611,7 +2835,7 @@ class Parser return $this->CaseExpression(); default: - if ($this->_isAggregateFunction($lookaheadType)) { + if ($this->isAggregateFunction($lookaheadType)) { return $this->AggregateExpression(); } } @@ -2629,9 +2853,9 @@ class Parser */ public function EntityExpression() { - $glimpse = $this->_lexer->glimpse(); + $glimpse = $this->lexer->glimpse(); - if ($this->_lexer->isNextToken(Lexer::T_IDENTIFIER) && $glimpse['value'] === '.') { + if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER) && $glimpse['value'] === '.') { return $this->SingleValuedAssociationPathExpression(); } @@ -2645,7 +2869,7 @@ class Parser */ public function SimpleEntityExpression() { - if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { + if ($this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { return $this->InputParameter(); } @@ -2661,7 +2885,7 @@ class Parser */ public function AggregateExpression() { - $lookaheadType = $this->_lexer->lookahead['type']; + $lookaheadType = $this->lexer->lookahead['type']; $isDistinct = false; if ( ! in_array($lookaheadType, array(Lexer::T_COUNT, Lexer::T_AVG, Lexer::T_MAX, Lexer::T_MIN, Lexer::T_SUM))) { @@ -2669,10 +2893,10 @@ class Parser } $this->match($lookaheadType); - $functionName = $this->_lexer->token['value']; + $functionName = $this->lexer->token['value']; $this->match(Lexer::T_OPEN_PARENTHESIS); - if ($this->_lexer->isNextToken(Lexer::T_DISTINCT)) { + if ($this->lexer->isNextToken(Lexer::T_DISTINCT)) { $this->match(Lexer::T_DISTINCT); $isDistinct = true; } @@ -2693,8 +2917,8 @@ class Parser */ public function QuantifiedExpression() { - $lookaheadType = $this->_lexer->lookahead['type']; - $value = $this->_lexer->lookahead['value']; + $lookaheadType = $this->lexer->lookahead['type']; + $value = $this->lexer->lookahead['value']; if ( ! in_array($lookaheadType, array(Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME))) { $this->syntaxError('ALL, ANY or SOME'); @@ -2721,7 +2945,7 @@ class Parser $not = false; $arithExpr1 = $this->ArithmeticExpression(); - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } @@ -2744,11 +2968,11 @@ class Parser */ public function ComparisonExpression() { - $this->_lexer->glimpse(); + $this->lexer->glimpse(); $leftExpr = $this->ArithmeticExpression(); $operator = $this->ComparisonOperator(); - $rightExpr = ($this->_isNextAllAnySome()) + $rightExpr = ($this->isNextAllAnySome()) ? $this->QuantifiedExpression() : $this->ArithmeticExpression(); @@ -2764,7 +2988,7 @@ class Parser { $inExpression = new AST\InExpression($this->ArithmeticExpression()); - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $inExpression->not = true; } @@ -2772,13 +2996,13 @@ class Parser $this->match(Lexer::T_IN); $this->match(Lexer::T_OPEN_PARENTHESIS); - if ($this->_lexer->isNextToken(Lexer::T_SELECT)) { + if ($this->lexer->isNextToken(Lexer::T_SELECT)) { $inExpression->subselect = $this->Subselect(); } else { $literals = array(); $literals[] = $this->InParameter(); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $literals[] = $this->InParameter(); } @@ -2800,7 +3024,7 @@ class Parser { $instanceOfExpression = new AST\InstanceOfExpression($this->IdentificationVariable()); - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $instanceOfExpression->not = true; } @@ -2810,12 +3034,12 @@ class Parser $exprValues = array(); - if ($this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { + if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { $this->match(Lexer::T_OPEN_PARENTHESIS); $exprValues[] = $this->InstanceOfParameter(); - while ($this->_lexer->isNextToken(Lexer::T_COMMA)) { + while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $exprValues[] = $this->InstanceOfParameter(); @@ -2842,10 +3066,10 @@ class Parser */ public function InstanceOfParameter() { - if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { + if ($this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { $this->match(Lexer::T_INPUT_PARAMETER); - return new AST\InputParameter($this->_lexer->token['value']); + return new AST\InputParameter($this->lexer->token['value']); } return $this->AliasIdentificationVariable(); @@ -2861,27 +3085,27 @@ class Parser $stringExpr = $this->StringExpression(); $not = false; - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } $this->match(Lexer::T_LIKE); - if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { + if ($this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { $this->match(Lexer::T_INPUT_PARAMETER); - $stringPattern = new AST\InputParameter($this->_lexer->token['value']); + $stringPattern = new AST\InputParameter($this->lexer->token['value']); } else { $stringPattern = $this->StringPrimary(); } $escapeChar = null; - if ($this->_lexer->lookahead['type'] === Lexer::T_ESCAPE) { + if ($this->lexer->lookahead['type'] === Lexer::T_ESCAPE) { $this->match(Lexer::T_ESCAPE); $this->match(Lexer::T_STRING); - $escapeChar = new AST\Literal(AST\Literal::STRING, $this->_lexer->token['value']); + $escapeChar = new AST\Literal(AST\Literal::STRING, $this->lexer->token['value']); } $likeExpr = new AST\LikeExpression($stringExpr, $stringPattern, $escapeChar); @@ -2891,24 +3115,43 @@ class Parser } /** - * NullComparisonExpression ::= (SingleValuedPathExpression | InputParameter) "IS" ["NOT"] "NULL" + * NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | SingleValuedPathExpression) "IS" ["NOT"] "NULL" * * @return \Doctrine\ORM\Query\AST\NullComparisonExpression */ public function NullComparisonExpression() { - if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { - $this->match(Lexer::T_INPUT_PARAMETER); - $expr = new AST\InputParameter($this->_lexer->token['value']); - } else { - $expr = $this->SingleValuedPathExpression(); + switch (true) { + case $this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER): + $this->match(Lexer::T_INPUT_PARAMETER); + + $expr = new AST\InputParameter($this->lexer->token['value']); + break; + + case $this->lexer->isNextToken(Lexer::T_NULLIF): + $expr = $this->NullIfExpression(); + break; + + case $this->lexer->isNextToken(Lexer::T_COALESCE): + $expr = $this->CoalesceExpression(); + break; + + case $this->isFunction(): + $expr = $this->FunctionDeclaration(); + break; + + default: + $expr = $this->SingleValuedPathExpression(); + break; } $nullCompExpr = new AST\NullComparisonExpression($expr); + $this->match(Lexer::T_IS); - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); + $nullCompExpr->not = true; } @@ -2926,7 +3169,7 @@ class Parser { $not = false; - if ($this->_lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } @@ -2949,7 +3192,7 @@ class Parser */ public function ComparisonOperator() { - switch ($this->_lexer->lookahead['value']) { + switch ($this->lexer->lookahead['value']) { case '=': $this->match(Lexer::T_EQUALS); @@ -2959,10 +3202,10 @@ class Parser $this->match(Lexer::T_LOWER_THAN); $operator = '<'; - if ($this->_lexer->isNextToken(Lexer::T_EQUALS)) { + if ($this->lexer->isNextToken(Lexer::T_EQUALS)) { $this->match(Lexer::T_EQUALS); $operator .= '='; - } else if ($this->_lexer->isNextToken(Lexer::T_GREATER_THAN)) { + } else if ($this->lexer->isNextToken(Lexer::T_GREATER_THAN)) { $this->match(Lexer::T_GREATER_THAN); $operator .= '>'; } @@ -2973,7 +3216,7 @@ class Parser $this->match(Lexer::T_GREATER_THAN); $operator = '>'; - if ($this->_lexer->isNextToken(Lexer::T_EQUALS)) { + if ($this->lexer->isNextToken(Lexer::T_EQUALS)) { $this->match(Lexer::T_EQUALS); $operator .= '='; } @@ -2993,10 +3236,12 @@ class Parser /** * FunctionDeclaration ::= FunctionsReturningStrings | FunctionsReturningNumerics | FunctionsReturningDatetime + * + * @return \Doctrine\ORM\Query\AST\Functions\FunctionNode */ public function FunctionDeclaration() { - $token = $this->_lexer->lookahead; + $token = $this->lexer->lookahead; $funcName = strtolower($token['value']); // Check for built-in functions first! @@ -3016,15 +3261,17 @@ class Parser } /** - * Helper function for FunctionDeclaration grammar rule + * Helper function for FunctionDeclaration grammar rule. + * + * @return \Doctrine\ORM\Query\AST\Functions\FunctionNode */ private function CustomFunctionDeclaration() { - $token = $this->_lexer->lookahead; + $token = $this->lexer->lookahead; $funcName = strtolower($token['value']); // Check for custom functions afterwards - $config = $this->_em->getConfiguration(); + $config = $this->em->getConfiguration(); switch (true) { case ($config->getCustomStringFunction($funcName) !== null): @@ -3049,10 +3296,12 @@ class Parser * "SQRT" "(" SimpleArithmeticExpression ")" | * "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | * "SIZE" "(" CollectionValuedPathExpression ")" + * + * @return \Doctrine\ORM\Query\AST\Functions\FunctionNode */ public function FunctionsReturningNumerics() { - $funcNameLower = strtolower($this->_lexer->lookahead['value']); + $funcNameLower = strtolower($this->lexer->lookahead['value']); $funcClass = self::$_NUMERIC_FUNCTIONS[$funcNameLower]; $function = new $funcClass($funcNameLower); @@ -3061,11 +3310,14 @@ class Parser return $function; } + /** + * @return \Doctrine\ORM\Query\AST\Functions\FunctionNode + */ public function CustomFunctionsReturningNumerics() { // getCustomNumericFunction is case-insensitive - $funcName = strtolower($this->_lexer->lookahead['value']); - $funcClass = $this->_em->getConfiguration()->getCustomNumericFunction($funcName); + $funcName = strtolower($this->lexer->lookahead['value']); + $funcClass = $this->em->getConfiguration()->getCustomNumericFunction($funcName); $function = new $funcClass($funcName); $function->parse($this); @@ -3075,10 +3327,12 @@ class Parser /** * FunctionsReturningDateTime ::= "CURRENT_DATE" | "CURRENT_TIME" | "CURRENT_TIMESTAMP" + * + * @return \Doctrine\ORM\Query\AST\Functions\FunctionNode */ public function FunctionsReturningDatetime() { - $funcNameLower = strtolower($this->_lexer->lookahead['value']); + $funcNameLower = strtolower($this->lexer->lookahead['value']); $funcClass = self::$_DATETIME_FUNCTIONS[$funcNameLower]; $function = new $funcClass($funcNameLower); @@ -3087,11 +3341,14 @@ class Parser return $function; } + /** + * @return \Doctrine\ORM\Query\AST\Functions\FunctionNode + */ public function CustomFunctionsReturningDatetime() { // getCustomDatetimeFunction is case-insensitive - $funcName = $this->_lexer->lookahead['value']; - $funcClass = $this->_em->getConfiguration()->getCustomDatetimeFunction($funcName); + $funcName = $this->lexer->lookahead['value']; + $funcClass = $this->em->getConfiguration()->getCustomDatetimeFunction($funcName); $function = new $funcClass($funcName); $function->parse($this); @@ -3106,10 +3363,12 @@ class Parser * "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" | * "LOWER" "(" StringPrimary ")" | * "UPPER" "(" StringPrimary ")" + * + * @return \Doctrine\ORM\Query\AST\Functions\FunctionNode */ public function FunctionsReturningStrings() { - $funcNameLower = strtolower($this->_lexer->lookahead['value']); + $funcNameLower = strtolower($this->lexer->lookahead['value']); $funcClass = self::$_STRING_FUNCTIONS[$funcNameLower]; $function = new $funcClass($funcNameLower); @@ -3118,11 +3377,14 @@ class Parser return $function; } + /** + * @return \Doctrine\ORM\Query\AST\Functions\FunctionNode + */ public function CustomFunctionsReturningStrings() { // getCustomStringFunction is case-insensitive - $funcName = $this->_lexer->lookahead['value']; - $funcClass = $this->_em->getConfiguration()->getCustomStringFunction($funcName); + $funcName = $this->lexer->lookahead['value']; + $funcClass = $this->em->getConfiguration()->getCustomStringFunction($funcName); $function = new $funcClass($funcName); $function->parse($this); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ParserResult.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ParserResult.php old mode 100755 new mode 100644 index e068622de4..dfd7dd2c9d --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ParserResult.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ParserResult.php @@ -65,8 +65,8 @@ class ParserResult /** * Gets the ResultSetMapping for the parsed query. * - * @return ResultSetMapping The result set mapping of the parsed query or NULL - * if the query is not a SELECT query. + * @return ResultSetMapping|null The result set mapping of the parsed query or NULL + * if the query is not a SELECT query. */ public function getResultSetMapping() { @@ -77,6 +77,8 @@ class ParserResult * Sets the ResultSetMapping of the parsed query. * * @param ResultSetMapping $rsm + * + * @return void */ public function setResultSetMapping(ResultSetMapping $rsm) { @@ -87,6 +89,8 @@ class ParserResult * Sets the SQL executor that should be used for this ParserResult. * * @param \Doctrine\ORM\Query\Exec\AbstractSqlExecutor $executor + * + * @return void */ public function setSqlExecutor($executor) { @@ -108,7 +112,9 @@ class ParserResult * several SQL parameter positions. * * @param string|integer $dqlPosition - * @param integer $sqlPosition + * @param integer $sqlPosition + * + * @return void */ public function addParameterMapping($dqlPosition, $sqlPosition) { @@ -129,6 +135,7 @@ class ParserResult * Gets the SQL parameter positions for a DQL parameter name/position. * * @param string|integer $dqlPosition The name or position of the DQL parameter. + * * @return array The positions of the corresponding SQL parameters. */ public function getSqlParameterPositions($dqlPosition) diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Printer.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Printer.php old mode 100755 new mode 100644 index 83640c5d78..ffb4575387 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Printer.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Printer.php @@ -59,7 +59,9 @@ class Printer * * This method is called before executing a production. * - * @param string $name production name + * @param string $name Production name. + * + * @return void */ public function startProduction($name) { @@ -71,6 +73,8 @@ class Printer * Decreases indentation level by one and prints a closing parenthesis. * * This method is called after executing a production. + * + * @return void */ public function endProduction() { @@ -81,7 +85,9 @@ class Printer /** * Prints text indented with spaces depending on current indentation level. * - * @param string $str text + * @param string $str The text. + * + * @return void */ public function println($str) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php old mode 100755 new mode 100644 index 6a03c8c504..da0d2d50c4 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php @@ -19,12 +19,9 @@ namespace Doctrine\ORM\Query; -use Doctrine\ORM\Query\AST\PathExpression; - /** - * Description of QueryException + * Description of QueryException. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -34,56 +31,108 @@ use Doctrine\ORM\Query\AST\PathExpression; */ class QueryException extends \Doctrine\ORM\ORMException { + /** + * @param string $dql + * + * @return QueryException + */ public static function dqlError($dql) { return new self($dql); } + /** + * @param string $message + * @param \Exception|null $previous + * + * @return QueryException + */ public static function syntaxError($message, $previous = null) { return new self('[Syntax Error] ' . $message, 0, $previous); } + /** + * @param string $message + * @param \Exception|null $previous + * + * @return QueryException + */ public static function semanticalError($message, $previous = null) { return new self('[Semantical Error] ' . $message, 0, $previous); } + /** + * @return QueryException + */ public static function invalidLockMode() { return new self('Invalid lock mode hint provided.'); } + /** + * @param string $expected + * @param string $received + * + * @return QueryException + */ public static function invalidParameterType($expected, $received) { return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.'); } + /** + * @param string $pos + * + * @return QueryException + */ public static function invalidParameterPosition($pos) { return new self('Invalid parameter position: ' . $pos); } + /** + * @return QueryException + */ public static function invalidParameterNumber() { return new self("Invalid parameter number: number of bound variables does not match number of tokens"); } + /** + * @param string $value + * + * @return QueryException + */ public static function invalidParameterFormat($value) { return new self('Invalid parameter format, '.$value.' given, but : or ? expected.'); } + /** + * @param string $key + * + * @return QueryException + */ public static function unknownParameter($key) { return new self("Invalid parameter: token ".$key." is not defined in the query."); } - public static function parameterTypeMissmatch() + /** + * @return QueryException + */ + public static function parameterTypeMismatch() { - return new self("DQL Query parameter and type numbers missmatch, but have to be exactly equal."); + return new self("DQL Query parameter and type numbers mismatch, but have to be exactly equal."); } + /** + * @param object $pathExpr + * + * @return QueryException + */ public static function invalidPathExpression($pathExpr) { return new self( @@ -91,21 +140,32 @@ class QueryException extends \Doctrine\ORM\ORMException ); } - public static function invalidLiteral($literal) { + /** + * @param string $literal + * + * @return QueryException + */ + public static function invalidLiteral($literal) + { return new self("Invalid literal '$literal'"); } /** * @param array $assoc + * + * @return QueryException */ public static function iterateWithFetchJoinCollectionNotAllowed($assoc) { return new self( "Invalid query operation: Not allowed to iterate over fetch join collections ". - "in class ".$assoc['sourceEntity']." assocation ".$assoc['fieldName'] + "in class ".$assoc['sourceEntity']." association ".$assoc['fieldName'] ); } + /** + * @return QueryException + */ public static function partialObjectsAreDangerous() { return new self( @@ -115,15 +175,23 @@ class QueryException extends \Doctrine\ORM\ORMException ); } + /** + * @param array $assoc + * + * @return QueryException + */ public static function overwritingJoinConditionsNotYetSupported($assoc) { return new self( "Unsupported query operation: It is not yet possible to overwrite the join ". - "conditions in class ".$assoc['sourceEntityName']." assocation ".$assoc['fieldName'].". ". + "conditions in class ".$assoc['sourceEntityName']." association ".$assoc['fieldName'].". ". "Use WITH to append additional join conditions to the association." ); } + /** + * @return QueryException + */ public static function associationPathInverseSideNotSupported() { return new self( @@ -132,13 +200,22 @@ class QueryException extends \Doctrine\ORM\ORMException ); } - public static function iterateWithFetchJoinNotAllowed($assoc) { + /** + * @param array $assoc + * + * @return QueryException + */ + public static function iterateWithFetchJoinNotAllowed($assoc) + { return new self( "Iterate with fetch join in class " . $assoc['sourceEntity'] . " using association " . $assoc['fieldName'] . " not allowed." ); } + /** + * @return QueryException + */ public static function associationPathCompositeKeyNotSupported() { return new self( @@ -148,9 +225,28 @@ class QueryException extends \Doctrine\ORM\ORMException ); } + /** + * @param string $className + * @param string $rootClass + * + * @return QueryException + */ public static function instanceOfUnrelatedClass($className, $rootClass) { return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " . - "inheritance hierachy exists between these two classes."); + "inheritance hierarchy exists between these two classes."); + } + + /** + * @param string $dqlAlias + * + * @return QueryException + */ + public static function invalidQueryComponent($dqlAlias) + { + return new self( + "Invalid query component given for DQL alias '" . $dqlAlias . "', ". + "requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys." + ); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php new file mode 100644 index 0000000000..775d700192 --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php @@ -0,0 +1,179 @@ +. + */ + +namespace Doctrine\ORM\Query; + +use Doctrine\Common\Collections\ArrayCollection; + +use Doctrine\Common\Collections\Expr\ExpressionVisitor; +use Doctrine\Common\Collections\Expr\Comparison; +use Doctrine\Common\Collections\Expr\CompositeExpression; +use Doctrine\Common\Collections\Expr\Value; + +use Doctrine\ORM\QueryBuilder; +use Doctrine\ORM\Query\Parameter; + +/** + * Converts Collection expressions to Query expressions. + * + * @author Kirill chEbba Chebunin + * @since 2.4 + */ +class QueryExpressionVisitor extends ExpressionVisitor +{ + /** + * @var array + */ + private static $operatorMap = array( + Comparison::GT => Expr\Comparison::GT, + Comparison::GTE => Expr\Comparison::GTE, + Comparison::LT => Expr\Comparison::LT, + Comparison::LTE => Expr\Comparison::LTE + ); + + /** + * @var Expr + */ + private $expr; + + /** + * @var array + */ + private $parameters = array(); + + /** + * Constructor with internal initialization. + */ + public function __construct() + { + $this->expr = new Expr(); + } + + /** + * Gets bound parameters. + * Filled after {@link dispach()}. + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getParameters() + { + return new ArrayCollection($this->parameters); + } + + /** + * Clears parameters. + * + * @return void + */ + public function clearParameters() + { + $this->parameters = array(); + } + + /** + * Converts Criteria expression to Query one based on static map. + * + * @param string $criteriaOperator + * + * @return string|null + */ + private static function convertComparisonOperator($criteriaOperator) + { + return isset(self::$operatorMap[$criteriaOperator]) ? self::$operatorMap[$criteriaOperator] : null; + } + + /** + * {@inheritDoc} + */ + public function walkCompositeExpression(CompositeExpression $expr) + { + $expressionList = array(); + + foreach ($expr->getExpressionList() as $child) { + $expressionList[] = $this->dispatch($child); + } + + switch($expr->getType()) { + case CompositeExpression::TYPE_AND: + return new Expr\Andx($expressionList); + + case CompositeExpression::TYPE_OR: + return new Expr\Orx($expressionList); + + default: + throw new \RuntimeException("Unknown composite " . $expr->getType()); + } + } + + /** + * {@inheritDoc} + */ + public function walkComparison(Comparison $comparison) + { + $parameterName = str_replace('.', '_', $comparison->getField()); + $parameter = new Parameter($parameterName, $this->walkValue($comparison->getValue())); + $placeholder = ':' . $parameterName; + + switch ($comparison->getOperator()) { + case Comparison::IN: + $this->parameters[] = $parameter; + return $this->expr->in($comparison->getField(), $placeholder); + + case Comparison::NIN: + $this->parameters[] = $parameter; + return $this->expr->notIn($comparison->getField(), $placeholder); + + case Comparison::EQ: + case Comparison::IS: + if ($this->walkValue($comparison->getValue()) === null) { + return $this->expr->isNull($comparison->getField()); + } + $this->parameters[] = $parameter; + return $this->expr->eq($comparison->getField(), $placeholder); + + case Comparison::NEQ: + if ($this->walkValue($comparison->getValue()) === null) { + return $this->expr->isNotNull($comparison->getField()); + } + $this->parameters[] = $parameter; + return $this->expr->neq($comparison->getField(), $placeholder); + + default: + $operator = self::convertComparisonOperator($comparison->getOperator()); + if ($operator) { + $this->parameters[] = $parameter; + return new Expr\Comparison( + $comparison->getField(), + $operator, + $placeholder + ); + } + + throw new \RuntimeException("Unknown comparison operator: " . $comparison->getOperator()); + } + } + + /** + * {@inheritDoc} + */ + public function walkValue(Value $value) + { + return $value->getValue(); + } +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ResultSetMapping.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ResultSetMapping.php old mode 100755 new mode 100644 index b8cbd32253..f4d11cf449 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ResultSetMapping.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ResultSetMapping.php @@ -36,97 +36,141 @@ namespace Doctrine\ORM\Query; class ResultSetMapping { /** + * Whether the result is mixed (contains scalar values together with field values). + * * @ignore - * @var boolean Whether the result is mixed (contains scalar values together with field values). + * @var boolean */ public $isMixed = false; /** + * Maps alias names to class names. + * * @ignore - * @var array Maps alias names to class names. + * @var array */ public $aliasMap = array(); /** + * Maps alias names to related association field names. + * * @ignore - * @var array Maps alias names to related association field names. + * @var array */ public $relationMap = array(); /** + * Maps alias names to parent alias names. + * * @ignore - * @var array Maps alias names to parent alias names. + * @var array */ public $parentAliasMap = array(); /** + * Maps column names in the result set to field names for each class. + * * @ignore - * @var array Maps column names in the result set to field names for each class. + * @var array */ public $fieldMappings = array(); /** + * Maps column names in the result set to the alias/field name to use in the mapped result. + * * @ignore - * @var array Maps column names in the result set to the alias/field name to use in the mapped result. + * @var array */ public $scalarMappings = array(); /** + * Maps column names in the result set to the alias/field type to use in the mapped result. + * * @ignore - * @var array Maps column names in the result set to the alias/field type to use in the mapped result. + * @var array */ public $typeMappings = array(); /** + * Maps entities in the result set to the alias name to use in the mapped result. + * * @ignore - * @var array Maps entities in the result set to the alias name to use in the mapped result. + * @var array */ public $entityMappings = array(); /** + * Maps column names of meta columns (foreign keys, discriminator columns, ...) to field names. + * * @ignore - * @var array Maps column names of meta columns (foreign keys, discriminator columns, ...) to field names. + * @var array */ public $metaMappings = array(); /** + * Maps column names in the result set to the alias they belong to. + * * @ignore - * @var array Maps column names in the result set to the alias they belong to. + * @var array */ public $columnOwnerMap = array(); /** + * List of columns in the result set that are used as discriminator columns. + * * @ignore - * @var array List of columns in the result set that are used as discriminator columns. + * @var array */ public $discriminatorColumns = array(); /** + * Maps alias names to field names that should be used for indexing. + * * @ignore - * @var array Maps alias names to field names that should be used for indexing. + * @var array */ public $indexByMap = array(); /** + * Map from column names to class names that declare the field the column is mapped to. + * * @ignore - * @var array Map from column names to class names that declare the field the column is mapped to. + * @var array */ public $declaringClasses = array(); /** - * @var array This is necessary to hydrate derivate foreign keys correctly. + * This is necessary to hydrate derivate foreign keys correctly. + * + * @var array */ public $isIdentifierColumn = array(); + /** + * Maps column names in the result set to field names for each new object expression. + * + * @var array + */ + public $newObjectMappings = array(); + + /** + * Maps metadata parameter names to the metadata attribute. + * + * @var array + */ + public $metadataParameterMapping = array(); + /** * Adds an entity result to this ResultSetMapping. * - * @param string $class The class name of the entity. - * @param string $alias The alias for the class. The alias must be unique among all entity - * results or joined entity results within this ResultSetMapping. - * @param string $resultAlias The result alias with which the entity result should be - * placed in the result structure. + * @param string $class The class name of the entity. + * @param string $alias The alias for the class. The alias must be unique among all entity + * results or joined entity results within this ResultSetMapping. + * @param string|null $resultAlias The result alias with which the entity result should be + * placed in the result structure. + * * @return ResultSetMapping This ResultSetMapping instance. + * * @todo Rename: addRootEntity */ public function addEntityResult($class, $alias, $resultAlias = null) @@ -146,10 +190,12 @@ class ResultSetMapping * The discriminator column will be used to determine the concrete class name to * instantiate. * - * @param string $alias The alias of the entity result or joined entity result the discriminator - * column should be used for. + * @param string $alias The alias of the entity result or joined entity result the discriminator + * column should be used for. * @param string $discrColumn The name of the discriminator column in the SQL result set. + * * @return ResultSetMapping This ResultSetMapping instance. + * * @todo Rename: addDiscriminatorColumn */ public function setDiscriminatorColumn($alias, $discrColumn) @@ -163,15 +209,16 @@ class ResultSetMapping /** * Sets a field to use for indexing an entity result or joined entity result. * - * @param string $alias The alias of an entity result or joined entity result. + * @param string $alias The alias of an entity result or joined entity result. * @param string $fieldName The name of the field to use for indexing. + * * @return ResultSetMapping This ResultSetMapping instance. */ public function addIndexBy($alias, $fieldName) { $found = false; - foreach ($this->fieldMappings as $columnName => $columnFieldName) { + foreach (array_merge($this->metaMappings, $this->fieldMappings) as $columnName => $columnFieldName) { if ( ! ($columnFieldName === $fieldName && $this->columnOwnerMap[$columnName] === $alias)) continue; $this->addIndexByColumn($alias, $columnName); @@ -196,9 +243,10 @@ class ResultSetMapping } /** - * Set to index by a scalar result column name + * Sets to index by a scalar result column name. + * + * @param string $resultColumnName * - * @param $resultColumnName * @return ResultSetMapping This ResultSetMapping instance. */ public function addIndexByScalar($resultColumnName) @@ -211,8 +259,9 @@ class ResultSetMapping /** * Sets a column to use for indexing an entity or joined entity result by the given alias name. * - * @param $alias - * @param $resultColumnName + * @param string $alias + * @param string $resultColumnName + * * @return ResultSetMapping This ResultSetMapping instance. */ public function addIndexByColumn($alias, $resultColumnName) @@ -227,7 +276,9 @@ class ResultSetMapping * a field set for indexing. * * @param string $alias + * * @return boolean + * * @todo Rename: isIndexed($alias) */ public function hasIndexBy($alias) @@ -240,7 +291,9 @@ class ResultSetMapping * as part of an entity result or joined entity result. * * @param string $columnName The name of the column in the SQL result set. + * * @return boolean + * * @todo Rename: isField */ public function isFieldResult($columnName) @@ -251,15 +304,17 @@ class ResultSetMapping /** * Adds a field to the result that belongs to an entity or joined entity. * - * @param string $alias The alias of the root entity or joined entity to which the field belongs. - * @param string $columnName The name of the column in the SQL result set. - * @param string $fieldName The name of the field on the declaring class. - * @param string $declaringClass The name of the class that declares/owns the specified field. - * When $alias refers to a superclass in a mapped hierarchy but - * the field $fieldName is defined on a subclass, specify that here. - * If not specified, the field is assumed to belong to the class - * designated by $alias. + * @param string $alias The alias of the root entity or joined entity to which the field belongs. + * @param string $columnName The name of the column in the SQL result set. + * @param string $fieldName The name of the field on the declaring class. + * @param string|null $declaringClass The name of the class that declares/owns the specified field. + * When $alias refers to a superclass in a mapped hierarchy but + * the field $fieldName is defined on a subclass, specify that here. + * If not specified, the field is assumed to belong to the class + * designated by $alias. + * * @return ResultSetMapping This ResultSetMapping instance. + * * @todo Rename: addField */ public function addFieldResult($alias, $columnName, $fieldName, $declaringClass = null) @@ -281,11 +336,14 @@ class ResultSetMapping /** * Adds a joined entity result. * - * @param string $class The class name of the joined entity. - * @param string $alias The unique alias to use for the joined entity. + * @param string $class The class name of the joined entity. + * @param string $alias The unique alias to use for the joined entity. * @param string $parentAlias The alias of the entity result that is the parent of this joined result. - * @param object $relation The association field that connects the parent entity result with the joined entity result. + * @param object $relation The association field that connects the parent entity result + * with the joined entity result. + * * @return ResultSetMapping This ResultSetMapping instance. + * * @todo Rename: addJoinedEntity */ public function addJoinedEntityResult($class, $alias, $parentAlias, $relation) @@ -301,8 +359,8 @@ class ResultSetMapping * Adds a scalar result mapping. * * @param string $columnName The name of the column in the SQL result set. - * @param string $alias The result alias with which the scalar result should be placed in the result structure. - * @param string $type The column type + * @param string $alias The result alias with which the scalar result should be placed in the result structure. + * @param string $type The column type * * @return ResultSetMapping This ResultSetMapping instance. * @@ -320,11 +378,24 @@ class ResultSetMapping return $this; } + /** + * Adds a metadata parameter mappings. + * + * @param mixed $parameter The parameter name in the SQL result set. + * @param string $attribute The metadata attribute. + */ + public function addMetadataParameterMapping($parameter, $attribute) + { + $this->metadataParameterMapping[$parameter] = $attribute; + } + /** * Checks whether a column with a given name is mapped as a scalar result. * - * @param string $columName The name of the column in the SQL result set. + * @param string $columnName The name of the column in the SQL result set. + * * @return boolean + * * @todo Rename: isScalar */ public function isScalarResult($columnName) @@ -337,6 +408,7 @@ class ResultSetMapping * identified by the given unique alias. * * @param string $alias + * * @return string */ public function getClassName($alias) @@ -348,6 +420,7 @@ class ResultSetMapping * Gets the field alias for a column that is mapped as a scalar value. * * @param string $columnName The name of the column in the SQL result set. + * * @return string */ public function getScalarAlias($columnName) @@ -359,6 +432,7 @@ class ResultSetMapping * Gets the name of the class that owns a field mapping for the specified column. * * @param string $columnName + * * @return string */ public function getDeclaringClass($columnName) @@ -367,8 +441,8 @@ class ResultSetMapping } /** - * * @param string $alias + * * @return AssociationMapping */ public function getRelation($alias) @@ -377,8 +451,8 @@ class ResultSetMapping } /** - * * @param string $alias + * * @return boolean */ public function isRelation($alias) @@ -390,6 +464,7 @@ class ResultSetMapping * Gets the alias of the class that owns a field mapping for the specified column. * * @param string $columnName + * * @return string */ public function getEntityAlias($columnName) @@ -401,6 +476,7 @@ class ResultSetMapping * Gets the parent alias of the given alias. * * @param string $alias + * * @return string */ public function getParentAlias($alias) @@ -412,6 +488,7 @@ class ResultSetMapping * Checks whether the given alias has a parent alias. * * @param string $alias + * * @return boolean */ public function hasParentAlias($alias) @@ -423,6 +500,7 @@ class ResultSetMapping * Gets the field name for a column name. * * @param string $columnName + * * @return string */ public function getFieldName($columnName) @@ -431,7 +509,6 @@ class ResultSetMapping } /** - * * @return array */ public function getAliasMap() @@ -451,6 +528,7 @@ class ResultSetMapping /** * Checks whether this ResultSetMapping defines a mixed result. + * * Mixed results can only occur in object and array (graph) hydration. In such a * case a mixed result means that scalar values are mixed with objects/array in * the result. @@ -465,13 +543,15 @@ class ResultSetMapping /** * Adds a meta column (foreign key or discriminator column) to the result set. * - * @param string $alias - * @param string $columnName - * @param string $fieldName - * @param bool + * @param string $alias The result alias with which the meta result should be placed in the result structure. + * @param string $columnName The name of the column in the SQL result set. + * @param string $fieldName The name of the field on the declaring class. + * @param bool $isIdentifierColumn + * @param string $type The column type + * * @return ResultSetMapping This ResultSetMapping instance. */ - public function addMetaResult($alias, $columnName, $fieldName, $isIdentifierColumn = false) + public function addMetaResult($alias, $columnName, $fieldName, $isIdentifierColumn = false, $type = null) { $this->metaMappings[$columnName] = $fieldName; $this->columnOwnerMap[$columnName] = $alias; @@ -480,6 +560,11 @@ class ResultSetMapping $this->isIdentifierColumn[$alias][$columnName] = true; } + if ($type) { + $this->typeMappings[$columnName] = $type; + } + return $this; } } + diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php old mode 100755 new mode 100644 index 8e31bcf94f..ad159e0a56 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -23,97 +23,230 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping\ClassMetadataInfo; /** - * A ResultSetMappingBuilder uses the EntityManager to automatically populate entity fields + * A ResultSetMappingBuilder uses the EntityManager to automatically populate entity fields. * * @author Michael Ridgway * @since 2.1 */ class ResultSetMappingBuilder extends ResultSetMapping { + /** + * Picking this rename mode will register entity columns as is, + * as they are in the database. This can cause clashes when multiple + * entities are fetched that have columns with the same name. + * + * @var int + */ + const COLUMN_RENAMING_NONE = 1; + + /** + * Picking custom renaming allows the user to define the renaming + * of specific columns with a rename array that contains column names as + * keys and result alias as values. + * + * @var int + */ + const COLUMN_RENAMING_CUSTOM = 2; + + /** + * Incremental renaming uses a result set mapping internal counter to add a + * number to each column result, leading to uniqueness. This only works if + * you use {@see generateSelectClause()} to generate the SELECT clause for + * you. + * + * @var int + */ + const COLUMN_RENAMING_INCREMENT = 3; + + /** + * @var int + */ + private $sqlCounter = 0; + /** * @var EntityManager */ private $em; /** - * @param EntityManager + * Default column renaming mode. + * + * @var int */ - public function __construct(EntityManager $em) + private $defaultRenameMode; + + /** + * @param EntityManager $em + * @param integer $defaultRenameMode + */ + public function __construct(EntityManager $em, $defaultRenameMode = self::COLUMN_RENAMING_NONE) { - $this->em = $em; + $this->em = $em; + $this->defaultRenameMode = $defaultRenameMode; } /** * Adds a root entity and all of its fields to the result set. * - * @param string $class The class name of the root entity. - * @param string $alias The unique alias to use for the root entity. - * @param array $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName) + * @param string $class The class name of the root entity. + * @param string $alias The unique alias to use for the root entity. + * @param array $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). + * @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). + * + * @return void */ - public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = array()) + public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = array(), $renameMode = null) { + $renameMode = $renameMode ?: $this->defaultRenameMode; + $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); + $this->addEntityResult($class, $alias); - $this->addAllClassFields($class, $alias, $renamedColumns); + $this->addAllClassFields($class, $alias, $columnAliasMap); } /** * Adds a joined entity and all of its fields to the result set. * - * @param string $class The class name of the joined entity. - * @param string $alias The unique alias to use for the joined entity. - * @param string $parentAlias The alias of the entity result that is the parent of this joined result. - * @param object $relation The association field that connects the parent entity result with the joined entity result. - * @param array $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName) + * @param string $class The class name of the joined entity. + * @param string $alias The unique alias to use for the joined entity. + * @param string $parentAlias The alias of the entity result that is the parent of this joined result. + * @param object $relation The association field that connects the parent entity result + * with the joined entity result. + * @param array $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). + * @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). + * + * @return void */ - public function addJoinedEntityFromClassMetadata($class, $alias, $parentAlias, $relation, $renamedColumns = array()) + public function addJoinedEntityFromClassMetadata($class, $alias, $parentAlias, $relation, $renamedColumns = array(), $renameMode = null) { + $renameMode = $renameMode ?: $this->defaultRenameMode; + $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); + $this->addJoinedEntityResult($class, $alias, $parentAlias, $relation); - $this->addAllClassFields($class, $alias, $renamedColumns); + $this->addAllClassFields($class, $alias, $columnAliasMap); } /** - * Adds all fields of the given class to the result set mapping (columns and meta fields) + * Adds all fields of the given class to the result set mapping (columns and meta fields). + * + * @param string $class + * @param string $alias + * @param array $columnAliasMap + * + * @return void + * + * @throws \InvalidArgumentException */ - protected function addAllClassFields($class, $alias, $renamedColumns = array()) + protected function addAllClassFields($class, $alias, $columnAliasMap = array()) { $classMetadata = $this->em->getClassMetadata($class); + $platform = $this->em->getConnection()->getDatabasePlatform(); + if ($classMetadata->isInheritanceTypeSingleTable() || $classMetadata->isInheritanceTypeJoined()) { throw new \InvalidArgumentException('ResultSetMapping builder does not currently support inheritance.'); } - $platform = $this->em->getConnection()->getDatabasePlatform(); + + foreach ($classMetadata->getColumnNames() as $columnName) { $propertyName = $classMetadata->getFieldName($columnName); - if (isset($renamedColumns[$columnName])) { - $columnName = $renamedColumns[$columnName]; - } - $columnName = $platform->getSQLResultCasing($columnName); - if (isset($this->fieldMappings[$columnName])) { + $columnAlias = $platform->getSQLResultCasing($columnAliasMap[$columnName]); + + if (isset($this->fieldMappings[$columnAlias])) { throw new \InvalidArgumentException("The column '$columnName' conflicts with another column in the mapper."); } - $this->addFieldResult($alias, $columnName, $propertyName); + + $this->addFieldResult($alias, $columnAlias, $propertyName); } + foreach ($classMetadata->associationMappings as $associationMapping) { if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) { foreach ($associationMapping['joinColumns'] as $joinColumn) { - $columnName = $joinColumn['name']; - $renamedColumnName = isset($renamedColumns[$columnName]) ? $renamedColumns[$columnName] : $columnName; - $renamedColumnName = $platform->getSQLResultCasing($renamedColumnName); - if (isset($this->metaMappings[$renamedColumnName])) { - throw new \InvalidArgumentException("The column '$renamedColumnName' conflicts with another column in the mapper."); + $columnName = $joinColumn['name']; + $columnAlias = $platform->getSQLResultCasing($columnAliasMap[$columnName]); + + if (isset($this->metaMappings[$columnAlias])) { + throw new \InvalidArgumentException("The column '$columnAlias' conflicts with another column in the mapper."); } - $this->addMetaResult($alias, $renamedColumnName, $columnName); + + $this->addMetaResult( + $alias, + $columnAlias, + $columnName, + (isset($associationMapping['id']) && $associationMapping['id'] === true) + ); } } } } + /** + * Gets column alias for a given column. + * + * @param string $columnName + * @param int $mode + * @param array $customRenameColumns + * + * @return string + */ + private function getColumnAlias($columnName, $mode, array $customRenameColumns) + { + switch ($mode) { + case self::COLUMN_RENAMING_INCREMENT: + return $columnName . $this->sqlCounter++; + + case self::COLUMN_RENAMING_CUSTOM: + return isset($customRenameColumns[$columnName]) + ? $customRenameColumns[$columnName] : $columnName; + + case self::COLUMN_RENAMING_NONE: + return $columnName; + + } + } + + /** + * Retrieves a class columns and join columns aliases that are used in the SELECT clause. + * + * This depends on the renaming mode selected by the user. + * + * @param string $className + * @param int $mode + * @param array $customRenameColumns + * + * @return array + */ + private function getColumnAliasMap($className, $mode, array $customRenameColumns) + { + if ($customRenameColumns) { // for BC with 2.2-2.3 API + $mode = self::COLUMN_RENAMING_CUSTOM; + } + + $columnAlias = array(); + $class = $this->em->getClassMetadata($className); + + foreach ($class->getColumnNames() as $columnName) { + $columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns); + } + + foreach ($class->associationMappings as $associationMapping) { + if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) { + foreach ($associationMapping['joinColumns'] as $joinColumn) { + $columnName = $joinColumn['name']; + $columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns); + } + } + } + + return $columnAlias; + } /** * Adds the mappings of the results of native SQL queries to the result set. * - * @param ClassMetadataInfo $class - * @param array $queryMapping - * @return ResultSetMappingBuilder + * @param ClassMetadataInfo $class + * @param array $queryMapping + * + * @return ResultSetMappingBuilder */ public function addNamedNativeQueryMapping(ClassMetadataInfo $class, array $queryMapping) { @@ -127,13 +260,13 @@ class ResultSetMappingBuilder extends ResultSetMapping /** * Adds the class mapping of the results of native SQL queries to the result set. * - * @param ClassMetadataInfo $class - * @param string $resultClassName + * @param ClassMetadataInfo $class + * @param string $resultClassName + * * @return ResultSetMappingBuilder */ public function addNamedNativeQueryResultClassMapping(ClassMetadataInfo $class, $resultClassName) { - $classMetadata = $this->em->getClassMetadata($resultClassName); $shortName = $classMetadata->reflClass->getShortName(); $alias = strtolower($shortName[0]).'0'; @@ -166,9 +299,10 @@ class ResultSetMappingBuilder extends ResultSetMapping /** * Adds the result set mapping of the results of native SQL queries to the result set. * - * @param ClassMetadataInfo $class - * @param string $resultSetMappingName - * @return ResultSetMappingBuilder + * @param ClassMetadataInfo $class + * @param string $resultSetMappingName + * + * @return ResultSetMappingBuilder */ public function addNamedNativeQueryResultSetMapping(ClassMetadataInfo $class, $resultSetMappingName) { @@ -212,9 +346,12 @@ class ResultSetMappingBuilder extends ResultSetMapping * Adds the entity result mapping of the results of native SQL queries to the result set. * * @param ClassMetadataInfo $classMetadata - * @param array $entityMapping - * @param string $alias + * @param array $entityMapping + * @param string $alias + * * @return ResultSetMappingBuilder + * + * @throws \InvalidArgumentException */ public function addNamedNativeQueryEntityResultMapping(ClassMetadataInfo $classMetadata, array $entityMapping, $alias) { @@ -261,4 +398,51 @@ class ResultSetMappingBuilder extends ResultSetMapping return $this; } + + /** + * Generates the Select clause from this ResultSetMappingBuilder. + * + * Works only for all the entity results. The select parts for scalar + * expressions have to be written manually. + * + * @param array $tableAliases + * + * @return string + */ + public function generateSelectClause($tableAliases = array()) + { + $sql = ""; + + foreach ($this->columnOwnerMap as $columnName => $dqlAlias) { + $tableAlias = isset($tableAliases[$dqlAlias]) + ? $tableAliases[$dqlAlias] : $dqlAlias; + + if ($sql) { + $sql .= ", "; + } + + $sql .= $tableAlias . "."; + + if (isset($this->fieldMappings[$columnName])) { + $class = $this->em->getClassMetadata($this->declaringClasses[$columnName]); + $sql .= $class->fieldMappings[$this->fieldMappings[$columnName]]['columnName']; + } else if (isset($this->metaMappings[$columnName])) { + $sql .= $this->metaMappings[$columnName]; + } else if (isset($this->discriminatorColumn[$columnName])) { + $sql .= $this->discriminatorColumn[$columnName]; + } + + $sql .= " AS " . $columnName; + } + + return $sql; + } + + /** + * @return string + */ + public function __toString() + { + return $this->generateSelectClause(array()); + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php old mode 100755 new mode 100644 index d3608e3a0f..157bbf618b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php @@ -19,12 +19,13 @@ namespace Doctrine\ORM\Query; -use Doctrine\DBAL\LockMode, - Doctrine\DBAL\Types\Type, - Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Query, - Doctrine\ORM\Query\QueryException, - Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Query; +use Doctrine\ORM\Query\QueryException; +use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\Mapping\ClassMetadataInfo; /** * The SqlWalker is a TreeWalker that walks over a DQL AST and constructs @@ -34,6 +35,7 @@ use Doctrine\DBAL\LockMode, * @author Roman Borschel * @author Benjamin Eberlei * @author Alexander + * @author Fabio B. Silva * @since 2.0 * @todo Rename: SQLWalker */ @@ -50,40 +52,47 @@ class SqlWalker implements TreeWalker private $rsm; /** - * Counters for generating unique column aliases. + * Counter for generating unique column aliases. * * @var integer */ private $aliasCounter = 0; /** - * Counters for generating unique table aliases. + * Counter for generating unique table aliases. * * @var integer */ private $tableAliasCounter = 0; /** - * Counters for generating unique scalar result. + * Counter for generating unique scalar result. * * @var integer */ private $scalarResultCounter = 1; /** - * Counters for generating unique parameter indexes. + * Counter for generating unique parameter indexes. * * @var integer */ private $sqlParamIndex = 0; + /** + * Counter for generating indexes. + * + * @var integer + */ + private $newObjectCounter = 0; + /** * @var ParserResult */ private $parserResult; /** - * @var EntityManager + * @var \Doctrine\ORM\EntityManager */ private $em; @@ -93,7 +102,7 @@ class SqlWalker implements TreeWalker private $conn; /** - * @var AbstractQuery + * @var \Doctrine\ORM\AbstractQuery */ private $query; @@ -110,7 +119,14 @@ class SqlWalker implements TreeWalker private $scalarResultAliasMap = array(); /** - * Map from DQL-Alias + Field-Name to SQL Column Alias + * Map from Table-Alias + Column-Name to OrderBy-Direction. + * + * @var array + */ + private $orderedColumnsMap = array(); + + /** + * Map from DQL-Alias + Field-Name to SQL Column Alias. * * @var array */ @@ -132,7 +148,7 @@ class SqlWalker implements TreeWalker /** * The DQL alias of the root class of the currently traversed query. - * + * * @var array */ private $rootAliases = array(); @@ -148,7 +164,7 @@ class SqlWalker implements TreeWalker /** * The database platform abstraction. * - * @var AbstractPlatform + * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ private $platform; @@ -187,7 +203,7 @@ class SqlWalker implements TreeWalker /** * Gets the Connection used by the walker. * - * @return Connection + * @return \Doctrine\DBAL\Connection */ public function getConnection() { @@ -197,7 +213,7 @@ class SqlWalker implements TreeWalker /** * Gets the EntityManager used by the walker. * - * @return EntityManager + * @return \Doctrine\ORM\EntityManager */ public function getEntityManager() { @@ -208,6 +224,7 @@ class SqlWalker implements TreeWalker * Gets the information about a single query component. * * @param string $dqlAlias The DQL alias. + * * @return array */ public function getQueryComponent($dqlAlias) @@ -216,9 +233,29 @@ class SqlWalker implements TreeWalker } /** - * Gets an executor that can be used to execute the result of this walker. - * - * @return AbstractExecutor + * {@inheritdoc} + */ + public function getQueryComponents() + { + return $this->queryComponents; + } + + /** + * {@inheritdoc} + */ + public function setQueryComponent($dqlAlias, array $queryComponent) + { + $requiredKeys = array('metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token'); + + if (array_diff($requiredKeys, array_keys($queryComponent))) { + throw QueryException::invalidQueryComponent($dqlAlias); + } + + $this->queryComponents[$dqlAlias] = $queryComponent; + } + + /** + * {@inheritdoc} */ public function getExecutor($AST) { @@ -246,7 +283,8 @@ class SqlWalker implements TreeWalker * Generates a unique, short SQL table alias. * * @param string $tableName Table name - * @param string $dqlAlias The DQL alias. + * @param string $dqlAlias The DQL alias. + * * @return string Generated table alias. */ public function getSQLTableAlias($tableName, $dqlAlias = '') @@ -267,6 +305,7 @@ class SqlWalker implements TreeWalker * @param string $tableName * @param string $alias * @param string $dqlAlias + * * @return string */ public function setSQLTableAlias($tableName, $alias, $dqlAlias = '') @@ -282,6 +321,7 @@ class SqlWalker implements TreeWalker * Gets an SQL column alias for a column name. * * @param string $columnName + * * @return string */ public function getSQLColumnAlias($columnName) @@ -293,8 +333,9 @@ class SqlWalker implements TreeWalker * Generates the SQL JOINs that are necessary for Class Table Inheritance * for the given class. * - * @param ClassMetadata $class The class for which to generate the joins. - * @param string $dqlAlias The DQL alias of the class. + * @param ClassMetadata $class The class for which to generate the joins. + * @param string $dqlAlias The DQL alias of the class. + * * @return string The SQL. */ private function _generateClassTableInheritanceJoins($class, $dqlAlias) @@ -350,33 +391,48 @@ class SqlWalker implements TreeWalker return $sql; } + /** + * @return string + */ private function _generateOrderedCollectionOrderByItems() { - $sqlParts = array(); + $orderedColumns = array(); foreach ($this->selectedClasses as $selectedClass) { - $dqlAlias = $selectedClass['dqlAlias']; - $qComp = $this->queryComponents[$dqlAlias]; + $dqlAlias = $selectedClass['dqlAlias']; + $qComp = $this->queryComponents[$dqlAlias]; + $persister = $this->em->getUnitOfWork()->getEntityPersister($qComp['metadata']->name); - if ( ! isset($qComp['relation']['orderBy'])) continue; + if ( ! isset($qComp['relation']['orderBy'])) { + continue; + } foreach ($qComp['relation']['orderBy'] as $fieldName => $orientation) { $columnName = $this->quoteStrategy->getColumnName($fieldName, $qComp['metadata'], $this->platform); $tableName = ($qComp['metadata']->isInheritanceTypeJoined()) - ? $this->em->getUnitOfWork()->getEntityPersister($qComp['metadata']->name)->getOwningTable($fieldName) + ? $persister->getOwningTable($fieldName) : $qComp['metadata']->getTableName(); - $sqlParts[] = $this->getSQLTableAlias($tableName, $dqlAlias) . '.' . $columnName . ' ' . $orientation; + $orderedColumn = $this->getSQLTableAlias($tableName, $dqlAlias) . '.' . $columnName; + + // OrderByClause should replace an ordered relation. see - DDC-2475 + if (isset($this->orderedColumnsMap[$orderedColumn])) { + continue; + } + + $this->orderedColumnsMap[$orderedColumn] = $orientation; + $orderedColumns[] = $orderedColumn . ' ' . $orientation; } } - return implode(', ', $sqlParts); + return implode(', ', $orderedColumns); } /** * Generates a discriminator column SQL condition for the class with the given DQL alias. * * @param array $dqlAliases List of root DQL aliases to inspect for discriminator restrictions. + * * @return string */ private function _generateDiscriminatorColumnConditionSQL(array $dqlAliases) @@ -391,7 +447,7 @@ class SqlWalker implements TreeWalker $conn = $this->em->getConnection(); $values = array(); - if ($class->discriminatorValue !== null) { // discrimnators can be 0 + if ($class->discriminatorValue !== null) { // discriminators can be 0 $values[] = $conn->quote($class->discriminatorValue); } @@ -411,8 +467,8 @@ class SqlWalker implements TreeWalker /** * Generates the filter SQL for a given entity and table alias. * - * @param ClassMetadata $targetEntity Metadata of the target entity. - * @param string $targetTableAlias The table alias of the joined/selected table. + * @param ClassMetadata $targetEntity Metadata of the target entity. + * @param string $targetTableAlias The table alias of the joined/selected table. * * @return string The SQL query part to add to a query. */ @@ -452,51 +508,58 @@ class SqlWalker implements TreeWalker return implode(' AND ', $filterClauses); } + /** - * Walks down a SelectStatement AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ public function walkSelectStatement(AST\SelectStatement $AST) { - $sql = $this->walkSelectClause($AST->selectClause); - $sql .= $this->walkFromClause($AST->fromClause); - $sql .= $this->walkWhereClause($AST->whereClause); - $sql .= $AST->groupByClause ? $this->walkGroupByClause($AST->groupByClause) : ''; - $sql .= $AST->havingClause ? $this->walkHavingClause($AST->havingClause) : ''; + $limit = $this->query->getMaxResults(); + $offset = $this->query->getFirstResult(); + $lockMode = $this->query->getHint(Query::HINT_LOCK_MODE); + $sql = $this->walkSelectClause($AST->selectClause) + . $this->walkFromClause($AST->fromClause) + . $this->walkWhereClause($AST->whereClause); - if (($orderByClause = $AST->orderByClause) !== null) { - $sql .= $AST->orderByClause ? $this->walkOrderByClause($AST->orderByClause) : ''; - } else if (($orderBySql = $this->_generateOrderedCollectionOrderByItems()) !== '') { + if ($AST->groupByClause) { + $sql .= $this->walkGroupByClause($AST->groupByClause); + } + + if ($AST->havingClause) { + $sql .= $this->walkHavingClause($AST->havingClause); + } + + if ($AST->orderByClause) { + $sql .= $this->walkOrderByClause($AST->orderByClause); + } + + if ( ! $AST->orderByClause && ($orderBySql = $this->_generateOrderedCollectionOrderByItems())) { $sql .= ' ORDER BY ' . $orderBySql; } - $sql = $this->platform->modifyLimitQuery( - $sql, $this->query->getMaxResults(), $this->query->getFirstResult() - ); + if ($limit !== null || $offset !== null) { + $sql = $this->platform->modifyLimitQuery($sql, $limit, $offset); + } - if (($lockMode = $this->query->getHint(Query::HINT_LOCK_MODE)) !== false) { - switch ($lockMode) { - case LockMode::PESSIMISTIC_READ: - $sql .= ' ' . $this->platform->getReadLockSQL(); - break; + if ($lockMode === false || $lockMode === LockMode::NONE) { + return $sql; + } - case LockMode::PESSIMISTIC_WRITE: - $sql .= ' ' . $this->platform->getWriteLockSQL(); - break; + if ($lockMode === LockMode::PESSIMISTIC_READ) { + return $sql . ' ' . $this->platform->getReadLockSQL(); + } - case LockMode::OPTIMISTIC: - foreach ($this->selectedClasses as $selectedClass) { - if ( ! $selectedClass['class']->isVersioned) { - throw \Doctrine\ORM\OptimisticLockException::lockFailed($selectedClass['class']->name); - } - } - break; - case LockMode::NONE: - break; + if ($lockMode === LockMode::PESSIMISTIC_WRITE) { + return $sql . ' ' . $this->platform->getWriteLockSQL(); + } - default: - throw \Doctrine\ORM\Query\QueryException::invalidLockMode(); + if ($lockMode !== LockMode::OPTIMISTIC) { + throw QueryException::invalidLockMode(); + } + + foreach ($this->selectedClasses as $selectedClass) { + if ( ! $selectedClass['class']->isVersioned) { + throw OptimisticLockException::lockFailed($selectedClass['class']->name); } } @@ -504,10 +567,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL. - * - * @param UpdateStatement - * @return string The SQL. + * {@inheritdoc} */ public function walkUpdateStatement(AST\UpdateStatement $AST) { @@ -518,10 +578,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. - * - * @param DeleteStatement - * @return string The SQL. + * {@inheritdoc} */ public function walkDeleteStatement(AST\DeleteStatement $AST) { @@ -536,6 +593,7 @@ class SqlWalker implements TreeWalker * This one differs of ->walkIdentificationVariable() because it generates the entity identifiers. * * @param string $identVariable + * * @return string */ public function walkEntityIdentificationVariable($identVariable) @@ -556,6 +614,7 @@ class SqlWalker implements TreeWalker * * @param string $identificationVariable * @param string $fieldName + * * @return string The SQL. */ public function walkIdentificationVariable($identificationVariable, $fieldName = null) @@ -573,10 +632,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a PathExpression AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkPathExpression($pathExpr) { @@ -632,10 +688,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a SelectClause AST node, thereby generating the appropriate SQL. - * - * @param $selectClause - * @return string The SQL. + * {@inheritdoc} */ public function walkSelectClause($selectClause) { @@ -740,9 +793,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a FromClause AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ public function walkFromClause($fromClause) { @@ -782,6 +833,8 @@ class SqlWalker implements TreeWalker /** * Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL. * + * @param AST\RangeVariableDeclaration $rangeVariableDeclaration + * * @return string */ public function walkRangeVariableDeclaration($rangeVariableDeclaration) @@ -789,10 +842,12 @@ class SqlWalker implements TreeWalker $class = $this->em->getClassMetadata($rangeVariableDeclaration->abstractSchemaName); $dqlAlias = $rangeVariableDeclaration->aliasIdentificationVariable; - $this->rootAliases[] = $dqlAlias; + if ($rangeVariableDeclaration->isRoot) { + $this->rootAliases[] = $dqlAlias; + } - $sql = $class->getQuotedTableName($this->platform) . ' ' - . $this->getSQLTableAlias($class->getTableName(), $dqlAlias); + $sql = $this->quoteStrategy->getTableName($class,$this->platform) . ' ' + . $this->getSQLTableAlias($class->getTableName(), $dqlAlias); if ($class->isInheritanceTypeJoined()) { $sql .= $this->_generateClassTableInheritanceJoins($class, $dqlAlias); @@ -804,9 +859,15 @@ class SqlWalker implements TreeWalker /** * Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL. * + * @param AST\JoinAssociationDeclaration $joinAssociationDeclaration + * @param int $joinType + * @param AST\ConditionalExpression $condExpr + * * @return string + * + * @throws QueryException */ - public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joinType = AST\Join::JOIN_TYPE_INNER) + public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joinType = AST\Join::JOIN_TYPE_INNER, $condExpr = null) { $sql = ''; @@ -817,7 +878,7 @@ class SqlWalker implements TreeWalker $relation = $this->queryComponents[$joinedDqlAlias]['relation']; $targetClass = $this->em->getClassMetadata($relation['targetEntity']); $sourceClass = $this->em->getClassMetadata($relation['sourceEntity']); - $targetTableName = $targetClass->getQuotedTableName($this->platform); + $targetTableName = $this->quoteStrategy->getTableName($targetClass,$this->platform); $targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName(), $joinedDqlAlias); $sourceTableAlias = $this->getSQLTableAlias($sourceClass->getTableName(), $associationPathExpression->identificationVariable); @@ -872,7 +933,7 @@ class SqlWalker implements TreeWalker // Join relation table $joinTable = $assoc['joinTable']; $joinTableAlias = $this->getSQLTableAlias($joinTable['name'], $joinedDqlAlias); - $joinTableName = $sourceClass->getQuotedJoinTableName($assoc, $this->platform); + $joinTableName = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->platform); $conditions = array(); $relationColumns = ($relation['isOwningSide']) @@ -921,6 +982,13 @@ class SqlWalker implements TreeWalker break; } + // Handle WITH clause + if ($condExpr !== null) { + // Phase 2 AST optimization: Skip processing of ConditionalExpression + // if only one ConditionalTerm is defined + $sql .= ' AND (' . $this->walkConditionalExpression($condExpr) . ')'; + } + // FIXME: these should either be nested or all forced to be left joins (DDC-XXX) if ($targetClass->isInheritanceTypeJoined()) { $sql .= $this->_generateClassTableInheritanceJoins($targetClass, $joinedDqlAlias); @@ -941,9 +1009,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ public function walkFunction($function) { @@ -951,10 +1017,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. - * - * @param OrderByClause - * @return string The SQL. + * {@inheritdoc} */ public function walkOrderByClause($orderByClause) { @@ -968,26 +1031,23 @@ class SqlWalker implements TreeWalker } /** - * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. - * - * @param OrderByItem - * @return string The SQL. + * {@inheritdoc} */ public function walkOrderByItem($orderByItem) { + $type = strtoupper($orderByItem->type); $expr = $orderByItem->expression; $sql = ($expr instanceof AST\Node) ? $expr->dispatch($this) : $this->walkResultVariable($this->queryComponents[$expr]['token']['value']); - return $sql . ' ' . strtoupper($orderByItem->type); + $this->orderedColumnsMap[$sql] = $type; + + return $sql . ' ' . $type; } /** - * Walks down a HavingClause AST node, thereby generating the appropriate SQL. - * - * @param HavingClause - * @return string The SQL. + * {@inheritdoc} */ public function walkHavingClause($havingClause) { @@ -995,9 +1055,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a Join AST node and creates the corresponding SQL. - * - * @return string The SQL. + * {@inheritdoc} */ public function walkJoin($join) { @@ -1010,24 +1068,37 @@ class SqlWalker implements TreeWalker switch (true) { case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\RangeVariableDeclaration): - $class = $this->em->getClassMetadata($joinDeclaration->abstractSchemaName); - $condExprConjunction = $class->isInheritanceTypeJoined() && $joinType != AST\Join::JOIN_TYPE_LEFT && $joinType != AST\Join::JOIN_TYPE_LEFTOUTER + $class = $this->em->getClassMetadata($joinDeclaration->abstractSchemaName); + $dqlAlias = $joinDeclaration->aliasIdentificationVariable; + $tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias); + $condition = '(' . $this->walkConditionalExpression($join->conditionalExpression) . ')'; + $condExprConjunction = ($class->isInheritanceTypeJoined() && $joinType != AST\Join::JOIN_TYPE_LEFT && $joinType != AST\Join::JOIN_TYPE_LEFTOUTER) ? ' AND ' : ' ON '; - $sql .= $this->walkRangeVariableDeclaration($joinDeclaration) - . $condExprConjunction . '(' . $this->walkConditionalExpression($join->conditionalExpression) . ')'; + $sql .= $this->walkRangeVariableDeclaration($joinDeclaration); + + $conditions = array($condition); + + // Apply remaining inheritance restrictions + $discrSql = $this->_generateDiscriminatorColumnConditionSQL(array($dqlAlias)); + + if ($discrSql) { + $conditions[] = $discrSql; + } + + // Apply the filters + $filterExpr = $this->generateFilterConditionSQL($class, $tableAlias); + + if ($filterExpr) { + $conditions[] = $filterExpr; + } + + $sql .= $condExprConjunction . implode(' AND ', $conditions); break; case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\JoinAssociationDeclaration): - $sql .= $this->walkJoinAssociationDeclaration($joinDeclaration, $joinType); - - // Handle WITH clause - if (($condExpr = $join->conditionalExpression) !== null) { - // Phase 2 AST optimization: Skip processment of ConditionalExpression - // if only one ConditionalTerm is defined - $sql .= ' AND (' . $this->walkConditionalExpression($condExpr) . ')'; - } + $sql .= $this->walkJoinAssociationDeclaration($joinDeclaration, $joinType, $join->conditionalExpression); break; } @@ -1037,7 +1108,8 @@ class SqlWalker implements TreeWalker /** * Walks down a CaseExpression AST node and generates the corresponding SQL. * - * @param CoalesceExpression|NullIfExpression|GeneralCaseExpression|SimpleCaseExpression $expression + * @param AST\CoalesceExpression|AST\NullIfExpression|AST\GeneralCaseExpression|AST\SimpleCaseExpression $expression + * * @return string The SQL. */ public function walkCaseExpression($expression) @@ -1063,7 +1135,8 @@ class SqlWalker implements TreeWalker /** * Walks down a CoalesceExpression AST node and generates the corresponding SQL. * - * @param CoalesceExpression $coalesceExpression + * @param AST\CoalesceExpression $coalesceExpression + * * @return string The SQL. */ public function walkCoalesceExpression($coalesceExpression) @@ -1084,7 +1157,8 @@ class SqlWalker implements TreeWalker /** * Walks down a NullIfExpression AST node and generates the corresponding SQL. * - * @param NullIfExpression $nullIfExpression + * @param AST\NullIfExpression $nullIfExpression + * * @return string The SQL. */ public function walkNullIfExpression($nullIfExpression) @@ -1103,7 +1177,8 @@ class SqlWalker implements TreeWalker /** * Walks down a GeneralCaseExpression AST node and generates the corresponding SQL. * - * @param GeneralCaseExpression $generalCaseExpression + * @param AST\GeneralCaseExpression $generalCaseExpression + * * @return string The SQL. */ public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCaseExpression) @@ -1123,7 +1198,8 @@ class SqlWalker implements TreeWalker /** * Walks down a SimpleCaseExpression AST node and generates the corresponding SQL. * - * @param SimpleCaseExpression $simpleCaseExpression + * @param AST\SimpleCaseExpression $simpleCaseExpression + * * @return string The SQL. */ public function walkSimpleCaseExpression($simpleCaseExpression) @@ -1141,10 +1217,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a SelectExpression AST node and generates the corresponding SQL. - * - * @param SelectExpression $selectExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkSelectExpression($selectExpression) { @@ -1196,6 +1269,7 @@ class SqlWalker implements TreeWalker case ($expr instanceof AST\SimpleArithmeticExpression): case ($expr instanceof AST\ArithmeticTerm): case ($expr instanceof AST\ArithmeticFactor): + case ($expr instanceof AST\ParenthesisExpression): case ($expr instanceof AST\Literal): case ($expr instanceof AST\NullIfExpression): case ($expr instanceof AST\CoalesceExpression): @@ -1228,6 +1302,10 @@ class SqlWalker implements TreeWalker } break; + case ($expr instanceof AST\NewObjectExpression): + $sql .= $this->walkNewObject($expr); + break; + default: // IdentificationVariable or PartialObjectExpression if ($expr instanceof AST\PartialObjectExpression) { @@ -1320,10 +1398,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL. - * - * @param QuantifiedExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkQuantifiedExpression($qExpr) { @@ -1331,10 +1406,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a Subselect AST node, thereby generating the appropriate SQL. - * - * @param Subselect - * @return string The SQL. + * {@inheritdoc} */ public function walkSubselect($subselect) { @@ -1359,10 +1431,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. - * - * @param SubselectFromClause - * @return string The SQL. + * {@inheritdoc} */ public function walkSubselectFromClause($subselectFromClause) { @@ -1386,10 +1455,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. - * - * @param SimpleSelectClause - * @return string The SQL. + * {@inheritdoc} */ public function walkSimpleSelectClause($simpleSelectClause) { @@ -1398,11 +1464,81 @@ class SqlWalker implements TreeWalker } /** - * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL. + * @param \Doctrine\ORM\Query\AST\ParenthesisExpression $parenthesisExpression + * + * @return string. + */ + public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesisExpression) + { + return sprintf('(%s)', $parenthesisExpression->expression->dispatch($this)); + } + + /** + * @param AST\NewObjectExpression $newObjectExpression * - * @param SimpleSelectExpression * @return string The SQL. */ + public function walkNewObject($newObjectExpression) + { + $sqlSelectExpressions = array(); + $objIndex = $this->newObjectCounter++; + + foreach ($newObjectExpression->args as $argIndex => $e) { + $resultAlias = $this->scalarResultCounter++; + $columnAlias = $this->getSQLColumnAlias('sclr'); + + switch (true) { + case ($e instanceof AST\NewObjectExpression): + $sqlSelectExpressions[] = $e->dispatch($this); + break; + + default: + $sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias; + break; + } + + switch (true) { + case ($e instanceof AST\PathExpression): + $fieldName = $e->field; + $dqlAlias = $e->identificationVariable; + $qComp = $this->queryComponents[$dqlAlias]; + $class = $qComp['metadata']; + $fieldType = $class->getTypeOfField($fieldName); + break; + + case ($e instanceof AST\Literal): + switch ($e->type) { + case AST\Literal::BOOLEAN: + $fieldType = 'boolean'; + break; + + case AST\Literal::NUMERIC: + $fieldType = is_float($e->value) ? 'float' : 'integer'; + break; + } + break; + + default: + $fieldType = 'string'; + break; + } + + $this->scalarResultAliasMap[$resultAlias] = $columnAlias; + $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldType); + + $this->rsm->newObjectMappings[$columnAlias] = array( + 'className' => $newObjectExpression->className, + 'objIndex' => $objIndex, + 'argIndex' => $argIndex + ); + } + + return implode(', ', $sqlSelectExpressions); + } + + /** + * {@inheritdoc} + */ public function walkSimpleSelectExpression($simpleSelectExpression) { $expr = $simpleSelectExpression->expression; @@ -1454,10 +1590,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL. - * - * @param AggregateExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkAggregateExpression($aggExpression) { @@ -1466,10 +1599,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a GroupByClause AST node, thereby generating the appropriate SQL. - * - * @param GroupByClause - * @return string The SQL. + * {@inheritdoc} */ public function walkGroupByClause($groupByClause) { @@ -1483,10 +1613,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. - * - * @param GroupByItem - * @return string The SQL. + * {@inheritdoc} */ public function walkGroupByItem($groupByItem) { @@ -1523,10 +1650,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. - * - * @param DeleteClause - * @return string The SQL. + * {@inheritdoc} */ public function walkDeleteClause(AST\DeleteClause $deleteClause) { @@ -1541,10 +1665,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. - * - * @param UpdateClause - * @return string The SQL. + * {@inheritdoc} */ public function walkUpdateClause($updateClause) { @@ -1561,10 +1682,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. - * - * @param UpdateItem - * @return string The SQL. + * {@inheritdoc} */ public function walkUpdateItem($updateItem) { @@ -1594,11 +1712,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a WhereClause AST node, thereby generating the appropriate SQL. - * WhereClause or not, the appropriate discriminator sql is added. - * - * @param WhereClause - * @return string The SQL. + * {@inheritdoc} */ public function walkWhereClause($whereClause) { @@ -1637,14 +1751,11 @@ class SqlWalker implements TreeWalker } /** - * Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL. - * - * @param ConditionalExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkConditionalExpression($condExpr) { - // Phase 2 AST optimization: Skip processment of ConditionalExpression + // Phase 2 AST optimization: Skip processing of ConditionalExpression // if only one ConditionalTerm is defined if ( ! ($condExpr instanceof AST\ConditionalExpression)) { return $this->walkConditionalTerm($condExpr); @@ -1654,14 +1765,11 @@ class SqlWalker implements TreeWalker } /** - * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. - * - * @param ConditionalTerm - * @return string The SQL. + * {@inheritdoc} */ public function walkConditionalTerm($condTerm) { - // Phase 2 AST optimization: Skip processment of ConditionalTerm + // Phase 2 AST optimization: Skip processing of ConditionalTerm // if only one ConditionalFactor is defined if ( ! ($condTerm instanceof AST\ConditionalTerm)) { return $this->walkConditionalFactor($condTerm); @@ -1671,14 +1779,11 @@ class SqlWalker implements TreeWalker } /** - * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. - * - * @param ConditionalFactor - * @return string The SQL. + * {@inheritdoc} */ public function walkConditionalFactor($factor) { - // Phase 2 AST optimization: Skip processment of ConditionalFactor + // Phase 2 AST optimization: Skip processing of ConditionalFactor // if only one ConditionalPrimary is defined return ( ! ($factor instanceof AST\ConditionalFactor)) ? $this->walkConditionalPrimary($factor) @@ -1686,10 +1791,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. - * - * @param ConditionalPrimary - * @return string The SQL. + * {@inheritdoc} */ public function walkConditionalPrimary($primary) { @@ -1705,10 +1807,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. - * - * @param ExistsExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkExistsExpression($existsExpr) { @@ -1720,10 +1819,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. - * - * @param CollectionMemberExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkCollectionMemberExpression($collMemberExpr) { @@ -1833,10 +1929,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param EmptyCollectionComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) { @@ -1847,34 +1940,24 @@ class SqlWalker implements TreeWalker } /** - * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param NullComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkNullComparisonExpression($nullCompExpr) { - $sql = ''; - $innerExpr = $nullCompExpr->expression; + $expression = $nullCompExpr->expression; + $comparison = ' IS' . ($nullCompExpr->not ? ' NOT' : '') . ' NULL'; - if ($innerExpr instanceof AST\InputParameter) { - $dqlParamKey = $innerExpr->name; - $this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++); - $sql .= ' ?'; - } else { - $sql .= $this->walkPathExpression($innerExpr); + if ($expression instanceof AST\InputParameter) { + $this->parserResult->addParameterMapping($expression->name, $this->sqlParamIndex++); + + return '?' . $comparison; } - $sql .= ' IS' . ($nullCompExpr->not ? ' NOT' : '') . ' NULL'; - - return $sql; + return $expression->dispatch($this) . $comparison; } /** - * Walks down an InExpression AST node, thereby generating the appropriate SQL. - * - * @param InExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkInExpression($inExpr) { @@ -1890,10 +1973,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. - * - * @param InstanceOfExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkInstanceOfExpression($instanceOfExpr) { @@ -1901,7 +1981,7 @@ class SqlWalker implements TreeWalker $dqlAlias = $instanceOfExpr->identificationVariable; $discrClass = $class = $this->queryComponents[$dqlAlias]['metadata']; - + if ($class->discriminatorColumn) { $discrClass = $this->em->getClassMetadata($class->rootEntityName); } @@ -1915,24 +1995,31 @@ class SqlWalker implements TreeWalker $sqlParameterList = array(); foreach ($instanceOfExpr->value as $parameter) { + if ($parameter instanceof AST\InputParameter) { + + $this->rsm->addMetadataParameterMapping($parameter->name, 'discriminatorValue'); + $sqlParameterList[] = $this->walkInputParameter($parameter); - } else { - // Get name from ClassMetadata to resolve aliases. - $entityClassName = $this->em->getClassMetadata($parameter)->name; - if ($entityClassName == $class->name) { - $sqlParameterList[] = $this->conn->quote($class->discriminatorValue); - } else { - $discrMap = array_flip($class->discriminatorMap); - - if (!isset($discrMap[$entityClassName])) { - throw QueryException::instanceOfUnrelatedClass($entityClassName, $class->rootEntityName); - } - - $sqlParameterList[] = $this->conn->quote($discrMap[$entityClassName]); - } + continue; } + + // Get name from ClassMetadata to resolve aliases. + $entityClassName = $this->em->getClassMetadata($parameter)->name; + $discriminatorValue = $class->discriminatorValue; + + if ($entityClassName !== $class->name) { + $discrMap = array_flip($class->discriminatorMap); + + if ( ! isset($discrMap[$entityClassName])) { + throw QueryException::instanceOfUnrelatedClass($entityClassName, $class->rootEntityName); + } + + $discriminatorValue = $discrMap[$entityClassName]; + } + + $sqlParameterList[] = $this->conn->quote($discriminatorValue); } $sql .= '(' . implode(', ', $sqlParameterList) . ')'; @@ -1941,10 +2028,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an InParameter AST node, thereby generating the appropriate SQL. - * - * @param InParameter - * @return string The SQL. + * {@inheritdoc} */ public function walkInParameter($inParam) { @@ -1954,10 +2038,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a literal that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkLiteral($literal) { @@ -1980,10 +2061,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. - * - * @param BetweenExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkBetweenExpression($betweenExpr) { @@ -1998,10 +2076,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. - * - * @param LikeExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkLikeExpression($likeExpr) { @@ -2029,10 +2104,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. - * - * @param StateFieldPathExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkStateFieldPathExpression($stateFieldPathExpression) { @@ -2040,10 +2112,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param ComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkComparisonExpression($compExpr) { @@ -2065,10 +2134,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an InputParameter AST node, thereby generating the appropriate SQL. - * - * @param InputParameter - * @return string The SQL. + * {@inheritdoc} */ public function walkInputParameter($inputParam) { @@ -2078,10 +2144,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param ArithmeticExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkArithmeticExpression($arithmeticExpr) { @@ -2091,10 +2154,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param SimpleArithmeticExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkSimpleArithmeticExpression($simpleArithmeticExpr) { @@ -2106,10 +2166,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkArithmeticTerm($term) { @@ -2119,7 +2176,7 @@ class SqlWalker implements TreeWalker : $term; } - // Phase 2 AST optimization: Skip processment of ArithmeticTerm + // Phase 2 AST optimization: Skip processing of ArithmeticTerm // if only one ArithmeticFactor is defined if ( ! ($term instanceof AST\ArithmeticTerm)) { return $this->walkArithmeticFactor($term); @@ -2129,10 +2186,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkArithmeticFactor($factor) { @@ -2140,7 +2194,7 @@ class SqlWalker implements TreeWalker return $factor; } - // Phase 2 AST optimization: Skip processment of ArithmeticFactor + // Phase 2 AST optimization: Skip processing of ArithmeticFactor // if only one ArithmeticPrimary is defined if ( ! ($factor instanceof AST\ArithmeticFactor)) { return $this->walkArithmeticPrimary($factor); @@ -2154,7 +2208,8 @@ class SqlWalker implements TreeWalker /** * Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL. * - * @param mixed + * @param mixed $primary + * * @return string The SQL. */ public function walkArithmeticPrimary($primary) @@ -2171,10 +2226,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkStringPrimary($stringPrimary) { @@ -2184,10 +2236,7 @@ class SqlWalker implements TreeWalker } /** - * Walks down a ResultVriable that represents an AST node, thereby generating the appropriate SQL. - * - * @param string $resultVariable - * @return string The SQL. + * {@inheritdoc} */ public function walkResultVariable($resultVariable) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalker.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalker.php old mode 100755 new mode 100644 index c88ca1328b..9ddd86b043 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalker.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalker.php @@ -28,17 +28,36 @@ namespace Doctrine\ORM\Query; interface TreeWalker { /** - * Initializes TreeWalker with important information about the ASTs to be walked + * Initializes TreeWalker with important information about the ASTs to be walked. * - * @param Query $query The parsed Query. - * @param ParserResult $parserResult The result of the parsing process. - * @param array $queryComponents Query components (symbol table) + * @param \Doctrine\ORM\AbstractQuery $query The parsed Query. + * @param \Doctrine\ORM\Query\ParserResult $parserResult The result of the parsing process. + * @param array $queryComponents The query components (symbol table). */ public function __construct($query, $parserResult, array $queryComponents); + /** + * Returns internal queryComponents array. + * + * @return array + */ + public function getQueryComponents(); + + /** + * Sets or overrides a query component for a given dql alias. + * + * @param string $dqlAlias The DQL alias. + * @param array $queryComponent + * + * @return void + */ + public function setQueryComponent($dqlAlias, array $queryComponent); + /** * Walks down a SelectStatement AST node, thereby generating the appropriate SQL. * + * @param AST\SelectStatement $AST + * * @return string The SQL. */ function walkSelectStatement(AST\SelectStatement $AST); @@ -46,6 +65,8 @@ interface TreeWalker /** * Walks down a SelectClause AST node, thereby generating the appropriate SQL. * + * @param AST\SelectClause $selectClause + * * @return string The SQL. */ function walkSelectClause($selectClause); @@ -53,6 +74,8 @@ interface TreeWalker /** * Walks down a FromClause AST node, thereby generating the appropriate SQL. * + * @param AST\FromClause $fromClause + * * @return string The SQL. */ function walkFromClause($fromClause); @@ -60,6 +83,8 @@ interface TreeWalker /** * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. * + * @param AST\Functions\FunctionNode $function + * * @return string The SQL. */ function walkFunction($function); @@ -67,7 +92,8 @@ interface TreeWalker /** * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. * - * @param OrderByClause + * @param AST\OrderByClause $orderByClause + * * @return string The SQL. */ function walkOrderByClause($orderByClause); @@ -75,7 +101,8 @@ interface TreeWalker /** * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. * - * @param OrderByItem + * @param AST\OrderByItem $orderByItem + * * @return string The SQL. */ function walkOrderByItem($orderByItem); @@ -83,7 +110,8 @@ interface TreeWalker /** * Walks down a HavingClause AST node, thereby generating the appropriate SQL. * - * @param HavingClause + * @param AST\HavingClause $havingClause + * * @return string The SQL. */ function walkHavingClause($havingClause); @@ -91,7 +119,8 @@ interface TreeWalker /** * Walks down a Join AST node and creates the corresponding SQL. * - * @param Join $joinVarDecl + * @param AST\Join $join + * * @return string The SQL. */ function walkJoin($join); @@ -99,7 +128,8 @@ interface TreeWalker /** * Walks down a SelectExpression AST node and generates the corresponding SQL. * - * @param SelectExpression $selectExpression + * @param AST\SelectExpression $selectExpression + * * @return string The SQL. */ function walkSelectExpression($selectExpression); @@ -107,7 +137,8 @@ interface TreeWalker /** * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL. * - * @param QuantifiedExpression + * @param AST\QuantifiedExpression $qExpr + * * @return string The SQL. */ function walkQuantifiedExpression($qExpr); @@ -115,7 +146,8 @@ interface TreeWalker /** * Walks down a Subselect AST node, thereby generating the appropriate SQL. * - * @param Subselect + * @param AST\Subselect $subselect + * * @return string The SQL. */ function walkSubselect($subselect); @@ -123,7 +155,8 @@ interface TreeWalker /** * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. * - * @param SubselectFromClause + * @param AST\SubselectFromClause $subselectFromClause + * * @return string The SQL. */ function walkSubselectFromClause($subselectFromClause); @@ -131,7 +164,8 @@ interface TreeWalker /** * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. * - * @param SimpleSelectClause + * @param AST\SimpleSelectClause $simpleSelectClause + * * @return string The SQL. */ function walkSimpleSelectClause($simpleSelectClause); @@ -139,7 +173,8 @@ interface TreeWalker /** * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL. * - * @param SimpleSelectExpression + * @param AST\SimpleSelectExpression $simpleSelectExpression + * * @return string The SQL. */ function walkSimpleSelectExpression($simpleSelectExpression); @@ -147,7 +182,8 @@ interface TreeWalker /** * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL. * - * @param AggregateExpression + * @param AST\AggregateExpression $aggExpression + * * @return string The SQL. */ function walkAggregateExpression($aggExpression); @@ -155,7 +191,8 @@ interface TreeWalker /** * Walks down a GroupByClause AST node, thereby generating the appropriate SQL. * - * @param GroupByClause + * @param AST\GroupByClause $groupByClause + * * @return string The SQL. */ function walkGroupByClause($groupByClause); @@ -163,7 +200,8 @@ interface TreeWalker /** * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. * - * @param GroupByItem + * @param AST\PathExpression|string $groupByItem + * * @return string The SQL. */ function walkGroupByItem($groupByItem); @@ -171,7 +209,8 @@ interface TreeWalker /** * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL. * - * @param UpdateStatement + * @param AST\UpdateStatement $AST + * * @return string The SQL. */ function walkUpdateStatement(AST\UpdateStatement $AST); @@ -179,7 +218,8 @@ interface TreeWalker /** * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. * - * @param DeleteStatement + * @param AST\DeleteStatement $AST + * * @return string The SQL. */ function walkDeleteStatement(AST\DeleteStatement $AST); @@ -187,7 +227,8 @@ interface TreeWalker /** * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. * - * @param DeleteClause + * @param AST\DeleteClause $deleteClause + * * @return string The SQL. */ function walkDeleteClause(AST\DeleteClause $deleteClause); @@ -195,7 +236,8 @@ interface TreeWalker /** * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. * - * @param UpdateClause + * @param AST\UpdateClause $updateClause + * * @return string The SQL. */ function walkUpdateClause($updateClause); @@ -203,23 +245,27 @@ interface TreeWalker /** * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. * - * @param UpdateItem + * @param AST\UpdateItem $updateItem + * * @return string The SQL. */ function walkUpdateItem($updateItem); /** * Walks down a WhereClause AST node, thereby generating the appropriate SQL. + * WhereClause or not, the appropriate discriminator sql is added. + * + * @param AST\WhereClause $whereClause * - * @param WhereClause * @return string The SQL. */ function walkWhereClause($whereClause); /** - * Walks down a ConditionalExpression AST node, thereby generating the appropriate SQL. + * Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL. + * + * @param AST\ConditionalExpression $condExpr * - * @param ConditionalExpression * @return string The SQL. */ function walkConditionalExpression($condExpr); @@ -227,7 +273,8 @@ interface TreeWalker /** * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. * - * @param ConditionalTerm + * @param AST\ConditionalTerm $condTerm + * * @return string The SQL. */ function walkConditionalTerm($condTerm); @@ -235,7 +282,8 @@ interface TreeWalker /** * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. * - * @param ConditionalFactor + * @param AST\ConditionalFactor $factor + * * @return string The SQL. */ function walkConditionalFactor($factor); @@ -243,7 +291,8 @@ interface TreeWalker /** * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. * - * @param ConditionalPrimary + * @param AST\ConditionalPrimary $primary + * * @return string The SQL. */ function walkConditionalPrimary($primary); @@ -251,7 +300,8 @@ interface TreeWalker /** * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. * - * @param ExistsExpression + * @param AST\ExistsExpression $existsExpr + * * @return string The SQL. */ function walkExistsExpression($existsExpr); @@ -259,7 +309,8 @@ interface TreeWalker /** * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. * - * @param CollectionMemberExpression + * @param AST\CollectionMemberExpression $collMemberExpr + * * @return string The SQL. */ function walkCollectionMemberExpression($collMemberExpr); @@ -267,7 +318,8 @@ interface TreeWalker /** * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. * - * @param EmptyCollectionComparisonExpression + * @param AST\EmptyCollectionComparisonExpression $emptyCollCompExpr + * * @return string The SQL. */ function walkEmptyCollectionComparisonExpression($emptyCollCompExpr); @@ -275,7 +327,8 @@ interface TreeWalker /** * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. * - * @param NullComparisonExpression + * @param AST\NullComparisonExpression $nullCompExpr + * * @return string The SQL. */ function walkNullComparisonExpression($nullCompExpr); @@ -283,7 +336,8 @@ interface TreeWalker /** * Walks down an InExpression AST node, thereby generating the appropriate SQL. * - * @param InExpression + * @param AST\InExpression $inExpr + * * @return string The SQL. */ function walkInExpression($inExpr); @@ -291,7 +345,8 @@ interface TreeWalker /** * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. * - * @param InstanceOfExpression + * @param AST\InstanceOfExpression $instanceOfExpr + * * @return string The SQL. */ function walkInstanceOfExpression($instanceOfExpr); @@ -299,7 +354,8 @@ interface TreeWalker /** * Walks down a literal that represents an AST node, thereby generating the appropriate SQL. * - * @param mixed + * @param mixed $literal + * * @return string The SQL. */ function walkLiteral($literal); @@ -307,7 +363,8 @@ interface TreeWalker /** * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. * - * @param BetweenExpression + * @param AST\BetweenExpression $betweenExpr + * * @return string The SQL. */ function walkBetweenExpression($betweenExpr); @@ -315,7 +372,8 @@ interface TreeWalker /** * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. * - * @param LikeExpression + * @param AST\LikeExpression $likeExpr + * * @return string The SQL. */ function walkLikeExpression($likeExpr); @@ -323,7 +381,8 @@ interface TreeWalker /** * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. * - * @param StateFieldPathExpression + * @param AST\PathExpression $stateFieldPathExpression + * * @return string The SQL. */ function walkStateFieldPathExpression($stateFieldPathExpression); @@ -331,7 +390,8 @@ interface TreeWalker /** * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. * - * @param ComparisonExpression + * @param AST\ComparisonExpression $compExpr + * * @return string The SQL. */ function walkComparisonExpression($compExpr); @@ -339,7 +399,8 @@ interface TreeWalker /** * Walks down an InputParameter AST node, thereby generating the appropriate SQL. * - * @param InputParameter + * @param AST\InputParameter $inputParam + * * @return string The SQL. */ function walkInputParameter($inputParam); @@ -347,7 +408,8 @@ interface TreeWalker /** * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. * - * @param ArithmeticExpression + * @param AST\ArithmeticExpression $arithmeticExpr + * * @return string The SQL. */ function walkArithmeticExpression($arithmeticExpr); @@ -355,7 +417,8 @@ interface TreeWalker /** * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. * - * @param mixed + * @param mixed $term + * * @return string The SQL. */ function walkArithmeticTerm($term); @@ -363,7 +426,8 @@ interface TreeWalker /** * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. * - * @param mixed + * @param mixed $stringPrimary + * * @return string The SQL. */ function walkStringPrimary($stringPrimary); @@ -371,7 +435,8 @@ interface TreeWalker /** * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. * - * @param mixed + * @param mixed $factor + * * @return string The SQL. */ function walkArithmeticFactor($factor); @@ -379,23 +444,26 @@ interface TreeWalker /** * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. * - * @param SimpleArithmeticExpression + * @param AST\SimpleArithmeticExpression $simpleArithmeticExpr + * * @return string The SQL. */ function walkSimpleArithmeticExpression($simpleArithmeticExpr); /** - * Walks down an PathExpression AST node, thereby generating the appropriate SQL. + * Walks down a PathExpression AST node, thereby generating the appropriate SQL. + * + * @param mixed $pathExpr * - * @param mixed * @return string The SQL. */ function walkPathExpression($pathExpr); /** - * Walks down an ResultVariable AST node, thereby generating the appropriate SQL. + * Walks down a ResultVariable that represents an AST node, thereby generating the appropriate SQL. * * @param string $resultVariable + * * @return string The SQL. */ function walkResultVariable($resultVariable); @@ -403,7 +471,9 @@ interface TreeWalker /** * Gets an executor that can be used to execute the result of this walker. * - * @return AbstractExecutor + * @param AST\DeleteStatement|AST\UpdateStatement|AST\SelectStatement $AST + * + * @return Exec\AbstractSqlExecutor */ function getExecutor($AST); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php old mode 100755 new mode 100644 index 4446a85e0a..e95155c13f --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php @@ -28,8 +28,25 @@ namespace Doctrine\ORM\Query; */ abstract class TreeWalkerAdapter implements TreeWalker { + /** + * The original Query. + * + * @var \Doctrine\ORM\AbstractQuery + */ private $_query; + + /** + * The ParserResult of the original query that was produced by the Parser. + * + * @var \Doctrine\ORM\Query\ParserResult + */ private $_parserResult; + + /** + * The query components of the original query (the "symbol table") that was produced by the Parser. + * + * @var array + */ private $_queryComponents; /** @@ -42,6 +59,28 @@ abstract class TreeWalkerAdapter implements TreeWalker $this->_queryComponents = $queryComponents; } + /** + * {@inheritdoc} + */ + public function getQueryComponents() + { + return $this->_queryComponents; + } + + /** + * {@inheritdoc} + */ + public function setQueryComponent($dqlAlias, array $queryComponent) + { + $requiredKeys = array('metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token'); + + if (array_diff($requiredKeys, array_keys($queryComponent))) { + throw QueryException::invalidQueryComponent($dqlAlias); + } + + $this->_queryComponents[$dqlAlias] = $queryComponent; + } + /** * @return array */ @@ -51,9 +90,9 @@ abstract class TreeWalkerAdapter implements TreeWalker } /** - * Retrieve Query Instance reponsible for the current walkers execution. + * Retrieves the Query Instance responsible for the current walkers execution. * - * @return \Doctrine\ORM\Query + * @return \Doctrine\ORM\AbstractQuery */ protected function _getQuery() { @@ -61,7 +100,7 @@ abstract class TreeWalkerAdapter implements TreeWalker } /** - * Retrieve ParserResult + * Retrieves the ParserResult. * * @return \Doctrine\ORM\Query\ParserResult */ @@ -71,373 +110,331 @@ abstract class TreeWalkerAdapter implements TreeWalker } /** - * Walks down a SelectStatement AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ - public function walkSelectStatement(AST\SelectStatement $AST) {} + public function walkSelectStatement(AST\SelectStatement $AST) + { + } /** - * Walks down a SelectClause AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ - public function walkSelectClause($selectClause) {} + public function walkSelectClause($selectClause) + { + } /** - * Walks down a FromClause AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ - public function walkFromClause($fromClause) {} + public function walkFromClause($fromClause) + { + } /** - * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ - public function walkFunction($function) {} + public function walkFunction($function) + { + } /** - * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. - * - * @param OrderByClause - * @return string The SQL. + * {@inheritdoc} */ - public function walkOrderByClause($orderByClause) {} + public function walkOrderByClause($orderByClause) + { + } /** - * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. - * - * @param OrderByItem - * @return string The SQL. + * {@inheritdoc} */ - public function walkOrderByItem($orderByItem) {} + public function walkOrderByItem($orderByItem) + { + } /** - * Walks down a HavingClause AST node, thereby generating the appropriate SQL. - * - * @param HavingClause - * @return string The SQL. + * {@inheritdoc} */ - public function walkHavingClause($havingClause) {} + public function walkHavingClause($havingClause) + { + } /** - * Walks down a Join AST node and creates the corresponding SQL. - * - * @param Join $join - * @return string The SQL. + * {@inheritdoc} */ - public function walkJoin($join) {} + public function walkJoin($join) + { + } /** - * Walks down a SelectExpression AST node and generates the corresponding SQL. - * - * @param SelectExpression $selectExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkSelectExpression($selectExpression) {} + public function walkSelectExpression($selectExpression) + { + } /** - * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL. - * - * @param QuantifiedExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkQuantifiedExpression($qExpr) {} + public function walkQuantifiedExpression($qExpr) + { + } /** - * Walks down a Subselect AST node, thereby generating the appropriate SQL. - * - * @param Subselect - * @return string The SQL. + * {@inheritdoc} */ - public function walkSubselect($subselect) {} + public function walkSubselect($subselect) + { + } /** - * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. - * - * @param SubselectFromClause - * @return string The SQL. + * {@inheritdoc} */ - public function walkSubselectFromClause($subselectFromClause) {} + public function walkSubselectFromClause($subselectFromClause) + { + } /** - * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. - * - * @param SimpleSelectClause - * @return string The SQL. + * {@inheritdoc} */ - public function walkSimpleSelectClause($simpleSelectClause) {} + public function walkSimpleSelectClause($simpleSelectClause) + { + } /** - * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL. - * - * @param SimpleSelectExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkSimpleSelectExpression($simpleSelectExpression) {} + public function walkSimpleSelectExpression($simpleSelectExpression) + { + } /** - * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL. - * - * @param AggregateExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkAggregateExpression($aggExpression) {} + public function walkAggregateExpression($aggExpression) + { + } /** - * Walks down a GroupByClause AST node, thereby generating the appropriate SQL. - * - * @param GroupByClause - * @return string The SQL. + * {@inheritdoc} */ - public function walkGroupByClause($groupByClause) {} + public function walkGroupByClause($groupByClause) + { + } /** - * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. - * - * @param GroupByItem - * @return string The SQL. + * {@inheritdoc} */ - public function walkGroupByItem($groupByItem) {} + public function walkGroupByItem($groupByItem) + { + } /** - * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL. - * - * @param UpdateStatement - * @return string The SQL. + * {@inheritdoc} */ - public function walkUpdateStatement(AST\UpdateStatement $AST) {} + public function walkUpdateStatement(AST\UpdateStatement $AST) + { + } /** - * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. - * - * @param DeleteStatement - * @return string The SQL. + * {@inheritdoc} */ - public function walkDeleteStatement(AST\DeleteStatement $AST) {} + public function walkDeleteStatement(AST\DeleteStatement $AST) + { + } /** - * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. - * - * @param DeleteClause - * @return string The SQL. + * {@inheritdoc} */ - public function walkDeleteClause(AST\DeleteClause $deleteClause) {} + public function walkDeleteClause(AST\DeleteClause $deleteClause) + { + } /** - * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. - * - * @param UpdateClause - * @return string The SQL. + * {@inheritdoc} */ - public function walkUpdateClause($updateClause) {} + public function walkUpdateClause($updateClause) + { + } /** - * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. - * - * @param UpdateItem - * @return string The SQL. + * {@inheritdoc} */ - public function walkUpdateItem($updateItem) {} + public function walkUpdateItem($updateItem) + { + } /** - * Walks down a WhereClause AST node, thereby generating the appropriate SQL. - * - * @param WhereClause - * @return string The SQL. + * {@inheritdoc} */ - public function walkWhereClause($whereClause) {} + public function walkWhereClause($whereClause) + { + } /** - * Walks down a ConditionalExpression AST node, thereby generating the appropriate SQL. - * - * @param ConditionalExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkConditionalExpression($condExpr) {} + public function walkConditionalExpression($condExpr) + { + } /** - * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. - * - * @param ConditionalTerm - * @return string The SQL. + * {@inheritdoc} */ - public function walkConditionalTerm($condTerm) {} + public function walkConditionalTerm($condTerm) + { + } /** - * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. - * - * @param ConditionalFactor - * @return string The SQL. + * {@inheritdoc} */ - public function walkConditionalFactor($factor) {} + public function walkConditionalFactor($factor) + { + } /** - * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. - * - * @param ConditionalPrimary - * @return string The SQL. + * {@inheritdoc} */ - public function walkConditionalPrimary($primary) {} + public function walkConditionalPrimary($primary) + { + } /** - * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. - * - * @param ExistsExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkExistsExpression($existsExpr) {} + public function walkExistsExpression($existsExpr) + { + } /** - * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. - * - * @param CollectionMemberExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkCollectionMemberExpression($collMemberExpr) {} + public function walkCollectionMemberExpression($collMemberExpr) + { + } /** - * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param EmptyCollectionComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) {} + public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) + { + } /** - * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param NullComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkNullComparisonExpression($nullCompExpr) {} + public function walkNullComparisonExpression($nullCompExpr) + { + } /** - * Walks down an InExpression AST node, thereby generating the appropriate SQL. - * - * @param InExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkInExpression($inExpr) {} + public function walkInExpression($inExpr) + { + } /** - * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. - * - * @param InstanceOfExpression - * @return string The SQL. + * {@inheritdoc} */ - function walkInstanceOfExpression($instanceOfExpr) {} + function walkInstanceOfExpression($instanceOfExpr) + { + } /** - * Walks down a literal that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ - public function walkLiteral($literal) {} + public function walkLiteral($literal) + { + } /** - * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. - * - * @param BetweenExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkBetweenExpression($betweenExpr) {} + public function walkBetweenExpression($betweenExpr) + { + } /** - * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. - * - * @param LikeExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkLikeExpression($likeExpr) {} + public function walkLikeExpression($likeExpr) + { + } /** - * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. - * - * @param StateFieldPathExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkStateFieldPathExpression($stateFieldPathExpression) {} + public function walkStateFieldPathExpression($stateFieldPathExpression) + { + } /** - * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param ComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkComparisonExpression($compExpr) {} + public function walkComparisonExpression($compExpr) + { + } /** - * Walks down an InputParameter AST node, thereby generating the appropriate SQL. - * - * @param InputParameter - * @return string The SQL. + * {@inheritdoc} */ - public function walkInputParameter($inputParam) {} + public function walkInputParameter($inputParam) + { + } /** - * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param ArithmeticExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkArithmeticExpression($arithmeticExpr) {} + public function walkArithmeticExpression($arithmeticExpr) + { + } /** - * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ - public function walkArithmeticTerm($term) {} + public function walkArithmeticTerm($term) + { + } /** - * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ - public function walkStringPrimary($stringPrimary) {} + public function walkStringPrimary($stringPrimary) + { + } /** - * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ - public function walkArithmeticFactor($factor) {} + public function walkArithmeticFactor($factor) + { + } /** - * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param SimpleArithmeticExpression - * @return string The SQL. + * {@inheritdoc} */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr) {} + public function walkSimpleArithmeticExpression($simpleArithmeticExpr) + { + } /** - * Walks down an PathExpression AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ - public function walkPathExpression($pathExpr) {} + public function walkPathExpression($pathExpr) + { + } /** - * Walks down an ResultVariable AST node, thereby generating the appropriate SQL. - * - * @param string $resultVariable - * @return string The SQL. + * {@inheritdoc} */ - public function walkResultVariable($resultVariable) {} + public function walkResultVariable($resultVariable) + { + } /** - * Gets an executor that can be used to execute the result of this walker. - * - * @return AbstractExecutor + * {@inheritdoc} */ - public function getExecutor($AST) {} + public function getExecutor($AST) + { + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerChain.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerChain.php old mode 100755 new mode 100644 index 13bbcdeef4..4ce356d842 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerChain.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerChain.php @@ -29,17 +29,60 @@ namespace Doctrine\ORM\Query; */ class TreeWalkerChain implements TreeWalker { - /** The tree walkers. */ + /** + * The tree walkers. + * + * @var TreeWalker[] + */ private $_walkers = array(); - /** The original Query. */ + + /** + * The original Query. + * + * @var \Doctrine\ORM\AbstractQuery + */ private $_query; - /** The ParserResult of the original query that was produced by the Parser. */ + + /** + * The ParserResult of the original query that was produced by the Parser. + * + * @var \Doctrine\ORM\Query\ParserResult + */ private $_parserResult; - /** The query components of the original query (the "symbol table") that was produced by the Parser. */ + + /** + * The query components of the original query (the "symbol table") that was produced by the Parser. + * + * @var array + */ private $_queryComponents; /** - * @inheritdoc + * Returns the internal queryComponents array. + * + * @return array + */ + public function getQueryComponents() + { + return $this->_queryComponents; + } + + /** + * {@inheritdoc} + */ + public function setQueryComponent($dqlAlias, array $queryComponent) + { + $requiredKeys = array('metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token'); + + if (array_diff($requiredKeys, array_keys($queryComponent))) { + throw QueryException::invalidQueryComponent($dqlAlias); + } + + $this->_queryComponents[$dqlAlias] = $queryComponent; + } + + /** + * {@inheritdoc} */ public function __construct($query, $parserResult, array $queryComponents) { @@ -52,6 +95,8 @@ class TreeWalkerChain implements TreeWalker * Adds a tree walker to the chain. * * @param string $walkerClass The class of the walker to instantiate. + * + * @return void */ public function addTreeWalker($walkerClass) { @@ -59,21 +104,19 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a SelectStatement AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ public function walkSelectStatement(AST\SelectStatement $AST) { foreach ($this->_walkers as $walker) { $walker->walkSelectStatement($AST); + + $this->_queryComponents = $walker->getQueryComponents(); } } /** - * Walks down a SelectClause AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ public function walkSelectClause($selectClause) { @@ -83,9 +126,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a FromClause AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ public function walkFromClause($fromClause) { @@ -95,9 +136,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. - * - * @return string The SQL. + * {@inheritdoc} */ public function walkFunction($function) { @@ -107,10 +146,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. - * - * @param OrderByClause - * @return string The SQL. + * {@inheritdoc} */ public function walkOrderByClause($orderByClause) { @@ -120,10 +156,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. - * - * @param OrderByItem - * @return string The SQL. + * {@inheritdoc} */ public function walkOrderByItem($orderByItem) { @@ -133,10 +166,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a HavingClause AST node, thereby generating the appropriate SQL. - * - * @param HavingClause - * @return string The SQL. + * {@inheritdoc} */ public function walkHavingClause($havingClause) { @@ -146,10 +176,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a Join AST node and creates the corresponding SQL. - * - * @param Join $join - * @return string The SQL. + * {@inheritdoc} */ public function walkJoin($join) { @@ -159,10 +186,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a SelectExpression AST node and generates the corresponding SQL. - * - * @param SelectExpression $selectExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkSelectExpression($selectExpression) { @@ -172,10 +196,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL. - * - * @param QuantifiedExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkQuantifiedExpression($qExpr) { @@ -185,10 +206,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a Subselect AST node, thereby generating the appropriate SQL. - * - * @param Subselect - * @return string The SQL. + * {@inheritdoc} */ public function walkSubselect($subselect) { @@ -198,10 +216,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. - * - * @param SubselectFromClause - * @return string The SQL. + * {@inheritdoc} */ public function walkSubselectFromClause($subselectFromClause) { @@ -211,10 +226,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. - * - * @param SimpleSelectClause - * @return string The SQL. + * {@inheritdoc} */ public function walkSimpleSelectClause($simpleSelectClause) { @@ -224,10 +236,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL. - * - * @param SimpleSelectExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkSimpleSelectExpression($simpleSelectExpression) { @@ -237,10 +246,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL. - * - * @param AggregateExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkAggregateExpression($aggExpression) { @@ -250,10 +256,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a GroupByClause AST node, thereby generating the appropriate SQL. - * - * @param GroupByClause - * @return string The SQL. + * {@inheritdoc} */ public function walkGroupByClause($groupByClause) { @@ -263,10 +266,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. - * - * @param GroupByItem - * @return string The SQL. + * {@inheritdoc} */ public function walkGroupByItem($groupByItem) { @@ -276,10 +276,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL. - * - * @param UpdateStatement - * @return string The SQL. + * {@inheritdoc} */ public function walkUpdateStatement(AST\UpdateStatement $AST) { @@ -289,10 +286,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. - * - * @param DeleteStatement - * @return string The SQL. + * {@inheritdoc} */ public function walkDeleteStatement(AST\DeleteStatement $AST) { @@ -302,10 +296,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. - * - * @param DeleteClause - * @return string The SQL. + * {@inheritdoc} */ public function walkDeleteClause(AST\DeleteClause $deleteClause) { @@ -315,10 +306,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. - * - * @param UpdateClause - * @return string The SQL. + * {@inheritdoc} */ public function walkUpdateClause($updateClause) { @@ -328,10 +316,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. - * - * @param UpdateItem - * @return string The SQL. + * {@inheritdoc} */ public function walkUpdateItem($updateItem) { @@ -341,10 +326,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a WhereClause AST node, thereby generating the appropriate SQL. - * - * @param WhereClause - * @return string The SQL. + * {@inheritdoc} */ public function walkWhereClause($whereClause) { @@ -354,10 +336,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a ConditionalExpression AST node, thereby generating the appropriate SQL. - * - * @param ConditionalExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkConditionalExpression($condExpr) { @@ -367,10 +346,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. - * - * @param ConditionalTerm - * @return string The SQL. + * {@inheritdoc} */ public function walkConditionalTerm($condTerm) { @@ -380,10 +356,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. - * - * @param ConditionalFactor - * @return string The SQL. + * {@inheritdoc} */ public function walkConditionalFactor($factor) { @@ -393,10 +366,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. - * - * @param ConditionalPrimary - * @return string The SQL. + * {@inheritdoc} */ public function walkConditionalPrimary($condPrimary) { @@ -406,10 +376,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. - * - * @param ExistsExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkExistsExpression($existsExpr) { @@ -419,10 +386,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. - * - * @param CollectionMemberExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkCollectionMemberExpression($collMemberExpr) { @@ -432,10 +396,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param EmptyCollectionComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) { @@ -445,10 +406,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param NullComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkNullComparisonExpression($nullCompExpr) { @@ -458,10 +416,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an InExpression AST node, thereby generating the appropriate SQL. - * - * @param InExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkInExpression($inExpr) { @@ -471,10 +426,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. - * - * @param InstanceOfExpression - * @return string The SQL. + * {@inheritdoc} */ function walkInstanceOfExpression($instanceOfExpr) { @@ -484,10 +436,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a literal that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkLiteral($literal) { @@ -497,10 +446,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. - * - * @param BetweenExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkBetweenExpression($betweenExpr) { @@ -510,10 +456,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. - * - * @param LikeExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkLikeExpression($likeExpr) { @@ -523,10 +466,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. - * - * @param StateFieldPathExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkStateFieldPathExpression($stateFieldPathExpression) { @@ -536,10 +476,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param ComparisonExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkComparisonExpression($compExpr) { @@ -549,10 +486,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an InputParameter AST node, thereby generating the appropriate SQL. - * - * @param InputParameter - * @return string The SQL. + * {@inheritdoc} */ public function walkInputParameter($inputParam) { @@ -562,10 +496,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param ArithmeticExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkArithmeticExpression($arithmeticExpr) { @@ -575,10 +506,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkArithmeticTerm($term) { @@ -588,10 +516,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkStringPrimary($stringPrimary) { @@ -601,10 +526,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkArithmeticFactor($factor) { @@ -614,10 +536,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param SimpleArithmeticExpression - * @return string The SQL. + * {@inheritdoc} */ public function walkSimpleArithmeticExpression($simpleArithmeticExpr) { @@ -627,10 +546,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an PathExpression AST node, thereby generating the appropriate SQL. - * - * @param mixed - * @return string The SQL. + * {@inheritdoc} */ public function walkPathExpression($pathExpr) { @@ -640,10 +556,7 @@ class TreeWalkerChain implements TreeWalker } /** - * Walks down an ResultVariable AST node, thereby generating the appropriate SQL. - * - * @param string $resultVariable - * @return string The SQL. + * {@inheritdoc} */ public function walkResultVariable($resultVariable) { @@ -653,10 +566,9 @@ class TreeWalkerChain implements TreeWalker } /** - * Gets an executor that can be used to execute the result of this walker. - * - * @return AbstractExecutor + * {@inheritdoc} */ public function getExecutor($AST) - {} + { + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/QueryBuilder.php b/vendor/doctrine/orm/lib/Doctrine/ORM/QueryBuilder.php old mode 100755 new mode 100644 index 51ef277067..76d2e506c7 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/QueryBuilder.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/QueryBuilder.php @@ -20,8 +20,10 @@ namespace Doctrine\ORM; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\QueryExpressionVisitor; /** * This class is responsible for building DQL query strings via an object oriented @@ -39,17 +41,21 @@ class QueryBuilder const DELETE = 1; const UPDATE = 2; - /** The builder states. */ + /* The builder states. */ const STATE_DIRTY = 0; const STATE_CLEAN = 1; /** - * @var EntityManager The EntityManager used by this QueryBuilder. + * The EntityManager used by this QueryBuilder. + * + * @var EntityManager */ private $_em; /** - * @var array The array of DQL parts collected. + * The array of DQL parts collected. + * + * @var array */ private $_dqlParts = array( 'distinct' => false, @@ -64,37 +70,51 @@ class QueryBuilder ); /** - * @var integer The type of query this is. Can be select, update or delete. + * The type of query this is. Can be select, update or delete. + * + * @var integer */ private $_type = self::SELECT; /** - * @var integer The state of the query object. Can be dirty or clean. + * The state of the query object. Can be dirty or clean. + * + * @var integer */ private $_state = self::STATE_CLEAN; /** - * @var string The complete DQL string for this query. + * The complete DQL string for this query. + * + * @var string */ private $_dql; /** - * @var \Doctrine\Common\Collections\ArrayCollection The query parameters. + * The query parameters. + * + * @var \Doctrine\Common\Collections\ArrayCollection */ private $parameters = array(); /** - * @var integer The index of the first result to retrieve. + * The index of the first result to retrieve. + * + * @var integer */ private $_firstResult = null; /** - * @var integer The maximum number of results to retrieve. + * The maximum number of results to retrieve. + * + * @var integer */ private $_maxResults = null; /** - * @var array Keeps root entity alias names for join entities. + * Keeps root entity alias names for join entities. + * + * @var array */ private $joinRootAliases = array(); @@ -114,7 +134,8 @@ class QueryBuilder * This producer method is intended for convenient inline usage. Example: * * - * $qb = $em->createQueryBuilder() + * $qb = $em->createQueryBuilder(); + * $qb * ->select('u') * ->from('User', 'u') * ->where($qb->expr()->eq('u.id', 1)); @@ -131,7 +152,7 @@ class QueryBuilder } /** - * Get the type of the currently built query. + * Gets the type of the currently built query. * * @return integer */ @@ -141,7 +162,7 @@ class QueryBuilder } /** - * Get the associated EntityManager for this query builder. + * Gets the associated EntityManager for this query builder. * * @return EntityManager */ @@ -151,7 +172,7 @@ class QueryBuilder } /** - * Get the state of this query builder instance. + * Gets the state of this query builder instance. * * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. */ @@ -161,7 +182,7 @@ class QueryBuilder } /** - * Get the complete DQL string formed by the current specifications of this QueryBuilder. + * Gets the complete DQL string formed by the current specifications of this QueryBuilder. * * * $qb = $em->createQueryBuilder() @@ -178,8 +199,6 @@ class QueryBuilder return $this->_dql; } - $dql = ''; - switch ($this->_type) { case self::DELETE: $dql = $this->_getDQLForDelete(); @@ -227,8 +246,9 @@ class QueryBuilder /** * Finds the root entity alias of the joined entity. * - * @param string $alias The alias of the new join entity + * @param string $alias The alias of the new join entity * @param string $parentAlias The parent entity alias of the join relationship + * * @return string */ private function findRootAlias($alias, $parentAlias) @@ -263,7 +283,8 @@ class QueryBuilder * * * @deprecated Please use $qb->getRootAliases() instead. - * @return string $rootAlias + * + * @return string */ public function getRootAlias() { @@ -283,7 +304,7 @@ class QueryBuilder * $qb->getRootAliases(); // array('u') * * - * @return array $rootAliases + * @return array */ public function getRootAliases() { @@ -316,7 +337,7 @@ class QueryBuilder * $qb->getRootEntities(); // array('User') * * - * @return array $rootEntities + * @return array */ public function getRootEntities() { @@ -348,9 +369,10 @@ class QueryBuilder * ->setParameter('user_id', 1); * * - * @param string|integer $key The parameter position or name. - * @param mixed $value The parameter value. - * @param string|null $type PDO::PARAM_* or \Doctrine\DBAL\Types\Type::* constant + * @param string|integer $key The parameter position or name. + * @param mixed $value The parameter value. + * @param string|null $type PDO::PARAM_* or \Doctrine\DBAL\Types\Type::* constant + * * @return QueryBuilder This QueryBuilder instance. */ public function setParameter($key, $value, $type = null) @@ -388,10 +410,11 @@ class QueryBuilder * ->setParameters(new ArrayCollection(array( * new Parameter('user_id1', 1), * new Parameter('user_id2', 2) - ))); + * ))); * * - * @param \Doctrine\Common\Collections\ArrayCollection|array $params The query parameters to set. + * @param \Doctrine\Common\Collections\ArrayCollection|array $parameters The query parameters to set. + * * @return QueryBuilder This QueryBuilder instance. */ public function setParameters($parameters) @@ -448,6 +471,7 @@ class QueryBuilder * Sets the position of the first result to retrieve (the "offset"). * * @param integer $firstResult The first result to return. + * * @return QueryBuilder This QueryBuilder instance. */ public function setFirstResult($firstResult) @@ -472,6 +496,7 @@ class QueryBuilder * Sets the maximum number of results to retrieve (the "limit"). * * @param integer $maxResults The maximum number of results to retrieve. + * * @return QueryBuilder This QueryBuilder instance. */ public function setMaxResults($maxResults) @@ -498,13 +523,21 @@ class QueryBuilder * The available parts are: 'select', 'from', 'join', 'set', 'where', * 'groupBy', 'having' and 'orderBy'. * - * @param string $dqlPartName - * @param string $dqlPart - * @param string $append + * @param string $dqlPartName + * @param Expr\Base $dqlPart + * @param bool $append + * * @return QueryBuilder This QueryBuilder instance. */ public function add($dqlPartName, $dqlPart, $append = false) { + if ($append && ($dqlPartName === "where" || $dqlPartName === "having")) { + throw new \InvalidArgumentException( + "Using \$append = true does not have an effect with 'where' or 'having' ". + "parts. See QueryBuilder#andWhere() for an example for correct usage." + ); + } + $isMultiple = is_array($this->_dqlParts[$dqlPartName]); // This is introduced for backwards compatibility reasons. @@ -550,6 +583,7 @@ class QueryBuilder * * * @param mixed $select The selection expressions. + * * @return QueryBuilder This QueryBuilder instance. */ public function select($select = null) @@ -566,7 +600,7 @@ class QueryBuilder } /** - * Add a DISTINCT flag to this query. + * Adds a DISTINCT flag to this query. * * * $qb = $em->createQueryBuilder() @@ -575,7 +609,8 @@ class QueryBuilder * ->from('User', 'u'); * * - * @param bool + * @param bool $flag + * * @return QueryBuilder */ public function distinct($flag = true) @@ -597,6 +632,7 @@ class QueryBuilder * * * @param mixed $select The selection expression. + * * @return QueryBuilder This QueryBuilder instance. */ public function addSelect($select = null) @@ -624,7 +660,8 @@ class QueryBuilder * * * @param string $delete The class/type whose instances are subject to the deletion. - * @param string $alias The class/type alias used in the constructed query. + * @param string $alias The class/type alias used in the constructed query. + * * @return QueryBuilder This QueryBuilder instance. */ public function delete($delete = null, $alias = null) @@ -650,7 +687,8 @@ class QueryBuilder * * * @param string $update The class/type whose instances are subject to the update. - * @param string $alias The class/type alias used in the constructed query. + * @param string $alias The class/type alias used in the constructed query. + * * @return QueryBuilder This QueryBuilder instance. */ public function update($update = null, $alias = null) @@ -665,7 +703,7 @@ class QueryBuilder } /** - * Create and add a query root corresponding to the entity identified by the given alias, + * Creates and adds a query root corresponding to the entity identified by the given alias, * forming a cartesian product with any existing query roots. * * @@ -674,9 +712,10 @@ class QueryBuilder * ->from('User', 'u') * * - * @param string $from The class name. - * @param string $alias The alias of the class. + * @param string $from The class name. + * @param string $alias The alias of the class. * @param string $indexBy The index for the from. + * * @return QueryBuilder This QueryBuilder instance. */ public function from($from, $alias, $indexBy = null) @@ -698,11 +737,12 @@ class QueryBuilder * ->join('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1'); * * - * @param string $join The relationship to join - * @param string $alias The alias of the join - * @param string $conditionType The condition type constant. Either ON or WITH. - * @param string $condition The condition for the join - * @param string $indexBy The index for the join + * @param string $join The relationship to join. + * @param string $alias The alias of the join. + * @param string|null $conditionType The condition type constant. Either ON or WITH. + * @param string|null $condition The condition for the join. + * @param string|null $indexBy The index for the join. + * * @return QueryBuilder This QueryBuilder instance. */ public function join($join, $alias, $conditionType = null, $condition = null, $indexBy = null) @@ -723,11 +763,12 @@ class QueryBuilder * ->from('User', 'u') * ->innerJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1'); * - * @param string $join The relationship to join - * @param string $alias The alias of the join - * @param string $conditionType The condition type constant. Either ON or WITH. - * @param string $condition The condition for the join - * @param string $indexBy The index for the join + * @param string $join The relationship to join. + * @param string $alias The alias of the join. + * @param string|null $conditionType The condition type constant. Either ON or WITH. + * @param string|null $condition The condition for the join. + * @param string|null $indexBy The index for the join. + * * @return QueryBuilder This QueryBuilder instance. */ public function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null) @@ -757,11 +798,12 @@ class QueryBuilder * ->leftJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1'); * * - * @param string $join The relationship to join - * @param string $alias The alias of the join - * @param string $conditionType The condition type constant. Either ON or WITH. - * @param string $condition The condition for the join - * @param string $indexBy The index for the join + * @param string $join The relationship to join. + * @param string $alias The alias of the join. + * @param string|null $conditionType The condition type constant. Either ON or WITH. + * @param string|null $condition The condition for the join. + * @param string|null $indexBy The index for the join. + * * @return QueryBuilder This QueryBuilder instance. */ public function leftJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null) @@ -787,8 +829,9 @@ class QueryBuilder * ->where('u.id = ?'); * * - * @param string $key The key/field to set. + * @param string $key The key/field to set. * @param string $value The value, expression, placeholder, etc. + * * @return QueryBuilder This QueryBuilder instance. */ public function set($key, $value) @@ -819,6 +862,7 @@ class QueryBuilder * * * @param mixed $predicates The restriction predicates. + * * @return QueryBuilder This QueryBuilder instance. */ public function where($predicates) @@ -843,7 +887,9 @@ class QueryBuilder * * * @param mixed $where The query restrictions. + * * @return QueryBuilder This QueryBuilder instance. + * * @see where() */ public function andWhere($where) @@ -858,7 +904,7 @@ class QueryBuilder $where = new Expr\Andx($args); } - return $this->add('where', $where, true); + return $this->add('where', $where); } /** @@ -873,8 +919,10 @@ class QueryBuilder * ->orWhere('u.id = 2'); * * - * @param mixed $where The WHERE statement - * @return QueryBuilder $qb + * @param mixed $where The WHERE statement. + * + * @return QueryBuilder + * * @see where() */ public function orWhere($where) @@ -889,7 +937,7 @@ class QueryBuilder $where = new Expr\Orx($args); } - return $this->add('where', $where, true); + return $this->add('where', $where); } /** @@ -904,6 +952,7 @@ class QueryBuilder * * * @param string $groupBy The grouping expression. + * * @return QueryBuilder This QueryBuilder instance. */ public function groupBy($groupBy) @@ -911,7 +960,6 @@ class QueryBuilder return $this->add('groupBy', new Expr\GroupBy(func_get_args())); } - /** * Adds a grouping expression to the query. * @@ -924,6 +972,7 @@ class QueryBuilder * * * @param string $groupBy The grouping expression. + * * @return QueryBuilder This QueryBuilder instance. */ public function addGroupBy($groupBy) @@ -936,6 +985,7 @@ class QueryBuilder * Replaces any previous having restrictions, if any. * * @param mixed $having The restriction over the groups. + * * @return QueryBuilder This QueryBuilder instance. */ public function having($having) @@ -952,6 +1002,7 @@ class QueryBuilder * conjunction with any existing having restrictions. * * @param mixed $having The restriction to append. + * * @return QueryBuilder This QueryBuilder instance. */ public function andHaving($having) @@ -974,6 +1025,7 @@ class QueryBuilder * disjunction with any existing having restrictions. * * @param mixed $having The restriction to add. + * * @return QueryBuilder This QueryBuilder instance. */ public function orHaving($having) @@ -995,8 +1047,9 @@ class QueryBuilder * Specifies an ordering for the query results. * Replaces any previously specified orderings, if any. * - * @param string $sort The ordering expression. - * @param string $order The ordering direction. + * @param string|Expr\OrderBy $sort The ordering expression. + * @param string $order The ordering direction. + * * @return QueryBuilder This QueryBuilder instance. */ public function orderBy($sort, $order = null) @@ -1009,20 +1062,64 @@ class QueryBuilder /** * Adds an ordering to the query results. * - * @param string $sort The ordering expression. - * @param string $order The ordering direction. + * @param string|Expr\OrderBy $sort The ordering expression. + * @param string $order The ordering direction. + * * @return QueryBuilder This QueryBuilder instance. */ public function addOrderBy($sort, $order = null) { - return $this->add('orderBy', new Expr\OrderBy($sort, $order), true); + $orderBy = ($sort instanceof Expr\OrderBy) ? $sort : new Expr\OrderBy($sort, $order); + + return $this->add('orderBy', $orderBy, true); } /** - * Get a query part by its name. + * Adds criteria to the query. + * + * Adds where expressions with AND operator. + * Adds orderings. + * Overrides firstResult and maxResults if they're set. + * + * @param Criteria $criteria + * + * @return QueryBuilder + */ + public function addCriteria(Criteria $criteria) + { + $visitor = new QueryExpressionVisitor(); + + if ($whereExpression = $criteria->getWhereExpression()) { + $this->andWhere($visitor->dispatch($whereExpression)); + foreach ($visitor->getParameters() as $parameter) { + $this->parameters->add($parameter); + } + } + + if ($criteria->getOrderings()) { + foreach ($criteria->getOrderings() as $sort => $order) { + $this->addOrderBy($sort, $order); + } + } + + // Overwrite limits only if they was set in criteria + if (($firstResult = $criteria->getFirstResult()) !== null) { + $this->setFirstResult($firstResult); + } + if (($maxResults = $criteria->getMaxResults()) !== null) { + $this->setMaxResults($maxResults); + } + + return $this; + } + + /** + * Gets a query part by its name. * * @param string $queryPartName + * * @return mixed $queryPart + * * @todo Rename: getQueryPart (or remove?) */ public function getDQLPart($queryPartName) @@ -1031,9 +1128,10 @@ class QueryBuilder } /** - * Get all query parts. + * Gets all query parts. * * @return array $dqlParts + * * @todo Rename: getQueryParts (or remove?) */ public function getDQLParts() @@ -1041,6 +1139,9 @@ class QueryBuilder return $this->_dqlParts; } + /** + * @return string + */ private function _getDQLForDelete() { return 'DELETE' @@ -1049,6 +1150,9 @@ class QueryBuilder . $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', ')); } + /** + * @return string + */ private function _getDQLForUpdate() { return 'UPDATE' @@ -1058,6 +1162,9 @@ class QueryBuilder . $this->_getReducedDQLQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', ')); } + /** + * @return string + */ private function _getDQLForSelect() { $dql = 'SELECT' @@ -1094,6 +1201,12 @@ class QueryBuilder return $dql; } + /** + * @param string $queryPartName + * @param array $options + * + * @return string + */ private function _getReducedDQLQueryPart($queryPartName, $options = array()) { $queryPart = $this->getDQLPart($queryPartName); @@ -1108,9 +1221,10 @@ class QueryBuilder } /** - * Reset DQL parts + * Resets DQL parts. + * + * @param array|null $parts * - * @param array $parts * @return QueryBuilder */ public function resetDQLParts($parts = null) @@ -1127,10 +1241,11 @@ class QueryBuilder } /** - * Reset single DQL part + * Resets single DQL part. * * @param string $part - * @return QueryBuilder; + * + * @return QueryBuilder */ public function resetDQLPart($part) { @@ -1152,7 +1267,7 @@ class QueryBuilder } /** - * Deep clone of all expression objects in the DQL parts. + * Deep clones all expression objects in the DQL parts. * * @return void */ diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/README.markdown b/vendor/doctrine/orm/lib/Doctrine/ORM/README.markdown old mode 100755 new mode 100644 diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php new file mode 100644 index 0000000000..2774dea687 --- /dev/null +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php @@ -0,0 +1,77 @@ +. + */ + +namespace Doctrine\ORM\Repository; + +use Doctrine\ORM\EntityManagerInterface; + +/** + * This factory is used to create default repository objects for entities at runtime. + * + * @author Guilherme Blanco + * @since 2.4 + */ +class DefaultRepositoryFactory implements RepositoryFactory +{ + /** + * The list of EntityRepository instances. + * + * @var array<\Doctrine\Common\Persistence\ObjectRepository> + */ + private $repositoryList = array(); + + /** + * {@inheritdoc} + */ + public function getRepository(EntityManagerInterface $entityManager, $entityName) + { + $entityName = ltrim($entityName, '\\'); + + if (isset($this->repositoryList[$entityName])) { + return $this->repositoryList[$entityName]; + } + + $repository = $this->createRepository($entityManager, $entityName); + + $this->repositoryList[$entityName] = $repository; + + return $repository; + } + + /** + * Create a new repository instance for an entity class. + * + * @param \Doctrine\ORM\EntityManagerInterface $entityManager The EntityManager instance. + * @param string $entityName The name of the entity. + * + * @return \Doctrine\Common\Persistence\ObjectRepository + */ + protected function createRepository(EntityManagerInterface $entityManager, $entityName) + { + $metadata = $entityManager->getClassMetadata($entityName); + $repositoryClassName = $metadata->customRepositoryClassName; + + if ($repositoryClassName === null) { + $configuration = $entityManager->getConfiguration(); + $repositoryClassName = $configuration->getDefaultRepositoryClassName(); + } + + return new $repositoryClassName($entityManager, $metadata); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/RepositoryFactory.php old mode 100755 new mode 100644 similarity index 58% rename from vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php rename to vendor/doctrine/orm/lib/Doctrine/ORM/Repository/RepositoryFactory.php index 8ca2a2c946..f3af43ebe0 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/RepositoryFactory.php @@ -1,5 +1,4 @@ . */ -namespace Doctrine\Tests\Models\DDC753; +namespace Doctrine\ORM\Repository; + +use Doctrine\ORM\EntityManagerInterface; /** - * @Entity() + * Interface for entity repository factory. + * + * @author Guilherme Blanco + * @since 2.4 */ -class DDC753EntityWithDefaultCustomRepository +interface RepositoryFactory { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue + * Gets the repository for an entity class. + * + * @param \Doctrine\ORM\EntityManagerInterface $entityManager The EntityManager instance. + * @param string $entityName The name of the entity. + * + * @return \Doctrine\Common\Persistence\ObjectRepository */ - protected $id; - - /** @column(type="string") */ - protected $name; - + public function getRepository(EntityManagerInterface $entityManager, $entityName); } \ No newline at end of file diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php old mode 100755 new mode 100644 index c01d964b84..c90adbedb5 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php @@ -19,15 +19,15 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console, - Doctrine\Common\Cache; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\Common\Cache\ApcCache; /** * Command to clear the metadata cache of the various cache drivers. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -35,10 +35,10 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class MetadataCommand extends Console\Command\Command +class MetadataCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -73,9 +73,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); $cacheDriver = $em->getConfiguration()->getMetadataCacheImpl(); @@ -84,11 +84,11 @@ EOT throw new \InvalidArgumentException('No Metadata cache driver is configured on given EntityManager.'); } - if ($cacheDriver instanceof Cache\ApcCache) { + if ($cacheDriver instanceof ApcCache) { throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); } - $output->write('Clearing ALL Metadata cache entries' . PHP_EOL); + $output->writeln('Clearing ALL Metadata cache entries'); $result = $cacheDriver->deleteAll(); $message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; @@ -98,6 +98,6 @@ EOT $message = ($result) ? 'Successfully flushed cache entries.' : $message; } - $output->write($message . PHP_EOL); + $output->writeln($message); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php old mode 100755 new mode 100644 index a984b96035..6c8d761ca3 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php @@ -19,15 +19,15 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console, - Doctrine\Common\Cache; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\Common\Cache\ApcCache; /** * Command to clear the query cache of the various cache drivers. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -35,10 +35,10 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class QueryCommand extends Console\Command\Command +class QueryCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -73,9 +73,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); $cacheDriver = $em->getConfiguration()->getQueryCacheImpl(); @@ -84,7 +84,7 @@ EOT throw new \InvalidArgumentException('No Query cache driver is configured on given EntityManager.'); } - if ($cacheDriver instanceof Cache\ApcCache) { + if ($cacheDriver instanceof ApcCache) { throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php old mode 100755 new mode 100644 index 096aa53a74..26eb3d46d0 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php @@ -19,15 +19,15 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console, - Doctrine\Common\Cache; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\Common\Cache\ApcCache; /** * Command to clear the result cache of the various cache drivers. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -35,10 +35,10 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class ResultCommand extends Console\Command\Command +class ResultCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -73,9 +73,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); $cacheDriver = $em->getConfiguration()->getResultCacheImpl(); @@ -84,11 +84,11 @@ EOT throw new \InvalidArgumentException('No Result cache driver is configured on given EntityManager.'); } - if ($cacheDriver instanceof Cache\ApcCache) { + if ($cacheDriver instanceof ApcCache) { throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI."); } - $output->write('Clearing ALL Result cache entries' . PHP_EOL); + $output->writeln('Clearing ALL Result cache entries'); $result = $cacheDriver->deleteAll(); $message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; @@ -98,6 +98,6 @@ EOT $message = ($result) ? 'Successfully flushed cache entries.' : $message; } - $output->write($message . PHP_EOL); + $output->writeln($message); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php old mode 100755 new mode 100644 index a96429993a..71d72deb84 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php @@ -19,17 +19,19 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console, - Doctrine\ORM\Tools\Export\ClassMetadataExporter, - Doctrine\ORM\Tools\ConvertDoctrine1Schema, - Doctrine\ORM\Tools\EntityGenerator; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console; +use Doctrine\ORM\Tools\Export\ClassMetadataExporter; +use Doctrine\ORM\Tools\ConvertDoctrine1Schema; +use Doctrine\ORM\Tools\EntityGenerator; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Command\Command; /** * Command to convert a Doctrine 1 schema to a Doctrine 2 mapping file. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -37,15 +39,15 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class ConvertDoctrine1SchemaCommand extends Console\Command\Command +class ConvertDoctrine1SchemaCommand extends Command { /** - * @var EntityGenerator + * @var EntityGenerator|null */ private $entityGenerator = null; /** - * @var ClassMetadataExporter + * @var ClassMetadataExporter|null */ private $metadataExporter = null; @@ -63,6 +65,8 @@ class ConvertDoctrine1SchemaCommand extends Console\Command\Command /** * @param EntityGenerator $entityGenerator + * + * @return void */ public function setEntityGenerator(EntityGenerator $entityGenerator) { @@ -83,6 +87,8 @@ class ConvertDoctrine1SchemaCommand extends Console\Command\Command /** * @param ClassMetadataExporter $metadataExporter + * + * @return void */ public function setMetadataExporter(ClassMetadataExporter $metadataExporter) { @@ -90,12 +96,13 @@ class ConvertDoctrine1SchemaCommand extends Console\Command\Command } /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { $this ->setName('orm:convert-d1-schema') + ->setAliases(array('orm:convert:d1-schema')) ->setDescription('Converts Doctrine 1.X schema into a Doctrine 2.X schema.') ->setDefinition(array( new InputArgument( @@ -129,12 +136,10 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { - $em = $this->getHelper('em')->getEntityManager(); - // Process source directories $fromPaths = array_merge(array($input->getArgument('from-path')), $input->getOption('from')); @@ -145,19 +150,20 @@ EOT $extend = $input->getOption('extend'); $numSpaces = $input->getOption('num-spaces'); - $this->convertDoctrine1Schema($em, $fromPaths, $destPath, $toType, $numSpaces, $extend, $output); + $this->convertDoctrine1Schema($fromPaths, $destPath, $toType, $numSpaces, $extend, $output); } /** - * @param \Doctrine\ORM\EntityManager $em - * @param array $fromPaths - * @param string $destPath - * @param string $toType - * @param int $numSpaces - * @param string|null $extend - * @param Console\Output\OutputInterface $output + * @param array $fromPaths + * @param string $destPath + * @param string $toType + * @param int $numSpaces + * @param string|null $extend + * @param OutputInterface $output + * + * @throws \InvalidArgumentException */ - public function convertDoctrine1Schema($em, $fromPaths, $destPath, $toType, $numSpaces, $extend, $output) + public function convertDoctrine1Schema(array $fromPaths, $destPath, $toType, $numSpaces, $extend, OutputInterface $output) { foreach ($fromPaths as &$dirName) { $dirName = realpath($dirName); @@ -166,7 +172,9 @@ EOT throw new \InvalidArgumentException( sprintf("Doctrine 1.X schema directory '%s' does not exist.", $dirName) ); - } else if ( ! is_readable($dirName)) { + } + + if ( ! is_readable($dirName)) { throw new \InvalidArgumentException( sprintf("Doctrine 1.X schema directory '%s' does not have read permissions.", $dirName) ); @@ -177,7 +185,9 @@ EOT throw new \InvalidArgumentException( sprintf("Doctrine 2.X mapping destination directory '%s' does not exist.", $destPath) ); - } else if ( ! is_writable($destPath)) { + } + + if ( ! is_writable($destPath)) { throw new \InvalidArgumentException( sprintf("Doctrine 2.X mapping destination directory '%s' does not have write permissions.", $destPath) ); @@ -201,20 +211,20 @@ EOT $metadata = $converter->getMetadata(); if ($metadata) { - $output->write(PHP_EOL); + $output->writeln(''); foreach ($metadata as $class) { - $output->write(sprintf('Processing entity "%s"', $class->name) . PHP_EOL); + $output->writeln(sprintf('Processing entity "%s"', $class->name)); } $exporter->setMetadata($metadata); $exporter->export(); - $output->write(PHP_EOL . sprintf( + $output->writeln(PHP_EOL . sprintf( 'Converting Doctrine 1.X schema to "%s" mapping type in "%s"', $toType, $destPath )); } else { - $output->write('No Metadata Classes to process.' . PHP_EOL); + $output->writeln('No Metadata Classes to process.'); } } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php old mode 100755 new mode 100644 index 84070fbffb..5300783af4 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php @@ -19,18 +19,20 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console, - Doctrine\ORM\Tools\Console\MetadataFilter, - Doctrine\ORM\Tools\Export\ClassMetadataExporter, - Doctrine\ORM\Tools\EntityGenerator, - Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Doctrine\ORM\Tools\Console\MetadataFilter; +use Doctrine\ORM\Tools\Export\ClassMetadataExporter; +use Doctrine\ORM\Tools\EntityGenerator; +use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; +use Doctrine\ORM\Mapping\Driver\DatabaseDriver; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Command\Command; /** * Command to convert your mapping information between the various formats. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -38,15 +40,16 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class ConvertMappingCommand extends Console\Command\Command +class ConvertMappingCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { $this ->setName('orm:convert-mapping') + ->setAliases(array('orm:convert:mapping')) ->setDescription('Convert mapping information between supported formats.') ->setDefinition(array( new InputOption( @@ -84,10 +87,10 @@ class ConvertMappingCommand extends Console\Command\Command Convert mapping information between supported formats. This is an execute one-time command. It should not be necessary for -you to call this method multiple times, escpecially when using the --from-database +you to call this method multiple times, especially when using the --from-database flag. -Converting an existing databsae schema into mapping files only solves about 70-80% +Converting an existing database schema into mapping files only solves about 70-80% of the necessary mapping information. Additionally the detection from an existing database cannot detect inverse associations, inheritance types, entities with foreign keys as primary keys and many of the @@ -96,19 +99,25 @@ semantical operations on associations such as cascade. Hint: There is no need to convert YAML or XML mapping files to annotations every time you make changes. All mapping drivers are first class citizens in Doctrine 2 and can be used as runtime mapping for the ORM. + +Hint: If you have a database with tables that should not be managed +by the ORM, you can use a DBAL functionality to filter the tables and sequences down +on a global level: + + \$config->setFilterSchemaAssetsExpression(\$regexp); EOT ); } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); if ($input->getOption('from-database') === true) { - $databaseDriver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver( + $databaseDriver = new DatabaseDriver( $em->getConnection()->getSchemaManager() ); @@ -136,7 +145,9 @@ EOT throw new \InvalidArgumentException( sprintf("Mapping destination directory '%s' does not exist.", $input->getArgument('dest-path')) ); - } else if ( ! is_writable($destPath)) { + } + + if ( ! is_writable($destPath)) { throw new \InvalidArgumentException( sprintf("Mapping destination directory '%s' does not have write permissions.", $destPath) ); @@ -145,7 +156,7 @@ EOT $toType = strtolower($input->getArgument('to-type')); $exporter = $this->getExporter($toType, $destPath); - $exporter->setOverwriteExistingFiles( ($input->getOption('force') !== false) ); + $exporter->setOverwriteExistingFiles($input->getOption('force')); if ($toType == 'annotation') { $entityGenerator = new EntityGenerator(); @@ -160,20 +171,26 @@ EOT if (count($metadata)) { foreach ($metadata as $class) { - $output->write(sprintf('Processing entity "%s"', $class->name) . PHP_EOL); + $output->writeln(sprintf('Processing entity "%s"', $class->name)); } $exporter->setMetadata($metadata); $exporter->export(); - $output->write(PHP_EOL . sprintf( - 'Exporting "%s" mapping information to "%s"' . PHP_EOL, $toType, $destPath + $output->writeln(PHP_EOL . sprintf( + 'Exporting "%s" mapping information to "%s"', $toType, $destPath )); } else { - $output->write('No Metadata Classes to process.' . PHP_EOL); + $output->writeln('No Metadata Classes to process.'); } } + /** + * @param string $toType + * @param string $destPath + * + * @return \Doctrine\ORM\Tools\Export\Driver\AbstractExporter + */ protected function getExporter($toType, $destPath) { $cme = new ClassMetadataExporter(); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php old mode 100755 new mode 100644 index 53f90b2ed1..3601570eb3 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php @@ -19,14 +19,14 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to ensure that Doctrine is properly configured for a production environment. * - * * @link www.doctrine-project.org * @since 2.0 * @version $Revision$ @@ -35,10 +35,10 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class EnsureProductionSettingsCommand extends Console\Command\Command +class EnsureProductionSettingsCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -48,7 +48,7 @@ class EnsureProductionSettingsCommand extends Console\Command\Command ->setDefinition(array( new InputOption( 'complete', null, InputOption::VALUE_NONE, - 'Flag to also inspect database connection existance.' + 'Flag to also inspect database connection existence.' ) )) ->setHelp(<<getHelper('em')->getEntityManager(); - $error = false; try { $em->getConfiguration()->ensureProductionSettings(); @@ -72,12 +71,11 @@ EOT $em->getConnection()->connect(); } } catch (\Exception $e) { - $error = true; $output->writeln('' . $e->getMessage() . ''); + + return 1; } - if ($error === false) { - $output->write('Environment is correctly configured for production.' . PHP_EOL); - } + $output->writeln('Environment is correctly configured for production.'); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php old mode 100755 new mode 100644 index 7210b6b7bc..a8fcac3c85 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php @@ -19,17 +19,18 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console, - Doctrine\ORM\Tools\Console\MetadataFilter, - Doctrine\ORM\Tools\EntityGenerator, - Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Doctrine\ORM\Tools\Console\MetadataFilter; +use Doctrine\ORM\Tools\EntityGenerator; +use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Command\Command; /** * Command to generate entity classes and method stubs from your mapping information. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -37,15 +38,16 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class GenerateEntitiesCommand extends Console\Command\Command +class GenerateEntitiesCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { $this ->setName('orm:generate-entities') + ->setAliases(array('orm:generate:entities')) ->setDescription('Generate entity classes and method stubs from your mapping information.') ->setDefinition(array( new InputOption( @@ -90,7 +92,7 @@ to error and we suggest you use code repositories such as GIT or SVN to make backups of your code. It makes sense to generate the entity code if you are using entities as Data -Access Objects only and dont put much additional logic on them. If you are +Access Objects only and don't put much additional logic on them. If you are however putting much more logic on the entities you should refrain from using the entity-generator and code your entities manually. @@ -104,9 +106,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); @@ -122,7 +124,9 @@ EOT throw new \InvalidArgumentException( sprintf("Entities destination directory '%s' does not exist.", $input->getArgument('dest-path')) ); - } else if ( ! is_writable($destPath)) { + } + + if ( ! is_writable($destPath)) { throw new \InvalidArgumentException( sprintf("Entities destination directory '%s' does not have write permissions.", $destPath) ); @@ -143,8 +147,8 @@ EOT } foreach ($metadatas as $metadata) { - $output->write( - sprintf('Processing entity "%s"', $metadata->name) . PHP_EOL + $output->writeln( + sprintf('Processing entity "%s"', $metadata->name) ); } @@ -152,9 +156,9 @@ EOT $entityGenerator->generate($metadatas, $destPath); // Outputting information message - $output->write(PHP_EOL . sprintf('Entity classes generated to "%s"', $destPath) . PHP_EOL); + $output->writeln(PHP_EOL . sprintf('Entity classes generated to "%s"', $destPath)); } else { - $output->write('No Metadata Classes to process.' . PHP_EOL); + $output->writeln('No Metadata Classes to process.'); } } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php old mode 100755 new mode 100644 index 2a7de9d482..5221187941 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php @@ -19,15 +19,16 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console, - Doctrine\ORM\Tools\Console\MetadataFilter; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Doctrine\ORM\Tools\Console\MetadataFilter; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Command\Command; /** * Command to (re)generate the proxy classes used by doctrine. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -35,15 +36,16 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class GenerateProxiesCommand extends Console\Command\Command +class GenerateProxiesCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { $this ->setName('orm:generate-proxies') + ->setAliases(array('orm:generate:proxies')) ->setDescription('Generates proxy classes for entity classes.') ->setDefinition(array( new InputOption( @@ -62,9 +64,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); @@ -86,7 +88,9 @@ EOT throw new \InvalidArgumentException( sprintf("Proxies destination directory '%s' does not exist.", $em->getConfiguration()->getProxyDir()) ); - } else if ( ! is_writable($destPath)) { + } + + if ( ! is_writable($destPath)) { throw new \InvalidArgumentException( sprintf("Proxies destination directory '%s' does not have write permissions.", $destPath) ); @@ -94,8 +98,8 @@ EOT if ( count($metadatas)) { foreach ($metadatas as $metadata) { - $output->write( - sprintf('Processing entity "%s"', $metadata->name) . PHP_EOL + $output->writeln( + sprintf('Processing entity "%s"', $metadata->name) ); } @@ -103,10 +107,9 @@ EOT $em->getProxyFactory()->generateProxyClasses($metadatas, $destPath); // Outputting information message - $output->write(PHP_EOL . sprintf('Proxy classes generated to "%s"', $destPath) . PHP_EOL); + $output->writeln(PHP_EOL . sprintf('Proxy classes generated to "%s"', $destPath)); } else { - $output->write('No Metadata Classes to process.' . PHP_EOL); + $output->writeln('No Metadata Classes to process.'); } - } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php old mode 100755 new mode 100644 index b716aee623..975bc69383 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php @@ -19,16 +19,17 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console, - Doctrine\ORM\Tools\Console\MetadataFilter, - Doctrine\ORM\Tools\EntityRepositoryGenerator; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Doctrine\ORM\Tools\Console\MetadataFilter; +use Doctrine\ORM\Tools\EntityRepositoryGenerator; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Command\Command; /** * Command to generate repository classes for mapping information. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -36,15 +37,16 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class GenerateRepositoriesCommand extends Console\Command\Command +class GenerateRepositoriesCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { $this ->setName('orm:generate-repositories') + ->setAliases(array('orm:generate:repositories')) ->setDescription('Generate repository classes from your mapping information.') ->setDefinition(array( new InputOption( @@ -62,9 +64,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); @@ -78,7 +80,9 @@ EOT throw new \InvalidArgumentException( sprintf("Entities destination directory '%s' does not exist.", $input->getArgument('dest-path')) ); - } else if ( ! is_writable($destPath)) { + } + + if ( ! is_writable($destPath)) { throw new \InvalidArgumentException( sprintf("Entities destination directory '%s' does not have write permissions.", $destPath) ); @@ -90,8 +94,8 @@ EOT foreach ($metadatas as $metadata) { if ($metadata->customRepositoryClassName) { - $output->write( - sprintf('Processing repository "%s"', $metadata->customRepositoryClassName) . PHP_EOL + $output->writeln( + sprintf('Processing repository "%s"', $metadata->customRepositoryClassName) ); $generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $destPath); @@ -102,12 +106,12 @@ EOT if ($numRepositories) { // Outputting information message - $output->write(PHP_EOL . sprintf('Repository classes generated to "%s"', $destPath) . PHP_EOL); + $output->writeln(PHP_EOL . sprintf('Repository classes generated to "%s"', $destPath) ); } else { - $output->write('No Repository classes were found to be processed.' . PHP_EOL); + $output->writeln('No Repository classes were found to be processed.' ); } } else { - $output->write('No Metadata Classes to process.' . PHP_EOL); + $output->writeln('No Metadata Classes to process.' ); } } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php old mode 100755 new mode 100644 index b0902bab43..f23fe22c1b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php @@ -25,8 +25,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; /** - * Show information about mapped entities - * + * Show information about mapped entities. * * @link www.doctrine-project.org * @since 2.1 @@ -34,6 +33,9 @@ use Symfony\Component\Console\Command\Command; */ class InfoCommand extends Command { + /** + * {@inheritdoc} + */ protected function configure() { $this @@ -47,6 +49,9 @@ EOT ); } + /** + * {@inheritdoc} + */ protected function execute(InputInterface $input, OutputInterface $output) { /* @var $entityManager \Doctrine\ORM\EntityManager */ @@ -65,6 +70,8 @@ EOT $output->writeln(sprintf("Found %d mapped entities:", count($entityClassNames))); + $failure = false; + foreach ($entityClassNames as $entityClassName) { try { $entityManager->getClassMetadata($entityClassName); @@ -73,7 +80,11 @@ EOT $output->writeln("[FAIL] ".$entityClassName); $output->writeln(sprintf("%s", $e->getMessage())); $output->writeln(''); + + $failure = true; } } + + return $failure ? 1 : 0; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php old mode 100755 new mode 100644 index c9af93f7b6..1189b8194c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php @@ -19,14 +19,16 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\Common\Util\Debug; /** * Command to execute DQL queries in a given EntityManager. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -34,10 +36,10 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class RunDqlCommand extends Console\Command\Command +class RunDqlCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -71,9 +73,9 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); @@ -116,6 +118,6 @@ EOT $resultSet = $query->execute(array(), constant($hydrationMode)); - \Doctrine\Common\Util\Debug::dump($resultSet, $input->getOption('depth')); + Debug::dump($resultSet, $input->getOption('depth')); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php old mode 100755 new mode 100644 index a87eb20042..0aabd630c5 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php @@ -19,23 +19,35 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; -use Symfony\Component\Console\Input\InputInterface, - Symfony\Component\Console\Output\OutputInterface, - Symfony\Component\Console\Command\Command, - Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Command\Command; +use Doctrine\ORM\Tools\SchemaTool; +/** + * Base class for CreateCommand, DropCommand and UpdateCommand. + * + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ abstract class AbstractCommand extends Command { /** - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output - * @param SchemaTool $schemaTool - * @param array $metadatas + * @param SchemaTool $schemaTool + * @param array $metadatas + * + * @return null|int Null or 0 if everything went fine, or an error code. */ abstract protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas); /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -48,11 +60,12 @@ abstract class AbstractCommand extends Command if ( ! empty($metadatas)) { // Create SchemaTool - $tool = new \Doctrine\ORM\Tools\SchemaTool($em); + $tool = new SchemaTool($em); - $this->executeSchemaCommand($input, $output, $tool, $metadatas); + return $this->executeSchemaCommand($input, $output, $tool, $metadatas); } else { - $output->write('No Metadata Classes to process.' . PHP_EOL); + $output->writeln('No Metadata Classes to process.'); + return 0; } } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php old mode 100755 new mode 100644 index 69d3f36092..610f25c959 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php @@ -19,16 +19,15 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console\Input\InputInterface, - Symfony\Component\Console\Output\OutputInterface, - Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\ORM\Tools\SchemaTool; /** * Command to create the database schema for a set of classes based on their mappings. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -39,7 +38,7 @@ use Symfony\Component\Console\Input\InputArgument, class CreateCommand extends AbstractCommand { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -56,21 +55,32 @@ class CreateCommand extends AbstractCommand )) ->setHelp(<<Hint: If you have a database with tables that should not be managed +by the ORM, you can use a DBAL functionality to filter the tables and sequences down +on a global level: + + \$config->setFilterSchemaAssetsExpression(\$regexp); EOT ); } + /** + * {@inheritdoc} + */ protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas) { - if ($input->getOption('dump-sql') === true) { + if ($input->getOption('dump-sql')) { $sqls = $schemaTool->getCreateSchemaSql($metadatas); - $output->write(implode(';' . PHP_EOL, $sqls) . ';' . PHP_EOL); + $output->writeln(implode(';' . PHP_EOL, $sqls) . ';'); } else { - $output->write('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL . PHP_EOL); + $output->writeln('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL); - $output->write('Creating database schema...' . PHP_EOL); + $output->writeln('Creating database schema...'); $schemaTool->createSchema($metadatas); - $output->write('Database schema created successfully!' . PHP_EOL); + $output->writeln('Database schema created successfully!'); } + + return 0; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php old mode 100755 new mode 100644 index 50fa645b21..ac003b9910 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php @@ -19,16 +19,15 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console\Input\InputInterface, - Symfony\Component\Console\Output\OutputInterface, - Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\ORM\Tools\SchemaTool; /** * Command to drop the database schema for a set of classes based on their mappings. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -39,7 +38,7 @@ use Symfony\Component\Console\Input\InputArgument, class DropCommand extends AbstractCommand { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -65,44 +64,65 @@ class DropCommand extends AbstractCommand ->setHelp(<<Hint: If you have a database with tables that should not be managed +by the ORM, you can use a DBAL functionality to filter the tables and sequences down +on a global level: + + \$config->setFilterSchemaAssetsExpression(\$regexp); EOT ); } + /** + * {@inheritdoc} + */ protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas) { - $isFullDatabaseDrop = ($input->getOption('full-database')); + $isFullDatabaseDrop = $input->getOption('full-database'); - if ($input->getOption('dump-sql') === true) { + if ($input->getOption('dump-sql')) { if ($isFullDatabaseDrop) { $sqls = $schemaTool->getDropDatabaseSQL(); } else { $sqls = $schemaTool->getDropSchemaSQL($metadatas); } - $output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL); - } else if ($input->getOption('force') === true) { - $output->write('Dropping database schema...' . PHP_EOL); + $output->writeln(implode(';' . PHP_EOL, $sqls)); + + return 0; + } + + if ($input->getOption('force')) { + $output->writeln('Dropping database schema...'); + if ($isFullDatabaseDrop) { $schemaTool->dropDatabase(); } else { $schemaTool->dropSchema($metadatas); } - $output->write('Database schema dropped successfully!' . PHP_EOL); - } else { - $output->write('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL . PHP_EOL); - if ($isFullDatabaseDrop) { - $sqls = $schemaTool->getDropDatabaseSQL(); - } else { - $sqls = $schemaTool->getDropSchemaSQL($metadatas); - } + $output->writeln('Database schema dropped successfully!'); - if (count($sqls)) { - $output->write('Schema-Tool would execute ' . count($sqls) . ' queries to drop the database.' . PHP_EOL); - $output->write('Please run the operation with --force to execute these queries or use --dump-sql to see them.' . PHP_EOL); - } else { - $output->write('Nothing to drop. The database is empty!' . PHP_EOL); - } + return 0; } + + $output->writeln('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL); + + if ($isFullDatabaseDrop) { + $sqls = $schemaTool->getDropDatabaseSQL(); + } else { + $sqls = $schemaTool->getDropSchemaSQL($metadatas); + } + + if (count($sqls)) { + $output->writeln('Schema-Tool would execute ' . count($sqls) . ' queries to drop the database.'); + $output->writeln('Please run the operation with --force to execute these queries or use --dump-sql to see them.'); + + return 1; + } + + $output->writeln('Nothing to drop. The database is empty!'); + + return 0; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php old mode 100755 new mode 100644 index 26552cc45a..0c2665edaf --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -19,17 +19,16 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console\Input\InputInterface, - Symfony\Component\Console\Output\OutputInterface, - Doctrine\ORM\Tools\SchemaTool; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\ORM\Tools\SchemaTool; /** * Command to generate the SQL needed to update the database schema to match * the current mapping information. * - * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -40,10 +39,13 @@ use Symfony\Component\Console\Input\InputArgument, */ class UpdateCommand extends AbstractCommand { + /** + * @var string + */ protected $name = 'orm:schema-tool:update'; /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -82,50 +84,72 @@ Alternatively, you can execute the generated queries: %command.name% --force +If both options are specified, the queries are output and then executed: + +%command.name% --dump-sql --force + Finally, be aware that if the --complete option is passed, this task will drop all database assets (e.g. tables, etc) that are *not* described by the current metadata. In other words, without this option, this task leaves untouched any "extra" tables that exist in the database, but which aren't described by any metadata. + +Hint: If you have a database with tables that should not be managed +by the ORM, you can use a DBAL functionality to filter the tables and sequences down +on a global level: + + \$config->setFilterSchemaAssetsExpression(\$regexp); EOT ); } + /** + * {@inheritdoc} + */ protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas) { // Defining if update is complete or not (--complete not defined means $saveMode = true) - $saveMode = ($input->getOption('complete') !== true); + $saveMode = ! $input->getOption('complete'); $sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode); - if (0 == count($sqls)) { + + if (0 === count($sqls)) { $output->writeln('Nothing to update - your database is already in sync with the current entity metadata.'); - return; + return 0; } - $dumpSql = (true === $input->getOption('dump-sql')); - $force = (true === $input->getOption('force')); - if ($dumpSql && $force) { - throw new \InvalidArgumentException('You can pass either the --dump-sql or the --force option (but not both simultaneously).'); - } + $dumpSql = true === $input->getOption('dump-sql'); + $force = true === $input->getOption('force'); if ($dumpSql) { - $output->writeln(implode(';' . PHP_EOL, $sqls)); - } else if ($force) { + $output->writeln(implode(';' . PHP_EOL, $sqls) . ';'); + } + + if ($force) { + if ($dumpSql) { + $output->writeln(''); + } $output->writeln('Updating database schema...'); $schemaTool->updateSchema($metadatas, $saveMode); $output->writeln(sprintf('Database schema updated successfully! "%s" queries were executed', count($sqls))); - } else { - $output->writeln('ATTENTION: This operation should not be executed in a production environment.'); - $output->writeln(' Use the incremental update to detect changes during development and use'); - $output->writeln(' the SQL DDL provided to manually update your database in production.'); - $output->writeln(''); - - $output->writeln(sprintf('The Schema-Tool would execute "%s" queries to update the database.', count($sqls))); - $output->writeln('Please run the operation by passing one of the following options:'); - - $output->writeln(sprintf(' %s --force to execute the command', $this->getName())); - $output->writeln(sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName())); } + + if ($dumpSql || $force) { + return 0; + } + + $output->writeln('ATTENTION: This operation should not be executed in a production environment.'); + $output->writeln(' Use the incremental update to detect changes during development and use'); + $output->writeln(' the SQL DDL provided to manually update your database in production.'); + $output->writeln(''); + + $output->writeln(sprintf('The Schema-Tool would execute "%s" queries to update the database.', count($sqls))); + $output->writeln('Please run the operation by passing one - or both - of the following options:'); + + $output->writeln(sprintf(' %s --force to execute the command', $this->getName())); + $output->writeln(sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName())); + + return 1; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php old mode 100755 new mode 100644 index 3dbc54fbd7..4bffbf76e9 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php @@ -19,12 +19,13 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\ORM\Tools\SchemaValidator; /** - * Validate that the current mapping is valid + * Command to validate that the current mapping is valid. * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.com @@ -34,10 +35,10 @@ use Symfony\Component\Console\Input\InputArgument, * @author Jonathan Wage * @author Roman Borschel */ -class ValidateSchemaCommand extends Console\Command\Command +class ValidateSchemaCommand extends Command { /** - * @see Console\Command\Command + * {@inheritdoc} */ protected function configure() { @@ -51,34 +52,37 @@ EOT } /** - * @see Console\Command\Command + * {@inheritdoc} */ - protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getHelper('em')->getEntityManager(); - $validator = new \Doctrine\ORM\Tools\SchemaValidator($em); + $validator = new SchemaValidator($em); $errors = $validator->validateMapping(); $exit = 0; if ($errors) { foreach ($errors as $className => $errorMessages) { - $output->write("[Mapping] FAIL - The entity-class '" . $className . "' mapping is invalid:\n"); + $output->writeln("[Mapping] FAIL - The entity-class '" . $className . "' mapping is invalid:"); + foreach ($errorMessages as $errorMessage) { - $output->write('* ' . $errorMessage . "\n"); + $output->writeln('* ' . $errorMessage); } - $output->write("\n"); + + $output->writeln(''); } + $exit += 1; } else { - $output->write('[Mapping] OK - The mapping files are correct.' . "\n"); + $output->writeln('[Mapping] OK - The mapping files are correct.'); } if (!$validator->schemaInSyncWithMetadata()) { - $output->write('[Database] FAIL - The database schema is not in sync with the current mapping file.' . "\n"); + $output->writeln('[Database] FAIL - The database schema is not in sync with the current mapping file.'); $exit += 2; } else { - $output->write('[Database] OK - The database schema is in sync with the mapping files.' . "\n"); + $output->writeln('[Database] OK - The database schema is in sync with the mapping files.'); } return $exit; diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php old mode 100755 new mode 100644 index e8bc6ecd4f..365fcb415c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -21,19 +21,42 @@ namespace Doctrine\ORM\Tools\Console; use Symfony\Component\Console\Application; use Symfony\Component\Console\Helper\HelperSet; +use Doctrine\ORM\Version; +use Doctrine\ORM\EntityManager; +use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; +use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; + +/** + * Handles running the Console Tools inside Symfony Console context. + */ class ConsoleRunner { /** - * Run console with the given helperset. + * Create a Symfony Console HelperSet + * + * @param EntityManager $entityManager + * @return HelperSet + */ + public static function createHelperSet(EntityManager $entityManager) + { + return new HelperSet(array( + 'db' => new ConnectionHelper($entityManager->getConnection()), + 'em' => new EntityManagerHelper($entityManager) + )); + } + + /** + * Runs console with the given helperset. + * + * @param \Symfony\Component\Console\Helper\HelperSet $helperSet + * @param \Symfony\Component\Console\Command\Command[] $commands * - * @param \Symfony\Component\Console\Helper\HelperSet $helperSet - * @param \Symfony\Component\Console\Command\Command[] $commands * @return void */ static public function run(HelperSet $helperSet, $commands = array()) { - $cli = new Application('Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION); + $cli = new Application('Doctrine Command Line Interface', Version::VERSION); $cli->setCatchExceptions(true); $cli->setHelperSet($helperSet); self::addCommands($cli); @@ -43,6 +66,8 @@ class ConsoleRunner /** * @param Application $cli + * + * @return void */ static public function addCommands(Application $cli) { @@ -69,4 +94,26 @@ class ConsoleRunner new \Doctrine\ORM\Tools\Console\Command\InfoCommand() )); } + + static public function printCliConfigTemplate() + { + echo <<<'HELP' +You are missing a "cli-config.php" or "config/cli-config.php" file in your +project, which is required to get the Doctrine Console working. You can use the +following sample as a template: + + @@ -36,15 +35,16 @@ use Symfony\Component\Console\Helper\Helper, class EntityManagerHelper extends Helper { /** - * Doctrine ORM EntityManager + * Doctrine ORM EntityManager. + * * @var EntityManager */ protected $_em; /** - * Constructor + * Constructor. * - * @param Connection $connection Doctrine Database Connection + * @param \Doctrine\ORM\EntityManager $em */ public function __construct(EntityManager $em) { @@ -52,7 +52,7 @@ class EntityManagerHelper extends Helper } /** - * Retrieves Doctrine ORM EntityManager + * Retrieves Doctrine ORM EntityManager. * * @return EntityManager */ @@ -62,7 +62,7 @@ class EntityManagerHelper extends Helper } /** - * @see Helper + * {@inheritdoc} */ public function getName() { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php old mode 100755 new mode 100644 index 72c753e559..4f7813c1f5 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php @@ -32,44 +32,61 @@ namespace Doctrine\ORM\Tools\Console; */ class MetadataFilter extends \FilterIterator implements \Countable { + /** + * @var array + */ + private $filter = array(); + /** * Filter Metadatas by one or more filter options. * - * @param array $metadatas + * @param array $metadatas * @param array|string $filter + * * @return array */ static public function filter(array $metadatas, $filter) { $metadatas = new MetadataFilter(new \ArrayIterator($metadatas), $filter); + return iterator_to_array($metadatas); } - private $_filter = array(); - + /** + * @param \ArrayIterator $metadata + * @param array|string $filter + */ public function __construct(\ArrayIterator $metadata, $filter) { - $this->_filter = (array)$filter; + $this->filter = (array) $filter; + parent::__construct($metadata); } + /** + * @return bool + */ public function accept() { - if (count($this->_filter) == 0) { + if (count($this->filter) == 0) { return true; } $it = $this->getInnerIterator(); $metadata = $it->current(); - foreach ($this->_filter as $filter) { + foreach ($this->filter as $filter) { if (strpos($metadata->name, $filter) !== false) { return true; } } + return false; } + /** + * @return int + */ public function count() { return count($this->getInnerIterator()); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php old mode 100755 new mode 100644 index 46f358a861..5409453884 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php @@ -19,14 +19,15 @@ namespace Doctrine\ORM\Tools; -use Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Tools\Export\Driver\AbstractExporter, - Doctrine\Common\Util\Inflector; +use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\Common\Util\Inflector; +use Doctrine\DBAL\Types\Type; +use Symfony\Component\Yaml\Yaml; /** * Class to help with converting Doctrine 1 schema files to Doctrine 2 mapping files * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco @@ -35,7 +36,15 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo, */ class ConvertDoctrine1Schema { - private $_legacyTypeMap = array( + /** + * @var array + */ + private $from; + + /** + * @var array + */ + private $legacyTypeMap = array( // TODO: This list may need to be updated 'clob' => 'text', 'timestamp' => 'datetime', @@ -44,57 +53,71 @@ class ConvertDoctrine1Schema /** * Constructor passes the directory or array of directories - * to convert the Doctrine 1 schema files from + * to convert the Doctrine 1 schema files from. * * @param array $from + * * @author Jonathan Wage */ public function __construct($from) { - $this->_from = (array) $from; + $this->from = (array) $from; } /** - * Get an array of ClassMetadataInfo instances from the passed - * Doctrine 1 schema + * Gets an array of ClassMetadataInfo instances from the passed + * Doctrine 1 schema. * - * @return array $metadatas An array of ClassMetadataInfo instances + * @return array An array of ClassMetadataInfo instances */ public function getMetadata() { $schema = array(); - foreach ($this->_from as $path) { + foreach ($this->from as $path) { if (is_dir($path)) { $files = glob($path . '/*.yml'); foreach ($files as $file) { - $schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::parse($file)); + $schema = array_merge($schema, (array) Yaml::parse($file)); } } else { - $schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::parse($path)); + $schema = array_merge($schema, (array) Yaml::parse($path)); } } $metadatas = array(); foreach ($schema as $className => $mappingInformation) { - $metadatas[] = $this->_convertToClassMetadataInfo($className, $mappingInformation); + $metadatas[] = $this->convertToClassMetadataInfo($className, $mappingInformation); } return $metadatas; } - private function _convertToClassMetadataInfo($className, $mappingInformation) + /** + * @param string $className + * @param array $mappingInformation + * + * @return \Doctrine\ORM\Mapping\ClassMetadataInfo + */ + private function convertToClassMetadataInfo($className, $mappingInformation) { $metadata = new ClassMetadataInfo($className); - $this->_convertTableName($className, $mappingInformation, $metadata); - $this->_convertColumns($className, $mappingInformation, $metadata); - $this->_convertIndexes($className, $mappingInformation, $metadata); - $this->_convertRelations($className, $mappingInformation, $metadata); + $this->convertTableName($className, $mappingInformation, $metadata); + $this->convertColumns($className, $mappingInformation, $metadata); + $this->convertIndexes($className, $mappingInformation, $metadata); + $this->convertRelations($className, $mappingInformation, $metadata); return $metadata; } - private function _convertTableName($className, array $model, ClassMetadataInfo $metadata) + /** + * @param string $className + * @param array $model + * @param ClassMetadataInfo $metadata + * + * @return void + */ + private function convertTableName($className, array $model, ClassMetadataInfo $metadata) { if (isset($model['tableName']) && $model['tableName']) { $e = explode('.', $model['tableName']); @@ -108,13 +131,20 @@ class ConvertDoctrine1Schema } } - private function _convertColumns($className, array $model, ClassMetadataInfo $metadata) + /** + * @param string $className + * @param array $model + * @param ClassMetadataInfo $metadata + * + * @return void + */ + private function convertColumns($className, array $model, ClassMetadataInfo $metadata) { $id = false; if (isset($model['columns']) && $model['columns']) { foreach ($model['columns'] as $name => $column) { - $fieldMapping = $this->_convertColumn($className, $name, $column, $metadata); + $fieldMapping = $this->convertColumn($className, $name, $column, $metadata); if (isset($fieldMapping['id']) && $fieldMapping['id']) { $id = true; @@ -134,46 +164,66 @@ class ConvertDoctrine1Schema } } - private function _convertColumn($className, $name, $column, ClassMetadataInfo $metadata) + /** + * @param string $className + * @param string $name + * @param string|array $column + * @param ClassMetadataInfo $metadata + * + * @return array + * + * @throws ToolsException + */ + private function convertColumn($className, $name, $column, ClassMetadataInfo $metadata) { if (is_string($column)) { $string = $column; $column = array(); $column['type'] = $string; } + if ( ! isset($column['name'])) { $column['name'] = $name; } + // check if a column alias was used (column_name as field_name) if (preg_match("/(\w+)\sas\s(\w+)/i", $column['name'], $matches)) { $name = $matches[1]; $column['name'] = $name; $column['alias'] = $matches[2]; } + if (preg_match("/([a-zA-Z]+)\(([0-9]+)\)/", $column['type'], $matches)) { $column['type'] = $matches[1]; $column['length'] = $matches[2]; } + $column['type'] = strtolower($column['type']); // check if legacy column type (1.x) needs to be mapped to a 2.0 one - if (isset($this->_legacyTypeMap[$column['type']])) { - $column['type'] = $this->_legacyTypeMap[$column['type']]; + if (isset($this->legacyTypeMap[$column['type']])) { + $column['type'] = $this->legacyTypeMap[$column['type']]; } - if ( ! \Doctrine\DBAL\Types\Type::hasType($column['type'])) { + + if ( ! Type::hasType($column['type'])) { throw ToolsException::couldNotMapDoctrine1Type($column['type']); } $fieldMapping = array(); + if (isset($column['primary'])) { $fieldMapping['id'] = true; } + $fieldMapping['fieldName'] = isset($column['alias']) ? $column['alias'] : $name; $fieldMapping['columnName'] = $column['name']; $fieldMapping['type'] = $column['type']; + if (isset($column['length'])) { $fieldMapping['length'] = $column['length']; } + $allowed = array('precision', 'scale', 'unique', 'options', 'notnull', 'version'); + foreach ($column as $key => $value) { if (in_array($key, $allowed)) { $fieldMapping[$key] = $value; @@ -184,88 +234,111 @@ class ConvertDoctrine1Schema if (isset($column['autoincrement'])) { $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - } else if (isset($column['sequence'])) { + } elseif (isset($column['sequence'])) { $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); + $definition = array( 'sequenceName' => is_array($column['sequence']) ? $column['sequence']['name']:$column['sequence'] ); + if (isset($column['sequence']['size'])) { $definition['allocationSize'] = $column['sequence']['size']; } + if (isset($column['sequence']['value'])) { $definition['initialValue'] = $column['sequence']['value']; } + $metadata->setSequenceGeneratorDefinition($definition); } + return $fieldMapping; } - private function _convertIndexes($className, array $model, ClassMetadataInfo $metadata) + /** + * @param string $className + * @param array $model + * @param ClassMetadataInfo $metadata + * + * @return void + */ + private function convertIndexes($className, array $model, ClassMetadataInfo $metadata) { - if (isset($model['indexes']) && $model['indexes']) { - foreach ($model['indexes'] as $name => $index) { - $type = (isset($index['type']) && $index['type'] == 'unique') - ? 'uniqueConstraints' : 'indexes'; + if (empty($model['indexes'])) { + return; + } - $metadata->table[$type][$name] = array( - 'columns' => $index['fields'] - ); - } + foreach ($model['indexes'] as $name => $index) { + $type = (isset($index['type']) && $index['type'] == 'unique') + ? 'uniqueConstraints' : 'indexes'; + + $metadata->table[$type][$name] = array( + 'columns' => $index['fields'] + ); } } - private function _convertRelations($className, array $model, ClassMetadataInfo $metadata) + /** + * @param string $className + * @param array $model + * @param ClassMetadataInfo $metadata + * + * @return void + */ + private function convertRelations($className, array $model, ClassMetadataInfo $metadata) { - if (isset($model['relations']) && $model['relations']) { - foreach ($model['relations'] as $name => $relation) { - if ( ! isset($relation['alias'])) { - $relation['alias'] = $name; - } - if ( ! isset($relation['class'])) { - $relation['class'] = $name; - } - if ( ! isset($relation['local'])) { - $relation['local'] = Inflector::tableize($relation['class']); - } - if ( ! isset($relation['foreign'])) { - $relation['foreign'] = 'id'; - } - if ( ! isset($relation['foreignAlias'])) { - $relation['foreignAlias'] = $className; - } + if (empty($model['relations'])) { + return; + } - if (isset($relation['refClass'])) { - $type = 'many'; - $foreignType = 'many'; - $joinColumns = array(); - } else { - $type = isset($relation['type']) ? $relation['type'] : 'one'; - $foreignType = isset($relation['foreignType']) ? $relation['foreignType'] : 'many'; - $joinColumns = array( - array( - 'name' => $relation['local'], - 'referencedColumnName' => $relation['foreign'], - 'onDelete' => isset($relation['onDelete']) ? $relation['onDelete'] : null, - ) - ); - } - - if ($type == 'one' && $foreignType == 'one') { - $method = 'mapOneToOne'; - } else if ($type == 'many' && $foreignType == 'many') { - $method = 'mapManyToMany'; - } else { - $method = 'mapOneToMany'; - } - - $associationMapping = array(); - $associationMapping['fieldName'] = $relation['alias']; - $associationMapping['targetEntity'] = $relation['class']; - $associationMapping['mappedBy'] = $relation['foreignAlias']; - $associationMapping['joinColumns'] = $joinColumns; - - $metadata->$method($associationMapping); + foreach ($model['relations'] as $name => $relation) { + if ( ! isset($relation['alias'])) { + $relation['alias'] = $name; } + if ( ! isset($relation['class'])) { + $relation['class'] = $name; + } + if ( ! isset($relation['local'])) { + $relation['local'] = Inflector::tableize($relation['class']); + } + if ( ! isset($relation['foreign'])) { + $relation['foreign'] = 'id'; + } + if ( ! isset($relation['foreignAlias'])) { + $relation['foreignAlias'] = $className; + } + + if (isset($relation['refClass'])) { + $type = 'many'; + $foreignType = 'many'; + $joinColumns = array(); + } else { + $type = isset($relation['type']) ? $relation['type'] : 'one'; + $foreignType = isset($relation['foreignType']) ? $relation['foreignType'] : 'many'; + $joinColumns = array( + array( + 'name' => $relation['local'], + 'referencedColumnName' => $relation['foreign'], + 'onDelete' => isset($relation['onDelete']) ? $relation['onDelete'] : null, + ) + ); + } + + if ($type == 'one' && $foreignType == 'one') { + $method = 'mapOneToOne'; + } elseif ($type == 'many' && $foreignType == 'many') { + $method = 'mapManyToMany'; + } else { + $method = 'mapOneToMany'; + } + + $associationMapping = array(); + $associationMapping['fieldName'] = $relation['alias']; + $associationMapping['targetEntity'] = $relation['class']; + $associationMapping['mappedBy'] = $relation['foreignAlias']; + $associationMapping['joinColumns'] = $joinColumns; + + $metadata->$method($associationMapping); } } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php old mode 100755 new mode 100644 index c2bb0fdfea..2b6478be57 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -19,10 +19,12 @@ namespace Doctrine\ORM\Tools; +use Doctrine\Common\Persistence\Proxy; use Doctrine\ORM\Event\OnFlushEventArgs; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\UnitOfWork; +use Doctrine\ORM\EntityManager; /** * Use this logger to dump the identity map during the onFlush event. This is useful for debugging @@ -30,11 +32,18 @@ use Doctrine\ORM\UnitOfWork; */ class DebugUnitOfWorkListener { + /** + * @var string + */ private $file; + + /** + * @var string + */ private $context; /** - * Pass a stream and contet information for the debugging session. + * Pass a stream and context information for the debugging session. * * The stream can be php://output to print to the screen. * @@ -47,15 +56,21 @@ class DebugUnitOfWorkListener $this->context = $context; } + /** + * @param \Doctrine\ORM\Event\OnFlushEventArgs $args + * + * @return void + */ public function onFlush(OnFlushEventArgs $args) { $this->dumpIdentityMap($args->getEntityManager()); } /** - * Dump the contents of the identity map into a stream. + * Dumps the contents of the identity map into a stream. * * @param EntityManager $em + * * @return void */ public function dumpIdentityMap(EntityManager $em) @@ -72,20 +87,22 @@ class DebugUnitOfWorkListener fwrite($fh, "Flush Operation [".$this->context."] - Dumping identity map:\n"); foreach ($identityMap as $className => $map) { fwrite($fh, "Class: ". $className . "\n"); + foreach ($map as $entity) { fwrite($fh, " Entity: " . $this->getIdString($entity, $uow) . " " . spl_object_hash($entity)."\n"); fwrite($fh, " Associations:\n"); $cm = $em->getClassMetadata($className); + foreach ($cm->associationMappings as $field => $assoc) { fwrite($fh, " " . $field . " "); - $value = $cm->reflFields[$field]->getValue($entity); + $value = $cm->getFieldValue($entity, $field); if ($assoc['type'] & ClassMetadata::TO_ONE) { if ($value === null) { fwrite($fh, " NULL\n"); } else { - if ($value instanceof Proxy && !$value->__isInitialized__) { + if ($value instanceof Proxy && !$value->__isInitialized()) { fwrite($fh, "[PROXY] "); } @@ -95,8 +112,9 @@ class DebugUnitOfWorkListener $initialized = !($value instanceof PersistentCollection) || $value->isInitialized(); if ($value === null) { fwrite($fh, " NULL\n"); - } else if ($initialized) { + } elseif ($initialized) { fwrite($fh, "[INITIALIZED] " . $this->getType($value). " " . count($value) . " elements\n"); + foreach ($value as $obj) { fwrite($fh, " " . $this->getIdString($obj, $uow) . " " . spl_object_hash($obj)."\n"); } @@ -110,24 +128,38 @@ class DebugUnitOfWorkListener } } } + fclose($fh); } + /** + * @param mixed $var + * + * @return string + */ private function getType($var) { if (is_object($var)) { $refl = new \ReflectionObject($var); + return $refl->getShortname(); - } else { - return gettype($var); } + + return gettype($var); } - private function getIdString($entity, $uow) + /** + * @param object $entity + * @param UnitOfWork $uow + * + * @return string + */ + private function getIdString($entity, UnitOfWork $uow) { if ($uow->isInIdentityMap($entity)) { $ids = $uow->getEntityIdentifier($entity); $idstring = ""; + foreach ($ids as $k => $v) { $idstring .= $k."=".$v; } @@ -136,13 +168,14 @@ class DebugUnitOfWorkListener } $state = $uow->getEntityState($entity); + if ($state == UnitOfWork::STATE_NEW) { $idstring .= " [NEW]"; - } else if ($state == UnitOfWork::STATE_REMOVED) { + } elseif ($state == UnitOfWork::STATE_REMOVED) { $idstring .= " [REMOVED]"; - } else if ($state == UnitOfWork::STATE_MANAGED) { + } elseif ($state == UnitOfWork::STATE_MANAGED) { $idstring .= " [MANAGED]"; - } else if ($state == UnitOfwork::STATE_DETACHED) { + } elseif ($state == UnitOfwork::STATE_DETACHED) { $idstring .= " [DETACHED]"; } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php old mode 100755 new mode 100644 index e44f99f9f2..7a3ec6f893 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Tools; +use Doctrine\Common\Persistence\Mapping\StaticReflectionService; use Doctrine\ORM\Mapping\ClassMetadataFactory; -use Doctrine\ORM\Mapping\ClassMetadataInfo; /** * The DisconnectedClassMetadataFactory is used to create ClassMetadataInfo objects @@ -28,7 +28,7 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo; * load some mapping information and use it to do things like generate code * from the mapping information. * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -38,8 +38,11 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo; */ class DisconnectedClassMetadataFactory extends ClassMetadataFactory { + /** + * @return \Doctrine\Common\Persistence\Mapping\StaticReflectionService + */ public function getReflectionService() { - return new \Doctrine\Common\Persistence\Mapping\StaticReflectionService; + return new StaticReflectionService(); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityGenerator.php old mode 100755 new mode 100644 index 73c52fb35b..ec3a6e143b --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -19,12 +19,12 @@ namespace Doctrine\ORM\Tools; -use Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\Common\Util\Inflector, - Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\Common\Util\Inflector; +use Doctrine\DBAL\Types\Type; /** - * Generic class used to generate PHP5 entity classes from ClassMetadataInfo instances + * Generic class used to generate PHP5 entity classes from ClassMetadataInfo instances. * * [php] * $classes = $em->getClassMetadataFactory()->getAllMetadata(); @@ -47,102 +47,102 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo, class EntityGenerator { /** - * Specifies class fields should be protected + * Specifies class fields should be protected. */ const FIELD_VISIBLE_PROTECTED = 'protected'; /** - * Specifies class fields should be private + * Specifies class fields should be private. */ const FIELD_VISIBLE_PRIVATE = 'private'; /** * @var bool */ - private $backupExisting = true; + protected $backupExisting = true; /** - * The extension to use for written php files + * The extension to use for written php files. * * @var string */ - private $extension = '.php'; + protected $extension = '.php'; /** - * Whether or not the current ClassMetadataInfo instance is new or old + * Whether or not the current ClassMetadataInfo instance is new or old. * * @var boolean */ - private $isNew = true; + protected $isNew = true; /** * @var array */ - private $staticReflection = array(); + protected $staticReflection = array(); /** - * Number of spaces to use for indention in generated code + * Number of spaces to use for indention in generated code. */ - private $numSpaces = 4; + protected $numSpaces = 4; /** - * The actual spaces to use for indention + * The actual spaces to use for indention. * * @var string */ - private $spaces = ' '; + protected $spaces = ' '; /** - * The class all generated entities should extend + * The class all generated entities should extend. * * @var string */ - private $classToExtend; + protected $classToExtend; /** - * Whether or not to generation annotations + * Whether or not to generation annotations. * * @var boolean */ - private $generateAnnotations = false; + protected $generateAnnotations = false; /** * @var string */ - private $annotationsPrefix = ''; + protected $annotationsPrefix = ''; /** - * Whether or not to generated sub methods + * Whether or not to generate sub methods. * * @var boolean */ - private $generateEntityStubMethods = false; + protected $generateEntityStubMethods = false; /** - * Whether or not to update the entity class if it exists already + * Whether or not to update the entity class if it exists already. * * @var boolean */ - private $updateEntityIfExists = false; + protected $updateEntityIfExists = false; /** - * Whether or not to re-generate entity class if it exists already + * Whether or not to re-generate entity class if it exists already. * * @var boolean */ - private $regenerateEntityIfExists = false; + protected $regenerateEntityIfExists = false; /** * @var boolean */ - private $fieldVisibility = 'private'; + protected $fieldVisibility = 'private'; /** - * Hash-map for handle types + * Hash-map for handle types. * * @var array */ - private $typeAlias = array( + protected $typeAlias = array( Type::DATETIMETZ => '\DateTime', Type::DATETIME => '\DateTime', Type::DATE => '\DateTime', @@ -152,13 +152,15 @@ class EntityGenerator Type::SMALLINT => 'integer', Type::TEXT => 'string', Type::BLOB => 'string', - Type::DECIMAL => 'float', + Type::DECIMAL => 'string', Type::JSON_ARRAY => 'array', Type::SIMPLE_ARRAY => 'array', ); /** - * @var array Hash-map to handle generator types string. + * Hash-map to handle generator types string. + * + * @var array */ protected static $generatorStrategyMap = array( ClassMetadataInfo::GENERATOR_TYPE_AUTO => 'AUTO', @@ -171,7 +173,9 @@ class EntityGenerator ); /** - * @var array Hash-map to handle the change tracking policy string. + * Hash-map to handle the change tracking policy string. + * + * @var array */ protected static $changeTrackingPolicyMap = array( ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT => 'DEFERRED_IMPLICIT', @@ -180,7 +184,9 @@ class EntityGenerator ); /** - * @var array Hash-map to handle the inheritance type string. + * Hash-map to handle the inheritance type string. + * + * @var array */ protected static $inheritanceTypeMap = array( ClassMetadataInfo::INHERITANCE_TYPE_NONE => 'NONE', @@ -192,7 +198,7 @@ class EntityGenerator /** * @var string */ - private static $classTemplate = + protected static $classTemplate = ' @@ -209,7 +215,7 @@ use Doctrine\ORM\Mapping as ORM; /** * @var string */ - private static $getMethodTemplate = + protected static $getMethodTemplate = '/** * * @@ -223,7 +229,7 @@ public function () /** * @var string */ - private static $setMethodTemplate = + protected static $setMethodTemplate = '/** * * @@ -240,7 +246,7 @@ public function ($) /** * @var string */ - private static $addMethodTemplate = + protected static $addMethodTemplate = '/** * * @@ -257,7 +263,7 @@ public function ($) /** * @var string */ - private static $removeMethodTemplate = + protected static $removeMethodTemplate = '/** * * @@ -271,7 +277,7 @@ public function ($) /** * @var string */ - private static $lifecycleCallbackMethodTemplate = + protected static $lifecycleCallbackMethodTemplate = '/** * @ */ @@ -283,7 +289,7 @@ public function () /** * @var string */ - private static $constructorMethodTemplate = + protected static $constructorMethodTemplate = '/** * Constructor */ @@ -293,6 +299,9 @@ public function __construct() } '; + /** + * Constructor. + */ public function __construct() { if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) { @@ -301,10 +310,11 @@ public function __construct() } /** - * Generate and write entity classes for the given array of ClassMetadataInfo instances + * Generates and writes entity classes for the given array of ClassMetadataInfo instances. * - * @param array $metadatas + * @param array $metadatas * @param string $outputDirectory + * * @return void */ public function generate(array $metadatas, $outputDirectory) @@ -315,11 +325,14 @@ public function __construct() } /** - * Generated and write entity class to disk for the given ClassMetadataInfo instance + * Generates and writes entity class to disk for the given ClassMetadataInfo instance. * * @param ClassMetadataInfo $metadata - * @param string $outputDirectory + * @param string $outputDirectory + * * @return void + * + * @throws \RuntimeException */ public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory) { @@ -349,16 +362,17 @@ public function __construct() if ($this->isNew) { file_put_contents($path, $this->generateEntityClass($metadata)); // If entity exists and we're allowed to update the entity class - } else if ( ! $this->isNew && $this->updateEntityIfExists) { + } elseif ( ! $this->isNew && $this->updateEntityIfExists) { file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path)); } } /** - * Generate a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance + * Generates a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance. * * @param ClassMetadataInfo $metadata - * @return string $code + * + * @return string */ public function generateEntityClass(ClassMetadataInfo $metadata) { @@ -377,15 +391,17 @@ public function __construct() ); $code = str_replace($placeHolders, $replacements, self::$classTemplate); + return str_replace('', $this->spaces, $code); } /** - * Generate the updated code for the given ClassMetadataInfo and entity at path + * Generates the updated code for the given ClassMetadataInfo and entity at path. * * @param ClassMetadataInfo $metadata - * @param string $path - * @return string $code; + * @param string $path + * + * @return string */ public function generateUpdatedEntityClass(ClassMetadataInfo $metadata, $path) { @@ -395,13 +411,14 @@ public function __construct() $body = str_replace('', $this->spaces, $body); $last = strrpos($currentCode, '}'); - return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : ''). "}"; + return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : ''). "}\n"; } /** - * Set the number of spaces the exported class should have + * Sets the number of spaces the exported class should have. * * @param integer $numSpaces + * * @return void */ public function setNumSpaces($numSpaces) @@ -411,9 +428,10 @@ public function __construct() } /** - * Set the extension to use when writing php files to disk + * Sets the extension to use when writing php files to disk. * * @param string $extension + * * @return void */ public function setExtension($extension) @@ -422,7 +440,9 @@ public function __construct() } /** - * Set the name of the class the generated classes should extend from + * Sets the name of the class the generated classes should extend from. + * + * @param string $classToExtend * * @return void */ @@ -432,9 +452,10 @@ public function __construct() } /** - * Set whether or not to generate annotations for the entity + * Sets whether or not to generate annotations for the entity. * * @param bool $bool + * * @return void */ public function setGenerateAnnotations($bool) @@ -443,24 +464,29 @@ public function __construct() } /** - * Set the class fields visibility for the entity (can either be private or protected) + * Sets the class fields visibility for the entity (can either be private or protected). + * + * @param bool $visibility * - * @param bool $bool * @return void + * + * @throws \InvalidArgumentException */ public function setFieldVisibility($visibility) { if ($visibility !== self::FIELD_VISIBLE_PRIVATE && $visibility !== self::FIELD_VISIBLE_PROTECTED) { - throw new \InvalidArgumentException('Invalid provided visibilty (only private and protected are allowed): ' . $visibility); + throw new \InvalidArgumentException('Invalid provided visibility (only private and protected are allowed): ' . $visibility); } $this->fieldVisibility = $visibility; } /** - * Set an annotation prefix. + * Sets an annotation prefix. * * @param string $prefix + * + * @return void */ public function setAnnotationPrefix($prefix) { @@ -468,9 +494,10 @@ public function __construct() } /** - * Set whether or not to try and update the entity if it already exists + * Sets whether or not to try and update the entity if it already exists. * * @param bool $bool + * * @return void */ public function setUpdateEntityIfExists($bool) @@ -479,9 +506,10 @@ public function __construct() } /** - * Set whether or not to regenerate the entity if it exists + * Sets whether or not to regenerate the entity if it exists. * * @param bool $bool + * * @return void */ public function setRegenerateEntityIfExists($bool) @@ -490,9 +518,10 @@ public function __construct() } /** - * Set whether or not to generate stub methods for the entity + * Sets whether or not to generate stub methods for the entity. * * @param bool $bool + * * @return void */ public function setGenerateStubMethods($bool) @@ -502,17 +531,22 @@ public function __construct() /** * Should an existing entity be backed up if it already exists? + * + * @param bool $bool + * + * @return void */ public function setBackupExisting($bool) { $this->backupExisting = $bool; } - /** - * @param string $type - * @return string + /** + * @param string $type + * + * @return string */ - private function getType($type) + protected function getType($type) { if (isset($this->typeAlias[$type])) { return $this->typeAlias[$type]; @@ -521,20 +555,35 @@ public function __construct() return $type; } - private function generateEntityNamespace(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityNamespace(ClassMetadataInfo $metadata) { if ($this->hasNamespace($metadata)) { return 'namespace ' . $this->getNamespace($metadata) .';'; } } - private function generateEntityClassName(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityClassName(ClassMetadataInfo $metadata) { return 'class ' . $this->getClassName($metadata) . ($this->extendsClass() ? ' extends ' . $this->getClassToExtendName() : null); } - private function generateEntityBody(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityBody(ClassMetadataInfo $metadata) { $fieldMappingProperties = $this->generateEntityFieldMappingProperties($metadata); $associationMappingProperties = $this->generateEntityAssociationMappingProperties($metadata); @@ -564,7 +613,12 @@ public function __construct() return implode("\n", $code); } - private function generateEntityConstructor(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityConstructor(ClassMetadataInfo $metadata) { if ($this->hasMethod('__construct', $metadata)) { return ''; @@ -587,9 +641,12 @@ public function __construct() /** * @todo this won't work if there is a namespace in brackets and a class outside of it. + * * @param string $src + * + * @return void */ - private function parseTokensInEntityFile($src) + protected function parseTokensInEntityFile($src) { $tokens = token_get_all($src); $lastSeenNamespace = ""; @@ -597,6 +654,7 @@ public function __construct() $inNamespace = false; $inClass = false; + for ($i = 0; $i < count($tokens); $i++) { $token = $tokens[$i]; if (in_array($token[0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) { @@ -606,7 +664,7 @@ public function __construct() if ($inNamespace) { if ($token[0] == T_NS_SEPARATOR || $token[0] == T_STRING) { $lastSeenNamespace .= $token[1]; - } else if (is_string($token) && in_array($token, array(';', '{'))) { + } elseif (is_string($token) && in_array($token, array(';', '{'))) { $inNamespace = false; } } @@ -621,21 +679,27 @@ public function __construct() if ($token[0] == T_NAMESPACE) { $lastSeenNamespace = ""; $inNamespace = true; - } else if ($token[0] == T_CLASS) { + } elseif ($token[0] == T_CLASS) { $inClass = true; - } else if ($token[0] == T_FUNCTION) { + } elseif ($token[0] == T_FUNCTION) { if ($tokens[$i+2][0] == T_STRING) { $this->staticReflection[$lastSeenClass]['methods'][] = $tokens[$i+2][1]; - } else if ($tokens[$i+2] == "&" && $tokens[$i+3][0] == T_STRING) { + } elseif ($tokens[$i+2] == "&" && $tokens[$i+3][0] == T_STRING) { $this->staticReflection[$lastSeenClass]['methods'][] = $tokens[$i+3][1]; } - } else if (in_array($token[0], array(T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED)) && $tokens[$i+2][0] != T_FUNCTION) { + } elseif (in_array($token[0], array(T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED)) && $tokens[$i+2][0] != T_FUNCTION) { $this->staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i+2][1], 1); } } } - private function hasProperty($property, ClassMetadataInfo $metadata) + /** + * @param string $property + * @param ClassMetadataInfo $metadata + * + * @return bool + */ + protected function hasProperty($property, ClassMetadataInfo $metadata) { if ($this->extendsClass()) { // don't generate property if its already on the base class. @@ -651,11 +715,18 @@ public function __construct() ); } - private function hasMethod($method, ClassMetadataInfo $metadata) + /** + * @param string $method + * @param ClassMetadataInfo $metadata + * + * @return bool + */ + protected function hasMethod($method, ClassMetadataInfo $metadata) { if ($this->extendsClass()) { // don't generate method if its already on the base class. $reflClass = new \ReflectionClass($this->getClassToExtend()); + if ($reflClass->hasMethod($method)) { return true; } @@ -667,40 +738,69 @@ public function __construct() ); } - private function hasNamespace(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return bool + */ + protected function hasNamespace(ClassMetadataInfo $metadata) { return strpos($metadata->name, '\\') ? true : false; } - private function extendsClass() + /** + * @return bool + */ + protected function extendsClass() { return $this->classToExtend ? true : false; } - private function getClassToExtend() + /** + * @return string + */ + protected function getClassToExtend() { return $this->classToExtend; } - private function getClassToExtendName() + /** + * @return string + */ + protected function getClassToExtendName() { $refl = new \ReflectionClass($this->getClassToExtend()); return '\\' . $refl->getName(); } - private function getClassName(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function getClassName(ClassMetadataInfo $metadata) { return ($pos = strrpos($metadata->name, '\\')) ? substr($metadata->name, $pos + 1, strlen($metadata->name)) : $metadata->name; } - private function getNamespace(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function getNamespace(ClassMetadataInfo $metadata) { return substr($metadata->name, 0, strrpos($metadata->name, '\\')); } - private function generateEntityDocBlock(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityDocBlock(ClassMetadataInfo $metadata) { $lines = array(); $lines[] = '/**'; @@ -742,7 +842,12 @@ public function __construct() return implode("\n", $lines); } - private function generateTableAnnotation($metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateTableAnnotation($metadata) { $table = array(); @@ -767,7 +872,13 @@ public function __construct() return '@' . $this->annotationsPrefix . 'Table(' . implode(', ', $table) . ')'; } - private function generateTableConstraints($constraintName, $constraints) + /** + * @param string $constraintName + * @param array $constraints + * + * @return string + */ + protected function generateTableConstraints($constraintName, $constraints) { $annotations = array(); foreach ($constraints as $name => $constraint) { @@ -780,17 +891,27 @@ public function __construct() return implode(', ', $annotations); } - private function generateInheritanceAnnotation($metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateInheritanceAnnotation($metadata) { if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) { return '@' . $this->annotationsPrefix . 'InheritanceType("'.$this->getInheritanceTypeString($metadata->inheritanceType).'")'; } } - private function generateDiscriminatorColumnAnnotation($metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateDiscriminatorColumnAnnotation($metadata) { if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - $discrColumn = $metadata->discriminatorValue; + $discrColumn = $metadata->discriminatorColumn; $columnDefinition = 'name="' . $discrColumn['name'] . '", type="' . $discrColumn['type'] . '", length=' . $discrColumn['length']; @@ -799,7 +920,12 @@ public function __construct() } } - private function generateDiscriminatorMapAnnotation($metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateDiscriminatorMapAnnotation($metadata) { if ($metadata->inheritanceType != ClassMetadataInfo::INHERITANCE_TYPE_NONE) { $inheritanceClassMap = array(); @@ -812,7 +938,12 @@ public function __construct() } } - private function generateEntityStubMethods(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityStubMethods(ClassMetadataInfo $metadata) { $methods = array(); @@ -837,7 +968,7 @@ public function __construct() if ($code = $this->generateEntityStubMethod($metadata, 'get', $associationMapping['fieldName'], $associationMapping['targetEntity'])) { $methods[] = $code; } - } else if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) { + } elseif ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) { if ($code = $this->generateEntityStubMethod($metadata, 'add', $associationMapping['fieldName'], $associationMapping['targetEntity'])) { $methods[] = $code; } @@ -853,26 +984,39 @@ public function __construct() return implode("\n\n", $methods); } - private function isAssociationIsNullable($associationMapping) + /** + * @param array $associationMapping + * + * @return bool + */ + protected function isAssociationIsNullable($associationMapping) { if (isset($associationMapping['id']) && $associationMapping['id']) { return false; } + if (isset($associationMapping['joinColumns'])) { $joinColumns = $associationMapping['joinColumns']; } else { - //@todo thereis no way to retreive targetEntity metadata + //@todo there is no way to retrieve targetEntity metadata $joinColumns = array(); } + foreach ($joinColumns as $joinColumn) { if(isset($joinColumn['nullable']) && !$joinColumn['nullable']) { return false; } } + return true; } - private function generateEntityLifecycleCallbackMethods(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityLifecycleCallbackMethods(ClassMetadataInfo $metadata) { if (isset($metadata->lifecycleCallbacks) && $metadata->lifecycleCallbacks) { $methods = array(); @@ -891,7 +1035,12 @@ public function __construct() return ""; } - private function generateEntityAssociationMappingProperties(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityAssociationMappingProperties(ClassMetadataInfo $metadata) { $lines = array(); @@ -908,7 +1057,12 @@ public function __construct() return implode("\n", $lines); } - private function generateEntityFieldMappingProperties(ClassMetadataInfo $metadata) + /** + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateEntityFieldMappingProperties(ClassMetadataInfo $metadata) { $lines = array(); @@ -926,15 +1080,24 @@ public function __construct() return implode("\n", $lines); } - private function generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null) + /** + * @param ClassMetadataInfo $metadata + * @param string $type + * @param string $fieldName + * @param string|null $typeHint + * @param string|null $defaultValue + * + * @return string + */ + protected function generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null) { $methodName = $type . Inflector::classify($fieldName); - if (in_array($type, array("add", "remove")) && substr($methodName, -1) == "s") { - $methodName = substr($methodName, 0, -1); + if (in_array($type, array("add", "remove"))) { + $methodName = Inflector::singularize($methodName); } if ($this->hasMethod($methodName, $metadata)) { - return; + return ''; } $this->staticReflection[$metadata->name]['methods'][] = $methodName; @@ -970,10 +1133,17 @@ public function __construct() return $this->prefixCodeWithSpaces($method); } - private function generateLifecycleCallbackMethod($name, $methodName, $metadata) + /** + * @param string $name + * @param string $methodName + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateLifecycleCallbackMethod($name, $methodName, $metadata) { if ($this->hasMethod($methodName, $metadata)) { - return; + return ''; } $this->staticReflection[$metadata->name]['methods'][] = $methodName; @@ -991,7 +1161,12 @@ public function __construct() return $this->prefixCodeWithSpaces($method); } - private function generateJoinColumnAnnotation(array $joinColumn) + /** + * @param array $joinColumn + * + * @return string + */ + protected function generateJoinColumnAnnotation(array $joinColumn) { $joinColumnAnnot = array(); @@ -1022,7 +1197,13 @@ public function __construct() return '@' . $this->annotationsPrefix . 'JoinColumn(' . implode(', ', $joinColumnAnnot) . ')'; } - private function generateAssociationMappingPropertyDocBlock(array $associationMapping, ClassMetadataInfo $metadata) + /** + * @param array $associationMapping + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateAssociationMappingPropertyDocBlock(array $associationMapping, ClassMetadataInfo $metadata) { $lines = array(); $lines[] = $this->spaces . '/**'; @@ -1082,6 +1263,10 @@ public function __construct() if ($associationMapping['isCascadeMerge']) $cascades[] = '"merge"'; if ($associationMapping['isCascadeRefresh']) $cascades[] = '"refresh"'; + if (count($cascades) === 5) { + $cascades = array('"all"'); + } + $typeOptions[] = 'cascade={' . implode(',', $cascades) . '}'; } @@ -1164,7 +1349,13 @@ public function __construct() return implode("\n", $lines); } - private function generateFieldMappingPropertyDocBlock(array $fieldMapping, ClassMetadataInfo $metadata) + /** + * @param array $fieldMapping + * @param ClassMetadataInfo $metadata + * + * @return string + */ + protected function generateFieldMappingPropertyDocBlock(array $fieldMapping, ClassMetadataInfo $metadata) { $lines = array(); $lines[] = $this->spaces . '/**'; @@ -1244,21 +1435,31 @@ public function __construct() return implode("\n", $lines); } - private function prefixCodeWithSpaces($code, $num = 1) + /** + * @param string $code + * @param int $num + * + * @return string + */ + protected function prefixCodeWithSpaces($code, $num = 1) { $lines = explode("\n", $code); foreach ($lines as $key => $value) { - $lines[$key] = str_repeat($this->spaces, $num) . $lines[$key]; + if ( ! empty($value)) { + $lines[$key] = str_repeat($this->spaces, $num) . $lines[$key]; + } } return implode("\n", $lines); } /** - * @param integer $type The inheritance type used by the class and it's subclasses. - * @return string The literal string for the inheritance type. - * @throws \InvalidArgumentException When the inheritance type does not exists. + * @param integer $type The inheritance type used by the class and its subclasses. + * + * @return string The literal string for the inheritance type. + * + * @throws \InvalidArgumentException When the inheritance type does not exists. */ protected function getInheritanceTypeString($type) { @@ -1270,9 +1471,11 @@ public function __construct() } /** - * @param integer $type The policy used for change-tracking for the mapped class. - * @return string The literal string for the change-tracking type. - * @throws \InvalidArgumentException When the change-tracking type does not exists. + * @param integer $type The policy used for change-tracking for the mapped class. + * + * @return string The literal string for the change-tracking type. + * + * @throws \InvalidArgumentException When the change-tracking type does not exists. */ protected function getChangeTrackingPolicyString($type) { @@ -1284,8 +1487,10 @@ public function __construct() } /** - * @param integer $type The generator to use for the mapped class. - * @return string The literal string for the generetor type. + * @param integer $type The generator to use for the mapped class. + * + * @return string The literal string for the generator type. + * * @throws \InvalidArgumentException When the generator type does not exists. */ protected function getIdGeneratorTypeString($type) diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php old mode 100755 new mode 100644 index e696abcdb9..5093cd54d5 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php @@ -22,7 +22,7 @@ namespace Doctrine\ORM\Tools; /** * Class to generate entity repository classes * - * + * * @link www.doctrine-project.org * @since 2.0 * @author Benjamin Eberlei @@ -35,7 +35,7 @@ class EntityRepositoryGenerator protected static $_template = '; + use Doctrine\ORM\EntityRepository; @@ -50,18 +50,43 @@ class extends EntityRepository } '; + /** + * @param string $fullClassName + * + * @return string + */ public function generateEntityRepositoryClass($fullClassName) { - $namespace = substr($fullClassName, 0, strrpos($fullClassName, '\\')); $className = substr($fullClassName, strrpos($fullClassName, '\\') + 1, strlen($fullClassName)); $variables = array( - '' => $namespace, + '' => $this->generateEntityRepositoryNamespace($fullClassName), '' => $className ); + return str_replace(array_keys($variables), array_values($variables), self::$_template); } + /** + * Generates the namespace statement, if class do not have namespace, return empty string instead. + * + * @param string $fullClassName The full repository class name. + * + * @return string $namespace + */ + private function generateEntityRepositoryNamespace($fullClassName) + { + $namespace = substr($fullClassName, 0, strrpos($fullClassName, '\\')); + + return $namespace ? 'namespace ' . $namespace . ';' : ''; + } + + /** + * @param string $fullClassName + * @param string $outputDirectory + * + * @return void + */ public function writeEntityRepositoryClass($fullClassName, $outputDirectory) { $code = $this->generateEntityRepositoryClass($fullClassName); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php old mode 100755 new mode 100644 index 0473111651..36455621c8 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php @@ -19,6 +19,7 @@ namespace Doctrine\ORM\Tools\Event; +use Doctrine\Common\EventArgs; use Doctrine\DBAL\Schema\Schema; use Doctrine\ORM\EntityManager; @@ -30,33 +31,41 @@ use Doctrine\ORM\EntityManager; * @since 1.0 * @author Benjamin Eberlei */ -class GenerateSchemaEventArgs extends \Doctrine\Common\EventArgs +class GenerateSchemaEventArgs extends EventArgs { - private $_em = null; - private $_schema = null; + /** + * @var \Doctrine\ORM\EntityManager + */ + private $em; /** - * @param ClassMetadata $classMetadata - * @param Schema $schema - * @param Table $classTable + * @var \Doctrine\DBAL\Schema\Schema + */ + private $schema; + + /** + * @param EntityManager $em + * @param Schema $schema */ public function __construct(EntityManager $em, Schema $schema) { - $this->_em = $em; - $this->_schema = $schema; + $this->em = $em; + $this->schema = $schema; } /** * @return EntityManager */ - public function getEntityManager() { - return $this->_em; + public function getEntityManager() + { + return $this->em; } /** * @return Schema */ - public function getSchema() { - return $this->_schema; + public function getSchema() + { + return $this->schema; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php old mode 100755 new mode 100644 index 060c55469e..9e68ae6e92 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php @@ -18,6 +18,7 @@ */ namespace Doctrine\ORM\Tools\Event; +use Doctrine\Common\EventArgs; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; @@ -30,42 +31,56 @@ use Doctrine\DBAL\Schema\Table; * @since 1.0 * @author Benjamin Eberlei */ -class GenerateSchemaTableEventArgs extends \Doctrine\Common\EventArgs +class GenerateSchemaTableEventArgs extends EventArgs { - private $_classMetadata = null; - private $_schema = null; - private $_classTable = null; + /** + * @var \Doctrine\ORM\Mapping\ClassMetadata + */ + private $classMetadata; + + /** + * @var \Doctrine\DBAL\Schema\Schema + */ + private $schema; + + /** + * @var \Doctrine\DBAL\Schema\Table + */ + private $classTable; /** * @param ClassMetadata $classMetadata - * @param Schema $schema - * @param Table $classTable + * @param Schema $schema + * @param Table $classTable */ public function __construct(ClassMetadata $classMetadata, Schema $schema, Table $classTable) { - $this->_classMetadata = $classMetadata; - $this->_schema = $schema; - $this->_classTable = $classTable; + $this->classMetadata = $classMetadata; + $this->schema = $schema; + $this->classTable = $classTable; } /** * @return ClassMetadata */ - public function getClassMetadata() { - return $this->_classMetadata; + public function getClassMetadata() + { + return $this->classMetadata; } /** * @return Schema */ - public function getSchema() { - return $this->_schema; + public function getSchema() + { + return $this->schema; } /** * @return Table */ - public function getClassTable() { - return $this->_classTable; + public function getClassTable() + { + return $this->classTable; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php old mode 100755 new mode 100644 index 843c00492e..478ae8473c --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php @@ -19,20 +19,21 @@ namespace Doctrine\ORM\Tools\Export; -use Doctrine\ORM\Tools\Export\ExportException, - Doctrine\ORM\EntityManager; +use Doctrine\ORM\Tools\Export\ExportException; /** * Class used for converting your mapping information between the * supported formats: yaml, xml, and php/annotation. * - * * @link www.doctrine-project.org * @since 2.0 * @author Jonathan Wage */ class ClassMetadataExporter { + /** + * @var array + */ private static $_exporterDrivers = array( 'xml' => 'Doctrine\ORM\Tools\Export\Driver\XmlExporter', 'yaml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter', @@ -42,10 +43,12 @@ class ClassMetadataExporter ); /** - * Register a new exporter driver class under a specified name + * Registers a new exporter driver class under a specified name. * * @param string $name * @param string $class + * + * @return void */ public static function registerExportDriver($name, $class) { @@ -53,11 +56,14 @@ class ClassMetadataExporter } /** - * Get a exporter driver instance + * Gets an exporter driver instance. * - * @param string $type The type to get (yml, xml, etc.) - * @param string $source The directory where the exporter will export to - * @return AbstractExporter $exporter + * @param string $type The type to get (yml, xml, etc.). + * @param string|null $dest The directory where the exporter will export to. + * + * @return Driver\AbstractExporter + * + * @throws ExportException */ public function getExporter($type, $dest = null) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php old mode 100755 new mode 100644 index 7c13397987..d40d0786e6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php @@ -24,25 +24,47 @@ use Doctrine\ORM\Tools\Export\ExportException; /** * Abstract base class which is to be used for the Exporter drivers - * which can be found in \Doctrine\ORM\Tools\Export\Driver + * which can be found in \Doctrine\ORM\Tools\Export\Driver. * - * * @link www.doctrine-project.org * @since 2.0 * @author Jonathan Wage */ abstract class AbstractExporter { + /** + * @var array + */ protected $_metadata = array(); + + /** + * @var string|null + */ protected $_outputDir; + + /** + * @var string|null + */ protected $_extension; + + /** + * @var bool + */ protected $_overwriteExistingFiles = false; + /** + * @param string|null $dir + */ public function __construct($dir = null) { $this->_outputDir = $dir; } + /** + * @param bool $overwrite + * + * @return void + */ public function setOverwriteExistingFiles($overwrite) { $this->_overwriteExistingFiles = $overwrite; @@ -50,17 +72,19 @@ abstract class AbstractExporter /** * Converts a single ClassMetadata instance to the exported format - * and returns it + * and returns it. * * @param ClassMetadataInfo $metadata - * @return mixed $exported + * + * @return string */ abstract public function exportClassMetadata(ClassMetadataInfo $metadata); /** - * Set the array of ClassMetadataInfo instances to export + * Sets the array of ClassMetadataInfo instances to export. * * @param array $metadata + * * @return void */ public function setMetadata(array $metadata) @@ -69,9 +93,9 @@ abstract class AbstractExporter } /** - * Get the extension used to generated the path to a class + * Gets the extension used to generated the path to a class. * - * @return string $extension + * @return string|null */ public function getExtension() { @@ -79,7 +103,7 @@ abstract class AbstractExporter } /** - * Set the directory to output the mapping files to + * Sets the directory to output the mapping files to. * * [php] * $exporter = new YamlExporter($metadata); @@ -87,6 +111,7 @@ abstract class AbstractExporter * $exporter->export(); * * @param string $dir + * * @return void */ public function setOutputDir($dir) @@ -95,10 +120,12 @@ abstract class AbstractExporter } /** - * Export each ClassMetadata instance to a single Doctrine Mapping file - * named after the entity + * Exports each ClassMetadata instance to a single Doctrine Mapping file + * named after the entity. * * @return void + * + * @throws \Doctrine\ORM\Tools\Export\ExportException */ public function export() { @@ -123,10 +150,11 @@ abstract class AbstractExporter } /** - * Generate the path to write the class for the given ClassMetadataInfo instance + * Generates the path to write the class for the given ClassMetadataInfo instance. * * @param ClassMetadataInfo $metadata - * @return string $path + * + * @return string */ protected function _generateOutputPath(ClassMetadataInfo $metadata) { @@ -134,7 +162,7 @@ abstract class AbstractExporter } /** - * Set the directory to output the mapping files to + * Sets the directory to output the mapping files to. * * [php] * $exporter = new YamlExporter($metadata, __DIR__ . '/yaml'); @@ -142,6 +170,7 @@ abstract class AbstractExporter * $exporter->export(); * * @param string $extension + * * @return void */ public function setExtension($extension) @@ -149,65 +178,72 @@ abstract class AbstractExporter $this->_extension = $extension; } + /** + * @param int $type + * + * @return string + */ protected function _getInheritanceTypeString($type) { - switch ($type) - { + switch ($type) { case ClassMetadataInfo::INHERITANCE_TYPE_NONE: return 'NONE'; - break; case ClassMetadataInfo::INHERITANCE_TYPE_JOINED: return 'JOINED'; - break; case ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE: return 'SINGLE_TABLE'; - break; case ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS: return 'PER_CLASS'; - break; } } + /** + * @param int $policy + * + * @return string + */ protected function _getChangeTrackingPolicyString($policy) { - switch ($policy) - { + switch ($policy) { case ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT: return 'DEFERRED_IMPLICIT'; - break; case ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT: return 'DEFERRED_EXPLICIT'; - break; case ClassMetadataInfo::CHANGETRACKING_NOTIFY: return 'NOTIFY'; - break; } } + /** + * @param int $type + * + * @return string + */ protected function _getIdGeneratorTypeString($type) { - switch ($type) - { + switch ($type) { case ClassMetadataInfo::GENERATOR_TYPE_AUTO: return 'AUTO'; - break; case ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE: return 'SEQUENCE'; - break; case ClassMetadataInfo::GENERATOR_TYPE_TABLE: return 'TABLE'; - break; case ClassMetadataInfo::GENERATOR_TYPE_IDENTITY: return 'IDENTITY'; - break; + + case ClassMetadataInfo::GENERATOR_TYPE_UUID: + return 'UUID'; + + case ClassMetadataInfo::GENERATOR_TYPE_CUSTOM: + return 'CUSTOM'; } } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php old mode 100755 new mode 100644 index d1ec92ab45..044a1da53a --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php @@ -19,34 +19,37 @@ namespace Doctrine\ORM\Tools\Export\Driver; -use Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Tools\EntityGenerator; +use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\ORM\Tools\EntityGenerator; /** - * ClassMetadata exporter for PHP classes with annotations + * ClassMetadata exporter for PHP classes with annotations. * - * * @link www.doctrine-project.org * @since 2.0 * @author Jonathan Wage */ class AnnotationExporter extends AbstractExporter { + /** + * @var string + */ protected $_extension = '.php'; + + /** + * @var EntityGenerator|null + */ private $_entityGenerator; /** - * Converts a single ClassMetadata instance to the exported format - * and returns it - * - * @param ClassMetadataInfo $metadata - * @return string $exported + * {@inheritdoc} */ public function exportClassMetadata(ClassMetadataInfo $metadata) { if ( ! $this->_entityGenerator) { throw new \RuntimeException('For the AnnotationExporter you must set an EntityGenerator instance with the setEntityGenerator() method.'); } + $this->_entityGenerator->setGenerateAnnotations(true); $this->_entityGenerator->setGenerateStubMethods(false); $this->_entityGenerator->setRegenerateEntityIfExists(false); @@ -55,11 +58,21 @@ class AnnotationExporter extends AbstractExporter return $this->_entityGenerator->generateEntityClass($metadata); } + /** + * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata + * + * @return string + */ protected function _generateOutputPath(ClassMetadataInfo $metadata) { return $this->_outputDir . '/' . str_replace('\\', '/', $metadata->name) . $this->_extension; } + /** + * @param \Doctrine\ORM\Tools\EntityGenerator $entityGenerator + * + * @return void + */ public function setEntityGenerator(EntityGenerator $entityGenerator) { $this->_entityGenerator = $entityGenerator; diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php old mode 100755 new mode 100644 index 24f72431e2..778c30f498 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php @@ -22,23 +22,21 @@ namespace Doctrine\ORM\Tools\Export\Driver; use Doctrine\ORM\Mapping\ClassMetadataInfo; /** - * ClassMetadata exporter for PHP code + * ClassMetadata exporter for PHP code. * - * * @link www.doctrine-project.org * @since 2.0 * @author Jonathan Wage */ class PhpExporter extends AbstractExporter { + /** + * @var string + */ protected $_extension = '.php'; /** - * Converts a single ClassMetadata instance to the exported format - * and returns it - * - * @param ClassMetadataInfo $metadata - * @return mixed $exported + * {@inheritdoc} */ public function exportClassMetadata(ClassMetadataInfo $metadata) { @@ -99,6 +97,11 @@ class PhpExporter extends AbstractExporter unset($cascade[$key]); } } + + if (count($cascade) === 5) { + $cascade = array('all'); + } + $associationMappingArray = array( 'fieldName' => $associationMapping['fieldName'], 'targetEntity' => $associationMapping['targetEntity'], @@ -115,7 +118,7 @@ class PhpExporter extends AbstractExporter ); $associationMappingArray = array_merge($associationMappingArray, $oneToOneMappingArray); - } else if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { + } elseif ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { $method = 'mapOneToMany'; $potentialAssociationMappingIndexes = array( 'mappedBy', @@ -128,7 +131,7 @@ class PhpExporter extends AbstractExporter } } $associationMappingArray = array_merge($associationMappingArray, $oneToManyMappingArray); - } else if ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { + } elseif ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { $method = 'mapManyToMany'; $potentialAssociationMappingIndexes = array( 'mappedBy', @@ -149,6 +152,11 @@ class PhpExporter extends AbstractExporter return implode("\n", $lines); } + /** + * @param mixed $var + * + * @return string + */ protected function _varExport($var) { $export = var_export($var, true); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php old mode 100755 new mode 100644 index 48cf019562..1a8fde1841 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php @@ -22,23 +22,21 @@ namespace Doctrine\ORM\Tools\Export\Driver; use Doctrine\ORM\Mapping\ClassMetadataInfo; /** - * ClassMetadata exporter for Doctrine XML mapping files + * ClassMetadata exporter for Doctrine XML mapping files. * - * * @link www.doctrine-project.org * @since 2.0 * @author Jonathan Wage */ class XmlExporter extends AbstractExporter { + /** + * @var string + */ protected $_extension = '.dcm.xml'; /** - * Converts a single ClassMetadata instance to the exported format - * and returns it - * - * @param ClassMetadataInfo $metadata - * @return mixed $exported + * {@inheritdoc} */ public function exportClassMetadata(ClassMetadataInfo $metadata) { @@ -79,6 +77,7 @@ class XmlExporter extends AbstractExporter $discriminatorColumnXml = $root->addChild('discriminator-column'); $discriminatorColumnXml->addAttribute('name', $metadata->discriminatorColumn['name']); $discriminatorColumnXml->addAttribute('type', $metadata->discriminatorColumn['type']); + if (isset($metadata->discriminatorColumn['length'])) { $discriminatorColumnXml->addAttribute('length', $metadata->discriminatorColumn['length']); } @@ -86,6 +85,7 @@ class XmlExporter extends AbstractExporter if ($metadata->discriminatorMap) { $discriminatorMapXml = $root->addChild('discriminator-map'); + foreach ($metadata->discriminatorMap as $value => $className) { $discriminatorMappingXml = $discriminatorMapXml->addChild('discriminator-mapping'); $discriminatorMappingXml->addAttribute('value', $value); @@ -94,6 +94,7 @@ class XmlExporter extends AbstractExporter } $trackingPolicy = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy); + if ( $trackingPolicy != 'DEFERRED_IMPLICIT') { $root->addChild('change-tracking-policy', $trackingPolicy); } @@ -128,6 +129,15 @@ class XmlExporter extends AbstractExporter } } + foreach ($metadata->associationMappings as $name => $assoc) { + if (isset($assoc['id']) && $assoc['id']) { + $id[$name] = array( + 'fieldName' => $name, + 'associationKey' => true + ); + } + } + if ( ! $metadata->isIdentifierComposite && $idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) { $id[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $idGeneratorType; } @@ -136,7 +146,11 @@ class XmlExporter extends AbstractExporter foreach ($id as $field) { $idXml = $root->addChild('id'); $idXml->addAttribute('name', $field['fieldName']); - $idXml->addAttribute('type', $field['type']); + + if (isset($field['type'])) { + $idXml->addAttribute('type', $field['type']); + } + if (isset($field['columnName'])) { $idXml->addAttribute('column', $field['columnName']); } @@ -161,57 +175,70 @@ class XmlExporter extends AbstractExporter $fieldXml = $root->addChild('field'); $fieldXml->addAttribute('name', $field['fieldName']); $fieldXml->addAttribute('type', $field['type']); + if (isset($field['columnName'])) { $fieldXml->addAttribute('column', $field['columnName']); } + if (isset($field['length'])) { $fieldXml->addAttribute('length', $field['length']); } + if (isset($field['precision'])) { $fieldXml->addAttribute('precision', $field['precision']); } + if (isset($field['scale'])) { $fieldXml->addAttribute('scale', $field['scale']); } + if (isset($field['unique']) && $field['unique']) { $fieldXml->addAttribute('unique', $field['unique']); } + if (isset($field['options'])) { $optionsXml = $fieldXml->addChild('options'); foreach ($field['options'] as $key => $value) { $optionsXml->addAttribute($key, $value); } } + if (isset($field['version'])) { $fieldXml->addAttribute('version', $field['version']); } + if (isset($field['columnDefinition'])) { $fieldXml->addAttribute('column-definition', $field['columnDefinition']); } + if (isset($field['nullable'])) { $fieldXml->addAttribute('nullable', $field['nullable'] ? 'true' : 'false'); } } } + $orderMap = array( ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_ONE, ClassMetadataInfo::MANY_TO_MANY, ); - uasort($metadata->associationMappings, function($m1, $m2)use(&$orderMap){ - $a1 = array_search($m1['type'],$orderMap); - $a2 = array_search($m2['type'],$orderMap); + + uasort($metadata->associationMappings, function($m1, $m2) use (&$orderMap){ + $a1 = array_search($m1['type'], $orderMap); + $a2 = array_search($m2['type'], $orderMap); + return strcmp($a1, $a2); }); - foreach ($metadata->associationMappings as $name => $associationMapping) { + + foreach ($metadata->associationMappings as $associationMapping) { if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_ONE) { $associationMappingXml = $root->addChild('one-to-one'); - } else if ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_ONE) { + } elseif ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_ONE) { $associationMappingXml = $root->addChild('many-to-one'); - } else if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { + } elseif ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { $associationMappingXml = $root->addChild('one-to-many'); - } else if ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { + } elseif ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { $associationMappingXml = $root->addChild('many-to-many'); } @@ -221,41 +248,53 @@ class XmlExporter extends AbstractExporter if (isset($associationMapping['mappedBy'])) { $associationMappingXml->addAttribute('mapped-by', $associationMapping['mappedBy']); } + if (isset($associationMapping['inversedBy'])) { $associationMappingXml->addAttribute('inversed-by', $associationMapping['inversedBy']); } + if (isset($associationMapping['indexBy'])) { $associationMappingXml->addAttribute('index-by', $associationMapping['indexBy']); } - if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval']!==false) { + + if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval'] !== false) { $associationMappingXml->addAttribute('orphan-removal', 'true'); } + if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) { $joinTableXml = $associationMappingXml->addChild('join-table'); $joinTableXml->addAttribute('name', $associationMapping['joinTable']['name']); $joinColumnsXml = $joinTableXml->addChild('join-columns'); + foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) { $joinColumnXml = $joinColumnsXml->addChild('join-column'); $joinColumnXml->addAttribute('name', $joinColumn['name']); $joinColumnXml->addAttribute('referenced-column-name', $joinColumn['referencedColumnName']); + if (isset($joinColumn['onDelete'])) { $joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']); } } + $inverseJoinColumnsXml = $joinTableXml->addChild('inverse-join-columns'); + foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) { $inverseJoinColumnXml = $inverseJoinColumnsXml->addChild('join-column'); $inverseJoinColumnXml->addAttribute('name', $inverseJoinColumn['name']); $inverseJoinColumnXml->addAttribute('referenced-column-name', $inverseJoinColumn['referencedColumnName']); + if (isset($inverseJoinColumn['onDelete'])) { $inverseJoinColumnXml->addAttribute('on-delete', $inverseJoinColumn['onDelete']); } + if (isset($inverseJoinColumn['columnDefinition'])) { $inverseJoinColumnXml->addAttribute('column-definition', $inverseJoinColumn['columnDefinition']); } + if (isset($inverseJoinColumn['nullable'])) { $inverseJoinColumnXml->addAttribute('nullable', $inverseJoinColumn['nullable']); } + if (isset($inverseJoinColumn['orderBy'])) { $inverseJoinColumnXml->addAttribute('order-by', $inverseJoinColumn['orderBy']); } @@ -263,16 +302,20 @@ class XmlExporter extends AbstractExporter } if (isset($associationMapping['joinColumns'])) { $joinColumnsXml = $associationMappingXml->addChild('join-columns'); + foreach ($associationMapping['joinColumns'] as $joinColumn) { $joinColumnXml = $joinColumnsXml->addChild('join-column'); $joinColumnXml->addAttribute('name', $joinColumn['name']); $joinColumnXml->addAttribute('referenced-column-name', $joinColumn['referencedColumnName']); + if (isset($joinColumn['onDelete'])) { $joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']); } + if (isset($joinColumn['columnDefinition'])) { $joinColumnXml->addAttribute('column-definition', $joinColumn['columnDefinition']); } + if (isset($joinColumn['nullable'])) { $joinColumnXml->addAttribute('nullable', $joinColumn['nullable']); } @@ -280,6 +323,7 @@ class XmlExporter extends AbstractExporter } if (isset($associationMapping['orderBy'])) { $orderByXml = $associationMappingXml->addChild('order-by'); + foreach ($associationMapping['orderBy'] as $name => $direction) { $orderByFieldXml = $orderByXml->addChild('order-by-field'); $orderByFieldXml->addAttribute('name', $name); @@ -287,26 +331,34 @@ class XmlExporter extends AbstractExporter } } $cascade = array(); + if ($associationMapping['isCascadeRemove']) { $cascade[] = 'cascade-remove'; } + if ($associationMapping['isCascadePersist']) { $cascade[] = 'cascade-persist'; } + if ($associationMapping['isCascadeRefresh']) { $cascade[] = 'cascade-refresh'; } + if ($associationMapping['isCascadeMerge']) { $cascade[] = 'cascade-merge'; } + if ($associationMapping['isCascadeDetach']) { $cascade[] = 'cascade-detach'; } + if (count($cascade) === 5) { $cascade = array('cascade-all'); } + if ($cascade) { $cascadeXml = $associationMappingXml->addChild('cascade'); + foreach ($cascade as $type) { $cascadeXml->addChild($type); } @@ -315,6 +367,7 @@ class XmlExporter extends AbstractExporter if (isset($metadata->lifecycleCallbacks) && count($metadata->lifecycleCallbacks)>0) { $lifecycleCallbacksXml = $root->addChild('lifecycle-callbacks'); + foreach ($metadata->lifecycleCallbacks as $name => $methods) { foreach ($methods as $method) { $lifecycleCallbackXml = $lifecycleCallbacksXml->addChild('lifecycle-callback'); @@ -329,6 +382,7 @@ class XmlExporter extends AbstractExporter /** * @param \SimpleXMLElement $simpleXml + * * @return string $xml */ private function _asXml($simpleXml) @@ -337,7 +391,6 @@ class XmlExporter extends AbstractExporter $dom->loadXML($simpleXml->asXML()); $dom->formatOutput = true; - $result = $dom->saveXML(); - return $result; + return $dom->saveXML(); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php old mode 100755 new mode 100644 index ceafa834a2..45c4319254 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php @@ -19,28 +19,25 @@ namespace Doctrine\ORM\Tools\Export\Driver; +use Symfony\Component\Yaml\Yaml; use Doctrine\ORM\Mapping\ClassMetadataInfo; /** - * ClassMetadata exporter for Doctrine YAML mapping files + * ClassMetadata exporter for Doctrine YAML mapping files. * - * * @link www.doctrine-project.org * @since 2.0 * @author Jonathan Wage */ class YamlExporter extends AbstractExporter { + /** + * @var string + */ protected $_extension = '.dcm.yml'; /** - * Converts a single ClassMetadata instance to the exported format - * and returns it - * - * TODO: Should this code be pulled out in to a toArray() method in ClassMetadata - * - * @param ClassMetadataInfo $metadata - * @return mixed $exported + * {@inheritdoc} */ public function exportClassMetadata(ClassMetadataInfo $metadata) { @@ -59,6 +56,7 @@ class YamlExporter extends AbstractExporter } $inheritanceType = $metadata->inheritanceType; + if ($inheritanceType !== ClassMetadataInfo::INHERITANCE_TYPE_NONE) { $array['inheritanceType'] = $this->_getInheritanceTypeString($inheritanceType); } @@ -92,10 +90,8 @@ class YamlExporter extends AbstractExporter $ids = array(); foreach ($fieldMappings as $name => $fieldMapping) { $fieldMapping['column'] = $fieldMapping['columnName']; - unset( - $fieldMapping['columnName'], - $fieldMapping['fieldName'] - ); + + unset($fieldMapping['columnName'], $fieldMapping['fieldName']); if ($fieldMapping['column'] == $name) { unset($fieldMapping['column']); @@ -114,9 +110,7 @@ class YamlExporter extends AbstractExporter $ids[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $idGeneratorType; } - if ($ids) { - $array['fields'] = $ids; - } + $array['id'] = $ids; if ($fieldMappings) { if ( ! isset($array['fields'])) { @@ -127,38 +121,51 @@ class YamlExporter extends AbstractExporter foreach ($metadata->associationMappings as $name => $associationMapping) { $cascade = array(); + if ($associationMapping['isCascadeRemove']) { $cascade[] = 'remove'; } + if ($associationMapping['isCascadePersist']) { $cascade[] = 'persist'; } + if ($associationMapping['isCascadeRefresh']) { $cascade[] = 'refresh'; } + if ($associationMapping['isCascadeMerge']) { $cascade[] = 'merge'; } + if ($associationMapping['isCascadeDetach']) { $cascade[] = 'detach'; } if (count($cascade) === 5) { $cascade = array('all'); } + $associationMappingArray = array( 'targetEntity' => $associationMapping['targetEntity'], 'cascade' => $cascade, ); + if (isset($mapping['id']) && $mapping['id'] === true) { + $array['id'][$name]['associationKey'] = true; + } + if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { $joinColumns = $associationMapping['joinColumns']; $newJoinColumns = array(); + foreach ($joinColumns as $joinColumn) { $newJoinColumns[$joinColumn['name']]['referencedColumnName'] = $joinColumn['referencedColumnName']; + if (isset($joinColumn['onDelete'])) { $newJoinColumns[$joinColumn['name']]['onDelete'] = $joinColumn['onDelete']; } } + $oneToOneMappingArray = array( 'mappedBy' => $associationMapping['mappedBy'], 'inversedBy' => $associationMapping['inversedBy'], @@ -173,8 +180,7 @@ class YamlExporter extends AbstractExporter } else { $array['manyToOne'][$name] = $associationMappingArray; } - - } else if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { + } elseif ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) { $oneToManyMappingArray = array( 'mappedBy' => $associationMapping['mappedBy'], 'inversedBy' => $associationMapping['inversedBy'], @@ -184,7 +190,7 @@ class YamlExporter extends AbstractExporter $associationMappingArray = array_merge($associationMappingArray, $oneToManyMappingArray); $array['oneToMany'][$name] = $associationMappingArray; - } else if ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { + } elseif ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) { $manyToManyMappingArray = array( 'mappedBy' => $associationMapping['mappedBy'], 'inversedBy' => $associationMapping['inversedBy'], @@ -200,6 +206,6 @@ class YamlExporter extends AbstractExporter $array['lifecycleCallbacks'] = $metadata->lifecycleCallbacks; } - return \Symfony\Component\Yaml\Yaml::dump(array($metadata->name => $array), 10); + return Yaml::dump(array($metadata->name => $array), 10); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/ExportException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/ExportException.php old mode 100755 new mode 100644 index 5ba8bd26ba..89ddfe22eb --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/ExportException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Export/ExportException.php @@ -6,16 +6,31 @@ use Doctrine\ORM\ORMException; class ExportException extends ORMException { + /** + * @param string $type + * + * @return ExportException + */ public static function invalidExporterDriverType($type) { return new self("The specified export driver '$type' does not exist"); } + /** + * @param string $type + * + * @return ExportException + */ public static function invalidMappingDriverType($type) { return new self("The mapping driver '$type' does not exist"); } + /** + * @param string $file + * + * @return ExportException + */ public static function attemptOverwriteExistingFile($file) { return new self("Attempting to overwrite an existing file '".$file."'."); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php old mode 100755 new mode 100644 index 43e8f22396..a65c733284 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -13,11 +13,11 @@ namespace Doctrine\ORM\Tools\Pagination; -use Doctrine\ORM\Query\SqlWalker, - Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\AST\SelectStatement; /** - * Wrap the query in order to accurately count the root objects + * Wraps the query in order to accurately count the root objects. * * Given a DQL like `SELECT u FROM User u` it will generate an SQL query like: * SELECT COUNT(*) (SELECT DISTINCT FROM ()) @@ -30,12 +30,12 @@ use Doctrine\ORM\Query\SqlWalker, class CountOutputWalker extends SqlWalker { /** - * @var Doctrine\DBAL\Platforms\AbstractPlatform + * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ private $platform; /** - * @var Doctrine\ORM\Query\ResultSetMapping + * @var \Doctrine\ORM\Query\ResultSetMapping */ private $rsm; @@ -45,13 +45,15 @@ class CountOutputWalker extends SqlWalker private $queryComponents; /** - * Constructor. Stores various parameters that are otherwise unavailable + * Constructor. + * + * Stores various parameters that are otherwise unavailable * because Doctrine\ORM\Query\SqlWalker keeps everything private without * accessors. * - * @param Doctrine\ORM\Query $query - * @param Doctrine\ORM\Query\ParserResult $parserResult - * @param array $queryComponents + * @param \Doctrine\ORM\Query $query + * @param \Doctrine\ORM\Query\ParserResult $parserResult + * @param array $queryComponents */ public function __construct($query, $parserResult, array $queryComponents) { @@ -63,14 +65,17 @@ class CountOutputWalker extends SqlWalker } /** - * Walks down a SelectStatement AST node, wrapping it in a COUNT (SELECT DISTINCT) + * Walks down a SelectStatement AST node, wrapping it in a COUNT (SELECT DISTINCT). * * Note that the ORDER BY clause is not removed. Many SQL implementations (e.g. MySQL) * are able to cache subqueries. By keeping the ORDER BY clause intact, the limitSubQuery * that will most likely be executed next can be read from the native SQL cache. * * @param SelectStatement $AST + * * @return string + * + * @throws \RuntimeException */ public function walkSelectStatement(SelectStatement $AST) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php old mode 100755 new mode 100644 index 0fc7e75856..778dd30720 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -13,14 +13,14 @@ namespace Doctrine\ORM\Tools\Pagination; -use Doctrine\ORM\Query\TreeWalkerAdapter, - Doctrine\ORM\Query\AST\SelectStatement, - Doctrine\ORM\Query\AST\SelectExpression, - Doctrine\ORM\Query\AST\PathExpression, - Doctrine\ORM\Query\AST\AggregateExpression; +use Doctrine\ORM\Query\TreeWalkerAdapter; +use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\AST\SelectExpression; +use Doctrine\ORM\Query\AST\PathExpression; +use Doctrine\ORM\Query\AST\AggregateExpression; /** - * Replaces the selectClause of the AST with a COUNT statement + * Replaces the selectClause of the AST with a COUNT statement. * * @category DoctrineExtensions * @package DoctrineExtensions\Paginate @@ -31,15 +31,18 @@ use Doctrine\ORM\Query\TreeWalkerAdapter, class CountWalker extends TreeWalkerAdapter { /** - * Distinct mode hint name + * Distinct mode hint name. */ const HINT_DISTINCT = 'doctrine_paginator.distinct'; /** - * Walks down a SelectStatement AST node, modifying it to retrieve a COUNT + * Walks down a SelectStatement AST node, modifying it to retrieve a COUNT. * * @param SelectStatement $AST + * * @return void + * + * @throws \RuntimeException */ public function walkSelectStatement(SelectStatement $AST) { diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php old mode 100755 new mode 100644 index 35f8219dc4..2ee5f90562 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -16,9 +16,10 @@ namespace Doctrine\ORM\Tools\Pagination; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\AST\SelectStatement; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; +use Doctrine\DBAL\Platforms\OraclePlatform; /** - * Wrap the query in order to select root entity IDs for pagination + * Wraps the query in order to select root entity IDs for pagination. * * Given a DQL like `SELECT u FROM User u` it will generate an SQL query like: * SELECT DISTINCT FROM () LIMIT x OFFSET y @@ -31,12 +32,12 @@ use Doctrine\DBAL\Platforms\PostgreSqlPlatform; class LimitSubqueryOutputWalker extends SqlWalker { /** - * @var Doctrine\DBAL\Platforms\AbstractPlatform + * @var \Doctrine\DBAL\Platforms\AbstractPlatform */ private $platform; /** - * @var Doctrine\ORM\Query\ResultSetMapping + * @var \Doctrine\ORM\Query\ResultSetMapping */ private $rsm; @@ -56,13 +57,15 @@ class LimitSubqueryOutputWalker extends SqlWalker private $maxResults; /** - * Constructor. Stores various parameters that are otherwise unavailable + * Constructor. + * + * Stores various parameters that are otherwise unavailable * because Doctrine\ORM\Query\SqlWalker keeps everything private without * accessors. * - * @param Doctrine\ORM\Query $query - * @param Doctrine\ORM\Query\ParserResult $parserResult - * @param array $queryComponents + * @param \Doctrine\ORM\Query $query + * @param \Doctrine\ORM\Query\ParserResult $parserResult + * @param array $queryComponents */ public function __construct($query, $parserResult, array $queryComponents) { @@ -79,21 +82,42 @@ class LimitSubqueryOutputWalker extends SqlWalker } /** - * Walks down a SelectStatement AST node, wrapping it in a SELECT DISTINCT + * Walks down a SelectStatement AST node, wrapping it in a SELECT DISTINCT. * * @param SelectStatement $AST + * * @return string + * + * @throws \RuntimeException */ public function walkSelectStatement(SelectStatement $AST) { - $innerSql = parent::walkSelectStatement($AST); + if ($this->platform instanceof PostgreSqlPlatform) { + // Set every select expression as visible(hidden = false) to + // make $AST to have scalar mappings properly + $hiddens = array(); + foreach ($AST->selectClause->selectExpressions as $idx => $expr) { + $hiddens[$idx] = $expr->hiddenAliasResultVariable; + $expr->hiddenAliasResultVariable = false; + } + + $innerSql = parent::walkSelectStatement($AST); + + // Restore hiddens + foreach ($AST->selectClause->selectExpressions as $idx => $expr) { + $expr->hiddenAliasResultVariable = $hiddens[$idx]; + } + } else { + $innerSql = parent::walkSelectStatement($AST); + } - // Find out the SQL alias of the identifier column of the root entity + + // Find out the SQL alias of the identifier column of the root entity. // It may be possible to make this work with multiple root entities but that - // would probably require issuing multiple queries or doing a UNION SELECT - // so for now, It's not supported. + // would probably require issuing multiple queries or doing a UNION SELECT. + // So for now, it's not supported. - // Get the root entity and alias from the AST fromClause + // Get the root entity and alias from the AST fromClause. $from = $AST->fromClause->identificationVariableDeclarations; if (count($from) !== 1) { throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); @@ -136,12 +160,13 @@ class LimitSubqueryOutputWalker extends SqlWalker $sql = sprintf('SELECT DISTINCT %s FROM (%s) dctrn_result', implode(', ', $sqlIdentifier), $innerSql); - if ($this->platform instanceof PostgreSqlPlatform) { + if ($this->platform instanceof PostgreSqlPlatform || + $this->platform instanceof OraclePlatform) { //http://www.doctrine-project.org/jira/browse/DDC-1958 - $this->getPostgresqlSql($AST, $sqlIdentifier, $innerSql, $sql); + $this->preserveSqlOrdering($AST, $sqlIdentifier, $innerSql, $sql); } - // Apply the limit and offset + // Apply the limit and offset. $sql = $this->platform->modifyLimitQuery( $sql, $this->maxResults, $this->firstResult ); @@ -156,25 +181,30 @@ class LimitSubqueryOutputWalker extends SqlWalker return $sql; } - + /** - * Generate new SQL for postgresql if necessary + * Generates new SQL for Postgresql or Oracle if necessary. * * @param SelectStatement $AST - * @param array sqlIdentifier + * @param array $sqlIdentifier + * @param string $innerSql * @param string $sql + * + * @return void */ - public function getPostgresqlSql(SelectStatement $AST, array $sqlIdentifier, $innerSql, &$sql) + public function preserveSqlOrdering(SelectStatement $AST, array $sqlIdentifier, $innerSql, &$sql) { - // For every order by, find out the SQL alias by inspecting the ResultSetMapping + // For every order by, find out the SQL alias by inspecting the ResultSetMapping. $sqlOrderColumns = array(); $orderBy = array(); if (isset($AST->orderByClause)) { foreach ($AST->orderByClause->orderByItems as $item) { - $possibleAliases = array_keys($this->rsm->fieldMappings, $item->expression->field); + $possibleAliases = (is_object($item->expression)) + ? array_keys($this->rsm->fieldMappings, $item->expression->field) + : array_keys($this->rsm->scalarMappings, $item->expression); foreach ($possibleAliases as $alias) { - if ($this->rsm->columnOwnerMap[$alias] == $item->expression->identificationVariable) { + if (!is_object($item->expression) || $this->rsm->columnOwnerMap[$alias] == $item->expression->identificationVariable) { $sqlOrderColumns[] = $alias; $orderBy[] = $alias . ' ' . $item->type; break; @@ -185,8 +215,8 @@ class LimitSubqueryOutputWalker extends SqlWalker $sqlOrderColumns = array_diff($sqlOrderColumns, $sqlIdentifier); } - //we don't need orderBy in inner query - //However at least on 5.4.6 I'm getting a segmentation fault and thus we don't clear it for now + // We don't need orderBy in inner query. + // However at least on 5.4.6 I'm getting a segmentation fault and thus we don't clear it for now. /*$AST->orderByClause = null; $innerSql = parent::walkSelectStatement($AST);*/ diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php old mode 100755 new mode 100644 index 1ae74f4373..ca3f1032ca --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -18,15 +18,14 @@ namespace Doctrine\ORM\Tools\Pagination; -use Doctrine\DBAL\Types\Type, - Doctrine\ORM\Query\TreeWalkerAdapter, - Doctrine\ORM\Query\AST\SelectStatement, - Doctrine\ORM\Query\AST\SelectExpression, - Doctrine\ORM\Query\AST\PathExpression, - Doctrine\ORM\Query\AST\AggregateExpression; +use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Query\TreeWalkerAdapter; +use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\AST\SelectExpression; +use Doctrine\ORM\Query\AST\PathExpression; /** - * Replaces the selectClause of the AST with a SELECT DISTINCT root.id equivalent + * Replaces the selectClause of the AST with a SELECT DISTINCT root.id equivalent. * * @category DoctrineExtensions * @package DoctrineExtensions\Paginate @@ -37,21 +36,26 @@ use Doctrine\DBAL\Types\Type, class LimitSubqueryWalker extends TreeWalkerAdapter { /** - * ID type hint + * ID type hint. */ const IDENTIFIER_TYPE = 'doctrine_paginator.id.type'; /** - * @var int Counter for generating unique order column aliases + * Counter for generating unique order column aliases. + * + * @var int */ private $_aliasCounter = 0; /** * Walks down a SelectStatement AST node, modifying it to retrieve DISTINCT ids - * of the root Entity + * of the root Entity. * * @param SelectStatement $AST + * * @return void + * + * @throws \RuntimeException */ public function walkSelectStatement(SelectStatement $AST) { @@ -60,7 +64,7 @@ class LimitSubqueryWalker extends TreeWalkerAdapter $selectExpressions = array(); foreach ($this->_getQueryComponents() as $dqlAlias => $qComp) { - // preserve mixed data in query for ordering + // Preserve mixed data in query for ordering. if (isset($qComp['resultVariable'])) { $selectExpressions[] = new SelectExpression($qComp['resultVariable'], $dqlAlias); continue; @@ -112,8 +116,4 @@ class LimitSubqueryWalker extends TreeWalkerAdapter $AST->selectClause->isDistinct = true; } - } - - - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index ee139f7567..ecace32f6f 100755 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -19,14 +19,12 @@ namespace Doctrine\ORM\Tools\Pagination; -use Doctrine\ORM\QueryBuilder, - Doctrine\ORM\Query, - Doctrine\ORM\Query\ResultSetMapping, - Doctrine\ORM\NoResultException; +use Doctrine\ORM\QueryBuilder; +use Doctrine\ORM\Query; +use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\ORM\NoResultException; /** - * Paginator - * * The paginator can handle various complex scenarios with DQL. * * @author Pablo Díez @@ -58,8 +56,8 @@ class Paginator implements \Countable, \IteratorAggregate /** * Constructor. * - * @param Query|QueryBuilder $query A Doctrine ORM query or query builder. - * @param Boolean $fetchJoinCollection Whether the query joins a collection (true by default). + * @param Query|QueryBuilder $query A Doctrine ORM query or query builder. + * @param boolean $fetchJoinCollection Whether the query joins a collection (true by default). */ public function __construct($query, $fetchJoinCollection = true) { @@ -72,7 +70,7 @@ class Paginator implements \Countable, \IteratorAggregate } /** - * Returns the query + * Returns the query. * * @return Query */ @@ -84,7 +82,7 @@ class Paginator implements \Countable, \IteratorAggregate /** * Returns whether the query joins a collection. * - * @return Boolean Whether the query joins a collection. + * @return boolean Whether the query joins a collection. */ public function getFetchJoinCollection() { @@ -92,7 +90,7 @@ class Paginator implements \Countable, \IteratorAggregate } /** - * Returns whether the paginator will use an output walker + * Returns whether the paginator will use an output walker. * * @return bool|null */ @@ -102,9 +100,10 @@ class Paginator implements \Countable, \IteratorAggregate } /** - * Set whether the paginator will use an output walker + * Sets whether the paginator will use an output walker. * * @param bool|null $useOutputWalkers + * * @return $this */ public function setUseOutputWalkers($useOutputWalkers) @@ -122,7 +121,7 @@ class Paginator implements \Countable, \IteratorAggregate /* @var $countQuery Query */ $countQuery = $this->cloneQuery($this->query); - if ( ! $countQuery->getHint(CountWalker::HINT_DISTINCT)) { + if ( ! $countQuery->hasHint(CountWalker::HINT_DISTINCT)) { $countQuery->setHint(CountWalker::HINT_DISTINCT, true); } @@ -135,7 +134,7 @@ class Paginator implements \Countable, \IteratorAggregate $countQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); $countQuery->setResultSetMapping($rsm); } else { - $countQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); + $this->appendTreeWalker($countQuery, 'Doctrine\ORM\Tools\Pagination\CountWalker'); } $countQuery->setFirstResult(null)->setMaxResults(null); @@ -148,6 +147,7 @@ class Paginator implements \Countable, \IteratorAggregate $this->count = 0; } } + return $this->count; } @@ -165,7 +165,7 @@ class Paginator implements \Countable, \IteratorAggregate if ($this->useOutputWalker($subQuery)) { $subQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); } else { - $subQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker')); + $this->appendTreeWalker($subQuery, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker'); } $subQuery->setFirstResult($offset)->setMaxResults($length); @@ -178,7 +178,7 @@ class Paginator implements \Countable, \IteratorAggregate return new \ArrayIterator(array()); } - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); + $this->appendTreeWalker($whereInQuery, 'Doctrine\ORM\Tools\Pagination\WhereInWalker'); $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, count($ids)); $whereInQuery->setFirstResult(null)->setMaxResults(null); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, $ids); @@ -191,6 +191,7 @@ class Paginator implements \Countable, \IteratorAggregate ->getResult($this->query->getHydrationMode()) ; } + return new \ArrayIterator($result); } @@ -216,7 +217,7 @@ class Paginator implements \Countable, \IteratorAggregate } /** - * Determine whether to use an output walker for the query + * Determines whether to use an output walker for the query. * * @param Query $query The query. * @@ -230,5 +231,22 @@ class Paginator implements \Countable, \IteratorAggregate return $this->useOutputWalkers; } -} + /** + * Appends a custom tree walker to the tree walkers hint. + * + * @param Query $query + * @param string $walkerClass + */ + private function appendTreeWalker(Query $query, $walkerClass) + { + $hints = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS); + + if ($hints === false) { + $hints = array(); + } + + $hints[] = $walkerClass; + $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $hints); + } +} diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php old mode 100755 new mode 100644 index d65b581bc0..27cbc3c2e1 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -17,22 +17,22 @@ namespace Doctrine\ORM\Tools\Pagination; -use Doctrine\ORM\Query\AST\ArithmeticExpression, - Doctrine\ORM\Query\AST\SimpleArithmeticExpression, - Doctrine\ORM\Query\TreeWalkerAdapter, - Doctrine\ORM\Query\AST\SelectStatement, - Doctrine\ORM\Query\AST\PathExpression, - Doctrine\ORM\Query\AST\InExpression, - Doctrine\ORM\Query\AST\NullComparisonExpression, - Doctrine\ORM\Query\AST\InputParameter, - Doctrine\ORM\Query\AST\ConditionalPrimary, - Doctrine\ORM\Query\AST\ConditionalTerm, - Doctrine\ORM\Query\AST\ConditionalExpression, - Doctrine\ORM\Query\AST\ConditionalFactor, - Doctrine\ORM\Query\AST\WhereClause; +use Doctrine\ORM\Query\AST\ArithmeticExpression; +use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; +use Doctrine\ORM\Query\TreeWalkerAdapter; +use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\AST\PathExpression; +use Doctrine\ORM\Query\AST\InExpression; +use Doctrine\ORM\Query\AST\NullComparisonExpression; +use Doctrine\ORM\Query\AST\InputParameter; +use Doctrine\ORM\Query\AST\ConditionalPrimary; +use Doctrine\ORM\Query\AST\ConditionalTerm; +use Doctrine\ORM\Query\AST\ConditionalExpression; +use Doctrine\ORM\Query\AST\ConditionalFactor; +use Doctrine\ORM\Query\AST\WhereClause; /** - * Replaces the whereClause of the AST with a WHERE id IN (:foo_1, :foo_2) equivalent + * Replaces the whereClause of the AST with a WHERE id IN (:foo_1, :foo_2) equivalent. * * @category DoctrineExtensions * @package DoctrineExtensions\Paginate @@ -43,17 +43,17 @@ use Doctrine\ORM\Query\AST\ArithmeticExpression, class WhereInWalker extends TreeWalkerAdapter { /** - * ID Count hint name + * ID Count hint name. */ const HINT_PAGINATOR_ID_COUNT = 'doctrine.id.count'; /** - * Primary key alias for query + * Primary key alias for query. */ const PAGINATOR_ID_ALIAS = 'dpid'; /** - * Replaces the whereClause in the AST + * Replaces the whereClause in the AST. * * Generates a clause equivalent to WHERE IN (:dpid_1, :dpid_2, ...) * @@ -61,10 +61,13 @@ class WhereInWalker extends TreeWalkerAdapter * the PAGINATOR_ID_ALIAS * * The total number of parameters is retrieved from - * the HINT_PAGINATOR_ID_COUNT query hint + * the HINT_PAGINATOR_ID_COUNT query hint. + * + * @param SelectStatement $AST * - * @param SelectStatement $AST * @return void + * + * @throws \RuntimeException */ public function walkSelectStatement(SelectStatement $AST) { @@ -142,4 +145,3 @@ class WhereInWalker extends TreeWalkerAdapter } } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php old mode 100755 new mode 100644 index ac141407fa..e193ae2e3e --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -39,11 +39,12 @@ class ResolveTargetEntityListener private $resolveTargetEntities = array(); /** - * Add a target-entity class name to resolve to a new class name. + * Adds a target-entity class name to resolve to a new class name. * * @param string $originalEntity * @param string $newEntity - * @param array $mapping + * @param array $mapping + * * @return void */ public function addResolveTargetEntity($originalEntity, $newEntity, array $mapping) @@ -53,14 +54,16 @@ class ResolveTargetEntityListener } /** - * Process event and resolve new target entity names. + * Processes event and resolves new target entity names. * * @param LoadClassMetadataEventArgs $args + * * @return void */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $cm = $args->getClassMetadata(); + foreach ($cm->associationMappings as $mapping) { if (isset($this->resolveTargetEntities[$mapping['targetEntity']])) { $this->remapAssociation($cm, $mapping); @@ -68,6 +71,12 @@ class ResolveTargetEntityListener } } + /** + * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $classMetadata + * @param array $mapping + * + * @return void + */ private function remapAssociation($classMetadata, $mapping) { $newMapping = $this->resolveTargetEntities[$mapping['targetEntity']]; @@ -92,4 +101,3 @@ class ResolveTargetEntityListener } } } - diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaTool.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaTool.php old mode 100755 new mode 100644 index 3dee05b8ca..21140f7a02 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -19,27 +19,30 @@ namespace Doctrine\ORM\Tools; -use Doctrine\ORM\ORMException, - Doctrine\DBAL\Types\Type, - Doctrine\DBAL\Schema\Schema, - Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets, - Doctrine\ORM\EntityManager, - Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Internal\CommitOrderCalculator, - Doctrine\ORM\Tools\Event\GenerateSchemaTableEventArgs, - Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; +use Doctrine\ORM\ORMException; +use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Schema\Comparator; +use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; +use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Internal\CommitOrderCalculator; +use Doctrine\ORM\Tools\Event\GenerateSchemaTableEventArgs; +use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; /** * The SchemaTool is a tool to create/drop/update database schemas based on * ClassMetadata class descriptors. * - * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel * @author Benjamin Eberlei + * @author Stefano Rodriguez */ class SchemaTool { @@ -76,9 +79,11 @@ class SchemaTool /** * Creates the database schema for the given array of ClassMetadata instances. * - * @throws ToolsException * @param array $classes + * * @return void + * + * @throws ToolsException */ public function createSchema(array $classes) { @@ -88,7 +93,7 @@ class SchemaTool foreach ($createSchemaSql as $sql) { try { $conn->executeQuery($sql); - } catch(\Exception $e) { + } catch (\Exception $e) { throw ToolsException::schemaToolFailure($sql, $e); } } @@ -99,7 +104,8 @@ class SchemaTool * the given list of ClassMetadata instances. * * @param array $classes - * @return array $sql The SQL statements needed to create the schema for the classes. + * + * @return array The SQL statements needed to create the schema for the classes. */ public function getCreateSchemaSql(array $classes) { @@ -108,10 +114,11 @@ class SchemaTool } /** - * Some instances of ClassMetadata don't need to be processed in the SchemaTool context. This method detects them. + * Detects instances of ClassMetadata that don't need to be processed in the SchemaTool context. * * @param ClassMetadata $class - * @param array $processedClasses + * @param array $processedClasses + * * @return bool */ private function processingNotRequired($class, array $processedClasses) @@ -124,10 +131,13 @@ class SchemaTool } /** - * From a given set of metadata classes this method creates a Schema instance. + * Creates a Schema instance from a given set of metadata classes. * * @param array $classes + * * @return Schema + * + * @throws \Doctrine\ORM\ORMException */ public function getSchemaFromMetadata(array $classes) { @@ -140,17 +150,20 @@ class SchemaTool $metadataSchemaConfig->setExplicitForeignKeyIndexes(false); $schema = new Schema(array(), array(), $metadataSchemaConfig); + $addedFks = array(); + $blacklistedFks = array(); + foreach ($classes as $class) { + /** @var \Doctrine\ORM\Mapping\ClassMetadata $class */ if ($this->processingNotRequired($class, $processedClasses)) { continue; } - $table = $schema->createTable($this->quoteStrategy->getTableName($class, $this->platform)); - $columns = array(); // table columns + $table = $schema->createTable($this->quoteStrategy->getTableName($class, $this->platform)); if ($class->isInheritanceTypeSingleTable()) { - $columns = $this->_gatherColumns($class, $table); - $this->_gatherRelationsSql($class, $table, $schema); + $this->gatherColumns($class, $table); + $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks); // Add the discriminator column $this->addDiscriminatorColumnDefinition($class, $table); @@ -163,17 +176,21 @@ class SchemaTool foreach ($class->subClasses as $subClassName) { $subClass = $this->em->getClassMetadata($subClassName); - $this->_gatherColumns($subClass, $table); - $this->_gatherRelationsSql($subClass, $table, $schema); + $this->gatherColumns($subClass, $table); + $this->gatherRelationsSql($subClass, $table, $schema, $addedFks, $blacklistedFks); $processedClasses[$subClassName] = true; } - } else if ($class->isInheritanceTypeJoined()) { + } elseif ($class->isInheritanceTypeJoined()) { // Add all non-inherited fields as columns $pkColumns = array(); foreach ($class->fieldMappings as $fieldName => $mapping) { if ( ! isset($mapping['inherited'])) { - $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); - $this->_gatherColumn($class, $mapping, $table); + $columnName = $this->quoteStrategy->getColumnName( + $mapping['fieldName'], + $class, + $this->platform + ); + $this->gatherColumn($class, $mapping, $table); if ($class->isIdentifier($fieldName)) { $pkColumns[] = $columnName; @@ -181,43 +198,59 @@ class SchemaTool } } - $this->_gatherRelationsSql($class, $table, $schema); + $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks); // Add the discriminator column only to the root table if ($class->name == $class->rootEntityName) { $this->addDiscriminatorColumnDefinition($class, $table); } else { // Add an ID FK column to child tables - /* @var \Doctrine\ORM\Mapping\ClassMetadata $class */ - $idMapping = $class->fieldMappings[$class->identifier[0]]; - $this->_gatherColumn($class, $idMapping, $table); - $columnName = $this->quoteStrategy->getColumnName($class->identifier[0], $class, $this->platform); - // TODO: This seems rather hackish, can we optimize it? - $table->getColumn($columnName)->setAutoincrement(false); + $inheritedKeyColumns = array(); + foreach ($class->identifier as $identifierField) { + $idMapping = $class->fieldMappings[$identifierField]; + if (isset($idMapping['inherited'])) { + $this->gatherColumn($class, $idMapping, $table); + $columnName = $this->quoteStrategy->getColumnName( + $identifierField, + $class, + $this->platform + ); + // TODO: This seems rather hackish, can we optimize it? + $table->getColumn($columnName)->setAutoincrement(false); - $pkColumns[] = $columnName; + $pkColumns[] = $columnName; + $inheritedKeyColumns[] = $columnName; + } + } + if (!empty($inheritedKeyColumns)) { + // Add a FK constraint on the ID column + $table->addForeignKeyConstraint( + $this->quoteStrategy->getTableName( + $this->em->getClassMetadata($class->rootEntityName), + $this->platform + ), + $inheritedKeyColumns, + $inheritedKeyColumns, + array('onDelete' => 'CASCADE') + ); + } - // Add a FK constraint on the ID column - $table->addUnnamedForeignKeyConstraint( - $this->quoteStrategy->getTableName($this->em->getClassMetadata($class->rootEntityName), $this->platform), - array($columnName), array($columnName), array('onDelete' => 'CASCADE') - ); } $table->setPrimaryKey($pkColumns); - } else if ($class->isInheritanceTypeTablePerClass()) { + } elseif ($class->isInheritanceTypeTablePerClass()) { throw ORMException::notSupported(); } else { - $this->_gatherColumns($class, $table); - $this->_gatherRelationsSql($class, $table, $schema); + $this->gatherColumns($class, $table); + $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks); } $pkColumns = array(); foreach ($class->identifier as $identifierField) { if (isset($class->fieldMappings[$identifierField])) { $pkColumns[] = $this->quoteStrategy->getColumnName($identifierField, $class, $this->platform); - } else if (isset($class->associationMappings[$identifierField])) { + } elseif (isset($class->associationMappings[$identifierField])) { /* @var $assoc \Doctrine\ORM\Mapping\OneToOne */ $assoc = $class->associationMappings[$identifierField]; foreach ($assoc['joinColumns'] as $joinColumn) { @@ -263,7 +296,10 @@ class SchemaTool } if ($eventManager->hasListeners(ToolEvents::postGenerateSchemaTable)) { - $eventManager->dispatchEvent(ToolEvents::postGenerateSchemaTable, new GenerateSchemaTableEventArgs($class, $schema, $table)); + $eventManager->dispatchEvent( + ToolEvents::postGenerateSchemaTable, + new GenerateSchemaTableEventArgs($class, $schema, $table) + ); } } @@ -272,7 +308,10 @@ class SchemaTool } if ($eventManager->hasListeners(ToolEvents::postGenerateSchema)) { - $eventManager->dispatchEvent(ToolEvents::postGenerateSchema, new GenerateSchemaEventArgs($this->em, $schema)); + $eventManager->dispatchEvent( + ToolEvents::postGenerateSchema, + new GenerateSchemaEventArgs($this->em, $schema) + ); } return $schema; @@ -283,14 +322,18 @@ class SchemaTool * column of a class. * * @param ClassMetadata $class + * @param Table $table + * * @return array The portable column definition of the discriminator column as required by - * the DBAL. + * the DBAL. */ - private function addDiscriminatorColumnDefinition($class, $table) + private function addDiscriminatorColumnDefinition($class, Table $table) { $discrColumn = $class->discriminatorColumn; - if ( ! isset($discrColumn['type']) || (strtolower($discrColumn['type']) == 'string' && $discrColumn['length'] === null)) { + if ( ! isset($discrColumn['type']) || + (strtolower($discrColumn['type']) == 'string' && $discrColumn['length'] === null) + ) { $discrColumn['type'] = 'string'; $discrColumn['length'] = 255; } @@ -312,20 +355,20 @@ class SchemaTool * found in the given class. * * @param ClassMetadata $class - * @param Table $table + * @param Table $table + * * @return array The list of portable column definitions as required by the DBAL. */ - private function _gatherColumns($class, $table) + private function gatherColumns($class, Table $table) { - $columns = array(); $pkColumns = array(); - foreach ($class->fieldMappings as $fieldName => $mapping) { + foreach ($class->fieldMappings as $mapping) { if ($class->isInheritanceTypeSingleTable() && isset($mapping['inherited'])) { continue; } - $column = $this->_gatherColumn($class, $mapping, $table); + $this->gatherColumn($class, $mapping, $table); if ($class->isIdentifier($mapping['fieldName'])) { $pkColumns[] = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); @@ -334,22 +377,21 @@ class SchemaTool // For now, this is a hack required for single table inheritence, since this method is called // twice by single table inheritence relations - if(!$table->hasIndex('primary')) { + if (!$table->hasIndex('primary')) { //$table->setPrimaryKey($pkColumns); } - - return $columns; } /** * Creates a column definition as required by the DBAL from an ORM field mapping definition. * - * @param ClassMetadata $class The class that owns the field mapping. - * @param array $mapping The field mapping. - * @param Table $table + * @param ClassMetadata $class The class that owns the field mapping. + * @param array $mapping The field mapping. + * @param Table $table + * * @return array The portable column definition as required by the DBAL. */ - private function _gatherColumn($class, array $mapping, $table) + private function gatherColumn($class, array $mapping, Table $table) { $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); $columnType = $mapping['type']; @@ -364,7 +406,7 @@ class SchemaTool $options['platformOptions'] = array(); $options['platformOptions']['version'] = $class->isVersioned && $class->versionField == $mapping['fieldName'] ? true : false; - if(strtolower($columnType) == 'string' && $options['length'] === null) { + if (strtolower($columnType) == 'string' && $options['length'] === null) { $options['length'] = 255; } @@ -423,13 +465,18 @@ class SchemaTool * This includes the SQL for foreign key constraints and join tables. * * @param ClassMetadata $class - * @param \Doctrine\DBAL\Schema\Table $table - * @param \Doctrine\DBAL\Schema\Schema $schema + * @param Table $table + * @param Schema $schema + * @param array $addedFks + * @param array $blacklistedFks + * * @return void + * + * @throws \Doctrine\ORM\ORMException */ - private function _gatherRelationsSql($class, $table, $schema) + private function gatherRelationsSql($class, $table, $schema, &$addedFks, &$blacklistedFks) { - foreach ($class->associationMappings as $fieldName => $mapping) { + foreach ($class->associationMappings as $mapping) { if (isset($mapping['inherited'])) { continue; } @@ -439,31 +486,60 @@ class SchemaTool if ($mapping['type'] & ClassMetadata::TO_ONE && $mapping['isOwningSide']) { $primaryKeyColumns = $uniqueConstraints = array(); // PK is unnecessary for this relation-type - $this->_gatherRelationJoinColumns($mapping['joinColumns'], $table, $foreignClass, $mapping, $primaryKeyColumns, $uniqueConstraints); + $this->gatherRelationJoinColumns( + $mapping['joinColumns'], + $table, + $foreignClass, + $mapping, + $primaryKeyColumns, + $uniqueConstraints, + $addedFks, + $blacklistedFks + ); - foreach($uniqueConstraints as $indexName => $unique) { + foreach ($uniqueConstraints as $indexName => $unique) { $table->addUniqueIndex($unique['columns'], is_numeric($indexName) ? null : $indexName); } - } else if ($mapping['type'] == ClassMetadata::ONE_TO_MANY && $mapping['isOwningSide']) { + } elseif ($mapping['type'] == ClassMetadata::ONE_TO_MANY && $mapping['isOwningSide']) { //... create join table, one-many through join table supported later throw ORMException::notSupported(); - } else if ($mapping['type'] == ClassMetadata::MANY_TO_MANY && $mapping['isOwningSide']) { + } elseif ($mapping['type'] == ClassMetadata::MANY_TO_MANY && $mapping['isOwningSide']) { // create join table $joinTable = $mapping['joinTable']; - $theJoinTable = $schema->createTable($this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform)); + $theJoinTable = $schema->createTable( + $this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform) + ); $primaryKeyColumns = $uniqueConstraints = array(); // Build first FK constraint (relation table => source table) - $this->_gatherRelationJoinColumns($joinTable['joinColumns'], $theJoinTable, $class, $mapping, $primaryKeyColumns, $uniqueConstraints); + $this->gatherRelationJoinColumns( + $joinTable['joinColumns'], + $theJoinTable, + $class, + $mapping, + $primaryKeyColumns, + $uniqueConstraints, + $addedFks, + $blacklistedFks + ); // Build second FK constraint (relation table => target table) - $this->_gatherRelationJoinColumns($joinTable['inverseJoinColumns'], $theJoinTable, $foreignClass, $mapping, $primaryKeyColumns, $uniqueConstraints); + $this->gatherRelationJoinColumns( + $joinTable['inverseJoinColumns'], + $theJoinTable, + $foreignClass, + $mapping, + $primaryKeyColumns, + $uniqueConstraints, + $addedFks, + $blacklistedFks + ); $theJoinTable->setPrimaryKey($primaryKeyColumns); - foreach($uniqueConstraints as $indexName => $unique) { + foreach ($uniqueConstraints as $indexName => $unique) { $theJoinTable->addUniqueIndex($unique['columns'], is_numeric($indexName) ? null : $indexName); } } @@ -471,17 +547,18 @@ class SchemaTool } /** - * Get the class metadata that is responsible for the definition of the referenced column name. + * Gets the class metadata that is responsible for the definition of the referenced column name. * * Previously this was a simple task, but with DDC-117 this problem is actually recursive. If its - * not a simple field, go through all identifier field names that are associations recursivly and + * not a simple field, go through all identifier field names that are associations recursively and * find that referenced column name. * * TODO: Is there any way to make this code more pleasing? * * @param ClassMetadata $class - * @param string $referencedColumnName - * @return array(ClassMetadata, referencedFieldName) + * @param string $referencedColumnName + * + * @return array (ClassMetadata, referencedFieldName) */ private function getDefiningClass($class, $referencedColumnName) { @@ -489,10 +566,13 @@ class SchemaTool if ($class->hasField($referencedFieldName)) { return array($class, $referencedFieldName); - } else if (in_array($referencedColumnName, $class->getIdentifierColumnNames())) { + } + + if (in_array($referencedColumnName, $class->getIdentifierColumnNames())) { // it seems to be an entity as foreign key foreach ($class->getIdentifierFieldNames() as $fieldName) { - if ($class->hasAssociation($fieldName) && $class->getSingleAssociationJoinColumnName($fieldName) == $referencedColumnName) { + if ($class->hasAssociation($fieldName) + && $class->getSingleAssociationJoinColumnName($fieldName) == $referencedColumnName) { return $this->getDefiningClass( $this->em->getClassMetadata($class->associationMappings[$fieldName]['targetEntity']), $class->getSingleAssociationReferencedJoinColumnName($fieldName) @@ -505,17 +585,31 @@ class SchemaTool } /** - * Gather columns and fk constraints that are required for one part of relationship. + * Gathers columns and fk constraints that are required for one part of relationship. * - * @param array $joinColumns - * @param \Doctrine\DBAL\Schema\Table $theJoinTable + * @param array $joinColumns + * @param Table $theJoinTable * @param ClassMetadata $class - * @param array $mapping - * @param array $primaryKeyColumns - * @param array $uniqueConstraints + * @param array $mapping + * @param array $primaryKeyColumns + * @param array $uniqueConstraints + * @param array $addedFks + * @param array $blacklistedFks + * + * @return void + * + * @throws \Doctrine\ORM\ORMException */ - private function _gatherRelationJoinColumns($joinColumns, $theJoinTable, $class, $mapping, &$primaryKeyColumns, &$uniqueConstraints) - { + private function gatherRelationJoinColumns( + $joinColumns, + $theJoinTable, + $class, + $mapping, + &$primaryKeyColumns, + &$uniqueConstraints, + &$addedFks, + &$blacklistedFks + ) { $localColumns = array(); $foreignColumns = array(); $fkOptions = array(); @@ -523,7 +617,10 @@ class SchemaTool foreach ($joinColumns as $joinColumn) { - list($definingClass, $referencedFieldName) = $this->getDefiningClass($class, $joinColumn['referencedColumnName']); + list($definingClass, $referencedFieldName) = $this->getDefiningClass( + $class, + $joinColumn['referencedColumnName'] + ); if ( ! $definingClass) { throw new \Doctrine\ORM\ORMException( @@ -533,7 +630,11 @@ class SchemaTool } $quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); - $quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $class, $this->platform); + $quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName( + $joinColumn, + $class, + $this->platform + ); $primaryKeyColumns[] = $quotedColumnName; $localColumns[] = $quotedColumnName; @@ -549,10 +650,12 @@ class SchemaTool $columnDef = null; if (isset($joinColumn['columnDefinition'])) { $columnDef = $joinColumn['columnDefinition']; - } else if (isset($fieldMapping['columnDefinition'])) { + } elseif (isset($fieldMapping['columnDefinition'])) { $columnDef = $fieldMapping['columnDefinition']; } + $columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef); + if (isset($joinColumn['nullable'])) { $columnOptions['notnull'] = !$joinColumn['nullable']; } @@ -563,7 +666,7 @@ class SchemaTool if ($fieldMapping['type'] == "string" && isset($fieldMapping['length'])) { $columnOptions['length'] = $fieldMapping['length']; - } else if ($fieldMapping['type'] == "decimal") { + } elseif ($fieldMapping['type'] == "decimal") { $columnOptions['scale'] = $fieldMapping['scale']; $columnOptions['precision'] = $fieldMapping['precision']; } @@ -580,18 +683,40 @@ class SchemaTool } } - $theJoinTable->addUnnamedForeignKeyConstraint( - $foreignTableName, $localColumns, $foreignColumns, $fkOptions - ); + $compositeName = $theJoinTable->getName().'.'.implode('', $localColumns); + if (isset($addedFks[$compositeName]) + && ($foreignTableName != $addedFks[$compositeName]['foreignTableName'] + || 0 < count(array_diff($foreignColumns, $addedFks[$compositeName]['foreignColumns']))) + ) { + foreach ($theJoinTable->getForeignKeys() as $fkName => $key) { + if (0 === count(array_diff($key->getLocalColumns(), $localColumns)) + && (($key->getForeignTableName() != $foreignTableName) + || 0 < count(array_diff($key->getForeignColumns(), $foreignColumns))) + ) { + $theJoinTable->removeForeignKey($fkName); + break; + } + } + $blacklistedFks[$compositeName] = true; + } elseif (!isset($blacklistedFks[$compositeName])) { + $addedFks[$compositeName] = array('foreignTableName' => $foreignTableName, 'foreignColumns' => $foreignColumns); + $theJoinTable->addUnnamedForeignKeyConstraint( + $foreignTableName, + $localColumns, + $foreignColumns, + $fkOptions + ); + } } /** * Drops the database schema for the given classes. * - * In any way when an exception is thrown it is supressed since drop was + * In any way when an exception is thrown it is suppressed since drop was * issued for all classes of the schema and some probably just don't exist. * * @param array $classes + * * @return void */ public function dropSchema(array $classes) @@ -602,7 +727,7 @@ class SchemaTool foreach ($dropSchemaSql as $sql) { try { $conn->executeQuery($sql); - } catch(\Exception $e) { + } catch (\Exception $e) { } } @@ -633,25 +758,27 @@ class SchemaTool $sm = $this->em->getConnection()->getSchemaManager(); $schema = $sm->createSchema(); - $visitor = new \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector($this->platform); - /* @var $schema \Doctrine\DBAL\Schema\Schema */ + $visitor = new DropSchemaSqlCollector($this->platform); $schema->visit($visitor); + return $visitor->getQueries(); } /** - * Get SQL to drop the tables defined by the passed classes. + * Gets SQL to drop the tables defined by the passed classes. * * @param array $classes + * * @return array */ public function getDropSchemaSQL(array $classes) { - $visitor = new \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector($this->platform); + $visitor = new DropSchemaSqlCollector($this->platform); $schema = $this->getSchemaFromMetadata($classes); $sm = $this->em->getConnection()->getSchemaManager(); $fullSchema = $sm->createSchema(); + foreach ($fullSchema->getTables() as $table) { if ( ! $schema->hasTable($table->getName())) { foreach ($table->getForeignKeys() as $foreignKey) { @@ -672,6 +799,7 @@ class SchemaTool foreach ($schema->getSequences() as $sequence) { $visitor->acceptSequence($sequence); } + foreach ($schema->getTables() as $table) { /* @var $sequence Table */ if ($table->hasPrimaryKey()) { @@ -694,11 +822,12 @@ class SchemaTool * instances to the current database schema that is inspected. If $saveMode is set * to true the command is executed in the Database, else SQL is returned. * - * @param array $classes + * @param array $classes * @param boolean $saveMode + * * @return void */ - public function updateSchema(array $classes, $saveMode=false) + public function updateSchema(array $classes, $saveMode = false) { $updateSchemaSql = $this->getUpdateSchemaSql($classes, $saveMode); $conn = $this->em->getConnection(); @@ -714,24 +843,25 @@ class SchemaTool * If $saveMode is set to true the command is executed in the Database, * else SQL is returned. * - * @param array $classes The classes to consider. - * @param boolean $saveMode True for writing to DB, false for SQL string + * @param array $classes The classes to consider. + * @param boolean $saveMode True for writing to DB, false for SQL string. + * * @return array The sequence of SQL statements. */ - public function getUpdateSchemaSql(array $classes, $saveMode=false) + public function getUpdateSchemaSql(array $classes, $saveMode = false) { $sm = $this->em->getConnection()->getSchemaManager(); $fromSchema = $sm->createSchema(); $toSchema = $this->getSchemaFromMetadata($classes); - $comparator = new \Doctrine\DBAL\Schema\Comparator(); + $comparator = new Comparator(); $schemaDiff = $comparator->compare($fromSchema, $toSchema); if ($saveMode) { return $schemaDiff->toSaveSql($this->platform); - } else { - return $schemaDiff->toSql($this->platform); } + + return $schemaDiff->toSql($this->platform); } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaValidator.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaValidator.php old mode 100755 new mode 100644 index 7a3f6f5808..889297ce85 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -78,9 +78,10 @@ class SchemaValidator } /** - * Validate a single class of the current + * Validates a single class of the current. * * @param ClassMetadataInfo $class + * * @return array */ public function validateClass(ClassMetadataInfo $class) @@ -111,24 +112,23 @@ class SchemaValidator "the target entity '". $targetMetadata->name . "' also maps an association as identifier."; } - /* @var $assoc AssociationMapping */ if ($assoc['mappedBy']) { if ($targetMetadata->hasField($assoc['mappedBy'])) { $ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the owning side ". - "field " . $assoc['targetEntity'] . "#" . $assoc['mappedBy'] . " which is not defined as association."; + "field " . $assoc['targetEntity'] . "#" . $assoc['mappedBy'] . " which is not defined as association, but as field."; } if (!$targetMetadata->hasAssociation($assoc['mappedBy'])) { $ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the owning side ". "field " . $assoc['targetEntity'] . "#" . $assoc['mappedBy'] . " which does not exist."; - } else if ($targetMetadata->associationMappings[$assoc['mappedBy']]['inversedBy'] == null) { + } elseif ($targetMetadata->associationMappings[$assoc['mappedBy']]['inversedBy'] == null) { $ce[] = "The field " . $class->name . "#" . $fieldName . " is on the inverse side of a ". "bi-directional relationship, but the specified mappedBy association on the target-entity ". $assoc['targetEntity'] . "#" . $assoc['mappedBy'] . " does not contain the required ". "'inversedBy=".$fieldName."' attribute."; - } else if ($targetMetadata->associationMappings[$assoc['mappedBy']]['inversedBy'] != $fieldName) { + } elseif ($targetMetadata->associationMappings[$assoc['mappedBy']]['inversedBy'] != $fieldName) { $ce[] = "The mappings " . $class->name . "#" . $fieldName . " and " . $assoc['targetEntity'] . "#" . $assoc['mappedBy'] . " are ". - "incosistent with each other."; + "inconsistent with each other."; } } @@ -137,18 +137,19 @@ class SchemaValidator $ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the inverse side ". "field " . $assoc['targetEntity'] . "#" . $assoc['inversedBy'] . " which is not defined as association."; } + if (!$targetMetadata->hasAssociation($assoc['inversedBy'])) { $ce[] = "The association " . $class->name . "#" . $fieldName . " refers to the inverse side ". "field " . $assoc['targetEntity'] . "#" . $assoc['inversedBy'] . " which does not exist."; - } else if ($targetMetadata->associationMappings[$assoc['inversedBy']]['mappedBy'] == null) { + } elseif ($targetMetadata->associationMappings[$assoc['inversedBy']]['mappedBy'] == null) { $ce[] = "The field " . $class->name . "#" . $fieldName . " is on the owning side of a ". "bi-directional relationship, but the specified mappedBy association on the target-entity ". $assoc['targetEntity'] . "#" . $assoc['mappedBy'] . " does not contain the required ". "'inversedBy' attribute."; - } else if ($targetMetadata->associationMappings[$assoc['inversedBy']]['mappedBy'] != $fieldName) { + } elseif ($targetMetadata->associationMappings[$assoc['inversedBy']]['mappedBy'] != $fieldName) { $ce[] = "The mappings " . $class->name . "#" . $fieldName . " and " . $assoc['targetEntity'] . "#" . $assoc['inversedBy'] . " are ". - "incosistent with each other."; + "inconsistent with each other."; } // Verify inverse side/owning side match each other @@ -157,10 +158,10 @@ class SchemaValidator if ($assoc['type'] == ClassMetadataInfo::ONE_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_ONE){ $ce[] = "If association " . $class->name . "#" . $fieldName . " is one-to-one, then the inversed " . "side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be one-to-one as well."; - } else if ($assoc['type'] == ClassMetadataInfo::MANY_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_MANY){ + } elseif ($assoc['type'] == ClassMetadataInfo::MANY_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_MANY){ $ce[] = "If association " . $class->name . "#" . $fieldName . " is many-to-one, then the inversed " . "side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be one-to-many."; - } else if ($assoc['type'] == ClassMetadataInfo::MANY_TO_MANY && $targetAssoc['type'] !== ClassMetadataInfo::MANY_TO_MANY){ + } elseif ($assoc['type'] == ClassMetadataInfo::MANY_TO_MANY && $targetAssoc['type'] !== ClassMetadataInfo::MANY_TO_MANY){ $ce[] = "If association " . $class->name . "#" . $fieldName . " is many-to-many, then the inversed " . "side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be many-to-many as well."; } @@ -201,7 +202,7 @@ class SchemaValidator "' are missing."; } - } else if ($assoc['type'] & ClassMetadataInfo::TO_ONE) { + } elseif ($assoc['type'] & ClassMetadataInfo::TO_ONE) { $identifierColumns = $targetMetadata->getIdentifierColumnNames(); foreach ($assoc['joinColumns'] as $joinColumn) { if (!in_array($joinColumn['referencedColumnName'], $identifierColumns)) { @@ -212,6 +213,7 @@ class SchemaValidator if (count($identifierColumns) != count($assoc['joinColumns'])) { $ids = array(); + foreach ($assoc['joinColumns'] as $joinColumn) { $ids[] = $joinColumn['name']; } @@ -238,6 +240,12 @@ class SchemaValidator if ($publicAttr->isStatic()) { continue; } + + if ( ! isset($class->fieldMappings[$publicAttr->getName()]) && + ! isset($class->associationMappings[$publicAttr->getName()])) { + continue; + } + $ce[] = "Field '".$publicAttr->getName()."' in class '".$class->name."' must be private ". "or protected. Public fields may break lazy-loading."; } @@ -253,29 +261,7 @@ class SchemaValidator } /** - * @param string $columnName - * @param ClassMetadataInfo $class - * @return bool - */ - private function columnExistsOnEntity($columnName, $class) - { - if (isset($class->fieldNames[$columnName])) { - return true; - } - foreach ($class->associationMappings as $assoc) { - if ($assoc['isOwningSide']) { - foreach ($assoc['joinColumns'] as $columnMapping) { - if ($columnMapping['name'] == $columnName) { - return true; - } - } - } - } - return false; - } - - /** - * Check if the Database Schema is in sync with the current metadata state. + * Checks if the Database Schema is in sync with the current metadata state. * * @return bool */ @@ -284,6 +270,7 @@ class SchemaValidator $schemaTool = new SchemaTool($this->em); $allMetadata = $this->em->getMetadataFactory()->getAllMetadata(); - return (count($schemaTool->getUpdateSchemaSql($allMetadata, true)) == 0); + + return count($schemaTool->getUpdateSchemaSql($allMetadata, true)) == 0; } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Setup.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Setup.php old mode 100755 new mode 100644 index fe4be7a6da..11992a96ee --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Setup.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Setup.php @@ -33,61 +33,15 @@ use Doctrine\ORM\Mapping\Driver\YamlDriver; */ class Setup { - /** - * Use this method to register all autoloaders for a setup where Doctrine is checked out from - * its github repository at {@link http://github.com/doctrine/doctrine2} - * - * @param string $gitCheckoutRootPath - * @return void - */ - static public function registerAutoloadGit($gitCheckoutRootPath) - { - if (!class_exists('Doctrine\Common\ClassLoader', false)) { - require_once $gitCheckoutRootPath . "/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php"; - } - - $loader = new ClassLoader("Doctrine\Common", $gitCheckoutRootPath . "/lib/vendor/doctrine-common/lib"); - $loader->register(); - - $loader = new ClassLoader("Doctrine\DBAL", $gitCheckoutRootPath . "/lib/vendor/doctrine-dbal/lib"); - $loader->register(); - - $loader = new ClassLoader("Doctrine\ORM", $gitCheckoutRootPath . "/lib"); - $loader->register(); - - $loader = new ClassLoader("Symfony\Component", $gitCheckoutRootPath . "/lib/vendor"); - $loader->register(); - } - - /** - * Use this method to register all autoloaders for a setup where Doctrine is installed - * though {@link http://pear.doctrine-project.org}. - * - * This method registers autoloaders for both Doctrine and Symfony top - * level namespaces. - * - * @return void - */ - static public function registerAutoloadPEAR() - { - if (!class_exists('Doctrine\Common\ClassLoader', false)) { - require_once "Doctrine/Common/ClassLoader.php"; - } - - $loader = new ClassLoader("Doctrine"); - $loader->register(); - - $loader = new ClassLoader("Symfony"); - $loader->register(); - } - /** * Use this method to register all autoloads for a downloaded Doctrine library. * Pick the directory the library was uncompressed into. * * @param string $directory + * + * @return void */ - static public function registerAutoloadDirectory($directory) + public static function registerAutoloadDirectory($directory) { if (!class_exists('Doctrine\Common\ClassLoader', false)) { require_once $directory . "/Doctrine/Common/ClassLoader.php"; @@ -101,76 +55,84 @@ class Setup } /** - * Create a configuration with an annotation metadata driver. + * Creates a configuration with an annotation metadata driver. * - * @param array $paths + * @param array $paths * @param boolean $isDevMode - * @param string $proxyDir - * @param Cache $cache - * @param bool $useSimpleAnnotationReader + * @param string $proxyDir + * @param Cache $cache + * @param bool $useSimpleAnnotationReader + * * @return Configuration */ - static public function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null, $useSimpleAnnotationReader = true) + public static function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null, $useSimpleAnnotationReader = true) { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths, $useSimpleAnnotationReader)); + return $config; } /** - * Create a configuration with a xml metadata driver. + * Creates a configuration with a xml metadata driver. * - * @param array $paths + * @param array $paths * @param boolean $isDevMode - * @param string $proxyDir - * @param Cache $cache + * @param string $proxyDir + * @param Cache $cache + * * @return Configuration */ - static public function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) + public static function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new XmlDriver($paths)); + return $config; } /** - * Create a configuration with a yaml metadata driver. + * Creates a configuration with a yaml metadata driver. * - * @param array $paths + * @param array $paths * @param boolean $isDevMode - * @param string $proxyDir - * @param Cache $cache + * @param string $proxyDir + * @param Cache $cache + * * @return Configuration */ - static public function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) + public static function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new YamlDriver($paths)); + return $config; } /** - * Create a configuration without a metadata driver. + * Creates a configuration without a metadata driver. * - * @param bool $isDevMode + * @param bool $isDevMode * @param string $proxyDir - * @param Cache $cache + * @param Cache $cache + * * @return Configuration */ - static public function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null) + public static function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null) { $proxyDir = $proxyDir ?: sys_get_temp_dir(); + if ($isDevMode === false && $cache === null) { if (extension_loaded('apc')) { $cache = new \Doctrine\Common\Cache\ApcCache(); - } else if (extension_loaded('xcache')) { + } elseif (extension_loaded('xcache')) { $cache = new \Doctrine\Common\Cache\XcacheCache(); - } else if (extension_loaded('memcache')) { + } elseif (extension_loaded('memcache')) { $memcache = new \Memcache(); $memcache->connect('127.0.0.1'); $cache = new \Doctrine\Common\Cache\MemcacheCache(); $cache->setMemcache($memcache); - } else if (extension_loaded('redis')) { + } elseif (extension_loaded('redis')) { $redis = new \Redis(); $redis->connect('127.0.0.1'); $cache = new \Doctrine\Common\Cache\RedisCache(); @@ -178,9 +140,10 @@ class Setup } else { $cache = new ArrayCache(); } - } else if ($cache === null) { + } elseif ($cache === null) { $cache = new ArrayCache(); } + $cache->setNamespace("dc2_" . md5($proxyDir) . "_"); // to avoid collisions $config = new Configuration(); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ToolEvents.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ToolEvents.php old mode 100755 new mode 100644 index 7aa98d9a61..aebb5d8f37 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ToolEvents.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ToolEvents.php @@ -23,7 +23,7 @@ class ToolEvents { /** * The postGenerateSchemaTable event occurs in SchemaTool#getSchemaFromMetadata() - * whenever an entity class is transformed into its table representation. It recieves + * whenever an entity class is transformed into its table representation. It receives * the current non-complete Schema instance, the Entity Metadata Class instance and * the Schema Table instance of this entity. * diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ToolsException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ToolsException.php old mode 100755 new mode 100644 index 30f7ea146f..0a46164049 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ToolsException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/ToolsException.php @@ -22,17 +22,28 @@ namespace Doctrine\ORM\Tools; use Doctrine\ORM\ORMException; /** - * Tools related Exceptions + * Tools related Exceptions. * * @author Benjamin Eberlei */ class ToolsException extends ORMException { + /** + * @param string $sql + * @param \Exception $e + * + * @return ToolsException + */ public static function schemaToolFailure($sql, \Exception $e) { return new self("Schema-Tool failed with Error '" . $e->getMessage() . "' while executing DDL: " . $sql, "0", $e); } + /** + * @param string $type + * + * @return ToolsException + */ public static function couldNotMapDoctrine1Type($type) { return new self("Could not map doctrine 1 type '$type'!"); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/TransactionRequiredException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/TransactionRequiredException.php old mode 100755 new mode 100644 index 3e04224fc7..2242e60fb7 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/TransactionRequiredException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/TransactionRequiredException.php @@ -30,6 +30,9 @@ namespace Doctrine\ORM; */ class TransactionRequiredException extends ORMException { + /** + * @return TransactionRequiredException + */ static public function transactionRequired() { return new self('An open transaction is required for this operation.'); diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/UnexpectedResultException.php b/vendor/doctrine/orm/lib/Doctrine/ORM/UnexpectedResultException.php old mode 100755 new mode 100644 index 5d6b6d179d..3cd561f096 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/UnexpectedResultException.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/UnexpectedResultException.php @@ -27,5 +27,4 @@ namespace Doctrine\ORM; */ class UnexpectedResultException extends ORMException { - } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php b/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php old mode 100755 new mode 100644 index e93773362d..0eb7c8fd89 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php @@ -19,15 +19,24 @@ namespace Doctrine\ORM; -use Exception, InvalidArgumentException, UnexpectedValueException, - Doctrine\Common\Collections\ArrayCollection, - Doctrine\Common\Collections\Collection, - Doctrine\Common\NotifyPropertyChanged, - Doctrine\Common\PropertyChangedListener, - Doctrine\Common\Persistence\ObjectManagerAware, - Doctrine\ORM\Event\LifecycleEventArgs, - Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Proxy\Proxy; +use Exception; +use InvalidArgumentException; +use UnexpectedValueException; + +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; +use Doctrine\Common\NotifyPropertyChanged; +use Doctrine\Common\PropertyChangedListener; +use Doctrine\Common\Persistence\ObjectManagerAware; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Proxy\Proxy; + +use Doctrine\ORM\Event\LifecycleEventArgs; +use Doctrine\ORM\Event\PreUpdateEventArgs; +use Doctrine\ORM\Event\PreFlushEventArgs; +use Doctrine\ORM\Event\OnFlushEventArgs; +use Doctrine\ORM\Event\PostFlushEventArgs; +use Doctrine\ORM\Event\ListenersInvoker; /** * The UnitOfWork is responsible for tracking changes to objects during an @@ -217,6 +226,13 @@ class UnitOfWork implements PropertyChangedListener */ private $evm; + /** + * The ListenersInvoker used for dispatching events. + * + * @var \Doctrine\ORM\Event\ListenersInvoker + */ + private $listenersInvoker; + /** * Orphaned entities that are scheduled for removal. * @@ -245,8 +261,9 @@ class UnitOfWork implements PropertyChangedListener */ public function __construct(EntityManager $em) { - $this->em = $em; - $this->evm = $em->getEventManager(); + $this->em = $em; + $this->evm = $em->getEventManager(); + $this->listenersInvoker = new ListenersInvoker($em); } /** @@ -264,15 +281,15 @@ class UnitOfWork implements PropertyChangedListener * * @param null|object|array $entity * - * @throws \Exception - * * @return void + * + * @throws \Exception */ public function commit($entity = null) { // Raise preFlush if ($this->evm->hasListeners(Events::preFlush)) { - $this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->em)); + $this->evm->dispatchEvent(Events::preFlush, new PreFlushEventArgs($this->em)); } // Compute changes done since last commit. @@ -292,6 +309,9 @@ class UnitOfWork implements PropertyChangedListener $this->collectionUpdates || $this->collectionDeletions || $this->orphanRemovals)) { + $this->dispatchOnFlushEvent(); + $this->dispatchPostFlushEvent(); + return; // Nothing to do. } @@ -301,10 +321,7 @@ class UnitOfWork implements PropertyChangedListener } } - // Raise onFlush - if ($this->evm->hasListeners(Events::onFlush)) { - $this->evm->dispatchEvent(Events::onFlush, new Event\OnFlushEventArgs($this->em)); - } + $this->dispatchOnFlushEvent(); // Now we need a commit order to maintain referential integrity $commitOrder = $this->getCommitOrder(); @@ -359,10 +376,7 @@ class UnitOfWork implements PropertyChangedListener $coll->takeSnapshot(); } - // Raise postFlush - if ($this->evm->hasListeners(Events::postFlush)) { - $this->evm->dispatchEvent(Events::postFlush, new Event\PostFlushEventArgs($this->em)); - } + $this->dispatchPostFlushEvent(); // Clear up $this->entityInsertions = @@ -378,7 +392,7 @@ class UnitOfWork implements PropertyChangedListener } /** - * Compute the changesets of all entities scheduled for insertion + * Computes the changesets of all entities scheduled for insertion. * * @return void */ @@ -392,18 +406,18 @@ class UnitOfWork implements PropertyChangedListener } /** - * Only flush the given entity according to a ruleset that keeps the UoW consistent. + * Only flushes the given entity according to a ruleset that keeps the UoW consistent. * * 1. All entities scheduled for insertion, (orphan) removals and changes in collections are processed as well! * 2. Read Only entities are skipped. * 3. Proxies are skipped. * 4. Only if entity is properly managed. * - * @param object $entity - * - * @throws \InvalidArgumentException + * @param object $entity * * @return void + * + * @throws \InvalidArgumentException */ private function computeSingleEntityChangeSet($entity) { @@ -496,9 +510,13 @@ class UnitOfWork implements PropertyChangedListener * then this collection is marked for deletion. * * @ignore + * * @internal Don't call from the outside. + * * @param ClassMetadata $class The class descriptor of the entity. * @param object $entity The entity for which to compute the changes. + * + * @return void */ public function computeChangeSet(ClassMetadata $class, $entity) { @@ -512,9 +530,10 @@ class UnitOfWork implements PropertyChangedListener $class = $this->em->getClassMetadata(get_class($entity)); } - // Fire PreFlush lifecycle callbacks - if (isset($class->lifecycleCallbacks[Events::preFlush])) { - $class->invokeLifecycleCallbacks(Events::preFlush, $entity); + $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preFlush); + + if ($invoke !== ListenersInvoker::INVOKE_NONE) { + $this->listenersInvoker->invoke($class, Events::preFlush, $entity, new PreFlushEventArgs($this->em), $invoke); } $actualData = array(); @@ -587,7 +606,7 @@ class UnitOfWork implements PropertyChangedListener $orgValue = $originalData[$propName]; - // skip if value havent changed + // skip if value haven't changed if ($orgValue === $actualValue) { continue; } @@ -675,6 +694,8 @@ class UnitOfWork implements PropertyChangedListener * Computes all the changes that have been done to entities and collections * since the last commit and stores these changes in the _entityChangeSet map * temporarily for access by the persisters, until the UoW commit is finished. + * + * @return void */ public function computeChangeSets() { @@ -802,19 +823,18 @@ class UnitOfWork implements PropertyChangedListener } /** - * @param ClassMetadata $class - * @param object $entity + * @param \Doctrine\ORM\Mapping\ClassMetadata $class + * @param object $entity + * + * @return void */ private function persistNew($class, $entity) { - $oid = spl_object_hash($entity); + $oid = spl_object_hash($entity); + $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::prePersist); - if (isset($class->lifecycleCallbacks[Events::prePersist])) { - $class->invokeLifecycleCallbacks(Events::prePersist, $entity); - } - - if ($this->evm->hasListeners(Events::prePersist)) { - $this->evm->dispatchEvent(Events::prePersist, new LifecycleEventArgs($entity, $this->em)); + if ($invoke !== ListenersInvoker::INVOKE_NONE) { + $this->listenersInvoker->invoke($class, Events::prePersist, $entity, new LifecycleEventArgs($entity, $this->em), $invoke); } $idGen = $class->idGenerator; @@ -846,8 +866,11 @@ class UnitOfWork implements PropertyChangedListener * whereby changes detected in this method prevail. * * @ignore - * @param ClassMetadata $class The class descriptor of the entity. - * @param object $entity The entity for which to (re)calculate the change set. + * + * @param ClassMetadata $class The class descriptor of the entity. + * @param object $entity The entity for which to (re)calculate the change set. + * + * @return void * * @throws ORMInvalidArgumentException If the passed entity is not MANAGED. */ @@ -902,15 +925,15 @@ class UnitOfWork implements PropertyChangedListener * Executes all entity insertions for entities of the specified type. * * @param \Doctrine\ORM\Mapping\ClassMetadata $class + * + * @return void */ private function executeInserts($class) { - $className = $class->name; - $persister = $this->getEntityPersister($className); - $entities = array(); - - $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]); - $hasListeners = $this->evm->hasListeners(Events::postPersist); + $entities = array(); + $className = $class->name; + $persister = $this->getEntityPersister($className); + $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postPersist); foreach ($this->entityInsertions as $oid => $entity) { if ($this->em->getClassMetadata(get_class($entity))->name !== $className) { @@ -921,7 +944,7 @@ class UnitOfWork implements PropertyChangedListener unset($this->entityInsertions[$oid]); - if ($hasLifecycleCallbacks || $hasListeners) { + if ($invoke !== ListenersInvoker::INVOKE_NONE) { $entities[] = $entity; } } @@ -945,13 +968,7 @@ class UnitOfWork implements PropertyChangedListener } foreach ($entities as $entity) { - if ($hasLifecycleCallbacks) { - $class->invokeLifecycleCallbacks(Events::postPersist, $entity); - } - - if ($hasListeners) { - $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entity, $this->em)); - } + $this->listenersInvoker->invoke($class, Events::postPersist, $entity, new LifecycleEventArgs($entity, $this->em), $invoke); } } @@ -959,48 +976,34 @@ class UnitOfWork implements PropertyChangedListener * Executes all entity updates for entities of the specified type. * * @param \Doctrine\ORM\Mapping\ClassMetadata $class + * + * @return void */ private function executeUpdates($class) { - $className = $class->name; - $persister = $this->getEntityPersister($className); - - $hasPreUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::preUpdate]); - $hasPreUpdateListeners = $this->evm->hasListeners(Events::preUpdate); - - $hasPostUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postUpdate]); - $hasPostUpdateListeners = $this->evm->hasListeners(Events::postUpdate); + $className = $class->name; + $persister = $this->getEntityPersister($className); + $preUpdateInvoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preUpdate); + $postUpdateInvoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postUpdate); foreach ($this->entityUpdates as $oid => $entity) { if ($this->em->getClassMetadata(get_class($entity))->name !== $className) { continue; } - if ($hasPreUpdateLifecycleCallbacks) { - $class->invokeLifecycleCallbacks(Events::preUpdate, $entity); - + if ($preUpdateInvoke != ListenersInvoker::INVOKE_NONE) { + $this->listenersInvoker->invoke($class, Events::preUpdate, $entity, new PreUpdateEventArgs($entity, $this->em, $this->entityChangeSets[$oid]), $preUpdateInvoke); $this->recomputeSingleEntityChangeSet($class, $entity); } - if ($hasPreUpdateListeners) { - $this->evm->dispatchEvent( - Events::preUpdate, - new Event\PreUpdateEventArgs($entity, $this->em, $this->entityChangeSets[$oid]) - ); - } - - if (!empty($this->entityChangeSets[$oid])) { + if ( ! empty($this->entityChangeSets[$oid])) { $persister->update($entity); } unset($this->entityUpdates[$oid]); - if ($hasPostUpdateLifecycleCallbacks) { - $class->invokeLifecycleCallbacks(Events::postUpdate, $entity); - } - - if ($hasPostUpdateListeners) { - $this->evm->dispatchEvent(Events::postUpdate, new LifecycleEventArgs($entity, $this->em)); + if ($postUpdateInvoke != ListenersInvoker::INVOKE_NONE) { + $this->listenersInvoker->invoke($class, Events::postUpdate, $entity, new LifecycleEventArgs($entity, $this->em), $postUpdateInvoke); } } } @@ -1009,14 +1012,14 @@ class UnitOfWork implements PropertyChangedListener * Executes all entity deletions for entities of the specified type. * * @param \Doctrine\ORM\Mapping\ClassMetadata $class + * + * @return void */ private function executeDeletions($class) { - $className = $class->name; - $persister = $this->getEntityPersister($className); - - $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postRemove]); - $hasListeners = $this->evm->hasListeners(Events::postRemove); + $className = $class->name; + $persister = $this->getEntityPersister($className); + $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postRemove); foreach ($this->entityDeletions as $oid => $entity) { if ($this->em->getClassMetadata(get_class($entity))->name !== $className) { @@ -1039,12 +1042,8 @@ class UnitOfWork implements PropertyChangedListener $class->reflFields[$class->identifier[0]]->setValue($entity, null); } - if ($hasLifecycleCallbacks) { - $class->invokeLifecycleCallbacks(Events::postRemove, $entity); - } - - if ($hasListeners) { - $this->evm->dispatchEvent(Events::postRemove, new LifecycleEventArgs($entity, $this->em)); + if ($invoke !== ListenersInvoker::INVOKE_NONE) { + $this->listenersInvoker->invoke($class, Events::postRemove, $entity, new LifecycleEventArgs($entity, $this->em), $invoke); } } } @@ -1052,7 +1051,7 @@ class UnitOfWork implements PropertyChangedListener /** * Gets the commit order. * - * @param array $entityChangeSet + * @param array|null $entityChangeSet * * @return array */ @@ -1065,7 +1064,7 @@ class UnitOfWork implements PropertyChangedListener $calc = $this->getCommitOrderCalculator(); // See if there are any new classes in the changeset, that are not in the - // commit order graph yet (dont have a node). + // commit order graph yet (don't have a node). // We have to inspect changeSet to be able to correctly build dependencies. // It is not possible to use IdentityMap here because post inserted ids // are not yet available. @@ -1129,6 +1128,8 @@ class UnitOfWork implements PropertyChangedListener * * @param object $entity The entity to schedule for insertion. * + * @return void + * * @throws ORMInvalidArgumentException * @throws \InvalidArgumentException */ @@ -1179,6 +1180,8 @@ class UnitOfWork implements PropertyChangedListener * * @param object $entity The entity to schedule for being updated. * + * @return void + * * @throws ORMInvalidArgumentException */ public function scheduleForUpdate($entity) @@ -1206,8 +1209,11 @@ class UnitOfWork implements PropertyChangedListener * Extra updates for entities are stored as (entity, changeset) tuples. * * @ignore - * @param object $entity The entity for which to schedule an extra update. - * @param array $changeset The changeset of the entity (what to update). + * + * @param object $entity The entity for which to schedule an extra update. + * @param array $changeset The changeset of the entity (what to update). + * + * @return void */ public function scheduleExtraUpdate($entity, array $changeset) { @@ -1237,7 +1243,6 @@ class UnitOfWork implements PropertyChangedListener return isset($this->entityUpdates[spl_object_hash($entity)]); } - /** * Checks whether an entity is registered to be checked in the unit of work. * @@ -1257,6 +1262,8 @@ class UnitOfWork implements PropertyChangedListener * Schedules an entity for deletion. * * @param object $entity + * + * @return void */ public function scheduleForDelete($entity) { @@ -1304,7 +1311,7 @@ class UnitOfWork implements PropertyChangedListener /** * Checks whether an entity is scheduled for insertion, update or deletion. * - * @param $entity + * @param object $entity * * @return boolean */ @@ -1324,12 +1331,13 @@ class UnitOfWork implements PropertyChangedListener * the root entity. * * @ignore + * * @param object $entity The entity to register. * - * @throws ORMInvalidArgumentException + * @return boolean TRUE if the registration was successful, FALSE if the identity of + * the entity in question is already managed. * - * @return boolean TRUE if the registration was successful, FALSE if the identity of - * the entity in question is already managed. + * @throws ORMInvalidArgumentException */ public function addToIdentityMap($entity) { @@ -1354,11 +1362,11 @@ class UnitOfWork implements PropertyChangedListener /** * Gets the state of an entity with regard to the current unit of work. * - * @param object $entity - * @param integer $assume The state to assume if the state is not yet known (not MANAGED or REMOVED). - * This parameter can be set to improve performance of entity state detection - * by potentially avoiding a database lookup if the distinction between NEW and DETACHED - * is either known or does not matter for the caller of the method. + * @param object $entity + * @param int|null $assume The state to assume if the state is not yet known (not MANAGED or REMOVED). + * This parameter can be set to improve performance of entity state detection + * by potentially avoiding a database lookup if the distinction between NEW and DETACHED + * is either known or does not matter for the caller of the method. * * @return int The entity state. */ @@ -1438,11 +1446,12 @@ class UnitOfWork implements PropertyChangedListener * entity from the persistence management of Doctrine. * * @ignore + * * @param object $entity * - * @throws ORMInvalidArgumentException - * * @return boolean + * + * @throws ORMInvalidArgumentException */ public function removeFromIdentityMap($entity) { @@ -1473,6 +1482,7 @@ class UnitOfWork implements PropertyChangedListener * Gets an entity in the identity map by its identifier hash. * * @ignore + * * @param string $idHash * @param string $rootClassName * @@ -1489,10 +1499,11 @@ class UnitOfWork implements PropertyChangedListener * the given hash, FALSE is returned. * * @ignore + * * @param string $idHash * @param string $rootClassName * - * @return mixed The found entity or FALSE. + * @return object|bool The found entity or FALSE. */ public function tryGetByIdHash($idHash, $rootClassName) { @@ -1533,6 +1544,7 @@ class UnitOfWork implements PropertyChangedListener * Checks whether an identifier hash exists in the identity map. * * @ignore + * * @param string $idHash * @param string $rootClassName * @@ -1547,6 +1559,8 @@ class UnitOfWork implements PropertyChangedListener * Persists an entity as part of the current unit of work. * * @param object $entity The entity to persist. + * + * @return void */ public function persist($entity) { @@ -1561,8 +1575,10 @@ class UnitOfWork implements PropertyChangedListener * This method is internally called during persist() cascades as it tracks * the already visited entities to prevent infinite recursions. * - * @param object $entity The entity to persist. - * @param array $visited The already visited entities. + * @param object $entity The entity to persist. + * @param array $visited The already visited entities. + * + * @return void * * @throws ORMInvalidArgumentException * @throws UnexpectedValueException @@ -1619,6 +1635,8 @@ class UnitOfWork implements PropertyChangedListener * Deletes an entity as part of the current unit of work. * * @param object $entity The entity to remove. + * + * @return void */ public function remove($entity) { @@ -1633,8 +1651,10 @@ class UnitOfWork implements PropertyChangedListener * This method is internally called during delete() cascades as it tracks * the already visited entities to prevent infinite recursions. * - * @param object $entity The entity to delete. - * @param array $visited The map of the already visited entities. + * @param object $entity The entity to delete. + * @param array $visited The map of the already visited entities. + * + * @return void * * @throws ORMInvalidArgumentException If the instance is a detached entity. * @throws UnexpectedValueException @@ -1663,12 +1683,10 @@ class UnitOfWork implements PropertyChangedListener break; case self::STATE_MANAGED: - if (isset($class->lifecycleCallbacks[Events::preRemove])) { - $class->invokeLifecycleCallbacks(Events::preRemove, $entity); - } + $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preRemove); - if ($this->evm->hasListeners(Events::preRemove)) { - $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($entity, $this->em)); + if ($invoke !== ListenersInvoker::INVOKE_NONE) { + $this->listenersInvoker->invoke($class, Events::preRemove, $entity, new LifecycleEventArgs($entity, $this->em), $invoke); } $this->scheduleForDelete($entity); @@ -1687,11 +1705,11 @@ class UnitOfWork implements PropertyChangedListener * * @param object $entity * + * @return object The managed copy of the entity. + * * @throws OptimisticLockException If the entity uses optimistic locking through a version * attribute and the version check against the managed copy fails. * - * @return object The managed copy of the entity. - * * @todo Require active transaction!? OptimisticLockException may result in undefined state!? */ public function merge($entity) @@ -1727,17 +1745,17 @@ class UnitOfWork implements PropertyChangedListener /** * Executes a merge operation on an entity. * - * @param object $entity - * @param array $visited - * @param object $prevManagedCopy - * @param array $assoc + * @param object $entity + * @param array $visited + * @param object|null $prevManagedCopy + * @param array|null $assoc + * + * @return object The managed copy of the entity. * * @throws OptimisticLockException If the entity uses optimistic locking through a version * attribute and the version check against the managed copy fails. * @throws ORMInvalidArgumentException If the entity instance is NEW. * @throws EntityNotFoundException - * - * @return object The managed copy of the entity. */ private function doMerge($entity, array &$visited, $prevManagedCopy = null, $assoc = null) { @@ -1758,7 +1776,8 @@ class UnitOfWork implements PropertyChangedListener $managedCopy = $entity; if ($this->getEntityState($entity, self::STATE_DETACHED) !== self::STATE_MANAGED) { - if ($entity instanceof Proxy && ! $entity->__isInitialized__) { + if ($entity instanceof Proxy && ! $entity->__isInitialized()) { + $this->em->getProxyFactory()->resetUninitializedProxy($entity); $entity->__load(); } @@ -1806,12 +1825,13 @@ class UnitOfWork implements PropertyChangedListener } if ($class->isVersioned) { - $managedCopyVersion = $class->reflFields[$class->versionField]->getValue($managedCopy); - $entityVersion = $class->reflFields[$class->versionField]->getValue($entity); + $reflField = $class->reflFields[$class->versionField]; + $managedCopyVersion = $reflField->getValue($managedCopy); + $entityVersion = $reflField->getValue($entity); - // Throw exception if versions dont match. + // Throw exception if versions don't match. if ($managedCopyVersion != $entityVersion) { - throw OptimisticLockException::lockFailedVersionMissmatch($entity, $entityVersion, $managedCopyVersion); + throw OptimisticLockException::lockFailedVersionMismatch($entity, $entityVersion, $managedCopyVersion); } } @@ -1920,6 +1940,8 @@ class UnitOfWork implements PropertyChangedListener * no longer be managed by Doctrine. * * @param object $entity The entity to detach. + * + * @return void */ public function detach($entity) { @@ -1931,9 +1953,11 @@ class UnitOfWork implements PropertyChangedListener /** * Executes a detach operation on the given entity. * - * @param object $entity - * @param array $visited - * @param boolean $noCascade if true, don't cascade detach operation + * @param object $entity + * @param array $visited + * @param boolean $noCascade if true, don't cascade detach operation. + * + * @return void */ private function doDetach($entity, array &$visited, $noCascade = false) { @@ -1976,6 +2000,8 @@ class UnitOfWork implements PropertyChangedListener * * @param object $entity The entity to refresh. * + * @return void + * * @throws InvalidArgumentException If the entity is not MANAGED. */ public function refresh($entity) @@ -1988,8 +2014,10 @@ class UnitOfWork implements PropertyChangedListener /** * Executes a refresh operation on an entity. * - * @param object $entity The entity to refresh. - * @param array $visited The already visited entities during cascades. + * @param object $entity The entity to refresh. + * @param array $visited The already visited entities during cascades. + * + * @return void * * @throws ORMInvalidArgumentException If the entity is not MANAGED. */ @@ -2021,7 +2049,9 @@ class UnitOfWork implements PropertyChangedListener * Cascades a refresh operation to associated entities. * * @param object $entity - * @param array $visited + * @param array $visited + * + * @return void */ private function cascadeRefresh($entity, array &$visited) { @@ -2062,7 +2092,9 @@ class UnitOfWork implements PropertyChangedListener * Cascades a detach operation to associated entities. * * @param object $entity - * @param array $visited + * @param array $visited + * + * @return void */ private function cascadeDetach($entity, array &$visited) { @@ -2104,7 +2136,9 @@ class UnitOfWork implements PropertyChangedListener * * @param object $entity * @param object $managedCopy - * @param array $visited + * @param array $visited + * + * @return void */ private function cascadeMerge($entity, $managedCopy, array &$visited) { @@ -2141,7 +2175,7 @@ class UnitOfWork implements PropertyChangedListener * Cascades the save operation to associated entities. * * @param object $entity - * @param array $visited + * @param array $visited * * @return void */ @@ -2184,7 +2218,9 @@ class UnitOfWork implements PropertyChangedListener * Cascades the delete operation to associated entities. * * @param object $entity - * @param array $visited + * @param array $visited + * + * @return void */ private function cascadeRemove($entity, array &$visited) { @@ -2225,14 +2261,14 @@ class UnitOfWork implements PropertyChangedListener * Acquire a lock on the given entity. * * @param object $entity - * @param int $lockMode - * @param int $lockVersion + * @param int $lockMode + * @param int $lockVersion + * + * @return void * * @throws ORMInvalidArgumentException * @throws TransactionRequiredException * @throws OptimisticLockException - * - * @return void */ public function lock($entity, $lockMode, $lockVersion = null) { @@ -2259,7 +2295,7 @@ class UnitOfWork implements PropertyChangedListener $entityVersion = $class->reflFields[$class->versionField]->getValue($entity); if ($entityVersion != $lockVersion) { - throw OptimisticLockException::lockFailedVersionMissmatch($entity, $lockVersion, $entityVersion); + throw OptimisticLockException::lockFailedVersionMismatch($entity, $lockVersion, $entityVersion); } break; @@ -2300,7 +2336,9 @@ class UnitOfWork implements PropertyChangedListener /** * Clears the UnitOfWork. * - * @param string $entityName if given, only entities of this type will get detached + * @param string|null $entityName if given, only entities of this type will get detached. + * + * @return void */ public function clear($entityName = null) { @@ -2318,6 +2356,7 @@ class UnitOfWork implements PropertyChangedListener $this->collectionUpdates = $this->extraUpdates = $this->readOnlyObjects = + $this->visitedCollections = $this->orphanRemovals = array(); if ($this->commitOrderCalculator !== null) { @@ -2346,7 +2385,10 @@ class UnitOfWork implements PropertyChangedListener * UnitOfWork. * * @ignore + * * @param object $entity + * + * @return void */ public function scheduleOrphanRemoval($entity) { @@ -2358,6 +2400,8 @@ class UnitOfWork implements PropertyChangedListener * Schedules a complete collection for removal when this UnitOfWork commits. * * @param PersistentCollection $coll + * + * @return void */ public function scheduleCollectionDeletion(PersistentCollection $coll) { @@ -2403,11 +2447,13 @@ class UnitOfWork implements PropertyChangedListener * Creates an entity. Used for reconstitution of persistent entities. * * @ignore + * * @param string $className The name of the entity class. - * @param array $data The data for the entity. - * @param array $hints Any hints to account for during reconstitution/lookup of the entity. + * @param array $data The data for the entity. + * @param array $hints Any hints to account for during reconstitution/lookup of the entity. * * @return object The managed entity instance. + * * @internal Highly performance-sensitive method. * * @todo Rename: getOrCreateEntity @@ -2439,8 +2485,27 @@ class UnitOfWork implements PropertyChangedListener $entity = $this->identityMap[$class->rootEntityName][$idHash]; $oid = spl_object_hash($entity); - if ($entity instanceof Proxy && ! $entity->__isInitialized__) { - $entity->__isInitialized__ = true; + if ( + isset($hints[Query::HINT_REFRESH]) + && isset($hints[Query::HINT_REFRESH_ENTITY]) + && ($unmanagedProxy = $hints[Query::HINT_REFRESH_ENTITY]) !== $entity + && $unmanagedProxy instanceof Proxy + && (($unmanagedProxyClass = $this->em->getClassMetadata(get_class($unmanagedProxy))) === $class) + ) { + // DDC-1238 - we have a managed instance, but it isn't the provided one. + // Therefore we clear its identifier. Also, we must re-fetch metadata since the + // refreshed object may be anything + + foreach ($unmanagedProxyClass->identifier as $fieldName) { + $unmanagedProxyClass->reflFields[$fieldName]->setValue($unmanagedProxy, null); + } + + return $unmanagedProxy; + } + + if ($entity instanceof Proxy && ! $entity->__isInitialized()) { + $entity->__setInitialized(true); + $overrideLocalValues = true; if ($entity instanceof NotifyPropertyChanged) { @@ -2609,7 +2674,10 @@ class UnitOfWork implements PropertyChangedListener $this->entityIdentifiers[$newValueOid] = $associatedId; $this->identityMap[$targetClass->rootEntityName][$relatedIdHash] = $newValue; - if ($newValue instanceof NotifyPropertyChanged) { + if ( + $newValue instanceof NotifyPropertyChanged && + ( ! $newValue instanceof Proxy || $newValue->__isInitialized()) + ) { $newValue->addPropertyChangedListener($this); } $this->entityStates[$newValueOid] = self::STATE_MANAGED; @@ -2647,13 +2715,10 @@ class UnitOfWork implements PropertyChangedListener } if ($overrideLocalValues) { - if (isset($class->lifecycleCallbacks[Events::postLoad])) { - $class->invokeLifecycleCallbacks(Events::postLoad, $entity); - } + $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postLoad); - - if ($this->evm->hasListeners(Events::postLoad)) { - $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($entity, $this->em)); + if ($invoke !== ListenersInvoker::INVOKE_NONE) { + $this->listenersInvoker->invoke($class, Events::postLoad, $entity, new LifecycleEventArgs($entity, $this->em), $invoke); } } @@ -2692,6 +2757,7 @@ class UnitOfWork implements PropertyChangedListener * @param \Doctrine\ORM\PersistentCollection $collection The collection to initialize. * * @return void + * * @todo Maybe later move to EntityManager#initialize($proxyOrCollection). See DDC-733. */ public function loadCollection(PersistentCollection $collection) @@ -2708,6 +2774,8 @@ class UnitOfWork implements PropertyChangedListener $persister->loadManyToManyCollection($assoc, $collection->getOwner(), $collection); break; } + + $collection->setInitialized(true); } /** @@ -2741,6 +2809,11 @@ class UnitOfWork implements PropertyChangedListener /** * @ignore + * + * @param object $entity + * @param array $data + * + * @return void */ public function setOriginalEntityData($entity, array $data) { @@ -2752,9 +2825,12 @@ class UnitOfWork implements PropertyChangedListener * Sets a property value of the original data array of an entity. * * @ignore + * * @param string $oid * @param string $property - * @param mixed $value + * @param mixed $value + * + * @return void */ public function setOriginalEntityProperty($oid, $property, $value) { @@ -2776,15 +2852,39 @@ class UnitOfWork implements PropertyChangedListener return $this->entityIdentifiers[spl_object_hash($entity)]; } + /** + * Processes an entity instance to extract their identifier values. + * + * @param object $entity The entity instance. + * + * @return mixed A scalar value. + * + * @throws \Doctrine\ORM\ORMInvalidArgumentException + */ + public function getSingleIdentifierValue($entity) + { + $class = $this->em->getClassMetadata(get_class($entity)); + + if ($class->isIdentifierComposite) { + throw ORMInvalidArgumentException::invalidCompositeIdentifier(); + } + + $values = $this->isInIdentityMap($entity) + ? $this->getEntityIdentifier($entity) + : $class->getIdentifierValues($entity); + + return isset($values[$class->identifier[0]]) ? $values[$class->identifier[0]] : null; + } + /** * Tries to find an entity with the given identifier in the identity map of * this UnitOfWork. * - * @param mixed $id The entity identifier to look for. + * @param mixed $id The entity identifier to look for. * @param string $rootClassName The name of the root class of the mapped entity hierarchy. * - * @return mixed Returns the entity with the specified identifier if it exists in - * this UnitOfWork, FALSE otherwise. + * @return object|bool Returns the entity with the specified identifier if it exists in + * this UnitOfWork, FALSE otherwise. */ public function tryGetById($id, $rootClassName) { @@ -2801,6 +2901,9 @@ class UnitOfWork implements PropertyChangedListener * Schedules an entity for dirty-checking at commit-time. * * @param object $entity The entity to schedule for dirty-checking. + * + * @return void + * * @todo Rename: scheduleForSynchronization */ public function scheduleForDirtyCheck($entity) @@ -2836,7 +2939,7 @@ class UnitOfWork implements PropertyChangedListener /** * Gets the EntityPersister for an Entity. * - * @param string $entityName The name of the Entity. + * @param string $entityName The name of the Entity. * * @return \Doctrine\ORM\Persisters\BasicEntityPersister */ @@ -2905,8 +3008,10 @@ class UnitOfWork implements PropertyChangedListener * Registers an entity as managed. * * @param object $entity The entity. - * @param array $id The identifier values. - * @param array $data The original entity data. + * @param array $id The identifier values. + * @param array $data The original entity data. + * + * @return void */ public function registerManaged($entity, array $id, array $data) { @@ -2918,7 +3023,7 @@ class UnitOfWork implements PropertyChangedListener $this->addToIdentityMap($entity); - if ($entity instanceof NotifyPropertyChanged) { + if ($entity instanceof NotifyPropertyChanged && ( ! $entity instanceof Proxy || $entity->__isInitialized())) { $entity->addPropertyChangedListener($this); } } @@ -2928,6 +3033,8 @@ class UnitOfWork implements PropertyChangedListener * Clears the property changeset of the entity with the given OID. * * @param string $oid The entity's OID. + * + * @return void */ public function clearEntityChangeSet($oid) { @@ -2939,10 +3046,12 @@ class UnitOfWork implements PropertyChangedListener /** * Notifies this UnitOfWork of a property change in an entity. * - * @param object $entity The entity that owns the property. + * @param object $entity The entity that owns the property. * @param string $propertyName The name of the property that changed. - * @param mixed $oldValue The old value of the property. - * @param mixed $newValue The new value of the property. + * @param mixed $oldValue The old value of the property. + * @param mixed $newValue The new value of the property. + * + * @return void */ public function propertyChanged($entity, $propertyName, $oldValue, $newValue) { @@ -2994,7 +3103,7 @@ class UnitOfWork implements PropertyChangedListener } /** - * Get the currently scheduled complete collection deletions + * Gets the currently scheduled complete collection deletions * * @return array */ @@ -3016,7 +3125,7 @@ class UnitOfWork implements PropertyChangedListener /** * Helper method to initialize a lazy loading proxy or persistent collection. * - * @param object + * @param object $obj * * @return void */ @@ -3036,7 +3145,7 @@ class UnitOfWork implements PropertyChangedListener /** * Helper method to show an object as string. * - * @param object $obj + * @param object $obj * * @return string */ @@ -3051,12 +3160,11 @@ class UnitOfWork implements PropertyChangedListener * This operation cannot be undone as some parts of the UnitOfWork now keep gathering information * on this object that might be necessary to perform a correct update. * - * * @param object $object * - * @throws ORMInvalidArgumentException - * * @return void + * + * @throws ORMInvalidArgumentException */ public function markReadOnly($object) { @@ -3072,9 +3180,9 @@ class UnitOfWork implements PropertyChangedListener * * @param object $object * - * @throws ORMInvalidArgumentException - * * @return bool + * + * @throws ORMInvalidArgumentException */ public function isReadOnly($object) { @@ -3084,4 +3192,18 @@ class UnitOfWork implements PropertyChangedListener return isset($this->readOnlyObjects[spl_object_hash($object)]); } + + private function dispatchOnFlushEvent() + { + if ($this->evm->hasListeners(Events::onFlush)) { + $this->evm->dispatchEvent(Events::onFlush, new OnFlushEventArgs($this->em)); + } + } + + private function dispatchPostFlushEvent() + { + if ($this->evm->hasListeners(Events::postFlush)) { + $this->evm->dispatchEvent(Events::postFlush, new PostFlushEventArgs($this->em)); + } + } } diff --git a/vendor/doctrine/orm/lib/Doctrine/ORM/Version.php b/vendor/doctrine/orm/lib/Doctrine/ORM/Version.php old mode 100755 new mode 100644 index 8638b3616c..c6506b55c6 --- a/vendor/doctrine/orm/lib/Doctrine/ORM/Version.php +++ b/vendor/doctrine/orm/lib/Doctrine/ORM/Version.php @@ -36,12 +36,13 @@ class Version /** * Current Doctrine Version */ - const VERSION = '2.3.4'; + const VERSION = '2.4.1'; /** * Compares a Doctrine version with the current one. * * @param string $version Doctrine version to compare. + * * @return int Returns -1 if older, 0 if it is the same, 1 if version * passed as argument is newer. */ diff --git a/vendor/doctrine/orm/phpunit.xml.dist b/vendor/doctrine/orm/phpunit.xml.dist deleted file mode 100755 index 3ab5edbaef..0000000000 --- a/vendor/doctrine/orm/phpunit.xml.dist +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - ./tests/Doctrine/Tests/ORM - - - - - - performance - locking_functional - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/run-all.sh b/vendor/doctrine/orm/run-all.sh deleted file mode 100755 index 80712eebc7..0000000000 --- a/vendor/doctrine/orm/run-all.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# This script is a small convenience wrapper for running the doctrine testsuite against a large bunch of databases. -# Just create the phpunit.xmls as described in the array below and configure the specific files section -# to connect to that database. Just omit a file if you dont have that database and the tests will be skipped. - -configs[1]="mysql.phpunit.xml" -configs[2]='postgres.phpunit.xml' -configs[3]='sqlite.phpunit.xml' -configs[4]='oracle.phpunit.xml' -configs[5]='db2.phpunit.xml' -configs[6]='pdo-ibm.phpunit.xml' -configs[7]='sqlsrv.phpunit.xml' - -for i in "${configs[@]}"; do - if [ -f "$i" ]; - then - echo "RUNNING TESTS WITH CONFIG $i" - phpunit -c "$i" "$@" - fi; -done diff --git a/vendor/doctrine/orm/tests/.gitignore b/vendor/doctrine/orm/tests/.gitignore deleted file mode 100755 index 7210405266..0000000000 --- a/vendor/doctrine/orm/tests/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Doctrine/Tests/Proxies/ -Doctrine/Tests/ORM/Proxy/generated/ -Doctrine/Tests/ORM/Tools/Export/export diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalFunctionalTestCase.php deleted file mode 100755 index c4705a25e4..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalFunctionalTestCase.php +++ /dev/null @@ -1,32 +0,0 @@ -sharedFixture['conn'] = null; - self::$_sharedConn = null; - } - - protected function setUp() - { - if (isset($this->sharedFixture['conn'])) { - $this->_conn = $this->sharedFixture['conn']; - } else { - if ( ! isset(self::$_sharedConn)) { - self::$_sharedConn = TestUtil::getConnection(); - } - $this->_conn = self::$_sharedConn; - } - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTestCase.php deleted file mode 100755 index 2478e7bcc9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTestCase.php +++ /dev/null @@ -1,10 +0,0 @@ -getIntegerTypeDeclarationSQL($fieldDeclaration); - } - - public function canRequireSQLConversion() - { - return true; - } - - public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) - { - return 'ABS(' . $sqlExpr . ')'; - } - - public function convertToPHPValueSQL($sqlExpr, $platform) - { - return '-(' . $sqlExpr . ')'; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php deleted file mode 100755 index 47e8c790d8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php +++ /dev/null @@ -1,29 +0,0 @@ -_generatorType = $type; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/ConnectionMock.php deleted file mode 100755 index 90ebfec306..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ /dev/null @@ -1,106 +0,0 @@ -_platformMock = new DatabasePlatformMock(); - - parent::__construct($params, $driver, $config, $eventManager); - - // Override possible assignment of platform to database platform mock - $this->_platform = $this->_platformMock; - } - - /** - * @override - */ - public function getDatabasePlatform() - { - return $this->_platformMock; - } - - /** - * @override - */ - public function insert($tableName, array $data, array $types = array()) - { - $this->_inserts[$tableName][] = $data; - } - - /** - * @override - */ - public function executeUpdate($query, array $params = array(), array $types = array()) - { - $this->_executeUpdates[] = array('query' => $query, 'params' => $params, 'types' => $types); - } - - /** - * @override - */ - public function lastInsertId($seqName = null) - { - return $this->_lastInsertId; - } - - /** - * @override - */ - public function fetchColumn($statement, array $params = array(), $colnum = 0) - { - return $this->_fetchOneResult; - } - - /** - * @override - */ - public function quote($input, $type = null) - { - if (is_string($input)) { - return "'" . $input . "'"; - } - return $input; - } - - /* Mock API */ - - public function setFetchOneResult($fetchOneResult) - { - $this->_fetchOneResult = $fetchOneResult; - } - - public function setDatabasePlatform($platform) - { - $this->_platformMock = $platform; - } - - public function setLastInsertId($id) - { - $this->_lastInsertId = $id; - } - - public function getInserts() - { - return $this->_inserts; - } - - public function getExecuteUpdates() - { - return $this->_executeUpdates; - } - - public function reset() - { - $this->_inserts = array(); - $this->_lastInsertId = 0; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php deleted file mode 100755 index b634408bec..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php +++ /dev/null @@ -1,97 +0,0 @@ -_prefersIdentityColumns; - } - - /** - * @override - */ - public function prefersSequences() - { - return $this->_prefersSequences; - } - - /** @override */ - public function getSequenceNextValSQL($sequenceName) - { - return $this->_sequenceNextValSql; - } - - /** @override */ - public function getBooleanTypeDeclarationSQL(array $field) {} - - /** @override */ - public function getIntegerTypeDeclarationSQL(array $field) {} - - /** @override */ - public function getBigIntTypeDeclarationSQL(array $field) {} - - /** @override */ - public function getSmallIntTypeDeclarationSQL(array $field) {} - - /** @override */ - protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {} - - /** @override */ - public function getVarcharTypeDeclarationSQL(array $field) {} - - /** @override */ - public function getClobTypeDeclarationSQL(array $field) {} - - /* MOCK API */ - - public function setPrefersIdentityColumns($bool) - { - $this->_prefersIdentityColumns = $bool; - } - - public function setPrefersSequences($bool) - { - $this->_prefersSequences = $bool; - } - - public function setSequenceNextValSql($sql) - { - $this->_sequenceNextValSql = $sql; - } - - public function getName() - { - return 'mock'; - } - - protected function initializeDoctrineTypeMappings() - { - - } - /** - * Gets the SQL Snippet used to declare a BLOB column type. - */ - public function getBlobTypeDeclarationSQL(array $field) - { - throw DBALException::notSupported(__METHOD__); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php deleted file mode 100755 index a18e24a4da..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php +++ /dev/null @@ -1,17 +0,0 @@ -_platformMock) { - $this->_platformMock = new DatabasePlatformMock; - } - return $this->_platformMock; - } - - /** - * @override - */ - public function getSchemaManager(\Doctrine\DBAL\Connection $conn) - { - if($this->_schemaManagerMock == null) { - return new SchemaManagerMock($conn); - } else { - return $this->_schemaManagerMock; - } - } - - /* MOCK API */ - - public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform) - { - $this->_platformMock = $platform; - } - - public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm) - { - $this->_schemaManagerMock = $sm; - } - - public function getName() - { - return 'mock'; - } - - public function getDatabase(\Doctrine\DBAL\Connection $conn) - { - return; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityManagerMock.php deleted file mode 100755 index ca49410ada..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityManagerMock.php +++ /dev/null @@ -1,106 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Mocks; - -use Doctrine\ORM\Proxy\ProxyFactory; - -/** - * Special EntityManager mock used for testing purposes. - */ -class EntityManagerMock extends \Doctrine\ORM\EntityManager -{ - private $_uowMock; - private $_proxyFactoryMock; - private $_idGenerators = array(); - - /** - * @override - */ - public function getUnitOfWork() - { - return isset($this->_uowMock) ? $this->_uowMock : parent::getUnitOfWork(); - } - - /* Mock API */ - - /** - * Sets a (mock) UnitOfWork that will be returned when getUnitOfWork() is called. - * - * @param $uow - */ - public function setUnitOfWork($uow) - { - $this->_uowMock = $uow; - } - - public function setProxyFactory($proxyFactory) - { - $this->_proxyFactoryMock = $proxyFactory; - } - - public function getProxyFactory() - { - return isset($this->_proxyFactoryMock) ? $this->_proxyFactoryMock : parent::getProxyFactory(); - } - - /** - * Mock factory method to create an EntityManager. - * - * @param unknown_type $conn - * @param unknown_type $name - * @param Doctrine_Configuration $config - * @param Doctrine_EventManager $eventManager - * @return Doctrine\ORM\EntityManager - */ - public static function create($conn, \Doctrine\ORM\Configuration $config = null, - \Doctrine\Common\EventManager $eventManager = null) - { - if (is_null($config)) { - $config = new \Doctrine\ORM\Configuration(); - $config->setProxyDir(__DIR__ . '/../Proxies'); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(), true)); - } - if (is_null($eventManager)) { - $eventManager = new \Doctrine\Common\EventManager(); - } - - return new EntityManagerMock($conn, $config, $eventManager); - } -/* - public function setIdGenerator($className, $generator) - { - $this->_idGenerators[$className] = $generator; - } -*/ - /** @override */ -/* public function getIdGenerator($className) - { - - if (isset($this->_idGenerators[$className])) { - return $this->_idGenerators[$className]; - } - - return parent::getIdGenerator($className); - } - */ -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php deleted file mode 100755 index 768e357b1b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php +++ /dev/null @@ -1,100 +0,0 @@ - $entity - * @return - * @override - */ - public function insert($entity) - { - $this->_inserts[] = $entity; - if ( ! is_null($this->_mockIdGeneratorType) && $this->_mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY - || $this->_class->isIdGeneratorIdentity()) { - $id = $this->_identityColumnValueCounter++; - $this->_postInsertIds[$id] = $entity; - return $id; - } - return null; - } - - public function addInsert($entity) - { - $this->_inserts[] = $entity; - if ( ! is_null($this->_mockIdGeneratorType) && $this->_mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY - || $this->_class->isIdGeneratorIdentity()) { - $id = $this->_identityColumnValueCounter++; - $this->_postInsertIds[$id] = $entity; - return $id; - } - return null; - } - - public function executeInserts() - { - return $this->_postInsertIds; - } - - public function setMockIdGeneratorType($genType) - { - $this->_mockIdGeneratorType = $genType; - } - - public function update($entity) - { - $this->_updates[] = $entity; - } - - public function exists($entity, array $extraConditions = array()) - { - $this->existsCalled = true; - } - - public function delete($entity) - { - $this->_deletes[] = $entity; - } - - public function getInserts() - { - return $this->_inserts; - } - - public function getUpdates() - { - return $this->_updates; - } - - public function getDeletes() - { - return $this->_deletes; - } - - public function reset() - { - $this->existsCalled = false; - $this->_identityColumnValueCounter = 0; - $this->_inserts = array(); - $this->_updates = array(); - $this->_deletes = array(); - } - - public function isExistsCalled() - { - return $this->existsCalled; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php deleted file mode 100755 index 297d41ee36..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ -class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement -{ - private $_resultSet; - - /** - * Creates a new mock statement that will serve the provided fake result set to clients. - * - * @param array $resultSet The faked SQL result set. - */ - public function __construct(array $resultSet) - { - $this->_resultSet = $resultSet; - } - - /** - * Fetches all rows from the result set. - * - * @return array - */ - public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null) - { - return $this->_resultSet; - } - - public function fetchColumn($columnNumber = 0) - { - $row = current($this->_resultSet); - if ( ! is_array($row)) return false; - $val = array_shift($row); - return $val !== null ? $val : false; - } - - /** - * Fetches the next row in the result set. - * - */ - public function fetch($fetchStyle = null) - { - $current = current($this->_resultSet); - next($this->_resultSet); - return $current; - } - - /** - * Closes the cursor, enabling the statement to be executed again. - * - * @return boolean - */ - public function closeCursor() - { - return true; - } - - public function setResultSet(array $resultSet) - { - reset($resultSet); - $this->_resultSet = $resultSet; - } - - public function bindColumn($column, &$param, $type = null) - { - } - - public function bindValue($param, $value, $type = null) - { - } - - public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()) - { - } - - public function columnCount() - { - } - - public function errorCode() - { - } - - public function errorInfo() - { - } - - public function execute($params = array()) - { - } - - public function rowCount() - { - } - - public function getIterator() - { - return $this->_resultSet; - } - - public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) - { - - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/IdentityIdGeneratorMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/IdentityIdGeneratorMock.php deleted file mode 100755 index 0c5696b487..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/IdentityIdGeneratorMock.php +++ /dev/null @@ -1,12 +0,0 @@ -_mockPostInsertId = $id; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php deleted file mode 100755 index 3dfb5e3a92..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php +++ /dev/null @@ -1,21 +0,0 @@ -_sequenceNumber++; - } - - /** - * @override - */ - public function nextId($seqName, $ondemand = true) - { - return $this->_sequenceNumber++; - } - - /** - * @override - */ - public function lastInsertId($table = null, $field = null) - { - return $this->_sequenceNumber - 1; - } - - /** - * @override - */ - public function currId($seqName) - { - return $this->_sequenceNumber; - } - - /* Mock API */ - - public function reset() - { - $this->_sequenceNumber = 0; - } - - public function autoinc() - { - $this->_sequenceNumber++; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/StatementMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/StatementMock.php deleted file mode 100755 index 9b6959ff4b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/StatementMock.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class StatementMock implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement -{ - public function bindValue($param, $value, $type = null){} - public function bindParam($column, &$variable, $type = null, $length = null){} - public function errorCode(){} - public function errorInfo(){} - public function execute($params = null){} - public function rowCount(){} - public function closeCursor(){} - public function columnCount(){} - public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null){} - public function fetch($fetchStyle = null){} - public function fetchAll($fetchStyle = null){} - public function fetchColumn($columnIndex = 0){} - public function getIterator(){} -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/TaskMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/TaskMock.php deleted file mode 100755 index d4d50689d9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/TaskMock.php +++ /dev/null @@ -1,81 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Mocks; - -use Doctrine\Common\Cli\AbstractNamespace; - -/** - * TaskMock used for testing the CLI interface. - * @author Nils Adermann - */ -class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask -{ - /** - * Since instances of this class can be created elsewhere all instances - * register themselves in this array for later inspection. - * - * @var array(TaskMock) - */ - static public $instances = array(); - - private $runCounter = 0; - - /** - * Constructor of Task Mock Object. - * Makes sure the object can be inspected later. - * - * @param AbstractNamespace CLI Namespace, passed to parent constructor - */ - function __construct(AbstractNamespace $namespace) - { - self::$instances[] = $this; - - parent::__construct($namespace); - } - - /** - * Returns the number of times run() was called on this object. - * - * @return int - */ - public function getRunCounter() - { - return $this->runCounter; - } - - /* Mock API */ - - /** - * Method invoked by CLI to run task. - */ - public function run() - { - $this->runCounter++; - } - - /** - * Method supposed to generate the CLI Task Documentation - */ - public function buildDocumentation() - { - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php deleted file mode 100755 index 9535cdde35..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php +++ /dev/null @@ -1,58 +0,0 @@ -_persisterMock[$entityName]) ? - $this->_persisterMock[$entityName] : parent::getEntityPersister($entityName); - } - - /** - * @param $entity - * @override - */ - public function getEntityChangeSet($entity) - { - $oid = spl_object_hash($entity); - return isset($this->_mockDataChangeSets[$oid]) ? - $this->_mockDataChangeSets[$oid] : parent::getEntityChangeSet($entity); - } - - /* MOCK API */ - - /** - * Sets a (mock) persister for an entity class that will be returned when - * getEntityPersister() is invoked for that class. - * - * @param $entityName - * @param $persister - */ - public function setEntityPersister($entityName, $persister) - { - $this->_persisterMock[$entityName] = $persister; - } - - public function setDataChangeSet($entity, array $mockChangeSet) - { - $this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet; - } - - public function setEntityState($entity, $state) - { - $this->_entityStates[spl_object_hash($entity)] = $state; - } - - public function setOriginalEntityData($entity, array $originalData) - { - $this->_originalEntityData[spl_object_hash($entity)] = $originalData; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsAddress.php deleted file mode 100755 index 9833f3dfbc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ /dev/null @@ -1,191 +0,0 @@ -id; - } - - public function getUser() { - return $this->user; - } - - public function getCountry() { - return $this->country; - } - - public function getZipCode() { - return $this->zip; - } - - public function getCity() { - return $this->city; - } - - public function setUser(CmsUser $user) { - if ($this->user !== $user) { - $this->user = $user; - $user->setAddress($this); - } - } - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - $metadata->setPrimaryTable(array( - 'name' => 'company_person', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'find-all', - 'query' => 'SELECT id, country, city FROM cms_addresses', - 'resultSetMapping' => 'mapping-find-all', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'find-by-id', - 'query' => 'SELECT * FROM cms_addresses WHERE id = ?', - 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'count', - 'query' => 'SELECT COUNT(*) AS count FROM cms_addresses', - 'resultSetMapping' => 'mapping-count', - )); - - - $metadata->addSqlResultSetMapping(array ( - 'name' => 'mapping-find-all', - 'columns' => array(), - 'entities' => array ( array ( - 'fields' => array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'city', - 'column' => 'city', - ), - array ( - 'name' => 'country', - 'column' => 'country', - ), - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress', - ), - ), - )); - - $metadata->addSqlResultSetMapping(array ( - 'name' => 'mapping-without-fields', - 'columns' => array(), - 'entities' => array(array ( - 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', - 'fields' => array() - ) - ) - )); - - $metadata->addSqlResultSetMapping(array ( - 'name' => 'mapping-count', - 'columns' =>array ( - array ( - 'name' => 'count', - ), - ) - )); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsArticle.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsArticle.php deleted file mode 100755 index 266cbc6622..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsArticle.php +++ /dev/null @@ -1,48 +0,0 @@ -user = $author; - } - - public function addComment(CmsComment $comment) { - $this->comments[] = $comment; - $comment->setArticle($this); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsComment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsComment.php deleted file mode 100755 index 3e238210b7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsComment.php +++ /dev/null @@ -1,38 +0,0 @@ -article = $article; - } - - public function __toString() { - return __CLASS__."[id=".$this->id."]"; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmail.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmail.php deleted file mode 100755 index c79c30036a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmail.php +++ /dev/null @@ -1,48 +0,0 @@ -id; - } - - public function getEmail() { - return $this->email; - } - - public function setEmail($email) { - $this->email = $email; - } - - public function getUser() { - return $this->user; - } - - public function setUser(CmsUser $user) { - $this->user = $user; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php deleted file mode 100755 index c1697150fc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php +++ /dev/null @@ -1,44 +0,0 @@ -id; - } - - public function getName() { - return $this->name; - } - - public function getSpouse() { - return $this->spouse; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsGroup.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsGroup.php deleted file mode 100755 index b65ae8557d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsGroup.php +++ /dev/null @@ -1,49 +0,0 @@ -name = $name; - } - - public function getName() { - return $this->name; - } - - public function addUser(CmsUser $user) { - $this->users[] = $user; - } - - public function getUsers() { - return $this->users; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php deleted file mode 100755 index ff28dfd9bf..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php +++ /dev/null @@ -1,28 +0,0 @@ -user = $user; - } - - public function getUser() { - return $this->user; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsUser.php deleted file mode 100755 index 2bae6ed4f2..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ /dev/null @@ -1,437 +0,0 @@ -phonenumbers = new ArrayCollection; - $this->articles = new ArrayCollection; - $this->groups = new ArrayCollection; - } - - public function getId() { - return $this->id; - } - - public function getStatus() { - return $this->status; - } - - public function getUsername() { - return $this->username; - } - - public function getName() { - return $this->name; - } - - /** - * Adds a phonenumber to the user. - * - * @param CmsPhonenumber $phone - */ - public function addPhonenumber(CmsPhonenumber $phone) { - $this->phonenumbers[] = $phone; - $phone->setUser($this); - } - - public function getPhonenumbers() { - return $this->phonenumbers; - } - - public function addArticle(CmsArticle $article) { - $this->articles[] = $article; - $article->setAuthor($this); - } - - public function addGroup(CmsGroup $group) { - $this->groups[] = $group; - $group->addUser($this); - } - - public function getGroups() { - return $this->groups; - } - - public function removePhonenumber($index) { - if (isset($this->phonenumbers[$index])) { - $ph = $this->phonenumbers[$index]; - unset($this->phonenumbers[$index]); - $ph->user = null; - return true; - } - return false; - } - - public function getAddress() { return $this->address; } - - public function setAddress(CmsAddress $address) { - if ($this->address !== $address) { - $this->address = $address; - $address->setUser($this); - } - } - - public function getEmail() { return $this->email; } - - public function setEmail(CmsEmail $email = null) { - if ($this->email !== $email) { - $this->email = $email; - - if ($email) { - $email->setUser($this); - } - } - } - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - $metadata->setPrimaryTable(array( - 'name' => 'cms_users', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'fetchIdAndUsernameWithResultClass', - 'query' => 'SELECT id, username FROM cms_users WHERE username = ?', - 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'fetchAllColumns', - 'query' => 'SELECT * FROM cms_users WHERE username = ?', - 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'fetchJoinedAddress', - 'query' => 'SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', - 'resultSetMapping' => 'mappingJoinedAddress', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'fetchJoinedPhonenumber', - 'query' => 'SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', - 'resultSetMapping' => 'mappingJoinedPhonenumber', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'fetchUserPhonenumberCount', - 'query' => 'SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username', - 'resultSetMapping' => 'mappingUserPhonenumberCount', - )); - - $metadata->addNamedNativeQuery(array ( - "name" => "fetchMultipleJoinsEntityResults", - "resultSetMapping" => "mappingMultipleJoinsEntityResults", - "query" => "SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username" - )); - - $metadata->addSqlResultSetMapping(array ( - 'name' => 'mappingJoinedAddress', - 'columns' => array(), - 'entities' => array(array ( - 'fields'=> array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'name', - 'column' => 'name', - ), - array ( - 'name' => 'status', - 'column' => 'status', - ), - array ( - 'name' => 'address.zip', - 'column' => 'zip', - ), - array ( - 'name' => 'address.city', - 'column' => 'city', - ), - array ( - 'name' => 'address.country', - 'column' => 'country', - ), - array ( - 'name' => 'address.id', - 'column' => 'a_id', - ), - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'discriminatorColumn' => null - ), - ), - )); - - $metadata->addSqlResultSetMapping(array ( - 'name' => 'mappingJoinedPhonenumber', - 'columns' => array(), - 'entities' => array(array( - 'fields'=> array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'name', - 'column' => 'name', - ), - array ( - 'name' => 'status', - 'column' => 'status', - ), - array ( - 'name' => 'phonenumbers.phonenumber', - 'column' => 'number', - ), - ), - 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', - 'discriminatorColumn' => null - ), - ), - )); - - $metadata->addSqlResultSetMapping(array ( - 'name' => 'mappingUserPhonenumberCount', - 'columns' => array(), - 'entities' => array ( - array( - 'fields' => array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'name', - 'column' => 'name', - ), - array ( - 'name' => 'status', - 'column' => 'status', - ) - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'discriminatorColumn' => null - ) - ), - 'columns' => array ( - array ( - 'name' => 'numphones', - ) - ) - )); - - $metadata->addSqlResultSetMapping(array( - 'name' => 'mappingMultipleJoinsEntityResults', - 'entities' => array(array( - 'fields' => array( - array( - 'name' => 'id', - 'column' => 'u_id', - ), - array( - 'name' => 'name', - 'column' => 'u_name', - ), - array( - 'name' => 'status', - 'column' => 'u_status', - ) - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'discriminatorColumn' => null, - ), - array( - 'fields' => array( - array( - 'name' => 'id', - 'column' => 'a_id', - ), - array( - 'name' => 'zip', - 'column' => 'a_zip', - ), - array( - 'name' => 'country', - 'column' => 'a_country', - ), - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress', - 'discriminatorColumn' => null, - ), - ), - 'columns' => array(array( - 'name' => 'numphones', - ) - ) - )); - - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyAuction.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyAuction.php deleted file mode 100755 index 5743122bc7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyAuction.php +++ /dev/null @@ -1,17 +0,0 @@ -data = $data; - } - - public function getData() { - return $this->data; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyCar.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyCar.php deleted file mode 100755 index 5af89b2a32..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyCar.php +++ /dev/null @@ -1,33 +0,0 @@ -brand = $brand; - } - - public function getId() { - return $this->id; - } - - public function getBrand() { - return $this->title; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyContract.php deleted file mode 100755 index bc8503dfe9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ /dev/null @@ -1,131 +0,0 @@ -engineers = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function getId() - { - return $this->id; - } - - public function markCompleted() - { - $this->completed = true; - } - - public function isCompleted() - { - return $this->completed; - } - - public function getSalesPerson() - { - return $this->salesPerson; - } - - public function setSalesPerson(CompanyEmployee $salesPerson) - { - $this->salesPerson = $salesPerson; - } - - public function getEngineers() - { - return $this->engineers; - } - - public function addEngineer(CompanyEmployee $engineer) - { - $this->engineers[] = $engineer; - } - - public function removeEngineer(CompanyEmployee $engineer) - { - $this->engineers->removeElement($engineer); - } - - abstract public function calculatePrice(); -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php deleted file mode 100755 index 9d153770e0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php +++ /dev/null @@ -1,59 +0,0 @@ -salary; - } - - public function setSalary($salary) { - $this->salary = $salary; - } - - public function getDepartment() { - return $this->department; - } - - public function setDepartment($dep) { - $this->department = $dep; - } - - public function getStartDate() { - return $this->startDate; - } - - public function setStartDate($date) { - $this->startDate = $date; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEvent.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEvent.php deleted file mode 100755 index bb320aa91a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEvent.php +++ /dev/null @@ -1,36 +0,0 @@ -id; - } - - public function getOrganization() { - return $this->organization; - } - - public function setOrganization(CompanyOrganization $org) { - $this->organization = $org; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php deleted file mode 100755 index 9186fc3b17..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php +++ /dev/null @@ -1,30 +0,0 @@ -fixPrice; - } - - public function getFixPrice() - { - return $this->fixPrice; - } - - public function setFixPrice($fixPrice) - { - $this->fixPrice = $fixPrice; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php deleted file mode 100755 index 121d8ec8e9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ /dev/null @@ -1,110 +0,0 @@ -hoursWorked * $this->pricePerHour; - } - - public function getHoursWorked() - { - return $this->hoursWorked; - } - - public function setHoursWorked($hoursWorked) - { - $this->hoursWorked = $hoursWorked; - } - - public function getPricePerHour() - { - return $this->pricePerHour; - } - - public function setPricePerHour($pricePerHour) - { - $this->pricePerHour = $pricePerHour; - } - public function getManagers() - { - return $this->managers; - } - - public function addManager(CompanyManager $manager) - { - $this->managers[] = $manager; - } - - public function removeManager(CompanyManager $manager) - { - $this->managers->removeElement($manager); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php deleted file mode 100755 index b9ad3d4c92..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ /dev/null @@ -1,30 +0,0 @@ -maxPrice, parent::calculatePrice()); - } - - public function getMaxPrice() - { - return $this->maxPrice; - } - - public function setMaxPrice($maxPrice) - { - $this->maxPrice = $maxPrice; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyManager.php deleted file mode 100755 index aec9a77ae9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyManager.php +++ /dev/null @@ -1,42 +0,0 @@ -title; - } - - public function setTitle($title) { - $this->title = $title; - } - - public function getCar() { - return $this->car; - } - - public function setCar(CompanyCar $car) { - $this->car = $car; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php deleted file mode 100755 index ca9941062d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php +++ /dev/null @@ -1,44 +0,0 @@ -id; - } - - public function getEvents() { - return $this->events; - } - - public function addEvent(CompanyEvent $event) { - $this->events[] = $event; - $event->setOrganization($this); - } - - /** - * @OneToOne(targetEntity="CompanyEvent", cascade={"persist"}) - * @JoinColumn(name="main_event_id", referencedColumnName="id", nullable=true) - */ - private $mainevent; - - public function getMainEvent() { - return $this->mainevent; - } - - public function setMainEvent($event) { - $this->mainevent = $event; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyPerson.php deleted file mode 100755 index 4636fa4e30..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyPerson.php +++ /dev/null @@ -1,160 +0,0 @@ -friends = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function getId() { - return $this->id; - } - - public function getName() { - return $this->name; - } - - public function setName($name) { - $this->name = $name; - } - - public function getSpouse() { - return $this->spouse; - } - - public function getFriends() { - return $this->friends; - } - - public function addFriend(CompanyPerson $friend) { - if ( ! $this->friends->contains($friend)) { - $this->friends->add($friend); - $friend->addFriend($this); - } - } - - public function setSpouse(CompanyPerson $spouse) { - if ($spouse !== $this->spouse) { - $this->spouse = $spouse; - $this->spouse->setSpouse($this); - } - } - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - - $metadata->setPrimaryTable(array( - 'name' => 'company_person', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'fetchAllWithResultClass', - 'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name', - 'resultClass' => 'Doctrine\\Tests\\Models\\Company\\CompanyPerson', - )); - - $metadata->addNamedNativeQuery(array ( - 'name' => 'fetchAllWithSqlResultSetMapping', - 'query' => 'SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name', - 'resultSetMapping' => 'mappingFetchAll', - )); - - $metadata->addSqlResultSetMapping(array ( - 'name' => 'mappingFetchAll', - 'columns' => array(), - 'entities' => array ( array ( - 'fields' => array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'name', - 'column' => 'name', - ), - ), - 'entityClass' => 'Doctrine\Tests\Models\Company\CompanyPerson', - 'discriminatorColumn' => 'discriminator', - ), - ), - )); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php deleted file mode 100755 index 733190d584..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php +++ /dev/null @@ -1,17 +0,0 @@ -data = $data; - } - - public function getData() { - return $this->data; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php deleted file mode 100755 index e178ab51c3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php +++ /dev/null @@ -1,21 +0,0 @@ -friendsWithMe = new \Doctrine\Common\Collections\ArrayCollection(); - $this->myFriends = new \Doctrine\Common\Collections\ArrayCollection(); - } - - public function addMyFriend(CustomTypeParent $friend) - { - $this->getMyFriends()->add($friend); - $friend->addFriendWithMe($this); - } - - public function getMyFriends() - { - return $this->myFriends; - } - - public function addFriendWithMe(CustomTypeParent $friend) - { - $this->getFriendsWithMe()->add($friend); - } - - public function getFriendsWithMe() - { - return $this->friendsWithMe; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php deleted file mode 100755 index e4b46e8809..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php +++ /dev/null @@ -1,26 +0,0 @@ -articleDetails = $details; - $this->reference = $reference; - $this->translation = $translation; - } - - public function getId() - { - return $this->id; - } - - public function getArticleDetails() - { - return $this->articleDetails; - } - - public function getReference() - { - return $this->reference; - } - - public function getTranslation() - { - return $this->translation; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php deleted file mode 100755 index d77bb942b8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php +++ /dev/null @@ -1,87 +0,0 @@ -title = $title; - $this->references = new \Doctrine\Common\Collections\ArrayCollection(); - $this->translations = new \Doctrine\Common\Collections\ArrayCollection(); - } - - public function setDetails($details) - { - $this->details = $details; - } - - public function id() - { - return $this->id; - } - - public function addReference($reference) - { - $this->references[] = $reference; - } - - public function references() - { - return $this->references; - } - - public function addTranslation($language, $title) - { - $this->translations[] = new DDC117Translation($this, $language, $title); - } - - public function getText() - { - return $this->details->getText(); - } - - public function getDetails() - { - return $this->details; - } - - public function resetText() - { - $this->details = null; - } - - public function getTranslations() - { - return $this->translations; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php deleted file mode 100755 index ae13df036f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php +++ /dev/null @@ -1,39 +0,0 @@ -article = $article; - $article->setDetails($this); - - $this->update($text); - } - - public function update($text) - { - $this->text = $text; - } - - public function getText() - { - return $this->text; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php deleted file mode 100755 index a323bb3045..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php +++ /dev/null @@ -1,54 +0,0 @@ -name = $name; - $this->reviewingTranslations = new \Doctrine\Common\Collections\ArrayCollection(); - } - - public function addLastTranslation(DDC117Translation $t) - { - $this->lastTranslation = $t; - $t->lastTranslatedBy[] = $this; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php deleted file mode 100755 index 7e0084a67d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php +++ /dev/null @@ -1,31 +0,0 @@ -source = $source; - $this->target = $target; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php deleted file mode 100755 index 3c9017d198..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php +++ /dev/null @@ -1,64 +0,0 @@ -addReference($this); - $target->addReference($this); - - $this->source = $source; - $this->target = $target; - $this->description = $description; - $this->created = new \DateTime("now"); - } - - public function source() - { - return $this->source; - } - - public function target() - { - return $this->target; - } - - public function setDescription($desc) - { - $this->description = $desc; - } - - public function getDescription() - { - return $this->description; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php deleted file mode 100755 index b0fb4375db..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php +++ /dev/null @@ -1,65 +0,0 @@ -article = $article; - $this->language = $language; - $this->title = $title; - $this->reviewedByEditors = new \Doctrine\Common\Collections\ArrayCollection(); - $this->lastTranslatedBy = new \Doctrine\Common\Collections\ArrayCollection(); - } - - public function getArticleId() - { - return $this->article->id(); - } - - public function getLanguage() - { - return $this->language; - } - - public function getLastTranslatedBy() - { - return $this->lastTranslatedBy; - } - - public function getReviewedByEditors() - { - return $this->reviewedByEditors; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php deleted file mode 100755 index eaf9006c75..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Models\DDC753; - -use Doctrine\ORM\EntityRepository; - -class DDC753CustomRepository extends EntityRepository -{ - - /** - * @return bool - */ - public function isCustomRepository() - { - return true; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php deleted file mode 100755 index 5be9aa522e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Models\DDC753; - -use Doctrine\ORM\EntityRepository; - -class DDC753DefaultRepository extends EntityRepository -{ - /** - * @return bool - */ - public function isDefaultRepository() - { - return true; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php deleted file mode 100755 index 594f79f785..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Models\DDC869; - -/** - * @Entity - */ -class DDC869ChequePayment extends DDC869Payment -{ - - /** @column(type="string") */ - protected $serialNumber; - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - $metadata->mapField(array( - 'fieldName' => 'serialNumber', - 'type' => 'string', - )); - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php deleted file mode 100755 index 9e978d4947..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Models\DDC869; - -/** - * @Entity - */ -class DDC869CreditCardPayment extends DDC869Payment -{ - - /** @column(type="string") */ - protected $creditCardNumber; - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - $metadata->mapField(array( - 'fieldName' => 'creditCardNumber', - 'type' => 'string', - )); - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php deleted file mode 100755 index b9b8febdc3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Models\DDC869; - -/** - * @MappedSuperclass(repositoryClass = "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository") - */ -class DDC869Payment -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - protected $id; - - /** @column(type="float") */ - protected $value; - - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - $metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - )); - $metadata->mapField(array( - 'fieldName' => 'value', - 'type' => 'float', - )); - $metadata->isMappedSuperclass = true; - $metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); - $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php deleted file mode 100755 index 7520568b03..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Models\DDC889; - -class DDC889Class extends DDC889SuperClass -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - protected $id; - - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - $metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - )); - - $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php deleted file mode 100755 index 7cffe488bc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Models\DDC889; - -/** - * @MappedSuperclass - */ -class DDC889SuperClass -{ - - /** @Column() */ - protected $name; - - public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) - { - $metadata->mapField(array( - 'fieldName' => 'name', - )); - - $metadata->isMappedSuperclass = true; - $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php deleted file mode 100755 index f5edaf8576..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php +++ /dev/null @@ -1,123 +0,0 @@ -zip = $zip; - $this->country = $country; - $this->city = $city; - $this->street = $street; - } - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * @return string - */ - public function getCountry() - { - return $this->country; - } - - /** - * @param string $country - */ - public function setCountry($country) - { - $this->country = $country; - } - - /** - * @return string - */ - public function getZip() - { - return $this->zip; - } - - /** - * @param string $zip - */ - public function setZip($zip) - { - $this->zip = $zip; - } - - /** - * @return string - */ - public function getCity() - { - return $this->city; - } - - /** - * @param string $city - */ - public function setCity($city) - { - $this->city = $city; - } - - /** - * @return string - */ - public function getStreet() - { - return $this->street; - } - - /** - * @param string $street - */ - public function setStreet($street) - { - $this->street = $street; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php deleted file mode 100755 index e22b973deb..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php +++ /dev/null @@ -1,47 +0,0 @@ -setAssociationOverride('address',array( - 'joinColumns'=>array(array( - 'name' => 'adminaddress_id', - 'referencedColumnName' => 'id', - )) - )); - - $metadata->setAssociationOverride('groups',array( - 'joinTable' => array( - 'name' => 'ddc964_users_admingroups', - 'joinColumns' => array(array( - 'name' => 'adminuser_id', - )), - 'inverseJoinColumns' =>array (array ( - 'name' => 'admingroup_id', - )) - ) - )); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php deleted file mode 100755 index 5260409976..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php +++ /dev/null @@ -1,70 +0,0 @@ -name = $name; - $this->users = new ArrayCollection(); - } - - /** - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param DDC964User $user - */ - public function addUser(DDC964User $user) - { - $this->users[] = $user; - } - - /** - * @return ArrayCollection - */ - public function getUsers() - { - return $this->users; - } - -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php deleted file mode 100755 index 90501187c2..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php +++ /dev/null @@ -1,44 +0,0 @@ -setAttributeOverride('id', array( - 'columnName' => 'guest_id', - 'type' => 'integer', - 'length' => 140, - )); - - $metadata->setAttributeOverride('name',array( - 'columnName' => 'guest_name', - 'nullable' => false, - 'unique' => true, - 'length' => 240, - )); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964User.php deleted file mode 100755 index 608f42d966..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC964/DDC964User.php +++ /dev/null @@ -1,155 +0,0 @@ -name = $name; - $this->groups = new ArrayCollection; - } - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * @param DDC964Group $group - */ - public function addGroup(DDC964Group $group) - { - $this->groups->add($group); - $group->addUser($this); - } - - /** - * @return ArrayCollection - */ - public function getGroups() - { - return $this->groups; - } - - /** - * @return DDC964Address - */ - public function getAddress() - { - return $this->address; - } - - /** - * @param DDC964Address $address - */ - public function setAddress(DDC964Address $address) - { - $this->address = $address; - } - - public static function loadMetadata($metadata) - { - $metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'user_id', - 'length' => 150, - )); - $metadata->mapField(array( - 'fieldName' => 'name', - 'type' => 'string', - 'columnName'=> 'user_name', - 'nullable' => true, - 'unique' => false, - 'length' => 250, - )); - - $metadata->mapManyToOne(array( - 'fieldName' => 'address', - 'targetEntity' => 'DDC964Address', - 'cascade' => array('persist','merge'), - 'joinColumn' => array('name'=>'address_id', 'referencedColumnMame'=>'id'), - )); - - $metadata->mapManyToMany(array( - 'fieldName' => 'groups', - 'targetEntity' => 'DDC964Group', - 'inversedBy' => 'users', - 'cascade' => array('persist','merge','detach'), - 'joinTable' => array( - 'name' => 'ddc964_users_groups', - 'joinColumns' => array(array( - 'name'=>'user_id', - 'referencedColumnName'=>'id', - )), - 'inverseJoinColumns'=>array(array( - 'name'=>'group_id', - 'referencedColumnName'=>'id', - )) - ) - )); - - $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php deleted file mode 100755 index 3d9f6798f1..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php +++ /dev/null @@ -1,91 +0,0 @@ -products = new ArrayCollection; - } - - public function getId() { - return $this->id; - } - - public function getPayment() { - return $this->payment; - } - - public function setPayment($payment) { - $this->payment = $payment; - } - - public function setCustomer(ECommerceCustomer $customer) { - if ($this->customer !== $customer) { - $this->customer = $customer; - $customer->setCart($this); - } - } - - public function removeCustomer() { - if ($this->customer !== null) { - $customer = $this->customer; - $this->customer = null; - $customer->removeCart(); - } - } - - public function getCustomer() { - return $this->customer; - } - - public function getProducts() - { - return $this->products; - } - - public function addProduct(ECommerceProduct $product) { - $this->products[] = $product; - } - - public function removeProduct(ECommerceProduct $product) { - return $this->products->removeElement($product); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php deleted file mode 100755 index a8d8dc6bbb..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php +++ /dev/null @@ -1,126 +0,0 @@ -products = new ArrayCollection(); - $this->children = new ArrayCollection(); - } - - public function getId() - { - return $this->id; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - public function addProduct(ECommerceProduct $product) - { - if (!$this->products->contains($product)) { - $this->products[] = $product; - $product->addCategory($this); - } - } - - public function removeProduct(ECommerceProduct $product) - { - $removed = $this->products->removeElement($product); - if ($removed) { - $product->removeCategory($this); - } - } - - public function getProducts() - { - return $this->products; - } - - private function setParent(ECommerceCategory $parent) - { - $this->parent = $parent; - } - - public function getChildren() - { - return $this->children; - } - - public function getParent() - { - return $this->parent; - } - - public function addChild(ECommerceCategory $child) - { - $this->children[] = $child; - $child->setParent($this); - } - - /** does not set the owning side. */ - public function brokenAddChild(ECommerceCategory $child) - { - $this->children[] = $child; - } - - - public function removeChild(ECommerceCategory $child) - { - $removed = $this->children->removeElement($child); - if ($removed) { - $child->removeParent(); - } - } - - private function removeParent() - { - $this->parent = null; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php deleted file mode 100755 index a5de9e119c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php +++ /dev/null @@ -1,94 +0,0 @@ -id; - } - - public function getName() { - return $this->name; - } - - public function setName($name) { - $this->name = $name; - } - - public function setCart(ECommerceCart $cart) - { - if ($this->cart !== $cart) { - $this->cart = $cart; - $cart->setCustomer($this); - } - } - - /* Does not properly maintain the bidirectional association! */ - public function brokenSetCart(ECommerceCart $cart) { - $this->cart = $cart; - } - - public function getCart() { - return $this->cart; - } - - public function removeCart() - { - if ($this->cart !== null) { - $cart = $this->cart; - $this->cart = null; - $cart->removeCustomer(); - } - } - - public function setMentor(ECommerceCustomer $mentor) - { - $this->mentor = $mentor; - } - - public function removeMentor() - { - $this->mentor = null; - } - - public function getMentor() - { - return $this->mentor; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php deleted file mode 100755 index 04fc2bed35..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php +++ /dev/null @@ -1,59 +0,0 @@ -id; - } - - public function getDescription() { - return $this->description; - } - - public function setDescription($description) { - $this->description = $description; - } - - public function setProduct(ECommerceProduct $product) { - $this->product = $product; - } - - public function removeProduct() { - if ($this->product !== null) { - $product = $this->product; - $this->product = null; - $product->removeFeature($this); - } - } - - public function getProduct() { - return $this->product; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php deleted file mode 100755 index f053fd2cb7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php +++ /dev/null @@ -1,178 +0,0 @@ -features = new ArrayCollection; - $this->categories = new ArrayCollection; - $this->related = new ArrayCollection; - } - - public function getId() - { - return $this->id; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getShipping() - { - return $this->shipping; - } - - public function setShipping(ECommerceShipping $shipping) - { - $this->shipping = $shipping; - } - - public function removeShipping() - { - $this->shipping = null; - } - - public function getFeatures() - { - return $this->features; - } - - public function addFeature(ECommerceFeature $feature) - { - $this->features[] = $feature; - $feature->setProduct($this); - } - - /** does not set the owning side */ - public function brokenAddFeature(ECommerceFeature $feature) - { - $this->features[] = $feature; - } - - public function removeFeature(ECommerceFeature $feature) - { - $removed = $this->features->removeElement($feature); - if ($removed) { - $feature->removeProduct(); - } - return $removed; - } - - public function addCategory(ECommerceCategory $category) - { - if (!$this->categories->contains($category)) { - $this->categories[] = $category; - $category->addProduct($this); - } - } - - public function removeCategory(ECommerceCategory $category) - { - $removed = $this->categories->removeElement($category); - if ($removed) { - $category->removeProduct($this); - } - } - - public function getCategories() - { - return $this->categories; - } - - public function getRelated() - { - return $this->related; - } - - public function addRelated(ECommerceProduct $related) - { - if (!$this->related->contains($related)) { - $this->related[] = $related; - $related->addRelated($this); - } - } - - public function removeRelated(ECommerceProduct $related) - { - $removed = $this->related->removeElement($related); - if ($removed) { - $related->removeRelated($this); - } - } - - public function __clone() - { - $this->isCloned = true; - } - - /** - * Testing docblock contents here - */ - public function __wakeup() - { - $this->wakeUp = true; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php deleted file mode 100755 index a0f302cc22..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php +++ /dev/null @@ -1,40 +0,0 @@ -id; - } - - public function getDays() - { - return $this->days; - } - - public function setDays($days) - { - $this->days = $days; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php deleted file mode 100755 index 13d78ab643..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php +++ /dev/null @@ -1,14 +0,0 @@ -id; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumEntry.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumEntry.php deleted file mode 100755 index efa359b005..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumEntry.php +++ /dev/null @@ -1,26 +0,0 @@ -topic; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumUser.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumUser.php deleted file mode 100755 index 3f3b5d9d2f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumUser.php +++ /dev/null @@ -1,41 +0,0 @@ -id; - } - - public function getUsername() { - return $this->username; - } - - public function getAvatar() { - return $this->avatar; - } - - public function setAvatar(ForumAvatar $avatar) { - $this->avatar = $avatar; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/BooleanModel.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/BooleanModel.php deleted file mode 100755 index 2c931563ee..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/BooleanModel.php +++ /dev/null @@ -1,20 +0,0 @@ -_user = $author; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php deleted file mode 100755 index ac38341459..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php +++ /dev/null @@ -1,41 +0,0 @@ -_description; - } - - public function addUser(LegacyUser $user) { - $this->_users[] = $user; - } - - public function getUsers() { - return $this->_users; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php deleted file mode 100755 index 3e3deedb15..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php +++ /dev/null @@ -1,80 +0,0 @@ -_articles = new ArrayCollection; - $this->_references = new ArrayCollection; - $this->_cars = new ArrayCollection; - } - - public function getId() { - return $this->_id; - } - - public function getUsername() { - return $this->_username; - } - - public function addArticle(LegacyArticle $article) { - $this->_articles[] = $article; - $article->setAuthor($this); - } - - public function addReference($reference) - { - $this->_references[] = $reference; - } - - public function references() - { - return $this->_references; - } - - public function addCar(LegacyCar $car) { - $this->_cars[] = $car; - $car->addUser($this); - } - - public function getCars() { - return $this->_cars; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php deleted file mode 100755 index 8dc20db232..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php +++ /dev/null @@ -1,65 +0,0 @@ -addReference($this); - $target->addReference($this); - - $this->_source = $source; - $this->_target = $target; - $this->_description = $description; - $this->_created = new \DateTime("now"); - } - - public function source() - { - return $this->_source; - } - - public function target() - { - return $this->_target; - } - - public function setDescription($desc) - { - $this->_description = $desc; - } - - public function getDescription() - { - return $this->_description; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavCountry.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavCountry.php deleted file mode 100755 index fd37552600..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavCountry.php +++ /dev/null @@ -1,39 +0,0 @@ -name = $name; - } - - public function getId() { - return $this->id; - } - - public function getName() { - return $this->name; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php deleted file mode 100755 index 25858d0b3e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php +++ /dev/null @@ -1,48 +0,0 @@ -poi = $poi; - $this->file = $file; - } - - public function getId() { - return $this->id; - } - - public function getPointOfInterest() { - return $this->poi; - } - - public function getFile() { - return $this->file; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php deleted file mode 100755 index 33d0f70bdb..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php +++ /dev/null @@ -1,79 +0,0 @@ -lat = $lat; - $this->long = $long; - $this->name = $name; - $this->country = $country; - $this->visitors = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function getLong() { - return $this->long; - } - - public function getLat() { - return $this->lat; - } - - public function getName() { - return $this->name; - } - - public function getCountry() { - return $this->country; - } - - public function addVisitor(NavUser $user) - { - $this->visitors[] = $user; - } - - public function getVisitors() - { - return $this->visitors; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavTour.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavTour.php deleted file mode 100755 index 5a58017aa3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavTour.php +++ /dev/null @@ -1,61 +0,0 @@ -name = $name; - $this->pois = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function addPointOfInterest(NavPointOfInterest $poi) - { - $this->pois[] = $poi; - } - - public function getPointOfInterests() - { - return $this->pois; - } - - public function getName() - { - return $this->name; - } - - public function getId() - { - return $this->id; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavUser.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavUser.php deleted file mode 100755 index 42117e46b8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavUser.php +++ /dev/null @@ -1,28 +0,0 @@ -name = $name; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Address.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Address.php deleted file mode 100755 index 58e303f133..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Address.php +++ /dev/null @@ -1,54 +0,0 @@ -user !== $user) { - $this->user = $user; - $user->setAddress($this); - } - } - - - public function getId() - { - return $this->id; - } - - public function getZip() - { - return $this->zip; - } - - public function getUser() - { - return $this->user; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Group.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Group.php deleted file mode 100755 index c653b69742..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Group.php +++ /dev/null @@ -1,42 +0,0 @@ -name = $name; - $this->parent = $parent; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Phone.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Phone.php deleted file mode 100755 index 3d4475372c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/Phone.php +++ /dev/null @@ -1,24 +0,0 @@ -value = $value; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/User.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/User.php deleted file mode 100755 index d034f598db..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Quote/User.php +++ /dev/null @@ -1,102 +0,0 @@ -phones = new ArrayCollection; - $this->groups = new ArrayCollection; - } - - - public function getPhones() - { - return $this->phones; - } - - public function getAddress() - { - return $this->address; - } - - public function getGroups() - { - return $this->groups; - } - - public function setAddress(Address $address) { - if ($this->address !== $address) { - $this->address = $address; - $address->setUser($this); - } - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php deleted file mode 100755 index a130e7b0c4..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php +++ /dev/null @@ -1,37 +0,0 @@ -name; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php deleted file mode 100755 index 9e5d5d02e7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php +++ /dev/null @@ -1,39 +0,0 @@ -legs = new ArrayCollection(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php deleted file mode 100755 index 9b862fc391..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php +++ /dev/null @@ -1,32 +0,0 @@ -passengerName; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php deleted file mode 100755 index c8d661782f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php +++ /dev/null @@ -1,48 +0,0 @@ -name = $name; - } - - public function getId() - { - return $this->id; - } - - public function addStock(Stock $stock) - { - $this->stocks[$stock->getSymbol()] = $stock; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Market.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Market.php deleted file mode 100755 index 87e12cab65..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Market.php +++ /dev/null @@ -1,56 +0,0 @@ -name = $name; - $this->stocks = new ArrayCollection(); - } - - public function getId() - { - return $this->id; - } - - public function getName() - { - return $this->name; - } - - public function addStock(Stock $stock) - { - $this->stocks[$stock->getSymbol()] = $stock; - } - - public function getStock($symbol) - { - return $this->stocks[$symbol]; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Stock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Stock.php deleted file mode 100755 index d65675be93..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Stock.php +++ /dev/null @@ -1,49 +0,0 @@ -symbol = $symbol; - $this->price = $initialOfferingPrice; - $this->market = $market; - $market->addStock($this); - } - - public function getSymbol() - { - return $this->symbol; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php deleted file mode 100755 index ff8205987f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php +++ /dev/null @@ -1,56 +0,0 @@ -_calc = new \Doctrine\ORM\Internal\CommitOrderCalculator(); - } - - public function testCommitOrdering1() - { - $class1 = new ClassMetadata(__NAMESPACE__ . '\NodeClass1'); - $class2 = new ClassMetadata(__NAMESPACE__ . '\NodeClass2'); - $class3 = new ClassMetadata(__NAMESPACE__ . '\NodeClass3'); - $class4 = new ClassMetadata(__NAMESPACE__ . '\NodeClass4'); - $class5 = new ClassMetadata(__NAMESPACE__ . '\NodeClass5'); - - $this->_calc->addClass($class1); - $this->_calc->addClass($class2); - $this->_calc->addClass($class3); - $this->_calc->addClass($class4); - $this->_calc->addClass($class5); - - $this->_calc->addDependency($class1, $class2); - $this->_calc->addDependency($class2, $class3); - $this->_calc->addDependency($class3, $class4); - $this->_calc->addDependency($class5, $class1); - - $sorted = $this->_calc->getCommitOrder(); - - // There is only 1 valid ordering for this constellation - $correctOrder = array($class5, $class1, $class2, $class3, $class4); - $this->assertSame($correctOrder, $sorted); - } -} - -class NodeClass1 {} -class NodeClass2 {} -class NodeClass3 {} -class NodeClass4 {} -class NodeClass5 {} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/ConfigurationTest.php deleted file mode 100755 index 76832c1dc7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ /dev/null @@ -1,276 +0,0 @@ - - */ -class ConfigurationTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Configuration - */ - private $configuration; - - protected function setUp() - { - parent::setUp(); - $this->configuration = new Configuration(); - } - - public function testSetGetProxyDir() - { - $this->assertSame(null, $this->configuration->getProxyDir()); // defaults - - $this->configuration->setProxyDir(__DIR__); - $this->assertSame(__DIR__, $this->configuration->getProxyDir()); - } - - public function testSetGetAutoGenerateProxyClasses() - { - $this->assertSame(true, $this->configuration->getAutoGenerateProxyClasses()); // defaults - - $this->configuration->setAutoGenerateProxyClasses(false); - $this->assertSame(false, $this->configuration->getAutoGenerateProxyClasses()); - } - - public function testSetGetProxyNamespace() - { - $this->assertSame(null, $this->configuration->getProxyNamespace()); // defaults - - $this->configuration->setProxyNamespace(__NAMESPACE__); - $this->assertSame(__NAMESPACE__, $this->configuration->getProxyNamespace()); - } - - public function testSetGetMetadataDriverImpl() - { - $this->assertSame(null, $this->configuration->getMetadataDriverImpl()); // defaults - - $metadataDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $this->configuration->setMetadataDriverImpl($metadataDriver); - $this->assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl()); - } - - public function testNewDefaultAnnotationDriver() - { - $paths = array(__DIR__); - $reflectionClass = new ReflectionClass(__NAMESPACE__ . '\ConfigurationTestAnnotationReaderChecker'); - - $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false); - $reader = $annotationDriver->getReader(); - $annotation = $reader->getMethodAnnotation( - $reflectionClass->getMethod('namespacedAnnotationMethod'), - 'Doctrine\ORM\Mapping\PrePersist' - ); - $this->assertInstanceOf('Doctrine\ORM\Mapping\PrePersist', $annotation); - - $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths); - $reader = $annotationDriver->getReader(); - $annotation = $reader->getMethodAnnotation( - $reflectionClass->getMethod('simpleAnnotationMethod'), - 'Doctrine\ORM\Mapping\PrePersist' - ); - $this->assertInstanceOf('Doctrine\ORM\Mapping\PrePersist', $annotation); - } - - public function testSetGetEntityNamespace() - { - $this->configuration->addEntityNamespace('TestNamespace', __NAMESPACE__); - $this->assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace')); - $namespaces = array('OtherNamespace' => __NAMESPACE__); - $this->configuration->setEntityNamespaces($namespaces); - $this->assertSame($namespaces, $this->configuration->getEntityNamespaces()); - $this->setExpectedException('Doctrine\ORM\ORMException'); - $this->configuration->getEntityNamespace('NonExistingNamespace'); - } - - public function testSetGetQueryCacheImpl() - { - $this->assertSame(null, $this->configuration->getQueryCacheImpl()); // defaults - $queryCacheImpl = $this->getMock('Doctrine\Common\Cache\Cache'); - $this->configuration->setQueryCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getQueryCacheImpl()); - } - - public function testSetGetHydrationCacheImpl() - { - $this->assertSame(null, $this->configuration->getHydrationCacheImpl()); // defaults - $queryCacheImpl = $this->getMock('Doctrine\Common\Cache\Cache'); - $this->configuration->setHydrationCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getHydrationCacheImpl()); - } - - public function testSetGetMetadataCacheImpl() - { - $this->assertSame(null, $this->configuration->getMetadataCacheImpl()); // defaults - $queryCacheImpl = $this->getMock('Doctrine\Common\Cache\Cache'); - $this->configuration->setMetadataCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getMetadataCacheImpl()); - } - - public function testAddGetNamedQuery() - { - $dql = 'SELECT u FROM User u'; - $this->configuration->addNamedQuery('QueryName', $dql); - $this->assertSame($dql, $this->configuration->getNamedQuery('QueryName')); - $this->setExpectedException('Doctrine\ORM\ORMException'); - $this->configuration->getNamedQuery('NonExistingQuery'); - } - - public function testAddGetNamedNativeQuery() - { - $sql = 'SELECT * FROM user'; - $rsm = $this->getMock('Doctrine\ORM\Query\ResultSetMapping'); - $this->configuration->addNamedNativeQuery('QueryName', $sql, $rsm); - $fetched = $this->configuration->getNamedNativeQuery('QueryName'); - $this->assertSame($sql, $fetched[0]); - $this->assertSame($rsm, $fetched[1]); - $this->setExpectedException('Doctrine\ORM\ORMException'); - $this->configuration->getNamedQuery('NonExistingQuery'); - } - - public function ensureProductionSettings() - { - $cache = $this->getMock('Doctrine\Common\Cache\Cache'); - $this->configuration->setAutoGenerateProxyClasses(true); - - try { - $this->configuration->ensureProductionSettings(); - $this->fail('Didn\'t check all production settings'); - } catch (ORMException $e) {} - - $this->configuration->setQueryCacheImpl($cache); - - try { - $this->configuration->ensureProductionSettings(); - $this->fail('Didn\'t check all production settings'); - } catch (ORMException $e) {} - - $this->configuration->setMetadataCacheImpl($cache); - - try { - $this->configuration->ensureProductionSettings(); - $this->fail('Didn\'t check all production settings'); - } catch (ORMException $e) {} - - $this->configuration->setAutoGenerateProxyClasses(false); - $this->configuration->ensureProductionSettings(); - } - - public function testAddGetCustomStringFunction() - { - $this->configuration->addCustomStringFunction('FunctionName', __CLASS__); - $this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction')); - $this->configuration->setCustomStringFunctions(array('OtherFunctionName' => __CLASS__)); - $this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('OtherFunctionName')); - $this->setExpectedException('Doctrine\ORM\ORMException'); - $this->configuration->addCustomStringFunction('concat', __CLASS__); - } - - public function testAddGetCustomNumericFunction() - { - $this->configuration->addCustomNumericFunction('FunctionName', __CLASS__); - $this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction')); - $this->configuration->setCustomNumericFunctions(array('OtherFunctionName' => __CLASS__)); - $this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('OtherFunctionName')); - $this->setExpectedException('Doctrine\ORM\ORMException'); - $this->configuration->addCustomNumericFunction('abs', __CLASS__); - } - - public function testAddGetCustomDatetimeFunction() - { - $this->configuration->addCustomDatetimeFunction('FunctionName', __CLASS__); - $this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction')); - $this->configuration->setCustomDatetimeFunctions(array('OtherFunctionName' => __CLASS__)); - $this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('OtherFunctionName')); - $this->setExpectedException('Doctrine\ORM\ORMException'); - $this->configuration->addCustomDatetimeFunction('date_add', __CLASS__); - } - - public function testAddGetCustomHydrationMode() - { - $this->assertSame(null, $this->configuration->getCustomHydrationMode('NonExisting')); - $this->configuration->addCustomHydrationMode('HydrationModeName', __CLASS__); - $this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('HydrationModeName')); - } - - public function testSetCustomHydrationModes() - { - $this->configuration->addCustomHydrationMode('HydrationModeName', __CLASS__); - $this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('HydrationModeName')); - - $this->configuration->setCustomHydrationModes( - array( - 'AnotherHydrationModeName' => __CLASS__ - ) - ); - - $this->assertNull($this->configuration->getCustomHydrationMode('HydrationModeName')); - $this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('AnotherHydrationModeName')); - } - - public function testSetGetClassMetadataFactoryName() - { - $this->assertSame('Doctrine\ORM\Mapping\ClassMetadataFactory', $this->configuration->getClassMetadataFactoryName()); - $this->configuration->setClassMetadataFactoryName(__CLASS__); - $this->assertSame(__CLASS__, $this->configuration->getClassMetadataFactoryName()); - } - - public function testAddGetFilters() - { - $this->assertSame(null, $this->configuration->getFilterClassName('NonExistingFilter')); - $this->configuration->addFilter('FilterName', __CLASS__); - $this->assertSame(__CLASS__, $this->configuration->getFilterClassName('FilterName')); - } - - public function setDefaultRepositoryClassName() - { - $this->assertSame('Doctrine\ORM\EntityRepository', $this->configuration->getDefaultRepositoryClassName()); - $repositoryClass = 'Doctrine\Tests\Models\DDC753\DDC753CustomRepository'; - $this->configuration->setDefaultRepositoryClassName($repositoryClass); - $this->assertSame($repositoryClass, $this->configuration->getDefaultRepositoryClassName()); - $this->setExpectedException('Doctrine\ORM\ORMException'); - $this->configuration->setDefaultRepositoryClassName(__CLASS__); - } - - public function testSetGetNamingStrategy() - { - $this->assertInstanceOf('Doctrine\ORM\Mapping\NamingStrategy', $this->configuration->getNamingStrategy()); - $namingStrategy = $this->getMock('Doctrine\ORM\Mapping\NamingStrategy'); - $this->configuration->setNamingStrategy($namingStrategy); - $this->assertSame($namingStrategy, $this->configuration->getNamingStrategy()); - } - - public function testSetGetQuoteStrategy() - { - $this->assertInstanceOf('Doctrine\ORM\Mapping\QuoteStrategy', $this->configuration->getQuoteStrategy()); - $quoteStrategy = $this->getMock('Doctrine\ORM\Mapping\QuoteStrategy'); - $this->configuration->setQuoteStrategy($quoteStrategy); - $this->assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); - } -} - -class ConfigurationTestAnnotationReaderChecker -{ - /** @PrePersist */ - public function simpleAnnotationMethod() - { - } - - /** @AnnotationNamespace\PrePersist */ - public function namespacedAnnotationMethod() - { - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php deleted file mode 100755 index b3aa607926..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php +++ /dev/null @@ -1,252 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Query; - -require_once __DIR__ . '/../../TestInit.php'; - -/** - * Test case for testing the saving and referencing of query identifiers. - * - * @author Guilherme Blanco - * @author Janne Vanhala - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link http://www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - */ -class DqlGenerationTest extends \Doctrine\Tests\OrmTestCase -{ - protected function setUp() { - $this->markTestSkipped('Not yet implemented.'); - } - - protected function createQuery() - { - return $this->_em->createQuery(); - } - - public function testSelect() - { - $query = $this->createQuery(); - - // select and from - $query->setDql('FROM User u'); - $this->assertEquals('FROM User u', $query->getDql()); // Internally we use SELECT * FROM User u to process the DQL - $query->free(); - - $query->select()->from('User u'); - $this->assertEquals('SELECT * FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.*')->from('User u'); - $this->assertEquals('SELECT u.* FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.id')->from('User u'); - $this->assertEquals('SELECT u.id FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.id, u.name')->from('User u'); - $this->assertEquals('SELECT u.id, u.name FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.name AS myCustomName')->from('User u'); - $this->assertEquals('SELECT u.name AS myCustomName FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.id')->select('u.name')->from('User u'); - $this->assertEquals('SELECT u.id, u.name FROM User u', $query->getDql()); - $query->free(); - } - - - public function testSelectDistinct() - { - $query = $this->createQuery(); - - $query->select()->distinct()->from('User u'); - $this->assertEquals('SELECT DISTINCT * FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.name')->distinct(false)->from('User u'); - $this->assertEquals('SELECT u.name FROM User u', $query->getDql()); - $query->free(); - - $query->select()->distinct(false)->from('User u'); - $this->assertEquals('SELECT * FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.name')->distinct()->from('User u'); - $this->assertEquals('SELECT DISTINCT u.name FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.name, u.email')->distinct()->from('User u'); - $this->assertEquals('SELECT DISTINCT u.name, u.email FROM User u', $query->getDql()); - $query->free(); - - $query->select('u.name')->select('u.email')->distinct()->from('User u'); - $this->assertEquals('SELECT DISTINCT u.name, u.email FROM User u', $query->getDql()); - $query->free(); - - $query->select('DISTINCT u.name')->from('User u'); - $this->assertEquals('SELECT DISTINCT u.name FROM User u', $query->getDql()); - $query->free(); - - $query->select('DISTINCT u.name, u.email')->from('User u'); - $this->assertEquals('SELECT DISTINCT u.name, u.email FROM User u', $query->getDql()); - $query->free(); - - $query->select('DISTINCT u.name')->select('u.email')->from('User u'); - $this->assertEquals('SELECT DISTINCT u.name, u.email FROM User u', $query->getDql()); - $query->free(); - } - - - public function testSelectJoin() - { - $query = $this->createQuery(); - - $query->select('u.*')->from('User u')->join('u.Group g')->where('g.id = ?', 1); - $this->assertEquals('SELECT u.* FROM User u INNER JOIN u.Group g WHERE g.id = ?', $query->getDql()); - $this->assertEquals(array(1), $query->getParams()); - $query->free(); - - $query->select('u.*')->from('User u')->innerJoin('u.Group g')->where('g.id = ?', 1); - $this->assertEquals('SELECT u.* FROM User u INNER JOIN u.Group g WHERE g.id = ?', $query->getDql()); - $this->assertEquals(array(1), $query->getParams()); - $query->free(); - - $query->select('u.*')->from('User u')->leftJoin('u.Group g')->where('g.id IS NULL'); - $this->assertEquals('SELECT u.* FROM User u LEFT JOIN u.Group g WHERE g.id IS NULL', $query->getDql()); - $query->free(); - - $query->select('u.*')->from('User u')->leftJoin('u.UserGroup ug')->leftJoin('ug.Group g')->where('g.name = ?', 'admin'); - $this->assertEquals('SELECT u.* FROM User u LEFT JOIN u.UserGroup ug LEFT JOIN ug.Group g WHERE g.name = ?', $query->getDql()); - $query->free(); - } - - - public function testSelectWhere() - { - $query = $this->createQuery(); - - $query->select('u.name')->from('User u')->where('u.id = ?', 1); - $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ?', $query->getDql()); - $this->assertEquals(array(1), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->where('u.id = ? AND u.type != ?', array(1, 'admin')); - $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? AND u.type != ?', $query->getDql()); - $this->assertEquals(array(1, 'admin'), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->where('u.id = ?', 1)->andWhere('u.type != ?', 'admin'); - $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? AND u.type != ?', $query->getDql()); - $this->assertEquals(array(1, 'admin'), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->where('( u.id = ?', 1)->andWhere('u.type != ? )', 'admin'); - $this->assertEquals('SELECT u.name FROM User u WHERE ( u.id = ? AND u.type != ? )', $query->getDql()); - $this->assertEquals(array(1, 'admin'), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->where('u.id = ? OR u.type != ?', array(1, 'admin')); - $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? OR u.type != ?', $query->getDql()); - $this->assertEquals(array(1, 'admin'), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->where('u.id = ?', 1)->orWhere('u.type != ?', 'admin'); - $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? OR u.type != ?', $query->getDql()); - $this->assertEquals(array(1, 'admin'), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->andwhere('u.id = ?', 1)->andWhere('u.type != ?', 'admin')->orWhere('u.email = ?', 'admin@localhost'); - $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? AND u.type != ? OR u.email = ?', $query->getDql()); - $this->assertEquals(array(1, 'admin', 'admin@localhost'), $query->getParams()); - $query->free(); - } - - - public function testSelectWhereIn() - { - $query = $this->createQuery(); - - $query->select('u.name')->from('User u')->whereIn('u.id', array(1, 2, 3, 4, 5)); - $this->assertEquals('SELECT u.name FROM User u WHERE u.id IN (?, ?, ?, ?, ?)', $query->getDql()); - $this->assertEquals(array(1, 2, 3, 4, 5), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->whereNotIn('u.id', array(1, 2, 3)); - $this->assertEquals('SELECT u.name FROM User u WHERE u.id NOT IN (?, ?, ?)', $query->getDql()); - $this->assertEquals(array(1, 2, 3), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->where('u.type = ?', 'admin')->andWhereIn('u.id', array(1, 2)); - $this->assertEquals('SELECT u.name FROM User u WHERE u.type = ? AND u.id IN (?, ?)', $query->getDql()); - $this->assertEquals(array('admin', 1, 2), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->where('u.type = ?', 'admin')->andWhereNotIn('u.id', array(1, 2)); - $this->assertEquals('SELECT u.name FROM User u WHERE u.type = ? AND u.id NOT IN (?, ?)', $query->getDql()); - $this->assertEquals(array('admin', 1, 2), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->whereIn('u.type', array('admin', 'moderator'))->andWhereNotIn('u.id', array(1, 2, 3, 4)); - $this->assertEquals('SELECT u.name FROM User u WHERE u.type IN (?, ?) AND u.id NOT IN (?, ?, ?, ?)', $query->getDql()); - $this->assertEquals(array('admin', 'moderator', 1, 2, 3, 4), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->whereIn('u.type', array('admin', 'moderator'))->orWhereIn('u.id', array(1, 2, 3, 4)); - $this->assertEquals('SELECT u.name FROM User u WHERE u.type IN (?, ?) OR u.id IN (?, ?, ?, ?)', $query->getDql()); - $this->assertEquals(array('admin', 'moderator', 1, 2, 3, 4), $query->getParams()); - $query->free(); - - $query->select('u.name')->from('User u')->whereIn('u.type', array('admin', 'moderator'))->andWhereNotIn('u.id', array(1, 2))->orWhereNotIn('u.type', array('admin', 'moderator'))->andWhereNotIn('u.email', array('user@localhost', 'guest@localhost')); - $this->assertEquals('SELECT u.name FROM User u WHERE u.type IN (?, ?) AND u.id NOT IN (?, ?) OR u.type NOT IN (?, ?) AND u.email NOT IN (?, ?)', $query->getDql()); - $this->assertEquals(array('admin', 'moderator', 1, 2, 'admin', 'moderator', 'user@localhost', 'guest@localhost'), $query->getParams()); - $query->free(); - } - - - public function testDelete() - { - $query = $this->createQuery(); - - $query->setDql('DELETE CmsUser u'); - $this->assertEquals('DELETE CmsUser u', $query->getDql()); - $query->free(); - - $query->delete()->from('CmsUser u'); - $this->assertEquals('DELETE FROM CmsUser u', $query->getDql()); - $query->free(); - - $query->delete()->from('CmsUser u')->where('u.id = ?', 1); - $this->assertEquals('DELETE FROM CmsUser u WHERE u.id = ?', $query->getDql()); - $query->free(); - - $query->delete()->from('CmsUser u')->where('u.username = ?', 'gblanco')->orWhere('u.name = ?', 'Guilherme'); - $this->assertEquals('DELETE FROM CmsUser u WHERE u.username = ? OR u.name = ?', $query->getDql()); - $query->free(); - } - -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php deleted file mode 100755 index 014a7b421e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -assertEquals("romanb", $entity->username); - } -} - -class ConstructorTestEntity1 -{ - private $id; - public $username; - - public function __construct($username = null) - { - if ($username !== null) { - $this->username = $username; - } - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/EntityManagerTest.php deleted file mode 100755 index 7de9213597..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ /dev/null @@ -1,175 +0,0 @@ -_em = $this->_getTestEntityManager(); - } - - /** - * @group DDC-899 - */ - public function testIsOpen() - { - $this->assertTrue($this->_em->isOpen()); - $this->_em->close(); - $this->assertFalse($this->_em->isOpen()); - } - - public function testGetConnection() - { - $this->assertInstanceOf('Doctrine\DBAL\Connection', $this->_em->getConnection()); - } - - public function testGetMetadataFactory() - { - $this->assertInstanceOf('Doctrine\ORM\Mapping\ClassMetadataFactory', $this->_em->getMetadataFactory()); - } - - public function testGetConfiguration() - { - $this->assertInstanceOf('Doctrine\ORM\Configuration', $this->_em->getConfiguration()); - } - - public function testGetUnitOfWork() - { - $this->assertInstanceOf('Doctrine\ORM\UnitOfWork', $this->_em->getUnitOfWork()); - } - - public function testGetProxyFactory() - { - $this->assertInstanceOf('Doctrine\ORM\Proxy\ProxyFactory', $this->_em->getProxyFactory()); - } - - public function testGetEventManager() - { - $this->assertInstanceOf('Doctrine\Common\EventManager', $this->_em->getEventManager()); - } - - public function testCreateNativeQuery() - { - $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); - $query = $this->_em->createNativeQuery('SELECT foo', $rsm); - - $this->assertSame('SELECT foo', $query->getSql()); - } - - public function testCreateQueryBuilder() - { - $this->assertInstanceOf('Doctrine\ORM\QueryBuilder', $this->_em->createQueryBuilder()); - } - - public function testCreateQueryBuilderAliasValid() - { - $q = $this->_em->createQueryBuilder() - ->select('u')->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $q2 = clone $q; - - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q->getQuery()->getDql()); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q2->getQuery()->getDql()); - - $q3 = clone $q; - - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q3->getQuery()->getDql()); - } - - public function testCreateQuery_DqlIsOptional() - { - $this->assertInstanceOf('Doctrine\ORM\Query', $this->_em->createQuery()); - } - - public function testGetPartialReference() - { - $user = $this->_em->getPartialReference('Doctrine\Tests\Models\CMS\CmsUser', 42); - $this->assertTrue($this->_em->contains($user)); - $this->assertEquals(42, $user->id); - $this->assertNull($user->getName()); - } - - public function testCreateQuery() - { - $q = $this->_em->createQuery('SELECT 1'); - $this->assertInstanceOf('Doctrine\ORM\Query', $q); - $this->assertEquals('SELECT 1', $q->getDql()); - } - - static public function dataMethodsAffectedByNoObjectArguments() - { - return array( - array('persist'), - array('remove'), - array('merge'), - array('refresh'), - array('detach') - ); - } - - /** - * @dataProvider dataMethodsAffectedByNoObjectArguments - */ - public function testThrowsExceptionOnNonObjectValues($methodName) { - $this->setExpectedException('Doctrine\ORM\ORMInvalidArgumentException', - 'EntityManager#'.$methodName.'() expects parameter 1 to be an entity object, NULL given.'); - $this->_em->$methodName(null); - } - - static public function dataAffectedByErrorIfClosedException() - { - return array( - array('flush'), - array('persist'), - array('remove'), - array('merge'), - array('refresh'), - ); - } - - /** - * @dataProvider dataAffectedByErrorIfClosedException - * @param string $methodName - */ - public function testAffectedByErrorIfClosedException($methodName) - { - $this->setExpectedException('Doctrine\ORM\ORMException', 'closed'); - - $this->_em->close(); - $this->_em->$methodName(new \stdClass()); - } - - /** - * @group DDC-1125 - */ - public function testTransactionalAcceptsReturn() - { - $return = $this->_em->transactional(function ($em) { - return 'foo'; - }); - - $this->assertEquals('foo', $return); - } - - public function testTransactionalAcceptsVariousCallables() - { - $this->assertSame('callback', $this->_em->transactional(array($this, 'transactionalCallback'))); - } - - public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed() - { - $this->setExpectedException('InvalidArgumentException', 'Expected argument of type "callable", got "object"'); - $this->_em->transactional($this); - } - - public function transactionalCallback($em) - { - $this->assertSame($this->_em, $em); - return 'callback'; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php deleted file mode 100755 index f11ad26225..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals(1, $this->_countForeignKeys($firstId, $secondId)); - } - - public function assertForeignKeysNotContain($firstId, $secondId) - { - $this->assertEquals(0, $this->_countForeignKeys($firstId, $secondId)); - } - - protected function _countForeignKeys($firstId, $secondId) - { - return count($this->_em->getConnection()->executeQuery(" - SELECT {$this->_firstField} - FROM {$this->_table} - WHERE {$this->_firstField} = ? - AND {$this->_secondField} = ? - ", array($firstId, $secondId))->fetchAll()); - } - - public function assertCollectionEquals(Collection $first, Collection $second) - { - return $first->forAll(function($k, $e) use($second) { return $second->contains($e); }); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php deleted file mode 100755 index f152796726..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ /dev/null @@ -1,598 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Phrase'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PhraseType'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Definition'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Lemma'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Type') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - - public function testIssue() - { - //setup - $phrase = new Phrase; - $phrase->setPhrase('lalala'); - - $type = new PhraseType; - $type->setType('nonsense'); - $type->setAbbreviation('non'); - - $def1 = new Definition; - $def1->setDefinition('def1'); - $def2 = new Definition; - $def2->setDefinition('def2'); - - $phrase->setType($type); - $phrase->addDefinition($def1); - $phrase->addDefinition($def2); - - $this->_em->persist($phrase); - $this->_em->persist($type); - - $this->_em->flush(); - $this->_em->clear(); - //end setup - - // test1 - lazy-loading many-to-one after find() - $phrase2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Phrase', $phrase->getId()); - $this->assertTrue(is_numeric($phrase2->getType()->getId())); - - $this->_em->clear(); - - // test2 - eager load in DQL query - $query = $this->_em->createQuery("SELECT p,t FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t"); - $res = $query->getResult(); - $this->assertEquals(1, count($res)); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\PhraseType', $res[0]->getType()); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $res[0]->getType()->getPhrases()); - $this->assertFalse($res[0]->getType()->getPhrases()->isInitialized()); - - $this->_em->clear(); - - // test2 - eager load in DQL query with double-join back and forth - $query = $this->_em->createQuery("SELECT p,t,pp FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t JOIN t.phrases pp"); - $res = $query->getResult(); - $this->assertEquals(1, count($res)); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\PhraseType', $res[0]->getType()); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $res[0]->getType()->getPhrases()); - $this->assertTrue($res[0]->getType()->getPhrases()->isInitialized()); - - $this->_em->clear(); - - // test3 - lazy-loading one-to-many after find() - $phrase3 = $this->_em->find('Doctrine\Tests\ORM\Functional\Phrase', $phrase->getId()); - $definitions = $phrase3->getDefinitions(); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $definitions); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Definition', $definitions[0]); - - $this->_em->clear(); - - // test4 - lazy-loading after DQL query - $query = $this->_em->createQuery("SELECT p FROM Doctrine\Tests\ORM\Functional\Phrase p"); - $res = $query->getResult(); - $definitions = $res[0]->getDefinitions(); - - $this->assertEquals(1, count($res)); - - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Definition', $definitions[0]); - $this->assertEquals(2, $definitions->count()); - } - - public function testManyToMany() - { - $lemma = new Lemma; - $lemma->setLemma('abu'); - - $type = new Type(); - $type->setType('nonsense'); - $type->setAbbreviation('non'); - - $lemma->addType($type); - - $this->_em->persist($lemma); - $this->_em->persist($type); - $this->_em->flush(); - - // test5 ManyToMany - $query = $this->_em->createQuery("SELECT l FROM Doctrine\Tests\ORM\Functional\Lemma l"); - $res = $query->getResult(); - $types = $res[0]->getTypes(); - - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Type', $types[0]); - } -} - -/** - * @Entity - * @Table(name="lemma") - */ -class Lemma { - - const CLASS_NAME = __CLASS__; - - /** - * @var int - * @Id - * @Column(type="integer", name="lemma_id") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * - * @var string - * @Column(type="string", name="lemma_name", unique=true, length=255) - */ - private $lemma; - - /** - * @var kateglo\application\utilities\collections\ArrayCollection - * @ManyToMany(targetEntity="Type", mappedBy="lemmas", cascade={"persist"}) - */ - private $types; - - public function __construct() { - $this->types = new \Doctrine\Common\Collections\ArrayCollection(); - } - - - /** - * - * @return int - */ - public function getId(){ - return $this->id; - } - - /** - * - * @param string $lemma - * @return void - */ - public function setLemma($lemma){ - $this->lemma = $lemma; - } - - /** - * - * @return string - */ - public function getLemma(){ - return $this->lemma; - } - - /** - * - * @param kateglo\application\models\Type $type - * @return void - */ - public function addType(Type $type){ - if (!$this->types->contains($type)) { - $this->types[] = $type; - $type->addLemma($this); - } - } - - /** - * - * @param kateglo\application\models\Type $type - * @return void - */ - public function removeType(Type $type) - { - $removed = $this->sources->removeElement($type); - if ($removed !== null) { - $removed->removeLemma($this); - } - } - - /** - * - * @return kateglo\application\helpers\collections\ArrayCollection - */ - public function getTypes() - { - return $this->types; - } -} - -/** - * @Entity - * @Table(name="type") - */ -class Type { - - const CLASS_NAME = __CLASS__; - - /** - * - * @var int - * @Id - * @Column(type="integer", name="type_id") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * - * @var string - * @Column(type="string", name="type_name", unique=true) - */ - private $type; - - /** - * - * @var string - * @Column(type="string", name="type_abbreviation", unique=true) - */ - private $abbreviation; - - /** - * @var kateglo\application\helpers\collections\ArrayCollection - * @ManyToMany(targetEntity="Lemma") - * @JoinTable(name="lemma_type", - * joinColumns={@JoinColumn(name="type_id", referencedColumnName="type_id")}, - * inverseJoinColumns={@JoinColumn(name="lemma_id", referencedColumnName="lemma_id")} - * ) - */ - private $lemmas; - - public function __construct(){ - $this->lemmas = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * - * @return int - */ - public function getId(){ - return $this->id; - } - - /** - * - * @param string $type - * @return void - */ - public function setType($type){ - $this->type = $type; - } - - /** - * - * @return string - */ - public function getType(){ - return $this->type; - } - - /** - * - * @param string $abbreviation - * @return void - */ - public function setAbbreviation($abbreviation){ - $this->abbreviation = $abbreviation; - } - - /** - * - * @return string - */ - public function getAbbreviation(){ - return $this->abbreviation; - } - - /** - * - * @param kateglo\application\models\Lemma $lemma - * @return void - */ - public function addLemma(Lemma $lemma) - { - if (!$this->lemmas->contains($lemma)) { - $this->lemmas[] = $lemma; - $lemma->addType($this); - } - } - - /** - * - * @param kateglo\application\models\Lemma $lemma - * @return void - */ - public function removeLEmma(Lemma $lemma) - { - $removed = $this->lemmas->removeElement($lemma); - if ($removed !== null) { - $removed->removeType($this); - } - } - - /** - * - * @return kateglo\application\helpers\collections\ArrayCollection - */ - public function getCategories() - { - return $this->categories; - } - -} - - -/** - * @Entity - * @Table(name="phrase") - */ -class Phrase { - - const CLASS_NAME = __CLASS__; - - /** - * @Id - * @Column(type="integer", name="phrase_id") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @Column(type="string", name="phrase_name", unique=true, length=255) - */ - private $phrase; - - /** - * @ManyToOne(targetEntity="PhraseType") - * @JoinColumn(name="phrase_type_id", referencedColumnName="phrase_type_id") - */ - private $type; - - /** - * @OneToMany(targetEntity="Definition", mappedBy="phrase", cascade={"persist"}) - */ - private $definitions; - - public function __construct() { - $this->definitions = new \Doctrine\Common\Collections\ArrayCollection; - } - - /** - * - * @param Definition $definition - * @return void - */ - public function addDefinition(Definition $definition){ - $this->definitions[] = $definition; - $definition->setPhrase($this); - } - - /** - * @return int - */ - public function getId(){ - return $this->id; - } - - /** - * @param string $phrase - * @return void - */ - public function setPhrase($phrase){ - $this->phrase = $phrase; - } - - /** - * @return string - */ - public function getPhrase(){ - return $this->phrase; - } - - /** - * - * @param PhraseType $type - * @return void - */ - public function setType(PhraseType $type){ - $this->type = $type; - } - - /** - * - * @return PhraseType - */ - public function getType(){ - return $this->type; - } - - /** - * - * @return ArrayCollection - */ - public function getDefinitions(){ - return $this->definitions; - } -} - -/** - * @Entity - * @Table(name="phrase_type") - */ -class PhraseType { - - const CLASS_NAME = __CLASS__; - - /** - * @Id - * @Column(type="integer", name="phrase_type_id") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @Column(type="string", name="phrase_type_name", unique=true) - */ - private $type; - - /** - * @Column(type="string", name="phrase_type_abbreviation", unique=true) - */ - private $abbreviation; - - /** - * @OneToMany(targetEntity="Phrase", mappedBy="type") - */ - private $phrases; - - public function __construct() { - $this->phrases = new \Doctrine\Common\Collections\ArrayCollection; - } - - /** - * @return int - */ - public function getId(){ - return $this->id; - } - - /** - * @param string $type - * @return void - */ - public function setType($type){ - $this->type = $type; - } - - /** - * @return string - */ - public function getType(){ - return $this->type; - } - - /** - * @param string $abbreviation - * @return void - */ - public function setAbbreviation($abbreviation){ - $this->abbreviation = $abbreviation; - } - - /** - * @return string - */ - public function getAbbreviation(){ - return $this->abbreviation; - } - - /** - * @param ArrayCollection $phrases - * @return void - */ - public function setPhrases($phrases){ - $this->phrases = $phrases; - } - - /** - * - * @return ArrayCollection - */ - public function getPhrases(){ - return $this->phrases; - } - -} - -/** - * @Entity - * @Table(name="definition") - */ -class Definition { - - const CLASS_NAME = __CLASS__; - - /** - * @Id - * @Column(type="integer", name="definition_id") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @ManyToOne(targetEntity="Phrase") - * @JoinColumn(name="definition_phrase_id", referencedColumnName="phrase_id") - */ - private $phrase; - - /** - * @Column(type="text", name="definition_text") - */ - private $definition; - - /** - * @return int - */ - public function getId(){ - return $this->id; - } - - /** - * @param Phrase $phrase - * @return void - */ - public function setPhrase(Phrase $phrase){ - $this->phrase = $phrase; - } - - /** - * @return Phrase - */ - public function getPhrase(){ - return $this->phrase; - } - - public function removePhrase() { - if ($this->phrase !== null) { - /*@var $phrase kateglo\application\models\Phrase */ - $phrase = $this->phrase; - $this->phrase = null; - $phrase->removeDefinition($this); - } - } - - /** - * @param string $definition - * @return void - */ - public function setDefinition($definition){ - $this->definition = $definition; - } - - /** - * @return string - */ - public function getDefinition(){ - return $this->definition; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php deleted file mode 100755 index a5c06e3bd7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php +++ /dev/null @@ -1,183 +0,0 @@ - - */ -class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - protected function setUp() - { - $this->useModelSet('company'); - parent::setUp(); - - $this->generateFixture(); - } - - public function testAggregateWithHavingClause() - { - $dql = 'SELECT p.department, AVG(p.salary) AS avgSalary '. - 'FROM Doctrine\Tests\Models\Company\CompanyEmployee p '. - 'GROUP BY p.department HAVING SUM(p.salary) > 200000 ORDER BY p.department'; - - $result = $this->_em->createQuery($dql)->getScalarResult(); - - $this->assertEquals(2, count($result)); - $this->assertEquals('IT', $result[0]['department']); - $this->assertEquals(150000, $result[0]['avgSalary']); - $this->assertEquals('IT2', $result[1]['department']); - $this->assertEquals(600000, $result[1]['avgSalary']); - } - - public function testUnnamedScalarResultsAreOneBased() - { - $dql = 'SELECT p.department, AVG(p.salary) '. - 'FROM Doctrine\Tests\Models\Company\CompanyEmployee p '. - 'GROUP BY p.department HAVING SUM(p.salary) > 200000 ORDER BY p.department'; - - $result = $this->_em->createQuery($dql)->getScalarResult(); - - $this->assertEquals(2, count($result)); - $this->assertEquals(150000, $result[0][1]); - $this->assertEquals(600000, $result[1][1]); - } - - public function testOrderByResultVariableCollectionSize() - { - $dql = 'SELECT p.name, size(p.friends) AS friends ' . - 'FROM Doctrine\Tests\Models\Company\CompanyPerson p ' . - 'WHERE p.friends IS NOT EMPTY ' . - 'ORDER BY friends DESC, p.name DESC'; - - $result = $this->_em->createQuery($dql)->getScalarResult(); - - $this->assertEquals(4, count($result)); - - $this->assertEquals("Jonathan W.", $result[0]['name']); - $this->assertEquals(3, $result[0]['friends']); - - $this->assertEquals('Guilherme B.', $result[1]['name']); - $this->assertEquals(2, $result[1]['friends']); - - $this->assertEquals('Benjamin E.', $result[2]['name']); - $this->assertEquals(2, $result[2]['friends']); - - $this->assertEquals('Roman B.', $result[3]['name']); - $this->assertEquals(1, $result[3]['friends']); - } - - public function testIsNullAssocation() - { - $dql = 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p '. - 'WHERE p.spouse IS NULL'; - $result = $this->_em->createQuery($dql)->getResult(); - - $this->assertEquals(2, count($result)); - $this->assertTrue($result[0]->getId() > 0); - $this->assertNull($result[0]->getSpouse()); - - $this->assertTrue($result[1]->getId() > 0); - $this->assertNull($result[1]->getSpouse()); - } - - public function testSelectSubselect() - { - $dql = 'SELECT p, (SELECT c.brand FROM Doctrine\Tests\Models\Company\CompanyCar c WHERE p.car = c) brandName '. - 'FROM Doctrine\Tests\Models\Company\CompanyManager p'; - $result = $this->_em->createQuery($dql)->getArrayResult(); - - $this->assertEquals(1, count($result)); - $this->assertEquals("Caramba", $result[0]['brandName']); - } - - public function testInSubselect() - { - $dql = "SELECT p.name FROM Doctrine\Tests\Models\Company\CompanyPerson p ". - "WHERE p.name IN (SELECT n.name FROM Doctrine\Tests\Models\Company\CompanyPerson n WHERE n.name = 'Roman B.')"; - $result = $this->_em->createQuery($dql)->getScalarResult(); - - $this->assertEquals(1, count($result)); - $this->assertEquals('Roman B.', $result[0]['name']); - } - - public function testGroupByMultipleFields() - { - $dql = 'SELECT p.department, p.name, count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p '. - 'GROUP BY p.department, p.name'; - $result = $this->_em->createQuery($dql)->getResult(); - - $this->assertEquals(4, count($result)); - } - - public function testUpdateAs() - { - $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.salary = 1'; - $this->_em->createQuery($dql)->execute(); - - $this->assertTrue(count($this->_em->createQuery( - 'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1')->getResult()) > 0); - } - - public function testDeleteAs() - { - $dql = 'DELETE Doctrine\Tests\Models\Company\CompanyEmployee AS p'; - $this->_em->createQuery($dql)->getResult(); - - $dql = 'SELECT count(p) FROM Doctrine\Tests\Models\Company\CompanyEmployee p'; - $result = $this->_em->createQuery($dql)->getSingleScalarResult(); - - $this->assertEquals(0, $result); - } - - public function generateFixture() - { - $car = new CompanyCar('Caramba'); - - $manager1 = new CompanyManager(); - $manager1->setName('Roman B.'); - $manager1->setTitle('Foo'); - $manager1->setDepartment('IT'); - $manager1->setSalary(100000); - $manager1->setCar($car); - - $person2 = new CompanyEmployee(); - $person2->setName('Benjamin E.'); - $person2->setDepartment('IT'); - $person2->setSalary(200000); - - $person3 = new CompanyEmployee(); - $person3->setName('Guilherme B.'); - $person3->setDepartment('IT2'); - $person3->setSalary(400000); - - $person4 = new CompanyEmployee(); - $person4->setName('Jonathan W.'); - $person4->setDepartment('IT2'); - $person4->setSalary(800000); - - $person2->setSpouse($person3); - - $manager1->addFriend($person4); - $person2->addFriend($person3); - $person2->addFriend($person4); - $person3->addFriend($person4); - - $this->_em->persist($car); - $this->_em->persist($manager1); - $this->_em->persist($person2); - $this->_em->persist($person3); - $this->_em->persist($person4); - $this->_em->flush(); - $this->_em->clear(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php deleted file mode 100755 index 90f8fc5f9d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ /dev/null @@ -1,1299 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testBasicUnitsOfWorkWithOneToManyAssociation() - { - // Create - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'developer'; - $this->_em->persist($user); - - $this->_em->flush(); - - $this->assertTrue(is_numeric($user->id)); - $this->assertTrue($this->_em->contains($user)); - - // Read - $user2 = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id); - $this->assertTrue($user === $user2); - - // Add a phonenumber - $ph = new CmsPhonenumber; - $ph->phonenumber = "12345"; - $user->addPhonenumber($ph); - $this->_em->flush(); - $this->assertTrue($this->_em->contains($ph)); - $this->assertTrue($this->_em->contains($user)); - //$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->phonenumbers); - - // Update name - $user->name = 'guilherme'; - $this->_em->flush(); - $this->assertEquals('guilherme', $user->name); - - // Add another phonenumber - $ph2 = new CmsPhonenumber; - $ph2->phonenumber = "6789"; - $user->addPhonenumber($ph2); - $this->_em->flush(); - $this->assertTrue($this->_em->contains($ph2)); - - // Delete - $this->_em->remove($user); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($user)); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); - $this->_em->flush(); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($user)); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph2)); - } - - public function testOneToManyAssociationModification() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'developer'; - - $ph1 = new CmsPhonenumber; - $ph1->phonenumber = "0301234"; - $ph2 = new CmsPhonenumber; - $ph2->phonenumber = "987654321"; - - $user->addPhonenumber($ph1); - $user->addPhonenumber($ph2); - - $this->_em->persist($user); - $this->_em->flush(); - - //$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->phonenumbers); - - // Remove the first element from the collection - unset($user->phonenumbers[0]); - $ph1->user = null; // owning side! - - $this->_em->flush(); - - $this->assertEquals(1, count($user->phonenumbers)); - $this->assertNull($ph1->user); - } - - public function testBasicOneToOne() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'developer'; - - $address = new CmsAddress; - $address->country = 'Germany'; - $address->city = 'Berlin'; - $address->zip = '12345'; - - $user->address = $address; // inverse side - $address->user = $user; // owning side! - - $this->_em->persist($user); - $this->_em->flush(); - - // Check that the foreign key has been set - $userId = $this->_em->getConnection()->executeQuery( - "SELECT user_id FROM cms_addresses WHERE id=?", array($address->id) - )->fetchColumn(); - $this->assertTrue(is_numeric($userId)); - - $this->_em->clear(); - - $user2 = $this->_em->createQuery('select u from \Doctrine\Tests\Models\CMS\CmsUser u where u.id=?1') - ->setParameter(1, $userId) - ->getSingleResult(); - - // Address has been eager-loaded because it cant be lazy - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $user2->address); - } - - /** - * @group DDC-1230 - */ - public function testRemove() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); - - $this->_em->persist($user); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_MANAGED"); - - $this->_em->remove($user); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); - - $this->_em->persist($user); - $this->_em->flush(); - $id = $user->getId(); - - $this->_em->remove($user); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_REMOVED, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_REMOVED"); - $this->_em->flush(); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); - - $this->assertNull($this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $id)); - } - - public function testOneToManyOrphanRemoval() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - for ($i=0; $i<3; ++$i) { - $phone = new CmsPhonenumber; - $phone->phonenumber = 100 + $i; - $user->addPhonenumber($phone); - } - - $this->_em->persist($user); - - $this->_em->flush(); - - $user->getPhonenumbers()->remove(0); - $this->assertEquals(2, count($user->getPhonenumbers())); - - $this->_em->flush(); - - // Check that there are just 2 phonenumbers left - $count = $this->_em->getConnection()->fetchColumn("SELECT COUNT(*) FROM cms_phonenumbers"); - $this->assertEquals(2, $count); // only 2 remaining - - // check that clear() removes the others via orphan removal - $user->getPhonenumbers()->clear(); - $this->_em->flush(); - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn("select count(*) from cms_phonenumbers")); - } - - public function testBasicQuery() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - $this->_em->persist($user); - $this->_em->flush(); - - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u"); - - $users = $query->getResult(); - - $this->assertEquals(1, count($users)); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('gblanco', $users[0]->username); - $this->assertEquals('developer', $users[0]->status); - //$this->assertNull($users[0]->phonenumbers); - //$this->assertNull($users[0]->articles); - - $usersArray = $query->getArrayResult(); - - $this->assertTrue(is_array($usersArray)); - $this->assertEquals(1, count($usersArray)); - $this->assertEquals('Guilherme', $usersArray[0]['name']); - $this->assertEquals('gblanco', $usersArray[0]['username']); - $this->assertEquals('developer', $usersArray[0]['status']); - - $usersScalar = $query->getScalarResult(); - - $this->assertTrue(is_array($usersScalar)); - $this->assertEquals(1, count($usersScalar)); - $this->assertEquals('Guilherme', $usersScalar[0]['u_name']); - $this->assertEquals('gblanco', $usersScalar[0]['u_username']); - $this->assertEquals('developer', $usersScalar[0]['u_status']); - } - - public function testBasicOneToManyInnerJoin() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - $this->_em->persist($user); - $this->_em->flush(); - - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p"); - - $users = $query->getResult(); - - $this->assertEquals(0, count($users)); - } - - public function testBasicOneToManyLeftJoin() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - $this->_em->persist($user); - $this->_em->flush(); - - $query = $this->_em->createQuery("select u,p from Doctrine\Tests\Models\CMS\CmsUser u left join u.phonenumbers p"); - - $users = $query->getResult(); - - $this->assertEquals(1, count($users)); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('gblanco', $users[0]->username); - $this->assertEquals('developer', $users[0]->status); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->phonenumbers); - $this->assertTrue($users[0]->phonenumbers->isInitialized()); - $this->assertEquals(0, $users[0]->phonenumbers->count()); - //$this->assertNull($users[0]->articles); - } - - public function testBasicRefresh() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->flush(); - - $user->status = 'mascot'; - - $this->assertEquals('mascot', $user->status); - $this->_em->refresh($user); - $this->assertEquals('developer', $user->status); - } - - /** - * @group DDC-833 - */ - public function testRefreshResetsCollection() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - // Add a phonenumber - $ph1 = new CmsPhonenumber; - $ph1->phonenumber = "12345"; - $user->addPhonenumber($ph1); - - // Add a phonenumber - $ph2 = new CmsPhonenumber; - $ph2->phonenumber = "54321"; - - $this->_em->persist($user); - $this->_em->persist($ph1); - $this->_em->persist($ph2); - $this->_em->flush(); - - $user->addPhonenumber($ph2); - - $this->assertEquals(2, count($user->phonenumbers)); - $this->_em->refresh($user); - - $this->assertEquals(1, count($user->phonenumbers)); - } - - /** - * @group DDC-833 - */ - public function testDqlRefreshResetsCollection() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - // Add a phonenumber - $ph1 = new CmsPhonenumber; - $ph1->phonenumber = "12345"; - $user->addPhonenumber($ph1); - - // Add a phonenumber - $ph2 = new CmsPhonenumber; - $ph2->phonenumber = "54321"; - - $this->_em->persist($user); - $this->_em->persist($ph1); - $this->_em->persist($ph2); - $this->_em->flush(); - - $user->addPhonenumber($ph2); - - $this->assertEquals(2, count($user->phonenumbers)); - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"; - $user = $this->_em->createQuery($dql) - ->setParameter(1, $user->id) - ->setHint(Query::HINT_REFRESH, true) - ->getSingleResult(); - - $this->assertEquals(1, count($user->phonenumbers)); - } - - /** - * @group DDC-833 - */ - public function testCreateEntityOfProxy() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - // Add a phonenumber - $ph1 = new CmsPhonenumber; - $ph1->phonenumber = "12345"; - $user->addPhonenumber($ph1); - - // Add a phonenumber - $ph2 = new CmsPhonenumber; - $ph2->phonenumber = "54321"; - - $this->_em->persist($user); - $this->_em->persist($ph1); - $this->_em->persist($ph2); - $this->_em->flush(); - $this->_em->clear(); - - $userId = $user->id; - $user = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->id); - - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"; - $user = $this->_em->createQuery($dql) - ->setParameter(1, $userId) - ->getSingleResult(); - - $this->assertEquals(1, count($user->phonenumbers)); - } - - public function testAddToCollectionDoesNotInitialize() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - for ($i=0; $i<3; ++$i) { - $phone = new CmsPhonenumber; - $phone->phonenumber = 100 + $i; - $user->addPhonenumber($phone); - } - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $this->assertEquals(3, $user->getPhonenumbers()->count()); - - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); - - $gblanco = $query->getSingleResult(); - - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); - - $newPhone = new CmsPhonenumber; - $newPhone->phonenumber = 555; - $gblanco->addPhonenumber($newPhone); - - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); - $this->_em->persist($gblanco); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"); - $gblanco2 = $query->getSingleResult(); - $this->assertEquals(4, $gblanco2->getPhonenumbers()->count()); - } - - public function testInitializeCollectionWithNewObjectsRetainsNewObjects() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - for ($i=0; $i<3; ++$i) { - $phone = new CmsPhonenumber; - $phone->phonenumber = 100 + $i; - $user->addPhonenumber($phone); - } - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $this->assertEquals(3, $user->getPhonenumbers()->count()); - - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); - - $gblanco = $query->getSingleResult(); - - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); - - $newPhone = new CmsPhonenumber; - $newPhone->phonenumber = 555; - $gblanco->addPhonenumber($newPhone); - - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); - $this->assertEquals(4, $gblanco->getPhonenumbers()->count()); - $this->assertTrue($gblanco->getPhonenumbers()->isInitialized()); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"); - $gblanco2 = $query->getSingleResult(); - $this->assertEquals(4, $gblanco2->getPhonenumbers()->count()); - } - - public function testSetSetAssociationWithGetReference() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - $this->_em->persist($user); - - $address = new CmsAddress; - $address->country = 'Germany'; - $address->city = 'Berlin'; - $address->zip = '12345'; - $this->_em->persist($address); - - $this->_em->flush(); - $this->_em->detach($address); - - $this->assertFalse($this->_em->contains($address)); - $this->assertTrue($this->_em->contains($user)); - - // Assume we only got the identifier of the address and now want to attach - // that address to the user without actually loading it, using getReference(). - $addressRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsAddress', $address->getId()); - - //$addressRef->getId(); - //\Doctrine\Common\Util\Debug::dump($addressRef); - - $user->setAddress($addressRef); // Ugh! Initializes address 'cause of $address->setUser($user)! - - $this->_em->flush(); - $this->_em->clear(); - - // Check with a fresh load that the association is indeed there - $query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a where u.username='gblanco'"); - $gblanco = $query->getSingleResult(); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $gblanco); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $gblanco->getAddress()); - $this->assertEquals('Berlin', $gblanco->getAddress()->getCity()); - - } - - public function testOneToManyCascadeRemove() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - for ($i=0; $i<3; ++$i) { - $phone = new CmsPhonenumber; - $phone->phonenumber = 100 + $i; - $user->addPhonenumber($phone); - } - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); - $gblanco = $query->getSingleResult(); - - $this->_em->remove($gblanco); - $this->_em->flush(); - - $this->_em->clear(); - - $this->assertEquals(0, $this->_em->createQuery( - "select count(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p") - ->getSingleScalarResult()); - - $this->assertEquals(0, $this->_em->createQuery( - "select count(u.id) from Doctrine\Tests\Models\CMS\CmsUser u") - ->getSingleScalarResult()); - } - - public function testTextColumnSaveAndRetrieve() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $this->_em->persist($user); - - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article->text = "Lorem ipsum dolor sunt."; - $article->topic = "A Test Article!"; - $article->setAuthor($user); - - $this->_em->persist($article); - $this->_em->flush(); - $articleId = $article->id; - - $this->_em->clear(); - - // test find() with leading backslash at the same time - $articleNew = $this->_em->find('\Doctrine\Tests\Models\CMS\CmsArticle', $articleId); - $this->assertTrue($this->_em->contains($articleNew)); - $this->assertEquals("Lorem ipsum dolor sunt.", $articleNew->text); - - $this->assertNotSame($article, $articleNew); - - $articleNew->text = "Lorem ipsum dolor sunt. And stuff!"; - - $this->_em->flush(); - $this->_em->clear(); - - $articleNew = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $articleId); - $this->assertEquals("Lorem ipsum dolor sunt. And stuff!", $articleNew->text); - $this->assertTrue($this->_em->contains($articleNew)); - } - - public function testFlushDoesNotIssueUnnecessaryUpdates() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $address = new CmsAddress; - $address->country = 'Germany'; - $address->city = 'Berlin'; - $address->zip = '12345'; - - $address->user = $user; - $user->address = $address; - - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article->text = "Lorem ipsum dolor sunt."; - $article->topic = "A Test Article!"; - $article->setAuthor($user); - - $this->_em->persist($article); - $this->_em->persist($user); - - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery('select u,a,ad from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a join u.address ad'); - $user2 = $query->getSingleResult(); - - $this->assertEquals(1, count($user2->articles)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address); - - $oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); - $debugStack = new \Doctrine\DBAL\Logging\DebugStack; - $this->_em->getConnection()->getConfiguration()->setSQLLogger($debugStack); - - $this->_em->flush(); - $this->assertEquals(0, count($debugStack->queries)); - - $this->_em->getConnection()->getConfiguration()->setSQLLogger($oldLogger); - } - - public function testRemoveEntityByReference() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $userRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); - $this->_em->remove($userRef); - $this->_em->flush(); - $this->_em->clear(); - - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn("select count(*) from cms_users")); - - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(null); - } - - public function testQueryEntityByReference() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $address = new CmsAddress; - $address->country = 'Germany'; - $address->city = 'Berlin'; - $address->zip = '12345'; - - $user->setAddress($address); - - $this->_em->transactional(function($em) use($user) { - $em->persist($user); - }); - $this->_em->clear(); - - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $userRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); - $address2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsAddress a where a.user = :user') - ->setParameter('user', $userRef) - ->getSingleResult(); - - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->getUser()); - $this->assertTrue($userRef === $address2->getUser()); - $this->assertFalse($userRef->__isInitialized__); - $this->assertEquals('Germany', $address2->country); - $this->assertEquals('Berlin', $address2->city); - $this->assertEquals('12345', $address2->zip); - } - - public function testOneToOneNullUpdate() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - - $address = new CmsAddress(); - $address->city = "Bonn"; - $address->zip = "12354"; - $address->country = "Germany"; - $address->street = "somestreet"; - $address->user = $user; - - $this->_em->persist($address); - $this->_em->persist($user); - $this->_em->flush(); - - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select 1 from cms_addresses where user_id = ".$user->id)); - - $address->user = null; - $this->_em->flush(); - - $this->assertNotEquals(1, $this->_em->getConnection()->fetchColumn("select 1 from cms_addresses where user_id = ".$user->id)); - } - - /** - * @group DDC-600 - * @group DDC-455 - */ - public function testNewAssociatedEntityDuringFlushThrowsException() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - - $address = new CmsAddress(); - $address->city = "Bonn"; - $address->zip = "12354"; - $address->country = "Germany"; - $address->street = "somestreet"; - $address->user = $user; - - $this->_em->persist($address); - // pretend we forgot to persist $user - try { - $this->_em->flush(); // should raise an exception - $this->fail(); - } catch (\InvalidArgumentException $expected) {} - } - - /** - * @group DDC-600 - * @group DDC-455 - */ - public function testNewAssociatedEntityDuringFlushThrowsException2() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - - $address = new CmsAddress(); - $address->city = "Bonn"; - $address->zip = "12354"; - $address->country = "Germany"; - $address->street = "somestreet"; - $address->user = $user; - - $this->_em->persist($address); - $this->_em->persist($user); - $this->_em->flush(); - - $u2 = new CmsUser; - $u2->username = "beberlei"; - $u2->name = "Benjamin E."; - $u2->status = 'inactive'; - $address->user = $u2; - // pretend we forgot to persist $u2 - try { - $this->_em->flush(); // should raise an exception - $this->fail(); - } catch (\InvalidArgumentException $expected) {} - } - - /** - * @group DDC-600 - * @group DDC-455 - */ - public function testNewAssociatedEntityDuringFlushThrowsException3() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $art = new CmsArticle(); - $art->topic = 'topic'; - $art->text = 'the text'; - - $com = new CmsComment(); - $com->topic = 'Good'; - $com->text = 'Really good!'; - $art->addComment($com); - - $this->_em->persist($art); - // pretend we forgot to persist $com - try { - $this->_em->flush(); // should raise an exception - $this->fail(); - } catch (\InvalidArgumentException $expected) {} - } - - public function testOneToOneOrphanRemoval() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - - $address = new CmsAddress(); - $address->city = "Bonn"; - $address->zip = "12354"; - $address->country = "Germany"; - $address->street = "somestreet"; - $address->user = $user; - $user->address = $address; - - $this->_em->persist($address); - $this->_em->persist($user); - $this->_em->flush(); - $addressId = $address->getId(); - - $user->address = null; - - $this->_em->flush(); - - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn("select count(*) from cms_addresses")); - - // check orphan removal through replacement - $user->address = $address; - $address->user = $user; - - $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select count(*) from cms_addresses")); - - // remove $address to free up unique key id - $this->_em->remove($address); - $this->_em->flush(); - - $newAddress = new CmsAddress(); - $newAddress->city = "NewBonn"; - $newAddress->zip = "12354"; - $newAddress->country = "NewGermany"; - $newAddress->street = "somenewstreet"; - $newAddress->user = $user; - $user->address = $newAddress; - - $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select count(*) from cms_addresses")); - } - - public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - $this->_em->persist($user); - $this->_em->flush(); - $userId = $user->id; - $this->_em->clear(); - - $user = $this->_em->getPartialReference('Doctrine\Tests\Models\CMS\CmsUser', $userId); - $this->assertTrue($this->_em->contains($user)); - $this->assertNull($user->getName()); - $this->assertEquals($userId, $user->id); - - $user->name = 'Stephan'; - $this->_em->flush(); - $this->_em->clear(); - - $this->assertEquals('Benjamin E.', $this->_em->find(get_class($user), $userId)->name); - } - - public function testMergePersistsNewEntities() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - - $managedUser = $this->_em->merge($user); - $this->assertEquals('beberlei', $managedUser->username); - $this->assertEquals('Benjamin E.', $managedUser->name); - $this->assertEquals('active', $managedUser->status); - - $this->assertTrue($user !== $managedUser); - $this->assertTrue($this->_em->contains($managedUser)); - - $this->_em->flush(); - $userId = $managedUser->id; - $this->_em->clear(); - - $user2 = $this->_em->find(get_class($managedUser), $userId); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user2); - } - - public function testMergeNonPersistedProperties() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - $user->nonPersistedProperty = 'test'; - $user->nonPersistedPropertyObject = new CmsPhonenumber(); - - $managedUser = $this->_em->merge($user); - $this->assertEquals('test', $managedUser->nonPersistedProperty); - $this->assertSame($user->nonPersistedProperty, $managedUser->nonPersistedProperty); - $this->assertSame($user->nonPersistedPropertyObject, $managedUser->nonPersistedPropertyObject); - - $this->assertTrue($user !== $managedUser); - $this->assertTrue($this->_em->contains($managedUser)); - - $this->_em->flush(); - $userId = $managedUser->id; - $this->_em->clear(); - - $user2 = $this->_em->find(get_class($managedUser), $userId); - $this->assertNull($user2->nonPersistedProperty); - $this->assertNull($user2->nonPersistedPropertyObject); - $this->assertEquals('active', $user2->status); - } - - public function testMergeThrowsExceptionIfEntityWithGeneratedIdentifierDoesNotExist() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - $user->id = 42; - try { - $this->_em->merge($user); - $this->fail(); - } catch (\Doctrine\ORM\EntityNotFoundException $enfe) {} - } - - /** - * @group DDC-634 - */ - public function testOneToOneMergeSetNull() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - - $ph = new CmsPhonenumber(); - $ph->phonenumber = "12345"; - $user->addPhonenumber($ph); - - $this->_em->persist($user); - $this->_em->persist($ph); - $this->_em->flush(); - - $this->_em->clear(); - - $ph->user = null; - $managedPh = $this->_em->merge($ph); - - $this->_em->flush(); - $this->_em->clear(); - - $this->assertNull($this->_em->find(get_class($ph), $ph->phonenumber)->getUser()); - } - - /** - * @group DDC-952 - */ - public function testManyToOneFetchModeQuery() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin E."; - $user->status = 'active'; - - $article = new CmsArticle(); - $article->topic = "foo"; - $article->text = "bar"; - $article->user = $user; - - $this->_em->persist($article); - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $qc = $this->getCurrentQueryCount(); - $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.id = ?1"; - $article = $this->_em->createQuery($dql) - ->setParameter(1, $article->id) - ->setFetchMode('Doctrine\Tests\Models\CMS\CmsArticle', 'user', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER) - ->getSingleResult(); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $article->user, "It IS a proxy, ..."); - $this->assertTrue($article->user->__isInitialized__, "...but its initialized!"); - $this->assertEquals($qc+2, $this->getCurrentQueryCount()); - } - - /** - * @group DDC-1278 - */ - public function testClearWithEntityName() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $address = new CmsAddress(); - $address->city = "Springfield"; - $address->zip = "12354"; - $address->country = "Germany"; - $address->street = "Foo Street"; - $address->user = $user; - $user->address = $address; - - $article1 = new CmsArticle(); - $article1->topic = 'Foo'; - $article1->text = 'Foo Text'; - - $article2 = new CmsArticle(); - $article2->topic = 'Bar'; - $article2->text = 'Bar Text'; - - $user->addArticle($article1); - $user->addArticle($article2); - - $this->_em->persist($article1); - $this->_em->persist($article2); - $this->_em->persist($address); - $this->_em->persist($user); - $this->_em->flush(); - - $unitOfWork = $this->_em->getUnitOfWork(); - - $this->_em->clear('Doctrine\Tests\Models\CMS\CmsUser'); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($article1)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($article2)); - - $this->_em->clear(); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); - } - - public function testFlushManyExplicitEntities() - { - $userA = new CmsUser; - $userA->username = 'UserA'; - $userA->name = 'UserA'; - - $userB = new CmsUser; - $userB->username = 'UserB'; - $userB->name = 'UserB'; - - $userC = new CmsUser; - $userC->username = 'UserC'; - $userC->name = 'UserC'; - - $this->_em->persist($userA); - $this->_em->persist($userB); - $this->_em->persist($userC); - - $this->_em->flush(array($userA, $userB, $userB)); - - $userC->name = 'changed name'; - - $this->_em->flush(array($userA, $userB)); - $this->_em->refresh($userC); - - $this->assertTrue($userA->id > 0, 'user a has an id'); - $this->assertTrue($userB->id > 0, 'user b has an id'); - $this->assertTrue($userC->id > 0, 'user c has an id'); - $this->assertEquals('UserC', $userC->name, 'name has not changed because we did not flush it'); - } - - /** - * @group DDC-720 - */ - public function testFlushSingleManagedEntity() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->flush(); - - $user->status = 'administrator'; - $this->_em->flush($user); - $this->_em->clear(); - - $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals('administrator', $user->status); - } - - /** - * @group DDC-720 - */ - public function testFlushSingleUnmanagedEntity() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->setExpectedException('InvalidArgumentException', 'Entity has to be managed or scheduled for removal for single computation'); - $this->_em->flush($user); - } - - /** - * @group DDC-720 - */ - public function testFlushSingleAndNewEntity() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->flush(); - - $otherUser = new CmsUser; - $otherUser->name = 'Dominik2'; - $otherUser->username = 'domnikl2'; - $otherUser->status = 'developer'; - - $user->status = 'administrator'; - - $this->_em->persist($otherUser); - $this->_em->flush($user); - - $this->assertTrue($this->_em->contains($otherUser), "Other user is contained in EntityManager"); - $this->assertTrue($otherUser->id > 0, "other user has an id"); - } - - /** - * @group DDC-720 - */ - public function testFlushAndCascadePersist() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->flush(); - - $address = new CmsAddress(); - $address->city = "Springfield"; - $address->zip = "12354"; - $address->country = "Germany"; - $address->street = "Foo Street"; - $address->user = $user; - $user->address = $address; - - $this->_em->flush($user); - - $this->assertTrue($this->_em->contains($address), "Other user is contained in EntityManager"); - $this->assertTrue($address->id > 0, "other user has an id"); - } - - /** - * @group DDC-720 - */ - public function testFlushSingleAndNoCascade() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->flush(); - - $article1 = new CmsArticle(); - $article1->topic = 'Foo'; - $article1->text = 'Foo Text'; - $article1->author = $user; - $user->articles[] = $article1; - - $this->setExpectedException('InvalidArgumentException', "A new entity was found through the relationship 'Doctrine\Tests\Models\CMS\CmsUser#articles'"); - $this->_em->flush($user); - } - - /** - * @group DDC-720 - * @group DDC-1612 - * @group DDC-2267 - */ - public function testFlushSingleNewEntityThenRemove() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->flush($user); - - $userId = $user->id; - - $this->_em->remove($user); - $this->_em->flush($user); - $this->_em->clear(); - - $this->assertNull($this->_em->find(get_class($user), $userId)); - } - - /** - * @group DDC-720 - */ - public function testProxyIsIgnored() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->getReference(get_class($user), $user->id); - - $otherUser = new CmsUser; - $otherUser->name = 'Dominik2'; - $otherUser->username = 'domnikl2'; - $otherUser->status = 'developer'; - - $this->_em->persist($otherUser); - $this->_em->flush($user); - - $this->assertTrue($this->_em->contains($otherUser), "Other user is contained in EntityManager"); - $this->assertTrue($otherUser->id > 0, "other user has an id"); - } - - /** - * @group DDC-720 - */ - public function testFlushSingleSaveOnlySingle() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - $this->_em->persist($user); - - $user2 = new CmsUser; - $user2->name = 'Dominik'; - $user2->username = 'domnikl2'; - $user2->status = 'developer'; - $this->_em->persist($user2); - - $this->_em->flush(); - - $user->status = 'admin'; - $user2->status = 'admin'; - - $this->_em->flush($user); - $this->_em->clear(); - - $user2 = $this->_em->find(get_class($user2), $user2->id); - $this->assertEquals('developer', $user2->status); - } - - /** - * @group DDC-1585 - */ - public function testWrongAssocationInstance() - { - $user = new CmsUser; - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - $user->address = $user; - - $this->_em->persist($user); - - $this->setExpectedException("Doctrine\ORM\ORMException", "Found entity of type Doctrine\Tests\Models\CMS\CmsUser on association Doctrine\Tests\Models\CMS\CmsUser#address, but expecting Doctrine\Tests\Models\CMS\CmsAddress"); - $this->_em->flush(); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php deleted file mode 100755 index c5193eaa73..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ /dev/null @@ -1,497 +0,0 @@ -useModelSet('company'); - parent::setUp(); - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - } - - public function testCRUD() - { - $person = new CompanyPerson; - $person->setName('Roman S. Borschel'); - - $this->_em->persist($person); - - $employee = new CompanyEmployee; - $employee->setName('Roman S. Borschel'); - $employee->setSalary(100000); - $employee->setDepartment('IT'); - - $this->_em->persist($employee); - - $employee->setName('Guilherme Blanco'); - $this->_em->flush(); - - $this->_em->clear(); - - $query = $this->_em->createQuery("select p from Doctrine\Tests\Models\Company\CompanyPerson p order by p.name desc"); - - $entities = $query->getResult(); - - $this->assertEquals(2, count($entities)); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $entities[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[1]); - $this->assertTrue(is_numeric($entities[0]->getId())); - $this->assertTrue(is_numeric($entities[1]->getId())); - $this->assertEquals('Roman S. Borschel', $entities[0]->getName()); - $this->assertEquals('Guilherme Blanco', $entities[1]->getName()); - $this->assertEquals(100000, $entities[1]->getSalary()); - - $this->_em->clear(); - - $query = $this->_em->createQuery("select p from Doctrine\Tests\Models\Company\CompanyEmployee p"); - - $entities = $query->getResult(); - - $this->assertEquals(1, count($entities)); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[0]); - $this->assertTrue(is_numeric($entities[0]->getId())); - $this->assertEquals('Guilherme Blanco', $entities[0]->getName()); - $this->assertEquals(100000, $entities[0]->getSalary()); - - $this->_em->clear(); - - $guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(array('name' => 'Guilherme Blanco')); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $guilherme); - $this->assertEquals('Guilherme Blanco', $guilherme->getName()); - - $this->_em->clear(); - - $query = $this->_em->createQuery("update Doctrine\Tests\Models\Company\CompanyEmployee p set p.name = ?1, p.department = ?2 where p.name='Guilherme Blanco' and p.salary = ?3"); - $query->setParameter(1, 'NewName', 'string'); - $query->setParameter(2, 'NewDepartment'); - $query->setParameter(3, 100000); - $query->getSql(); - $numUpdated = $query->execute(); - $this->assertEquals(1, $numUpdated); - - $query = $this->_em->createQuery("delete from Doctrine\Tests\Models\Company\CompanyPerson p"); - $numDeleted = $query->execute(); - $this->assertEquals(2, $numDeleted); - } - - public function testMultiLevelUpdateAndFind() { - $manager = new CompanyManager; - $manager->setName('Roman S. Borschel'); - $manager->setSalary(100000); - $manager->setDepartment('IT'); - $manager->setTitle('CTO'); - $this->_em->persist($manager); - $this->_em->flush(); - - $manager->setName('Roman B.'); - $manager->setSalary(119000); - $manager->setTitle('CEO'); - $this->_em->persist($manager); - $this->_em->flush(); - - $this->_em->clear(); - - $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); - - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $manager); - $this->assertEquals('Roman B.', $manager->getName()); - $this->assertEquals(119000, $manager->getSalary()); - $this->assertEquals('CEO', $manager->getTitle()); - $this->assertTrue(is_numeric($manager->getId())); - } - - public function testFindOnBaseClass() { - $manager = new CompanyManager; - $manager->setName('Roman S. Borschel'); - $manager->setSalary(100000); - $manager->setDepartment('IT'); - $manager->setTitle('CTO'); - $this->_em->persist($manager); - $this->_em->flush(); - - $this->_em->clear(); - - $person = $this->_em->find('Doctrine\Tests\Models\Company\CompanyPerson', $manager->getId()); - - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $person); - $this->assertEquals('Roman S. Borschel', $person->getName()); - $this->assertEquals(100000, $person->getSalary()); - $this->assertEquals('CTO', $person->getTitle()); - $this->assertTrue(is_numeric($person->getId())); - //$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyCar', $person->getCar()); - } - - public function testSelfReferencingOneToOne() { - $manager = new CompanyManager; - $manager->setName('John Smith'); - $manager->setSalary(100000); - $manager->setDepartment('IT'); - $manager->setTitle('CTO'); - - $wife = new CompanyPerson; - $wife->setName('Mary Smith'); - $wife->setSpouse($manager); - - $this->assertSame($manager, $wife->getSpouse()); - $this->assertSame($wife, $manager->getSpouse()); - - $this->_em->persist($manager); - $this->_em->persist($wife); - - $this->_em->flush(); - - //var_dump($this->_em->getConnection()->fetchAll('select * from company_persons')); - //var_dump($this->_em->getConnection()->fetchAll('select * from company_employees')); - //var_dump($this->_em->getConnection()->fetchAll('select * from company_managers')); - - $this->_em->clear(); - - $query = $this->_em->createQuery('select p, s from Doctrine\Tests\Models\Company\CompanyPerson p join p.spouse s where p.name=\'Mary Smith\''); - - $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]); - $this->assertEquals('Mary Smith', $result[0]->getName()); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[0]->getSpouse()); - $this->assertEquals('John Smith', $result[0]->getSpouse()->getName()); - $this->assertSame($result[0], $result[0]->getSpouse()->getSpouse()); - } - - public function testSelfReferencingManyToMany() - { - $person1 = new CompanyPerson; - $person1->setName('Roman'); - - $person2 = new CompanyPerson; - $person2->setName('Jonathan'); - - $person1->addFriend($person2); - - $this->assertEquals(1, count($person1->getFriends())); - $this->assertEquals(1, count($person2->getFriends())); - - - $this->_em->persist($person1); - $this->_em->persist($person2); - - $this->_em->flush(); - - $this->_em->clear(); - - $query = $this->_em->createQuery('select p, f from Doctrine\Tests\Models\Company\CompanyPerson p join p.friends f where p.name=?1'); - $query->setParameter(1, 'Roman'); - - $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertEquals(1, count($result[0]->getFriends())); - $this->assertEquals('Roman', $result[0]->getName()); - - $friends = $result[0]->getFriends(); - $this->assertEquals('Jonathan', $friends[0]->getName()); - } - - public function testLazyLoading1() - { - $org = new CompanyOrganization; - $event1 = new CompanyAuction; - $event1->setData('auction'); - $org->addEvent($event1); - $event2 = new CompanyRaffle; - $event2->setData('raffle'); - $org->addEvent($event2); - - $this->_em->persist($org); - $this->_em->flush(); - $this->_em->clear(); - - $orgId = $org->getId(); - - $q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyOrganization a where a.id = ?1'); - $q->setParameter(1, $orgId); - - $result = $q->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]); - $this->assertNull($result[0]->getMainEvent()); - - $events = $result[0]->getEvents(); - - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $events); - $this->assertFalse($events->isInitialized()); - - $this->assertEquals(2, count($events)); - if ($events[0] instanceof CompanyAuction) { - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[1]); - } else { - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $events[1]); - } - } - - - public function testLazyLoading2() - { - $org = new CompanyOrganization; - $event1 = new CompanyAuction; - $event1->setData('auction'); - $org->setMainEvent($event1); - - $this->_em->persist($org); - $this->_em->flush(); - $this->_em->clear(); - - $q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyEvent a where a.id = ?1'); - $q->setParameter(1, $event1->getId()); - - $result = $q->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $result[0], sprintf("Is of class %s",get_class($result[0]))); - - $this->_em->clear(); - - $q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyOrganization a where a.id = ?1'); - $q->setParameter(1, $org->getId()); - - $result = $q->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]); - - $mainEvent = $result[0]->getMainEvent(); - // mainEvent should have been loaded because it can't be lazy - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $mainEvent); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $mainEvent); - } - - /** - * @group DDC-368 - */ - public function testBulkUpdateIssueDDC368() - { - $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.salary = 1'; - $this->_em->createQuery($dql)->execute(); - - $this->assertTrue(count($this->_em->createQuery( - 'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1') - ->getResult()) > 0); - } - - /** - * @group DDC-1341 - */ - public function testBulkUpdateNonScalarParameterDDC1341() - { - $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.startDate = ?0 WHERE p.department = ?1'; - $query = $this->_em->createQuery($dql) - ->setParameter(0, new \DateTime()) - ->setParameter(1, 'IT'); - - $result = $query->execute(); - - } - - /** - * @group DDC-130 - */ - public function testDeleteJoinTableRecords() - { - #$this->markTestSkipped('Nightmare! friends adds both ID 6-7 and 7-6 into two rows of the join table. How to detect this?'); - - $employee1 = new CompanyEmployee(); - $employee1->setName('gblanco'); - $employee1->setSalary(0); - $employee1->setDepartment('IT'); - - $employee2 = new CompanyEmployee(); - $employee2->setName('jwage'); - $employee2->setSalary(0); - $employee2->setDepartment('IT'); - - $employee1->addFriend($employee2); - - $this->_em->persist($employee1); - $this->_em->persist($employee2); - $this->_em->flush(); - - $employee1Id = $employee1->getId(); - - $this->_em->remove($employee1); - $this->_em->flush(); - - $this->assertNull($this->_em->find(get_class($employee1), $employee1Id)); - } - - /** - * @group DDC-728 - */ - public function testQueryForInheritedSingleValuedAssociation() - { - $manager = new CompanyManager(); - $manager->setName('gblanco'); - $manager->setSalary(1234); - $manager->setTitle('Awesome!'); - $manager->setDepartment('IT'); - - $person = new CompanyPerson(); - $person->setName('spouse'); - - $manager->setSpouse($person); - - $this->_em->persist($manager); - $this->_em->persist($person); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m WHERE m.spouse = ?1"; - $dqlManager = $this->_em->createQuery($dql)->setParameter(1, $person->getId())->getSingleResult(); - - $this->assertEquals($manager->getId(), $dqlManager->getId()); - $this->assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); - } - - /** - * @group DDC-817 - */ - public function testFindByAssociation() - { - $manager = new CompanyManager(); - $manager->setName('gblanco'); - $manager->setSalary(1234); - $manager->setTitle('Awesome!'); - $manager->setDepartment('IT'); - - $person = new CompanyPerson(); - $person->setName('spouse'); - - $manager->setSpouse($person); - - $this->_em->persist($manager); - $this->_em->persist($person); - $this->_em->flush(); - $this->_em->clear(); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager'); - $pmanager = $repos->findOneBy(array('spouse' => $person->getId())); - - $this->assertEquals($manager->getId(), $pmanager->getId()); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson'); - $pmanager = $repos->findOneBy(array('spouse' => $person->getId())); - - $this->assertEquals($manager->getId(), $pmanager->getId()); - } - - /** - * @group DDC-834 - */ - public function testGetReferenceEntityWithSubclasses() - { - $manager = new CompanyManager(); - $manager->setName('gblanco'); - $manager->setSalary(1234); - $manager->setTitle('Awesome!'); - $manager->setDepartment('IT'); - - $this->_em->persist($manager); - $this->_em->flush(); - $this->_em->clear(); - - $ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyPerson', $manager->getId()); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "Cannot Request a proxy from a class that has subclasses."); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $ref); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $ref, "Direct fetch of the reference has to load the child class Emplyoee directly."); - $this->_em->clear(); - - $ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "A proxy can be generated only if no subclasses exists for the requested reference."); - } - - /** - * @group DDC-992 - */ - public function testGetSubClassManyToManyCollection() - { - $manager = new CompanyManager(); - $manager->setName('gblanco'); - $manager->setSalary(1234); - $manager->setTitle('Awesome!'); - $manager->setDepartment('IT'); - - $person = new CompanyPerson(); - $person->setName('friend'); - - $manager->addFriend($person); - - $this->_em->persist($manager); - $this->_em->persist($person); - $this->_em->flush(); - $this->_em->clear(); - - $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); - $this->assertEquals(1, count($manager->getFriends())); - } - - /** - * @group DDC-1777 - */ - public function testExistsSubclass() - { - $manager = new CompanyManager(); - $manager->setName('gblanco'); - $manager->setSalary(1234); - $manager->setTitle('Awesome!'); - $manager->setDepartment('IT'); - - $this->assertFalse($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); - - $this->_em->persist($manager); - $this->_em->flush(); - - $this->assertTrue($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); - } - - /** - * @group DDC-1637 - */ - public function testMatching() - { - $manager = new CompanyManager(); - $manager->setName('gblanco'); - $manager->setSalary(1234); - $manager->setTitle('Awesome!'); - $manager->setDepartment('IT'); - - $this->_em->persist($manager); - $this->_em->flush(); - - $repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyEmployee"); - $users = $repository->matching(new Criteria( - Criteria::expr()->eq('department', 'IT') - )); - $this->assertEquals(1, count($users)); - - $repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyManager"); - $users = $repository->matching(new Criteria( - Criteria::expr()->eq('department', 'IT') - )); - $this->assertEquals(1, count($users)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php deleted file mode 100755 index 531b10020c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php +++ /dev/null @@ -1,176 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIParent'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIChild'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated2') - )); - } catch (\Exception $ignored) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - - public function testOneToOneAssocToBaseTypeBidirectional() - { - $child = new CTIChild; - $child->setData('hello'); - - $related = new CTIRelated; - $related->setCTIParent($child); - - $this->_em->persist($related); - $this->_em->persist($child); - - $this->_em->flush(); - $this->_em->clear(); - - $relatedId = $related->getId(); - - $related2 = $this->_em->find('Doctrine\Tests\ORM\Functional\CTIRelated', $relatedId); - - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIRelated', $related2); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $related2->getCTIParent()); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $related2->getCTIParent()); - $this->assertEquals('hello', $related2->getCTIParent()->getData()); - - $this->assertSame($related2, $related2->getCTIParent()->getRelated()); - } - - public function testManyToManyToCTIHierarchy() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); - $mmrel = new CTIRelated2; - $child = new CTIChild; - $child->setData('child'); - $mmrel->addCTIChild($child); - - $this->_em->persist($mmrel); - $this->_em->persist($child); - - $this->_em->flush(); - $this->_em->clear(); - - $mmrel2 = $this->_em->find(get_class($mmrel), $mmrel->getId()); - $this->assertFalse($mmrel2->getCTIChildren()->isInitialized()); - $this->assertEquals(1, count($mmrel2->getCTIChildren())); - $this->assertTrue($mmrel2->getCTIChildren()->isInitialized()); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $mmrel2->getCTIChildren()->get(0)); - } -} - -/** - * @Entity @Table(name="cti_parents") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"parent" = "CTIParent", "child" = "CTIChild"}) - */ -class CTIParent { - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** @OneToOne(targetEntity="CTIRelated", mappedBy="ctiParent") */ - private $related; - - public function getId() { - return $this->id; - } - - public function getRelated() { - return $this->related; - } - - public function setRelated($related) { - $this->related = $related; - $related->setCTIParent($this); - } -} - -/** - * @Entity @Table(name="cti_children") - */ -class CTIChild extends CTIParent { - /** - * @Column(type="string") - */ - private $data; - - public function getData() { - return $this->data; - } - - public function setData($data) { - $this->data = $data; - } - -} - -/** @Entity */ -class CTIRelated { - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @OneToOne(targetEntity="CTIParent") - * @JoinColumn(name="ctiparent_id", referencedColumnName="id") - */ - private $ctiParent; - - public function getId() { - return $this->id; - } - - public function getCTIParent() { - return $this->ctiParent; - } - - public function setCTIParent($ctiParent) { - $this->ctiParent = $ctiParent; - } -} - -/** @Entity */ -class CTIRelated2 -{ - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - /** @ManyToMany(targetEntity="CTIChild") */ - private $ctiChildren; - - - public function __construct() { - $this->ctiChildren = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function getId() { - return $this->id; - } - - public function addCTIChild(CTIChild $child) { - $this->ctiChildren->add($child); - } - - public function getCTIChildren() { - return $this->ctiChildren; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php deleted file mode 100755 index e86edb5b7b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -class ClearEventTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - protected function setUp() { - parent::setUp(); - } - - public function testEventIsCalledOnClear() - { - $listener = new OnClearListener; - $this->_em->getEventManager()->addEventListener(Events::onClear, $listener); - - $this->_em->clear(); - - $this->assertTrue($listener->called); - } -} - -class OnClearListener -{ - public $called = false; - - public function onClear(OnClearEventArgs $args) - { - $this->called = true; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php deleted file mode 100755 index 1af930a0cf..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ /dev/null @@ -1,144 +0,0 @@ -useModelSet('navigation'); - parent::setUp(); - } - - public function putGermanysBrandenburderTor() - { - $country = new NavCountry("Germany"); - $this->_em->persist($country); - $poi = new NavPointOfInterest(100, 200, "Brandenburger Tor", $country); - $this->_em->persist($poi); - $this->_em->flush(); - $this->_em->clear(); - } - - public function putTripAroundEurope() - { - $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); - - $tour = new NavTour("Trip around Europe"); - $tour->addPointOfInterest($poi); - - $this->_em->persist($tour); - $this->_em->flush(); - $this->_em->clear(); - - return $tour; - } - - public function testPersistCompositePkEntity() - { - $this->putGermanysBrandenburderTor(); - - $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); - - $this->assertInstanceOf('Doctrine\Tests\Models\Navigation\NavPointOfInterest', $poi); - $this->assertEquals(100, $poi->getLat()); - $this->assertEquals(200, $poi->getLong()); - $this->assertEquals('Brandenburger Tor', $poi->getName()); - } - - /** - * @group DDC-1651 - */ - public function testSetParameterCompositeKeyObject() - { - $this->putGermanysBrandenburderTor(); - - $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); - $photo = new NavPhotos($poi, "asdf"); - $this->_em->persist($photo); - $this->_em->flush(); - $this->_em->clear(); - - $dql = 'SELECT t FROM Doctrine\Tests\Models\Navigation\NavPhotos t WHERE t.poi = ?1'; - - $this->setExpectedException('Doctrine\ORM\Query\QueryException', 'A single-valued association path expression to an entity with a composite primary key is not supported.'); - $sql = $this->_em->createQuery($dql)->getSQL(); - } - - public function testManyToManyCompositeRelation() - { - $this->putGermanysBrandenburderTor(); - $tour = $this->putTripAroundEurope(); - - $tour = $this->_em->find('Doctrine\Tests\Models\Navigation\NavTour', $tour->getId()); - - $this->assertEquals(1, count($tour->getPointOfInterests())); - } - - public function testCompositeDqlEagerFetching() - { - $this->putGermanysBrandenburderTor(); - $this->putTripAroundEurope(); - - $dql = 'SELECT t, p, c FROM Doctrine\Tests\Models\Navigation\NavTour t ' . - 'INNER JOIN t.pois p INNER JOIN p.country c'; - $tours = $this->_em->createQuery($dql)->getResult(); - - $this->assertEquals(1, count($tours)); - - $pois = $tours[0]->getPointOfInterests(); - - $this->assertEquals(1, count($pois)); - $this->assertEquals('Brandenburger Tor', $pois[0]->getName()); - } - - public function testCompositeCollectionMemberExpression() - { - $this->markTestSkipped('How to test this?'); - - $this->putGermanysBrandenburderTor(); - $this->putTripAroundEurope(); - - $dql = 'SELECT t FROM Doctrine\Tests\Models\Navigation\NavTour t, Doctrine\Tests\Models\Navigation\NavPointOfInterest p ' . - 'WHERE p MEMBER OF t.pois'; - $tours = $this->_em->createQuery($dql) - ->getResult(); - - $this->assertEquals(1, count($tours)); - } - - public function testSpecifiyUnknownIdentifierPrimaryKeyFails() - { - $this->setExpectedException('Doctrine\ORM\ORMException', 'The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); - $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('key1' => 100)); - } - - /** - * @group DDC-1939 - */ - public function testDeleteCompositePersistentCollection() - { - $this->putGermanysBrandenburderTor(); - - $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); - $poi->addVisitor(new NavUser("test1")); - $poi->addVisitor(new NavUser("test2")); - - $this->_em->flush(); - - $poi->getVisitors()->clear(); - - $this->_em->flush(); - $this->_em->clear(); - - $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); - $this->assertEquals(0, count($poi->getVisitors())); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CustomTreeWalkersTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CustomTreeWalkersTest.php deleted file mode 100755 index 72fc6d587b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CustomTreeWalkersTest.php +++ /dev/null @@ -1,157 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Functional; - -use Doctrine\ORM\Query; - -require_once __DIR__ . '/../../TestInit.php'; - -/** - * Test case for custom AST walking and modification. - * - * @author Roman Borschel - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link http://www.doctrine-project.org - * @since 2.0 - */ -class CustomTreeWalkersTest extends \Doctrine\Tests\OrmTestCase -{ - private $_em; - - protected function setUp() - { - $this->_em = $this->_getTestEntityManager(); - } - - public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed) - { - try { - $query = $this->_em->createQuery($dqlToBeTested); - $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\Tests\ORM\Functional\CustomTreeWalker')) - ->useQueryCache(false); - - $this->assertEquals($sqlToBeConfirmed, $query->getSql()); - $query->free(); - } catch (\Exception $e) { - $this->fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); - - } - } - - public function testSupportsQueriesWithoutWhere() - { - $this->assertSqlGeneration( - 'select u from Doctrine\Tests\Models\CMS\CmsUser u', - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ WHERE c0_.id = 1" - ); - } - - public function testSupportsQueriesWithMultipleConditionalExpressions() - { - $this->assertSqlGeneration( - 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.name = :name or u.name = :otherName', - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ WHERE (c0_.name = ? OR c0_.name = ?) AND c0_.id = 1" - ); - } - - public function testSupportsQueriesWithSimpleConditionalExpression() - { - $this->assertSqlGeneration( - 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.name = :name', - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ WHERE c0_.name = ? AND c0_.id = 1" - ); - } -} - -class CustomTreeWalker extends Query\TreeWalkerAdapter -{ - public function walkSelectStatement(Query\AST\SelectStatement $selectStatement) - { - // Get the DQL aliases of all the classes we want to modify - $dqlAliases = array(); - - foreach ($this->_getQueryComponents() as $dqlAlias => $comp) { - // Hard-coded check just for demonstration: We want to modify the query if - // it involves the CmsUser class. - if ($comp['metadata']->name == 'Doctrine\Tests\Models\CMS\CmsUser') { - $dqlAliases[] = $dqlAlias; - } - } - - // Create our conditions for all involved classes - $factors = array(); - foreach ($dqlAliases as $alias) { - $pathExpr = new Query\AST\PathExpression(Query\AST\PathExpression::TYPE_STATE_FIELD, $alias, 'id'); - $pathExpr->type = Query\AST\PathExpression::TYPE_STATE_FIELD; - $comparisonExpr = new Query\AST\ComparisonExpression($pathExpr, '=', 1); - - $condPrimary = new Query\AST\ConditionalPrimary; - $condPrimary->simpleConditionalExpression = $comparisonExpr; - - $factor = new Query\AST\ConditionalFactor($condPrimary); - $factors[] = $factor; - } - - if (($whereClause = $selectStatement->whereClause) !== null) { - // There is already a WHERE clause, so append the conditions - $condExpr = $whereClause->conditionalExpression; - - // Since Phase 1 AST optimizations were included, we need to re-add the ConditionalExpression - if ( ! ($condExpr instanceof Query\AST\ConditionalExpression)) { - $condExpr = new Query\AST\ConditionalExpression(array($condExpr)); - - $whereClause->conditionalExpression = $condExpr; - } - - $existingTerms = $whereClause->conditionalExpression->conditionalTerms; - - if (count($existingTerms) > 1) { - // More than one term, so we need to wrap all these terms in a single root term - // i.e: "WHERE u.name = :foo or u.other = :bar" => "WHERE (u.name = :foo or u.other = :bar) AND " - - $primary = new Query\AST\ConditionalPrimary; - $primary->conditionalExpression = new Query\AST\ConditionalExpression($existingTerms); - $existingFactor = new Query\AST\ConditionalFactor($primary); - $term = new Query\AST\ConditionalTerm(array_merge(array($existingFactor), $factors)); - - $selectStatement->whereClause->conditionalExpression->conditionalTerms = array($term); - } else { - // Just one term so we can simply append our factors to that term - $singleTerm = $selectStatement->whereClause->conditionalExpression->conditionalTerms[0]; - - // Since Phase 1 AST optimizations were included, we need to re-add the ConditionalExpression - if ( ! ($singleTerm instanceof Query\AST\ConditionalTerm)) { - $singleTerm = new Query\AST\ConditionalTerm(array($singleTerm)); - - $selectStatement->whereClause->conditionalExpression->conditionalTerms[0] = $singleTerm; - } - - $singleTerm->conditionalFactors = array_merge($singleTerm->conditionalFactors, $factors); - $selectStatement->whereClause->conditionalExpression->conditionalTerms = array($singleTerm); - } - } else { - // Create a new WHERE clause with our factors - $term = new Query\AST\ConditionalTerm($factors); - $condExpr = new Query\AST\ConditionalExpression(array($term)); - $whereClause = new Query\AST\WhereClause($condExpr); - $selectStatement->whereClause = $whereClause; - } - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php deleted file mode 100755 index 0c30a0bef6..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ /dev/null @@ -1,148 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - - $this->_sm = $this->_em->getConnection()->getSchemaManager(); - } - - /** - * @group DDC-2059 - */ - public function testIssue2059() - { - if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); - } - - $user = new \Doctrine\DBAL\Schema\Table("ddc2059_user"); - $user->addColumn('id', 'integer'); - $user->setPrimaryKey(array('id')); - $project = new \Doctrine\DBAL\Schema\Table("ddc2059_project"); - $project->addColumn('id', 'integer'); - $project->addColumn('user_id', 'integer'); - $project->addColumn('user', 'string'); - $project->setPrimaryKey(array('id')); - $project->addForeignKeyConstraint('ddc2059_user', array('user_id'), array('id')); - - $metadata = $this->convertToClassMetadata(array($project, $user), array()); - - $this->assertTrue(isset($metadata['Ddc2059Project']->fieldMappings['user'])); - $this->assertTrue(isset($metadata['Ddc2059Project']->associationMappings['user2'])); - } - - public function testLoadMetadataFromDatabase() - { - if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); - } - - $table = new \Doctrine\DBAL\Schema\Table("dbdriver_foo"); - $table->addColumn('id', 'integer'); - $table->setPrimaryKey(array('id')); - $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 200)); - - $this->_sm->dropAndCreateTable($table); - - $metadatas = $this->extractClassMetadata(array("DbdriverFoo")); - - $this->assertArrayHasKey('DbdriverFoo', $metadatas); - $metadata = $metadatas['DbdriverFoo']; - - $this->assertArrayHasKey('id', $metadata->fieldMappings); - $this->assertEquals('id', $metadata->fieldMappings['id']['fieldName']); - $this->assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); - $this->assertEquals('integer', (string)$metadata->fieldMappings['id']['type']); - - $this->assertArrayHasKey('bar', $metadata->fieldMappings); - $this->assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']); - $this->assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName'])); - $this->assertEquals('string', (string)$metadata->fieldMappings['bar']['type']); - $this->assertEquals(200, $metadata->fieldMappings['bar']['length']); - $this->assertTrue($metadata->fieldMappings['bar']['nullable']); - } - - public function testLoadMetadataWithForeignKeyFromDatabase() - { - if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); - } - - $tableB = new \Doctrine\DBAL\Schema\Table("dbdriver_bar"); - $tableB->addColumn('id', 'integer'); - $tableB->setPrimaryKey(array('id')); - - $this->_sm->dropAndCreateTable($tableB); - - $tableA = new \Doctrine\DBAL\Schema\Table("dbdriver_baz"); - $tableA->addColumn('id', 'integer'); - $tableA->setPrimaryKey(array('id')); - $tableA->addColumn('bar_id', 'integer'); - $tableA->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id')); - - $this->_sm->dropAndCreateTable($tableA); - - $metadatas = $this->extractClassMetadata(array("DbdriverBar", "DbdriverBaz")); - - $this->assertArrayHasKey('DbdriverBaz', $metadatas); - $bazMetadata = $metadatas['DbdriverBaz']; - - $this->assertArrayNotHasKey('barId', $bazMetadata->fieldMappings, "The foreign Key field should not be inflected as 'barId' field, its an association."); - $this->assertArrayHasKey('id', $bazMetadata->fieldMappings); - - $bazMetadata->associationMappings = \array_change_key_case($bazMetadata->associationMappings, \CASE_LOWER); - - $this->assertArrayHasKey('bar', $bazMetadata->associationMappings); - $this->assertEquals(ClassMetadataInfo::MANY_TO_ONE, $bazMetadata->associationMappings['bar']['type']); - } - - public function testDetectManyToManyTables() - { - if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); - } - - $metadatas = $this->extractClassMetadata(array("CmsUsers", "CmsGroups")); - - $this->assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.'); - $this->assertArrayHasKey('CmsGroups', $metadatas, 'CmsGroups entity was not detected.'); - - $this->assertEquals(2, count($metadatas['CmsUsers']->associationMappings)); - $this->assertArrayHasKey('group', $metadatas['CmsUsers']->associationMappings); - $this->assertEquals(1, count($metadatas['CmsGroups']->associationMappings)); - $this->assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); - } - - public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails() - { - $tableB = new \Doctrine\DBAL\Schema\Table("dbdriver_bar"); - $tableB->addColumn('id', 'integer'); - $tableB->setPrimaryKey(array('id')); - - $tableA = new \Doctrine\DBAL\Schema\Table("dbdriver_baz"); - $tableA->addColumn('id', 'integer'); - $tableA->setPrimaryKey(array('id')); - - $tableMany = new \Doctrine\DBAL\Schema\Table("dbdriver_bar_baz"); - $tableMany->addColumn('bar_id', 'integer'); - $tableMany->addColumn('baz_id', 'integer'); - $tableMany->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id')); - - $metadatas = $this->convertToClassMetadata(array($tableA, $tableB), array($tableMany)); - - $this->assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), "no association mappings should be detected."); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php deleted file mode 100755 index 35fd8b20c5..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php +++ /dev/null @@ -1,55 +0,0 @@ -_em->getConnection()->getSchemaManager(); - $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($sm); - $driver->setTables($entityTables, $manyTables); - - $metadatas = array(); - foreach ($driver->getAllClassNames() AS $className) { - $class = new ClassMetadataInfo($className); - $driver->loadMetadataForClass($className, $class); - $metadatas[$className] = $class; - } - - return $metadatas; - } - - /** - * @param string $className - * @return ClassMetadata - */ - protected function extractClassMetadata(array $classNames) - { - $classNames = array_map('strtolower', $classNames); - $metadatas = array(); - - $sm = $this->_em->getConnection()->getSchemaManager(); - $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($sm); - - foreach ($driver->getAllClassNames() as $className) { - if (!in_array(strtolower($className), $classNames)) { - continue; - } - $class = new ClassMetadataInfo($className); - $driver->loadMetadataForClass($className, $class); - $metadatas[$className] = $class; - } - - if (count($metadatas) != count($classNames)) { - $this->fail("Have not found all classes matching the names '" . implode(", ", $classNames) . "' only tables " . implode(", ", array_keys($metadatas))); - } - return $metadatas; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php deleted file mode 100755 index 11511a0793..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ /dev/null @@ -1,150 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueUser'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueAddress') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - - public function testSimpleDetachMerge() { - $user = new DefaultValueUser; - $user->name = 'romanb'; - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $userId = $user->id; // e.g. from $_REQUEST - $user2 = $this->_em->getReference(get_class($user), $userId); - - $this->_em->flush(); - $this->assertFalse($user2->__isInitialized__); - - $a = new DefaultValueAddress; - $a->country = 'de'; - $a->zip = '12345'; - $a->city = 'Berlin'; - $a->street = 'Sesamestreet'; - - $a->user = $user2; - $this->_em->persist($a); - $this->_em->flush(); - - $this->assertFalse($user2->__isInitialized__); - $this->_em->clear(); - - $a2 = $this->_em->find(get_class($a), $a->id); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\DefaultValueUser', $a2->getUser()); - $this->assertEquals($userId, $a2->getUser()->getId()); - $this->assertEquals('Poweruser', $a2->getUser()->type); - } - - /** - * @group DDC-1386 - */ - public function testGetPartialReferenceWithDefaultValueNotEvalutedInFlush() - { - $user = new DefaultValueUser; - $user->name = 'romanb'; - $user->type = 'Normaluser'; - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->getPartialReference('Doctrine\Tests\ORM\Functional\DefaultValueUser', $user->id); - $this->assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); - - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find('Doctrine\Tests\ORM\Functional\DefaultValueUser', $user->id); - - $this->assertEquals('Normaluser', $user->type); - } -} - - -/** - * @Entity @Table(name="defaultvalueuser") - */ -class DefaultValueUser -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - /** - * @Column(type="string") - */ - public $name = ''; - /** - * @Column(type="string") - */ - public $type = 'Poweruser'; - /** - * @OneToOne(targetEntity="DefaultValueAddress", mappedBy="user", cascade={"persist"}) - */ - public $address; - - public function getId() {return $this->id;} -} - -/** - * CmsAddress - * - * @Entity @Table(name="defaultvalueaddresses") - */ -class DefaultValueAddress -{ - /** - * @Column(type="integer") - * @Id @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @Column(type="string", length=50) - */ - public $country; - - /** - * @Column(type="string", length=50) - */ - public $zip; - - /** - * @Column(type="string", length=50) - */ - public $city; - - /** - * Testfield for Schema Updating Tests. - */ - public $street; - - /** - * @OneToOne(targetEntity="DefaultValueUser") - * @JoinColumn(name="user_id", referencedColumnName="id") - */ - public $user; - - public function getUser() {return $this->user;} -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php deleted file mode 100755 index f5c50eb119..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ /dev/null @@ -1,218 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testSimpleDetachMerge() { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - // $user is now detached - - $this->assertFalse($this->_em->contains($user)); - - $user->name = 'Roman B.'; - - //$this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_em->getUnitOfWork()->getEntityState($user)); - - $user2 = $this->_em->merge($user); - - $this->assertFalse($user === $user2); - $this->assertTrue($this->_em->contains($user2)); - $this->assertEquals('Roman B.', $user2->name); - } - - public function testSerializeUnserializeModifyMerge() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $ph1 = new CmsPhonenumber; - $ph1->phonenumber = "1234"; - $user->addPhonenumber($ph1); - - $this->_em->persist($user); - $this->_em->flush(); - $this->assertTrue($this->_em->contains($user)); - $this->assertTrue($user->phonenumbers->isInitialized()); - - $serialized = serialize($user); - $this->_em->clear(); - $this->assertFalse($this->_em->contains($user)); - unset($user); - - $user = unserialize($serialized); - - $this->assertEquals(1, count($user->getPhonenumbers()), "Pre-Condition: 1 Phonenumber"); - - $ph2 = new CmsPhonenumber; - $ph2->phonenumber = "56789"; - $user->addPhonenumber($ph2); - $oldPhonenumbers = $user->getPhonenumbers(); - $this->assertEquals(2, count($oldPhonenumbers), "Pre-Condition: 2 Phonenumbers"); - $this->assertFalse($this->_em->contains($user)); - - $this->_em->persist($ph2); - - // Merge back in - $user = $this->_em->merge($user); // merge cascaded to phonenumbers - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user->phonenumbers[0]->user); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user->phonenumbers[1]->user); - $im = $this->_em->getUnitOfWork()->getIdentityMap(); - $this->_em->flush(); - - $this->assertTrue($this->_em->contains($user), "Failed to assert that merged user is contained inside EntityManager persistence context."); - $phonenumbers = $user->getPhonenumbers(); - $this->assertNotSame($oldPhonenumbers, $phonenumbers, "Merge should replace the Detached Collection with a new PersistentCollection."); - $this->assertEquals(2, count($phonenumbers), "Failed to assert that two phonenumbers are contained in the merged users phonenumber collection."); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $phonenumbers[1]); - $this->assertTrue($this->_em->contains($phonenumbers[1]), "Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context."); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $phonenumbers[0]); - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($phonenumbers[0])); - $this->assertTrue($this->_em->contains($phonenumbers[0]), "Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context."); - } - - /** - * @group DDC-203 - */ - public function testDetachedEntityThrowsExceptionOnFlush() - { - $ph = new CmsPhonenumber(); - $ph->phonenumber = '12345'; - $this->_em->persist($ph); - $this->_em->flush(); - $this->_em->clear(); - $this->_em->persist($ph); - try { - $this->_em->flush(); - $this->fail(); - } catch (\Exception $expected) {} - } - - public function testUninitializedLazyAssociationsAreIgnoredOnMerge() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $address = new CmsAddress; - $address->city = 'Berlin'; - $address->country = 'Germany'; - $address->street = 'Sesamestreet'; - $address->zip = 12345; - $address->setUser($user); - $this->_em->persist($address); - $this->_em->persist($user); - - $this->_em->flush(); - $this->_em->clear(); - - $address2 = $this->_em->find(get_class($address), $address->id); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->user); - $this->assertFalse($address2->user->__isInitialized__); - $detachedAddress2 = unserialize(serialize($address2)); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $detachedAddress2->user); - $this->assertFalse($detachedAddress2->user->__isInitialized__); - - $managedAddress2 = $this->_em->merge($detachedAddress2); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $managedAddress2->user); - $this->assertFalse($managedAddress2->user === $detachedAddress2->user); - $this->assertFalse($managedAddress2->user->__isInitialized__); - } - - /** - * @group DDC-822 - */ - public function testUseDetachedEntityAsQueryParameter() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $this->_em->persist($user); - - $this->_em->flush(); - $this->_em->detach($user); - - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"; - $query = $this->_em->createQuery($dql); - $query->setParameter(1, $user); - - $newUser = $query->getSingleResult(); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $newUser); - $this->assertEquals('gblanco', $newUser->username); - } - - /** - * @group DDC-920 - */ - public function testDetachManagedUnpersistedEntity() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->detach($user); - - $this->_em->flush(); - - $this->assertFalse($this->_em->contains($user)); - $this->assertFalse($this->_em->getUnitOfWork()->isInIdentityMap($user)); - } - - /** - * @group DDC-1340 - */ - public function testMergeArticleWrongVersion() - { - $article = new CmsArticle(); - $article->topic = "test"; - $article->text = "test"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->_em->detach($article); - - $sql = "UPDATE cms_articles SET version = version+1 WHERE id = " . $article->id; - $this->_em->getConnection()->executeUpdate($sql); - - $this->setExpectedException('Doctrine\ORM\OptimisticLockException', 'The optimistic lock failed, version 1 was expected, but is actually 2'); - $this->_em->merge($article); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php deleted file mode 100755 index 8631e529d1..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php +++ /dev/null @@ -1,87 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Functional; - -use Doctrine\Tests\Models\Generic\DateTimeModel; -use Doctrine\Common\Collections\Criteria; - -/** - * @author Josiah - */ -class EntityRepositoryCriteriaTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - protected function setUp() - { - $this->useModelSet('generic'); - parent::setUp(); - } - - public function tearDown() - { - if ($this->_em) { - $this->_em->getConfiguration()->setEntityNamespaces(array()); - } - parent::tearDown(); - } - - public function loadFixture() - { - $today = new DateTimeModel(); - $today->datetime = - $today->date = - $today->time = - new \DateTime('today'); - $this->_em->persist($today); - - $tomorrow = new DateTimeModel(); - $tomorrow->datetime = - $tomorrow->date = - $tomorrow->time = - new \DateTime('tomorrow'); - $this->_em->persist($tomorrow); - - $yesterday = new DateTimeModel(); - $yesterday->datetime = - $yesterday->date = - $yesterday->time = - new \DateTime('yesterday'); - $this->_em->persist($yesterday); - - $this->_em->flush(); - - unset($today); - unset($tomorrow); - unset($yesterday); - - $this->_em->clear(); - } - - public function testLteDateComparison() - { - $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\Generic\DateTimeModel'); - $dates = $repository->matching(new Criteria( - Criteria::expr()->lte('datetime', new \DateTime('today')) - )); - - $this->assertEquals(2, count($dates)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php deleted file mode 100755 index 46f8201f30..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ /dev/null @@ -1,710 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function tearDown() - { - if ($this->_em) { - $this->_em->getConfiguration()->setEntityNamespaces(array()); - } - parent::tearDown(); - } - - public function loadFixture() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'freak'; - $this->_em->persist($user); - - $user2 = new CmsUser; - $user2->name = 'Guilherme'; - $user2->username = 'gblanco'; - $user2->status = 'dev'; - $this->_em->persist($user2); - - $user3 = new CmsUser; - $user3->name = 'Benjamin'; - $user3->username = 'beberlei'; - $user3->status = null; - $this->_em->persist($user3); - - $user4 = new CmsUser; - $user4->name = 'Alexander'; - $user4->username = 'asm89'; - $user4->status = 'dev'; - $this->_em->persist($user4); - - $this->_em->flush(); - - $user1Id = $user->getId(); - - unset($user); - unset($user2); - unset($user3); - unset($user4); - - $this->_em->clear(); - - return $user1Id; - } - - public function loadAssociatedFixture() - { - $address = new CmsAddress(); - $address->city = "Berlin"; - $address->country = "Germany"; - $address->street = "Foostreet"; - $address->zip = "12345"; - - $user = new CmsUser(); - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'freak'; - $user->setAddress($address); - - $this->_em->persist($user); - $this->_em->persist($address); - $this->_em->flush(); - $this->_em->clear(); - - return array($user->id, $address->id); - } - - public function buildUser($name, $username, $status, $address) - { - $user = new CmsUser(); - $user->name = $name; - $user->username = $username; - $user->status = $status; - $user->setAddress($address); - - $this->_em->persist($user); - $this->_em->flush(); - - return $user; - } - - public function buildAddress($country, $city, $street, $zip) - { - $address = new CmsAddress(); - $address->country = $country; - $address->city = $city; - $address->street = $street; - $address->zip = $zip; - - $this->_em->persist($address); - $this->_em->flush(); - - return $address; - } - - public function testBasicFind() - { - $user1Id = $this->loadFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $user = $repos->find($user1Id); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$user); - $this->assertEquals('Roman', $user->name); - $this->assertEquals('freak', $user->status); - } - - public function testFindByField() - { - $user1Id = $this->loadFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $users = $repos->findBy(array('status' => 'dev')); - $this->assertEquals(2, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('dev', $users[0]->status); - } - - public function testFindByAssociationWithIntegerAsParameter() - { - $address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456'); - $user1 = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1); - - $address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321'); - $user2 = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2); - - $address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654'); - $user3 = $this->buildUser('Jonathan', 'jwage', 'dev', $address3); - - unset($address1); - unset($address2); - unset($address3); - - $this->_em->clear(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); - $addresses = $repository->findBy(array('user' => array($user1->getId(), $user2->getId()))); - - $this->assertEquals(2, count($addresses)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]); - } - - public function testFindByAssociationWithObjectAsParameter() - { - $address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456'); - $user1 = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1); - - $address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321'); - $user2 = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2); - - $address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654'); - $user3 = $this->buildUser('Jonathan', 'jwage', 'dev', $address3); - - unset($address1); - unset($address2); - unset($address3); - - $this->_em->clear(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); - $addresses = $repository->findBy(array('user' => array($user1, $user2))); - - $this->assertEquals(2, count($addresses)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]); - } - - public function testFindFieldByMagicCall() - { - $user1Id = $this->loadFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $users = $repos->findByStatus('dev'); - $this->assertEquals(2, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('dev', $users[0]->status); - } - - public function testFindAll() - { - $user1Id = $this->loadFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $users = $repos->findAll(); - $this->assertEquals(4, count($users)); - } - - public function testFindByAlias() - { - $user1Id = $this->loadFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - - $repos = $this->_em->getRepository('CMS:CmsUser'); - - $users = $repos->findAll(); - $this->assertEquals(4, count($users)); - } - - /** - * @expectedException \Doctrine\ORM\ORMException - */ - public function testExceptionIsThrownWhenCallingFindByWithoutParameter() { - $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') - ->findByStatus(); - } - - /** - * @expectedException \Doctrine\ORM\ORMException - */ - public function testExceptionIsThrownWhenUsingInvalidFieldName() { - $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') - ->findByThisFieldDoesNotExist('testvalue'); - } - - /** - * @group locking - * @group DDC-178 - */ - public function testPessimisticReadLockWithoutTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); - - $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') - ->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ); - } - - /** - * @group locking - * @group DDC-178 - */ - public function testPessimisticWriteLockWithoutTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); - - $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') - ->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE); - } - - /** - * @group locking - * @group DDC-178 - */ - public function testOptimisticLockUnversionedEntity_ThrowsException() - { - $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); - - $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') - ->find(1, \Doctrine\DBAL\LockMode::OPTIMISTIC); - } - - /** - * @group locking - * @group DDC-178 - */ - public function testIdentityMappedOptimisticLockUnversionedEntity_ThrowsException() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'freak'; - $this->_em->persist($user); - $this->_em->flush(); - - $userId = $user->id; - - $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); - - $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); - $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId, \Doctrine\DBAL\LockMode::OPTIMISTIC); - } - - /** - * @group DDC-819 - */ - public function testFindMagicCallByNullValue() - { - $this->loadFixture(); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $users = $repos->findByStatus(null); - $this->assertEquals(1, count($users)); - } - - /** - * @group DDC-819 - */ - public function testInvalidMagicCall() - { - $this->setExpectedException('BadMethodCallException'); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $repos->foo(); - } - - /** - * @group DDC-817 - */ - public function testFindByAssociationKey_ExceptionOnInverseSide() - { - list($userId, $addressId) = $this->loadAssociatedFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $this->setExpectedException('Doctrine\ORM\ORMException', "You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. Find methods only work on owning side associations."); - $user = $repos->findBy(array('address' => $addressId)); - } - - /** - * @group DDC-817 - */ - public function testFindOneByAssociationKey() - { - list($userId, $addressId) = $this->loadAssociatedFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); - $address = $repos->findOneBy(array('user' => $userId)); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address); - $this->assertEquals($addressId, $address->id); - } - - /** - * @group DDC-1241 - */ - public function testFindOneByOrderBy() - { - $this->loadFixture(); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $userAsc = $repos->findOneBy(array(), array("username" => "ASC")); - $userDesc = $repos->findOneBy(array(), array("username" => "DESC")); - - $this->assertNotSame($userAsc, $userDesc); - } - - /** - * @group DDC-817 - */ - public function testFindByAssociationKey() - { - list($userId, $addressId) = $this->loadAssociatedFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); - $addresses = $repos->findBy(array('user' => $userId)); - - $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses); - $this->assertEquals(1, count($addresses)); - $this->assertEquals($addressId, $addresses[0]->id); - } - - /** - * @group DDC-817 - */ - public function testFindAssociationByMagicCall() - { - list($userId, $addressId) = $this->loadAssociatedFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); - $addresses = $repos->findByUser($userId); - - $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses); - $this->assertEquals(1, count($addresses)); - $this->assertEquals($addressId, $addresses[0]->id); - } - - /** - * @group DDC-817 - */ - public function testFindOneAssociationByMagicCall() - { - list($userId, $addressId) = $this->loadAssociatedFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); - $address = $repos->findOneByUser($userId); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address); - $this->assertEquals($addressId, $address->id); - } - - public function testValidNamedQueryRetrieval() - { - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $query = $repos->createNamedQuery('all'); - - $this->assertInstanceOf('Doctrine\ORM\Query', $query); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL()); - } - - public function testInvalidNamedQueryRetrieval() - { - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - - $repos->createNamedQuery('invalidNamedQuery'); - } - - /** - * @group DDC-1087 - */ - public function testIsNullCriteriaDoesNotGenerateAParameter() - { - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repos->findBy(array('status' => null, 'username' => 'romanb')); - - $params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params']; - $this->assertEquals(1, count($params), "Should only execute with one parameter."); - $this->assertEquals(array('romanb'), $params); - } - - public function testIsNullCriteria() - { - $this->loadFixture(); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $users = $repos->findBy(array('status' => null)); - $this->assertEquals(1, count($users)); - } - - /** - * @group DDC-1094 - */ - public function testFindByLimitOffset() - { - $this->loadFixture(); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $users1 = $repos->findBy(array(), null, 1, 0); - $users2 = $repos->findBy(array(), null, 1, 1); - - $this->assertEquals(4, count($repos->findBy(array()))); - $this->assertEquals(1, count($users1)); - $this->assertEquals(1, count($users2)); - $this->assertNotSame($users1[0], $users2[0]); - } - - /** - * @group DDC-1094 - */ - public function testFindByOrderBy() - { - $this->loadFixture(); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $usersAsc = $repos->findBy(array(), array("username" => "ASC")); - $usersDesc = $repos->findBy(array(), array("username" => "DESC")); - - $this->assertEquals(4, count($usersAsc), "Pre-condition: only four users in fixture"); - $this->assertEquals(4, count($usersDesc), "Pre-condition: only four users in fixture"); - $this->assertSame($usersAsc[0], $usersDesc[3]); - $this->assertSame($usersAsc[3], $usersDesc[0]); - } - - /** - * @group DDC-1426 - */ - public function testFindFieldByMagicCallOrderBy() - { - $this->loadFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $usersAsc = $repos->findByStatus('dev', array('username' => "ASC")); - $usersDesc = $repos->findByStatus('dev', array('username' => "DESC")); - - $this->assertEquals(2, count($usersAsc)); - $this->assertEquals(2, count($usersDesc)); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$usersAsc[0]); - $this->assertEquals('Alexander', $usersAsc[0]->name); - $this->assertEquals('dev', $usersAsc[0]->status); - - $this->assertSame($usersAsc[0], $usersDesc[1]); - $this->assertSame($usersAsc[1], $usersDesc[0]); - } - - /** - * @group DDC-1426 - */ - public function testFindFieldByMagicCallLimitOffset() - { - $this->loadFixture(); - $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $users1 = $repos->findByStatus('dev', array(), 1, 0); - $users2 = $repos->findByStatus('dev', array(), 1, 1); - - $this->assertEquals(1, count($users1)); - $this->assertEquals(1, count($users2)); - $this->assertNotSame($users1[0], $users2[0]); - } - - /** - * @group DDC-753 - */ - public function testDefaultRepositoryClassName() - { - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); - $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\DDC753\DDC753EntityWithDefaultCustomRepository'); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC753\DDC753DefaultRepository", $repos); - $this->assertTrue($repos->isDefaultRepository()); - - - $repos = $this->_em->getRepository('Doctrine\Tests\Models\DDC753\DDC753EntityWithCustomRepository'); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC753\DDC753CustomRepository", $repos); - $this->assertTrue($repos->isCustomRepository()); - - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); - $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\ORM\EntityRepository"); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); - - } - - - /** - * @group DDC-753 - * @expectedException Doctrine\ORM\ORMException - * @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. It must be a Doctrine\Common\Persistence\ObjectRepository. - */ - public function testSetDefaultRepositoryInvalidClassError() - { - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); - $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753InvalidRepository"); - } - - /** - * @group DDC-1500 - */ - public function testInvalidOrientation() - { - $this->setExpectedException('Doctrine\ORM\ORMException', 'Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username'); - - $repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $repo->findBy(array('status' => 'test'), array('username' => 'INVALID')); - } - - /** - * @group DDC-1713 - */ - public function testFindByAssocationArray() - { - $repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle'); - $data = $repo->findBy(array('user' => array(1, 2, 3))); - - $query = array_pop($this->_sqlLoggerStack->queries); - $this->assertEquals(array(1,2,3), $query['params'][0]); - $this->assertEquals(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY, $query['types'][0]); - } - - /** - * @group DDC-1637 - */ - public function testMatchingEmptyCriteria() - { - $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria()); - - $this->assertEquals(4, count($users)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingCriteriaEqComparison() - { - $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria( - Criteria::expr()->eq('username', 'beberlei') - )); - - $this->assertEquals(1, count($users)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingCriteriaNeqComparison() - { - $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria( - Criteria::expr()->neq('username', 'beberlei') - )); - - $this->assertEquals(3, count($users)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingCriteriaInComparison() - { - $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria( - Criteria::expr()->in('username', array('beberlei', 'gblanco')) - )); - - $this->assertEquals(2, count($users)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingCriteriaNotInComparison() - { - $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria( - Criteria::expr()->notIn('username', array('beberlei', 'gblanco', 'asm89')) - )); - - $this->assertEquals(1, count($users)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingCriteriaLtComparison() - { - $firstUserId = $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria( - Criteria::expr()->lt('id', $firstUserId + 1) - )); - - $this->assertEquals(1, count($users)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingCriteriaLeComparison() - { - $firstUserId = $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria( - Criteria::expr()->lte('id', $firstUserId + 1) - )); - - $this->assertEquals(2, count($users)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingCriteriaGtComparison() - { - $firstUserId = $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria( - Criteria::expr()->gt('id', $firstUserId) - )); - - $this->assertEquals(3, count($users)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingCriteriaGteComparison() - { - $firstUserId = $this->loadFixture(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $users = $repository->matching(new Criteria( - Criteria::expr()->gte('id', $firstUserId) - )); - - $this->assertEquals(4, count($users)); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php deleted file mode 100755 index f8b41e06a0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ /dev/null @@ -1,583 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; - $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'); - $class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; - - $this->loadFixture(); - } - - public function tearDown() - { - parent::tearDown(); - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_LAZY; - $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY; - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'); - $class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_LAZY; - } - - /** - * @group DDC-546 - */ - public function testCountNotInitializesCollection() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $queryCount = $this->getCurrentQueryCount(); - - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); - - foreach ($user->groups AS $group) { } - - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); - } - - /** - * @group DDC-546 - */ - public function testCountWhenNewEntityPresent() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - - $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $newGroup->name = "Test4"; - - $user->addGroup($newGroup); - $this->_em->persist($newGroup); - - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(4, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); - } - - /** - * @group DDC-546 - */ - public function testCountWhenInitialized() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $queryCount = $this->getCurrentQueryCount(); - - foreach ($user->groups AS $group) { } - - $this->assertTrue($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Should only execute one query to initialize colleciton, no extra query for count() more."); - } - - /** - * @group DDC-546 - */ - public function testCountInverseCollection() - { - $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); - $this->assertFalse($group->users->isInitialized(), "Pre-Condition"); - - $this->assertEquals(4, count($group->users)); - $this->assertFalse($group->users->isInitialized(), "Extra Lazy collection should not be initialized by counting the collection."); - } - - /** - * @group DDC-546 - */ - public function testCountOneToMany() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $this->assertFalse($user->groups->isInitialized(), "Pre-Condition"); - - $this->assertEquals(2, count($user->articles)); - } - - /** - * @group DDC-546 - */ - public function testFullSlice() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); - - $someGroups = $user->groups->slice(null); - $this->assertEquals(3, count($someGroups)); - } - - /** - * @group DDC-546 - */ - public function testSlice() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); - - $queryCount = $this->getCurrentQueryCount(); - - $someGroups = $user->groups->slice(0, 2); - - $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsGroup', $someGroups); - $this->assertEquals(2, count($someGroups)); - $this->assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!"); - - $otherGroup = $user->groups->slice(2, 1); - - $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsGroup', $otherGroup); - $this->assertEquals(1, count($otherGroup)); - $this->assertFalse($user->groups->isInitialized()); - - foreach ($user->groups AS $group) { } - - $this->assertTrue($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); - - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); - } - - /** - * @group DDC-546 - */ - public function testSliceInitializedCollection() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $queryCount = $this->getCurrentQueryCount(); - - foreach ($user->groups AS $group) { } - - $someGroups = $user->groups->slice(0, 2); - - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - - $this->assertEquals(2, count($someGroups)); - $this->assertTrue($user->groups->contains($someGroups[0])); - $this->assertTrue($user->groups->contains($someGroups[1])); - } - - /** - * @group DDC-546 - */ - public function testSliceInverseCollection() - { - $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); - $this->assertFalse($group->users->isInitialized(), "Pre-Condition"); - $queryCount = $this->getCurrentQueryCount(); - - $someUsers = $group->users->slice(0, 2); - $otherUsers = $group->users->slice(2, 2); - - $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $someUsers); - $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $otherUsers); - $this->assertEquals(2, count($someUsers)); - $this->assertEquals(2, count($otherUsers)); - - // +2 queries executed by slice - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Slicing two parts should only execute two additional queries."); - } - - /** - * @group DDC-546 - */ - public function testSliceOneToMany() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); - - $queryCount = $this->getCurrentQueryCount(); - - $someArticle = $user->articles->slice(0, 1); - $otherArticle = $user->articles->slice(1, 1); - - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - } - - /** - * @group DDC-546 - */ - public function testContainsOneToMany() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); - - // Test One to Many existance retrieved from DB - $article = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId); - $queryCount = $this->getCurrentQueryCount(); - - $this->assertTrue($user->articles->contains($article)); - $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - - // Test One to Many existance with state new - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article->topic = "Testnew"; - $article->text = "blub"; - - $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of new entity should cause no query to be executed."); - - // Test One to Many existance with state clear - $this->_em->persist($article); - $this->_em->flush(); - - $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount+1, $this->getCurrentQueryCount(), "Checking for contains of persisted entity should cause one query to be executed."); - $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); - - // Test One to Many existance with state managed - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article->topic = "How to not fail anymore on tests"; - $article->text = "That is simple! Just write more tests!"; - - $this->_em->persist($article); - - $queryCount = $this->getCurrentQueryCount(); - - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of managed entity (but not persisted) should cause no query to be executed."); - $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); - } - - /** - * @group DDC-546 - */ - public function testContainsManyToMany() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); - - // Test Many to Many existance retrieved from DB - $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); - $queryCount = $this->getCurrentQueryCount(); - - $this->assertTrue($user->groups->contains($group)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Checking for contains of managed entity should cause one query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - - // Test Many to Many existance with state new - $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $group->name = "A New group!"; - - $queryCount = $this->getCurrentQueryCount(); - - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of new entity should cause no query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - - // Test Many to Many existance with state clear - $this->_em->persist($group); - $this->_em->flush(); - - $queryCount = $this->getCurrentQueryCount(); - - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Checking for contains of persisted entity should cause one query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - - // Test Many to Many existance with state managed - $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $group->name = "My managed group"; - - $this->_em->persist($group); - - $queryCount = $this->getCurrentQueryCount(); - - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of managed entity (but not persisted) should cause no query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - } - - /** - * @group DDC-546 - */ - public function testContainsManyToManyInverse() - { - $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); - $this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); - - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - - $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($group->users->contains($user)); - $this->assertEquals($queryCount+1, $this->getCurrentQueryCount(), "Checking for contains of managed entity should cause one query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - - $newUser = new \Doctrine\Tests\Models\CMS\CmsUser(); - $newUser->name = "A New group!"; - - $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($group->users->contains($newUser)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of new entity should cause no query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - } - - /** - * - */ - public function testRemoveElementOneToMany() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); - - // Test One to Many removal with Entity retrieved from DB - $article = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId); - $queryCount = $this->getCurrentQueryCount(); - - $user->articles->removeElement($article); - - $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - - // Test One to Many removal with Entity state as new - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article->topic = "Testnew"; - $article->text = "blub"; - - $queryCount = $this->getCurrentQueryCount(); - - $user->articles->removeElement($article); - - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a new entity should cause no query to be executed."); - - // Test One to Many removal with Entity state as clean - $this->_em->persist($article); - $this->_em->flush(); - - $queryCount = $this->getCurrentQueryCount(); - - $user->articles->removeElement($article); - - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed."); - $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); - - // Test One to Many removal with Entity state as managed - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article->topic = "How to not fail anymore on tests"; - $article->text = "That is simple! Just write more tests!"; - - $this->_em->persist($article); - - $queryCount = $this->getCurrentQueryCount(); - - $user->articles->removeElement($article); - - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a managed entity should cause no query to be executed."); - } - - /** - * - */ - public function testRemoveElementManyToMany() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); - - // Test Many to Many removal with Entity retrieved from DB - $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); - $queryCount = $this->getCurrentQueryCount(); - - $user->groups->removeElement($group); - - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - - // Test Many to Many removal with Entity state as new - $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $group->name = "A New group!"; - - $queryCount = $this->getCurrentQueryCount(); - - $user->groups->removeElement($group); - - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing new entity should cause no query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - - // Test Many to Many removal with Entity state as clean - $this->_em->persist($group); - $this->_em->flush(); - - $queryCount = $this->getCurrentQueryCount(); - - $user->groups->removeElement($group); - - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - - // Test Many to Many removal with Entity state as managed - $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $group->name = "A New group!"; - - $this->_em->persist($group); - - $queryCount = $this->getCurrentQueryCount(); - - $user->groups->removeElement($group); - - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a managed entity should cause no query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - } - - /** - * - */ - public function testRemoveElementManyToManyInverse() - { - $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); - $this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); - - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $queryCount = $this->getCurrentQueryCount(); - - $group->users->removeElement($user); - - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a managed entity should cause one query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - - $newUser = new \Doctrine\Tests\Models\CMS\CmsUser(); - $newUser->name = "A New group!"; - - $queryCount = $this->getCurrentQueryCount(); - - $group->users->removeElement($newUser); - - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a new entity should cause no query to be executed."); - $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - } - - /** - * @group DDC-1399 - */ - public function testCountAfterAddThenFlush() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - - $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $newGroup->name = "Test4"; - - $user->addGroup($newGroup); - $this->_em->persist($newGroup); - - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(4, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); - - $this->_em->flush(); - - $this->assertEquals(4, count($user->groups)); - } - - /** - * @group DDC-1462 - */ - public function testSliceOnDirtyCollection() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - /* @var $user CmsUser */ - - $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $newGroup->name = "Test4"; - - $user->addGroup($newGroup); - $this->_em->persist($newGroup); - - $qc = $this->getCurrentQueryCount(); - $groups = $user->groups->slice(0, 10); - - $this->assertEquals(4, count($groups)); - $this->assertEquals($qc + 1, $this->getCurrentQueryCount()); - } - - private function loadFixture() - { - $user1 = new \Doctrine\Tests\Models\CMS\CmsUser(); - $user1->username = "beberlei"; - $user1->name = "Benjamin"; - $user1->status = "active"; - - $user2 = new \Doctrine\Tests\Models\CMS\CmsUser(); - $user2->username = "jwage"; - $user2->name = "Jonathan"; - $user2->status = "active"; - - $user3 = new \Doctrine\Tests\Models\CMS\CmsUser(); - $user3->username = "romanb"; - $user3->name = "Roman"; - $user3->status = "active"; - - $user4 = new \Doctrine\Tests\Models\CMS\CmsUser(); - $user4->username = "gblanco"; - $user4->name = "Guilherme"; - $user4->status = "active"; - - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->persist($user3); - $this->_em->persist($user4); - - $group1 = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $group1->name = "Test1"; - - $group2 = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $group2->name = "Test2"; - - $group3 = new \Doctrine\Tests\Models\CMS\CmsGroup(); - $group3->name = "Test3"; - - $user1->addGroup($group1); - $user1->addGroup($group2); - $user1->addGroup($group3); - - $user2->addGroup($group1); - $user3->addGroup($group1); - $user4->addGroup($group1); - - $this->_em->persist($group1); - $this->_em->persist($group2); - $this->_em->persist($group3); - - $article1 = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article1->topic = "Test"; - $article1->text = "Test"; - $article1->setAuthor($user1); - - $article2 = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article2->topic = "Test"; - $article2->text = "Test"; - $article2->setAuthor($user1); - - $this->_em->persist($article1); - $this->_em->persist($article2); - - $this->_em->flush(); - $this->_em->clear(); - - $this->articleId = $article1->id; - $this->userId = $user1->getId(); - $this->groupId = $group1->id; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php deleted file mode 100755 index 8167e85876..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ /dev/null @@ -1,94 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testPersistNewEntitiesOnPreFlush() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_em->getEventManager()->addEventListener(Events::onFlush, new OnFlushListener); - - $user = new CmsUser; - $user->username = 'romanb'; - $user->name = 'Roman'; - $user->status = 'Dev'; - - $this->_em->persist($user); - - $this->assertEquals(0, $user->phonenumbers->count()); - - $this->_em->flush(); - - $this->assertEquals(1, $user->phonenumbers->count()); - $this->assertTrue($this->_em->contains($user->phonenumbers->get(0))); - $this->assertTrue($user->phonenumbers->get(0)->getUser() === $user); - - $this->assertFalse($user->phonenumbers->isDirty()); - - // Can be used together with SQL Logging to check that a subsequent flush has - // nothing to do. This proofs the correctness of the changes that happened in onFlush. - //echo "SECOND FLUSH"; - //$this->_em->flush(); - } -} - -class OnFlushListener -{ - public function onFlush(OnFlushEventArgs $args) - { - //echo "---preFlush".PHP_EOL; - - $em = $args->getEntityManager(); - $uow = $em->getUnitOfWork(); - - foreach ($uow->getScheduledEntityInsertions() as $entity) { - - if ($entity instanceof CmsUser) { - // Adds a phonenumber to every newly persisted CmsUser ... - - $phone = new CmsPhonenumber; - $phone->phonenumber = 12345; - // Update object model - $entity->addPhonenumber($phone); - // Invoke regular persist call - $em->persist($phone); - // Explicitly calculate the changeset since onFlush is raised - // after changeset calculation! - $uow->computeChangeSet($em->getClassMetadata(get_class($phone)), $phone); - - // Take a snapshot because the UoW wont do this for us, because - // the UoW did not visit this collection. - // Alternatively we could provide an ->addVisitedCollection() method - // on the UoW. - $entity->getPhonenumbers()->takeSnapshot(); - } - - /*foreach ($uow->getEntityChangeSet($entity) as $field => $change) { - list ($old, $new) = $change; - - var_dump($old); - }*/ - - } - } -} - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php deleted file mode 100755 index 9dc556d4b8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php +++ /dev/null @@ -1,88 +0,0 @@ -useModelSet('cms'); - - parent::setUp(); - - $user = new CmsUser; - $user->name = "Benjamin"; - $user->username = "beberlei"; - $user->status = 'active'; - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - } - - public function testHydrationCache() - { - $cache = new ArrayCache(); - $dql = "SELECT u FROM Doctrine\Tests\Models\Cms\CmsUser u"; - - $users = $this->_em->createQuery($dql) - ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) - ->getResult(); - - $c = $this->getCurrentQueryCount(); - $users = $this->_em->createQuery($dql) - ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) - ->getResult(); - - $this->assertEquals($c, $this->getCurrentQueryCount(), "Should not execute query. Its cached!"); - - $users = $this->_em->createQuery($dql) - ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) - ->getArrayResult(); - - $this->assertEquals($c + 1, $this->getCurrentQueryCount(), "Hydration is part of cache key."); - - $users = $this->_em->createQuery($dql) - ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) - ->getArrayResult(); - - $this->assertEquals($c + 1, $this->getCurrentQueryCount(), "Hydration now cached"); - - $users = $this->_em->createQuery($dql) - ->setHydrationCacheProfile(new QueryCacheProfile(null, 'cachekey', $cache)) - ->getArrayResult(); - - $this->assertTrue($cache->contains('cachekey'), 'Explicit cache key'); - - $users = $this->_em->createQuery($dql) - ->setHydrationCacheProfile(new QueryCacheProfile(null, 'cachekey', $cache)) - ->getArrayResult(); - $this->assertEquals($c + 2, $this->getCurrentQueryCount(), "Hydration now cached"); - } - - public function testHydrationParametersSerialization() - { - $cache = new ArrayCache(); - - $dql = "SELECT u FROM Doctrine\Tests\Models\Cms\CmsUser u WHERE u.id = ?1"; - $query = $this->_em->createQuery($dql) - ->setParameter(1, $userId = 1) - ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)); - - $query->getResult(); - - $c = $this->getCurrentQueryCount(); - - $query->getResult(); - - $this->assertEquals($c, $this->getCurrentQueryCount(), "Should not execute query. Its cached!"); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php deleted file mode 100755 index 84d0064a9e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php +++ /dev/null @@ -1,288 +0,0 @@ - - */ -class IdentityMapTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - protected function setUp() { - $this->useModelSet('cms'); - parent::setUp(); - } - - public function testBasicIdentityManagement() - { - $user = new CmsUser; - $user->status = 'dev'; - $user->username = 'romanb'; - $user->name = 'Roman B.'; - - $address = new CmsAddress; - $address->country = 'de'; - $address->zip = 1234; - $address->city = 'Berlin'; - - $user->setAddress($address); - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $user2 = $this->_em->find(get_class($user), $user->getId()); - $this->assertTrue($user2 !== $user); - $user3 = $this->_em->find(get_class($user), $user->getId()); - $this->assertTrue($user2 === $user3); - - $address2 = $this->_em->find(get_class($address), $address->getId()); - $this->assertTrue($address2 !== $address); - $address3 = $this->_em->find(get_class($address), $address->getId()); - $this->assertTrue($address2 === $address3); - - $this->assertTrue($user2->getAddress() === $address2); // !!! - } - - public function testSingleValuedAssociationIdentityMapBehaviorWithRefresh() - { - $address = new CmsAddress; - $address->country = 'de'; - $address->zip = '12345'; - $address->city = 'Berlin'; - - $user1 = new CmsUser; - $user1->status = 'dev'; - $user1->username = 'romanb'; - $user1->name = 'Roman B.'; - - $user2 = new CmsUser; - $user2->status = 'dev'; - $user2->username = 'gblanco'; - $user2->name = 'Guilherme Blanco'; - - $address->setUser($user1); - - $this->_em->persist($address); - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->flush(); - - $this->assertSame($user1, $address->user); - - //external update to CmsAddress - $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', array($user2->getId())); - - // But we want to have this external change! - // Solution 1: refresh(), broken atm! - $this->_em->refresh($address); - - // Now the association should be "correct", referencing $user2 - $this->assertSame($user2, $address->user); - $this->assertSame($user2->address, $address); // check back reference also - - // Attention! refreshes can result in broken bidirectional associations! this is currently expected! - // $user1 still points to $address! - $this->assertSame($user1->address, $address); - } - - public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery() - { - $address = new CmsAddress; - $address->country = 'de'; - $address->zip = '12345'; - $address->city = 'Berlin'; - - $user1 = new CmsUser; - $user1->status = 'dev'; - $user1->username = 'romanb'; - $user1->name = 'Roman B.'; - - $user2 = new CmsUser; - $user2->status = 'dev'; - $user2->username = 'gblanco'; - $user2->name = 'Guilherme Blanco'; - - $address->setUser($user1); - - $this->_em->persist($address); - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->flush(); - - - $this->assertSame($user1, $address->user); - - //external update to CmsAddress - $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', array($user2->getId())); - - //select - $q = $this->_em->createQuery('select a, u from Doctrine\Tests\Models\CMS\CmsAddress a join a.user u'); - $address2 = $q->getSingleResult(); - - $this->assertSame($address, $address2); - - // Should still be $user1 - $this->assertSame($user1, $address2->user); - $this->assertTrue($user2->address === null); - - // But we want to have this external change! - // Solution 2: Alternatively, a refresh query should work - $q = $this->_em->createQuery('select a, u from Doctrine\Tests\Models\CMS\CmsAddress a join a.user u'); - $q->setHint(Query::HINT_REFRESH, true); - $address3 = $q->getSingleResult(); - - $this->assertSame($address, $address3); // should still be the same, always from identity map - - // Now the association should be "correct", referencing $user2 - $this->assertSame($user2, $address2->user); - $this->assertSame($user2->address, $address2); // check back reference also - - // Attention! refreshes can result in broken bidirectional associations! this is currently expected! - // $user1 still points to $address2! - $this->assertSame($user1->address, $address2); - } - - public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQuery() - { - $user = new CmsUser; - $user->status = 'dev'; - $user->username = 'romanb'; - $user->name = 'Roman B.'; - - $phone1 = new CmsPhonenumber; - $phone1->phonenumber = 123; - - $phone2 = new CmsPhonenumber; - $phone2->phonenumber = 234; - - $phone3 = new CmsPhonenumber; - $phone3->phonenumber = 345; - - $user->addPhonenumber($phone1); - $user->addPhonenumber($phone2); - $user->addPhonenumber($phone3); - - $this->_em->persist($user); // cascaded to phone numbers - $this->_em->flush(); - - $this->assertEquals(3, count($user->getPhonenumbers())); - $this->assertFalse($user->getPhonenumbers()->isDirty()); - - //external update to CmsAddress - $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', array(999, $user->getId())); - - //select - $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); - $user2 = $q->getSingleResult(); - - $this->assertSame($user, $user2); - - // Should still be the same 3 phonenumbers - $this->assertEquals(3, count($user2->getPhonenumbers())); - - // But we want to have this external change! - // Solution 1: refresh(). - //$this->_em->refresh($user2); broken atm! - // Solution 2: Alternatively, a refresh query should work - $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); - $q->setHint(Query::HINT_REFRESH, true); - $user3 = $q->getSingleResult(); - - $this->assertSame($user, $user3); // should still be the same, always from identity map - - // Now the collection should be refreshed with correct count - $this->assertEquals(4, count($user3->getPhonenumbers())); - } - - public function testCollectionValuedAssociationIdentityMapBehaviorWithRefresh() - { - $user = new CmsUser; - $user->status = 'dev'; - $user->username = 'romanb'; - $user->name = 'Roman B.'; - - $phone1 = new CmsPhonenumber; - $phone1->phonenumber = 123; - - $phone2 = new CmsPhonenumber; - $phone2->phonenumber = 234; - - $phone3 = new CmsPhonenumber; - $phone3->phonenumber = 345; - - $user->addPhonenumber($phone1); - $user->addPhonenumber($phone2); - $user->addPhonenumber($phone3); - - $this->_em->persist($user); // cascaded to phone numbers - $this->_em->flush(); - - $this->assertEquals(3, count($user->getPhonenumbers())); - - //external update to CmsAddress - $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', array(999, $user->getId())); - - //select - $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); - $user2 = $q->getSingleResult(); - - $this->assertSame($user, $user2); - - // Should still be the same 3 phonenumbers - $this->assertEquals(3, count($user2->getPhonenumbers())); - - // But we want to have this external change! - // Solution 1: refresh(). - $this->_em->refresh($user2); - - $this->assertSame($user, $user2); // should still be the same, always from identity map - - // Now the collection should be refreshed with correct count - $this->assertEquals(4, count($user2->getPhonenumbers())); - } - - public function testReusedSplObjectHashDoesNotConfuseUnitOfWork() - { - $hash1 = $this->subRoutine($this->_em); - // Make sure cycles are collected NOW, because a PersistentCollection references - // its owner, hence without forcing gc on cycles now the object will not (yet) - // be garbage collected and thus the object hash is not reused. - // This is not a memory leak! - gc_collect_cycles(); - - $user1 = new CmsUser; - $user1->status = 'dev'; - $user1->username = 'jwage'; - $user1->name = 'Jonathan W.'; - $hash2 = spl_object_hash($user1); - $this->assertEquals($hash1, $hash2); // Hash reused! - $this->_em->persist($user1); - $this->_em->flush(); - } - - private function subRoutine($em) { - $user = new CmsUser; - $user->status = 'dev'; - $user->username = 'romanb'; - $user->name = 'Roman B.'; - $em->persist($user); - $em->flush(); - $em->remove($user); - $em->flush(); - - return spl_object_hash($user); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php deleted file mode 100755 index bca4ea5df7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php +++ /dev/null @@ -1,105 +0,0 @@ -useModelSet('stockexchange'); - parent::setUp(); - $this->loadFixture(); - } - - public function loadFixture() - { - $this->market = new Market("Some Exchange"); - $stock1 = new Stock("AAPL", 10, $this->market); - $stock2 = new Stock("GOOG", 20, $this->market); - - $this->bond = new Bond("MyBond"); - $this->bond->addStock($stock1); - $this->bond->addStock($stock2); - - $this->_em->persist($this->market); - $this->_em->persist($stock1); - $this->_em->persist($stock2); - $this->_em->persist($this->bond); - $this->_em->flush(); - $this->_em->clear(); - } - - public function testManyToOneFinder() - { - /* @var $market Doctrine\Tests\Models\StockExchange\Market */ - $market = $this->_em->find('Doctrine\Tests\Models\StockExchange\Market', $this->market->getId()); - - $this->assertEquals(2, count($market->stocks)); - $this->assertTrue(isset($market->stocks['AAPL']), "AAPL symbol has to be key in indexed assocation."); - $this->assertTrue(isset($market->stocks['GOOG']), "GOOG symbol has to be key in indexed assocation."); - $this->assertEquals("AAPL", $market->stocks['AAPL']->getSymbol()); - $this->assertEquals("GOOG", $market->stocks['GOOG']->getSymbol()); - } - - public function testManyToOneDQL() - { - $dql = "SELECT m, s FROM Doctrine\Tests\Models\StockExchange\Market m JOIN m.stocks s WHERE m.id = ?1"; - $market = $this->_em->createQuery($dql)->setParameter(1, $this->market->getId())->getSingleResult(); - - $this->assertEquals(2, count($market->stocks)); - $this->assertTrue(isset($market->stocks['AAPL']), "AAPL symbol has to be key in indexed assocation."); - $this->assertTrue(isset($market->stocks['GOOG']), "GOOG symbol has to be key in indexed assocation."); - $this->assertEquals("AAPL", $market->stocks['AAPL']->getSymbol()); - $this->assertEquals("GOOG", $market->stocks['GOOG']->getSymbol()); - } - - public function testManyToMany() - { - $bond = $this->_em->find('Doctrine\Tests\Models\StockExchange\Bond', $this->bond->getId()); - - $this->assertEquals(2, count($bond->stocks)); - $this->assertTrue(isset($bond->stocks['AAPL']), "AAPL symbol has to be key in indexed assocation."); - $this->assertTrue(isset($bond->stocks['GOOG']), "GOOG symbol has to be key in indexed assocation."); - $this->assertEquals("AAPL", $bond->stocks['AAPL']->getSymbol()); - $this->assertEquals("GOOG", $bond->stocks['GOOG']->getSymbol()); - } - - public function testManytoManyDQL() - { - $dql = "SELECT b, s FROM Doctrine\Tests\Models\StockExchange\Bond b JOIN b.stocks s WHERE b.id = ?1"; - $bond = $this->_em->createQuery($dql)->setParameter(1, $this->bond->getId())->getSingleResult(); - - $this->assertEquals(2, count($bond->stocks)); - $this->assertTrue(isset($bond->stocks['AAPL']), "AAPL symbol has to be key in indexed assocation."); - $this->assertTrue(isset($bond->stocks['GOOG']), "GOOG symbol has to be key in indexed assocation."); - $this->assertEquals("AAPL", $bond->stocks['AAPL']->getSymbol()); - $this->assertEquals("GOOG", $bond->stocks['GOOG']->getSymbol()); - } - - public function testDqlOverrideIndexBy() - { - $dql = "SELECT b, s FROM Doctrine\Tests\Models\StockExchange\Bond b JOIN b.stocks s INDEX BY s.id WHERE b.id = ?1"; - $bond = $this->_em->createQuery($dql)->setParameter(1, $this->bond->getId())->getSingleResult(); - - $this->assertEquals(2, count($bond->stocks)); - $this->assertFalse(isset($bond->stocks['AAPL']), "AAPL symbol not exists in re-indexed assocation."); - $this->assertFalse(isset($bond->stocks['GOOG']), "GOOG symbol not exists in re-indexed assocation."); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php deleted file mode 100755 index 230f562c6b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ /dev/null @@ -1,311 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackCascader'), - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - - public function testPreSavePostSaveCallbacksAreInvoked() - { - $entity = new LifecycleCallbackTestEntity; - $entity->value = 'hello'; - $this->_em->persist($entity); - $this->_em->flush(); - - $this->assertTrue($entity->prePersistCallbackInvoked); - $this->assertTrue($entity->postPersistCallbackInvoked); - - $this->_em->clear(); - - $query = $this->_em->createQuery("select e from Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity e"); - $result = $query->getResult(); - $this->assertTrue($result[0]->postLoadCallbackInvoked); - - $result[0]->value = 'hello again'; - - $this->_em->flush(); - - $this->assertEquals('changed from preUpdate callback!', $result[0]->value); - } - - public function testPreFlushCallbacksAreInvoked() - { - $entity = new LifecycleCallbackTestEntity; - $entity->value = 'hello'; - $this->_em->persist($entity); - - $this->_em->flush(); - - $this->assertTrue($entity->prePersistCallbackInvoked); - $this->assertTrue($entity->preFlushCallbackInvoked); - - $entity->preFlushCallbackInvoked = false; - $this->_em->flush(); - - $this->assertTrue($entity->preFlushCallbackInvoked); - - $entity->value = 'bye'; - $entity->preFlushCallbackInvoked = false; - $this->_em->flush(); - - $this->assertTrue($entity->preFlushCallbackInvoked); - } - - public function testChangesDontGetLost() - { - $user = new LifecycleCallbackTestUser; - $user->setName('Bob'); - $user->setValue('value'); - $this->_em->persist($user); - $this->_em->flush(); - - $user->setName('Alice'); - $this->_em->flush(); // Triggers preUpdate - - $this->_em->clear(); - - $user2 = $this->_em->find(get_class($user), $user->getId()); - - $this->assertEquals('Alice', $user2->getName()); - $this->assertEquals('Hello World', $user2->getValue()); - } - - /** - * @group DDC-194 - */ - public function testGetReferenceWithPostLoadEventIsDelayedUntilProxyTrigger() - { - $entity = new LifecycleCallbackTestEntity; - $entity->value = 'hello'; - $this->_em->persist($entity); - $this->_em->flush(); - $id = $entity->getId(); - - $this->_em->clear(); - - $reference = $this->_em->getReference('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity', $id); - $this->assertFalse($reference->postLoadCallbackInvoked); - - $reference->getValue(); // trigger proxy load - $this->assertTrue($reference->postLoadCallbackInvoked); - } - - /** - * @group DDC-958 - */ - public function testPostLoadTriggeredOnRefresh() - { - $entity = new LifecycleCallbackTestEntity; - $entity->value = 'hello'; - $this->_em->persist($entity); - $this->_em->flush(); - $id = $entity->getId(); - - $this->_em->clear(); - - $reference = $this->_em->find('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity', $id); - $this->assertTrue($reference->postLoadCallbackInvoked); - $reference->postLoadCallbackInvoked = false; - - $this->_em->refresh($reference); - $this->assertTrue($reference->postLoadCallbackInvoked, "postLoad should be invoked when refresh() is called."); - } - - /** - * @group DDC-113 - */ - public function testCascadedEntitiesCallsPrePersist() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $e1 = new LifecycleCallbackTestEntity; - $e2 = new LifecycleCallbackTestEntity; - - $c = new LifecycleCallbackCascader(); - $this->_em->persist($c); - - $c->entities[] = $e1; - $c->entities[] = $e2; - $e1->cascader = $c; - $e2->cascader = $c; - - //$this->_em->persist($c); - $this->_em->flush(); - - $this->assertTrue($e1->prePersistCallbackInvoked); - $this->assertTrue($e2->prePersistCallbackInvoked); - } - - public function testLifecycleCallbacksGetInherited() - { - $childMeta = $this->_em->getClassMetadata(__NAMESPACE__ . '\LifecycleCallbackChildEntity'); - $this->assertEquals(array('prePersist' => array(0 => 'doStuff')), $childMeta->lifecycleCallbacks); - } - - public function testLifecycleListener_ChangeUpdateChangeSet() - { - $listener = new LifecycleListenerPreUpdate; - $this->_em->getEventManager()->addEventListener(array('preUpdate'), $listener); - - $user = new LifecycleCallbackTestUser; - $user->setName('Bob'); - $user->setValue('value'); - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT u FROM Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser u WHERE u.name = 'Bob'"; - $bob = $this->_em->createQuery($dql)->getSingleResult(); - $bob->setName('Alice'); - - $this->_em->flush(); // preUpdate reverts Alice to Bob - $this->_em->clear(); - - $this->_em->getEventManager()->removeEventListener(array('preUpdate'), $listener); - - $bob = $this->_em->createQuery($dql)->getSingleResult(); - - $this->assertEquals('Bob', $bob->getName()); - } -} - -/** @Entity @HasLifecycleCallbacks */ -class LifecycleCallbackTestUser { - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - /** @Column(type="string") */ - private $value; - /** @Column(type="string") */ - private $name; - public function getId() {return $this->id;} - public function getValue() {return $this->value;} - public function setValue($value) {$this->value = $value;} - public function getName() {return $this->name;} - public function setName($name) {$this->name = $name;} - /** @PreUpdate */ - public function testCallback() {$this->value = 'Hello World';} -} - -/** - * @Entity - * @HasLifecycleCallbacks - * @Table(name="lc_cb_test_entity") - */ -class LifecycleCallbackTestEntity -{ - /* test stuff */ - public $prePersistCallbackInvoked = false; - public $postPersistCallbackInvoked = false; - public $postLoadCallbackInvoked = false; - - public $preFlushCallbackInvoked = false; - - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - /** - * @Column(type="string", nullable=true) - */ - public $value; - - /** - * @ManyToOne(targetEntity="LifecycleCallbackCascader") - * @JoinColumn(name="cascader_id", referencedColumnName="id") - */ - public $cascader; - - public function getId() { - return $this->id; - } - - public function getValue() { - return $this->value; - } - - /** @PrePersist */ - public function doStuffOnPrePersist() { - $this->prePersistCallbackInvoked = true; - } - - /** @PostPersist */ - public function doStuffOnPostPersist() { - $this->postPersistCallbackInvoked = true; - } - - /** @PostLoad */ - public function doStuffOnPostLoad() { - $this->postLoadCallbackInvoked = true; - } - - /** @PreUpdate */ - public function doStuffOnPreUpdate() { - $this->value = 'changed from preUpdate callback!'; - } - - /** @PreFlush */ - public function doStuffOnPreFlush() { - $this->preFlushCallbackInvoked = true; - } -} - -/** - * @Entity - * @Table(name="lc_cb_test_cascade") - */ -class LifecycleCallbackCascader -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @OneToMany(targetEntity="LifecycleCallbackTestEntity", mappedBy="cascader", cascade={"persist"}) - */ - public $entities; - - public function __construct() - { - $this->entities = new \Doctrine\Common\Collections\ArrayCollection(); - } -} - -/** @MappedSuperclass @HasLifecycleCallbacks */ -class LifecycleCallbackParentEntity { - /** @PrePersist */ - function doStuff() { - - } -} - -/** @Entity @Table(name="lc_cb_childentity") */ -class LifecycleCallbackChildEntity extends LifecycleCallbackParentEntity { - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; -} - -class LifecycleListenerPreUpdate -{ - public function preUpdate(PreUpdateEventArgs $eventArgs) - { - $eventArgs->setNewValue('name', 'Bob'); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php deleted file mode 100755 index a67a44d8ff..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php +++ /dev/null @@ -1,180 +0,0 @@ -markTestSkipped('pecl/gearman is required for this test to run.'); - } - - $this->useModelSet('cms'); - parent::setUp(); - $this->tasks = array(); - - $this->gearman = new \GearmanClient(); - $this->gearman->addServer(); - $this->gearman->setCompleteCallback(array($this, "gearmanTaskCompleted")); - - $article = new CmsArticle(); - $article->text = "my article"; - $article->topic = "Hello"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->articleId = $article->id; - } - - public function gearmanTaskCompleted($task) - { - $this->maxRunTime = max($this->maxRunTime, $task->data()); - } - - public function testFindWithLock() - { - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - - $this->assertLockWorked(); - } - - public function testFindWithWriteThenReadLock() - { - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); - - $this->assertLockWorked(); - } - - public function testFindWithReadThenWriteLock() - { - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - - $this->assertLockWorked(); - } - - public function testFindWithOneLock() - { - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::NONE); - - $this->assertLockDoesNotBlock(); - } - - public function testDqlWithLock() - { - $this->asyncDqlWithLock('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a', array(), LockMode::PESSIMISTIC_WRITE); - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - - $this->assertLockWorked(); - } - - public function testLock() - { - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - $this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - - $this->assertLockWorked(); - } - - public function testLock2() - { - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - $this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); - - $this->assertLockWorked(); - } - - public function testLock3() - { - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); - $this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - - $this->assertLockWorked(); - } - - public function testLock4() - { - $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::NONE); - $this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); - - $this->assertLockDoesNotBlock(); - } - - protected function assertLockDoesNotBlock() - { - $this->assertLockWorked($onlyForSeconds = 1); - } - - protected function assertLockWorked($forTime = 2, $notLongerThan = null) - { - if ($notLongerThan === null) { - $notLongerThan = $forTime + 1; - } - - $this->gearman->runTasks(); - - $this->assertTrue($this->maxRunTime > $forTime, - "Because of locking this tests should have run at least " . $forTime . " seconds, ". - "but only did for " . $this->maxRunTime . " seconds."); - $this->assertTrue($this->maxRunTime < $notLongerThan, - "The longest task should not run longer than " . $notLongerThan . " seconds, ". - "but did for " . $this->maxRunTime . " seconds." - ); - } - - protected function asyncFindWithLock($entityName, $entityId, $lockMode) - { - $this->startJob('findWithLock', array( - 'entityName' => $entityName, - 'entityId' => $entityId, - 'lockMode' => $lockMode, - )); - } - - protected function asyncDqlWithLock($dql, $params, $lockMode) - { - $this->startJob('dqlWithLock', array( - 'dql' => $dql, - 'dqlParams' => $params, - 'lockMode' => $lockMode, - )); - } - - protected function asyncLock($entityName, $entityId, $lockMode) - { - $this->startJob('lock', array( - 'entityName' => $entityName, - 'entityId' => $entityId, - 'lockMode' => $lockMode, - )); - } - - protected function startJob($fn, $fixture) - { - $this->gearman->addTask($fn, serialize(array( - 'conn' => $this->_em->getConnection()->getParams(), - 'fixture' => $fixture - ))); - - $this->assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php deleted file mode 100755 index 2db6cce125..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php +++ /dev/null @@ -1,112 +0,0 @@ -addServer(); - $worker->addFunction("findWithLock", array($lockAgent, "findWithLock")); - $worker->addFunction("dqlWithLock", array($lockAgent, "dqlWithLock")); - $worker->addFunction('lock', array($lockAgent, 'lock')); - - while($worker->work()) { - if ($worker->returnCode() != GEARMAN_SUCCESS) { - echo "return_code: " . $worker->returnCode() . "\n"; - break; - } - } - } - - protected function process($job, \Closure $do) - { - $fixture = $this->processWorkload($job); - - $s = microtime(true); - $this->em->beginTransaction(); - $do($fixture, $this->em); - - sleep(1); - $this->em->rollback(); - $this->em->clear(); - $this->em->close(); - $this->em->getConnection()->close(); - - return (microtime(true) - $s); - } - - public function findWithLock($job) - { - return $this->process($job, function($fixture, $em) { - $entity = $em->find($fixture['entityName'], $fixture['entityId'], $fixture['lockMode']); - }); - } - - public function dqlWithLock($job) - { - return $this->process($job, function($fixture, $em) { - /* @var $query Doctrine\ORM\Query */ - $query = $em->createQuery($fixture['dql']); - $query->setLockMode($fixture['lockMode']); - $query->setParameters($fixture['dqlParams']); - $result = $query->getResult(); - }); - } - - public function lock($job) - { - return $this->process($job, function($fixture, $em) { - $entity = $em->find($fixture['entityName'], $fixture['entityId']); - $em->lock($entity, $fixture['lockMode']); - }); - } - - protected function processWorkload($job) - { - echo "Received job: " . $job->handle() . " for function " . $job->functionName() . "\n"; - - $workload = $job->workload(); - $workload = unserialize($workload); - - if (!isset($workload['conn']) || !is_array($workload['conn'])) { - throw new \InvalidArgumentException("Missing Database parameters"); - } - - $this->em = $this->createEntityManager($workload['conn']); - - if (!isset($workload['fixture'])) { - throw new \InvalidArgumentException("Missing Fixture parameters"); - } - return $workload['fixture']; - } - - protected function createEntityManager($conn) - { - $config = new \Doctrine\ORM\Configuration(); - $config->setProxyDir(__DIR__ . '/../../../Proxies'); - $config->setProxyNamespace('MyProject\Proxies'); - $config->setAutoGenerateProxyClasses(true); - - $annotDriver = $config->newDefaultAnnotationDriver(array(__DIR__ . '/../../../Models/'), true); - $config->setMetadataDriverImpl($annotDriver); - - $cache = new \Doctrine\Common\Cache\ArrayCache(); - $config->setMetadataCacheImpl($cache); - $config->setQueryCacheImpl($cache); - $config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); - - $em = \Doctrine\ORM\EntityManager::create($conn, $config); - - return $em; - } -} - -LockAgentWorker::run(); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php deleted file mode 100755 index e7ec0f71d2..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ /dev/null @@ -1,186 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - $this->handles = array(); - } - - /** - * @group DDC-178 - * @group locking - */ - public function testLockVersionedEntity() { - $article = new CmsArticle(); - $article->text = "my article"; - $article->topic = "Hello"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version); - } - - /** - * @group DDC-178 - * @group locking - */ - public function testLockVersionedEntity_MissmatchThrowsException() { - $article = new CmsArticle(); - $article->text = "my article"; - $article->topic = "Hello"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); - $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); - } - - /** - * @group DDC-178 - * @group locking - */ - public function testLockUnversionedEntity_ThrowsException() { - $user = new CmsUser(); - $user->name = "foo"; - $user->status = "active"; - $user->username = "foo"; - - $this->_em->persist($user); - $this->_em->flush(); - - $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); - $this->_em->lock($user, LockMode::OPTIMISTIC); - } - - /** - * @group DDC-178 - * @group locking - */ - public function testLockUnmanagedEntity_ThrowsException() { - $article = new CmsArticle(); - - $this->setExpectedException('InvalidArgumentException', 'Entity Doctrine\Tests\Models\CMS\CmsArticle'); - $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); - } - - /** - * @group DDC-178 - * @group locking - */ - public function testLockPessimisticRead_NoTransaction_ThrowsException() { - $article = new CmsArticle(); - $article->text = "my article"; - $article->topic = "Hello"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); - $this->_em->lock($article, LockMode::PESSIMISTIC_READ); - } - - /** - * @group DDC-178 - * @group locking - */ - public function testLockPessimisticWrite_NoTransaction_ThrowsException() { - $article = new CmsArticle(); - $article->text = "my article"; - $article->topic = "Hello"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); - $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); - } - - /** - * @group DDC-178 - * @group locking - */ - public function testLockPessimisticWrite() { - $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSql(); - if (strlen($writeLockSql) == 0) { - $this->markTestSkipped('Database Driver has no Write Lock support.'); - } - - $article = new CmsArticle(); - $article->text = "my article"; - $article->topic = "Hello"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->_em->beginTransaction(); - try { - $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); - $this->_em->commit(); - } catch (\Exception $e) { - $this->_em->rollback(); - throw $e; - } - - $query = array_pop( $this->_sqlLoggerStack->queries ); - $query = array_pop( $this->_sqlLoggerStack->queries ); - $this->assertContains($writeLockSql, $query['sql']); - } - - /** - * @group DDC-178 - */ - public function testLockPessimisticRead() { - $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSql(); - if (strlen($readLockSql) == 0) { - $this->markTestSkipped('Database Driver has no Write Lock support.'); - } - - $article = new CmsArticle(); - $article->text = "my article"; - $article->topic = "Hello"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->_em->beginTransaction(); - try { - $this->_em->lock($article, LockMode::PESSIMISTIC_READ); - $this->_em->commit(); - } catch (\Exception $e) { - $this->_em->rollback(); - throw $e; - } - - $query = array_pop( $this->_sqlLoggerStack->queries ); - $query = array_pop( $this->_sqlLoggerStack->queries ); - $this->assertContains($readLockSql, $query['sql']); - } - - /** - * @group DDC-1693 - */ - public function testLockOptimisticNonVersionedThrowsExceptionInDQL() - { - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'"; - - $this->setExpectedException('Doctrine\ORM\OptimisticLockException', 'The optimistic lock on an entity failed.'); - $sql = $this->_em->createQuery($dql)->setHint( - \Doctrine\ORM\Query::HINT_LOCK_MODE, \Doctrine\DBAL\LockMode::OPTIMISTIC - )->getSQL(); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php deleted file mode 100755 index e2341a19e0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ /dev/null @@ -1,277 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - $this->_conn = $this->_em->getConnection(); - } - - public function testJoinedChildInsertSetsInitialVersionValue() - { - $test = new OptimisticJoinedChild(); - $test->name = 'child'; - $test->whatever = 'whatever'; - $this->_em->persist($test); - $this->_em->flush(); - - $this->assertEquals(1, $test->version); - - return $test; - } - - /** - * @depends testJoinedChildInsertSetsInitialVersionValue - */ - public function testJoinedChildFailureThrowsException(OptimisticJoinedChild $child) - { - $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild t WHERE t.id = :id'); - $q->setParameter('id', $child->id); - $test = $q->getSingleResult(); - - // Manually update/increment the version so we can try and save the same - // $test and make sure the exception is thrown saying the record was - // changed or updated since you read it - $this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id)); - - // Now lets change a property and try and save it again - $test->whatever = 'ok'; - try { - $this->_em->flush(); - } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); - } - } - - public function testJoinedParentInsertSetsInitialVersionValue() - { - $test = new OptimisticJoinedParent(); - $test->name = 'parent'; - $this->_em->persist($test); - $this->_em->flush(); - - $this->assertEquals(1, $test->version); - - return $test; - } - - /** - * @depends testJoinedParentInsertSetsInitialVersionValue - */ - public function testJoinedParentFailureThrowsException(OptimisticJoinedParent $parent) - { - $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent t WHERE t.id = :id'); - $q->setParameter('id', $parent->id); - $test = $q->getSingleResult(); - - // Manually update/increment the version so we can try and save the same - // $test and make sure the exception is thrown saying the record was - // changed or updated since you read it - $this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id)); - - // Now lets change a property and try and save it again - $test->name = 'WHATT???'; - try { - $this->_em->flush(); - } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); - } - } - - public function testMultipleFlushesDoIncrementalUpdates() - { - $test = new OptimisticStandard(); - - for ($i = 0; $i < 5; $i++) { - $test->name = 'test' . $i; - $this->_em->persist($test); - $this->_em->flush(); - - $this->assertInternalType('int', $test->getVersion()); - $this->assertEquals($i + 1, $test->getVersion()); - } - } - - public function testStandardInsertSetsInitialVersionValue() - { - $test = new OptimisticStandard(); - $test->name = 'test'; - $this->_em->persist($test); - $this->_em->flush(); - - $this->assertInternalType('int', $test->getVersion()); - $this->assertEquals(1, $test->getVersion()); - - return $test; - } - - /** - * @depends testStandardInsertSetsInitialVersionValue - */ - public function testStandardFailureThrowsException(OptimisticStandard $entity) - { - $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard t WHERE t.id = :id'); - $q->setParameter('id', $entity->id); - $test = $q->getSingleResult(); - - // Manually update/increment the version so we can try and save the same - // $test and make sure the exception is thrown saying the record was - // changed or updated since you read it - $this->_conn->executeQuery('UPDATE optimistic_standard SET version = ? WHERE id = ?', array(2, $test->id)); - - // Now lets change a property and try and save it again - $test->name = 'WHATT???'; - try { - $this->_em->flush(); - } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); - } - } - - public function testOptimisticTimestampSetsDefaultValue() - { - $test = new OptimisticTimestamp(); - $test->name = 'Testing'; - - $this->assertNull($test->version, "Pre-Condition"); - - $this->_em->persist($test); - $this->_em->flush(); - - $this->assertInstanceOf('DateTime', $test->version); - - return $test; - } - - /** - * @depends testOptimisticTimestampSetsDefaultValue - */ - public function testOptimisticTimestampFailureThrowsException(OptimisticTimestamp $entity) - { - $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id'); - $q->setParameter('id', $entity->id); - $test = $q->getSingleResult(); - - $this->assertInstanceOf('DateTime', $test->version); - - // Manually increment the version datetime column - $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); - $this->_conn->executeQuery('UPDATE optimistic_timestamp SET version = ? WHERE id = ?', array(date($format, strtotime($test->version->format($format)) + 3600), $test->id)); - - // Try and update the record and it should throw an exception - $test->name = 'Testing again'; - try { - $this->_em->flush(); - } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); - } - } -} - -/** - * @Entity - * @Table(name="optimistic_joined_parent") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"parent" = "OptimisticJoinedParent", "child" = "OptimisticJoinedChild"}) - */ -class OptimisticJoinedParent -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @Column(type="string", length=255) - */ - public $name; - - /** - * @Version @Column(type="integer") - */ - public $version; -} - -/** - * @Entity - * @Table(name="optimistic_joined_child") - */ -class OptimisticJoinedChild extends OptimisticJoinedParent -{ - /** - * @Column(type="string", length=255) - */ - public $whatever; -} - -/** - * @Entity - * @Table(name="optimistic_standard") - */ -class OptimisticStandard -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @Column(type="string", length=255) - */ - public $name; - - /** - * @Version @Column(type="integer") - */ - private $version; - - function getVersion() {return $this->version;} -} - -/** - * @Entity - * @Table(name="optimistic_timestamp") - */ -class OptimisticTimestamp -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @Column(type="string", length=255) - */ - public $name; - - /** - * @Version @Column(type="datetime") - */ - public $version; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php deleted file mode 100755 index 1e1df9d513..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ /dev/null @@ -1,380 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testUnsetManyToMany() - { - $user = $this->addCmsUserGblancoWithGroups(1); - - unset($user->groups[0]->users[0]); // inverse side - unset($user->groups[0]); // owning side! - - $this->_em->flush(); - - // Check that the link in the association table has been deleted - $this->assertGblancoGroupCountIs(0); - } - - public function testBasicManyToManyJoin() - { - $user = $this->addCmsUserGblancoWithGroups(1); - $this->_em->clear(); - - $this->assertEquals(0, $this->_em->getUnitOfWork()->size()); - - $query = $this->_em->createQuery("select u, g from Doctrine\Tests\Models\CMS\CmsUser u join u.groups g"); - - $result = $query->getResult(); - - $this->assertEquals(2, $this->_em->getUnitOfWork()->size()); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - $this->assertEquals('Guilherme', $result[0]->name); - $this->assertEquals(1, $result[0]->getGroups()->count()); - $groups = $result[0]->getGroups(); - $this->assertEquals('Developers_0', $groups[0]->getName()); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0])); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0])); - - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups[0]->getUsers()); - - $groups[0]->getUsers()->clear(); - $groups->clear(); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select u, g from Doctrine\Tests\Models\CMS\CmsUser u join u.groups g"); - $this->assertEquals(0, count($query->getResult())); - } - - public function testManyToManyAddRemove() - { - $user = $this->addCmsUserGblancoWithGroups(2); - $this->_em->clear(); - - $uRep = $this->_em->getRepository(get_class($user)); - - // Get user - $user = $uRep->findOneById($user->getId()); - - $this->assertNotNull($user, "Has to return exactly one entry."); - - $this->assertFalse($user->getGroups()->isInitialized()); - - // Check groups - $this->assertEquals(2, $user->getGroups()->count()); - - $this->assertTrue($user->getGroups()->isInitialized()); - - // Remove first group - unset($user->groups[0]); - //$user->getGroups()->remove(0); - - $this->_em->flush(); - $this->_em->clear(); - - // Reload same user - $user2 = $uRep->findOneById($user->getId()); - - // Check groups - $this->assertEquals(1, $user2->getGroups()->count()); - } - - public function testManyToManyInverseSideIgnored() - { - $user = $this->addCmsUserGblancoWithGroups(0); - - $group = new CmsGroup; - $group->name = 'Humans'; - - // modify directly, addUser() would also (properly) set the owning side - $group->users[] = $user; - - $this->_em->persist($user); - $this->_em->persist($group); - $this->_em->flush(); - $this->_em->clear(); - - // Association should not exist - $user2 = $this->_em->find(get_class($user), $user->getId()); - - $this->assertNotNull($user2, "Has to return exactly one entry."); - $this->assertEquals(0, $user2->getGroups()->count()); - } - - public function testManyToManyCollectionClearing() - { - $user = $this->addCmsUserGblancoWithGroups($groupCount = 10); - - // Check that there are indeed 10 links in the association table - $this->assertGblancoGroupCountIs($groupCount); - - $user->groups->clear(); - - $this->_em->flush(); - - // Check that the links in the association table have been deleted - $this->assertGblancoGroupCountIs(0); - } - - public function testManyToManyCollectionClearAndAdd() - { - $user = $this->addCmsUserGblancoWithGroups($groupCount = 10); - - $groups = $user->groups->toArray(); - $user->groups->clear(); - - foreach ($groups AS $group) { - $user->groups[] = $group; - } - - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups); - $this->assertTrue($user->groups->isDirty()); - - $this->assertEquals($groupCount, count($user->groups), "There should be 10 groups in the collection."); - - $this->_em->flush(); - - $this->assertGblancoGroupCountIs($groupCount); - } - - /** - * @param int $expectedGroupCount - */ - public function assertGblancoGroupCountIs($expectedGroupCount) - { - $countDql = "SELECT count(g.id) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g WHERE u.username = 'gblanco'"; - $this->assertEquals( - $expectedGroupCount, - $this->_em->createQuery($countDql)->getSingleScalarResult(), - "Failed to verify that CmsUser with username 'gblanco' has a group count of 10 with a DQL count query." - ); - } - - public function testRetrieveManyToManyAndAddMore() - { - $user = $this->addCmsUserGblancoWithGroups(2); - - $group = new CmsGroup(); - $group->name = 'Developers_Fresh'; - $this->_em->persist($group); - $this->_em->flush(); - - $this->_em->clear(); - - /* @var $freshUser CmsUser */ - $freshUser = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); - $newGroup = new CmsGroup(); - $newGroup->setName('12Monkeys'); - $freshUser->addGroup($newGroup); - - $this->assertFalse($freshUser->groups->isInitialized(), "CmsUser::groups Collection has to be uninitialized for this test."); - - $this->_em->flush(); - - $this->assertFalse($freshUser->groups->isInitialized(), "CmsUser::groups Collection has to be uninitialized for this test."); - $this->assertEquals(3, count($freshUser->getGroups())); - $this->assertEquals(3, count($freshUser->getGroups()->getSnapshot()), "Snapshot of CmsUser::groups should contain 3 entries."); - - $this->_em->clear(); - - $freshUser = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); - $this->assertEquals(3, count($freshUser->getGroups())); - } - - /** - * @group DDC-130 - */ - public function testRemoveUserWithManyGroups() - { - $user = $this->addCmsUserGblancoWithGroups(2); - $userId = $user->getId(); - - $this->_em->remove($user); - $this->_em->flush(); - - $newUser = $this->_em->find(get_class($user), $userId); - $this->assertNull($newUser); - } - - /** - * @group DDC-130 - */ - public function testRemoveGroupWithUser() - { - $user = $this->addCmsUserGblancoWithGroups(2); - - foreach ($user->getGroups() AS $group) { - $this->_em->remove($group); - } - $this->_em->flush(); - $this->_em->clear(); - - $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(0, count($newUser->getGroups())); - } - - public function testDereferenceCollectionDelete() - { - $user = $this->addCmsUserGblancoWithGroups(2); - $user->groups = null; - - $this->_em->flush(); - $this->_em->clear(); - - $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(0, count($newUser->getGroups())); - } - - /** - * @group DDC-839 - */ - public function testWorkWithDqlHydratedEmptyCollection() - { - $user = $this->addCmsUserGblancoWithGroups(0); - $group = new CmsGroup(); - $group->name = "Developers0"; - $this->_em->persist($group); - - $this->_em->flush(); - $this->_em->clear(); - - $newUser = $this->_em->createQuery('SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.groups g WHERE u.id = ?1') - ->setParameter(1, $user->getId()) - ->getSingleResult(); - $this->assertEquals(0, count($newUser->groups)); - $this->assertInternalType('array', $newUser->groups->getMapping()); - - $newUser->addGroup($group); - - $this->_em->flush(); - $this->_em->clear(); - - $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(1, count($newUser->groups)); - } - - /** - * @param int $groupCount - * @return CmsUser - */ - public function addCmsUserGblancoWithGroups($groupCount = 1) - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - for ($i=0; $i < $groupCount; ++$i) { - $group = new CmsGroup; - $group->name = 'Developers_' . $i; - $user->addGroup($group); - } - - $this->_em->persist($user); - $this->_em->flush(); - - $this->assertNotNull($user->getId(), "User 'gblanco' should have an ID assigned after the persist()/flush() operation."); - - return $user; - } - - /** - * @group DDC-980 - */ - public function testUpdateDeleteSizeSubselectQueries() - { - $this->_em->createQuery("DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) = 10")->execute(); - $this->_em->createQuery("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = 'inactive' WHERE SIZE(u.groups) = 10")->execute(); - } - - /** - * @group DDC-978 - */ - public function testClearAndResetCollection() - { - $user = $this->addCmsUserGblancoWithGroups(2); - $group1 = new CmsGroup; - $group1->name = 'Developers_New1'; - $group2 = new CmsGroup; - $group2->name = 'Developers_New2'; - - $this->_em->persist($group1); - $this->_em->persist($group2); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(get_class($user), $user->id); - - $coll = new ArrayCollection(array($group1, $group2)); - $user->groups = $coll; - $this->_em->flush(); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups, - "UnitOfWork should have replaced ArrayCollection with PersistentCollection."); - $this->_em->flush(); - - $this->_em->clear(); - - $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals(2, count($user->groups)); - $this->assertEquals('Developers_New1', $user->groups[0]->name); - $this->assertEquals('Developers_New2', $user->groups[1]->name); - } - - /** - * @group DDC-733 - */ - public function testInitializePersistentCollection() - { - $user = $this->addCmsUserGblancoWithGroups(2); - $this->_em->clear(); - - $user = $this->_em->find(get_class($user), $user->id); - - $this->assertFalse($user->groups->isInitialized(), "Pre-condition: lazy collection"); - $this->_em->getUnitOfWork()->initializeObject($user->groups); - $this->assertTrue($user->groups->isInitialized(), "Collection should be initialized after calling UnitOfWork::initializeObject()"); - } - - /** - * @group DDC-1189 - * @group DDC-956 - */ - public function testClearBeforeLazyLoad() - { - $user = $this->addCmsUserGblancoWithGroups(4); - - $this->_em->clear(); - - $user = $this->_em->find(get_class($user), $user->id); - $user->groups->clear(); - $this->assertEquals(0, count($user->groups)); - - $this->_em->flush(); - - $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals(0, count($user->groups)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php deleted file mode 100755 index cfe9f1e832..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php +++ /dev/null @@ -1,202 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - $this->firstProduct = new ECommerceProduct(); - $this->firstProduct->setName("First Product"); - $this->secondProduct = new ECommerceProduct(); - $this->secondProduct->setName("Second Product"); - $this->firstCategory = new ECommerceCategory(); - $this->firstCategory->setName("Business"); - $this->secondCategory = new ECommerceCategory(); - $this->secondCategory->setName("Home"); - } - - public function testSavesAManyToManyAssociationWithCascadeSaveSet() - { - $this->firstProduct->addCategory($this->firstCategory); - $this->firstProduct->addCategory($this->secondCategory); - $this->_em->persist($this->firstProduct); - $this->_em->flush(); - - $this->assertForeignKeysContain($this->firstProduct->getId(), $this->firstCategory->getId()); - $this->assertForeignKeysContain($this->firstProduct->getId(), $this->secondCategory->getId()); - } - - public function testRemovesAManyToManyAssociation() - { - $this->firstProduct->addCategory($this->firstCategory); - $this->firstProduct->addCategory($this->secondCategory); - $this->_em->persist($this->firstProduct); - $this->firstProduct->removeCategory($this->firstCategory); - - $this->_em->flush(); - - $this->assertForeignKeysNotContain($this->firstProduct->getId(), $this->firstCategory->getId()); - $this->assertForeignKeysContain($this->firstProduct->getId(), $this->secondCategory->getId()); - - $this->firstProduct->getCategories()->remove(1); - $this->_em->flush(); - - $this->assertForeignKeysNotContain($this->firstProduct->getId(), $this->secondCategory->getId()); - } - - public function testEagerLoadFromInverseSideAndLazyLoadFromOwningSide() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_createLoadingFixture(); - $categories = $this->_findCategories(); - $this->assertLazyLoadFromOwningSide($categories); - } - - public function testEagerLoadFromOwningSideAndLazyLoadFromInverseSide() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_createLoadingFixture(); - $products = $this->_findProducts(); - $this->assertLazyLoadFromInverseSide($products); - } - - private function _createLoadingFixture() - { - $this->firstProduct->addCategory($this->firstCategory); - $this->firstProduct->addCategory($this->secondCategory); - $this->secondProduct->addCategory($this->firstCategory); - $this->secondProduct->addCategory($this->secondCategory); - $this->_em->persist($this->firstProduct); - $this->_em->persist($this->secondProduct); - - $this->_em->flush(); - $this->_em->clear(); - } - - protected function _findProducts() - { - $query = $this->_em->createQuery('SELECT p, c FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p LEFT JOIN p.categories c ORDER BY p.id, c.id'); - //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - $result = $query->getResult(); - $this->assertEquals(2, count($result)); - $cats1 = $result[0]->getCategories(); - $cats2 = $result[1]->getCategories(); - $this->assertTrue($cats1->isInitialized()); - $this->assertTrue($cats2->isInitialized()); - $this->assertFalse($cats1[0]->getProducts()->isInitialized()); - $this->assertFalse($cats2[0]->getProducts()->isInitialized()); - - return $result; - } - - protected function _findCategories() - { - $query = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\ECommerce\ECommerceCategory c LEFT JOIN c.products p ORDER BY c.id, p.id'); - //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - $result = $query->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[1]); - $prods1 = $result[0]->getProducts(); - $prods2 = $result[1]->getProducts(); - $this->assertTrue($prods1->isInitialized()); - $this->assertTrue($prods2->isInitialized()); - - $this->assertFalse($prods1[0]->getCategories()->isInitialized()); - $this->assertFalse($prods2[0]->getCategories()->isInitialized()); - - return $result; - } - - public function assertLazyLoadFromInverseSide($products) - { - list ($firstProduct, $secondProduct) = $products; - - $firstProductCategories = $firstProduct->getCategories(); - $secondProductCategories = $secondProduct->getCategories(); - - $this->assertEquals(2, count($firstProductCategories)); - $this->assertEquals(2, count($secondProductCategories)); - - $this->assertTrue($firstProductCategories[0] === $secondProductCategories[0]); - $this->assertTrue($firstProductCategories[1] === $secondProductCategories[1]); - - $firstCategoryProducts = $firstProductCategories[0]->getProducts(); - $secondCategoryProducts = $firstProductCategories[1]->getProducts(); - - $this->assertFalse($firstCategoryProducts->isInitialized()); - $this->assertFalse($secondCategoryProducts->isInitialized()); - $this->assertEquals(0, $firstCategoryProducts->unwrap()->count()); - $this->assertEquals(0, $secondCategoryProducts->unwrap()->count()); - - $this->assertEquals(2, count($firstCategoryProducts)); // lazy-load - $this->assertTrue($firstCategoryProducts->isInitialized()); - $this->assertFalse($secondCategoryProducts->isInitialized()); - $this->assertEquals(2, count($secondCategoryProducts)); // lazy-load - $this->assertTrue($secondCategoryProducts->isInitialized()); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[1]); - - $this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts); - } - - public function assertLazyLoadFromOwningSide($categories) - { - list ($firstCategory, $secondCategory) = $categories; - - $firstCategoryProducts = $firstCategory->getProducts(); - $secondCategoryProducts = $secondCategory->getProducts(); - - $this->assertEquals(2, count($firstCategoryProducts)); - $this->assertEquals(2, count($secondCategoryProducts)); - - $this->assertTrue($firstCategoryProducts[0] === $secondCategoryProducts[0]); - $this->assertTrue($firstCategoryProducts[1] === $secondCategoryProducts[1]); - - $firstProductCategories = $firstCategoryProducts[0]->getCategories(); - $secondProductCategories = $firstCategoryProducts[1]->getCategories(); - - $this->assertFalse($firstProductCategories->isInitialized()); - $this->assertFalse($secondProductCategories->isInitialized()); - $this->assertEquals(0, $firstProductCategories->unwrap()->count()); - $this->assertEquals(0, $secondProductCategories->unwrap()->count()); - - $this->assertEquals(2, count($firstProductCategories)); // lazy-load - $this->assertTrue($firstProductCategories->isInitialized()); - $this->assertFalse($secondProductCategories->isInitialized()); - $this->assertEquals(2, count($secondProductCategories)); // lazy-load - $this->assertTrue($secondProductCategories->isInitialized()); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[1]); - - $this->assertCollectionEquals($firstProductCategories, $secondProductCategories); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php deleted file mode 100755 index 47c96b1fe0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php +++ /dev/null @@ -1,76 +0,0 @@ - - */ -class ManyToManyEventTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - /** - * @var PostUpdateListener - */ - private $listener; - - protected function setUp() - { - $this->useModelSet('cms'); - parent::setUp(); - $this->listener = new PostUpdateListener(); - $evm = $this->_em->getEventManager(); - $evm->addEventListener(Events::postUpdate, $this->listener); - } - - public function testListenerShouldBeNotifiedOnlyWhenUpdating() - { - $user = $this->createNewValidUser(); - $this->_em->persist($user); - $this->_em->flush(); - $this->assertFalse($this->listener->wasNotified); - - $group = new CmsGroup(); - $group->name = "admins"; - $user->addGroup($group); - $this->_em->persist($user); - $this->_em->flush(); - - $this->assertTrue($this->listener->wasNotified); - } - - /** - * @return CmsUser - */ - private function createNewValidUser() - { - $user = new CmsUser(); - $user->username = 'fran6co'; - $user->name = 'Francisco Facioni'; - $group = new CmsGroup(); - $group->name = "users"; - $user->addGroup($group); - return $user; - } -} - -class PostUpdateListener -{ - /** - * @var bool - */ - public $wasNotified = false; - - /** - * @param $args - */ - public function postUpdate($args) - { - $this->wasNotified = true; - } -} - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php deleted file mode 100755 index 40518e086c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php +++ /dev/null @@ -1,124 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - $this->firstProduct = new ECommerceProduct(); - $this->secondProduct = new ECommerceProduct(); - $this->firstRelated = new ECommerceProduct(); - $this->firstRelated->setName("Business"); - $this->secondRelated = new ECommerceProduct(); - $this->secondRelated->setName("Home"); - } - - public function testSavesAManyToManyAssociationWithCascadeSaveSet() - { - $this->firstProduct->addRelated($this->firstRelated); - $this->firstProduct->addRelated($this->secondRelated); - $this->_em->persist($this->firstProduct); - $this->_em->flush(); - - $this->assertForeignKeysContain($this->firstProduct->getId(), - $this->firstRelated->getId()); - $this->assertForeignKeysContain($this->firstProduct->getId(), - $this->secondRelated->getId()); - } - - public function testRemovesAManyToManyAssociation() - { - $this->firstProduct->addRelated($this->firstRelated); - $this->firstProduct->addRelated($this->secondRelated); - $this->_em->persist($this->firstProduct); - $this->firstProduct->removeRelated($this->firstRelated); - - $this->_em->flush(); - - $this->assertForeignKeysNotContain($this->firstProduct->getId(), - $this->firstRelated->getId()); - $this->assertForeignKeysContain($this->firstProduct->getId(), - $this->secondRelated->getId()); - } - - public function testEagerLoadsOwningSide() - { - $this->_createLoadingFixture(); - $products = $this->_findProducts(); - $this->assertLoadingOfOwningSide($products); - } - - public function testLazyLoadsOwningSide() - { - $this->_createLoadingFixture(); - - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); - $metadata->associationMappings['related']['fetch'] = ClassMetadata::FETCH_LAZY; - - $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); - $products = $query->getResult(); - $this->assertLoadingOfOwningSide($products); - } - - public function assertLoadingOfOwningSide($products) - { - list ($firstProduct, $secondProduct) = $products; - $this->assertEquals(2, count($firstProduct->getRelated())); - $this->assertEquals(2, count($secondProduct->getRelated())); - - $categories = $firstProduct->getRelated(); - $firstRelatedBy = $categories[0]->getRelated(); - $secondRelatedBy = $categories[1]->getRelated(); - - $this->assertEquals(2, count($firstRelatedBy)); - $this->assertEquals(2, count($secondRelatedBy)); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[1]); - - $this->assertCollectionEquals($firstRelatedBy, $secondRelatedBy); - } - - protected function _createLoadingFixture() - { - $this->firstProduct->addRelated($this->firstRelated); - $this->firstProduct->addRelated($this->secondRelated); - $this->secondProduct->addRelated($this->firstRelated); - $this->secondProduct->addRelated($this->secondRelated); - $this->_em->persist($this->firstProduct); - $this->_em->persist($this->secondProduct); - - $this->_em->flush(); - $this->_em->clear(); - } - - protected function _findProducts() - { - $query = $this->_em->createQuery('SELECT p, r FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p LEFT JOIN p.related r ORDER BY p.id, r.id'); - return $query->getResult(); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php deleted file mode 100755 index ba83d5315e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php +++ /dev/null @@ -1,108 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - $this->firstProduct = new ECommerceProduct(); - $this->firstProduct->setName('Doctrine 1.x Manual'); - $this->secondProduct = new ECommerceProduct(); - $this->secondProduct->setName('Doctrine 2.x Manual'); - $this->firstCart = new ECommerceCart(); - $this->secondCart = new ECommerceCart(); - } - - public function testSavesAManyToManyAssociationWithCascadeSaveSet() - { - $this->firstCart->addProduct($this->firstProduct); - $this->firstCart->addProduct($this->secondProduct); - $this->_em->persist($this->firstCart); - $this->_em->flush(); - - $this->assertForeignKeysContain($this->firstCart->getId(), $this->firstProduct->getId()); - $this->assertForeignKeysContain($this->firstCart->getId(), $this->secondProduct->getId()); - } - - public function testRemovesAManyToManyAssociation() - { - $this->firstCart->addProduct($this->firstProduct); - $this->firstCart->addProduct($this->secondProduct); - $this->_em->persist($this->firstCart); - $this->firstCart->removeProduct($this->firstProduct); - - $this->_em->flush(); - - $this->assertForeignKeysNotContain($this->firstCart->getId(), $this->firstProduct->getId()); - $this->assertForeignKeysContain($this->firstCart->getId(), $this->secondProduct->getId()); - } - - public function testEagerLoad() - { - $this->_createFixture(); - - $query = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\ECommerce\ECommerceCart c LEFT JOIN c.products p ORDER BY c.id, p.id'); - $result = $query->getResult(); - $firstCart = $result[0]; - $products = $firstCart->getProducts(); - $secondCart = $result[1]; - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]); - $this->assertCollectionEquals($products, $secondCart->getProducts()); - //$this->assertEquals("Doctrine 1.x Manual", $products[0]->getName()); - //$this->assertEquals("Doctrine 2.x Manual", $products[1]->getName()); - } - - public function testLazyLoadsCollection() - { - $this->_createFixture(); - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); - $metadata->associationMappings['products']['fetch'] = ClassMetadata::FETCH_LAZY; - - $query = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\ECommerce\ECommerceCart c'); - $result = $query->getResult(); - $firstCart = $result[0]; - $products = $firstCart->getProducts(); - $secondCart = $result[1]; - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]); - $this->assertCollectionEquals($products, $secondCart->getProducts()); - } - - private function _createFixture() - { - $this->firstCart->addProduct($this->firstProduct); - $this->firstCart->addProduct($this->secondProduct); - $this->secondCart->addProduct($this->firstProduct); - $this->secondCart->addProduct($this->secondProduct); - $this->_em->persist($this->firstCart); - $this->_em->persist($this->secondCart); - - $this->_em->flush(); - $this->_em->clear(); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php deleted file mode 100755 index f4439b9ad0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php +++ /dev/null @@ -1,47 +0,0 @@ -useModelSet('directorytree'); - parent::setUp(); - } - - public function testCRUD() - { - $root = new \Doctrine\Tests\Models\DirectoryTree\Directory(); - $root->setName('Root'); - $root->setPath('/root'); - - $directory = new \Doctrine\Tests\Models\DirectoryTree\Directory($root); - $directory->setName('TestA'); - $directory->setPath('/root/dir'); - - $file = new \Doctrine\Tests\Models\DirectoryTree\File($directory); - $file->setName('test-b.html'); - - $this->_em->persist($root); - $this->_em->persist($directory); - $this->_em->persist($file); - - $this->_em->flush(); - $this->_em->clear(); - - $cleanFile = $this->_em->find(get_class($file), $file->getId()); - - $this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $cleanFile->getParent()); - $this->assertEquals($directory->getId(), $cleanFile->getParent()->getId()); - $this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()->getParent()); - $this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php deleted file mode 100755 index 3436a74f4f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ /dev/null @@ -1,712 +0,0 @@ -useModelSet('cms'); - $this->useModelSet('company'); - parent::setUp(); - $this->platform = $this->_em->getConnection()->getDatabasePlatform(); - } - - public function testBasicNativeQuery() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); - $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); - - $query = $this->_em->createNativeQuery('SELECT id, name FROM cms_users WHERE username = ?', $rsm); - $query->setParameter(1, 'romanb'); - - $users = $query->getResult(); - - $this->assertEquals(1, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - $this->assertEquals('Roman', $users[0]->name); - } - - public function testBasicNativeQueryWithMetaResult() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - - $addr = new CmsAddress; - $addr->country = 'germany'; - $addr->zip = 10827; - $addr->city = 'Berlin'; - - - $user->setAddress($addr); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsAddress', 'a'); - $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('id'), 'id'); - $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country'); - $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip'); - $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('city'), 'city'); - $rsm->addMetaResult('a', $this->platform->getSQLResultCasing('user_id'), 'user_id'); - - $query = $this->_em->createNativeQuery('SELECT a.id, a.country, a.zip, a.city, a.user_id FROM cms_addresses a WHERE a.id = ?', $rsm); - $query->setParameter(1, $addr->id); - - $addresses = $query->getResult(); - - $this->assertEquals(1, count($addresses)); - $this->assertTrue($addresses[0] instanceof CmsAddress); - $this->assertEquals($addr->country, $addresses[0]->country); - $this->assertEquals($addr->zip, $addresses[0]->zip); - $this->assertEquals($addr->city, $addresses[0]->city); - $this->assertEquals($addr->street, $addresses[0]->street); - $this->assertTrue($addresses[0]->user instanceof CmsUser); - } - - public function testJoinedOneToManyNativeQuery() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - - $phone = new CmsPhonenumber; - $phone->phonenumber = 424242; - - $user->addPhonenumber($phone); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); - $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); - $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status'); - $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); - $rsm->addFieldResult('p', $this->platform->getSQLResultCasing('phonenumber'), 'phonenumber'); - - $query = $this->_em->createNativeQuery('SELECT id, name, status, phonenumber FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', $rsm); - $query->setParameter(1, 'romanb'); - - $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); - $this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($users[0]->getPhonenumbers())); - $phones = $users[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $users[0]); - - } - - public function testJoinedOneToOneNativeQuery() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - - $addr = new CmsAddress; - $addr->country = 'germany'; - $addr->zip = 10827; - $addr->city = 'Berlin'; - - - $user->setAddress($addr); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); - $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); - $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status'); - $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address'); - $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('a_id'), 'id'); - $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country'); - $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip'); - $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('city'), 'city'); - - $query = $this->_em->createNativeQuery('SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); - $query->setParameter(1, 'romanb'); - - $users = $query->getResult(); - - $this->assertEquals(1, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); - $this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress()); - $this->assertTrue($users[0]->getAddress()->getUser() == $users[0]); - $this->assertEquals('germany', $users[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); - $this->assertEquals('Berlin', $users[0]->getAddress()->getCity()); - } - - public function testFluentInterface() - { - $parameters = new ArrayCollection; - $parameters->add(new Parameter(1, 'foo')); - $parameters->add(new Parameter(2, 'bar')); - - $rsm = new ResultSetMapping; - - $q = $this->_em->createNativeQuery('SELECT id, name, status, phonenumber FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', $rsm); - $q2 = $q->setSql('foo', $rsm) - ->setResultSetMapping($rsm) - ->expireResultCache(true) - ->setHint('foo', 'bar') - ->setParameter(1, 'foo') - ->setParameters($parameters) - ->setResultCacheDriver(null) - ->setResultCacheLifetime(3500); - - $this->assertSame($q, $q2); - } - - public function testJoinedOneToManyNativeQueryWithRSMBuilder() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - - $phone = new CmsPhonenumber; - $phone->phonenumber = 424242; - - $user->addPhonenumber($phone); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $rsm = new ResultSetMappingBuilder($this->_em); - $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); - $query = $this->_em->createNativeQuery('SELECT u.*, p.* FROM cms_users u LEFT JOIN cms_phonenumbers p ON u.id = p.user_id WHERE username = ?', $rsm); - $query->setParameter(1, 'romanb'); - - $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); - $this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($users[0]->getPhonenumbers())); - $phones = $users[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $users[0]); - - $this->_em->clear(); - - $rsm = new ResultSetMappingBuilder($this->_em); - $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p'); - $query = $this->_em->createNativeQuery('SELECT p.* FROM cms_phonenumbers p WHERE p.phonenumber = ?', $rsm); - $query->setParameter(1, $phone->phonenumber); - $phone = $query->getSingleResult(); - - $this->assertNotNull($phone->getUser()); - $this->assertEquals($user->name, $phone->getUser()->getName()); - } - - public function testJoinedOneToOneNativeQueryWithRSMBuilder() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - - $addr = new CmsAddress; - $addr->country = 'germany'; - $addr->zip = 10827; - $addr->city = 'Berlin'; - - - $user->setAddress($addr); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - - $rsm = new ResultSetMappingBuilder($this->_em); - $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address', array('id' => 'a_id')); - - $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); - $query->setParameter(1, 'romanb'); - - $users = $query->getResult(); - - $this->assertEquals(1, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); - $this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress()); - $this->assertTrue($users[0]->getAddress()->getUser() == $users[0]); - $this->assertEquals('germany', $users[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); - $this->assertEquals('Berlin', $users[0]->getAddress()->getCity()); - - $this->_em->clear(); - - $rsm = new ResultSetMappingBuilder($this->_em); - $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a'); - $query = $this->_em->createNativeQuery('SELECT a.* FROM cms_addresses a WHERE a.id = ?', $rsm); - $query->setParameter(1, $addr->getId()); - $address = $query->getSingleResult(); - - $this->assertNotNull($address->getUser()); - $this->assertEquals($user->name, $address->getUser()->getName()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRSMBuilderThrowsExceptionOnColumnConflict() - { - $rsm = new ResultSetMappingBuilder($this->_em); - $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address'); - } - - /** - * @group PR-39 - */ - public function testUnknownParentAliasThrowsException() - { - $rsm = new ResultSetMappingBuilder($this->_em); - $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'un', 'address', array('id' => 'a_id')); - - $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); - $query->setParameter(1, 'romanb'); - - $this->setExpectedException( - "Doctrine\ORM\Internal\Hydration\HydrationException", - "The parent object of entity result with alias 'a' was not found. The parent alias is 'un'." - ); - $users = $query->getResult(); - } - - - /** - * @group DDC-1663 - */ - public function testBasicNativeNamedQueryWithSqlResultSetMapping() - { - $user = new CmsUser; - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $addr = new CmsAddress; - $addr->country = 'Brazil'; - $addr->zip = 10827; - $addr->city = 'São Paulo'; - - $user->setAddress($addr); - - $this->_em->clear(); - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); - $query = $repository->createNativeNamedQuery('find-all'); - $result = $query->getResult(); - - $this->assertCount(1, $result); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $result[0]); - $this->assertEquals($addr->id, $result[0]->id); - $this->assertEquals($addr->city, $result[0]->city); - $this->assertEquals($addr->country, $result[0]->country); - } - - /** - * @group DDC-1663 - */ - public function testBasicNativeNamedQueryWithResultClass() - { - $user = new CmsUser; - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $email = new CmsEmail(); - $email->email = 'fabio.bat.silva@gmail.com'; - - $user->setEmail($email); - - $this->_em->clear(); - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - - $result = $repository->createNativeNamedQuery('fetchIdAndUsernameWithResultClass') - ->setParameter(1, 'FabioBatSilva')->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - $this->assertNull($result[0]->name); - $this->assertNull($result[0]->email); - $this->assertEquals($user->id, $result[0]->id); - $this->assertEquals('FabioBatSilva', $result[0]->username); - - $this->_em->clear(); - - - $result = $repository->createNativeNamedQuery('fetchAllColumns') - ->setParameter(1, 'FabioBatSilva')->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - $this->assertEquals($user->id, $result[0]->id); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertEquals('FabioBatSilva', $result[0]->username); - $this->assertEquals('dev', $result[0]->status); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsEmail', $result[0]->email); - } - - - /** - * @group DDC-1663 - */ - public function testJoinedOneToOneNativeNamedQueryWithResultSetMapping() - { - $user = new CmsUser; - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $addr = new CmsAddress; - $addr->country = 'Brazil'; - $addr->zip = 10827; - $addr->city = 'São Paulo'; - - - $user->setAddress($addr); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - - $result = $repository->createNativeNamedQuery('fetchJoinedAddress') - ->setParameter(1, 'FabioBatSilva')->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]->getPhonenumbers()); - $this->assertFalse($result[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $result[0]->getAddress()); - $this->assertTrue($result[0]->getAddress()->getUser() == $result[0]); - $this->assertEquals('Brazil', $result[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $result[0]->getAddress()->getZipCode()); - $this->assertEquals('São Paulo', $result[0]->getAddress()->getCity()); - } - - /** - * @group DDC-1663 - */ - public function testJoinedOneToManyNativeNamedQueryWithResultSetMapping() - { - $user = new CmsUser; - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $phone = new CmsPhonenumber; - $phone->phonenumber = 424242; - - $user->addPhonenumber($phone); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $result = $repository->createNativeNamedQuery('fetchJoinedPhonenumber') - ->setParameter(1, 'FabioBatSilva')->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]->getPhonenumbers()); - $this->assertTrue($result[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($result[0]->getPhonenumbers())); - $phones = $result[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $result[0]); - } - - /** - * @group DDC-1663 - */ - public function testMixedNativeNamedQueryNormalJoin() - { - $user1 = new CmsUser; - $user1->name = 'Fabio B. Silva'; - $user1->username = 'FabioBatSilva'; - $user1->status = 'dev'; - - $user2 = new CmsUser; - $user2->name = 'test tester'; - $user2->username = 'test'; - $user2->status = 'tester'; - - $phone1 = new CmsPhonenumber; - $phone2 = new CmsPhonenumber; - $phone3 = new CmsPhonenumber; - $phone1->phonenumber = 11111111; - $phone2->phonenumber = 22222222; - $phone3->phonenumber = 33333333; - - $user1->addPhonenumber($phone1); - $user1->addPhonenumber($phone2); - $user2->addPhonenumber($phone3); - - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - - $result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount') - ->setParameter(1, array('test','FabioBatSilva'))->getResult(); - - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - - // first user => 2 phonenumbers - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); - $this->assertEquals('Fabio B. Silva', $result[0][0]->name); - $this->assertEquals(2, $result[0]['numphones']); - - // second user => 1 phonenumbers - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]); - $this->assertEquals('test tester', $result[1][0]->name); - $this->assertEquals(1, $result[1]['numphones']); - } - - /** - * @group DDC-1663 - */ - public function testNativeNamedQueryInheritance() - { - $person = new CompanyPerson; - $person->setName('Fabio B. Silva'); - - $employee = new CompanyEmployee; - $employee->setName('Fabio Silva'); - $employee->setSalary(100000); - $employee->setDepartment('IT'); - - $this->_em->persist($person); - $this->_em->persist($employee); - - $this->_em->flush(); - $this->_em->clear(); - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson'); - - $result = $repository->createNativeNamedQuery('fetchAllWithSqlResultSetMapping') - ->getResult(); - - $this->assertEquals(2, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[1]); - $this->assertTrue(is_numeric($result[0]->getId())); - $this->assertTrue(is_numeric($result[1]->getId())); - $this->assertEquals('Fabio B. Silva', $result[0]->getName()); - $this->assertEquals('Fabio Silva', $result[1]->getName()); - - - $this->_em->clear(); - - - $result = $repository->createNativeNamedQuery('fetchAllWithResultClass') - ->getResult(); - - $this->assertEquals(2, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[1]); - $this->assertTrue(is_numeric($result[0]->getId())); - $this->assertTrue(is_numeric($result[1]->getId())); - $this->assertEquals('Fabio B. Silva', $result[0]->getName()); - $this->assertEquals('Fabio Silva', $result[1]->getName()); - } - - /** - * @group DDC-1663 - * DQL : SELECT u, a, COUNT(p) AS numphones FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.address a JOIN u.phonenumbers p - */ - public function testMultipleEntityResults() - { - - $user = new CmsUser; - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $addr = new CmsAddress; - $addr->country = 'Brazil'; - $addr->zip = 10827; - $addr->city = 'São Paulo'; - - $phone = new CmsPhonenumber; - $phone->phonenumber = 424242; - - - $user->setAddress($addr); - $user->addPhonenumber($phone); - - - $this->_em->clear(); - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - - $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $query = $repository->createNativeNamedQuery('fetchMultipleJoinsEntityResults'); - $result = $query->getResult(); - - - $this->assertEquals(1, count($result)); - $this->assertTrue(is_array($result[0])); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); - $this->assertEquals('Fabio B. Silva', $result[0][0]->name); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $result[0][0]->getAddress()); - $this->assertTrue($result[0][0]->getAddress()->getUser() == $result[0][0]); - $this->assertEquals('Brazil', $result[0][0]->getAddress()->getCountry()); - $this->assertEquals(10827, $result[0][0]->getAddress()->getZipCode()); - - $this->assertEquals(1, $result[0]['numphones']); - - } - - /** - * @group DDC-1663 - */ - public function testNamedNativeQueryInheritance() - { - $contractMetadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyContract'); - $flexMetadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyFlexContract'); - - $contractQueries = $contractMetadata->getNamedNativeQueries(); - $flexQueries = $flexMetadata->getNamedNativeQueries(); - - $contractMappings = $contractMetadata->getSqlResultSetMappings(); - $flexMappings = $flexMetadata->getSqlResultSetMappings(); - - - // contract queries - $this->assertEquals('all-contracts', $contractQueries['all-contracts']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyContract', $contractQueries['all-contracts']['resultClass']); - - $this->assertEquals('all', $contractQueries['all']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyContract', $contractQueries['all']['resultClass']); - - - // flex contract queries - $this->assertEquals('all-contracts', $flexQueries['all-contracts']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexQueries['all-contracts']['resultClass']); - - $this->assertEquals('all-flex', $flexQueries['all-flex']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexQueries['all-flex']['resultClass']); - - $this->assertEquals('all', $flexQueries['all']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexQueries['all']['resultClass']); - - - // contract result mapping - $this->assertEquals('mapping-all-contracts', $contractMappings['mapping-all-contracts']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyContract', $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); - - $this->assertEquals('mapping-all', $contractMappings['mapping-all']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyContract', $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); - - // flex contract result mapping - $this->assertEquals('mapping-all-contracts', $flexMappings['mapping-all-contracts']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexMappings['mapping-all-contracts']['entities'][0]['entityClass']); - - $this->assertEquals('mapping-all', $flexMappings['mapping-all']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexMappings['mapping-all']['entities'][0]['entityClass']); - - $this->assertEquals('mapping-all-flex', $flexMappings['mapping-all-flex']['name']); - $this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexMappings['mapping-all-flex']['entities'][0]['entityClass']); - - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php deleted file mode 100755 index 069e11c237..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ /dev/null @@ -1,173 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyUser'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyGroup') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - - public function testChangeTracking() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $user = new NotifyUser(); - $group = new NotifyGroup(); - $user->setName('roman'); - $group->setName('dev'); - - $user->getGroups()->add($group); - $group->getUsers()->add($user); - - $this->_em->persist($user); - $this->_em->persist($group); - - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); - - $this->_em->flush(); - $this->_em->clear(); - - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); - - $userId = $user->getId(); - $groupId = $group->getId(); - unset($user, $group); - - $user = $this->_em->find(__NAMESPACE__.'\NotifyUser', $userId); - $this->assertEquals(1, $user->getGroups()->count()); - $group = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $groupId); - $this->assertEquals(1, $group->getUsers()->count()); - - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); - - $group2 = new NotifyGroup(); - $group2->setName('nerds'); - $this->_em->persist($group2); - $user->getGroups()->add($group2); - $group2->getUsers()->add($user); - - $group->setName('geeks'); - - $this->_em->flush(); - $this->_em->clear(); - - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); - - $group2Id = $group2->getId(); - unset($group2, $user); - - $user = $this->_em->find(__NAMESPACE__.'\NotifyUser', $userId); - $this->assertEquals(2, $user->getGroups()->count()); - $group2 = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $group2Id); - $this->assertEquals(1, $group2->getUsers()->count()); - $group = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $groupId); - $this->assertEquals(1, $group->getUsers()->count()); - $this->assertEquals('geeks', $group->getName()); - } -} - -class NotifyBaseEntity implements NotifyPropertyChanged { - public $listeners = array(); - - public function addPropertyChangedListener(PropertyChangedListener $listener) { - $this->listeners[] = $listener; - } - - protected function onPropertyChanged($propName, $oldValue, $newValue) { - if ($this->listeners) { - foreach ($this->listeners as $listener) { - $listener->propertyChanged($this, $propName, $oldValue, $newValue); - } - } - } -} - -/** @Entity @ChangeTrackingPolicy("NOTIFY") */ -class NotifyUser extends NotifyBaseEntity { - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - - /** @Column */ - private $name; - - /** @ManyToMany(targetEntity="NotifyGroup") */ - private $groups; - - function __construct() { - $this->groups = new ArrayCollection; - } - - function getId() { - return $this->id; - } - - function getName() { - return $this->name; - } - - function setName($name) { - $this->onPropertyChanged('name', $this->name, $name); - $this->name = $name; - } - - function getGroups() { - return $this->groups; - } -} - -/** @Entity */ -class NotifyGroup extends NotifyBaseEntity { - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - - /** @Column */ - private $name; - - /** @ManyToMany(targetEntity="NotifyUser", mappedBy="groups") */ - private $users; - - function __construct() { - $this->users = new ArrayCollection; - } - - function getId() { - return $this->id; - } - - function getName() { - return $this->name; - } - - function setName($name) { - $this->onPropertyChanged('name', $this->name, $name); - $this->name = $name; - } - - function getUsers() { - return $this->users; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php deleted file mode 100755 index f513395d7b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ /dev/null @@ -1,240 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - $this->product = new ECommerceProduct(); - $this->product->setName('Doctrine Cookbook'); - $this->firstFeature = new ECommerceFeature(); - $this->firstFeature->setDescription('Model writing tutorial'); - $this->secondFeature = new ECommerceFeature(); - $this->secondFeature->setDescription('Annotations examples'); - } - - public function testSavesAOneToManyAssociationWithCascadeSaveSet() { - $this->product->addFeature($this->firstFeature); - $this->product->addFeature($this->secondFeature); - $this->_em->persist($this->product); - $this->_em->flush(); - - $this->assertFeatureForeignKeyIs($this->product->getId(), $this->firstFeature); - $this->assertFeatureForeignKeyIs($this->product->getId(), $this->secondFeature); - } - - public function testSavesAnEmptyCollection() - { - $this->_em->persist($this->product); - $this->_em->flush(); - - $this->assertEquals(0, count($this->product->getFeatures())); - } - - public function testDoesNotSaveAnInverseSideSet() { - $this->product->brokenAddFeature($this->firstFeature); - $this->_em->persist($this->product); - $this->_em->flush(); - - $this->assertFeatureForeignKeyIs(null, $this->firstFeature); - } - - public function testRemovesOneToOneAssociation() - { - $this->product->addFeature($this->firstFeature); - $this->product->addFeature($this->secondFeature); - $this->_em->persist($this->product); - - $this->product->removeFeature($this->firstFeature); - $this->_em->flush(); - - $this->assertFeatureForeignKeyIs(null, $this->firstFeature); - $this->assertFeatureForeignKeyIs($this->product->getId(), $this->secondFeature); - } - - public function testEagerLoadsOneToManyAssociation() - { - $this->_createFixture(); - $query = $this->_em->createQuery('select p, f from Doctrine\Tests\Models\ECommerce\ECommerceProduct p join p.features f'); - $result = $query->getResult(); - $product = $result[0]; - - $features = $product->getFeatures(); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[0]); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $features[0]->getProduct()); - $this->assertSame($product, $features[0]->getProduct()); - $this->assertEquals('Model writing tutorial', $features[0]->getDescription()); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[1]); - $this->assertSame($product, $features[1]->getProduct()); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $features[1]->getProduct()); - $this->assertEquals('Annotations examples', $features[1]->getDescription()); - } - - public function testLazyLoadsObjectsOnTheOwningSide() - { - $this->_createFixture(); - - $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); - $result = $query->getResult(); - $product = $result[0]; - $features = $product->getFeatures(); - - $this->assertFalse($features->isInitialized()); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[0]); - $this->assertTrue($features->isInitialized()); - $this->assertSame($product, $features[0]->getProduct()); - $this->assertEquals('Model writing tutorial', $features[0]->getDescription()); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[1]); - $this->assertSame($product, $features[1]->getProduct()); - $this->assertEquals('Annotations examples', $features[1]->getDescription()); - } - - public function testLazyLoadsObjectsOnTheInverseSide() - { - $this->_createFixture(); - - $query = $this->_em->createQuery('select f from Doctrine\Tests\Models\ECommerce\ECommerceFeature f'); - $features = $query->getResult(); - - $product = $features[0]->getProduct(); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $product); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $product); - $this->assertFalse($product->__isInitialized__); - $this->assertSame('Doctrine Cookbook', $product->getName()); - $this->assertTrue($product->__isInitialized__); - } - - public function testLazyLoadsObjectsOnTheInverseSide2() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_createFixture(); - - $query = $this->_em->createQuery('select f,p from Doctrine\Tests\Models\ECommerce\ECommerceFeature f join f.product p'); - $features = $query->getResult(); - - $product = $features[0]->getProduct(); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $product); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $product); - $this->assertSame('Doctrine Cookbook', $product->getName()); - - $this->assertFalse($product->getFeatures()->isInitialized()); - - // This would trigger lazy-load - //$this->assertEquals(2, $product->getFeatures()->count()); - //$this->assertTrue($product->getFeatures()->contains($features[0])); - //$this->assertTrue($product->getFeatures()->contains($features[1])); - - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(null); - } - - public function testJoinFromOwningSide() - { - $query = $this->_em->createQuery('select f,p from Doctrine\Tests\Models\ECommerce\ECommerceFeature f join f.product p'); - $features = $query->getResult(); - $this->assertEquals(0, count($features)); - } - - /** - * @group DDC-1637 - */ - public function testMatching() - { - $this->_createFixture(); - - $product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId()); - $features = $product->getFeatures(); - - $results = $features->matching(new Criteria( - Criteria::expr()->eq('description', 'Model writing tutorial') - )); - - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); - $this->assertEquals(1, count($results)); - - $results = $features->matching(new Criteria()); - - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); - $this->assertEquals(2, count($results)); - } - - /** - * @group DDC-2340 - */ - public function testMatchingOnDirtyCollection() - { - $this->_createFixture(); - - $product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId()); - - $thirdFeature = new ECommerceFeature(); - $thirdFeature->setDescription('Model writing tutorial'); - - $features = $product->getFeatures(); - $features->add($thirdFeature); - - $results = $features->matching(new Criteria( - Criteria::expr()->eq('description', 'Model writing tutorial') - )); - - $this->assertEquals(2, count($results)); - } - - public function testMatchingBis() - { - $this->_createFixture(); - - $product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId()); - $features = $product->getFeatures(); - - $thirdFeature = new ECommerceFeature(); - $thirdFeature->setDescription('Third feature'); - $product->addFeature($thirdFeature); - - $results = $features->matching(new Criteria( - Criteria::expr()->eq('description', 'Third feature') - )); - - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); - $this->assertCount(1, $results); - - $results = $features->matching(new Criteria()); - - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); - $this->assertCount(3, $results); - } - - private function _createFixture() - { - $this->product->addFeature($this->firstFeature); - $this->product->addFeature($this->secondFeature); - $this->_em->persist($this->product); - - $this->_em->flush(); - $this->_em->clear(); - } - - public function assertFeatureForeignKeyIs($value, ECommerceFeature $feature) { - $foreignKey = $this->_em->getConnection()->executeQuery( - 'SELECT product_id FROM ecommerce_features WHERE id=?', - array($feature->getId()) - )->fetchColumn(); - $this->assertEquals($value, $foreignKey); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php deleted file mode 100755 index 28101ccc7c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php +++ /dev/null @@ -1,75 +0,0 @@ -useModelSet('cms'); - - parent::setUp(); - - $user = new CmsUser; - $user->status = 'dev'; - $user->username = 'romanb'; - $user->name = 'Roman B.'; - - $phone = new CmsPhonenumber; - $phone->phonenumber = '123456'; - - $user->addPhonenumber($phone); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->userId = $user->getId(); - $this->_em->clear(); - } - - public function testOrphanRemoval() - { - $userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - - $this->_em->remove($userProxy); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); - $result = $query->getResult(); - - $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); - - $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); - $result = $query->getResult(); - - $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); - } - - /** - * @group DDC-1496 - */ - public function testOrphanRemovalUnitializedCollection() - { - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - - $user->phonenumbers->clear(); - $this->_em->flush(); - - $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); - $result = $query->getResult(); - - $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php deleted file mode 100755 index d162171576..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php +++ /dev/null @@ -1,123 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - $this->parent = new ECommerceCategory(); - $this->parent->setName('Programming languages books'); - $this->firstChild = new ECommerceCategory(); - $this->firstChild->setName('Java books'); - $this->secondChild = new ECommerceCategory(); - $this->secondChild->setName('Php books'); - } - - public function testSavesAOneToManyAssociationWithCascadeSaveSet() { - $this->parent->addChild($this->firstChild); - $this->parent->addChild($this->secondChild); - $this->_em->persist($this->parent); - - $this->_em->flush(); - - $this->assertForeignKeyIs($this->parent->getId(), $this->firstChild); - $this->assertForeignKeyIs($this->parent->getId(), $this->secondChild); - } - - public function testSavesAnEmptyCollection() - { - $this->_em->persist($this->parent); - $this->_em->flush(); - - $this->assertEquals(0, count($this->parent->getChildren())); - } - - public function testDoesNotSaveAnInverseSideSet() { - $this->parent->brokenAddChild($this->firstChild); - $this->_em->persist($this->parent); - $this->_em->flush(); - - $this->assertForeignKeyIs(null, $this->firstChild); - } - - public function testRemovesOneToManyAssociation() - { - $this->parent->addChild($this->firstChild); - $this->parent->addChild($this->secondChild); - $this->_em->persist($this->parent); - - $this->parent->removeChild($this->firstChild); - $this->_em->flush(); - - $this->assertForeignKeyIs(null, $this->firstChild); - $this->assertForeignKeyIs($this->parent->getId(), $this->secondChild); - } - - public function testEagerLoadsOneToManyAssociation() - { - $this->_createFixture(); - - $query = $this->_em->createQuery('select c1, c2 from Doctrine\Tests\Models\ECommerce\ECommerceCategory c1 join c1.children c2'); - $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $parent = $result[0]; - $children = $parent->getChildren(); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[0]); - $this->assertSame($parent, $children[0]->getParent()); - $this->assertEquals(' books', strstr($children[0]->getName(), ' books')); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[1]); - $this->assertSame($parent, $children[1]->getParent()); - $this->assertEquals(' books', strstr($children[1]->getName(), ' books')); - } - - public function testLazyLoadsOneToManyAssociation() - { - $this->_createFixture(); - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCategory'); - $metadata->associationMappings['children']['fetch'] = ClassMetadata::FETCH_LAZY; - - $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCategory c order by c.id asc'); - $result = $query->getResult(); - $parent = $result[0]; - $children = $parent->getChildren(); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[0]); - $this->assertSame($parent, $children[0]->getParent()); - $this->assertEquals(' books', strstr($children[0]->getName(), ' books')); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[1]); - $this->assertSame($parent, $children[1]->getParent()); - $this->assertEquals(' books', strstr($children[1]->getName(), ' books')); - } - - private function _createFixture() - { - $this->parent->addChild($this->firstChild); - $this->parent->addChild($this->secondChild); - $this->_em->persist($this->parent); - - $this->_em->flush(); - $this->_em->clear(); - } - - public function assertForeignKeyIs($value, ECommerceCategory $child) { - $foreignKey = $this->_em->getConnection()->executeQuery('SELECT parent_id FROM ecommerce_categories WHERE id=?', array($child->getId()))->fetchColumn(); - $this->assertEquals($value, $foreignKey); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php deleted file mode 100755 index 42fd292358..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php +++ /dev/null @@ -1,86 +0,0 @@ -useModelSet('routing'); - parent::setUp(); - - $locations = array("Berlin", "Bonn", "Brasilia", "Atlanta"); - - foreach ($locations AS $locationName) { - $location = new RoutingLocation(); - $location->name = $locationName; - $this->_em->persist($location); - $this->locations[$locationName] = $location; - } - $this->_em->flush(); - } - - public function testPersistOwning_InverseCascade() - { - $leg = new RoutingLeg(); - $leg->fromLocation = $this->locations['Berlin']; - $leg->toLocation = $this->locations['Bonn']; - $leg->departureDate = new \DateTime("now"); - $leg->arrivalDate = new \DateTime("now +5 hours"); - - $route = new RoutingRoute(); - $route->legs[] = $leg; - - $this->_em->persist($route); - $this->_em->flush(); - $this->_em->clear(); - - $routes = $this->_em->createQuery( - "SELECT r, l, f, t FROM Doctrine\Tests\Models\Routing\RoutingRoute r ". - "JOIN r.legs l JOIN l.fromLocation f JOIN l.toLocation t" - )->getSingleResult(); - - $this->assertEquals(1, count($routes->legs)); - $this->assertEquals("Berlin", $routes->legs[0]->fromLocation->name); - $this->assertEquals("Bonn", $routes->legs[0]->toLocation->name); - } - - public function testLegsAreUniqueToRoutes() - { - $leg = new RoutingLeg(); - $leg->fromLocation = $this->locations['Berlin']; - $leg->toLocation = $this->locations['Bonn']; - $leg->departureDate = new \DateTime("now"); - $leg->arrivalDate = new \DateTime("now +5 hours"); - - $routeA = new RoutingRoute(); - $routeA->legs[] = $leg; - - $routeB = new RoutingRoute(); - $routeB->legs[] = $leg; - - $this->_em->persist($routeA); - $this->_em->persist($routeB); - - $exceptionThrown = false; - try { - // exception depending on the underyling Database Driver - $this->_em->flush(); - } catch(\Exception $e) { - $exceptionThrown = true; - } - - $this->assertTrue($exceptionThrown, "The underlying database driver throws an exception."); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php deleted file mode 100755 index ced524c45c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php +++ /dev/null @@ -1,151 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - $this->customer = new ECommerceCustomer(); - $this->customer->setName('John Doe'); - $this->cart = new ECommerceCart(); - $this->cart->setPayment('Credit card'); - } - - public function testSavesAOneToOneAssociationWithCascadeSaveSet() { - $this->customer->setCart($this->cart); - $this->_em->persist($this->customer); - $this->_em->flush(); - - $this->assertCartForeignKeyIs($this->customer->getId()); - } - - public function testDoesNotSaveAnInverseSideSet() { - $this->customer->brokenSetCart($this->cart); - $this->_em->persist($this->customer); - $this->_em->flush(); - - $this->assertCartForeignKeyIs(null); - } - - public function testRemovesOneToOneAssociation() - { - $this->customer->setCart($this->cart); - $this->_em->persist($this->customer); - $this->customer->removeCart(); - - $this->_em->flush(); - - $this->assertCartForeignKeyIs(null); - } - - public function testEagerLoad() - { - $this->_createFixture(); - - $query = $this->_em->createQuery('select c, ca from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c join c.cart ca'); - $result = $query->getResult(); - $customer = $result[0]; - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart()); - $this->assertEquals('paypal', $customer->getCart()->getPayment()); - } - - public function testLazyLoadsObjectsOnTheOwningSide() { - $this->_createFixture(); - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); - $metadata->associationMappings['customer']['fetchMode'] = ClassMetadata::FETCH_LAZY; - - $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCart c'); - $result = $query->getResult(); - $cart = $result[0]; - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart->getCustomer()); - $this->assertEquals('Giorgio', $cart->getCustomer()->getName()); - } - - public function testInverseSideIsNeverLazy() - { - $this->_createFixture(); - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCustomer'); - $metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_EAGER; - - $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c'); - $result = $query->getResult(); - $customer = $result[0]; - - $this->assertNull($customer->getMentor()); - $this->assertInstanceOF('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart()); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $customer->getCart()); - $this->assertEquals('paypal', $customer->getCart()->getPayment()); - } - - public function testUpdateWithProxyObject() - { - $cust = new ECommerceCustomer; - $cust->setName('Roman'); - $cart = new ECommerceCart; - $cart->setPayment('CARD'); - $cust->setCart($cart); - - $this->_em->persist($cust); - $this->_em->flush(); - $this->_em->clear(); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $cust->getCart()); - $this->assertEquals('Roman', $cust->getName()); - $this->assertSame($cust, $cart->getCustomer()); - - $query = $this->_em->createQuery('select ca from Doctrine\Tests\Models\ECommerce\ECommerceCart ca where ca.id =?1'); - $query->setParameter(1, $cart->getId()); - - $cart2 = $query->getSingleResult(); - - $cart2->setPayment('CHEQUE'); - - $this->_em->flush(); - $this->_em->clear(); - - $query2 = $this->_em->createQuery('select ca, c from Doctrine\Tests\Models\ECommerce\ECommerceCart ca left join ca.customer c where ca.id =?1'); - $query2->setParameter(1, $cart->getId()); - - $cart3 = $query2->getSingleResult(); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart3->getCustomer()); - $this->assertEquals('Roman', $cart3->getCustomer()->getName()); - } - - protected function _createFixture() - { - $customer = new ECommerceCustomer; - $customer->setName('Giorgio'); - $cart = new ECommerceCart; - $cart->setPayment('paypal'); - $customer->setCart($cart); - - $this->_em->persist($customer); - - $this->_em->flush(); - $this->_em->clear(); - } - - public function assertCartForeignKeyIs($value) { - $foreignKey = $this->_em->getConnection()->executeQuery('SELECT customer_id FROM ecommerce_carts WHERE id=?', array($this->cart->getId()))->fetchColumn(); - $this->assertEquals($value, $foreignKey); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php deleted file mode 100755 index 7ad30ab7a1..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ /dev/null @@ -1,343 +0,0 @@ -_em); - try { - $schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Train'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOrder'), - )); - } catch(\Exception $e) {} - } - - public function testEagerLoadOneToOneOwningSide() - { - $train = new Train(new TrainOwner("Alexander")); - $driver = new TrainDriver("Benjamin"); - $waggon = new Waggon(); - - $train->setDriver($driver); - $train->addWaggon($waggon); - - $this->_em->persist($train); // cascades - $this->_em->flush(); - $this->_em->clear(); - - $sqlCount = count($this->_sqlLoggerStack->queries); - - $train = $this->_em->find(get_class($train), $train->id); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $train->driver); - $this->assertEquals("Benjamin", $train->driver->name); - - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); - } - - public function testEagerLoadOneToOneNullOwningSide() - { - $train = new Train(new TrainOwner("Alexander")); - - $this->_em->persist($train); // cascades - $this->_em->flush(); - $this->_em->clear(); - - $sqlCount = count($this->_sqlLoggerStack->queries); - - $train = $this->_em->find(get_class($train), $train->id); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $train->driver); - $this->assertNull($train->driver); - - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); - } - - public function testEagerLoadOneToOneInverseSide() - { - $owner = new TrainOwner("Alexander"); - $train = new Train($owner); - - $this->_em->persist($train); // cascades - $this->_em->flush(); - $this->_em->clear(); - - $sqlCount = count($this->_sqlLoggerStack->queries); - - $driver = $this->_em->find(get_class($owner), $owner->id); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $owner->train); - $this->assertNotNull($owner->train); - - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); - } - - public function testEagerLoadOneToOneNullInverseSide() - { - $driver = new TrainDriver("Dagny Taggert"); - - $this->_em->persist($driver); - $this->_em->flush(); - $this->_em->clear(); - - $this->assertNull($driver->train); - - $sqlCount = count($this->_sqlLoggerStack->queries); - - $driver = $this->_em->find(get_class($driver), $driver->id); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $driver->train); - $this->assertNull($driver->train); - - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); - } - - public function testEagerLoadManyToOne() - { - $train = new Train(new TrainOwner("Alexander")); - $waggon = new Waggon(); - $train->addWaggon($waggon); - - $this->_em->persist($train); // cascades - $this->_em->flush(); - $this->_em->clear(); - - $waggon = $this->_em->find(get_class($waggon), $waggon->id); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $waggon->train); - $this->assertNotNull($waggon->train); - } - - public function testEagerLoadWithNullableColumnsGeneratesLeftJoinOnBothSides() - { - $train = new Train(new TrainOwner("Alexander")); - $driver = new TrainDriver("Benjamin"); - $train->setDriver($driver); - - $this->_em->persist($train); - $this->_em->flush(); - $this->_em->clear(); - - $train = $this->_em->find(get_class($train), $train->id); - $this->assertEquals( - "SELECT t0.id AS id1, t0.driver_id AS driver_id2, t3.id AS id4, t3.name AS name5, t0.owner_id AS owner_id6, t7.id AS id8, t7.name AS name9 FROM Train t0 LEFT JOIN TrainDriver t3 ON t0.driver_id = t3.id INNER JOIN TrainOwner t7 ON t0.owner_id = t7.id WHERE t0.id = ?", - $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] - ); - - $this->_em->clear(); - $driver = $this->_em->find(get_class($driver), $driver->id); - $this->assertEquals( - "SELECT t0.id AS id1, t0.name AS name2, t3.id AS id4, t3.driver_id AS driver_id5, t3.owner_id AS owner_id6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id IN (?)", - $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] - ); - } - - public function testEagerLoadWithNonNullableColumnsGeneratesInnerJoinOnOwningSide() - { - $waggon = new Waggon(); - - // It should have a train - $train = new Train(new TrainOwner("Alexander")); - $train->addWaggon($waggon); - - $this->_em->persist($train); - $this->_em->flush(); - $this->_em->clear(); - - $waggon = $this->_em->find(get_class($waggon), $waggon->id); - - // The last query is the eager loading of the owner of the train - $this->assertEquals( - "SELECT t0.id AS id1, t0.name AS name2, t3.id AS id4, t3.driver_id AS driver_id5, t3.owner_id AS owner_id6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id IN (?)", - $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] - ); - - // The one before is the fetching of the waggon and train - $this->assertEquals( - "SELECT t0.id AS id1, t0.train_id AS train_id2, t3.id AS id4, t3.driver_id AS driver_id5, t3.owner_id AS owner_id6 FROM Waggon t0 INNER JOIN Train t3 ON t0.train_id = t3.id WHERE t0.id = ?", - $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery - 1]['sql'] - ); - } - - public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningSide() - { - $owner = new TrainOwner('Alexander'); - $train = new Train($owner); - $this->_em->persist($train); - $this->_em->flush(); - $this->_em->clear(); - - $waggon = $this->_em->find(get_class($owner), $owner->id); - $this->assertEquals( - "SELECT t0.id AS id1, t0.name AS name2, t3.id AS id4, t3.driver_id AS driver_id5, t3.owner_id AS owner_id6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id = ?", - $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] - ); - } - - /** - * @group DDC-1946 - */ - public function testEagerLoadingDoesNotBreakRefresh() - { - $train = new Train(new TrainOwner('Johannes')); - $order = new TrainOrder($train); - $this->_em->persist($train); - $this->_em->persist($order); - $this->_em->flush(); - - $this->_em->getConnection()->exec("UPDATE TrainOrder SET train_id = NULL"); - - $this->assertSame($train, $order->train); - $this->_em->refresh($order); - $this->assertTrue($order->train === null, "Train reference was not refreshed to NULL."); - } -} - -/** - * @Entity - */ -class Train -{ - /** - * @id @column(type="integer") @generatedValue - * @var int - */ - public $id; - /** - * Owning side - * @OneToOne(targetEntity="TrainDriver", inversedBy="train", fetch="EAGER", cascade={"persist"}) - * @JoinColumn(nullable=true) - */ - public $driver; - /** - * Owning side - * @OneToOne(targetEntity="TrainOwner", inversedBy="train", fetch="EAGER", cascade={"persist"}) - * @JoinColumn(nullable=false) - */ - public $owner; - /** - * @oneToMany(targetEntity="Waggon", mappedBy="train", cascade={"persist"}) - */ - public $waggons; - - public function __construct(TrainOwner $owner) - { - $this->waggons = new \Doctrine\Common\Collections\ArrayCollection(); - $this->setOwner($owner); - } - - public function setDriver(TrainDriver $driver) - { - $this->driver = $driver; - $driver->setTrain($this); - } - - public function setOwner(TrainOwner $owner) - { - $this->owner = $owner; - $owner->setTrain($this); - } - - public function addWaggon(Waggon $w) - { - $w->setTrain($this); - $this->waggons[] = $w; - } -} - -/** - * @Entity - */ -class TrainDriver -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @column(type="string") */ - public $name; - /** - * Inverse side - * @OneToOne(targetEntity="Train", mappedBy="driver", fetch="EAGER") - */ - public $train; - - public function __construct($name) - { - $this->name = $name; - } - - public function setTrain(Train $t) - { - $this->train = $t; - } -} - -/** - * @Entity - */ -class TrainOwner -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @column(type="string") */ - public $name; - /** - * Inverse side - * @OneToOne(targetEntity="Train", mappedBy="owner", fetch="EAGER") - */ - public $train; - - public function __construct($name) - { - $this->name = $name; - } - - public function setTrain(Train $t) - { - $this->train = $t; - } -} - -/** - * @Entity - */ -class Waggon -{ - /** @id @generatedValue @column(type="integer") */ - public $id; - /** - * @ManyToOne(targetEntity="Train", inversedBy="waggons", fetch="EAGER") - * @JoinColumn(nullable=false) - */ - public $train; - - public function setTrain($train) - { - $this->train = $train; - } -} - -/** - * @Entity - */ -class TrainOrder -{ - /** @id @generatedValue @column(type="integer") */ - public $id; - - /** @OneToOne(targetEntity = "Train", fetch = "EAGER") */ - public $train; - - public function __construct(Train $train) - { - $this->train = $train; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php deleted file mode 100755 index 6b3d0a2f0f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php +++ /dev/null @@ -1,94 +0,0 @@ -useModelSet('cms'); - - parent::setUp(); - } - - public function testOrphanRemoval() - { - $user = new CmsUser; - $user->status = 'dev'; - $user->username = 'romanb'; - $user->name = 'Roman B.'; - - $address = new CmsAddress; - $address->country = 'de'; - $address->zip = 1234; - $address->city = 'Berlin'; - - $user->setAddress($address); - - $this->_em->persist($user); - $this->_em->flush(); - - $userId = $user->getId(); - - $this->_em->clear(); - - $userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $userId); - - $this->_em->remove($userProxy); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); - $result = $query->getResult(); - - $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); - - $query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a'); - $result = $query->getResult(); - - $this->assertEquals(0, count($result), 'CmsAddress should be removed by orphanRemoval'); - } - - public function testOrphanRemovalWhenUnlink() - { - $user = new CmsUser; - $user->status = 'dev'; - $user->username = 'beberlei'; - $user->name = 'Bejamin Eberlei'; - - $email = new CmsEmail; - $email->email = 'beberlei@domain.com'; - - $user->setEmail($email); - - $this->_em->persist($user); - $this->_em->flush(); - - $userId = $user->getId(); - - $this->_em->clear(); - - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); - - $user->setEmail(null); - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery('SELECT e FROM Doctrine\Tests\Models\CMS\CmsEmail e'); - $result = $query->getResult(); - - $this->assertEquals(0, count($result), 'CmsEmail should be removed by orphanRemoval'); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php deleted file mode 100755 index 326e7aec12..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ /dev/null @@ -1,165 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - $this->customer = new ECommerceCustomer(); - $this->customer->setName('Anakin Skywalker'); - $this->mentor = new ECommerceCustomer(); - $this->mentor->setName('Obi-wan Kenobi'); - } - - public function testSavesAOneToOneAssociationWithCascadeSaveSet() { - $this->customer->setMentor($this->mentor); - $this->_em->persist($this->customer); - $this->_em->flush(); - - $this->assertForeignKeyIs($this->mentor->getId()); - } - - public function testRemovesOneToOneAssociation() - { - $this->customer->setMentor($this->mentor); - $this->_em->persist($this->customer); - $this->customer->removeMentor(); - - $this->_em->flush(); - - $this->assertForeignKeyIs(null); - } - - public function testFind() - { - $id = $this->_createFixture(); - - $customer = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $id); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $customer->getMentor()); - } - - public function testEagerLoadsAssociation() - { - $this->_createFixture(); - - $query = $this->_em->createQuery('select c, m from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c left join c.mentor m order by c.id asc'); - $result = $query->getResult(); - $customer = $result[0]; - $this->assertLoadingOfAssociation($customer); - } - - /** - * @group mine - * @return unknown_type - */ - public function testLazyLoadsAssociation() - { - $this->_createFixture(); - - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCustomer'); - $metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_LAZY; - - $query = $this->_em->createQuery("select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c where c.name='Luke Skywalker'"); - $result = $query->getResult(); - $customer = $result[0]; - $this->assertLoadingOfAssociation($customer); - } - - public function testMultiSelfReference() - { - try { - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\MultiSelfReference') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - - $entity1 = new MultiSelfReference(); - $this->_em->persist($entity1); - $entity1->setOther1($entity2 = new MultiSelfReference); - $entity1->setOther2($entity3 = new MultiSelfReference); - $this->_em->flush(); - - $this->_em->clear(); - - $entity2 = $this->_em->find(get_class($entity1), $entity1->getId()); - - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\MultiSelfReference', $entity2->getOther1()); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\MultiSelfReference', $entity2->getOther2()); - $this->assertNull($entity2->getOther1()->getOther1()); - $this->assertNull($entity2->getOther1()->getOther2()); - $this->assertNull($entity2->getOther2()->getOther1()); - $this->assertNull($entity2->getOther2()->getOther2()); - } - - public function assertLoadingOfAssociation($customer) - { - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $customer->getMentor()); - $this->assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName()); - } - - public function assertForeignKeyIs($value) { - $foreignKey = $this->_em->getConnection()->executeQuery('SELECT mentor_id FROM ecommerce_customers WHERE id=?', array($this->customer->getId()))->fetchColumn(); - $this->assertEquals($value, $foreignKey); - } - - private function _createFixture() - { - $customer = new ECommerceCustomer; - $customer->setName('Luke Skywalker'); - $mentor = new ECommerceCustomer; - $mentor->setName('Obi-wan Kenobi'); - $customer->setMentor($mentor); - - $this->_em->persist($customer); - - $this->_em->flush(); - $this->_em->clear(); - - return $customer->getId(); - } -} - -/** - * @Entity - */ -class MultiSelfReference { - /** @Id @GeneratedValue(strategy="AUTO") @Column(type="integer") */ - private $id; - /** - * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) - * @JoinColumn(name="other1", referencedColumnName="id") - */ - private $other1; - /** - * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) - * @JoinColumn(name="other2", referencedColumnName="id") - */ - private $other2; - - public function getId() {return $this->id;} - public function setOther1($other1) {$this->other1 = $other1;} - public function getOther1() {return $this->other1;} - public function setOther2($other2) {$this->other2 = $other2;} - public function getOther2() {return $this->other2;} -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php deleted file mode 100755 index 1ffae6b13c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ /dev/null @@ -1,125 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - $this->product = new ECommerceProduct(); - $this->product->setName('Doctrine 2 Manual'); - $this->shipping = new ECommerceShipping(); - $this->shipping->setDays('5'); - } - - public function testSavesAOneToOneAssociationWithCascadeSaveSet() { - $this->product->setShipping($this->shipping); - $this->_em->persist($this->product); - $this->_em->flush(); - - $this->assertForeignKeyIs($this->shipping->getId()); - } - - public function testRemovesOneToOneAssociation() - { - $this->product->setShipping($this->shipping); - $this->_em->persist($this->product); - $this->product->removeShipping(); - - $this->_em->flush(); - - $this->assertForeignKeyIs(null); - } - - public function _testEagerLoad() - { - $this->_createFixture(); - - $query = $this->_em->createQuery('select p, s from Doctrine\Tests\Models\ECommerce\ECommerceProduct p left join p.shipping s'); - $result = $query->getResult(); - $product = $result[0]; - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceShipping', $product->getShipping()); - $this->assertEquals(1, $product->getShipping()->getDays()); - } - - public function testLazyLoadsObjects() { - $this->_createFixture(); - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); - $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; - - $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); - $result = $query->getResult(); - $product = $result[0]; - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceShipping', $product->getShipping()); - $this->assertEquals(1, $product->getShipping()->getDays()); - } - - public function testDoesNotLazyLoadObjectsIfConfigurationDoesNotAllowIt() { - $this->_createFixture(); - - $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); - $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - - $result = $query->getResult(); - $product = $result[0]; - - $this->assertNull($product->getShipping()); - } - - protected function _createFixture() - { - $product = new ECommerceProduct; - $product->setName('Php manual'); - $shipping = new ECommerceShipping; - $shipping->setDays('1'); - $product->setShipping($shipping); - - $this->_em->persist($product); - - $this->_em->flush(); - $this->_em->clear(); - } - - public function assertForeignKeyIs($value) { - $foreignKey = $this->_em->getConnection()->executeQuery( - 'SELECT shipping_id FROM ecommerce_products WHERE id=?', - array($this->product->getId()) - )->fetchColumn(); - $this->assertEquals($value, $foreignKey); - } - - /** - * @group DDC-762 - */ - public function testNullForeignKey() - { - $product = new ECommerceProduct(); - $product->setName('Doctrine 2 Manual'); - - $this->_em->persist($product); - $this->_em->flush(); - - $product = $this->_em->find(get_class($product), $product->getId()); - - $this->assertNull($product->getShipping()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php deleted file mode 100755 index c2e131cb31..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php +++ /dev/null @@ -1,113 +0,0 @@ -useModelSet('routing'); - parent::setUp(); - - $locations = array("Berlin", "Bonn", "Brasilia", "Atlanta"); - - foreach ($locations AS $locationName) { - $location = new RoutingLocation(); - $location->name = $locationName; - $this->_em->persist($location); - $this->locations[$locationName] = $location; - } - $this->_em->flush(); - } - - public function createPersistedRouteWithLegs() - { - $route = new RoutingRoute(); - - $leg1 = new RoutingLeg(); - $leg1->fromLocation = $this->locations['Berlin']; - $leg1->toLocation = $this->locations['Bonn']; - $leg1->departureDate = new \DateTime("now"); - $leg1->arrivalDate = new \DateTime("now +5 hours"); - - $leg2 = new RoutingLeg(); - $leg2->fromLocation = $this->locations['Bonn']; - $leg2->toLocation = $this->locations['Brasilia']; - $leg2->departureDate = new \DateTime("now +6 hours"); - $leg2->arrivalDate = new \DateTime("now +24 hours"); - - $route->legs[] = $leg2; - $route->legs[] = $leg1; - - $this->_em->persist($route); - $this->_em->flush(); - $routeId = $route->id; - $this->_em->clear(); - - return $routeId; - } - - public function testLazyManyToManyCollection_IsRetrievedWithOrderByClause() - { - $routeId = $this->createPersistedRouteWithLegs(); - - $route = $this->_em->find('Doctrine\Tests\Models\Routing\RoutingRoute', $routeId); - - $this->assertEquals(2, count($route->legs)); - $this->assertEquals("Berlin", $route->legs[0]->fromLocation->getName()); - $this->assertEquals("Bonn", $route->legs[1]->fromLocation->getName()); - } - - public function testLazyOneToManyCollection_IsRetrievedWithOrderByClause() - { - $route = new RoutingRoute(); - - $this->_em->persist($route); - $this->_em->flush(); - $routeId = $route->id; - - $booking1 = new RoutingRouteBooking(); - $booking1->passengerName = "Guilherme"; - $booking2 = new RoutingRouteBooking(); - $booking2->passengerName = "Benjamin"; - - $route->bookings[] = $booking1; - $booking1->route = $route; - $route->bookings[] = $booking2; - $booking2->route = $route; - - $this->_em->persist($booking1); - $this->_em->persist($booking2); - - $this->_em->flush(); - $this->_em->clear(); - - $route = $this->_em->find('Doctrine\Tests\Models\Routing\RoutingRoute', $routeId); - - $this->assertEquals(2, count($route->bookings)); - $this->assertEquals('Benjamin', $route->bookings[0]->getPassengerName()); - $this->assertEquals('Guilherme', $route->bookings[1]->getPassengerName()); - } - - public function testOrderedResultFromDqlQuery() - { - $routeId = $this->createPersistedRouteWithLegs(); - - $route = $this->_em->createQuery("SELECT r, l FROM Doctrine\Tests\Models\Routing\RoutingRoute r JOIN r.legs l WHERE r.id = ?1") - ->setParameter(1, $routeId) - ->getSingleResult(); - - $this->assertEquals(2, count($route->legs)); - $this->assertEquals("Berlin", $route->legs[0]->fromLocation->getName()); - $this->assertEquals("Bonn", $route->legs[1]->fromLocation->getName()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php deleted file mode 100755 index 8c0d37b98f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php +++ /dev/null @@ -1,133 +0,0 @@ - - */ -class OrderedJoinedTableInheritanceCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - protected function setUp() { - parent::setUp(); - try { - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Pet'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Cat'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Dog'), - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - - $dog = new OJTIC_Dog(); - $dog->name = "Poofy"; - - $dog1 = new OJTIC_Dog(); - $dog1->name = "Zampa"; - $dog2 = new OJTIC_Dog(); - $dog2->name = "Aari"; - - $dog1->mother = $dog; - $dog2->mother = $dog; - - $dog->children[] = $dog1; - $dog->children[] = $dog2; - - $this->_em->persist($dog); - $this->_em->persist($dog1); - $this->_em->persist($dog2); - $this->_em->flush(); - $this->_em->clear(); - } - - public function testOrderdOneToManyCollection() - { - $poofy = $this->_em->createQuery("SELECT p FROM Doctrine\Tests\ORM\Functional\OJTIC_Pet p WHERE p.name = 'Poofy'")->getSingleResult(); - - $this->assertEquals('Aari', $poofy->children[0]->getName()); - $this->assertEquals('Zampa', $poofy->children[1]->getName()); - - $this->_em->clear(); - - $result = $this->_em->createQuery( - "SELECT p, c FROM Doctrine\Tests\ORM\Functional\OJTIC_Pet p JOIN p.children c WHERE p.name = 'Poofy'") - ->getResult(); - - $this->assertEquals(1, count($result)); - $poofy = $result[0]; - - $this->assertEquals('Aari', $poofy->children[0]->getName()); - $this->assertEquals('Zampa', $poofy->children[1]->getName()); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({ - * "cat" = "OJTIC_Cat", - * "dog" = "OJTIC_Dog"}) - */ -abstract class OJTIC_Pet -{ - /** - * @Id - * @column(type="integer") - * @generatedValue(strategy="AUTO") - */ - public $id; - - /** - * - * @Column - */ - public $name; - - /** - * @ManyToOne(targetEntity="OJTIC_PET") - */ - public $mother; - - /** - * @OneToMany(targetEntity="OJTIC_Pet", mappedBy="mother") - * @OrderBy({"name" = "ASC"}) - */ - public $children; - - /** - * @ManyToMany(targetEntity="OJTIC_Pet") - * @JoinTable(name="OTJIC_Pet_Friends", - * joinColumns={@JoinColumn(name="pet_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="friend_id", referencedColumnName="id")}) - * @OrderBy({"name" = "ASC"}) - */ - public $friends; - - public function getName() - { - return $this->name; - } -} - -/** - * @Entity - */ -class OJTIC_Cat extends OJTIC_Pet -{ - -} - -/** - * @Entity - */ -class OJTIC_Dog extends OJTIC_Pet -{ - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php deleted file mode 100755 index 0a28455826..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ /dev/null @@ -1,168 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - $this->populate(); - } - - /** - * @dataProvider useOutputWalkers - */ - public function testCountSimpleWithoutJoin($useOutputWalkers) - { - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; - $query = $this->_em->createQuery($dql); - - $paginator = new Paginator($query); - $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator); - } - - /** - * @dataProvider useOutputWalkers - */ - public function testCountWithFetchJoin($useOutputWalkers) - { - $dql = "SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g"; - $query = $this->_em->createQuery($dql); - - $paginator = new Paginator($query); - $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator); - } - - public function testCountComplexWithOutputWalker() - { - $dql = "SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g HAVING COUNT(u.id) > 0"; - $query = $this->_em->createQuery($dql); - - $paginator = new Paginator($query); - $paginator->setUseOutputWalkers(true); - $this->assertCount(9, $paginator); - } - - /** - * @dataProvider useOutputWalkers - */ - public function testIterateSimpleWithoutJoinFetchJoinHandlingOff($useOutputWalkers) - { - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; - $query = $this->_em->createQuery($dql); - - $paginator = new Paginator($query, false); - $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator->getIterator()); - } - - /** - * @dataProvider useOutputWalkers - */ - public function testIterateSimpleWithoutJoinFetchJoinHandlingOn($useOutputWalkers) - { - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; - $query = $this->_em->createQuery($dql); - - $paginator = new Paginator($query, true); - $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator->getIterator()); - } - - /** - * @dataProvider useOutputWalkers - */ - public function testIterateWithFetchJoin($useOutputWalkers) - { - $dql = "SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g"; - $query = $this->_em->createQuery($dql); - - $paginator = new Paginator($query, true); - $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator->getIterator()); - } - - public function testIterateComplexWithOutputWalker() - { - $dql = "SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g HAVING COUNT(u.id) > 0"; - $query = $this->_em->createQuery($dql); - - $paginator = new Paginator($query); - $paginator->setUseOutputWalkers(true); - $this->assertCount(9, $paginator->getIterator()); - } - - public function testDetectOutputWalker() - { - // This query works using the output walkers but causes an exception using the TreeWalker - $dql = "SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g HAVING COUNT(u.id) > 0"; - $query = $this->_em->createQuery($dql); - - // If the Paginator detects the custom output walker it should fall back to using the - // Tree walkers for pagination, which leads to an exception. If the query works, the output walkers were used - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Query\SqlWalker'); - $paginator = new Paginator($query); - - $this->setExpectedException( - 'RuntimeException', - 'Cannot count query that uses a HAVING clause. Use the output walkers for pagination' - ); - - count($paginator); - } - - public function testCloneQuery() - { - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; - $query = $this->_em->createQuery($dql); - - $paginator = new Paginator($query); - $paginator->getIterator(); - - $this->assertTrue($query->getParameters()->isEmpty()); - } - - public function populate() - { - for ($i = 0; $i < 3; $i++) { - $user = new CmsUser(); - $user->name = "Name$i"; - $user->username = "username$i"; - $user->status = "active"; - $this->_em->persist($user); - - for ($j = 0; $j < 3; $j++) {; - $group = new CmsGroup(); - $group->name = "group$j"; - $user->addGroup($group); - $this->_em->persist($group); - } - } - $this->_em->flush(); - } - - public function useOutputWalkers() - { - return array( - array(true), - array(false), - ); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php deleted file mode 100755 index 2125966fce..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php +++ /dev/null @@ -1,98 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionHolder'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionContent'), - )); - } catch (\Exception $e) { - - } - PersistentObject::setObjectManager($this->_em); - } - - public function testPersist() - { - $collectionHolder = new PersistentCollectionHolder(); - $content = new PersistentCollectionContent('first element'); - $collectionHolder->addElement($content); - - $this->_em->persist($collectionHolder); - $this->_em->flush(); - $this->_em->clear(); - - $collectionHolder = $this->_em->find(__NAMESPACE__ . '\PersistentCollectionHolder', $collectionHolder->getId()); - $collectionHolder->getCollection(); - - $content = new PersistentCollectionContent('second element'); - $collectionHolder->addElement($content); - - $this->assertEquals(2, $collectionHolder->getCollection()->count()); - } - -} - -/** - * @Entity - */ -class PersistentCollectionHolder extends PersistentObject -{ - /** - * @Id @Column(type="integer") @GeneratedValue - * @var int - */ - protected $id; - - /** - * @var \Doctrine\Common\Collections\Collection - * @ManyToMany(targetEntity="PersistentCollectionContent", cascade={"all"}) - */ - protected $collection; - - public function __construct() - { - $this->collection = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * @param PersistentCollectionContent $element - */ - public function addElement(PersistentCollectionContent $element) - { - $this->collection->add($element); - } - - /** - * @return \Doctrine\Common\Collections\Collection - */ - public function getCollection() - { - return clone $this->collection; - } - -} - -/** - * @Entity - */ -class PersistentCollectionContent extends PersistentObject -{ - - /** - * @Id @Column(type="integer") @GeneratedValue - * @var int - */ - protected $id; - -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php deleted file mode 100755 index 88e54ae2e5..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php +++ /dev/null @@ -1,105 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PersistentEntity'), - )); - } catch (\Exception $e) { - - } - PersistentObject::setObjectManager($this->_em); - } - - public function testPersist() - { - $entity = new PersistentEntity(); - $entity->setName("test"); - - $this->_em->persist($entity); - $this->_em->flush(); - } - - public function testFind() - { - $entity = new PersistentEntity(); - $entity->setName("test"); - - $this->_em->persist($entity); - $this->_em->flush(); - $this->_em->clear(); - - $entity = $this->_em->find(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); - - $this->assertEquals('test', $entity->getName()); - $entity->setName('foobar'); - - $this->_em->flush(); - } - - public function testGetReference() - { - $entity = new PersistentEntity(); - $entity->setName("test"); - - $this->_em->persist($entity); - $this->_em->flush(); - $this->_em->clear(); - - $entity = $this->_em->getReference(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); - - $this->assertEquals('test', $entity->getName()); - } - - public function testSetAssociation() - { - $entity = new PersistentEntity(); - $entity->setName("test"); - $entity->setParent($entity); - - $this->_em->persist($entity); - $this->_em->flush(); - $this->_em->clear(); - - $entity = $this->_em->getReference(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); - $this->assertSame($entity, $entity->getParent()); - } -} - -/** - * @Entity - */ -class PersistentEntity extends PersistentObject -{ - /** - * @Id @Column(type="integer") @GeneratedValue - * @var int - */ - protected $id; - - /** - * @Column(type="string") - * @var string - */ - protected $name; - - /** - * @ManyToOne(targetEntity="PersistentEntity") - * @var PersistentEntity - */ - protected $parent; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php deleted file mode 100755 index 8198871965..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ -class PostFlushEventTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - /** - * @var PostFlushListener - */ - private $listener; - - protected function setUp() - { - $this->useModelSet('cms'); - parent::setUp(); - $this->listener = new PostFlushListener(); - $evm = $this->_em->getEventManager(); - $evm->addEventListener(Events::postFlush, $this->listener); - } - - public function testListenerShouldBeNotified() - { - $this->_em->persist($this->createNewValidUser()); - $this->_em->flush(); - $this->assertTrue($this->listener->wasNotified); - } - - public function testListenerShouldNotBeNotifiedWhenFlushThrowsException() - { - $user = new CmsUser(); - $user->username = 'dfreudenberger'; - $this->_em->persist($user); - $exceptionRaised = false; - - try { - $this->_em->flush(); - } catch (\Exception $ex) { - $exceptionRaised = true; - } - - $this->assertTrue($exceptionRaised); - $this->assertFalse($this->listener->wasNotified); - } - - public function testListenerShouldReceiveEntityManagerThroughArgs() - { - $this->_em->persist($this->createNewValidUser()); - $this->_em->flush(); - $receivedEm = $this->listener->receivedArgs->getEntityManager(); - $this->assertSame($this->_em, $receivedEm); - } - - /** - * @return CmsUser - */ - private function createNewValidUser() - { - $user = new CmsUser(); - $user->username = 'dfreudenberger'; - $user->name = 'Daniel Freudenberger'; - return $user; - } -} - -class PostFlushListener -{ - /** - * @var bool - */ - public $wasNotified = false; - - /** - * @var PostFlushEventArgs - */ - public $receivedArgs; - - /** - * @param PostFlushEventArgs $args - */ - public function postFlush(PostFlushEventArgs $args) - { - $this->wasNotified = true; - $this->receivedArgs = $args; - } -} - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostgreSQLIdentityStrategyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostgreSQLIdentityStrategyTest.php deleted file mode 100755 index 4ee7b7c9b6..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostgreSQLIdentityStrategyTest.php +++ /dev/null @@ -1,53 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->getName() != 'postgresql') { - $this->markTestSkipped('This test is special to the PostgreSQL IDENTITY key generation strategy.'); - } else { - try { - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PostgreSQLIdentityEntity'), - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - } - - protected function tearDown() { - parent::tearDown(); - // drop sequence manually due to dependency - $this->_em->getConnection()->exec('DROP SEQUENCE postgresqlidentityentity_id_seq CASCADE'); - } - - public function testPreSavePostSaveCallbacksAreInvoked() - { - $entity = new PostgreSQLIdentityEntity(); - $entity->setValue('hello'); - $this->_em->persist($entity); - $this->_em->flush(); - $this->assertTrue(is_numeric($entity->getId())); - $this->assertTrue($entity->getId() > 0); - $this->assertTrue($this->_em->contains($entity)); - } -} - -/** @Entity */ -class PostgreSQLIdentityEntity { - /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */ - private $id; - /** @Column(type="string") */ - private $value; - public function getId() {return $this->id;} - public function getValue() {return $this->value;} - public function setValue($value) {$this->value = $value;} -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php deleted file mode 100755 index 52ac8f5919..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php +++ /dev/null @@ -1,133 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), - )); - } catch (\Exception $e) { - } - $this->user = new CmsUser(); - $this->user->username = 'ocramius'; - $this->user->name = 'Marco'; - $this->_em->persist($this->user); - $this->_em->flush(); - $this->_em->clear(); - } - - /** - * Verifies that a proxy can be successfully persisted and updated - */ - public function testPersistUpdate() - { - // Considering case (a) - $persister = $this->_em->getUnitOfWork()->getEntityPersister('Doctrine\Tests\Models\CMS\CmsUser'); - $proxy = new Proxy($persister, array()); - $proxy->__isInitialized__ = true; - $proxy->username = 'ocra'; - $proxy->name = 'Marco'; - $this->_em->persist($proxy); - $this->_em->flush(); - $this->assertNotNull($proxy->getId()); - $proxy->name = 'Marco Pivetta'; - $this - ->_em - ->getUnitOfWork() - ->computeChangeSet($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $proxy); - $this->assertNotEmpty($this->_em->getUnitOfWork()->getEntityChangeSet($proxy)); - $this->assertEquals('Marco Pivetta', $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $proxy->getId())->name); - $this->_em->remove($proxy); - $this->_em->flush(); - } - - public function testEntityWithIdentifier() - { - // Considering case (b) - $persister = $this->_em->getUnitOfWork()->getEntityPersister('Doctrine\Tests\Models\CMS\CmsUser'); - $uninitializedProxy = new Proxy($persister, array('id' => $this->user->getId())); - $uninitializedProxy->id = $this->user->getId(); - $uninitializedProxy->username = 'ocra'; - $uninitializedProxy->name = 'Marco Pivetta'; - $this->_em->persist($uninitializedProxy); - $this->_em->flush(); - $this->assertEquals($this->user->getId(), $uninitializedProxy->getId()); - $this->_em->remove($uninitializedProxy); - $this->_em->flush(); - } - - /** - * Verifying that proxies can be used without problems as query parameters - */ - public function testProxyAsDqlParameterPersist() - { - $persister = $this->_em->getUnitOfWork()->getEntityPersister('Doctrine\Tests\Models\CMS\CmsUser'); - $proxy = new Proxy($persister, array('id' => $this->user->getId())); - $proxy->id = $this->user->getId(); - $result = $this - ->_em - ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u = ?1') - ->setParameter(1, $proxy) - ->getSingleResult(); - $this->assertSame($this->user->getId(), $result->getId()); - $this->_em->remove($proxy); - $this->_em->flush(); - } - - /** - * Verifying that proxies can be used without problems as query parameters - */ - public function testFindWithProxyName() - { - $result = $this - ->_em - ->find('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser', $this->user->getId()); - $this->assertSame($this->user->getId(), $result->getId()); - $this->_em->clear(); - $result = $this - ->_em - ->getReference('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser', $this->user->getId()); - $this->assertSame($this->user->getId(), $result->getId()); - $this->_em->clear(); - $result = $this - ->_em - ->getRepository('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser') - ->findOneBy(array('username' => $this->user->username)); - $this->assertSame($this->user->getId(), $result->getId()); - $this->_em->clear(); - $result = $this - ->_em - ->createQuery('SELECT u FROM Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1') - ->setParameter(1, $this->user->getId()) - ->getSingleResult(); - $this->assertSame($this->user->getId(), $result->getId()); - $this->_em->clear(); - } - - protected function tearDown() - { - $this->_em->createQuery('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u')->execute(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php deleted file mode 100755 index faffdd7bc1..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php +++ /dev/null @@ -1,153 +0,0 @@ -cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); - $this->cacheDataReflection->setAccessible(true); - - $this->useModelSet('cms'); - - parent::setUp(); - } - - /** - * @param ArrayCache $cache - * @return integer - */ - private function getCacheSize(ArrayCache $cache) - { - return sizeof($this->cacheDataReflection->getValue($cache)); - } - - - public function testQueryCache_DependsOnHints() - { - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - - $cache = new ArrayCache(); - $query->setQueryCacheDriver($cache); - - $query->getResult(); - $this->assertEquals(2, $this->getCacheSize($cache)); - - $query->setHint('foo', 'bar'); - - $query->getResult(); - $this->assertEquals(3, $this->getCacheSize($cache)); - - return $query; - } - - /** - * @param $query - * @depends testQueryCache_DependsOnHints - */ - public function testQueryCache_DependsOnFirstResult($query) - { - $cache = $query->getQueryCacheDriver(); - $cacheCount = $this->getCacheSize($cache); - - $query->setFirstResult(10); - $query->setMaxResults(9999); - - $query->getResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); - } - - /** - * @param $query - * @depends testQueryCache_DependsOnHints - */ - public function testQueryCache_DependsOnMaxResults($query) - { - $cache = $query->getQueryCacheDriver(); - $cacheCount = $this->getCacheSize($cache); - - $query->setMaxResults(10); - - $query->getResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); - } - - /** - * @param $query - * @depends testQueryCache_DependsOnHints - */ - public function testQueryCache_DependsOnHydrationMode($query) - { - $cache = $query->getQueryCacheDriver(); - $cacheCount = $this->getCacheSize($cache); - - $query->getArrayResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); - } - - public function testQueryCache_NoHitSaveParserResult() - { - $this->_em->getConfiguration()->setQueryCacheImpl(new ArrayCache()); - - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - - $cache = new \Doctrine\Common\Cache\ArrayCache(); - - $query->setQueryCacheDriver($cache); - - $users = $query->getResult(); - - $data = $this->cacheDataReflection->getValue($cache); - $this->assertEquals(2, count($data)); - - $this->assertInstanceOf('Doctrine\ORM\Query\ParserResult', array_pop($data)); - } - - public function testQueryCache_HitDoesNotSaveParserResult() - { - $this->_em->getConfiguration()->setQueryCacheImpl(new ArrayCache()); - - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - - $sqlExecMock = $this->getMock('Doctrine\ORM\Query\Exec\AbstractSqlExecutor', array('execute')); - $sqlExecMock->expects($this->once()) - ->method('execute') - ->will($this->returnValue( 10 )); - - $parserResultMock = $this->getMock('Doctrine\ORM\Query\ParserResult'); - $parserResultMock->expects($this->once()) - ->method('getSqlExecutor') - ->will($this->returnValue($sqlExecMock)); - - $cache = $this->getMock('Doctrine\Common\Cache\CacheProvider', - array('doFetch', 'doContains', 'doSave', 'doDelete', 'doFlush', 'doGetStats')); - $cache->expects($this->at(0))->method('doFetch')->will($this->returnValue(1)); - $cache->expects($this->at(1)) - ->method('doFetch') - ->with($this->isType('string')) - ->will($this->returnValue($parserResultMock)); - $cache->expects($this->never()) - ->method('doSave'); - - $query->setQueryCacheDriver($cache); - - $users = $query->getResult(); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php deleted file mode 100755 index 7f3180a6c2..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ /dev/null @@ -1,402 +0,0 @@ -useModelSet('company'); - parent::setUp(); - - $this->generateFixture(); - } - - public function testAggregateSum() - { - $salarySum = $this->_em->createQuery('SELECT SUM(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getSingleResult(); - - $this->assertEquals(1500000, $salarySum['salary']); - } - - public function testAggregateAvg() - { - $salaryAvg = $this->_em->createQuery('SELECT AVG(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getSingleResult(); - - $this->assertEquals(375000, round($salaryAvg['salary'], 0)); - } - - public function testAggregateMin() - { - $salary = $this->_em->createQuery('SELECT MIN(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getSingleResult(); - - $this->assertEquals(100000, $salary['salary']); - } - - public function testAggregateMax() - { - $salary = $this->_em->createQuery('SELECT MAX(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getSingleResult(); - - $this->assertEquals(800000, $salary['salary']); - } - - public function testAggregateCount() - { - $managerCount = $this->_em->createQuery('SELECT COUNT(m.id) AS managers FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getSingleResult(); - - $this->assertEquals(4, $managerCount['managers']); - } - - public function testFunctionAbs() - { - $result = $this->_em->createQuery('SELECT m, ABS(m.salary * -1) AS abs FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(100000, $result[0]['abs']); - $this->assertEquals(200000, $result[1]['abs']); - $this->assertEquals(400000, $result[2]['abs']); - $this->assertEquals(800000, $result[3]['abs']); - } - - public function testFunctionConcat() - { - $arg = $this->_em->createQuery('SELECT m, CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getArrayResult(); - - $this->assertEquals(4, count($arg)); - $this->assertEquals('Roman B.IT', $arg[0]['namedep']); - $this->assertEquals('Benjamin E.HR', $arg[1]['namedep']); - $this->assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); - $this->assertEquals('Jonathan W.Administration', $arg[3]['namedep']); - } - - public function testFunctionLength() - { - $result = $this->_em->createQuery('SELECT m, LENGTH(CONCAT(m.name, m.department)) AS namedeplength FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getArrayResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(10, $result[0]['namedeplength']); - $this->assertEquals(13, $result[1]['namedeplength']); - $this->assertEquals(32, $result[2]['namedeplength']); - $this->assertEquals(25, $result[3]['namedeplength']); - } - - public function testFunctionLocate() - { - $dql = "SELECT m, LOCATE('e', LOWER(m.name)) AS loc, LOCATE('e', LOWER(m.name), 7) AS loc2 ". - "FROM Doctrine\Tests\Models\Company\CompanyManager m"; - - $result = $this->_em->createQuery($dql) - ->getArrayResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(0, $result[0]['loc']); - $this->assertEquals(2, $result[1]['loc']); - $this->assertEquals(6, $result[2]['loc']); - $this->assertEquals(0, $result[3]['loc']); - $this->assertEquals(0, $result[0]['loc2']); - $this->assertEquals(10, $result[1]['loc2']); - $this->assertEquals(9, $result[2]['loc2']); - $this->assertEquals(0, $result[3]['loc2']); - } - - public function testFunctionLower() - { - $result = $this->_em->createQuery("SELECT m, LOWER(m.name) AS lowername FROM Doctrine\Tests\Models\Company\CompanyManager m") - ->getArrayResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals('roman b.', $result[0]['lowername']); - $this->assertEquals('benjamin e.', $result[1]['lowername']); - $this->assertEquals('guilherme b.', $result[2]['lowername']); - $this->assertEquals('jonathan w.', $result[3]['lowername']); - } - - public function testFunctionMod() - { - $result = $this->_em->createQuery("SELECT m, MOD(m.salary, 3500) AS amod FROM Doctrine\Tests\Models\Company\CompanyManager m") - ->getArrayResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(2000, $result[0]['amod']); - $this->assertEquals(500, $result[1]['amod']); - $this->assertEquals(1000, $result[2]['amod']); - $this->assertEquals(2000, $result[3]['amod']); - } - - public function testFunctionSqrt() - { - $result = $this->_em->createQuery("SELECT m, SQRT(m.salary) AS sqrtsalary FROM Doctrine\Tests\Models\Company\CompanyManager m") - ->getArrayResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(316, round($result[0]['sqrtsalary'])); - $this->assertEquals(447, round($result[1]['sqrtsalary'])); - $this->assertEquals(632, round($result[2]['sqrtsalary'])); - $this->assertEquals(894, round($result[3]['sqrtsalary'])); - } - - public function testFunctionUpper() - { - $result = $this->_em->createQuery("SELECT m, UPPER(m.name) AS uppername FROM Doctrine\Tests\Models\Company\CompanyManager m") - ->getArrayResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals('ROMAN B.', $result[0]['uppername']); - $this->assertEquals('BENJAMIN E.', $result[1]['uppername']); - $this->assertEquals('GUILHERME B.', $result[2]['uppername']); - $this->assertEquals('JONATHAN W.', $result[3]['uppername']); - } - - public function testFunctionSubstring() - { - $dql = "SELECT m, SUBSTRING(m.name, 1, 3) AS str1, SUBSTRING(m.name, 5) AS str2 ". - "FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.name"; - - $result = $this->_em->createQuery($dql) - ->getArrayResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals('Ben', $result[0]['str1']); - $this->assertEquals('Gui', $result[1]['str1']); - $this->assertEquals('Jon', $result[2]['str1']); - $this->assertEquals('Rom', $result[3]['str1']); - - $this->assertEquals('amin E.', $result[0]['str2']); - $this->assertEquals('herme B.', $result[1]['str2']); - $this->assertEquals('than W.', $result[2]['str2']); - $this->assertEquals('n B.', $result[3]['str2']); - } - - public function testFunctionTrim() - { - $dql = "SELECT m, TRIM(TRAILING '.' FROM m.name) AS str1, ". - " TRIM(LEADING '.' FROM m.name) AS str2, TRIM(CONCAT(' ', CONCAT(m.name, ' '))) AS str3 ". - "FROM Doctrine\Tests\Models\Company\CompanyManager m"; - - $result = $this->_em->createQuery($dql)->getArrayResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals('Roman B', $result[0]['str1']); - $this->assertEquals('Benjamin E', $result[1]['str1']); - $this->assertEquals('Guilherme B', $result[2]['str1']); - $this->assertEquals('Jonathan W', $result[3]['str1']); - $this->assertEquals('Roman B.', $result[0]['str2']); - $this->assertEquals('Benjamin E.', $result[1]['str2']); - $this->assertEquals('Guilherme B.', $result[2]['str2']); - $this->assertEquals('Jonathan W.', $result[3]['str2']); - $this->assertEquals('Roman B.', $result[0]['str3']); - $this->assertEquals('Benjamin E.', $result[1]['str3']); - $this->assertEquals('Guilherme B.', $result[2]['str3']); - $this->assertEquals('Jonathan W.', $result[3]['str3']); - } - - public function testOperatorAdd() - { - $result = $this->_em->createQuery('SELECT m, m.salary+2500 AS add FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(102500, $result[0]['add']); - $this->assertEquals(202500, $result[1]['add']); - $this->assertEquals(402500, $result[2]['add']); - $this->assertEquals(802500, $result[3]['add']); - } - - public function testOperatorSub() - { - $result = $this->_em->createQuery('SELECT m, m.salary-2500 AS sub FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(97500, $result[0]['sub']); - $this->assertEquals(197500, $result[1]['sub']); - $this->assertEquals(397500, $result[2]['sub']); - $this->assertEquals(797500, $result[3]['sub']); - } - - public function testOperatorMultiply() - { - $result = $this->_em->createQuery('SELECT m, m.salary*2 AS op FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(200000, $result[0]['op']); - $this->assertEquals(400000, $result[1]['op']); - $this->assertEquals(800000, $result[2]['op']); - $this->assertEquals(1600000, $result[3]['op']); - } - - /** - * @group test - */ - public function testOperatorDiv() - { - $result = $this->_em->createQuery('SELECT m, (m.salary/0.5) AS op FROM Doctrine\Tests\Models\Company\CompanyManager m') - ->getResult(); - - $this->assertEquals(4, count($result)); - $this->assertEquals(200000, $result[0]['op']); - $this->assertEquals(400000, $result[1]['op']); - $this->assertEquals(800000, $result[2]['op']); - $this->assertEquals(1600000, $result[3]['op']); - } - - public function testConcatFunction() - { - $arg = $this->_em->createQuery('SELECT CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m order by namedep desc') - ->getArrayResult(); - - $this->assertEquals(4, count($arg)); - $this->assertEquals('Roman B.IT', $arg[0]['namedep']); - $this->assertEquals('Jonathan W.Administration', $arg[1]['namedep']); - $this->assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); - $this->assertEquals('Benjamin E.HR', $arg[3]['namedep']); - } - - /** - * @group DDC-1014 - */ - public function testDateDiff() - { - $query = $this->_em->createQuery("SELECT DATE_DIFF(CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day')) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); - $arg = $query->getArrayResult(); - - $this->assertEquals(-10, $arg[0]['diff'], "Should be roughly -10 (or -9)", 1); - - $query = $this->_em->createQuery("SELECT DATE_DIFF(DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day'), CURRENT_TIMESTAMP()) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); - $arg = $query->getArrayResult(); - - $this->assertEquals(10, $arg[0]['diff'], "Should be roughly 10 (or 9)", 1); - } - - /** - * @group DDC-1014 - */ - public function testDateAdd() - { - $arg = $this->_em->createQuery("SELECT DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") - ->getArrayResult(); - - $this->assertTrue(strtotime($arg[0]['add']) > 0); - - $arg = $this->_em->createQuery("SELECT DATE_ADD(CURRENT_TIMESTAMP(), 10, 'month') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") - ->getArrayResult(); - - $this->assertTrue(strtotime($arg[0]['add']) > 0); - } - - /** - * @group DDC-1014 - */ - public function testDateSub() - { - $arg = $this->_em->createQuery("SELECT DATE_SUB(CURRENT_TIMESTAMP(), 10, 'day') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") - ->getArrayResult(); - - $this->assertTrue(strtotime($arg[0]['add']) > 0); - - $arg = $this->_em->createQuery("SELECT DATE_SUB(CURRENT_TIMESTAMP(), 10, 'month') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") - ->getArrayResult(); - - $this->assertTrue(strtotime($arg[0]['add']) > 0); - } - - /** - * @group DDC-1213 - */ - public function testBitOrComparison() - { - $dql = 'SELECT m, ' . - 'BIT_OR(4, 2) AS bit_or,' . - 'BIT_OR( (m.salary/100000) , 2 ) AS salary_bit_or ' . - 'FROM Doctrine\Tests\Models\Company\CompanyManager m ' . - 'ORDER BY ' . - 'm.id ' ; - $result = $this->_em->createQuery($dql)->getArrayResult(); - - $this->assertEquals(4 | 2, $result[0]['bit_or']); - $this->assertEquals(4 | 2, $result[1]['bit_or']); - $this->assertEquals(4 | 2, $result[2]['bit_or']); - $this->assertEquals(4 | 2, $result[3]['bit_or']); - - $this->assertEquals(($result[0][0]['salary']/100000) | 2, $result[0]['salary_bit_or']); - $this->assertEquals(($result[1][0]['salary']/100000) | 2, $result[1]['salary_bit_or']); - $this->assertEquals(($result[2][0]['salary']/100000) | 2, $result[2]['salary_bit_or']); - $this->assertEquals(($result[3][0]['salary']/100000) | 2, $result[3]['salary_bit_or']); - } - - /** - * @group DDC-1213 - */ - public function testBitAndComparison() - { - $dql = 'SELECT m, ' . - 'BIT_AND(4, 2) AS bit_and,' . - 'BIT_AND( (m.salary/100000) , 2 ) AS salary_bit_and ' . - 'FROM Doctrine\Tests\Models\Company\CompanyManager m ' . - 'ORDER BY ' . - 'm.id ' ; - $result = $this->_em->createQuery($dql)->getArrayResult(); - - $this->assertEquals(4 & 2, $result[0]['bit_and']); - $this->assertEquals(4 & 2, $result[1]['bit_and']); - $this->assertEquals(4 & 2, $result[2]['bit_and']); - $this->assertEquals(4 & 2, $result[3]['bit_and']); - - $this->assertEquals(($result[0][0]['salary']/100000) & 2, $result[0]['salary_bit_and']); - $this->assertEquals(($result[1][0]['salary']/100000) & 2, $result[1]['salary_bit_and']); - $this->assertEquals(($result[2][0]['salary']/100000) & 2, $result[2]['salary_bit_and']); - $this->assertEquals(($result[3][0]['salary']/100000) & 2, $result[3]['salary_bit_and']); - } - - protected function generateFixture() - { - $manager1 = new CompanyManager(); - $manager1->setName('Roman B.'); - $manager1->setTitle('Foo'); - $manager1->setDepartment('IT'); - $manager1->setSalary(100000); - - $manager2 = new CompanyManager(); - $manager2->setName('Benjamin E.'); - $manager2->setTitle('Foo'); - $manager2->setDepartment('HR'); - $manager2->setSalary(200000); - - $manager3 = new CompanyManager(); - $manager3->setName('Guilherme B.'); - $manager3->setTitle('Foo'); - $manager3->setDepartment('Complaint Department'); - $manager3->setSalary(400000); - - $manager4 = new CompanyManager(); - $manager4->setName('Jonathan W.'); - $manager4->setTitle('Foo'); - $manager4->setDepartment('Administration'); - $manager4->setSalary(800000); - - $this->_em->persist($manager1); - $this->_em->persist($manager2); - $this->_em->persist($manager3); - $this->_em->persist($manager4); - $this->_em->flush(); - $this->_em->clear(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryTest.php deleted file mode 100755 index 906b5e68f9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ /dev/null @@ -1,783 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testSimpleQueries() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select u, upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - - $result = $query->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); - $this->assertEquals('Guilherme', $result[0][0]->name); - $this->assertEquals('gblanco', $result[0][0]->username); - $this->assertEquals('developer', $result[0][0]->status); - $this->assertEquals('GUILHERME', $result[0][1]); - - $resultArray = $query->getArrayResult(); - $this->assertEquals(1, count($resultArray)); - $this->assertTrue(is_array($resultArray[0][0])); - $this->assertEquals('Guilherme', $resultArray[0][0]['name']); - $this->assertEquals('gblanco', $resultArray[0][0]['username']); - $this->assertEquals('developer', $resultArray[0][0]['status']); - $this->assertEquals('GUILHERME', $resultArray[0][1]); - - $scalarResult = $query->getScalarResult(); - $this->assertEquals(1, count($scalarResult)); - $this->assertEquals('Guilherme', $scalarResult[0]['u_name']); - $this->assertEquals('gblanco', $scalarResult[0]['u_username']); - $this->assertEquals('developer', $scalarResult[0]['u_status']); - $this->assertEquals('GUILHERME', $scalarResult[0][1]); - - $query = $this->_em->createQuery("select upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - $this->assertEquals('GUILHERME', $query->getSingleScalarResult()); - } - - public function testJoinQueries() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $article1 = new CmsArticle; - $article1->topic = "Doctrine 2"; - $article1->text = "This is an introduction to Doctrine 2."; - $user->addArticle($article1); - - $article2 = new CmsArticle; - $article2->topic = "Symfony 2"; - $article2->text = "This is an introduction to Symfony 2."; - $user->addArticle($article2); - - $this->_em->persist($user); - $this->_em->persist($article1); - $this->_em->persist($article2); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a ORDER BY a.topic"); - $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - $this->assertEquals(2, count($users[0]->articles)); - $this->assertEquals('Doctrine 2', $users[0]->articles[0]->topic); - $this->assertEquals('Symfony 2', $users[0]->articles[1]->topic); - } - - public function testUsingZeroBasedQueryParameterShouldWork() - { - $user = new CmsUser; - $user->name = 'Jonathan'; - $user->username = 'jwage'; - $user->status = 'developer'; - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?0'); - $q->setParameter(0, 'jwage'); - $user = $q->getSingleResult(); - - $this->assertNotNull($user); - } - - public function testUsingUnknownQueryParameterShouldThrowException() - { - $this->setExpectedException( - "Doctrine\ORM\Query\QueryException", - "Invalid parameter: token 2 is not defined in the query." - ); - - $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1'); - $q->setParameter(2, 'jwage'); - $user = $q->getSingleResult(); - } - - public function testMismatchingParamExpectedParamCount() - { - $this->setExpectedException( - "Doctrine\ORM\Query\QueryException", - "Invalid parameter number: number of bound variables does not match number of tokens" - ); - - $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1'); - $q->setParameter(1, 'jwage'); - $q->setParameter(2, 'jwage'); - - $user = $q->getSingleResult(); - } - - public function testInvalidInputParameterThrowsException() - { - $this->setExpectedException("Doctrine\ORM\Query\QueryException"); - - $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?'); - $q->setParameter(1, 'jwage'); - $user = $q->getSingleResult(); - } - - public function testSetParameters() - { - $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1 AND u.status = ?2'); - - $parameters = new ArrayCollection(); - $parameters->add(new Parameter(1, 'jwage')); - $parameters->add(new Parameter(2, 'active')); - - $q->setParameters($parameters); - $users = $q->getResult(); - } - - public function testSetParametersBackwardsCompatible() - { - $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1 AND u.status = ?2'); - $q->setParameters(array(1 => 'jwage', 2 => 'active')); - - $users = $q->getResult(); - } - - /** - * @group DDC-1070 - */ - public function testIterateResultAsArrayAndParams() - { - $article1 = new CmsArticle; - $article1->topic = "Doctrine 2"; - $article1->text = "This is an introduction to Doctrine 2."; - - $article2 = new CmsArticle; - $article2->topic = "Symfony 2"; - $article2->text = "This is an introduction to Symfony 2."; - - $this->_em->persist($article1); - $this->_em->persist($article2); - - $this->_em->flush(); - $this->_em->clear(); - $articleId = $article1->id; - - $query = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = ?1"); - $articles = $query->iterate(new ArrayCollection(array(new Parameter(1, 'Doctrine 2'))), Query::HYDRATE_ARRAY); - - $found = array(); - foreach ($articles AS $article) { - $found[] = $article; - } - $this->assertEquals(1, count($found)); - $this->assertEquals(array( - array(array('id' => $articleId, 'topic' => 'Doctrine 2', 'text' => 'This is an introduction to Doctrine 2.', 'version' => 1)) - ), $found); - } - - public function testIterateResult_IterativelyBuildUpUnitOfWork() - { - $article1 = new CmsArticle; - $article1->topic = "Doctrine 2"; - $article1->text = "This is an introduction to Doctrine 2."; - - $article2 = new CmsArticle; - $article2->topic = "Symfony 2"; - $article2->text = "This is an introduction to Symfony 2."; - - $this->_em->persist($article1); - $this->_em->persist($article2); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); - $articles = $query->iterate(); - - $iteratedCount = 0; - $topics = array(); - foreach($articles AS $row) { - $article = $row[0]; - $topics[] = $article->topic; - - $identityMap = $this->_em->getUnitOfWork()->getIdentityMap(); - $identityMapCount = count($identityMap['Doctrine\Tests\Models\CMS\CmsArticle']); - $this->assertTrue($identityMapCount>$iteratedCount); - - $iteratedCount++; - } - - $this->assertEquals(array("Doctrine 2", "Symfony 2"), $topics); - $this->assertEquals(2, $iteratedCount); - - $this->_em->flush(); - $this->_em->clear(); - } - - public function testIterateResultClearEveryCycle() - { - $article1 = new CmsArticle; - $article1->topic = "Doctrine 2"; - $article1->text = "This is an introduction to Doctrine 2."; - - $article2 = new CmsArticle; - $article2->topic = "Symfony 2"; - $article2->text = "This is an introduction to Symfony 2."; - - $this->_em->persist($article1); - $this->_em->persist($article2); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); - $articles = $query->iterate(); - - $iteratedCount = 0; - $topics = array(); - foreach($articles AS $row) { - $article = $row[0]; - $topics[] = $article->topic; - - $this->_em->clear(); - - $iteratedCount++; - } - - $this->assertEquals(array("Doctrine 2", "Symfony 2"), $topics); - $this->assertEquals(2, $iteratedCount); - - $this->_em->flush(); - } - - /** - * @expectedException \Doctrine\ORM\Query\QueryException - */ - public function testIterateResult_FetchJoinedCollection_ThrowsException() - { - $query = $this->_em->createQuery("SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a"); - $articles = $query->iterate(); - } - - /** - * @expectedException Doctrine\ORM\NoResultException - */ - public function testGetSingleResultThrowsExceptionOnNoResult() - { - $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a") - ->getSingleResult(); - } - - /** - * @expectedException Doctrine\ORM\NoResultException - */ - public function testGetSingleScalarResultThrowsExceptionOnNoResult() - { - $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a") - ->getSingleScalarResult(); - } - - /** - * @expectedException Doctrine\ORM\NonUniqueResultException - */ - public function testGetSingleScalarResultThrowsExceptionOnNonUniqueResult() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $article1 = new CmsArticle; - $article1->topic = "Doctrine 2"; - $article1->text = "This is an introduction to Doctrine 2."; - $user->addArticle($article1); - - $article2 = new CmsArticle; - $article2->topic = "Symfony 2"; - $article2->text = "This is an introduction to Symfony 2."; - $user->addArticle($article2); - - $this->_em->persist($user); - $this->_em->persist($article1); - $this->_em->persist($article2); - - $this->_em->flush(); - $this->_em->clear(); - - $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a") - ->getSingleScalarResult(); - } - - public function testModifiedLimitQuery() - { - for ($i = 0; $i < 5; $i++) { - $user = new CmsUser; - $user->name = 'Guilherme' . $i; - $user->username = 'gblanco' . $i; - $user->status = 'developer'; - $this->_em->persist($user); - } - - $this->_em->flush(); - $this->_em->clear(); - - $data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') - ->setFirstResult(1) - ->setMaxResults(2) - ->getResult(); - - $this->assertEquals(2, count($data)); - $this->assertEquals('gblanco1', $data[0]->username); - $this->assertEquals('gblanco2', $data[1]->username); - - $data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') - ->setFirstResult(3) - ->setMaxResults(2) - ->getResult(); - - $this->assertEquals(2, count($data)); - $this->assertEquals('gblanco3', $data[0]->username); - $this->assertEquals('gblanco4', $data[1]->username); - - $data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') - ->setFirstResult(3) - ->setMaxResults(2) - ->getScalarResult(); - } - - public function testSupportsQueriesWithEntityNamespaces() - { - $this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - - try { - $query = $this->_em->createQuery('UPDATE CMS:CmsUser u SET u.name = ?1'); - $this->assertEquals('UPDATE cms_users SET name = ?', $query->getSql()); - $query->free(); - } catch (\Exception $e) { - $this->fail($e->getMessage()); - } - - $this->_em->getConfiguration()->setEntityNamespaces(array()); - } - - /** - * @group DDC-604 - */ - public function testEntityParameters() - { - $article = new CmsArticle; - $article->topic = "dr. dolittle"; - $article->text = "Once upon a time ..."; - $author = new CmsUser; - $author->name = "anonymous"; - $author->username = "anon"; - $author->status = "here"; - $article->user = $author; - $this->_em->persist($author); - $this->_em->persist($article); - $this->_em->flush(); - $this->_em->clear(); - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a where a.topic = :topic and a.user = :user") - ->setParameter("user", $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $author->id)) - ->setParameter("topic", "dr. dolittle"); - - $result = $q->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0]); - $this->assertEquals("dr. dolittle", $result[0]->topic); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $result[0]->user); - $this->assertFalse($result[0]->user->__isInitialized__); - } - - /** - * @group DDC-952 - */ - public function testEnableFetchEagerMode() - { - for ($i = 0; $i < 10; $i++) { - $article = new CmsArticle; - $article->topic = "dr. dolittle"; - $article->text = "Once upon a time ..."; - $author = new CmsUser; - $author->name = "anonymous"; - $author->username = "anon".$i; - $author->status = "here"; - $article->user = $author; - $this->_em->persist($author); - $this->_em->persist($article); - } - $this->_em->flush(); - $this->_em->clear(); - - $articles = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a') - ->setFetchMode('Doctrine\Tests\Models\CMS\CmsArticle', 'user', ClassMetadata::FETCH_EAGER) - ->getResult(); - - $this->assertEquals(10, count($articles)); - foreach ($articles AS $article) { - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $article); - } - } - - /** - * @group DDC-991 - */ - public function testgetOneOrNullResult() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - - $fetchedUser = $query->getOneOrNullResult(); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $fetchedUser); - $this->assertEquals('gblanco', $fetchedUser->username); - - $query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - $fetchedUsername = $query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR); - $this->assertEquals('gblanco', $fetchedUsername); - } - - /** - * @group DDC-991 - */ - public function testgetOneOrNullResultSeveralRows() - { - $user = new CmsUser; - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - $this->_em->persist($user); - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'developer'; - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u"); - - $this->setExpectedException('Doctrine\ORM\NonUniqueResultException'); - $fetchedUser = $query->getOneOrNullResult(); - } - - /** - * @group DDC-991 - */ - public function testgetOneOrNullResultNoRows() - { - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u"); - $this->assertNull($query->getOneOrNullResult()); - - $query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - $this->assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR)); - } - - /** - * @group DBAL-171 - */ - public function testParameterOrder() - { - $user1 = new CmsUser; - $user1->name = 'Benjamin'; - $user1->username = 'beberlei'; - $user1->status = 'developer'; - $this->_em->persist($user1); - - $user2 = new CmsUser; - $user2->name = 'Roman'; - $user2->username = 'romanb'; - $user2->status = 'developer'; - $this->_em->persist($user2); - - $user3 = new CmsUser; - $user3->name = 'Jonathan'; - $user3->username = 'jwage'; - $user3->status = 'developer'; - $this->_em->persist($user3); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.status = :a AND u.id IN (:b)"); - $query->setParameters(new ArrayCollection(array( - new Parameter('b', array($user1->id, $user2->id, $user3->id)), - new Parameter('a', 'developer') - ))); - $result = $query->getResult(); - - $this->assertEquals(3, count($result)); - } - - public function testDqlWithAutoInferOfParameters() - { - $user = new CmsUser; - $user->name = 'Benjamin'; - $user->username = 'beberlei'; - $user->status = 'developer'; - $this->_em->persist($user); - - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'developer'; - $this->_em->persist($user); - - $user = new CmsUser; - $user->name = 'Jonathan'; - $user->username = 'jwage'; - $user->status = 'developer'; - $this->_em->persist($user); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username IN (?0)"); - $query->setParameter(0, array('beberlei', 'jwage')); - - $users = $query->execute(); - - $this->assertEquals(2, count($users)); - } - - public function testQueryBuilderWithStringWhereClauseContainingOrAndConditionalPrimary() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->innerJoin('u.articles', 'a') - ->where('(u.id = 0) OR (u.id IS NULL)'); - - $query = $qb->getQuery(); - $users = $query->execute(); - - $this->assertEquals(0, count($users)); - } - - public function testQueryWithArrayOfEntitiesAsParameter() - { - $userA = new CmsUser; - $userA->name = 'Benjamin'; - $userA->username = 'beberlei'; - $userA->status = 'developer'; - $this->_em->persist($userA); - - $userB = new CmsUser; - $userB->name = 'Roman'; - $userB->username = 'romanb'; - $userB->status = 'developer'; - $this->_em->persist($userB); - - $userC = new CmsUser; - $userC->name = 'Jonathan'; - $userC->username = 'jwage'; - $userC->status = 'developer'; - $this->_em->persist($userC); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u IN (?0) OR u.username = ?1"); - $query->setParameter(0, array($userA, $userC)); - $query->setParameter(1, 'beberlei'); - - $users = $query->execute(); - - $this->assertEquals(2, count($users)); - } - - public function testQueryWithHiddenAsSelectExpression() - { - $userA = new CmsUser; - $userA->name = 'Benjamin'; - $userA->username = 'beberlei'; - $userA->status = 'developer'; - $this->_em->persist($userA); - - $userB = new CmsUser; - $userB->name = 'Roman'; - $userB->username = 'romanb'; - $userB->status = 'developer'; - $this->_em->persist($userB); - - $userC = new CmsUser; - $userC->name = 'Jonathan'; - $userC->username = 'jwage'; - $userC->status = 'developer'; - $this->_em->persist($userC); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery("SELECT u, (SELECT COUNT(u2.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) AS HIDDEN total FROM Doctrine\Tests\Models\CMS\CmsUser u"); - $users = $query->execute(); - - $this->assertEquals(3, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - } - - /** - * @group DDC-1651 - */ - public function testSetParameterBindingSingleIdentifierObject() - { - $userC = new CmsUser; - $userC->name = 'Jonathan'; - $userC->username = 'jwage'; - $userC->status = 'developer'; - $this->_em->persist($userC); - - $this->_em->flush(); - $this->_em->clear(); - - $q = $this->_em->createQuery("SELECT DISTINCT u from Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"); - $q->setParameter(1, $userC); - - $this->assertEquals($userC, $q->getParameter(1)->getValue()); - - // Parameter is not converted before, but it should be converted during execution. Test should not fail here - $q->getResult(); - } - - - /** - * @group DDC-1822 - */ - public function testUnexpectedResultException() - { - $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; - $u1 = new CmsUser; - $u2 = new CmsUser; - $u1->name = 'Fabio B. Silva'; - $u1->username = 'FabioBatSilva'; - $u1->status = 'developer'; - $u2->name = 'Test'; - $u2->username = 'test'; - $u2->status = 'tester'; - - try { - $this->_em->createQuery($dql)->getSingleResult(); - $this->fail('Expected exception "\Doctrine\ORM\NoResultException".'); - } catch (\Doctrine\ORM\UnexpectedResultException $exc) { - $this->assertInstanceOf('\Doctrine\ORM\NoResultException', $exc); - } - - - $this->_em->persist($u1); - $this->_em->persist($u2); - $this->_em->flush(); - $this->_em->clear(); - - try { - $this->_em->createQuery($dql)->getSingleResult(); - $this->fail('Expected exception "\Doctrine\ORM\NonUniqueResultException".'); - } catch (\Doctrine\ORM\UnexpectedResultException $exc) { - $this->assertInstanceOf('\Doctrine\ORM\NonUniqueResultException', $exc); - } - } - - public function testMultipleJoinComponentsUsingInnerJoin() - { - $userA = new CmsUser; - $userA->name = 'Benjamin'; - $userA->username = 'beberlei'; - $userA->status = 'developer'; - - $phonenumberA = new CmsPhonenumber; - $phonenumberA->phonenumber = '111111'; - $userA->addPhonenumber($phonenumberA); - - $userB = new CmsUser; - $userB->name = 'Alexander'; - $userB->username = 'asm89'; - $userB->status = 'developer'; - - $this->_em->persist($userA); - $this->_em->persist($userB); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery(" - SELECT u, p - FROM Doctrine\Tests\Models\CMS\CmsUser u - INNER JOIN Doctrine\Tests\Models\CMS\CmsPhonenumber p WITH u = p.user - "); - $users = $query->execute(); - - $this->assertEquals(2, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $users[1]); - } - - public function testMultipleJoinComponentsUsingLeftJoin() - { - $userA = new CmsUser; - $userA->name = 'Benjamin'; - $userA->username = 'beberlei'; - $userA->status = 'developer'; - - $phonenumberA = new CmsPhonenumber; - $phonenumberA->phonenumber = '111111'; - $userA->addPhonenumber($phonenumberA); - - $userB = new CmsUser; - $userB->name = 'Alexander'; - $userB->username = 'asm89'; - $userB->status = 'developer'; - - $this->_em->persist($userA); - $this->_em->persist($userB); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery(" - SELECT u, p - FROM Doctrine\Tests\Models\CMS\CmsUser u - LEFT JOIN Doctrine\Tests\Models\CMS\CmsPhonenumber p WITH u = p.user - "); - $users = $query->execute(); - - $this->assertEquals(4, count($users)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $users[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[2]); - $this->assertNull($users[3]); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php deleted file mode 100755 index 2519a9c570..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ /dev/null @@ -1,94 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ReadOnlyEntity'), - )); - } catch(\Exception $e) { - } - } - - public function testReadOnlyEntityNeverChangeTracked() - { - $readOnly = new ReadOnlyEntity("Test1", 1234); - $this->_em->persist($readOnly); - $this->_em->flush(); - - $readOnly->name = "Test2"; - $readOnly->numericValue = 4321; - - $this->_em->flush(); - $this->_em->clear(); - - $dbReadOnly = $this->_em->find('Doctrine\Tests\ORM\Functional\ReadOnlyEntity', $readOnly->id); - $this->assertEquals("Test1", $dbReadOnly->name); - $this->assertEquals(1234, $dbReadOnly->numericValue); - } - - /** - * @group DDC-1659 - */ - public function testClearReadOnly() - { - $readOnly = new ReadOnlyEntity("Test1", 1234); - $this->_em->persist($readOnly); - $this->_em->flush(); - $this->_em->getUnitOfWork()->markReadOnly($readOnly); - - $this->_em->clear(); - - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); - } - - /** - * @group DDC-1659 - */ - public function testClearEntitiesReadOnly() - { - $readOnly = new ReadOnlyEntity("Test1", 1234); - $this->_em->persist($readOnly); - $this->_em->flush(); - $this->_em->getUnitOfWork()->markReadOnly($readOnly); - - $this->_em->clear(get_class($readOnly)); - - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); - } -} - -/** - * @Entity(readOnly=true) - */ -class ReadOnlyEntity -{ - /** - * @Id @GeneratedValue @Column(type="integer") - * @var int - */ - public $id; - /** @column(type="string") */ - public $name; - /** @Column(type="integer") */ - public $numericValue; - - public function __construct($name, $number) - { - $this->name = $name; - $this->numericValue = $number; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php deleted file mode 100755 index 3ce24e7399..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php +++ /dev/null @@ -1,250 +0,0 @@ - - * @author Benjamin Eberlei - */ -class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - protected function setUp() - { - $this->useModelSet('ecommerce'); - parent::setUp(); - $this->_factory = new ProxyFactory( - $this->_em, - __DIR__ . '/../../Proxies', - 'Doctrine\Tests\Proxies', - true); - } - - public function createProduct() - { - $product = new ECommerceProduct(); - $product->setName('Doctrine Cookbook'); - $this->_em->persist($product); - - $this->_em->flush(); - $this->_em->clear(); - - return $product->getId(); - } - - public function createAuction() - { - $event = new CompanyAuction(); - $event->setData('Doctrine Cookbook'); - $this->_em->persist($event); - - $this->_em->flush(); - $this->_em->clear(); - - return $event->getId(); - } - - public function testLazyLoadsFieldValuesFromDatabase() - { - $id = $this->createProduct(); - - $productProxy = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct', array('id' => $id)); - $this->assertEquals('Doctrine Cookbook', $productProxy->getName()); - } - - /** - * @group DDC-727 - */ - public function testAccessMetatadaForProxy() - { - $id = $this->createProduct(); - - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - $class = $this->_em->getClassMetadata(get_class($entity)); - - $this->assertEquals('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $class->name); - } - - /** - * @group DDC-1033 - */ - public function testReferenceFind() - { - $id = $this->createProduct(); - - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - $entity2 = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - - $this->assertSame($entity, $entity2); - $this->assertEquals('Doctrine Cookbook', $entity2->getName()); - } - - /** - * @group DDC-1033 - */ - public function testCloneProxy() - { - $id = $this->createProduct(); - - /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - - /* @var $clone Doctrine\Tests\Models\ECommerce\ECommerceProduct */ - $clone = clone $entity; - - $this->assertEquals($id, $entity->getId()); - $this->assertEquals('Doctrine Cookbook', $entity->getName()); - - $this->assertFalse($this->_em->contains($clone), "Cloning a reference proxy should return an unmanaged/detached entity."); - $this->assertEquals($id, $clone->getId(), "Cloning a reference proxy should return same id."); - $this->assertEquals('Doctrine Cookbook', $clone->getName(), "Cloning a reference proxy should return same product name."); - - // domain logic, Product::__clone sets isCloned public property - $this->assertTrue($clone->isCloned); - $this->assertFalse($entity->isCloned); - } - - /** - * @group DDC-733 - */ - public function testInitializeProxy() - { - $id = $this->createProduct(); - - /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - - $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); - $this->_em->getUnitOfWork()->initializeObject($entity); - $this->assertTrue($entity->__isInitialized__, "Should be initialized after called UnitOfWork::initializeObject()"); - } - - /** - * @group DDC-1163 - */ - public function testInitializeChangeAndFlushProxy() - { - $id = $this->createProduct(); - - /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - $entity->setName('Doctrine 2 Cookbook'); - - $this->_em->flush(); - $this->_em->clear(); - - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - $this->assertEquals('Doctrine 2 Cookbook', $entity->getName()); - } - - /** - * @group DDC-1022 - */ - public function testWakeupCalledOnProxy() - { - $id = $this->createProduct(); - - /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - - $this->assertFalse($entity->wakeUp); - - $entity->setName('Doctrine 2 Cookbook'); - - $this->assertTrue($entity->wakeUp, "Loading the proxy should call __wakeup()."); - } - - public function testDoNotInitializeProxyOnGettingTheIdentifier() - { - $id = $this->createProduct(); - - /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - - $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); - $this->assertEquals($id, $entity->getId()); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); - } - - /** - * @group DDC-1625 - */ - public function testDoNotInitializeProxyOnGettingTheIdentifier_DDC_1625() - { - $id = $this->createAuction(); - - /* @var $entity Doctrine\Tests\Models\Company\CompanyAuction */ - $entity = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyAuction' , $id); - - $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); - $this->assertEquals($id, $entity->getId()); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy when extending."); - } - - public function testDoNotInitializeProxyOnGettingTheIdentifierAndReturnTheRightType() - { - $product = new ECommerceProduct(); - $product->setName('Doctrine Cookbook'); - - $shipping = new ECommerceShipping(); - $shipping->setDays(1); - $product->setShipping($shipping); - $this->_em->persist($product); - $this->_em->flush(); - $this->_em->clear(); - - $id = $shipping->getId(); - - $product = $this->_em->getRepository('Doctrine\Tests\Models\ECommerce\ECommerceProduct')->find($product->getId()); - - $entity = $product->getShipping(); - $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); - $this->assertEquals($id, $entity->getId()); - $this->assertSame($id, $entity->getId(), "Check that the id's are the same value, and type."); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); - } - - public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier() - { - $id = $this->createProduct(); - - /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - - $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); - $this->assertEquals('Doctrine Cookbook', $entity->getName()); - $this->assertTrue($entity->__isInitialized__, "Getting something other than the identifier initializes the proxy."); - } - - /** - * @group DDC-1604 - */ - public function testCommonPersistenceProxy() - { - $id = $this->createProduct(); - - /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ - $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - $className = \Doctrine\Common\Util\ClassUtils::getClass($entity); - - $this->assertInstanceOf('Doctrine\Common\Persistence\Proxy', $entity); - $this->assertFalse($entity->__isInitialized()); - $this->assertEquals('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $className); - - $restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), "", get_class($entity)); - $restName = substr(get_class($entity), strlen($this->_em->getConfiguration()->getProxyNamespace()) +1); - $proxyFileName = $this->_em->getConfiguration()->getProxyDir() . DIRECTORY_SEPARATOR . str_replace("\\", "", $restName) . ".php"; - $this->assertTrue(file_exists($proxyFileName), "Proxy file name cannot be found generically."); - - $entity->__load(); - $this->assertTrue($entity->__isInitialized()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php deleted file mode 100755 index 5846d92a03..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php +++ /dev/null @@ -1,254 +0,0 @@ -cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); - $this->cacheDataReflection->setAccessible(true); - $this->useModelSet('cms'); - parent::setUp(); - } - - /** - * @param ArrayCache $cache - * @return integer - */ - private function getCacheSize(ArrayCache $cache) - { - return sizeof($this->cacheDataReflection->getValue($cache)); - } - - public function testResultCache() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - $this->_em->persist($user); - $this->_em->flush(); - - - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - - $cache = new ArrayCache(); - - $query->setResultCacheDriver($cache)->setResultCacheId('my_cache_id'); - - $this->assertFalse($cache->contains('my_cache_id')); - - $users = $query->getResult(); - - $this->assertTrue($cache->contains('my_cache_id')); - $this->assertEquals(1, count($users)); - $this->assertEquals('Roman', $users[0]->name); - - $this->_em->clear(); - - $query2 = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - $query2->setResultCacheDriver($cache)->setResultCacheId('my_cache_id'); - - $users = $query2->getResult(); - - $this->assertTrue($cache->contains('my_cache_id')); - $this->assertEquals(1, count($users)); - $this->assertEquals('Roman', $users[0]->name); - } - - public function testSetResultCacheId() - { - $cache = new ArrayCache; - - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - $query->setResultCacheDriver($cache); - $query->setResultCacheId('testing_result_cache_id'); - - $this->assertFalse($cache->contains('testing_result_cache_id')); - - $users = $query->getResult(); - - $this->assertTrue($cache->contains('testing_result_cache_id')); - } - - public function testUseResultCache() - { - $cache = new \Doctrine\Common\Cache\ArrayCache(); - - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - $query->useResultCache(true); - $query->setResultCacheDriver($cache); - $query->setResultCacheId('testing_result_cache_id'); - $users = $query->getResult(); - - $this->assertTrue($cache->contains('testing_result_cache_id')); - - $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); - } - - /** - * @group DDC-1026 - */ - public function testUseResultCacheParams() - { - $cache = new \Doctrine\Common\Cache\ArrayCache(); - - $sqlCount = count($this->_sqlLoggerStack->queries); - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux WHERE ux.id = ?1'); - $query->setParameter(1, 1); - $query->setResultCacheDriver($cache); - $query->useResultCache(true); - $query->getResult(); - - $query->setParameter(1, 2); - $query->getResult(); - - $this->assertEquals($sqlCount + 2, count($this->_sqlLoggerStack->queries), "Two non-cached queries."); - - $query->setParameter(1, 1); - $query->useResultCache(true); - $query->getResult(); - - $query->setParameter(1, 2); - $query->getResult(); - - $this->assertEquals($sqlCount + 2, count($this->_sqlLoggerStack->queries), "The next two sql should have been cached, but were not."); - } - - public function testNativeQueryResultCaching() - { - $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); - $rsm->addScalarResult('id', 'u'); - $query = $this->_em->createNativeQuery('select u.id FROM cms_users u WHERE u.id = ?', $rsm); - $query->setParameter(1, 10); - - $cache = new ArrayCache(); - $query->setResultCacheDriver($cache)->useResultCache(true); - - $this->assertEquals(0, $this->getCacheSize($cache)); - $query->getResult(); - $this->assertEquals(2, $this->getCacheSize($cache)); - - return $query; - } - - /** - * @param string $query - * @depends testNativeQueryResultCaching - */ - public function testResultCacheNotDependsOnQueryHints($query) - { - $cache = $query->getResultCacheDriver(); - $cacheCount = $this->getCacheSize($cache); - - $query->setHint('foo', 'bar'); - $query->getResult(); - - $this->assertEquals($cacheCount, $this->getCacheSize($cache)); - } - - /** - * @param $query - * @depends testNativeQueryResultCaching - */ - public function testResultCacheDependsOnParameters($query) - { - $cache = $query->getResultCacheDriver(); - $cacheCount = $this->getCacheSize($cache); - - $query->setParameter(1, 50); - $query->getResult(); - - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); - } - - /** - * @param $query - * @depends testNativeQueryResultCaching - */ - public function testResultCacheNotDependsOnHydrationMode($query) - { - $cache = $query->getResultCacheDriver(); - $cacheCount = $this->getCacheSize($cache); - - $this->assertNotEquals(\Doctrine\ORM\Query::HYDRATE_ARRAY, $query->getHydrationMode()); - $query->getArrayResult(); - - $this->assertEquals($cacheCount, $this->getCacheSize($cache)); - } - - /** - * @group DDC-909 - */ - public function testResultCacheWithObjectParameter() - { - $user1 = new CmsUser; - $user1->name = 'Roman'; - $user1->username = 'romanb'; - $user1->status = 'dev'; - - $user2 = new CmsUser; - $user2->name = 'Benjamin'; - $user2->username = 'beberlei'; - $user2->status = 'dev'; - - $article = new CmsArticle(); - $article->text = "foo"; - $article->topic = "baz"; - $article->user = $user1; - - $this->_em->persist($article); - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->flush(); - - $query = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1'); - $query->setParameter(1, $user1); - - $cache = new ArrayCache(); - - $query->setResultCacheDriver($cache)->useResultCache(true); - - $articles = $query->getResult(); - - $this->assertEquals(1, count($articles)); - $this->assertEquals('baz', $articles[0]->topic); - - $this->_em->clear(); - - $query2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1'); - $query2->setParameter(1, $user1); - - $query2->setResultCacheDriver($cache)->useResultCache(true); - - $articles = $query2->getResult(); - - $this->assertEquals(1, count($articles)); - $this->assertEquals('baz', $articles[0]->topic); - - $query3 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1'); - $query3->setParameter(1, $user2); - - $query3->setResultCacheDriver($cache)->useResultCache(true); - - $articles = $query3->getResult(); - - $this->assertEquals(0, count($articles)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php deleted file mode 100755 index 30f6d63f7b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ /dev/null @@ -1,1137 +0,0 @@ - - */ -class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - private $userId, $userId2, $articleId, $articleId2; - private $groupId, $groupId2; - private $managerId, $managerId2, $contractId1, $contractId2; - private $organizationId, $eventId1, $eventId2; - - public function setUp() - { - $this->useModelSet('cms'); - $this->useModelSet('company'); - parent::setUp(); - } - - public function tearDown() - { - parent::tearDown(); - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_LAZY; - $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY; - } - - public function testConfigureFilter() - { - $config = new \Doctrine\ORM\Configuration(); - - $config->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter"); - - $this->assertEquals("\Doctrine\Tests\ORM\Functional\MyLocaleFilter", $config->getFilterClassName("locale")); - $this->assertNull($config->getFilterClassName("foo")); - } - - public function testEntityManagerEnableFilter() - { - $em = $this->_getEntityManager(); - $this->configureFilters($em); - - // Enable an existing filter - $filter = $em->getFilters()->enable("locale"); - $this->assertTrue($filter instanceof \Doctrine\Tests\ORM\Functional\MyLocaleFilter); - - // Enable the filter again - $filter2 = $em->getFilters()->enable("locale"); - $this->assertEquals($filter, $filter2); - - // Enable a non-existing filter - $exceptionThrown = false; - try { - $filter = $em->getFilters()->enable("foo"); - } catch (\InvalidArgumentException $e) { - $exceptionThrown = true; - } - $this->assertTrue($exceptionThrown); - } - - public function testEntityManagerEnabledFilters() - { - $em = $this->_getEntityManager(); - - // No enabled filters - $this->assertEquals(array(), $em->getFilters()->getEnabledFilters()); - - $this->configureFilters($em); - $filter = $em->getFilters()->enable("locale"); - $filter = $em->getFilters()->enable("soft_delete"); - - // Two enabled filters - $this->assertEquals(2, count($em->getFilters()->getEnabledFilters())); - - } - - public function testEntityManagerDisableFilter() - { - $em = $this->_getEntityManager(); - $this->configureFilters($em); - - // Enable the filter - $filter = $em->getFilters()->enable("locale"); - - // Disable it - $this->assertEquals($filter, $em->getFilters()->disable("locale")); - $this->assertEquals(0, count($em->getFilters()->getEnabledFilters())); - - // Disable a non-existing filter - $exceptionThrown = false; - try { - $filter = $em->getFilters()->disable("foo"); - } catch (\InvalidArgumentException $e) { - $exceptionThrown = true; - } - $this->assertTrue($exceptionThrown); - - // Disable a non-enabled filter - $exceptionThrown = false; - try { - $filter = $em->getFilters()->disable("locale"); - } catch (\InvalidArgumentException $e) { - $exceptionThrown = true; - } - $this->assertTrue($exceptionThrown); - } - - public function testEntityManagerGetFilter() - { - $em = $this->_getEntityManager(); - $this->configureFilters($em); - - // Enable the filter - $filter = $em->getFilters()->enable("locale"); - - // Get the filter - $this->assertEquals($filter, $em->getFilters()->getFilter("locale")); - - // Get a non-enabled filter - $exceptionThrown = false; - try { - $filter = $em->getFilters()->getFilter("soft_delete"); - } catch (\InvalidArgumentException $e) { - $exceptionThrown = true; - } - $this->assertTrue($exceptionThrown); - } - - protected function configureFilters($em) - { - // Add filters to the configuration of the EM - $config = $em->getConfiguration(); - $config->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter"); - $config->addFilter("soft_delete", "\Doctrine\Tests\ORM\Functional\MySoftDeleteFilter"); - } - - protected function getMockConnection() - { - // Setup connection mock - $conn = $this->getMockBuilder('Doctrine\DBAL\Connection') - ->disableOriginalConstructor() - ->getMock(); - - return $conn; - } - - protected function getMockEntityManager() - { - // Setup connection mock - $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') - ->disableOriginalConstructor() - ->getMock(); - - return $em; - } - - protected function addMockFilterCollection($em) - { - $filterCollection = $this->getMockBuilder('Doctrine\ORM\Query\FilterCollection') - ->disableOriginalConstructor() - ->getMock(); - - $em->expects($this->any()) - ->method('getFilters') - ->will($this->returnValue($filterCollection)); - - return $filterCollection; - } - - public function testSQLFilterGetSetParameter() - { - // Setup mock connection - $conn = $this->getMockConnection(); - $conn->expects($this->once()) - ->method('quote') - ->with($this->equalTo('en')) - ->will($this->returnValue("'en'")); - - $em = $this->getMockEntityManager($conn); - $em->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($conn)); - - $filterCollection = $this->addMockFilterCollection($em); - $filterCollection - ->expects($this->once()) - ->method('setFiltersStateDirty'); - - $filter = new MyLocaleFilter($em); - - $filter->setParameter('locale', 'en', DBALType::STRING); - - $this->assertEquals("'en'", $filter->getParameter('locale')); - } - - public function testSQLFilterSetParameterInfersType() - { - // Setup mock connection - $conn = $this->getMockConnection(); - $conn->expects($this->once()) - ->method('quote') - ->with($this->equalTo('en')) - ->will($this->returnValue("'en'")); - - $em = $this->getMockEntityManager($conn); - $em->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($conn)); - - $filterCollection = $this->addMockFilterCollection($em); - $filterCollection - ->expects($this->once()) - ->method('setFiltersStateDirty'); - - $filter = new MyLocaleFilter($em); - - $filter->setParameter('locale', 'en'); - - $this->assertEquals("'en'", $filter->getParameter('locale')); - } - - public function testSQLFilterAddConstraint() - { - // Set up metadata mock - $targetEntity = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata') - ->disableOriginalConstructor() - ->getMock(); - - $filter = new MySoftDeleteFilter($this->getMockEntityManager()); - - // Test for an entity that gets extra filter data - $targetEntity->name = 'MyEntity\SoftDeleteNewsItem'; - $this->assertEquals('t1_.deleted = 0', $filter->addFilterConstraint($targetEntity, 't1_')); - - // Test for an entity that doesn't get extra filter data - $targetEntity->name = 'MyEntity\NoSoftDeleteNewsItem'; - $this->assertEquals('', $filter->addFilterConstraint($targetEntity, 't1_')); - - } - - public function testSQLFilterToString() - { - $em = $this->getMockEntityManager(); - $filterCollection = $this->addMockFilterCollection($em); - - $filter = new MyLocaleFilter($em); - $filter->setParameter('locale', 'en', DBALType::STRING); - $filter->setParameter('foo', 'bar', DBALType::STRING); - - $filter2 = new MyLocaleFilter($em); - $filter2->setParameter('foo', 'bar', DBALType::STRING); - $filter2->setParameter('locale', 'en', DBALType::STRING); - - $parameters = array( - 'foo' => array('value' => 'bar', 'type' => DBALType::STRING), - 'locale' => array('value' => 'en', 'type' => DBALType::STRING), - ); - - $this->assertEquals(serialize($parameters), ''.$filter); - $this->assertEquals(''.$filter, ''.$filter2); - } - - public function testQueryCache_DependsOnFilters() - { - $cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); - $cacheDataReflection->setAccessible(true); - - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - - $cache = new ArrayCache(); - $query->setQueryCacheDriver($cache); - - $query->getResult(); - $this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache))); - - $conf = $this->_em->getConfiguration(); - $conf->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter"); - $this->_em->getFilters()->enable("locale"); - - $query->getResult(); - $this->assertEquals(3, sizeof($cacheDataReflection->getValue($cache))); - - // Another time doesn't add another cache entry - $query->getResult(); - $this->assertEquals(3, sizeof($cacheDataReflection->getValue($cache))); - } - - public function testQueryGeneration_DependsOnFilters() - { - $query = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsAddress a'); - $firstSQLQuery = $query->getSQL(); - - $conf = $this->_em->getConfiguration(); - $conf->addFilter("country", "\Doctrine\Tests\ORM\Functional\CMSCountryFilter"); - $this->_em->getFilters()->enable("country") - ->setParameter("country", "en", DBALType::STRING); - - $this->assertNotEquals($firstSQLQuery, $query->getSQL()); - } - - public function testRepositoryFind() - { - $this->loadFixtureData(); - - $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId)); - $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId2)); - - $this->useCMSGroupPrefixFilter(); - $this->_em->clear(); - - $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId)); - $this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId2)); - } - - public function testRepositoryFindAll() - { - $this->loadFixtureData(); - - $this->assertCount(2, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll()); - - $this->useCMSGroupPrefixFilter(); - $this->_em->clear(); - - $this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll()); - } - - public function testRepositoryFindBy() - { - $this->loadFixtureData(); - - $this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findBy(array('id' => $this->groupId2))); - - $this->useCMSGroupPrefixFilter(); - $this->_em->clear(); - - $this->assertCount(0, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findBy(array('id' => $this->groupId2))); - } - - public function testRepositoryFindByX() - { - $this->loadFixtureData(); - - $this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findById($this->groupId2)); - - $this->useCMSGroupPrefixFilter(); - $this->_em->clear(); - - $this->assertCount(0, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findById($this->groupId2)); - } - - public function testRepositoryFindOneBy() - { - $this->loadFixtureData(); - - $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneBy(array('id' => $this->groupId2))); - - $this->useCMSGroupPrefixFilter(); - $this->_em->clear(); - - $this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneBy(array('id' => $this->groupId2))); - } - - public function testRepositoryFindOneByX() - { - $this->loadFixtureData(); - - $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneById($this->groupId2)); - - $this->useCMSGroupPrefixFilter(); - $this->_em->clear(); - - $this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneById($this->groupId2)); - } - - public function testToOneFilter() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->loadFixtureData(); - - $query = $this->_em->createQuery('select ux, ua from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.address ua'); - - // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); - - $conf = $this->_em->getConfiguration(); - $conf->addFilter("country", "\Doctrine\Tests\ORM\Functional\CMSCountryFilter"); - $this->_em->getFilters()->enable("country")->setParameter("country", "Germany", DBALType::STRING); - - // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); - } - - public function testManyToManyFilter() - { - $this->loadFixtureData(); - $query = $this->_em->createQuery('select ux, ug from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.groups ug'); - - // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); - - $conf = $this->_em->getConfiguration(); - $conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter"); - $this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "bar_%", DBALType::STRING); - - // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); - - } - - public function testWhereFilter() - { - $this->loadFixtureData(); - $query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1'); - - // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); - - $conf = $this->_em->getConfiguration(); - $conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter"); - $this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "bar_%", DBALType::STRING); - - // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); - } - - public function testWhereOrFilter() - { - $this->loadFixtureData(); - $query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1 OR 1=1'); - - // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); - - $conf = $this->_em->getConfiguration(); - $conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter"); - $this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "bar_%", DBALType::STRING); - - // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); - } - - - private function loadLazyFixtureData() - { - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; - $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; - $this->loadFixtureData(); - } - - private function useCMSArticleTopicFilter() - { - $conf = $this->_em->getConfiguration(); - $conf->addFilter("article_topic", "\Doctrine\Tests\ORM\Functional\CMSArticleTopicFilter"); - $this->_em->getFilters()->enable("article_topic")->setParameter("topic", "Test1", DBALType::STRING); - } - - public function testOneToMany_ExtraLazyCountWithFilter() - { - $this->loadLazyFixtureData(); - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals(2, count($user->articles)); - - $this->useCMSArticleTopicFilter(); - - $this->assertEquals(1, count($user->articles)); - } - - public function testOneToMany_ExtraLazyContainsWithFilter() - { - $this->loadLazyFixtureData(); - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $filteredArticle = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId2); - - $this->assertFalse($user->articles->isInitialized()); - $this->assertTrue($user->articles->contains($filteredArticle)); - - $this->useCMSArticleTopicFilter(); - - $this->assertFalse($user->articles->contains($filteredArticle)); - } - - public function testOneToMany_ExtraLazySliceWithFilter() - { - $this->loadLazyFixtureData(); - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals(2, count($user->articles->slice(0,10))); - - $this->useCMSArticleTopicFilter(); - - $this->assertEquals(1, count($user->articles->slice(0,10))); - } - - private function useCMSGroupPrefixFilter() - { - $conf = $this->_em->getConfiguration(); - $conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter"); - $this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "foo%", DBALType::STRING); - } - - public function testManyToMany_ExtraLazyCountWithFilter() - { - $this->loadLazyFixtureData(); - - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); - - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(2, count($user->groups)); - - $this->useCMSGroupPrefixFilter(); - - $this->assertEquals(1, count($user->groups)); - } - - public function testManyToMany_ExtraLazyContainsWithFilter() - { - $this->loadLazyFixtureData(); - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); - $filteredArticle = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId2); - - $this->assertFalse($user->groups->isInitialized()); - $this->assertTrue($user->groups->contains($filteredArticle)); - - $this->useCMSGroupPrefixFilter(); - - $this->assertFalse($user->groups->contains($filteredArticle)); - } - - public function testManyToMany_ExtraLazySliceWithFilter() - { - $this->loadLazyFixtureData(); - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); - - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(2, count($user->groups->slice(0,10))); - - $this->useCMSGroupPrefixFilter(); - - $this->assertEquals(1, count($user->groups->slice(0,10))); - } - - private function loadFixtureData() - { - $user = new CmsUser; - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'developer'; - - $address = new CmsAddress; - $address->country = 'Germany'; - $address->city = 'Berlin'; - $address->zip = '12345'; - - $user->address = $address; // inverse side - $address->user = $user; // owning side! - - $group = new CmsGroup; - $group->name = 'foo_group'; - $user->addGroup($group); - - $article1 = new CmsArticle; - $article1->topic = "Test1"; - $article1->text = "Test"; - $article1->setAuthor($user); - - $article2 = new CmsArticle; - $article2->topic = "Test2"; - $article2->text = "Test"; - $article2->setAuthor($user); - - $this->_em->persist($article1); - $this->_em->persist($article2); - - $this->_em->persist($user); - - $user2 = new CmsUser; - $user2->name = 'Guilherme'; - $user2->username = 'gblanco'; - $user2->status = 'developer'; - - $address2 = new CmsAddress; - $address2->country = 'France'; - $address2->city = 'Paris'; - $address2->zip = '12345'; - - $user->address = $address2; // inverse side - $address2->user = $user2; // owning side! - - $user2->addGroup($group); - $group2 = new CmsGroup; - $group2->name = 'bar_group'; - $user2->addGroup($group2); - - $this->_em->persist($user2); - $this->_em->flush(); - $this->_em->clear(); - - $this->userId = $user->getId(); - $this->userId2 = $user2->getId(); - $this->articleId = $article1->id; - $this->articleId2 = $article2->id; - $this->groupId = $group->id; - $this->groupId2 = $group2->id; - } - - public function testJoinSubclassPersister_FilterOnlyOnRootTableWhenFetchingSubEntity() - { - $this->loadCompanyJoinedSubclassFixtureData(); - // Persister - $this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager')->findAll())); - // SQLWalker - $this->assertEquals(2, count($this->_em->createQuery("SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm")->getResult())); - - // Enable the filter - $this->usePersonNameFilter('Guilh%'); - - $managers = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager')->findAll(); - $this->assertEquals(1, count($managers)); - $this->assertEquals("Guilherme", $managers[0]->getName()); - - $this->assertEquals(1, count($this->_em->createQuery("SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm")->getResult())); - } - - public function testJoinSubclassPersister_FilterOnlyOnRootTableWhenFetchingRootEntity() - { - $this->loadCompanyJoinedSubclassFixtureData(); - $this->assertEquals(3, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson')->findAll())); - $this->assertEquals(3, count($this->_em->createQuery("SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp")->getResult())); - - // Enable the filter - $this->usePersonNameFilter('Guilh%'); - - $persons = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson')->findAll(); - $this->assertEquals(1, count($persons)); - $this->assertEquals("Guilherme", $persons[0]->getName()); - - $this->assertEquals(1, count($this->_em->createQuery("SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp")->getResult())); - } - - private function loadCompanyJoinedSubclassFixtureData() - { - $manager = new CompanyManager; - $manager->setName('Roman'); - $manager->setTitle('testlead'); - $manager->setSalary(42); - $manager->setDepartment('persisters'); - - $manager2 = new CompanyManager; - $manager2->setName('Guilherme'); - $manager2->setTitle('devlead'); - $manager2->setSalary(42); - $manager2->setDepartment('parsers'); - - $person = new CompanyPerson; - $person->setName('Benjamin'); - - $this->_em->persist($manager); - $this->_em->persist($manager2); - $this->_em->persist($person); - $this->_em->flush(); - $this->_em->clear(); - } - - public function testSingleTableInheritance_FilterOnlyOnRootTableWhenFetchingSubEntity() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - // Persister - $this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); - // SQLWalker - $this->assertEquals(2, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc")->getResult())); - - // Enable the filter - $conf = $this->_em->getConfiguration(); - $conf->addFilter("completed_contract", "\Doctrine\Tests\ORM\Functional\CompletedContractFilter"); - $this->_em->getFilters() - ->enable("completed_contract") - ->setParameter("completed", true, DBALType::BOOLEAN); - - $this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); - $this->assertEquals(1, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc")->getResult())); - } - - public function testSingleTableInheritance_FilterOnlyOnRootTableWhenFetchingRootEntity() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - $this->assertEquals(4, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); - $this->assertEquals(4, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc")->getResult())); - - // Enable the filter - $conf = $this->_em->getConfiguration(); - $conf->addFilter("completed_contract", "\Doctrine\Tests\ORM\Functional\CompletedContractFilter"); - $this->_em->getFilters() - ->enable("completed_contract") - ->setParameter("completed", true, DBALType::BOOLEAN); - - $this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); - $this->assertEquals(2, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc")->getResult())); - } - - private function loadCompanySingleTableInheritanceFixtureData() - { - $contract1 = new CompanyFlexUltraContract; - $contract2 = new CompanyFlexUltraContract; - $contract2->markCompleted(); - - $contract3 = new CompanyFlexContract; - $contract4 = new CompanyFlexContract; - $contract4->markCompleted(); - - $manager = new CompanyManager; - $manager->setName('Alexander'); - $manager->setSalary(42); - $manager->setDepartment('Doctrine'); - $manager->setTitle('Filterer'); - - $manager2 = new CompanyManager; - $manager2->setName('Benjamin'); - $manager2->setSalary(1337); - $manager2->setDepartment('Doctrine'); - $manager2->setTitle('Maintainer'); - - $contract1->addManager($manager); - $contract2->addManager($manager); - $contract3->addManager($manager); - $contract4->addManager($manager); - - $contract1->addManager($manager2); - - $contract1->setSalesPerson($manager); - $contract2->setSalesPerson($manager); - - $this->_em->persist($manager); - $this->_em->persist($manager2); - $this->_em->persist($contract1); - $this->_em->persist($contract2); - $this->_em->persist($contract3); - $this->_em->persist($contract4); - $this->_em->flush(); - $this->_em->clear(); - - $this->managerId = $manager->getId(); - $this->managerId2 = $manager2->getId(); - $this->contractId1 = $contract1->getId(); - $this->contractId2 = $contract2->getId(); - } - - private function useCompletedContractFilter() - { - $conf = $this->_em->getConfiguration(); - $conf->addFilter("completed_contract", "\Doctrine\Tests\ORM\Functional\CompletedContractFilter"); - $this->_em->getFilters() - ->enable("completed_contract") - ->setParameter("completed", true, DBALType::BOOLEAN); - } - - public function testManyToMany_ExtraLazyCountWithFilterOnSTI() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - - $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); - - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(4, count($manager->managedContracts)); - - // Enable the filter - $this->useCompletedContractFilter(); - - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(2, count($manager->managedContracts)); - } - - public function testManyToMany_ExtraLazyContainsWithFilterOnSTI() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - - $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); - $contract1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId1); - $contract2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId2); - - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertTrue($manager->managedContracts->contains($contract1)); - $this->assertTrue($manager->managedContracts->contains($contract2)); - - // Enable the filter - $this->useCompletedContractFilter(); - - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertFalse($manager->managedContracts->contains($contract1)); - $this->assertTrue($manager->managedContracts->contains($contract2)); - } - - public function testManyToMany_ExtraLazySliceWithFilterOnSTI() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - - $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); - - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(4, count($manager->managedContracts->slice(0, 10))); - - // Enable the filter - $this->useCompletedContractFilter(); - - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(2, count($manager->managedContracts->slice(0, 10))); - } - - private function usePersonNameFilter($name) - { - // Enable the filter - $conf = $this->_em->getConfiguration(); - $conf->addFilter("person_name", "\Doctrine\Tests\ORM\Functional\CompanyPersonNameFilter"); - $this->_em->getFilters() - ->enable("person_name") - ->setParameter("name", $name, DBALType::STRING); - } - - public function testManyToMany_ExtraLazyCountWithFilterOnCTI() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - - $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); - - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(2, count($contract->managers)); - - // Enable the filter - $this->usePersonNameFilter('Benjamin'); - - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(1, count($contract->managers)); - } - - public function testManyToMany_ExtraLazyContainsWithFilterOnCTI() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - - $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); - $manager1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); - $manager2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId2); - - $this->assertFalse($contract->managers->isInitialized()); - $this->assertTrue($contract->managers->contains($manager1)); - $this->assertTrue($contract->managers->contains($manager2)); - - // Enable the filter - $this->usePersonNameFilter('Benjamin'); - - $this->assertFalse($contract->managers->isInitialized()); - $this->assertFalse($contract->managers->contains($manager1)); - $this->assertTrue($contract->managers->contains($manager2)); - } - - public function testManyToMany_ExtraLazySliceWithFilterOnCTI() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - - $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); - - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(2, count($contract->managers->slice(0, 10))); - - // Enable the filter - $this->usePersonNameFilter('Benjamin'); - - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(1, count($contract->managers->slice(0, 10))); - } - - public function testOneToMany_ExtraLazyCountWithFilterOnSTI() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - - $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); - - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(2, count($manager->soldContracts)); - - // Enable the filter - $this->useCompletedContractFilter(); - - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(1, count($manager->soldContracts)); - } - - public function testOneToMany_ExtraLazyContainsWithFilterOnSTI() - { - $this->loadCompanySingleTableInheritanceFixtureData(); - - $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); - $contract1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId1); - $contract2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId2); - - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertTrue($manager->soldContracts->contains($contract1)); - $this->assertTrue($manager->soldContracts->contains($contract2)); - - // Enable the filter - $this->useCompletedContractFilter(); - - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertFalse($manager->soldContracts->contains($contract1)); - $this->assertTrue($manager->soldContracts->contains($contract2)); - } - - public function testOneToMany_ExtraLazySliceWithFilterOnSTI() - { - - $this->loadCompanySingleTableInheritanceFixtureData(); - - $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); - - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(2, count($manager->soldContracts->slice(0, 10))); - - // Enable the filter - $this->useCompletedContractFilter(); - - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(1, count($manager->soldContracts->slice(0, 10))); - } - private function loadCompanyOrganizationEventJoinedSubclassFixtureData() - { - $organization = new CompanyOrganization; - - $event1 = new CompanyAuction; - $event1->setData('foo'); - - $event2 = new CompanyAuction; - $event2->setData('bar'); - - $organization->addEvent($event1); - $organization->addEvent($event2); - - $this->_em->persist($organization); - $this->_em->flush(); - $this->_em->clear(); - - $this->organizationId = $organization->getId(); - $this->eventId1 = $event1->getId(); - $this->eventId2 = $event2->getId(); - } - - private function useCompanyEventIdFilter() - { - // Enable the filter - $conf = $this->_em->getConfiguration(); - $conf->addFilter("event_id", "\Doctrine\Tests\ORM\Functional\CompanyEventFilter"); - $this->_em->getFilters() - ->enable("event_id") - ->setParameter("id", $this->eventId2); - } - - - public function testOneToMany_ExtraLazyCountWithFilterOnCTI() - { - $this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); - - $organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); - - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(2, count($organization->events)); - - // Enable the filter - $this->useCompanyEventIdFilter(); - - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(1, count($organization->events)); - } - - public function testOneToMany_ExtraLazyContainsWithFilterOnCTI() - { - $this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); - - $organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); - - $event1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyEvent', $this->eventId1); - $event2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyEvent', $this->eventId2); - - $this->assertFalse($organization->events->isInitialized()); - $this->assertTrue($organization->events->contains($event1)); - $this->assertTrue($organization->events->contains($event2)); - - // Enable the filter - $this->useCompanyEventIdFilter(); - - $this->assertFalse($organization->events->isInitialized()); - $this->assertFalse($organization->events->contains($event1)); - $this->assertTrue($organization->events->contains($event2)); - } - - public function testOneToMany_ExtraLazySliceWithFilterOnCTI() - { - $this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); - - $organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); - - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(2, count($organization->events->slice(0, 10))); - - // Enable the filter - $this->useCompanyEventIdFilter(); - - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(1, count($organization->events->slice(0, 10))); - } -} - -class MySoftDeleteFilter extends SQLFilter -{ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) - { - if ($targetEntity->name != "MyEntity\SoftDeleteNewsItem") { - return ""; - } - - return $targetTableAlias.'.deleted = 0'; - } -} - -class MyLocaleFilter extends SQLFilter -{ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) - { - if (!in_array("LocaleAware", $targetEntity->reflClass->getInterfaceNames())) { - return ""; - } - - return $targetTableAlias.'.locale = ' . $this->getParameter('locale'); // getParam uses connection to quote the value. - } -} - -class CMSCountryFilter extends SQLFilter -{ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) - { - if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsAddress") { - return ""; - } - - return $targetTableAlias.'.country = ' . $this->getParameter('country'); // getParam uses connection to quote the value. - } -} - -class CMSGroupPrefixFilter extends SQLFilter -{ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) - { - if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsGroup") { - return ""; - } - - return $targetTableAlias.'.name LIKE ' . $this->getParameter('prefix'); // getParam uses connection to quote the value. - } -} - -class CMSArticleTopicFilter extends SQLFilter -{ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) - { - if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsArticle") { - return ""; - } - - return $targetTableAlias.'.topic = ' . $this->getParameter('topic'); // getParam uses connection to quote the value. - } -} - -class CompanyPersonNameFilter extends SQLFilter -{ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') - { - if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyPerson") { - return ""; - } - - return $targetTableAlias.'.name LIKE ' . $this->getParameter('name'); - } -} - -class CompletedContractFilter extends SQLFilter -{ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') - { - if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyContract") { - return ""; - } - - return $targetTableAlias.'.completed = ' . $this->getParameter('completed'); - } -} - -class CompanyEventFilter extends SQLFilter -{ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') - { - if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyEvent") { - return ""; - } - - return $targetTableAlias.'.id = ' . $this->getParameter('id'); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php deleted file mode 100755 index a1e6daca5c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php +++ /dev/null @@ -1,68 +0,0 @@ -useModelSet('company'); - parent::setUp(); - } - - /** - * @group DDC-966 - * @return Schema - */ - public function testGeneratedSchema() - { - $schema = $this->_em->getConnection()->getSchemaManager()->createSchema(); - - $this->assertTrue($schema->hasTable('company_contracts')); - - return $schema; - } - - /** - * @group DDC-966 - * @depends testGeneratedSchema - */ - public function testSingleTableInheritance(Schema $schema) - { - $table = $schema->getTable('company_contracts'); - - // Check nullability constraints - $this->assertTrue($table->getColumn('id')->getNotnull()); - $this->assertTrue($table->getColumn('completed')->getNotnull()); - $this->assertFalse($table->getColumn('salesPerson_id')->getNotnull()); - $this->assertTrue($table->getColumn('discr')->getNotnull()); - $this->assertFalse($table->getColumn('fixPrice')->getNotnull()); - $this->assertFalse($table->getColumn('hoursWorked')->getNotnull()); - $this->assertFalse($table->getColumn('pricePerHour')->getNotnull()); - $this->assertFalse($table->getColumn('maxPrice')->getNotnull()); - } - - /** - * @group DBAL-115 - */ - public function testDropPartSchemaWithForeignKeys() - { - if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped("Foreign Key test"); - } - - $sql = $this->_schemaTool->getDropSchemaSQL(array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyManager'), - )); - $this->assertEquals(4, count($sql)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php deleted file mode 100755 index 5af85342bc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ /dev/null @@ -1,60 +0,0 @@ -_em->getConnection(); - - if ($conn->getDatabasePlatform()->getName() === 'sqlite') { - $this->markTestSkipped('Sqlite does not support ALTER TABLE'); - } - - $this->schemaTool = new Tools\SchemaTool($this->_em); - } - - /** - * @group DBAL-483 - */ - public function testDefaultValueIsComparedCorrectly() - { - $class = $this->_em->getClassMetadata(__NAMESPACE__ . '\\DBAL483Default'); - - $this->schemaTool->createSchema(array($class)); - - $updateSql = $this->schemaTool->getUpdateSchemaSql(array($class)); - - $updateSql = array_filter($updateSql, function ($sql) { - return strpos($sql, 'DBAL483') !== false; - }); - - $this->assertEquals(0, count($updateSql)); - } -} - -/** - * @Entity - */ -class DBAL483Default -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; - - /** - * @Column(type="integer", options={"default": 0}) - */ - public $num; - - /** - * @Column(type="string", options={"default": "foo"}) - */ - public $str = "foo"; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php deleted file mode 100755 index 22d2b1f8ee..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ /dev/null @@ -1,89 +0,0 @@ -_em->getConnection(); - - if (strpos($conn->getDriver()->getName(), "sqlite") !== false) { - $this->markTestSkipped('SQLite does not support ALTER TABLE statements.'); - } - $this->schemaTool = new Tools\SchemaTool($this->_em); - } - - /** - * @group DDC-214 - */ - public function testCmsAddressModel() - { - $this->classes = array( - 'Doctrine\Tests\Models\CMS\CmsUser', - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'Doctrine\Tests\Models\CMS\CmsAddress', - 'Doctrine\Tests\Models\CMS\CmsGroup', - 'Doctrine\Tests\Models\CMS\CmsArticle', - 'Doctrine\Tests\Models\CMS\CmsEmail', - ); - - $this->assertCreatedSchemaNeedsNoUpdates($this->classes); - } - - /** - * @group DDC-214 - */ - public function testCompanyModel() - { - $this->classes = array( - 'Doctrine\Tests\Models\Company\CompanyPerson', - 'Doctrine\Tests\Models\Company\CompanyEmployee', - 'Doctrine\Tests\Models\Company\CompanyManager', - 'Doctrine\Tests\Models\Company\CompanyOrganization', - 'Doctrine\Tests\Models\Company\CompanyEvent', - 'Doctrine\Tests\Models\Company\CompanyAuction', - 'Doctrine\Tests\Models\Company\CompanyRaffle', - 'Doctrine\Tests\Models\Company\CompanyCar' - ); - - $this->assertCreatedSchemaNeedsNoUpdates($this->classes); - } - - public function assertCreatedSchemaNeedsNoUpdates($classes) - { - $classMetadata = array(); - foreach ($classes AS $class) { - $classMetadata[] = $this->_em->getClassMetadata($class); - } - - try { - $this->schemaTool->createSchema($classMetadata); - } catch(\Exception $e) { - // was already created - } - - $sm = $this->_em->getConnection()->getSchemaManager(); - - $fromSchema = $sm->createSchema(); - $toSchema = $this->schemaTool->getSchemaFromMetadata($classMetadata); - - $comparator = new \Doctrine\DBAL\Schema\Comparator(); - $schemaDiff = $comparator->compare($fromSchema, $toSchema); - - $sql = $schemaDiff->toSql($this->_em->getConnection()->getDatabasePlatform()); - $sql = array_filter($sql, function($sql) { return strpos($sql, 'DROP') === false; }); - - $this->assertEquals(0, count($sql), "SQL: " . implode(PHP_EOL, $sql)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php deleted file mode 100755 index 4ac97c84bb..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ /dev/null @@ -1,99 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of mysql.'); - } - } - - public function testGetCreateSchemaSql() - { - $classes = array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmail'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), - ); - - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - - $this->assertEquals("CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[0]); - $this->assertEquals("CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[1]); - $this->assertEquals("CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[2]); - $this->assertEquals("CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[3]); - $this->assertEquals("CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[4]); - $this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[5]); - $this->assertEquals("ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)", $sql[6]); - $this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)", $sql[7]); - $this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id)", $sql[8]); - $this->assertEquals("ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)", $sql[9]); - $this->assertEquals("ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)", $sql[10]); - - $this->assertEquals(11, count($sql)); - } - - public function testGetCreateSchemaSql2() - { - $classes = array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\DecimalModel') - ); - - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - - $this->assertEquals(1, count($sql)); - $this->assertEquals("CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[0]); - } - - public function testGetCreateSchemaSql3() - { - $classes = array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\BooleanModel') - ); - - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - - $this->assertEquals(1, count($sql)); - $this->assertEquals("CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[0]); - } - - /** - * @group DBAL-204 - */ - public function testGetCreateSchemaSql4() - { - $classes = array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\MysqlSchemaNamespacedEntity') - ); - - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - - $this->assertEquals(0, count($sql)); - } - -} - -/** - * @Entity - * @Table("namespace.entity") - */ -class MysqlSchemaNamespacedEntity -{ - /** @Column(type="integer") @Id @GeneratedValue */ - public $id; -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php deleted file mode 100755 index 6326fc384a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ /dev/null @@ -1,198 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of postgresql.'); - } - } - - public function testPostgresMetadataSequenceIncrementedBy10() - { - $address = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - $this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); - } - - public function testGetCreateSchemaSql() - { - $classes = array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), - ); - - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - $sqlCount = count($sql); - - $this->assertEquals("CREATE TABLE cms_addresses (id INT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id))", array_shift($sql)); - $this->assertEquals("CREATE UNIQUE INDEX UNIQ_ACAC157BA76ED395 ON cms_addresses (user_id)", array_shift($sql)); - $this->assertEquals("CREATE TABLE cms_users (id INT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))", array_shift($sql)); - $this->assertEquals("CREATE UNIQUE INDEX UNIQ_3AF03EC5F85E0677 ON cms_users (username)", array_shift($sql)); - $this->assertEquals("CREATE UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 ON cms_users (email_id)", array_shift($sql)); - $this->assertEquals("CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))", array_shift($sql)); - $this->assertEquals("CREATE INDEX IDX_7EA9409AA76ED395 ON cms_users_groups (user_id)", array_shift($sql)); - $this->assertEquals("CREATE INDEX IDX_7EA9409AFE54D947 ON cms_users_groups (group_id)", array_shift($sql)); - $this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))", array_shift($sql)); - $this->assertEquals("CREATE INDEX IDX_F21F790FA76ED395 ON cms_phonenumbers (user_id)", array_shift($sql)); - $this->assertEquals("CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 1 MINVALUE 1 START 1", array_shift($sql)); - $this->assertEquals("CREATE SEQUENCE cms_users_id_seq INCREMENT BY 1 MINVALUE 1 START 1", array_shift($sql)); - $this->assertEquals("ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); - $this->assertEquals("ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); - $this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); - $this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); - $this->assertEquals("ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); - - $this->assertEquals(array(), $sql, "SQL Array should be empty now."); - $this->assertEquals(17, $sqlCount, "Total of 17 queries should be executed"); - } - - public function testGetCreateSchemaSql2() - { - $classes = array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\DecimalModel') - ); - - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - - $this->assertEquals(2, count($sql)); - - $this->assertEquals('CREATE TABLE decimal_model (id INT NOT NULL, "decimal" NUMERIC(5, 2) NOT NULL, "high_scale" NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id))', $sql[0]); - $this->assertEquals("CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[1]); - } - - public function testGetCreateSchemaSql3() - { - $classes = array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\BooleanModel') - ); - - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - - $this->assertEquals(2, count($sql)); - $this->assertEquals("CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))", $sql[0]); - $this->assertEquals("CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[1]); - } - - public function testGetDropSchemaSql() - { - $classes = array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), - ); - - $tool = new SchemaTool($this->_em); - $sql = $tool->getDropSchemaSQL($classes); - - $this->assertEquals(14, count($sql)); - $dropSequenceSQLs = 0; - foreach ($sql AS $stmt) { - if (strpos($stmt, "DROP SEQUENCE") === 0) { - $dropSequenceSQLs++; - } - } - $this->assertEquals(4, $dropSequenceSQLs, "Expect 4 sequences to be dropped."); - } - - /** - * @group DDC-1657 - */ - public function testUpdateSchemaWithPostgreSQLSchema() - { - $classes = array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Screen'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Avatar'), - ); - try { - $this->_em->getConnection()->exec("CREATE SCHEMA stonewood"); - } catch(\Exception $e) { - } - - $tool = new SchemaTool($this->_em); - $tool->createSchema($classes); - - $sql = $tool->getUpdateSchemaSql($classes); - $sql = array_filter($sql, function($sql) { return (strpos($sql, "DROP SEQUENCE stonewood.") === 0); }); - - $this->assertCount(0, $sql, implode("\n", $sql)); - } -} - -/** - * @Entity - * @Table(name="stonewood.screen") - */ -class DDC1657Screen -{ - /** - * Identifier - * @var integer - * - * @Id - * @GeneratedValue(strategy="IDENTITY") - * @Column(name="pk", type="integer", nullable=false) - */ - private $pk; - - /** - * Title - * @var string - * - * @Column(name="title", type="string", length=255, nullable=false) - */ - private $title; - - /** - * Path - * @var string - * - * @Column(name="path", type="string", length=255, nullable=false) - */ - private $path; - - /** - * Register date - * @var Date - * - * @Column(name="ddate", type="date", nullable=false) - */ - private $ddate; - - /** - * Avatar - * @var Stonewood\Model\Entity\Avatar - * - * @ManyToOne(targetEntity="DDC1657Avatar") - * @JoinColumn(name="pk_avatar", referencedColumnName="pk", nullable=true, onDelete="CASCADE") - */ - private $avatar; -} - -/** - * @Entity - * @Table(name="stonewood.avatar") - */ -class DDC1657Avatar -{ - /** - * Identifier - * @var integer - * - * @Id - * @GeneratedValue(strategy="IDENTITY") - * @Column(name="pk", type="integer", nullable=false) - */ - private $pk; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php deleted file mode 100755 index a575db0c0b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php +++ /dev/null @@ -1,50 +0,0 @@ - $classes) { - if ($modelSet == "customtype") { - continue; - } - $modelSets[] = array($modelSet); - } - return $modelSets; - } - - /** - * @dataProvider dataValidateModelSets - */ - public function testValidateModelSets($modelSet) - { - $validator = new SchemaValidator($this->_em); - - $classes = array(); - foreach (self::$_modelSets[$modelSet] as $className) { - $classes[] = $this->_em->getClassMetadata($className); - } - - foreach ($classes as $class) { - $ce = $validator->validateClass($class); - - foreach ($ce as $key => $error) { - if (strpos($error, "must be private or protected. Public fields may break lazy-loading.") !== false) { - unset($ce[$key]); - } - } - - $this->assertEquals(0, count($ce), "Invalid Modelset: " . $modelSet . " class " . $class->name . ": ". implode("\n", $ce)); - } - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php deleted file mode 100755 index 8a71cc1f11..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php +++ /dev/null @@ -1,53 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped('Only working for Databases that support sequences.'); - } - - try { - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\SequenceEntity'), - )); - } catch(\Exception $e) { - - } - } - - public function testHighAllocationSizeSequence() - { - for ($i = 0; $i < 11; $i++) { - $e = new SequenceEntity(); - $this->_em->persist($e); - } - $this->_em->flush(); - } -} - -/** - * @Entity - */ -class SequenceEntity -{ - /** - * @Id - * @column(type="integer") - * @GeneratedValue(strategy="SEQUENCE") - * @SequenceGenerator(allocationSize=5,sequenceName="person_id_seq") - */ - public $id; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php deleted file mode 100755 index 1c1dbdc58f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ /dev/null @@ -1,389 +0,0 @@ -useModelSet('company'); - parent::setUp(); - } - - public function persistRelatedEmployees() - { - $this->salesPerson = new \Doctrine\Tests\Models\Company\CompanyEmployee(); - $this->salesPerson->setName('Poor Sales Guy'); - $this->salesPerson->setDepartment('Sales'); - $this->salesPerson->setSalary(100); - - $engineer1 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); - $engineer1->setName('Roman B.'); - $engineer1->setDepartment('IT'); - $engineer1->setSalary(100); - $this->engineers[] = $engineer1; - - $engineer2 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); - $engineer2->setName('Jonathan W.'); - $engineer2->setDepartment('IT'); - $engineer2->setSalary(100); - $this->engineers[] = $engineer2; - - $engineer3 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); - $engineer3->setName('Benjamin E.'); - $engineer3->setDepartment('IT'); - $engineer3->setSalary(100); - $this->engineers[] = $engineer3; - - $engineer4 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); - $engineer4->setName('Guilherme B.'); - $engineer4->setDepartment('IT'); - $engineer4->setSalary(100); - $this->engineers[] = $engineer4; - - $this->_em->persist($this->salesPerson); - $this->_em->persist($engineer1); - $this->_em->persist($engineer2); - $this->_em->persist($engineer3); - $this->_em->persist($engineer4); - } - - public function loadFullFixture() - { - $this->persistRelatedEmployees(); - - $this->fix = new \Doctrine\Tests\Models\Company\CompanyFixContract(); - $this->fix->setFixPrice(1000); - $this->fix->setSalesPerson($this->salesPerson); - $this->fix->addEngineer($this->engineers[0]); - $this->fix->addEngineer($this->engineers[1]); - $this->fix->markCompleted(); - - $this->flex = new \Doctrine\Tests\Models\Company\CompanyFlexContract(); - $this->flex->setSalesPerson($this->salesPerson); - $this->flex->setHoursWorked(100); - $this->flex->setPricePerHour(100); - $this->flex->addEngineer($this->engineers[2]); - $this->flex->addEngineer($this->engineers[1]); - $this->flex->addEngineer($this->engineers[3]); - $this->flex->markCompleted(); - - $this->ultra = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); - $this->ultra->setSalesPerson($this->salesPerson); - $this->ultra->setHoursWorked(150); - $this->ultra->setPricePerHour(150); - $this->ultra->setMaxPrice(7000); - $this->ultra->addEngineer($this->engineers[3]); - $this->ultra->addEngineer($this->engineers[0]); - - $this->_em->persist($this->fix); - $this->_em->persist($this->flex); - $this->_em->persist($this->ultra); - $this->_em->flush(); - $this->_em->clear(); - } - - public function testPersistChildOfBaseClass() - { - $this->persistRelatedEmployees(); - - $fixContract = new \Doctrine\Tests\Models\Company\CompanyFixContract(); - $fixContract->setFixPrice(1000); - $fixContract->setSalesPerson($this->salesPerson); - - $this->_em->persist($fixContract); - $this->_em->flush(); - $this->_em->clear(); - - $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFixContract', $fixContract->getId()); - - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); - $this->assertEquals(1000, $contract->getFixPrice()); - $this->assertEquals($this->salesPerson->getId(), $contract->getSalesPerson()->getId()); - } - - public function testPersistDeepChildOfBaseClass() - { - $this->persistRelatedEmployees(); - - $ultraContract = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); - $ultraContract->setSalesPerson($this->salesPerson); - $ultraContract->setHoursWorked(100); - $ultraContract->setPricePerHour(50); - $ultraContract->setMaxPrice(7000); - - $this->_em->persist($ultraContract); - $this->_em->flush(); - $this->_em->clear(); - - $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $ultraContract->getId()); - - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $contract); - $this->assertEquals(7000, $contract->getMaxPrice()); - $this->assertEquals(100, $contract->getHoursWorked()); - $this->assertEquals(50, $contract->getPricePerHour()); - } - - public function testChildClassLifecycleUpdate() - { - $this->loadFullFixture(); - - $fix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); - $fix->setFixPrice(2500); - - $this->_em->flush(); - $this->_em->clear(); - - $newFix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); - $this->assertEquals(2500, $newFix->getFixPrice()); - } - - public function testChildClassLifecycleRemove() - { - $this->loadFullFixture(); - - $fix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); - $this->_em->remove($fix); - $this->_em->flush(); - - $this->assertNull($this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId())); - } - - public function testFindAllForAbstractBaseClass() - { - $this->loadFullFixture(); - $contracts = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyContract')->findAll(); - - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); - } - - public function testFindAllForChildClass() - { - $this->loadFullFixture(); - - $this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFixContract')->findAll())); - $this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); - $this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); - } - - public function testFindForAbstractBaseClass() - { - $this->loadFullFixture(); - - $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); - - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); - $this->assertEquals(1000, $contract->getFixPrice()); - } - - public function testQueryForAbstractBaseClass() - { - $this->loadFullFixture(); - - $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); - - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); - } - - public function testQueryForChildClass() - { - $this->loadFullFixture(); - - $this->assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c')->getResult())); - $this->assertEquals(2, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexContract c')->getResult())); - $this->assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract c')->getResult())); - } - - public function testQueryBaseClassWithJoin() - { - $this->loadFullFixture(); - - $contracts = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN c.salesPerson p')->getResult(); - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); - } - - public function testQueryScalarWithDiscrimnatorValue() - { - $this->loadFullFixture(); - - $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c ORDER BY c.id')->getScalarResult(); - - $discrValues = \array_map(function($a) { - return $a['c_discr']; - }, $contracts); - - sort($discrValues); - - $this->assertEquals(array('fix', 'flexible', 'flexultra'), $discrValues); - } - - public function testQueryChildClassWithCondition() - { - $this->loadFullFixture(); - - $dql = 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c WHERE c.fixPrice = ?1'; - $contract = $this->_em->createQuery($dql)->setParameter(1, 1000)->getSingleResult(); - - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); - $this->assertEquals(1000, $contract->getFixPrice()); - } - - public function testUpdateChildClassWithCondition() - { - $this->loadFullFixture(); - - $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyFlexContract c SET c.hoursWorked = c.hoursWorked * 2 WHERE c.hoursWorked = 150'; - $affected = $this->_em->createQuery($dql)->execute(); - - $this->assertEquals(1, $affected); - - $flexContract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->flex->getId()); - $ultraContract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->ultra->getId()); - - $this->assertEquals(300, $ultraContract->getHoursWorked()); - $this->assertEquals(100, $flexContract->getHoursWorked()); - } - - public function testUpdateBaseClassWithCondition() - { - $this->loadFullFixture(); - - $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyContract c SET c.completed = true WHERE c.completed = false'; - $affected = $this->_em->createQuery($dql)->execute(); - - $this->assertEquals(1, $affected); - - $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyContract c SET c.completed = false'; - $affected = $this->_em->createQuery($dql)->execute(); - - $this->assertEquals(3, $affected); - } - - public function testDeleteByChildClassCondition() - { - $this->loadFullFixture(); - - $dql = 'DELETE Doctrine\Tests\Models\Company\CompanyFlexContract c'; - $affected = $this->_em->createQuery($dql)->execute(); - - $this->assertEquals(2, $affected); - } - - public function testDeleteByBaseClassCondition() - { - $this->loadFullFixture(); - - $dql = "DELETE Doctrine\Tests\Models\Company\CompanyContract c WHERE c.completed = true"; - $affected = $this->_em->createQuery($dql)->execute(); - - $this->assertEquals(2, $affected); - - $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); - $this->assertEquals(1, count($contracts)); - - $this->assertFalse($contracts[0]->isCompleted(), "Only non completed contracts should be left."); - } - - /** - * @group DDC-130 - */ - public function testDeleteJoinTableRecords() - { - $this->loadFullFixture(); - - // remove managed copy of the fix contract - $this->_em->remove($this->_em->find(get_class($this->fix), $this->fix->getId())); - $this->_em->flush(); - - $this->assertNull($this->_em->find(get_class($this->fix), $this->fix->getId()), "Contract should not be present in the database anymore."); - } - - /** - * @group DDC-817 - */ - public function testFindByAssociation() - { - $this->loadFullFixture(); - - $repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyContract"); - $contracts = $repos->findBy(array('salesPerson' => $this->salesPerson->getId())); - $this->assertEquals(3, count($contracts), "There should be 3 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyContract'"); - - $repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFixContract"); - $contracts = $repos->findBy(array('salesPerson' => $this->salesPerson->getId())); - $this->assertEquals(1, count($contracts), "There should be 1 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFixContract'"); - - $repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFlexContract"); - $contracts = $repos->findBy(array('salesPerson' => $this->salesPerson->getId())); - $this->assertEquals(2, count($contracts), "There should be 2 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexContract'"); - - $repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFlexUltraContract"); - $contracts = $repos->findBy(array('salesPerson' => $this->salesPerson->getId())); - $this->assertEquals(1, count($contracts), "There should be 1 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'"); - } - - /** - * @group DDC-1637 - */ - public function testInheritanceMatching() - { - $this->loadFullFixture(); - - $repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyContract"); - $contracts = $repository->matching(new Criteria( - Criteria::expr()->eq('salesPerson', $this->salesPerson->getId()) - )); - $this->assertEquals(3, count($contracts)); - - $repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFixContract"); - $contracts = $repository->matching(new Criteria( - Criteria::expr()->eq('salesPerson', $this->salesPerson->getId()) - )); - $this->assertEquals(1, count($contracts)); - } - - /** - * @group DDC-834 - */ - public function testGetReferenceEntityWithSubclasses() - { - $this->loadFullFixture(); - - $ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "Cannot Request a proxy from a class that has subclasses."); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyContract', $ref); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $ref, "Direct fetch of the reference has to load the child class Emplyoee directly."); - $this->_em->clear(); - - $ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyFixContract', $this->fix->getId()); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "A proxy can be generated only if no subclasses exists for the requested reference."); - } - - /** - * @group DDC-952 - */ - public function testEagerLoadInheritanceHierachy() - { - $this->loadFullFixture(); - - $dql = 'SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1'; - $contract = $this->_em->createQuery($dql) - ->setFetchMode('Doctrine\Tests\Models\Company\CompanyFixContract', 'salesPerson', ClassMetadata::FETCH_EAGER) - ->setParameter(1, $this->fix->getId()) - ->getSingleResult(); - - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $contract->getSalesPerson()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php deleted file mode 100755 index de103eb079..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php +++ /dev/null @@ -1,110 +0,0 @@ - - */ -class StandardEntityPersisterTest extends \Doctrine\Tests\OrmFunctionalTestCase -{ - protected function setUp() - { - $this->useModelSet('ecommerce'); - parent::setUp(); - } - - public function testAcceptsForeignKeysAsCriteria() - { - $customer = new ECommerceCustomer(); - $customer->setName('John Doe'); - $cart = new ECommerceCart(); - $cart->setPayment('Credit card'); - $customer->setCart($cart); - $this->_em->persist($customer); - $this->_em->flush(); - $this->_em->clear(); - $cardId = $cart->getId(); - unset($cart); - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); - - $persister = $this->_em->getUnitOfWork()->getEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceCart'); - $newCart = new ECommerceCart(); - $this->_em->getUnitOfWork()->registerManaged($newCart, array('id' => $cardId), array()); - $persister->load(array('customer_id' => $customer->getId()), $newCart, $class->associationMappings['customer']); - $this->assertEquals('Credit card', $newCart->getPayment()); - } - - /** - * Ticket #2478 from Damon Jones (dljones) - */ - public function testAddPersistRetrieve() - { - $f1 = new ECommerceFeature; - $f1->setDescription('AC-3'); - - $f2 = new ECommerceFeature; - $f2->setDescription('DTS'); - - $p = new ECommerceProduct; - $p->addFeature($f1); - $p->addfeature($f2); - $this->_em->persist($p); - - $this->_em->flush(); - - $this->assertEquals(2, count($p->getFeatures())); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $p->getFeatures()); - - $q = $this->_em->createQuery( - 'SELECT p, f - FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p - JOIN p.features f' - ); - - $res = $q->getResult(); - - $this->assertEquals(2, count($p->getFeatures())); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $p->getFeatures()); - - // Check that the features are the same instances still - foreach ($p->getFeatures() as $feature) { - if ($feature->getDescription() == 'AC-3') { - $this->assertTrue($feature === $f1); - } else { - $this->assertTrue($feature === $f2); - } - } - - // Now we test how Hydrator affects IdentityMap - // (change from ArrayCollection to PersistentCollection) - $f3 = new ECommerceFeature(); - $f3->setDescription('XVID'); - $p->addFeature($f3); - - // Now we persist the Feature #3 - $this->_em->persist($p); - $this->_em->flush(); - - $q = $this->_em->createQuery( - 'SELECT p, f - FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p - JOIN p.features f' - ); - - $res = $q->getResult(); - - // Persisted Product now must have 3 Feature items - $this->assertEquals(3, count($res[0]->getFeatures())); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php deleted file mode 100755 index 93dc0eea6a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php +++ /dev/null @@ -1,81 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testReuseNamedEntityParameter() - { - $user = new CmsUser(); - $user->name = "John Galt"; - $user->username = "jgalt"; - $user->status = "inactive"; - - $article = new CmsArticle(); - $article->topic = "This is John Galt speaking!"; - $article->text = "Yadda Yadda!"; - $article->setAuthor($user); - - $this->_em->persist($user); - $this->_em->persist($article); - $this->_em->flush(); - - $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = :author"; - $this->_em->createQuery($dql) - ->setParameter('author', $user) - ->getResult(); - - $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = :author AND a.user = :author"; - $this->_em->createQuery($dql) - ->setParameter('author', $user) - ->getResult(); - - $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = :topic AND a.user = :author AND a.user = :author"; - $farticle = $this->_em->createQuery($dql) - ->setParameter('author', $user) - ->setParameter('topic', 'This is John Galt speaking!') - ->getSingleResult(); - - $this->assertSame($article, $farticle); - } - - public function testUseMultiplePositionalParameters() - { - $user = new CmsUser(); - $user->name = "John Galt"; - $user->username = "jgalt"; - $user->status = "inactive"; - - $article = new CmsArticle(); - $article->topic = "This is John Galt speaking!"; - $article->text = "Yadda Yadda!"; - $article->setAuthor($user); - - $this->_em->persist($user); - $this->_em->persist($article); - $this->_em->flush(); - - $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = ?1 AND a.user = ?2 AND a.user = ?3"; - $farticle = $this->_em->createQuery($dql) - ->setParameter(1, 'This is John Galt speaking!') - ->setParameter(2, $user) - ->setParameter(3, $user) - ->getSingleResult(); - - $this->assertSame($article, $farticle); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php deleted file mode 100755 index 5b30c043e2..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ /dev/null @@ -1,33 +0,0 @@ -useModelSet('company'); - parent::setUp(); - } - - public function testGrabWrongSubtypeReturnsNull() - { - $fix = new \Doctrine\Tests\Models\Company\CompanyFixContract(); - $fix->setFixPrice(2000); - - $this->_em->persist($fix); - $this->_em->flush(); - - $id = $fix->getId(); - - $this->assertNull($this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexContract', $id)); - $this->assertNull($this->_em->getReference('Doctrine\Tests\Models\Company\CompanyFlexContract', $id)); - $this->assertNull($this->_em->getPartialReference('Doctrine\Tests\Models\Company\CompanyFlexContract', $id)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php deleted file mode 100755 index 31bd8350fe..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php +++ /dev/null @@ -1,36 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testChangeSetPlusWeirdPHPCastingIntCastingRule() - { - $user = new \Doctrine\Tests\Models\CMS\CmsUser(); - $user->name = "John Galt"; - $user->username = "jgalt"; - $user->status = "+44"; - - $this->_em->persist($user); - $this->_em->flush(); - - $user->status = "44"; - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find("Doctrine\Tests\Models\CMS\CmsUser", $user->id); - $this->assertSame("44", $user->status); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php deleted file mode 100755 index 31c0733e09..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php +++ /dev/null @@ -1,37 +0,0 @@ -markTestSkipped('performance skipped'); - $this->useModelSet('cms'); - parent::setUp(); - } - - public function testPerformance() - { - for ($i = 2; $i < 10000; ++$i) { - $user = new \Doctrine\Tests\Models\CMS\CmsUser(); - $user->status = 'developer'; - $user->username = 'jwage'+$i; - $user->name = 'Jonathan'; - $this->_em->persist($user); - } - $this->_em->flush(); - $this->_em->clear(); - - $s = microtime(true); - $users = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); - $e = microtime(true); - echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php deleted file mode 100755 index 2b9d579a59..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ /dev/null @@ -1,317 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080Foo'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080Bar'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080FooBar'), - )); - - $foo1 = new DDC1080Foo(); - $foo1->setFooTitle('foo title 1'); - $foo2 = new DDC1080Foo(); - $foo2->setFooTitle('foo title 2'); - - $bar1 = new DDC1080Bar(); - $bar1->setBarTitle('bar title 1'); - $bar2 = new DDC1080Bar(); - $bar2->setBarTitle('bar title 2'); - $bar3 = new DDC1080Bar(); - $bar3->setBarTitle('bar title 3'); - - $foobar1 = new DDC1080FooBar(); - $foobar1->setFoo($foo1); - $foobar1->setBar($bar1); - $foobar1->setOrderNr(0); - - $foobar2 = new DDC1080FooBar(); - $foobar2->setFoo($foo1); - $foobar2->setBar($bar2); - $foobar2->setOrderNr(0); - - $foobar3 = new DDC1080FooBar(); - $foobar3->setFoo($foo1); - $foobar3->setBar($bar3); - $foobar3->setOrderNr(0); - - $this->_em->persist($foo1); - $this->_em->persist($foo2); - $this->_em->persist($bar1); - $this->_em->persist($bar2); - $this->_em->persist($bar3); - $this->_em->flush(); - - $this->_em->persist($foobar1); - $this->_em->persist($foobar2); - $this->_em->persist($foobar3); - $this->_em->flush(); - $this->_em->clear(); - - $foo = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC1080Foo', $foo1->getFooId()); - $fooBars = $foo->getFooBars(); - - $this->assertEquals(3, count($fooBars), "Should return three foobars."); - } -} - - -/** - * @Entity - * @Table(name="foo") - */ -class DDC1080Foo -{ - - /** - * @Id - * @Column(name="fooID", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - protected $_fooID; - /** - * @Column(name="fooTitle", type="string") - */ - protected $_fooTitle; - /** - * @OneToMany(targetEntity="DDC1080FooBar", mappedBy="_foo", - * cascade={"persist"}) - * @OrderBy({"_orderNr"="ASC"}) - */ - protected $_fooBars; - - public function __construct() - { - $this->_fooBars = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * @return the $fooID - */ - public function getFooID() - { - return $this->_fooID; - } - - /** - * @return the $fooTitle - */ - public function getFooTitle() - { - return $this->_fooTitle; - } - - /** - * @return the $fooBars - */ - public function getFooBars() - { - return $this->_fooBars; - } - - /** - * @param field_type $fooID - */ - public function setFooID($fooID) - { - $this->_fooID = $fooID; - } - - /** - * @param field_type $fooTitle - */ - public function setFooTitle($fooTitle) - { - $this->_fooTitle = $fooTitle; - } - - /** - * @param field_type $fooBars - */ - public function setFooBars($fooBars) - { - $this->_fooBars = $fooBars; - } - -} -/** - * @Entity - * @Table(name="bar") - */ -class DDC1080Bar -{ - - /** - * @Id - * @Column(name="barID", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - protected $_barID; - /** - * @Column(name="barTitle", type="string") - */ - protected $_barTitle; - /** - * @OneToMany(targetEntity="DDC1080FooBar", mappedBy="_bar", - * cascade={"persist"}) - * @OrderBy({"_orderNr"="ASC"}) - */ - protected $_fooBars; - - public function __construct() - { - $this->_fooBars = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * @return the $barID - */ - public function getBarID() - { - return $this->_barID; - } - - /** - * @return the $barTitle - */ - public function getBarTitle() - { - return $this->_barTitle; - } - - /** - * @return the $fooBars - */ - public function getFooBars() - { - return $this->_fooBars; - } - - /** - * @param field_type $barID - */ - public function setBarID($barID) - { - $this->_barID = $barID; - } - - /** - * @param field_type $barTitle - */ - public function setBarTitle($barTitle) - { - $this->_barTitle = $barTitle; - } - - /** - * @param field_type $fooBars - */ - public function setFooBars($fooBars) - { - $this->_fooBars = $fooBars; - } - -} - -/** - * @Table(name="fooBar") - * @Entity - */ -class DDC1080FooBar -{ - - /** - * @ManyToOne(targetEntity="DDC1080Foo") - * @JoinColumn(name="fooID", referencedColumnName="fooID") - * @Id - */ - protected $_foo = null; - /** - * @ManyToOne(targetEntity="DDC1080Bar") - * @JoinColumn(name="barID", referencedColumnName="barID") - * @Id - */ - protected $_bar = null; - /** - * @var integer orderNr - * @Column(name="orderNr", type="integer", nullable=false) - */ - protected $_orderNr = null; - - /** - * Retrieve the foo property - * - * @return DDC1080Foo - */ - public function getFoo() - { - return $this->_foo; - } - - /** - * Set the foo property - * - * @param DDC1080Foo $foo - * @return DDC1080FooBar - */ - public function setFoo($foo) - { - $this->_foo = $foo; - return $this; - } - - /** - * Retrieve the bar property - * - * @return DDC1080Bar - */ - public function getBar() - { - return $this->_bar; - } - - /** - * Set the bar property - * - * @param DDC1080Bar $bar - * @return DDC1080FooBar - */ - public function setBar($bar) - { - $this->_bar = $bar; - return $this; - } - - /** - * Retrieve the orderNr property - * - * @return integer|null - */ - public function getOrderNr() - { - return $this->_orderNr; - } - - /** - * Set the orderNr property - * - * @param integer|null $orderNr - * @return DDC1080FooBar - */ - public function setOrderNr($orderNr) - { - $this->_orderNr = $orderNr; - return $this; - } - -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php deleted file mode 100755 index 3e8a2fc0a1..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php +++ /dev/null @@ -1,99 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1113Engine'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1113Vehicle'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1113Car'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1113Bus'), - )); - } catch (\Exception $e) { - - } - } - - public function testIssue() - { - $car = new DDC1113Car(); - $car->engine = new DDC1113Engine(); - - $bus = new DDC1113Bus(); - $bus->engine = new DDC1113Engine(); - - $this->_em->persist($car); - $this->_em->flush(); - - $this->_em->persist($bus); - $this->_em->flush(); - - $this->_em->remove($bus); - $this->_em->remove($car); - $this->_em->flush(); - } - -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"car" = "DDC1113Car", "bus" = "DDC1113Bus"}) - */ -class DDC1113Vehicle -{ - - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; - - /** - * @ManyToOne(targetEntity="DDC1113Vehicle") - */ - public $parent; - - /** @OneToOne(targetEntity="DDC1113Engine", cascade={"persist", "remove"}) */ - public $engine; - -} - -/** - * @Entity - */ -class DDC1113Car extends DDC1113Vehicle -{ - -} - -/** - * @Entity - */ -class DDC1113Bus extends DDC1113Vehicle -{ - -} - -/** - * @Entity - */ -class DDC1113Engine -{ - - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; - -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php deleted file mode 100755 index c481aa395d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php +++ /dev/null @@ -1,46 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testVersionFieldIgnoredInChangesetComputation() - { - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article->text = "I don't know."; - $article->topic = "Who is John Galt?"; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->assertEquals(1, $article->version); - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'); - $uow = $this->_em->getUnitOfWork(); - - $uow->computeChangeSet($class, $article); - $changeSet = $uow->getEntityChangeSet($article); - $this->assertEquals(0, count($changeSet), "No changesets should be computed."); - - $article->text = "This is John Galt speaking."; - $this->_em->flush(); - - $this->assertEquals(2, $article->version); - - $uow->computeChangeSet($class, $article); - $changeSet = $uow->getEntityChangeSet($article); - $this->assertEquals(0, count($changeSet), "No changesets should be computed."); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php deleted file mode 100755 index fe975f69d1..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php +++ /dev/null @@ -1,56 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->getName() != 'postgresql') { - $this->markTestSkipped("This test is useful for all databases, but designed only for postgresql."); - } - - $sql = $this->_schemaTool->getCreateSchemaSql(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1151User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1151Group'), - )); - - $this->assertEquals("CREATE TABLE \"User\" (id INT NOT NULL, PRIMARY KEY(id))", $sql[0]); - $this->assertEquals("CREATE TABLE ddc1151user_ddc1151group (ddc1151user_id INT NOT NULL, ddc1151group_id INT NOT NULL, PRIMARY KEY(ddc1151user_id, ddc1151group_id))", $sql[1]); - $this->assertEquals("CREATE INDEX IDX_88A3259AC5AD08A ON ddc1151user_ddc1151group (ddc1151user_id)", $sql[2]); - $this->assertEquals("CREATE INDEX IDX_88A32597357E0B1 ON ddc1151user_ddc1151group (ddc1151group_id)", $sql[3]); - $this->assertEquals("CREATE TABLE \"Group\" (id INT NOT NULL, PRIMARY KEY(id))", $sql[4]); - $this->assertEquals("CREATE SEQUENCE \"User_id_seq\" INCREMENT BY 1 MINVALUE 1 START 1", $sql[5]); - $this->assertEquals("CREATE SEQUENCE \"Group_id_seq\" INCREMENT BY 1 MINVALUE 1 START 1", $sql[6]); - $this->assertEquals("ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A3259AC5AD08A FOREIGN KEY (ddc1151user_id) REFERENCES \"User\" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[7]); - $this->assertEquals("ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A32597357E0B1 FOREIGN KEY (ddc1151group_id) REFERENCES \"Group\" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[8]); - } -} - -/** - * @Entity - * @Table(name="`User`") - */ -class DDC1151User -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - - /** @ManyToMany(targetEntity="DDC1151Group") */ - public $groups; -} - -/** - * @Entity - * @Table(name="`Group`") - */ -class DDC1151Group -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php deleted file mode 100755 index 1e8cae6dbc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ /dev/null @@ -1,215 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1163Product'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1163SpecialProduct'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1163ProxyHolder'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1163Tag'), - )); - } - - public function testIssue() - { - $this->createSpecialProductAndProxyHolderReferencingIt(); - $this->_em->clear(); - - $this->createProxyForSpecialProduct(); - - $this->setPropertyAndAssignTagToSpecialProduct(); - - // fails - $this->_em->flush(); - } - - private function createSpecialProductAndProxyHolderReferencingIt() - { - $specialProduct = new DDC1163SpecialProduct(); - $this->_em->persist($specialProduct); - - $proxyHolder = new DDC1163ProxyHolder(); - $this->_em->persist($proxyHolder); - - $proxyHolder->setSpecialProduct($specialProduct); - - $this->_em->flush(); - - $this->productId = $specialProduct->getId(); - $this->proxyHolderId = $proxyHolder->getId(); - } - - /** - * We want Doctrine to instantiate a lazy-load proxy for the previously created - * 'SpecialProduct' and register it. - * - * When Doctrine loads the 'ProxyHolder', it will do just that because the 'ProxyHolder' - * references the 'SpecialProduct'. - */ - private function createProxyForSpecialProduct() - { - /* @var $proxyHolder ProxyHolder */ - $proxyHolder = $this->_em->find(__NAMESPACE__ . '\\DDC1163ProxyHolder', $this->proxyHolderId); - - $this->assertInstanceOf(__NAMESPACE__.'\\DDC1163SpecialProduct', $proxyHolder->getSpecialProduct()); - } - - private function setPropertyAndAssignTagToSpecialProduct() - { - /* @var $specialProduct SpecialProduct */ - $specialProduct = $this->_em->find(__NAMESPACE__ . '\\DDC1163SpecialProduct', $this->productId); - - $this->assertInstanceOf(__NAMESPACE__.'\\DDC1163SpecialProduct', $specialProduct); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $specialProduct); - - $specialProduct->setSubclassProperty('foobar'); - - // this screams violation of law of demeter ;) - $this->assertEquals( - __NAMESPACE__.'\\DDC1163SpecialProduct', - $this->_em->getUnitOfWork()->getEntityPersister(get_class($specialProduct))->getClassMetadata()->name - ); - - $tag = new DDC1163Tag('Foo'); - $this->_em->persist($tag); - $tag->setProduct($specialProduct); - } -} - -/** - * @Entity - */ -class DDC1163ProxyHolder -{ - - /** - * @var int - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - private $id; - /** - * @var SpecialProduct - * @OneToOne(targetEntity="DDC1163SpecialProduct") - */ - private $specialProduct; - - public function getId() - { - return $this->id; - } - - public function setSpecialProduct(DDC1163SpecialProduct $specialProduct) - { - $this->specialProduct = $specialProduct; - } - - public function getSpecialProduct() - { - return $this->specialProduct; - } - -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"special" = "DDC1163SpecialProduct"}) - */ -abstract class DDC1163Product -{ - - /** - * @var int - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - protected $id; - - public function getId() - { - return $this->id; - } - -} - -/** - * @Entity - */ -class DDC1163SpecialProduct extends DDC1163Product -{ - - /** - * @var string - * @Column(name="subclass_property", type="string", nullable=true) - */ - private $subclassProperty; - - /** - * @param string $value - */ - public function setSubclassProperty($value) - { - $this->subclassProperty = $value; - } - -} - -/** - * @Entity - */ -class DDC1163Tag -{ - - /** - * @var int - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - private $id; - /** - * @var string - * @Column(name="name", type="string") - */ - private $name; - /** - * @var Product - * @ManyToOne(targetEntity="DDC1163Product", inversedBy="tags") - * @JoinColumns({ - * @JoinColumn(name="product_id", referencedColumnName="id") - * }) - */ - private $product; - - /** - * @param string $name - */ - public function __construct($name) - { - $this->name = $name; - } - - /** - * @param Product $product - */ - public function setProduct(DDC1163Product $product) - { - $this->product = $product; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php deleted file mode 100755 index bf2ef0b274..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ /dev/null @@ -1,482 +0,0 @@ -useModelSet('ddc117'); - parent::setUp(); - - $this->article1 = new DDC117Article("Foo"); - $this->article2 = new DDC117Article("Bar"); - - $this->_em->persist($this->article1); - $this->_em->persist($this->article2); - $this->_em->flush(); - - $this->reference = new DDC117Reference($this->article1, $this->article2, "Test-Description"); - $this->_em->persist($this->reference); - - $this->translation = new DDC117Translation($this->article1, "en", "Bar"); - $this->_em->persist($this->translation); - - $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text"); - $this->_em->persist($this->articleDetails); - $this->_em->flush(); - - $this->_em->clear(); - } - - /** - * @group DDC-117 - */ - public function testAssociationOnlyCompositeKey() - { - $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); - - $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $mapRef); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->target()); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->source()); - $this->assertSame($mapRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); - - $this->_em->clear(); - - $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE r.source = ?1"; - $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 1)->getSingleResult(); - - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $mapRef); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->target()); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->source()); - $this->assertSame($dqlRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); - - $this->_em->clear(); - - $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1"; - $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); - - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $dqlRef); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $dqlRef->target()); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $dqlRef->source()); - $this->assertSame($dqlRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); - - $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1"; - $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); - - $this->_em->contains($dqlRef); - } - - /** - * @group DDC-117 - */ - public function testUpdateAssocationEntity() - { - $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); - - $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); - $this->assertNotNull($mapRef); - $mapRef->setDescription("New Description!!"); - $this->_em->flush(); - $this->_em->clear(); - - $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); - - $this->assertEquals('New Description!!', $mapRef->getDescription()); - } - - /** - * @group DDC-117 - */ - public function testFetchDql() - { - $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1"; - $refs = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getResult(); - - $this->assertTrue(count($refs) > 0, "Has to contain at least one Reference."); - - foreach ($refs AS $ref) { - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $ref, "Contains only Reference instances."); - $this->assertTrue($this->_em->contains($ref), "Contains Reference in the IdentityMap."); - } - } - - /** - * @group DDC-117 - */ - public function testRemoveCompositeElement() - { - $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); - - $refRep = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); - - $this->_em->remove($refRep); - $this->_em->flush(); - $this->_em->clear(); - - $this->assertNull($this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); - } - - /** - * @group DDC-117 - */ - public function testDqlRemoveCompositeElement() - { - $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); - - $dql = "DELETE "."Doctrine\Tests\Models\DDC117\DDC117Reference r WHERE r.source = ?1 AND r.target = ?2"; - $this->_em->createQuery($dql) - ->setParameter(1, $this->article1->id()) - ->setParameter(2, $this->article2->id()) - ->execute(); - - $this->assertNull($this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); - } - - /** - * @group DDC-117 - */ - public function testInverseSideAccess() - { - $this->article1 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article1->id()); - - $this->assertEquals(1, count($this->article1->references())); - - foreach ($this->article1->references() AS $this->reference) { - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $this->reference); - $this->assertSame($this->article1, $this->reference->source()); - } - - $this->_em->clear(); - - $dql = 'SELECT a, r FROM '. 'Doctrine\Tests\Models\DDC117\DDC117Article a INNER JOIN a.references r WHERE a.id = ?1'; - $articleDql = $this->_em->createQuery($dql) - ->setParameter(1, $this->article1->id()) - ->getSingleResult(); - - $this->assertEquals(1, count($this->article1->references())); - - foreach ($this->article1->references() AS $this->reference) { - $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $this->reference); - $this->assertSame($this->article1, $this->reference->source()); - } - } - - /** - * @group DDC-117 - */ - public function testMixedCompositeKey() - { - $idCriteria = array('article' => $this->article1->id(), 'language' => 'en'); - - $this->translation = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria); - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $this->translation); - - $this->assertSame($this->translation, $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria)); - - $this->_em->clear(); - - $dql = 'SELECT t, a FROM ' . 'Doctrine\Tests\Models\DDC117\DDC117Translation t JOIN t.article a WHERE t.article = ?1 AND t.language = ?2'; - $dqlTrans = $this->_em->createQuery($dql) - ->setParameter(1, $this->article1->id()) - ->setParameter(2, 'en') - ->getSingleResult(); - - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $this->translation); - } - - /** - * @group DDC-117 - */ - public function testMixedCompositeKeyViolateUniqueness() - { - $this->article1 = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Article', $this->article1->id()); - $this->article1->addTranslation('en', 'Bar'); - $this->article1->addTranslation('en', 'Baz'); - - $exceptionThrown = false; - try { - // exception depending on the underyling Database Driver - $this->_em->flush(); - } catch(\Exception $e) { - $exceptionThrown = true; - } - - $this->assertTrue($exceptionThrown, "The underlying database driver throws an exception."); - } - - /** - * @group DDC-117 - */ - public function testOneToOneForeignObjectId() - { - $this->article1 = new DDC117Article("Foo"); - $this->_em->persist($this->article1); - $this->_em->flush(); - - $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text"); - $this->_em->persist($this->articleDetails); - $this->_em->flush(); - - $this->articleDetails->update("not so very long text!"); - $this->_em->flush(); - $this->_em->clear(); - - /* @var $article DDC117Article */ - $article = $this->_em->find(get_class($this->article1), $this->article1->id()); - $this->assertEquals('not so very long text!', $article->getText()); - } - - /** - * @group DDC-117 - */ - public function testOneToOneCascadeRemove() - { - $article = $this->_em->find(get_class($this->article1), $this->article1->id()); - $this->_em->remove($article); - $this->_em->flush(); - - $this->assertFalse($this->_em->contains($article->getDetails())); - } - - /** - * @group DDC-117 - */ - public function testOneToOneCascadePersist() - { - if (!$this->_em->getConnection()->getDatabasePlatform()->prefersSequences()) { - $this->markTestSkipped('Test only works with databases that prefer sequences as ID strategy.'); - } - - $this->article1 = new DDC117Article("Foo"); - - $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text"); - - $this->_em->persist($this->article1); - $this->_em->flush(); - } - - /** - * @group DDC-117 - */ - public function testReferencesToForeignKeyEntities() - { - $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); - $reference = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); - - $idCriteria = array('article' => $this->article1->id(), 'language' => 'en'); - $translation = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria); - - $approveChanges = new DDC117ApproveChanges($reference->source()->getDetails(), $reference, $translation); - $this->_em->persist($approveChanges); - $this->_em->flush(); - $this->_em->clear(); - - $approveChanges = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117ApproveChanges", $approveChanges->getId()); - - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', $approveChanges->getArticleDetails()); - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Reference', $approveChanges->getReference()); - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $approveChanges->getTranslation()); - } - - /** - * @group DDC-117 - */ - public function testLoadOneToManyCollectionOfForeignKeyEntities() - { - /* @var $article DDC117Article */ - $article = $this->_em->find(get_class($this->article1), $this->article1->id()); - - $translations = $article->getTranslations(); - $this->assertFalse($translations->isInitialized()); - $this->assertContainsOnly('Doctrine\Tests\Models\DDC117\DDC117Translation', $translations); - $this->assertTrue($translations->isInitialized()); - } - - /** - * @group DDC-117 - */ - public function testLoadManyToManyCollectionOfForeignKeyEntities() - { - $editor = $this->loadEditorFixture(); - - $this->assertFalse($editor->reviewingTranslations->isInitialized()); - $this->assertContainsOnly("Doctrine\Tests\Models\DDC117\DDC117Translation", $editor->reviewingTranslations); - $this->assertTrue($editor->reviewingTranslations->isInitialized()); - - $this->_em->clear(); - - $dql = "SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE e.id = ?1"; - $editor = $this->_em->createQuery($dql)->setParameter(1, $editor->id)->getSingleResult(); - $this->assertTrue($editor->reviewingTranslations->isInitialized()); - $this->assertContainsOnly("Doctrine\Tests\Models\DDC117\DDC117Translation", $editor->reviewingTranslations); - } - - /** - * @group DDC-117 - */ - public function testClearManyToManyCollectionOfForeignKeyEntities() - { - $editor = $this->loadEditorFixture(); - $this->assertEquals(3, count($editor->reviewingTranslations)); - - $editor->reviewingTranslations->clear(); - $this->_em->flush(); - $this->_em->clear(); - - $editor = $this->_em->find(get_class($editor), $editor->id); - $this->assertEquals(0, count($editor->reviewingTranslations)); - } - - /** - * @group DDC-117 - */ - public function testLoadInverseManyToManyCollection() - { - $editor = $this->loadEditorFixture(); - - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $editor->reviewingTranslations[0]); - - $reviewedBy = $editor->reviewingTranslations[0]->getReviewedByEditors(); - $this->assertEquals(1, count($reviewedBy)); - $this->assertSame($editor, $reviewedBy[0]); - - $this->_em->clear(); - - $dql = "SELECT t, e FROM Doctrine\Tests\Models\DDC117\DDC117Translation t ". - "JOIN t.reviewedByEditors e WHERE t.article = ?1 AND t.language = ?2"; - $trans = $this->_em->createQuery($dql) - ->setParameter(1, $this->translation->getArticleId()) - ->setParameter(2, $this->translation->getLanguage()) - ->getSingleResult(); - - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $trans); - $this->assertContainsOnly('Doctrine\Tests\Models\DDC117\DDC117Editor', $trans->reviewedByEditors); - $this->assertEquals(1, count($trans->reviewedByEditors)); - } - - /** - * @group DDC-117 - */ - public function testLoadOneToManyOfSourceEntityWithAssociationIdentifier() - { - $editor = $this->loadEditorFixture(); - - $editor->addLastTranslation($editor->reviewingTranslations[0]); - $this->_em->flush(); - $this->_em->clear(); - - $editor = $this->_em->find(get_class($editor), $editor->id); - $lastTranslatedBy = $editor->reviewingTranslations[0]->getLastTranslatedBy(); - $lastTranslatedBy->count(); - - $this->assertEquals(1, count($lastTranslatedBy)); - } - - /** - * @return DDC117Editor - */ - private function loadEditorFixture() - { - $editor = new DDC117Editor("beberlei"); - - /* @var $article1 DDC117Article */ - $article1 = $this->_em->find(get_class($this->article1), $this->article1->id()); - foreach ($article1->getTranslations() AS $translation) { - $editor->reviewingTranslations[] = $translation; - } - - /* @var $article2 DDC117Article */ - $article2 = $this->_em->find(get_class($this->article2), $this->article2->id()); - $article2->addTranslation("de", "Vanille-Krapferl"); // omnomnom - $article2->addTranslation("fr", "Sorry can't speak french!"); - - foreach ($article2->getTranslations() AS $translation) { - $this->_em->persist($translation); // otherwise persisting the editor won't work, reachability! - $editor->reviewingTranslations[] = $translation; - } - - $this->_em->persist($editor); - $this->_em->flush(); - $this->_em->clear(); - - return $this->_em->find(get_class($editor), $editor->id); - } - - /** - * @group DDC-1519 - */ - public function testMergeForeignKeyIdentifierEntity() - { - $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); - - $refRep = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); - - $this->_em->detach($refRep); - $refRep = $this->_em->merge($refRep); - - $this->assertEquals($this->article1->id(), $refRep->source()->id()); - $this->assertEquals($this->article2->id(), $refRep->target()->id()); - } - - /** - * @group DDC-1652 - */ - public function testArrayHydrationWithCompositeKey() - { - $dql = "SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t"; - $before = count($this->_em->createQuery($dql)->getResult()); - - $this->article1 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article1->id()); - $this->article2 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article2->id()); - - $this->reference = new DDC117Reference($this->article2, $this->article1, "Test-Description"); - $this->_em->persist($this->reference); - - $this->reference = new DDC117Reference($this->article1, $this->article1, "Test-Description"); - $this->_em->persist($this->reference); - - $this->reference = new DDC117Reference($this->article2, $this->article2, "Test-Description"); - $this->_em->persist($this->reference); - - $this->_em->flush(); - - $dql = "SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t"; - $data = $this->_em->createQuery($dql)->getArrayResult(); - - $this->assertEquals($before + 3, count($data)); - } - - /** - * @group DDC-2246 - */ - public function testGetEntityState() - { - $this->article1 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article1->id()); - $this->article2 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article2->id()); - - $this->reference = new DDC117Reference($this->article2, $this->article1, "Test-Description"); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($this->reference)); - - $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); - $reference = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($reference)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php deleted file mode 100755 index 32856ace16..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php +++ /dev/null @@ -1,101 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1181Hotel'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1181Booking'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1181Room'), - )); - } - - /** - * @group DDC-1181 - */ - public function testIssue() - { - $hotel = new DDC1181Hotel(); - $room1 = new DDC1181Room(); - $room2 = new DDC1181Room(); - - $this->_em->persist($hotel); - $this->_em->persist($room1); - $this->_em->persist($room2); - $this->_em->flush(); - - $booking1 = new DDC1181Booking; - $booking1->hotel = $hotel; - $booking1->room = $room1; - $booking2 = new DDC1181Booking; - $booking2->hotel = $hotel; - $booking2->room = $room2; - $hotel->bookings[] = $booking1; - $hotel->bookings[] = $booking2; - - $this->_em->persist($booking1); - $this->_em->persist($booking2); - $this->_em->flush(); - - $this->_em->remove($hotel); - $this->_em->flush(); - } -} - -/** - * @Entity - */ -class DDC1181Hotel -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - - /** - * @oneToMany(targetEntity="DDC1181Booking", mappedBy="hotel", cascade={"remove"}) - * @var Booking[] - */ - public $bookings; - -} - -/** - * @Entity - */ -class DDC1181Booking -{ - /** - * @var Hotel - * - * @Id - * @ManyToOne(targetEntity="DDC1181Hotel", inversedBy="bookings") - * @JoinColumns({ - * @JoinColumn(name="hotel_id", referencedColumnName="id") - * }) - */ - public $hotel; - /** - * @var Room - * - * @Id - * @ManyToOne(targetEntity="DDC1181Room") - * @JoinColumns({ - * @JoinColumn(name="room_id", referencedColumnName="id") - * }) - */ - public $room; -} - -/** - * @Entity - */ -class DDC1181Room -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php deleted file mode 100755 index 6465fa6758..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ /dev/null @@ -1,93 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Company'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Person'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Account') - )); - } - - /** - * @group DDC-1193 - */ - public function testIssue() - { - $company = new DDC1193Company(); - $person = new DDC1193Person(); - $account = new DDC1193Account(); - - $person->account = $account; - $person->company = $company; - - $company->member = $person; - - $this->_em->persist($company); - - $this->_em->flush(); - - $companyId = $company->id; - $accountId = $account->id; - $this->_em->clear(); - - $company = $this->_em->find(get_class($company), $companyId); - - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), "Company is in identity map."); - $this->assertFalse($company->member->__isInitialized__, "Pre-Condition"); - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), "Member is in identity map."); - - $this->_em->remove($company); - $this->_em->flush(); - - $this->assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0); - } -} - -/** @Entity */ -class DDC1193Company { - /** - * @Id @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** @OneToOne(targetEntity="DDC1193Person", cascade={"persist", "remove"}) */ - public $member; - -} - -/** @Entity */ -class DDC1193Person { - /** - * @Id @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** - * @OneToOne(targetEntity="DDC1193Account", cascade={"persist", "remove"}) - */ - public $account; -} - -/** @Entity */ -class DDC1193Account { - /** - * @Id @Column(type="integer") - * @GeneratedValue - */ - public $id; - -} - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php deleted file mode 100755 index bddbbdf440..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php +++ /dev/null @@ -1,125 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_1'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_2'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_3') - )); - } catch(\Exception $e) { - } - } - - /** - * @group DDC-1209 - */ - public function testIdentifierCanHaveCustomType() - { - $this->_em->persist(new DDC1209_3()); - $this->_em->flush(); - } - - /** - * @group DDC-1209 - */ - public function testCompositeIdentifierCanHaveCustomType() - { - $future1 = new DDC1209_1(); - $this->_em->persist($future1); - - $this->_em->flush(); - - $future2 = new DDC1209_2($future1); - $this->_em->persist($future2); - - $this->_em->flush(); - } -} - -/** - * @Entity - */ -class DDC1209_1 -{ - /** - * @Id @GeneratedValue @Column(type="integer") - */ - private $id; - - public function getId() - { - return $this->id; - } -} - -/** - * @Entity - */ -class DDC1209_2 -{ - /** - * @Id - * @ManyToOne(targetEntity="DDC1209_1") - * @JoinColumn(referencedColumnName="id", nullable=false) - */ - private $future1; - /** - * @Id - * @Column(type="datetime", nullable=false) - */ - private $starting_datetime; - /** - * @Id - * @Column(type="datetime", nullable=false) - */ - private $during_datetime; - /** - * @Id - * @Column(type="datetime", nullable=false) - */ - private $ending_datetime; - - public function __construct(DDC1209_1 $future1) - { - $this->future1 = $future1; - $this->starting_datetime = new DateTime2(); - $this->during_datetime = new DateTime2(); - $this->ending_datetime = new DateTime2(); - } -} - -/** - * @Entity - */ -class DDC1209_3 -{ - /** - * @Id - * @Column(type="datetime", name="somedate") - */ - private $date; - - public function __construct() - { - $this->date = new DateTime2(); - } -} - -class DateTime2 extends \DateTime -{ - public function __toString() - { - return $this->format('Y'); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php deleted file mode 100755 index 95dcc2b65f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ /dev/null @@ -1,85 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity1'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity2'), - )); - } catch(\PDOException $e) { - - } - } - - public function testIssue() - { - $qb = $this->_em->createQueryBuilder(); - $qb->from('Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity1', 'te1') - ->select('te1') - ->where('te1.testEntity2 = ?1') - ->setParameter(1, 0); - - $this->assertEquals( - strtolower('SELECT t0_.test_entity2_id AS test_entity2_id0 FROM te1 t0_ WHERE t0_.test_entity2_id = ?'), - strtolower($qb->getQuery()->getSQL()) - ); - } -} - -/** - * @Entity - * @Table(name="te1") - */ -class DDC1225_TestEntity1 -{ - /** - * @Id - * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity2") - * @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false) - */ - private $testEntity2; - - /** - * @param DDC1225_TestEntity2 $testEntity2 - */ - public function setTestEntity2(DDC1225_TestEntity2 $testEntity2) - { - $this->testEntity2 = $testEntity2; - } - - /** - * @return DDC1225_TestEntity2 - */ - public function getTestEntity2() - { - return $this->testEntity2; - } -} - -/** - * @Entity - * @Table(name="te2") - */ -class DDC1225_TestEntity2 -{ - /** - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - */ - private $id; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php deleted file mode 100755 index 6e14e2111e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php +++ /dev/null @@ -1,136 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1228User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1228Profile'), - )); - } catch(\Exception $e) { - - } - } - - public function testOneToOnePersist() - { - $user = new DDC1228User; - $profile = new DDC1228Profile(); - $profile->name = "Foo"; - $user->profile = $profile; - - $this->_em->persist($user); - $this->_em->persist($profile); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id); - - $this->assertFalse($user->getProfile()->__isInitialized__, "Proxy is not initialized"); - $user->getProfile()->setName("Bar"); - $this->assertTrue($user->getProfile()->__isInitialized__, "Proxy is not initialized"); - - $this->assertEquals("Bar", $user->getProfile()->getName()); - $this->assertEquals(array("id" => 1, "name" => "Foo"), $this->_em->getUnitOfWork()->getOriginalEntityData($user->getProfile())); - - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id); - $this->assertEquals("Bar", $user->getProfile()->getName()); - } - - public function testRefresh() - { - $user = new DDC1228User; - $profile = new DDC1228Profile(); - $profile->name = "Foo"; - $user->profile = $profile; - - $this->_em->persist($user); - $this->_em->persist($profile); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1228User', $user->id); - - $this->_em->refresh($user); - $user->name = "Baz"; - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id); - $this->assertEquals("Baz", $user->name); - } -} - -/** - * @Entity - */ -class DDC1228User -{ - /** - * @Id @Column(type="integer") @GeneratedValue - * @var int - */ - public $id; - - /** - * @Column(type="string") - * @var string - */ - public $name = 'Bar'; - - /** - * @OneToOne(targetEntity="DDC1228Profile") - * @var Profile - */ - public $profile; - - public function getProfile() - { - return $this->profile; - } -} - -/** - * @Entity - */ -class DDC1228Profile -{ - /** - * @Id @Column(type="integer") @GeneratedValue - * @var int - */ - public $id; - - /** - * @column(type="string") - * @var string - */ - public $name; - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php deleted file mode 100755 index 6783928efc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ /dev/null @@ -1,100 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1238User'), - )); - } catch(\Exception $e) { - - } - } - - public function testIssue() - { - $user = new DDC1238User; - $user->setName("test"); - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $userId = $user->getId(); - $this->_em->clear(); - - $user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId); - $this->_em->clear(); - - $userId2 = $user->getId(); - $this->assertEquals($userId, $userId2, "This proxy can still be initialized."); - } - - public function testIssueProxyClear() - { - $user = new DDC1238User; - $user->setName("test"); - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - // force proxy load, getId() doesn't work anymore - $user->getName(); - $userId = $user->getId(); - $this->_em->clear(); - - $user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId); - $this->_em->clear(); - - $user2 = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId); - - // force proxy load, getId() doesn't work anymore - $user->getName(); - $this->assertNull($user->getId(), "Now this is null, we already have a user instance of that type"); - } -} - -/** - * @Entity - */ -class DDC1238User -{ - /** @Id @GeneratedValue @Column(type="integer") */ - private $id; - - /** - * @Column - * @var string - */ - private $name; - - public function getId() - { - return $this->id; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php deleted file mode 100755 index 3a756da9a2..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ /dev/null @@ -1,96 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1250ClientHistory'), - )); - } catch(\PDOException $e) { - - } - } - - public function testIssue() - { - $c1 = new DDC1250ClientHistory; - $c2 = new DDC1250ClientHistory; - $c1->declinedClientsHistory = $c2; - $c1->declinedBy = $c2; - $c2->declinedBy = $c1; - $c2->declinedClientsHistory= $c1; - - $this->_em->persist($c1); - $this->_em->persist($c2); - $this->_em->flush(); - $this->_em->clear(); - - $history = $this->_em->createQuery('SELECT h FROM ' . __NAMESPACE__ . '\\DDC1250ClientHistory h WHERE h.id = ?1') - ->setParameter(1, $c2->id)->getSingleResult(); - - $this->assertInstanceOf(__NAMESPACE__ . '\\DDC1250ClientHistory', $history); - } -} - -/** - * @Entity - */ -class DDC1250ClientHistory -{ - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; - - /** @OneToOne(targetEntity="DDC1250ClientHistory", inversedBy="declinedBy") - * @JoinColumn(name="declined_clients_history_id", referencedColumnName="id") - */ - public $declinedClientsHistory; - - /** - * @OneToOne(targetEntity="DDC1250ClientHistory", mappedBy="declinedClientsHistory") - * @var - */ - public $declinedBy; -} - -/** - * -Entities\ClientsHistory: -type: entity -table: clients_history -fields: -id: -id: true -type: integer -unsigned: false -nullable: false -generator: -strategy: IDENTITY -[...skiped...] -oneToOne: -declinedClientsHistory: -targetEntity: Entities\ClientsHistory -joinColumn: -name: declined_clients_history_id -referencedColumnName: id -inversedBy: declinedBy -declinedBy: -targetEntity: Entities\ClientsHistory -mappedBy: declinedClientsHistory -lifecycleCallbacks: { } -repositoryClass: Entities\ClientsHistoryRepository - - - */ \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php deleted file mode 100755 index a4f54b55f0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php +++ /dev/null @@ -1,50 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testIssue() - { - $user = new CmsUser(); - $user->name = "Benjamin"; - $user->username = "beberlei"; - $user->status = "active"; - $this->_em->persist($user); - - for ($i = 0; $i < 2; $i++) { - $group = new CmsGroup(); - $group->name = "group".$i; - $user->groups[] = $group; - $this->_em->persist($group); - } - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id); - $cloned = clone $user; - - $this->assertSame($user->groups, $cloned->groups); - $this->assertEquals(2, count($user->groups)); - $this->_em->merge($cloned); - - $this->assertEquals(2, count($user->groups)); - - $this->_em->flush(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php deleted file mode 100755 index 38278dc1cd..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php +++ /dev/null @@ -1,108 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300Foo'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300FooLocale'), - )); - } - - public function testIssue() - { - $foo = new DDC1300Foo(); - $foo->_fooReference = "foo"; - - $this->_em->persist($foo); - $this->_em->flush(); - - $locale = new DDC1300FooLocale(); - $locale->_foo = $foo; - $locale->_locale = "en"; - $locale->_title = "blub"; - - $this->_em->persist($locale); - $this->_em->flush(); - - $query = $this->_em->createQuery('SELECT f, fl FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1300Foo f JOIN f._fooLocaleRefFoo fl'); - $result = $query->getResult(); - - $this->assertEquals(1, count($result)); - } -} - -/** - * @Entity - */ -class DDC1300Foo -{ - /** - * @var integer fooID - * @Column(name="fooID", type="integer", nullable=false) - * @GeneratedValue(strategy="AUTO") - * @Id - */ - public $_fooID = null; - - /** - * @var string fooReference - * @Column(name="fooReference", type="string", nullable=true, length=45) - */ - public $_fooReference = null; - - /** - * @OneToMany(targetEntity="DDC1300FooLocale", mappedBy="_foo", - * cascade={"persist"}) - */ - public $_fooLocaleRefFoo = null; - - /** - * Constructor - * - * @param array|Zend_Config|null $options - * @return Bug_Model_Foo - */ - public function __construct($options = null) - { - $this->_fooLocaleRefFoo = new \Doctrine\Common\Collections\ArrayCollection(); - } - -} - -/** - * @Entity - */ -class DDC1300FooLocale -{ - - /** - * @ManyToOne(targetEntity="DDC1300Foo") - * @JoinColumn(name="fooID", referencedColumnName="fooID") - * @Id - */ - public $_foo = null; - - /** - * @var string locale - * @Column(name="locale", type="string", nullable=false, length=5) - * @Id - */ - public $_locale = null; - - /** - * @var string title - * @Column(name="title", type="string", nullable=true, length=150) - */ - public $_title = null; - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php deleted file mode 100755 index 94d02f905a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php +++ /dev/null @@ -1,148 +0,0 @@ -useModelSet('legacy'); - parent::setUp(); - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\Legacy\LegacyUser'); - $class->associationMappings['_articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; - $class->associationMappings['_references']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; - $class->associationMappings['_cars']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; - - $this->loadFixture(); - } - - public function tearDown() - { - parent::tearDown(); - - $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\Legacy\LegacyUser'); - $class->associationMappings['_articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY; - $class->associationMappings['_references']['fetch'] = ClassMetadataInfo::FETCH_LAZY; - $class->associationMappings['_cars']['fetch'] = ClassMetadataInfo::FETCH_LAZY; - } - - public function testCountNotInitializesLegacyCollection() - { - $user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId); - $queryCount = $this->getCurrentQueryCount(); - - $this->assertFalse($user->_articles->isInitialized()); - $this->assertEquals(2, count($user->_articles)); - $this->assertFalse($user->_articles->isInitialized()); - - foreach ($user->_articles AS $article) { } - - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); - } - - public function testCountNotInitializesLegacyCollectionWithForeignIdentifier() - { - $user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId); - $queryCount = $this->getCurrentQueryCount(); - - $this->assertFalse($user->_references->isInitialized()); - $this->assertEquals(2, count($user->_references)); - $this->assertFalse($user->_references->isInitialized()); - - foreach ($user->_references AS $reference) { } - - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); - } - - public function testCountNotInitializesLegacyManyToManyCollection() - { - $user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId); - $queryCount = $this->getCurrentQueryCount(); - - $this->assertFalse($user->_cars->isInitialized()); - $this->assertEquals(3, count($user->_cars)); - $this->assertFalse($user->_cars->isInitialized()); - - foreach ($user->_cars AS $reference) { } - - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); - } - - public function loadFixture() - { - $user1 = new \Doctrine\Tests\Models\Legacy\LegacyUser(); - $user1->_username = "beberlei"; - $user1->_name = "Benjamin"; - $user1->_status = "active"; - - $user2 = new \Doctrine\Tests\Models\Legacy\LegacyUser(); - $user2->_username = "jwage"; - $user2->_name = "Jonathan"; - $user2->_status = "active"; - - $user3 = new \Doctrine\Tests\Models\Legacy\LegacyUser(); - $user3->_username = "romanb"; - $user3->_name = "Roman"; - $user3->_status = "active"; - - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->persist($user3); - - $article1 = new \Doctrine\Tests\Models\Legacy\LegacyArticle(); - $article1->_topic = "Test"; - $article1->_text = "Test"; - $article1->setAuthor($user1); - - $article2 = new \Doctrine\Tests\Models\Legacy\LegacyArticle(); - $article2->_topic = "Test"; - $article2->_text = "Test"; - $article2->setAuthor($user1); - - $this->_em->persist($article1); - $this->_em->persist($article2); - - $car1 = new \Doctrine\Tests\Models\Legacy\LegacyCar(); - $car1->_description = "Test1"; - - $car2 = new \Doctrine\Tests\Models\Legacy\LegacyCar(); - $car2->_description = "Test2"; - - $car3 = new \Doctrine\Tests\Models\Legacy\LegacyCar(); - $car3->_description = "Test3"; - - $user1->addCar($car1); - $user1->addCar($car2); - $user1->addCar($car3); - - $user2->addCar($car1); - $user3->addCar($car1); - - $this->_em->persist($car1); - $this->_em->persist($car2); - $this->_em->persist($car3); - - $this->_em->flush(); - - $detail1 = new \Doctrine\Tests\Models\Legacy\LegacyUserReference($user1, $user2, "foo"); - $detail2 = new \Doctrine\Tests\Models\Legacy\LegacyUserReference($user1, $user3, "bar"); - - $this->_em->persist($detail1); - $this->_em->persist($detail2); - - $this->_em->flush(); - $this->_em->clear(); - - $this->userId = $user1->getId(); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php deleted file mode 100755 index b143b00300..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php +++ /dev/null @@ -1,54 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testIssue() - { - $phone = new CmsPhonenumber(); - $phone->phonenumber = "1234"; - - // puts user and phone into commit order calculator - $this->_em->persist($phone); - $this->_em->flush(); - - $address = new \Doctrine\Tests\Models\CMS\CmsAddress(); - $address->city = "bonn"; - $address->country = "Germany"; - $address->street = "somestreet!"; - $address->zip = 12345; - - $this->_em->persist($address); - - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "benjamin"; - $user->status = "active"; - $user->setAddress($address); - - // puts user and address into commit order calculator, but does not calculate user dependencies new - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->remove($user->getAddress()); - $this->_em->remove($user); - $this->_em->flush(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php deleted file mode 100755 index 0500a0e007..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ /dev/null @@ -1,218 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1335User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1335Phone'), - )); - $this->loadFixture(); - } catch(\Exception $e) { - } - } - - - public function testDql() - { - $dql = 'SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id'; - $query = $this->_em->createQuery($dql); - $result = $query->getResult(); - - $this->assertEquals(sizeof($result), 3); - $this->assertArrayHasKey(1, $result); - $this->assertArrayHasKey(2, $result); - $this->assertArrayHasKey(3, $result); - - $dql = 'SELECT u, p FROM '.__NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id'; - $query = $this->_em->createQuery($dql); - $result = $query->getResult(); - - $this->assertEquals(sizeof($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); - - $this->assertEquals(sizeof($result['foo@foo.com']->phones), 3); - $this->assertEquals(sizeof($result['bar@bar.com']->phones), 3); - $this->assertEquals(sizeof($result['foobar@foobar.com']->phones), 3); - - $foo = $result['foo@foo.com']->phones->toArray(); - $bar = $result['bar@bar.com']->phones->toArray(); - $foobar = $result['foobar@foobar.com']->phones->toArray(); - - $this->assertArrayHasKey(1, $foo); - $this->assertArrayHasKey(2, $foo); - $this->assertArrayHasKey(3, $foo); - - $this->assertArrayHasKey(4, $bar); - $this->assertArrayHasKey(5, $bar); - $this->assertArrayHasKey(6, $bar); - - $this->assertArrayHasKey(7, $foobar); - $this->assertArrayHasKey(8, $foobar); - $this->assertArrayHasKey(9, $foobar); - } - - public function testTicket() - { - $builder = $this->_em->createQueryBuilder(); - $builder->select('u')->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.id'); - - $dql = $builder->getQuery()->getDQL(); - $result = $builder->getQuery()->getResult(); - - $this->assertEquals(sizeof($result), 3); - $this->assertArrayHasKey(1, $result); - $this->assertArrayHasKey(2, $result); - $this->assertArrayHasKey(3, $result); - $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id', $dql); - } - - public function testIndexByUnique() - { - $builder = $this->_em->createQueryBuilder(); - $builder->select('u')->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.email'); - - $dql = $builder->getQuery()->getDQL(); - $result = $builder->getQuery()->getResult(); - - $this->assertEquals(sizeof($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); - $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email', $dql); - } - - public function testIndexWithJoin() - { - $builder = $this->_em->createQueryBuilder(); - $builder->select('u','p') - ->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.email') - ->join('u.phones', 'p', null, null, 'p.id'); - - $dql = $builder->getQuery()->getDQL(); - $result = $builder->getQuery()->getResult(); - - $this->assertEquals(sizeof($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); - - $this->assertEquals(sizeof($result['foo@foo.com']->phones), 3); - $this->assertEquals(sizeof($result['bar@bar.com']->phones), 3); - $this->assertEquals(sizeof($result['foobar@foobar.com']->phones), 3); - - $this->assertArrayHasKey(1, $result['foo@foo.com']->phones->toArray()); - $this->assertArrayHasKey(2, $result['foo@foo.com']->phones->toArray()); - $this->assertArrayHasKey(3, $result['foo@foo.com']->phones->toArray()); - - $this->assertArrayHasKey(4, $result['bar@bar.com']->phones->toArray()); - $this->assertArrayHasKey(5, $result['bar@bar.com']->phones->toArray()); - $this->assertArrayHasKey(6, $result['bar@bar.com']->phones->toArray()); - - $this->assertArrayHasKey(7, $result['foobar@foobar.com']->phones->toArray()); - $this->assertArrayHasKey(8, $result['foobar@foobar.com']->phones->toArray()); - $this->assertArrayHasKey(9, $result['foobar@foobar.com']->phones->toArray()); - - $this->assertEquals('SELECT u, p FROM '.__NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id', $dql); - } - - private function loadFixture() - { - $p1 = array('11 xxxx-xxxx','11 yyyy-yyyy','11 zzzz-zzzz'); - $p2 = array('22 xxxx-xxxx','22 yyyy-yyyy','22 zzzz-zzzz'); - $p3 = array('33 xxxx-xxxx','33 yyyy-yyyy','33 zzzz-zzzz'); - - $u1 = new DDC1335User("foo@foo.com", "Foo",$p1); - $u2 = new DDC1335User("bar@bar.com", "Bar",$p2); - $u3 = new DDC1335User("foobar@foobar.com", "Foo Bar",$p3); - - $this->_em->persist($u1); - $this->_em->persist($u2); - $this->_em->persist($u3); - $this->_em->flush(); - $this->_em->clear(); - } - -} - -/** - * @Entity - */ -class DDC1335User -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** - * @Column(type="string", unique=true) - */ - public $email; - - /** - * @Column(type="string") - */ - public $name; - - /** - * @OneToMany(targetEntity="DDC1335Phone", mappedBy="user", cascade={"persist", "remove"}) - */ - public $phones; - - public function __construct($email, $name, array $numbers = array()) - { - $this->name = $name; - $this->email = $email; - $this->phones = new \Doctrine\Common\Collections\ArrayCollection(); - - foreach ($numbers as $number) { - $this->phones->add(new DDC1335Phone($this,$number)); - } - } -} - -/** - * @Entity - */ -class DDC1335Phone -{ - /** - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue - */ - public $id; - - /** - * @Column(name="numericalValue", type="string", nullable = false) - */ - public $numericalValue; - - /** - * @ManyToOne(targetEntity="DDC1335User", inversedBy="phones") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable = false) - */ - public $user; - - public function __construct($user, $number) - { - $this->user = $user; - $this->numericalValue = $number; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php deleted file mode 100755 index 38f5837e59..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php +++ /dev/null @@ -1,37 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->getName() != "postgresql") { - $this->markTestSkipped("PostgreSQL only test."); - } - - $sql = $this->_schemaTool->getCreateSchemaSQL(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1360DoubleQuote') - )); - - $this->assertEquals(array( - 'CREATE TABLE "user"."user" (id INT NOT NULL, PRIMARY KEY(id))', - 'CREATE SEQUENCE "user"."user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', - ), $sql); - } -} - -/** - * @Entity @Table(name="`user`.`user`") - */ -class DDC1360DoubleQuote -{ - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php deleted file mode 100755 index f6b5a24600..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php +++ /dev/null @@ -1,99 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1383AbstractEntity'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1383Entity'), - )); - } catch(\Exception $ignored) {} - } - - public function testFailingCase() - { - $parent = new DDC1383Entity(); - $child = new DDC1383Entity(); - - $child->setReference($parent); - - $this->_em->persist($parent); - $this->_em->persist($child); - - $id = $child->getId(); - - $this->_em->flush(); - $this->_em->clear(); - - // Try merging the parent entity - $child = $this->_em->merge($child); - $parent = $child->getReference(); - - // Parent is not instance of the abstract class - self::assertTrue($parent instanceof DDC1383AbstractEntity, - "Entity class is " . get_class($parent) . ', "DDC1383AbstractEntity" was expected'); - - // Parent is NOT instance of entity - self::assertTrue($parent instanceof DDC1383Entity, - "Entity class is " . get_class($parent) . ', "DDC1383Entity" was expected'); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="integer") - * @DiscriminatorMap({1 = "DDC1383Entity"}) - */ -abstract class DDC1383AbstractEntity -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - protected $id; - - public function getId() - { - return $this->id; - } - - public function setId($id) - { - $this->id = $id; - } -} - -/** - * @Entity - */ -class DDC1383Entity extends DDC1383AbstractEntity -{ - /** - * @ManyToOne(targetEntity="DDC1383AbstractEntity") - */ - protected $reference; - - public function getReference() - { - return $this->reference; - } - - public function setReference(DDC1383AbstractEntity $reference) - { - $this->reference = $reference; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php deleted file mode 100755 index 095b1976c2..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php +++ /dev/null @@ -1,127 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1392File'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1392Picture'), - )); - } catch (\Exception $ignored) { - } - } - - public function testFailingCase() - { - $file = new DDC1392File; - - $picture = new DDC1392Picture; - $picture->setFile($file); - - $em = $this->_em; - $em->persist($picture); - $em->flush(); - $em->clear(); - - $fileId = $file->getFileId(); - $pictureId = $picture->getPictureId(); - - $this->assertTrue($fileId > 0); - - $picture = $em->find(__NAMESPACE__ . '\DDC1392Picture', $pictureId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), "Lazy Proxy should be marked MANAGED."); - - $file = $picture->getFile(); - - // With this activated there will be no problem - //$file->__load(); - - $picture->setFile(null); - - $em->clear(); - - $em->merge($file); - - $em->flush(); - - $q = $this->_em->createQuery("SELECT COUNT(e) FROM " . __NAMESPACE__ . '\DDC1392File e'); - $result = $q->getSingleScalarResult(); - - self::assertEquals(1, $result); - } -} - -/** - * @Entity - */ -class DDC1392Picture -{ - /** - * @Column(name="picture_id", type="integer") - * @Id @GeneratedValue - */ - private $pictureId; - - /** - * @ManyToOne(targetEntity="DDC1392File", cascade={"persist", "remove"}) - * @JoinColumn(name="file_id", referencedColumnName="file_id") - */ - private $file; - - /** - * Get pictureId - */ - public function getPictureId() - { - return $this->pictureId; - } - - /** - * Set file - */ - public function setFile($value = null) - { - $this->file = $value; - } - - /** - * Get file - */ - public function getFile() - { - return $this->file; - } -} - -/** - * @Entity - */ -class DDC1392File -{ - /** - * @Column(name="file_id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - public $fileId; - - /** - * Get fileId - */ - public function getFileId() - { - return $this->fileId; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php deleted file mode 100755 index 2523b5b729..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php +++ /dev/null @@ -1,131 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1400Article'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1400User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1400UserState'), - )); - } catch (\Exception $ignored) { - } - } - - public function testFailingCase() - { - $article = new DDC1400Article; - $user1 = new DDC1400User; - $user2 = new DDC1400User; - - $this->_em->persist($article); - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->flush(); - - $userState1 = new DDC1400UserState; - $userState1->article = $article; - $userState1->articleId = $article->id; - $userState1->user = $user1; - $userState1->userId = $user1->id; - - $userState2 = new DDC1400UserState; - $userState2->article = $article; - $userState2->articleId = $article->id; - $userState2->user = $user2; - $userState2->userId = $user2->id; - - $this->_em->persist($userState1); - $this->_em->persist($userState2); - - $this->_em->flush(); - $this->_em->clear(); - - $user1 = $this->_em->getReference(__NAMESPACE__.'\DDC1400User', $user1->id); - - $q = $this->_em->createQuery("SELECT a, s FROM ".__NAMESPACE__."\DDC1400Article a JOIN a.userStates s WITH s.user = :activeUser"); - $q->setParameter('activeUser', $user1); - $articles = $q->getResult(); - - $this->_em->flush(); - } -} - -/** - * @Entity - */ -class DDC1400Article -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** - * @OneToMany(targetEntity="DDC1400UserState", mappedBy="article", indexBy="userId", fetch="EXTRA_LAZY") - */ - public $userStates; -} - -/** - * @Entity - */ -class DDC1400User -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** - * @OneToMany(targetEntity="DDC1400UserState", mappedBy="user", indexBy="articleId", fetch="EXTRA_LAZY") - */ - public $userStates; -} - -/** - * @Entity - */ -class DDC1400UserState -{ - - /** - * @Id - * @ManyToOne(targetEntity="DDC1400Article", inversedBy="userStates") - */ - public $article; - - /** - * @Id - * @ManyToOne(targetEntity="DDC1400User", inversedBy="userStates") - */ - public $user; - - /** - * @Column(name="user_id", type="integer") - */ - public $userId; - - /** - * @Column(name="article_id", type="integer") - */ - public $articleId; - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php deleted file mode 100755 index cc1d7c9eeb..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php +++ /dev/null @@ -1,129 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1404ParentEntity'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1404ChildEntity'), - )); - - $this->loadFixtures(); - - } catch (Exception $exc) { - } - } - - public function testTicket() - { - $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC1404ChildEntity'); - $queryAll = $repository->createNamedQuery('all'); - $queryFirst = $repository->createNamedQuery('first'); - $querySecond = $repository->createNamedQuery('second'); - - - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p', $queryAll->getDQL()); - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 1', $queryFirst->getDQL()); - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 2', $querySecond->getDQL()); - - - $this->assertEquals(sizeof($queryAll->getResult()), 2); - $this->assertEquals(sizeof($queryFirst->getResult()), 1); - $this->assertEquals(sizeof($querySecond->getResult()), 1); - } - - - public function loadFixtures() - { - $c1 = new DDC1404ChildEntity("ChildEntity 1"); - $c2 = new DDC1404ChildEntity("ChildEntity 2"); - - $this->_em->persist($c1); - $this->_em->persist($c2); - - $this->_em->flush(); - } - -} - -/** - * @MappedSuperclass - * - * @NamedQueries({ - * @NamedQuery(name="all", query="SELECT p FROM __CLASS__ p"), - * @NamedQuery(name="first", query="SELECT p FROM __CLASS__ p WHERE p.id = 1"), - * }) - */ -class DDC1404ParentEntity -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue() - */ - protected $id; - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - -} - -/** - * @Entity - * - * @NamedQueries({ - * @NamedQuery(name="first", query="SELECT p FROM __CLASS__ p WHERE p.id = 1"), - * @NamedQuery(name="second", query="SELECT p FROM __CLASS__ p WHERE p.id = 2") - * }) - */ -class DDC1404ChildEntity extends DDC1404ParentEntity -{ - - /** - * @column(type="string") - */ - private $name; - - /** - * @param string $name - */ - public function __construct($name) - { - $this->name = $name; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php deleted file mode 100755 index 6965c6e3bf..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php +++ /dev/null @@ -1,89 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\User'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Group'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Phone'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Address'), - )); - } catch(\Exception $e) { - } - } - - public function testCreateRetreaveUpdateDelete() - { - - $user = new User; - $user->name = 'FabioBatSilva'; - $this->_em->persist($user); - - $address = new Address; - $address->zip = '12345'; - $this->_em->persist($address); - - $this->_em->flush(); - - $addressRef = $this->_em->getReference('Doctrine\Tests\Models\Quote\Address', $address->getId()); - - $user->setAddress($addressRef); - - $this->_em->flush(); - $this->_em->clear(); - - $id = $user->id; - $this->assertNotNull($id); - - - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $id); - $address = $user->getAddress(); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Address', $user->getAddress()); - - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals('12345', $address->zip); - - - $user->name = 'FabioBatSilva1'; - $user->address = null; - - $this->_em->persist($user); - $this->_em->remove($address); - $this->_em->flush(); - $this->_em->clear(); - - - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $id); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertNull($user->getAddress()); - - $this->assertEquals('FabioBatSilva1', $user->name); - - - $this->_em->remove($user); - $this->_em->flush(); - $this->_em->clear(); - - $this->assertNull($this->_em->find('Doctrine\Tests\Models\Quote\User', $id)); - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php deleted file mode 100755 index a8102239d0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ /dev/null @@ -1,297 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1430Order'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1430OrderProduct'), - )); - $this->loadFixtures(); - } catch (\Exception $exc) { - - } - } - - public function testOrderByFields() - { - $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC1430Order'); - $builder = $repository->createQueryBuilder('o'); - $query = $builder->select('o.id, o.date, COUNT(p.id) AS p_count') - ->leftJoin('o.products', 'p') - ->groupBy('o.id, o.date') - ->orderBy('o.id') - ->getQuery(); - - $this->assertEquals('SELECT o.id, o.date, COUNT(p.id) AS p_count FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1430Order o LEFT JOIN o.products p GROUP BY o.id, o.date ORDER BY o.id ASC', $query->getDQL()); - $this->assertEquals('SELECT d0_.order_id AS order_id0, d0_.created_at AS created_at1, COUNT(d1_.id) AS sclr2 FROM DDC1430Order d0_ LEFT JOIN DDC1430OrderProduct d1_ ON d0_.order_id = d1_.order_id GROUP BY d0_.order_id, d0_.created_at ORDER BY d0_.order_id ASC', $query->getSQL()); - - - $result = $query->getResult(); - - $this->assertEquals(2, sizeof($result)); - - $this->assertArrayHasKey('id', $result[0]); - $this->assertArrayHasKey('id', $result[1]); - - $this->assertArrayHasKey('p_count', $result[0]); - $this->assertArrayHasKey('p_count', $result[1]); - - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals(2, $result[1]['id']); - - $this->assertEquals(2, $result[0]['p_count']); - $this->assertEquals(3, $result[1]['p_count']); - } - - public function testOrderByAllObjectFields() - { - $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC1430Order'); - $builder = $repository->createQueryBuilder('o'); - $query = $builder->select('o, COUNT(p.id) AS p_count') - ->leftJoin('o.products', 'p') - ->groupBy('o.id, o.date, o.status') - ->orderBy('o.id') - ->getQuery(); - - - $this->assertEquals('SELECT o, COUNT(p.id) AS p_count FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1430Order o LEFT JOIN o.products p GROUP BY o.id, o.date, o.status ORDER BY o.id ASC', $query->getDQL()); - $this->assertEquals('SELECT d0_.order_id AS order_id0, d0_.created_at AS created_at1, d0_.order_status AS order_status2, COUNT(d1_.id) AS sclr3 FROM DDC1430Order d0_ LEFT JOIN DDC1430OrderProduct d1_ ON d0_.order_id = d1_.order_id GROUP BY d0_.order_id, d0_.created_at, d0_.order_status ORDER BY d0_.order_id ASC', $query->getSQL()); - - $result = $query->getResult(); - - - $this->assertEquals(2, sizeof($result)); - - $this->assertTrue($result[0][0] instanceof DDC1430Order); - $this->assertTrue($result[1][0] instanceof DDC1430Order); - - $this->assertEquals($result[0][0]->getId(), 1); - $this->assertEquals($result[1][0]->getId(), 2); - - $this->assertEquals($result[0]['p_count'], 2); - $this->assertEquals($result[1]['p_count'], 3); - } - - public function testTicket() - { - $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC1430Order'); - $builder = $repository->createQueryBuilder('o'); - $query = $builder->select('o, COUNT(p.id) AS p_count') - ->leftJoin('o.products', 'p') - ->groupBy('o') - ->orderBy('o.id') - ->getQuery(); - - - $this->assertEquals('SELECT o, COUNT(p.id) AS p_count FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1430Order o LEFT JOIN o.products p GROUP BY o ORDER BY o.id ASC', $query->getDQL()); - $this->assertEquals('SELECT d0_.order_id AS order_id0, d0_.created_at AS created_at1, d0_.order_status AS order_status2, COUNT(d1_.id) AS sclr3 FROM DDC1430Order d0_ LEFT JOIN DDC1430OrderProduct d1_ ON d0_.order_id = d1_.order_id GROUP BY d0_.order_id, d0_.created_at, d0_.order_status ORDER BY d0_.order_id ASC', $query->getSQL()); - - - $result = $query->getResult(); - - $this->assertEquals(2, sizeof($result)); - - $this->assertTrue($result[0][0] instanceof DDC1430Order); - $this->assertTrue($result[1][0] instanceof DDC1430Order); - - $this->assertEquals($result[0][0]->getId(), 1); - $this->assertEquals($result[1][0]->getId(), 2); - - $this->assertEquals($result[0]['p_count'], 2); - $this->assertEquals($result[1]['p_count'], 3); - } - - public function loadFixtures() - { - $o1 = new DDC1430Order('NEW'); - $o2 = new DDC1430Order('OK'); - - $o1->addProduct(new DDC1430OrderProduct(1.1)); - $o1->addProduct(new DDC1430OrderProduct(1.2)); - - $o2->addProduct(new DDC1430OrderProduct(2.1)); - $o2->addProduct(new DDC1430OrderProduct(2.2)); - $o2->addProduct(new DDC1430OrderProduct(2.3)); - - $this->_em->persist($o1); - $this->_em->persist($o2); - - $this->_em->flush(); - } - -} - -/** - * @Entity - */ -class DDC1430Order -{ - - /** - * @Id - * @Column(name="order_id", type="integer") - * @GeneratedValue() - */ - protected $id; - - /** - * @Column(name="created_at", type="datetime") - */ - private $date; - - /** - * @Column(name="order_status", type="string") - */ - private $status; - - /** - * @OneToMany(targetEntity="DDC1430OrderProduct", mappedBy="order", cascade={"persist", "remove"}) - * - * @var \Doctrine\Common\Collections\ArrayCollection $products - */ - private $products; - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - - public function __construct($status) - { - $this->status = $status; - $this->date = new \DateTime(); - $this->products = new \Doctrine\Common\Collections\ArrayCollection(); - } - /** - * @return \DateTime - */ - public function getDate() - { - return $this->date; - } - - /** - * @return string - */ - public function getStatus() - { - return $this->status; - } - - /** - * @param string $status - */ - public function setStatus($status) - { - $this->status = $status; - } - - /** - * @return \Doctrine\Common\Collections\ArrayCollection - */ - public function getProducts() - { - return $this->products; - } - - /** - * @param DDC1430OrderProduct $product - */ - public function addProduct(DDC1430OrderProduct $product) - { - $product->setOrder($this); - $this->products->add($product); - } -} - -/** - * @Entity - */ -class DDC1430OrderProduct -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue() - */ - protected $id; - - /** - * @var DDC1430Order $order - * - * @ManyToOne(targetEntity="DDC1430Order", inversedBy="products") - * @JoinColumn(name="order_id", referencedColumnName="order_id", nullable = false) - */ - private $order; - - /** - * @column(type="float") - */ - private $value; - - /** - * @param float $value - */ - public function __construct($value) - { - $this->value = $value; - } - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * @return DDC1430Order - */ - public function getOrder() - { - return $this->order; - } - - /** - * @param DDC1430Order $order - */ - public function setOrder(DDC1430Order $order) - { - $this->order = $order; - } - - /** - * @return float - */ - public function getValue() - { - return $this->value; - } - - /** - * @param float $value - */ - public function setValue($value) - { - $this->value = $value; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php deleted file mode 100755 index 906290ce3f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ /dev/null @@ -1,89 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1436Page'), - )); - } catch (\Exception $ignored) { - } - } - - public function testIdentityMap() - { - // fixtures - $parent = null; - for ($i = 0; $i < 3; $i++) { - $page = new DDC1436Page(); - $page->setParent($parent); - $this->_em->persist($page); - $parent = $page; - } - $this->_em->flush(); - $this->_em->clear(); - - $id = $parent->getId(); - - // step 1 - $page = $this->_em - ->createQuery('SELECT p, parent FROM ' . __NAMESPACE__ . '\DDC1436Page p LEFT JOIN p.parent parent WHERE p.id = :id') - ->setParameter('id', $id) - ->getOneOrNullResult(); - - $this->assertInstanceOf(__NAMESPACE__ . '\DDC1436Page', $page); - - // step 2 - $page = $this->_em->find(__NAMESPACE__ . '\DDC1436Page', $id); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC1436Page', $page); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC1436Page', $page->getParent()); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC1436Page', $page->getParent()->getParent()); - } -} - -/** - * @Entity - */ -class DDC1436Page -{ - /** - * @Id - * @GeneratedValue - * @Column(type="integer", name="id") - */ - protected $id; - /** - * @ManyToOne(targetEntity="DDC1436Page") - * @JoinColumn(name="pid", referencedColumnName="id") - */ - protected $parent; - - public function getId() - { - return $this->id; - } - - /** - * @return DDC1436Page - */ - public function getParent() - { - return $this->parent; - } - - public function setParent($parent) - { - $this->parent = $parent; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php deleted file mode 100755 index dd6391a740..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php +++ /dev/null @@ -1,64 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC144FlowElement'), - // $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC144Expression'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC144Operand'), - )); - - } - - /** - * @group DDC-144 - */ - public function testIssue() - { - - $operand = new DDC144Operand; - $operand->property = 'flowValue'; - $operand->operandProperty = 'operandValue'; - $this->_em->persist($operand); - $this->_em->flush(); - - } -} - -/** - * @Entity - * @Table(name="ddc144_flowelements") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(type="string", name="discr") - * @DiscriminatorMap({"flowelement" = "DDC144FlowElement", "operand" = "DDC144Operand"}) - */ -class DDC144FlowElement { - /** - * @Id @Column(type="integer") @GeneratedValue - * @var integer - */ - public $id; - /** @Column */ - public $property; -} - -abstract class DDC144Expression extends DDC144FlowElement { - abstract function method(); -} - -/** @Entity @Table(name="ddc144_operands") */ -class DDC144Operand extends DDC144Expression { - /** @Column */ - public $operandProperty; - function method() {} -} - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php deleted file mode 100755 index aef2d10a96..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ /dev/null @@ -1,127 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - - try { - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1452EntityA'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1452EntityB'), - )); - } catch (\Exception $ignored) { - } - } - - public function testIssue() - { - $a1 = new DDC1452EntityA(); - $a1->title = "foo"; - - $a2 = new DDC1452EntityA(); - $a2->title = "bar"; - - $b = new DDC1452EntityB(); - $b->entityAFrom = $a1; - $b->entityATo = $a2; - - $this->_em->persist($a1); - $this->_em->persist($a2); - $this->_em->persist($b); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT a, b, ba FROM " . __NAMESPACE__ . "\DDC1452EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba"; - $results = $this->_em->createQuery($dql)->setMaxResults(1)->getResult(); - - $this->assertSame($results[0], $results[0]->entitiesB[0]->entityAFrom); - $this->assertFalse( $results[0]->entitiesB[0]->entityATo instanceof \Doctrine\ORM\Proxy\Proxy ); - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results[0]->entitiesB[0]->entityATo->getEntitiesB()); - } - - public function testFetchJoinOneToOneFromInverse() - { - $address = new \Doctrine\Tests\Models\CMS\CmsAddress(); - $address->city = "Bonn"; - $address->country = "Germany"; - $address->street = "Somestreet"; - $address->zip = 12345; - - $user = new \Doctrine\Tests\Models\CMS\CmsUser(); - $user->name = "beberlei"; - $user->username = "beberlei"; - $user->status = "active"; - $user->address = $address; - $address->user = $user; - - $this->_em->persist($address); - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT a, u FROM Doctrine\Tests\Models\CMS\CmsAddress a INNER JOIN a.user u"; - $data = $this->_em->createQuery($dql)->getResult(); - $this->_em->clear(); - - $this->assertFalse($data[0]->user instanceof \Doctrine\ORM\Proxy\Proxy); - - $dql = "SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.address a"; - $data = $this->_em->createQuery($dql)->getResult(); - - $this->assertFalse($data[0]->address instanceof \Doctrine\ORM\Proxy\Proxy); - } -} - -/** - * @Entity - */ -class DDC1452EntityA -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @Column */ - public $title; - /** @ManyToMany(targetEntity="DDC1452EntityB", mappedBy="entityAFrom") */ - public $entitiesB; - - public function __construct() - { - $this->entitiesB = new ArrayCollection(); - } - - public function getEntitiesB() - { - return $this->entitiesB; - } -} - -/** - * @Entity - */ -class DDC1452EntityB -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - - /** - * @ManyToOne(targetEntity="DDC1452EntityA", inversedBy="entitiesB") - */ - public $entityAFrom; - /** - * @ManyToOne(targetEntity="DDC1452EntityA") - */ - public $entityATo; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php deleted file mode 100755 index eaf9dd3f9f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ /dev/null @@ -1,69 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1454File'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1454Picture'), - )); - } catch (\Exception $ignored) { - - } - } - - public function testFailingCase() - { - $pic = new DDC1454Picture(); - $this->_em->getUnitOfWork()->getEntityState($pic); - } - -} - -/** - * @Entity - */ -class DDC1454Picture extends DDC1454File -{ - -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"picture" = "DDC1454Picture"}) - */ -class DDC1454File -{ - /** - * @Column(name="file_id", type="integer") - * @Id - */ - public $fileId; - - public function __construct() { - $this->fileId = rand(); - } - - /** - * Get fileId - */ - public function getFileId() { - return $this->fileId; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php deleted file mode 100755 index 745b51c28f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php +++ /dev/null @@ -1,131 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\TestEntity'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\TestAdditionalEntity') - )); - } - - public function testIssue() - { - $testEntity = new TestEntity(); - $testEntity->setValue(3); - $testEntity->setAdditional(new TestAdditionalEntity()); - $this->_em->persist($testEntity); - $this->_em->flush(); - $this->_em->clear(); - - // So here the value is 3 - $this->assertEquals(3, $testEntity->getValue()); - - $test = $this->_em->getRepository(__NAMESPACE__ . '\TestEntity')->find(1); - - // New value is set - $test->setValue(5); - - // So here the value is 5 - $this->assertEquals(5, $test->getValue()); - - // Get the additional entity - $additional = $test->getAdditional(); - - // Still 5.. - $this->assertEquals(5, $test->getValue()); - - // Force the proxy to load - $additional->getBool(); - - // The value should still be 5 - $this->assertEquals(5, $test->getValue()); - } -} - - -/** - * @Entity - */ -class TestEntity -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - protected $id; - /** - * @Column(type="integer") - */ - protected $value; - /** - * @OneToOne(targetEntity="TestAdditionalEntity", inversedBy="entity", orphanRemoval=true, cascade={"persist", "remove"}) - */ - protected $additional; - - public function getValue() - { - return $this->value; - } - - public function setValue($value) - { - $this->value = $value; - } - - public function getAdditional() - { - return $this->additional; - } - - public function setAdditional($additional) - { - $this->additional = $additional; - } -} -/** - * @Entity - */ -class TestAdditionalEntity -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - protected $id; - /** - * @OneToOne(targetEntity="TestEntity", mappedBy="additional") - */ - protected $entity; - /** - * @Column(type="boolean") - */ - protected $bool; - - public function __construct() - { - $this->bool = false; - } - - public function getBool() - { - return $this->bool; - } - - public function setBool($bool) - { - $this->bool = $bool; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php deleted file mode 100755 index e6aa2e6bc3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ /dev/null @@ -1,86 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1461TwitterAccount'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1461User') - )); - } catch(\Exception $e) { - - } - } - - public function testChangeDetectionDeferredExplicit() - { - $user = new DDC1461User; - $this->_em->persist($user); - $this->_em->flush(); - - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user, \Doctrine\ORM\UnitOfWork::STATE_NEW), "Entity should be managed."); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), "Entity should be managed."); - - $acc = new DDC1461TwitterAccount; - $user->twitterAccount = $acc; - - $this->_em->persist($user); - $this->_em->flush(); - - $user = $this->_em->find(get_class($user), $user->id); - $this->assertNotNull($user->twitterAccount); - } -} - -/** - * @Entity - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ -class DDC1461User -{ - /** - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - */ - public $id; - - /** - * @OneToOne(targetEntity="DDC1461TwitterAccount", orphanRemoval=true, fetch="EAGER", cascade = {"persist"}, inversedBy="user") - * @var TwitterAccount - */ - public $twitterAccount; -} - -/** - * @Entity - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ -class DDC1461TwitterAccount -{ - /** - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - */ - public $id; - - /** - * @OneToOne(targetEntity="DDC1461User", fetch="EAGER") - */ - public $user; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php deleted file mode 100755 index 6ba0cd42f4..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php +++ /dev/null @@ -1,146 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1509AbstractFile'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1509File'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1509Picture'), - )); - } catch (\Exception $ignored) { - - } - } - - public function testFailingCase() - { - $file = new DDC1509File; - $thumbnail = new DDC1509File; - - $picture = new DDC1509Picture; - $picture->setFile($file); - $picture->setThumbnail($thumbnail); - - - /* @var $em \Doctrine\ORM\EntityManager */ - $em = $this->_em; - $em->persist($picture); - $em->flush(); - $em->clear(); - - $id = $picture->getPictureId(); - - $pic = $em->merge($picture); - /* @var $pic DDC1509Picture */ - - $this->assertNotNull($pic->getThumbnail()); - $this->assertNotNull($pic->getFile()); - } - -} - -/** - * @Entity - */ -class DDC1509Picture -{ - - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @ManyToOne(targetEntity="DDC1509AbstractFile", cascade={"persist", "remove"}) - */ - private $thumbnail; - - /** - * @ManyToOne(targetEntity="DDC1509AbstractFile", cascade={"persist", "remove"}) - */ - private $file; - - /** - * Get pictureId - */ - public function getPictureId() - { - return $this->id; - } - - /** - * Set file - */ - public function setFile($value = null) - { - $this->file = $value; - } - - /** - * Get file - */ - public function getFile() - { - return $this->file; - } - - public function getThumbnail() - { - return $this->thumbnail; - } - - public function setThumbnail($thumbnail) - { - $this->thumbnail = $thumbnail; - } - -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"file" = "DDC1509File"}) - */ -class DDC1509AbstractFile -{ - - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * Get fileId - */ - public function getFileId() - { - return $this->id; - } - -} - -/** - * @Entity - */ -class DDC1509File extends DDC1509AbstractFile -{ - -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php deleted file mode 100755 index cc0f9728db..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ /dev/null @@ -1,111 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1514EntityA'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1514EntityB'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1514EntityC'), - )); - } catch (\Exception $ignored) { - } - } - - public function testIssue() - { - $a1 = new DDC1514EntityA(); - $a1->title = "foo"; - - $a2 = new DDC1514EntityA(); - $a2->title = "bar"; - - $b1 = new DDC1514EntityB(); - $b1->entityAFrom = $a1; - $b1->entityATo = $a2; - - $b2 = new DDC1514EntityB(); - $b2->entityAFrom = $a2; - $b2->entityATo = $a1; - - $c = new DDC1514EntityC(); - $c->title = "baz"; - $a2->entityC = $c; - - $this->_em->persist($a1); - $this->_em->persist($a2); - $this->_em->persist($b1); - $this->_em->persist($b2); - $this->_em->persist($c); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT a, b, ba, c FROM " . __NAMESPACE__ . "\DDC1514EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba LEFT JOIN a.entityC AS c"; - $results = $this->_em->createQuery($dql)->getResult(); - - $this->assertEquals($c->title, $results[1]->entityC->title); - } -} - -/** - * @Entity - */ -class DDC1514EntityA -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @Column */ - public $title; - /** @ManyToMany(targetEntity="DDC1514EntityB", mappedBy="entityAFrom") */ - public $entitiesB; - /** @ManyToOne(targetEntity="DDC1514EntityC") */ - public $entityC; - - public function __construct() - { - $this->entitiesB = new ArrayCollection(); - } -} - -/** - * @Entity - */ -class DDC1514EntityB -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - - /** - * @ManyToOne(targetEntity="DDC1514EntityA", inversedBy="entitiesB") - */ - public $entityAFrom; - /** - * @ManyToOne(targetEntity="DDC1514EntityA") - */ - public $entityATo; -} - -/** - * @Entity - */ -class DDC1514EntityC -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @Column */ - public $title; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php deleted file mode 100755 index 9bd3360b89..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php +++ /dev/null @@ -1,64 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1515Foo'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1515Bar'), - )); - } - - public function testIssue() - { - $bar = new DDC1515Bar(); - $this->_em->persist($bar); - $this->_em->flush(); - - $foo = new DDC1515Foo(); - $foo->bar = $bar; - $this->_em->persist($foo); - $this->_em->flush(); - $this->_em->clear(); - - $bar = $this->_em->find(__NAMESPACE__ . '\DDC1515Bar', $bar->id); - $this->assertInstanceOf(__NAMESPACE__.'\DDC1515Foo', $bar->foo); - } -} - -/** - * @Entity - */ -class DDC1515Foo -{ - /** - * @OneToOne(targetEntity="DDC1515Bar", inversedBy="foo") @Id - */ - public $bar; -} - -/** - * @Entity - */ -class DDC1515Bar -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; - - /** - * @OneToOne(targetEntity="DDC1515Foo", mappedBy="bar") - */ - public $foo; -} - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php deleted file mode 100755 index 27d0a87ba5..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php +++ /dev/null @@ -1,67 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1526Menu'), - )); - } - - public function testIssue() - { - $parents = array(); - for ($i = 0; $i < 9; $i++) { - $entity = new DDC1526Menu; - - if (isset ($parents[($i % 3)])) { - $entity->parent = $parents[($i%3)]; - } - - $this->_em->persist($entity); - $parents[$i] = $entity; - } - $this->_em->flush(); - $this->_em->clear(); - - - $dql = "SELECT m, c - FROM " . __NAMESPACE__ . "\DDC1526Menu m - LEFT JOIN m.children c"; - $menus = $this->_em->createQuery($dql)->getResult(); - - // All Children collection now have to be initiailzed - foreach ($menus as $menu) { - $this->assertTrue($menu->children->isInitialized()); - } - } -} - -/** - * @Entity - */ -class DDC1526Menu -{ - /** - * @Column(type="integer") - * @Id - * @GeneratedValue - */ - public $id; - /** - * @ManyToOne(targetEntity="DDC1526Menu", inversedBy="children") - */ - public $parent; - - /** - * @OneToMany(targetEntity="DDC1526Menu", mappedBy="parent") - */ - public $children; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php deleted file mode 100755 index 6af9cc5472..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php +++ /dev/null @@ -1,201 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - private function initDb($link) - { - $article = new CmsArticle(); - $article->topic = 'foo'; - $article->text = 'foo'; - - $user = new CmsUser(); - $user->status = 'foo'; - $user->username = 'foo'; - $user->name = 'foo'; - - $user2 = new CmsUser(); - $user2->status = 'bar'; - $user2->username = 'bar'; - $user2->name = 'bar'; - - if ($link) { - $article->user = $user; - } - - $this->_em->persist($article); - $this->_em->persist($user); - $this->_em->persist($user2); - $this->_em->flush(); - $this->_em->clear(); - - $this->articleId = $article->id; - $this->userId = $user->id; - $this->user2Id = $user2->id; - } - - public function testLinkObjects() - { - $this->initDb(false); - - // don't join association - $article = $this->_em->find('Doctrine\Tests\Models\Cms\CmsArticle', $this->articleId); - - $user = $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $this->userId); - - $article->user = $user; - - $this->_em->flush(); - $this->_em->clear(); - - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $this->assertNotNull($article->user); - $this->assertEquals($user->id, $article->user->id); - } - - public function testLinkObjectsWithAssociationLoaded() - { - $this->initDb(false); - - // join association - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $user = $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $this->userId); - - $article->user = $user; - - $this->_em->flush(); - $this->_em->clear(); - - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $this->assertNotNull($article->user); - $this->assertEquals($user->id, $article->user->id); - } - - public function testUnlinkObjects() - { - $this->initDb(true); - - // don't join association - $article = $this->_em->find('Doctrine\Tests\Models\Cms\CmsArticle', $this->articleId); - - $article->user = null; - - $this->_em->flush(); - $this->_em->clear(); - - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $this->assertNull($article->user); - } - - public function testUnlinkObjectsWithAssociationLoaded() - { - $this->initDb(true); - - // join association - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $article->user = null; - - $this->_em->flush(); - $this->_em->clear(); - - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $this->assertNull($article->user); - } - - public function testChangeLink() - { - $this->initDb(false); - - // don't join association - $article = $this->_em->find('Doctrine\Tests\Models\Cms\CmsArticle', $this->articleId); - - $user2 = $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $this->user2Id); - - $article->user = $user2; - - $this->_em->flush(); - $this->_em->clear(); - - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $this->assertNotNull($article->user); - $this->assertEquals($user2->id, $article->user->id); - } - - public function testChangeLinkWithAssociationLoaded() - { - $this->initDb(false); - - // join association - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $user2 = $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $this->user2Id); - - $article->user = $user2; - - $this->_em->flush(); - $this->_em->clear(); - - $article = $this->_em - ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') - ->setParameter('id', $this->articleId) - ->getOneOrNullResult(); - - $this->assertNotNull($article->user); - $this->assertEquals($user2->id, $article->user->id); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php deleted file mode 100755 index 74c1fe1d53..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ /dev/null @@ -1,81 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548E1'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548E2'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548Rel'), - )); - } - - public function testIssue() - { - $rel = new DDC1548Rel(); - $this->_em->persist($rel); - $this->_em->flush(); - - $e1 = new DDC1548E1(); - $e1->rel = $rel; - $this->_em->persist($e1); - $this->_em->flush(); - $this->_em->clear(); - - $obt = $this->_em->find(__NAMESPACE__ . '\DDC1548Rel', $rel->id); - - $this->assertNull($obt->e2); - } -} - -/** - * @Entity - */ -class DDC1548E1 -{ - /** - * @Id - * @OneToOne(targetEntity="DDC1548Rel", inversedBy="e1") - */ - public $rel; -} - -/** - * @Entity - */ -class DDC1548E2 -{ - /** - * @Id - * @OneToOne(targetEntity="DDC1548Rel", inversedBy="e2") - */ - public $rel; -} - -/** - * @Entity - */ -class DDC1548Rel -{ - /** - * @Id @GeneratedValue - * @Column(type="integer") - */ - public $id; - - /** - * @OneToOne(targetEntity="DDC1548E1", mappedBy="rel") - */ - public $e1; - /** - * @OneToOne(targetEntity="DDC1548E2", mappedBy="rel") - */ - public $e2; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php deleted file mode 100755 index b8dec401c8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php +++ /dev/null @@ -1,45 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testIssue() - { - $user = new CmsUser(); - $user->status = 'foo'; - $user->username = 'foo'; - $user->name = 'foo'; - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - $detachedUser = clone $user; - $detachedUser->name = 'bar'; - $detachedUser->status = 'bar'; - - $newUser = $this->_em->getReference(get_class($user), $user->id); - - $mergedUser = $this->_em->merge($detachedUser); - - $this->assertNotSame($mergedUser, $detachedUser); - $this->assertEquals('bar', $detachedUser->getName()); - $this->assertEquals('bar', $mergedUser->getName()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php deleted file mode 100755 index a45c9f1f28..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php +++ /dev/null @@ -1,111 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack); - - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1595BaseInheritance'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1595InheritedEntity1'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1595InheritedEntity2'), - )); - } - - public function testIssue() - { - $e1 = new DDC1595InheritedEntity1(); - - $this->_em->persist($e1); - $this->_em->flush(); - $this->_em->clear(); - - $sqlLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); - $repository = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1595InheritedEntity1'); - - $entity1 = $repository->find($e1->id); - - // DDC-1596 - $this->assertEquals( - "SELECT t0.id AS id1, t0.type FROM base t0 WHERE t0.id = ? AND t0.type IN ('Entity1')", - $sqlLogger->queries[count($sqlLogger->queries)]['sql'] - ); - - $entities = $entity1->getEntities()->getValues(); - - $this->assertEquals( - "SELECT t0.id AS id1, t0.type FROM base t0 INNER JOIN entity1_entity2 ON t0.id = entity1_entity2.item WHERE entity1_entity2.parent = ? AND t0.type IN ('Entity2')", - $sqlLogger->queries[count($sqlLogger->queries)]['sql'] - ); - - $this->_em->clear(); - - $entity1 = $repository->find($e1->id); - $entities = $entity1->getEntities()->count(); - - $this->assertEquals( - "SELECT COUNT(*) FROM entity1_entity2 t WHERE parent = ?", - $sqlLogger->queries[count($sqlLogger->queries)]['sql'] - ); - } -} - -/** - * @Entity - * @Table(name="base") - * - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({ - * "Entity1" = "DDC1595InheritedEntity1", - * "Entity2" = "DDC1595InheritedEntity2" - * }) - */ -abstract class DDC1595BaseInheritance -{ - /** - * @Id @GeneratedValue - * @Column(type="integer") - * - * @var integer - */ - public $id; -} - -/** - * @Entity - * @Table(name="entity1") - */ -class DDC1595InheritedEntity1 extends DDC1595BaseInheritance -{ - /** - * @ManyToMany(targetEntity="DDC1595InheritedEntity2", fetch="EXTRA_LAZY") - * @JoinTable(name="entity1_entity2", - * joinColumns={@JoinColumn(name="parent", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="item", referencedColumnName="id")} - * ) - */ - protected $entities; - - public function getEntities() - { - return $this->entities; - } -} - -/** - * @Entity - * @Table(name="entity2") - */ -class DDC1595InheritedEntity2 extends DDC1595BaseInheritance -{ -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php deleted file mode 100755 index 3126d5491d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php +++ /dev/null @@ -1,65 +0,0 @@ -useModelSet('company'); - parent::setUp(); - } - - /** - * @group DDC-163 - */ - public function testQueryWithOrConditionUsingTwoRelationOnSameEntity() - { - $p1 = new CompanyPerson; - $p1->setName('p1'); - - $p2 = new CompanyPerson; - $p2->setName('p2'); - - $p3 = new CompanyPerson; - $p3->setName('p3'); - - $p4 = new CompanyPerson; - $p4->setName('p4'); - - $p1->setSpouse($p3); - $p1->addFriend($p2); - $p2->addFriend($p3); - - $p3->addFriend($p4); - - $this->_em->persist($p1); - $this->_em->persist($p2); - $this->_em->persist($p3); - $this->_em->persist($p4); - - $this->_em->flush(); - $this->_em->clear(); - - $dql = 'SELECT PARTIAL person.{id,name}, PARTIAL spouse.{id,name}, PARTIAL friend.{id,name} - FROM Doctrine\Tests\Models\Company\CompanyPerson person - LEFT JOIN person.spouse spouse - LEFT JOIN person.friends friend - LEFT JOIN spouse.friends spouse_friend - LEFT JOIN friend.friends friend_friend - WHERE person.name=:name AND (spouse_friend.name=:name2 OR friend_friend.name=:name2)'; - - $q = $this->_em->createQuery($dql); - $q->setParameter('name', "p1"); - $q->setParameter('name2', "p4"); - $result = $q->getScalarResult(); - - $this->assertEquals('p3', $result[0]['spouse_name']); - $this->assertEquals('p1', $result[0]['person_name']); - $this->assertEquals('p2', $result[0]['friend_name']); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php deleted file mode 100755 index 53d6bb6e25..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php +++ /dev/null @@ -1,121 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - - $user1 = new CmsUser(); - $user1->username = "beberlei"; - $user1->name = "Benjamin"; - $user1->status = "active"; - $group1 = new CmsGroup(); - $group1->name = "test"; - $group2 = new CmsGroup(); - $group2->name = "test"; - $user1->addGroup($group1); - $user1->addGroup($group2); - $user2 = new CmsUser(); - $user2->username = "romanb"; - $user2->name = "Roman"; - $user2->status = "active"; - - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->persist($group1); - $this->_em->persist($group2); - $this->_em->flush(); - $this->_em->clear(); - - $this->user1 = $this->_em->find(get_class($user1), $user1->id); - $this->user2 = $this->_em->find(get_class($user1), $user2->id); - } - - public function testClonePersistentCollectionAndReuse() - { - $user1 = $this->user1; - - $user1->groups = clone $user1->groups; - - $this->_em->flush(); - $this->_em->clear(); - - $user1 = $this->_em->find(get_class($user1), $user1->id); - - $this->assertEquals(2, count($user1->groups)); - } - - public function testClonePersistentCollectionAndShare() - { - $user1 = $this->user1; - $user2 = $this->user2; - - $user2->groups = clone $user1->groups; - - $this->_em->flush(); - $this->_em->clear(); - - $user1 = $this->_em->find(get_class($user1), $user1->id); - $user2 = $this->_em->find(get_class($user1), $user2->id); - - $this->assertEquals(2, count($user1->groups)); - $this->assertEquals(2, count($user2->groups)); - } - - public function testCloneThenDirtyPersistentCollection() - { - $user1 = $this->user1; - $user2 = $this->user2; - - $group3 = new CmsGroup(); - $group3->name = "test"; - $user2->groups = clone $user1->groups; - $user2->groups->add($group3); - - $this->_em->persist($group3); - $this->_em->flush(); - $this->_em->clear(); - - $user1 = $this->_em->find(get_class($user1), $user1->id); - $user2 = $this->_em->find(get_class($user1), $user2->id); - - $this->assertEquals(3, count($user2->groups)); - $this->assertEquals(2, count($user1->groups)); - } - - public function testNotCloneAndPassAroundFlush() - { - $user1 = $this->user1; - $user2 = $this->user2; - - $group3 = new CmsGroup(); - $group3->name = "test"; - $user2->groups = $user1->groups; - $user2->groups->add($group3); - - $this->assertEQuals(1, count($user1->groups->getInsertDiff())); - - $this->_em->persist($group3); - $this->_em->flush(); - $this->_em->clear(); - - $user1 = $this->_em->find(get_class($user1), $user1->id); - $user2 = $this->_em->find(get_class($user1), $user2->id); - - $this->assertEquals(3, count($user2->groups)); - $this->assertEquals(3, count($user1->groups)); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php deleted file mode 100755 index 016961935a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php +++ /dev/null @@ -1,103 +0,0 @@ -setUpEntitySchema(array( - __NAMESPACE__ . '\\DDC1654Post', - __NAMESPACE__ . '\\DDC1654Comment', - )); - } - - public function testManyToManyRemoveFromCollectionOrphanRemoval() - { - $post = new DDC1654Post(); - $post->comments[] = new DDC1654Comment(); - $post->comments[] = new DDC1654Comment(); - - $this->_em->persist($post); - $this->_em->flush(); - - $post->comments->remove(0); - $post->comments->remove(1); - - $this->_em->flush(); - $this->_em->clear(); - - $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll(); - $this->assertEquals(0, count($comments)); - } - - public function testManyToManyRemoveElementFromCollectionOrphanRemoval() - { - $post = new DDC1654Post(); - $post->comments[] = new DDC1654Comment(); - $post->comments[] = new DDC1654Comment(); - - $this->_em->persist($post); - $this->_em->flush(); - - $post->comments->removeElement($post->comments[0]); - $post->comments->removeElement($post->comments[1]); - - $this->_em->flush(); - $this->_em->clear(); - - $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll(); - $this->assertEquals(0, count($comments)); - } - - public function testManyToManyClearCollectionOrphanRemoval() - { - $post = new DDC1654Post(); - $post->comments[] = new DDC1654Comment(); - $post->comments[] = new DDC1654Comment(); - - $this->_em->persist($post); - $this->_em->flush(); - - $post->comments->clear(); - - $this->_em->flush(); - $this->_em->clear(); - - $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll(); - $this->assertEquals(0, count($comments)); - - } -} - -/** - * @Entity - */ -class DDC1654Post -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; - - /** - * @ManyToMany(targetEntity="DDC1654Comment", orphanRemoval=true, - * cascade={"persist"}) - */ - public $comments = array(); -} - -/** - * @Entity - */ -class DDC1654Comment -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php deleted file mode 100755 index 22b20e7220..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ /dev/null @@ -1,144 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Foo'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Bar'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Baz'), - )); - } catch(\Exception $e) { - - } - } - - public function testPostLoadOneToManyInheritance() - { - $cm = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1655Foo'); - $this->assertEquals(array("postLoad" => array("postLoad")), $cm->lifecycleCallbacks); - - $cm = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1655Bar'); - $this->assertEquals(array("postLoad" => array("postLoad", "postSubLoaded")), $cm->lifecycleCallbacks); - - $baz = new DDC1655Baz(); - $foo = new DDC1655Foo(); - $foo->baz = $baz; - $bar = new DDC1655Bar(); - $bar->baz = $baz; - - $this->_em->persist($foo); - $this->_em->persist($bar); - $this->_em->persist($baz); - $this->_em->flush(); - $this->_em->clear(); - - $baz = $this->_em->find(get_class($baz), $baz->id); - foreach ($baz->foos as $foo) { - $this->assertEquals(1, $foo->loaded, "should have loaded callback counter incremented for " . get_class($foo)); - } - } - - /** - * Check that post load is not executed several times when the entity - * is rehydrated again although its already known. - */ - public function testPostLoadInheritanceChild() - { - $bar = new DDC1655Bar(); - - $this->_em->persist($bar); - $this->_em->flush(); - $this->_em->clear(); - - $bar = $this->_em->find(get_class($bar), $bar->id); - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); - - $bar = $this->_em->find(get_class($bar), $bar->id); - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); - - $dql = "SELECT b FROM " . __NAMESPACE__ . "\DDC1655Bar b WHERE b.id = ?1"; - $bar = $this->_em->createQuery($dql)->setParameter(1, $bar->id)->getSingleResult(); - - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); - - $this->_em->refresh($bar); - - $this->assertEquals(2, $bar->loaded); - $this->assertEquals(2, $bar->subLoaded); - } -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({ - * "foo" = "DDC1655Foo", - * "bar" = "DDC1655Bar" - * }) - * @HasLifecycleCallbacks - */ -class DDC1655Foo -{ - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; - - public $loaded = 0; - - /** - * @ManyToOne(targetEntity="DDC1655Baz", inversedBy="foos") - */ - public $baz; - - /** - * @PostLoad - */ - public function postLoad() - { - $this->loaded++; - } -} - -/** - * @Entity - * @HasLifecycleCallbacks - */ -class DDC1655Bar extends DDC1655Foo -{ - public $subLoaded; - - /** - * @PostLoad - */ - public function postSubLoaded() - { - $this->subLoaded++; - } -} - -/** - * @Entity - */ -class DDC1655Baz -{ - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; - - /** - * @OneToMany(targetEntity="DDC1655Foo", mappedBy="baz") - */ - public $foos = array(); -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php deleted file mode 100755 index e664e537c3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php +++ /dev/null @@ -1,40 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testGivenOrphanRemovalOneToOne_WhenReplacing_ThenNoUniqueConstraintError() - { - $user = new CmsUser(); - $user->name = "Benjamin"; - $user->username = "beberlei"; - $user->status = "something"; - $user->setEmail($email = new CmsEmail()); - $email->setEmail("kontakt@beberlei.de"); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->assertTrue($this->_em->contains($email)); - - $user->setEmail($newEmail = new CmsEmail()); - $newEmail->setEmail("benjamin.eberlei@googlemail.com"); - - $this->_em->flush(); - - $this->assertFalse($this->_em->contains($email)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php deleted file mode 100755 index ee4c64a197..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php +++ /dev/null @@ -1,64 +0,0 @@ -useModelSet('ddc117'); - parent::setUp(); - - $this->_em->createQuery('DELETE FROM Doctrine\Tests\Models\DDC117\DDC117ArticleDetails ad')->execute(); - - $article = new DDC117Article("Foo"); - $this->_em->persist($article); - $this->_em->flush(); - - $articleDetails = new DDC117ArticleDetails($article, "Very long text"); - $this->_em->persist($articleDetails); - $this->_em->flush(); - - $dql = "SELECT ad FROM Doctrine\Tests\Models\DDC117\DDC117ArticleDetails ad"; - $query = $this->_em->createQuery($dql); - - $this->paginator = new Paginator($query); - } - - public function testPaginateCount() - { - $this->assertEquals(1, count($this->paginator)); - } - - public function testPaginateIterate() - { - foreach ($this->paginator as $ad) { - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', $ad); - } - } - - public function testPaginateCountNoOutputWalkers() - { - $this->paginator->setUseOutputWalkers(false); - $this->assertEquals(1, count($this->paginator)); - } - - public function testPaginateIterateNoOutputWalkers() - { - $this->paginator->setUseOutputWalkers(false); - - $this->setExpectedException('RuntimeException', 'Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator.'); - foreach ($this->paginator as $ad) { - $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', $ad); - } - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php deleted file mode 100755 index 0b5378040c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php +++ /dev/null @@ -1,64 +0,0 @@ -useModelSet('company'); - parent::setUp(); - - $this->oldMetadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyEmployee'); - - $metadata = clone $this->oldMetadata; - ksort($metadata->reflFields); - $this->_em->getMetadataFactory()->setMetadataFor('Doctrine\Tests\Models\Company\CompanyEmployee', $metadata); - } - - public function tearDown() - { - $this->_em->getMetadataFactory()->setMetadataFor('Doctrine\Tests\Models\Company\CompanyEmployee', $this->oldMetadata); - parent::tearDown(); - } - - /** - * @group DDC-168 - */ - public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFieldsArray() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $spouse = new CompanyEmployee; - $spouse->setName("Blub"); - $spouse->setDepartment("Accounting"); - $spouse->setSalary(500); - - $employee = new CompanyEmployee; - $employee->setName("Foo"); - $employee->setDepartment("bar"); - $employee->setSalary(1000); - $employee->setSpouse($spouse); - - $this->_em->persist($spouse); - $this->_em->persist($employee); - - $this->_em->flush(); - $this->_em->clear(); - - $q = $this->_em->createQuery("SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e WHERE e.name = ?1"); - $q->setParameter(1, "Foo"); - $theEmployee = $q->getSingleResult(); - - $this->assertEquals("bar", $theEmployee->getDepartment()); - $this->assertEquals("Foo", $theEmployee->getName()); - $this->assertEquals(1000, $theEmployee->getSalary()); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $theEmployee); - $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $theEmployee->getSpouse()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php deleted file mode 100755 index ab5d2934a7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ /dev/null @@ -1,153 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1690Parent'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1690Child') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - - public function testChangeTracking() - { - $parent = new DDC1690Parent(); - $child = new DDC1690Child(); - $parent->setName('parent'); - $child->setName('child'); - - $parent->setChild($child); - $child->setParent($parent); - - $this->_em->persist($parent); - $this->_em->persist($child); - - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); - - $this->_em->flush(); - $this->_em->clear(); - - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); - - $parentId = $parent->getId(); - $childId = $child->getId(); - unset($parent, $child); - - $parent = $this->_em->find(__NAMESPACE__.'\DDC1690Parent', $parentId); - $child = $this->_em->find(__NAMESPACE__.'\DDC1690Child', $childId); - - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); - unset($parent, $child); - - $parent = $this->_em->find(__NAMESPACE__.'\DDC1690Parent', $parentId); - $child = $parent->getChild(); - - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); - unset($parent, $child); - - $child = $this->_em->find(__NAMESPACE__.'\DDC1690Child', $childId); - $parent = $child->getParent(); - - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); - } -} - -class NotifyBaseEntity implements NotifyPropertyChanged { - public $listeners = array(); - - public function addPropertyChangedListener(PropertyChangedListener $listener) { - if (!in_array($listener, $this->listeners)) { - $this->listeners[] = $listener; - } - } - - protected function onPropertyChanged($propName, $oldValue, $newValue) { - if ($this->listeners) { - foreach ($this->listeners as $listener) { - $listener->propertyChanged($this, $propName, $oldValue, $newValue); - } - } - } -} - -/** @Entity @ChangeTrackingPolicy("NOTIFY") */ -class DDC1690Parent extends NotifyBaseEntity { - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - - /** @Column */ - private $name; - - /** @OneToOne(targetEntity="DDC1690Child") */ - private $child; - - function getId() { - return $this->id; - } - - function getName() { - return $this->name; - } - - function setName($name) { - $this->onPropertyChanged('name', $this->name, $name); - $this->name = $name; - } - - function setChild($child) { - $this->child = $child; - } - - function getChild() { - return $this->child; - } -} - -/** @Entity */ -class DDC1690Child extends NotifyBaseEntity { - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - - /** @Column */ - private $name; - - /** @OneToOne(targetEntity="DDC1690Parent", mappedBy="child") */ - private $parent; - - function getId() { - return $this->id; - } - - function getName() { - return $this->name; - } - - function setName($name) { - $this->onPropertyChanged('name', $this->name, $name); - $this->name = $name; - } - - function setParent($parent) { - $this->parent = $parent; - } - - function getParent() { - return $this->parent; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php deleted file mode 100755 index dc1f884275..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ /dev/null @@ -1,158 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->getName() != "sqlite") { - $this->markTestSkipped("Only with sqlite"); - } - $dql = "SELECT n.smallText, n.publishDate FROM " . __NAMESPACE__ . "\\DDC1695News n"; - $sql = $this->_em->createQuery($dql)->getSQL(); - - $this->assertEquals( - 'SELECT d0_."SmallText" AS SmallText0, d0_."PublishDate" AS PublishDate1 FROM "DDC1695News" d0_', - $sql - ); - } -} - -/** - * @Table(name="`DDC1695News`") - * @Entity - */ -class DDC1695News -{ - /** - * @var integer $idNews - * - * @Column(name="`IdNews`", type="integer", nullable=false) - * @Id - * @GeneratedValue - */ - private $idNews; - - /** - * @var bigint $iduser - * - * @Column(name="`IdUser`", type="bigint", nullable=false) - */ - private $idUser; - - /** - * @var integer $idLanguage - * - * @Column(name="`IdLanguage`", type="integer", nullable=false) - */ - private $idLanguage; - - /** - * @var integer $idCondition - * - * @Column(name="`IdCondition`", type="integer", nullable=true) - */ - private $idCondition; - - /** - * @var integer $idHealthProvider - * - * @Column(name="`IdHealthProvider`", type="integer", nullable=true) - */ - private $idHealthProvider; - - /** - * @var integer $idSpeciality - * - * @Column(name="`IdSpeciality`", type="integer", nullable=true) - */ - private $idSpeciality; - - /** - * @var integer $idMedicineType - * - * @Column(name="`IdMedicineType`", type="integer", nullable=true) - */ - private $idMedicineType; - - /** - * @var integer $idTreatment - * - * @Column(name="`IdTreatment`", type="integer", nullable=true) - */ - private $idTreatment; - - /** - * @var string $title - * - * @Column(name="`Title`", type="string", nullable=true) - */ - private $title; - - /** - * @var string $smallText - * - * @Column(name="`SmallText`", type="string", nullable=true) - */ - private $smallText; - - /** - * @var string $longText - * - * @Column(name="`LongText`", type="string", nullable=true) - */ - private $longText; - - /** - * @var datetimetz $publishDate - * - * @Column(name="`PublishDate`", type="datetimetz", nullable=true) - */ - private $publishDate; - - /** - * @var tsvector $idxNews - * - * @Column(name="`IdxNews`", type="tsvector", nullable=true) - */ - private $idxNews; - - /** - * @var boolean $highlight - * - * @Column(name="`Highlight`", type="boolean", nullable=false) - */ - private $highlight; - - /** - * @var integer $order - * - * @Column(name="`Order`", type="integer", nullable=false) - */ - private $order; - - /** - * @var boolean $deleted - * - * @Column(name="`Deleted`", type="boolean", nullable=false) - */ - private $deleted; - - /** - * @var boolean $active - * - * @Column(name="`Active`", type="boolean", nullable=false) - */ - private $active; - - /** - * @var boolean $updateToHighlighted - * - * @Column(name="`UpdateToHighlighted`", type="boolean", nullable=true) - */ - private $updateToHighlighted; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php deleted file mode 100755 index 50e702d996..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ /dev/null @@ -1,64 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1509File'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1509Picture'), - )); - } catch (\Exception $ignored) { - - } - } - - public function testPostLoadOnChild() - { - $class = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1707Child'); - $entity = new DDC1707Child(); - $class->invokeLifecycleCallbacks(\Doctrine\ORM\Events::postLoad, $entity); - - $this->assertTrue($entity->postLoad); - } -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"c": "DDC1707Child"}) - * @HasLifecycleCallbacks - */ -abstract class DDC1707Base -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - protected $id; - - public $postLoad = false; - - /** - * @PostLoad - */ - public function onPostLoad() - { - $this->postLoad = true; - } -} -/** - * @Entity - */ -class DDC1707Child extends DDC1707Base -{ -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php deleted file mode 100755 index 93b3458e61..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ /dev/null @@ -1,88 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(self::CLASS_NAME), - )); - } catch(\Exception $e) { - } - } - - public function testCreateRetreaveUpdateDelete() - { - $e1 = new SimpleEntity('Bar 1'); - $e2 = new SimpleEntity('Foo 1'); - - // Create - $this->_em->persist($e1); - $this->_em->persist($e2); - $this->_em->flush(); - $this->_em->clear(); - - $e1Id = $e1->id; - $e2Id = $e2->id; - - // Retreave - $e1 = $this->_em->find(self::CLASS_NAME, $e1Id); - $e2 = $this->_em->find(self::CLASS_NAME, $e2Id); - - $this->assertInstanceOf(self::CLASS_NAME, $e1); - $this->assertInstanceOf(self::CLASS_NAME, $e2); - - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); - - $this->assertEquals('Bar 1', $e1->value); - $this->assertEquals('Foo 1', $e2->value); - - $e1->value = 'Bar 2'; - $e2->value = 'Foo 2'; - - // Update - $this->_em->persist($e1); - $this->_em->persist($e2); - $this->_em->flush(); - - $this->assertEquals('Bar 2', $e1->value); - $this->assertEquals('Foo 2', $e2->value); - - $this->assertInstanceOf(self::CLASS_NAME, $e1); - $this->assertInstanceOf(self::CLASS_NAME, $e2); - - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); - - $this->assertEquals('Bar 2', $e1->value); - $this->assertEquals('Foo 2', $e2->value); - - // Delete - $this->_em->remove($e1); - $this->_em->remove($e2); - $this->_em->flush(); - - - $e1 = $this->_em->find(self::CLASS_NAME, $e1Id); - $e2 = $this->_em->find(self::CLASS_NAME, $e2Id); - - $this->assertNull($e1); - $this->assertNull($e2); - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php deleted file mode 100755 index 488f469b1d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php +++ /dev/null @@ -1,92 +0,0 @@ -_em->createQueryBuilder(); - /* @var $qb \Doctrine\ORM\QueryBuilder */ - - $qb->select('_a') - ->from(__NAMESPACE__ . '\DDC1757A', '_a') - ->from(__NAMESPACE__ . '\DDC1757B', '_b') - ->join('_b.c', '_c') - ->join('_c.d', '_d'); - - $q = $qb->getQuery(); - $dql = $q->getDQL(); - - // Show difference between expected and actual queries on error - self::assertEquals("SELECT _a FROM " . __NAMESPACE__ . "\DDC1757A _a, " . __NAMESPACE__ . "\DDC1757B _b INNER JOIN _b.c _c INNER JOIN _c.d _d", - $dql, - "Wrong DQL query"); - } -} - -/** - * @Entity - */ -class DDC1757A -{ - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - private $id; -} - -/** - * @Entity - */ -class DDC1757B -{ - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @OneToOne(targetEntity="DDC1757C") - */ - private $c; -} - -/** - * @Entity - */ -class DDC1757C -{ - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @OneToOne(targetEntity="DDC1757D") - */ - private $d; -} - -/** - * @Entity - */ -class DDC1757D -{ - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - public $id; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php deleted file mode 100755 index aebc6422c9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php +++ /dev/null @@ -1,74 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - - $this->user = new CmsUser(); - $this->user->username = "beberlei"; - $this->user->name = "Benjamin"; - $this->user->status = "active"; - - $this->phone = new CmsPhoneNumber(); - $this->phone->phonenumber = '0123456789'; - $this->user->addPhoneNumber($this->phone); - - $this->_em->persist($this->user); - $this->_em->persist($this->phone); - $this->_em->flush(); - $this->_em->clear(); - - $this->user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId()); - $this->phone = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsPhonenumber', $this->phone->phonenumber); - } - - public function testClear() - { - $clonedNumbers = clone $this->user->getPhonenumbers(); - $clonedNumbers->clear(); - $this->_em->flush(); - $this->_em->clear(); - - $this->user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId()); - - $this->assertCount(1, $this->user->getPhonenumbers()); - } - - public function testRemove() - { - $clonedNumbers = clone $this->user->getPhonenumbers(); - $clonedNumbers->remove(0); - $this->_em->flush(); - $this->_em->clear(); - - $this->user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId()); - - $this->assertCount(1, $this->user->getPhonenumbers()); - } - - public function testRemoveElement() - { - $clonedNumbers = clone $this->user->getPhonenumbers(); - $clonedNumbers->removeElement($this->phone); - $this->_em->flush(); - $this->_em->clear(); - - $this->user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId()); - - $this->assertCount(1, $this->user->getPhonenumbers()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php deleted file mode 100755 index 15cfd5903b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php +++ /dev/null @@ -1,136 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\User'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Group'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Phone'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Address'), - )); - } catch(\Exception $e) { - } - } - - public function testCreateRetreaveUpdateDelete() - { - - $e1 = new Group('Parent Bar 1'); - $e2 = new Group('Parent Foo 2'); - - $this->_em->persist($e1); - $this->_em->persist($e2); - $this->_em->flush(); - - $e3 = new Group('Bar 3', $e1); - $e4 = new Group('Foo 4', $e2); - - // Create - $this->_em->persist($e3); - $this->_em->persist($e4); - $this->_em->flush(); - $this->_em->clear(); - - $e1Id = $e1->id; - $e2Id = $e2->id; - $e3Id = $e3->id; - $e4Id = $e4->id; - - // Retreave - $e1 = $this->_em->find('Doctrine\Tests\Models\Quote\Group', $e1Id); - $e2 = $this->_em->find('Doctrine\Tests\Models\Quote\Group', $e2Id); - $e3 = $this->_em->find('Doctrine\Tests\Models\Quote\Group', $e3Id); - $e4 = $this->_em->find('Doctrine\Tests\Models\Quote\Group', $e4Id); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e1); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e2); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e3); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e4); - - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); - $this->assertEquals($e3Id, $e3->id); - $this->assertEquals($e4Id, $e4->id); - - - $this->assertEquals('Parent Bar 1', $e1->name); - $this->assertEquals('Parent Foo 2', $e2->name); - $this->assertEquals('Bar 3', $e3->name); - $this->assertEquals('Foo 4', $e4->name); - - $e1->name = 'Parent Bar 11'; - $e2->name = 'Parent Foo 22'; - $e3->name = 'Bar 33'; - $e4->name = 'Foo 44'; - - // Update - $this->_em->persist($e1); - $this->_em->persist($e2); - $this->_em->persist($e3); - $this->_em->persist($e4); - $this->_em->flush(); - - $this->assertEquals('Parent Bar 11', $e1->name); - $this->assertEquals('Parent Foo 22', $e2->name); - $this->assertEquals('Bar 33', $e3->name); - $this->assertEquals('Foo 44', $e4->name); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e1); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e2); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e3); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e4); - - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); - $this->assertEquals($e3Id, $e3->id); - $this->assertEquals($e4Id, $e4->id); - - $this->assertEquals('Parent Bar 11', $e1->name); - $this->assertEquals('Parent Foo 22', $e2->name); - $this->assertEquals('Bar 33', $e3->name); - $this->assertEquals('Foo 44', $e4->name); - - // Delete - $this->_em->remove($e4); - $this->_em->remove($e3); - $this->_em->remove($e2); - $this->_em->remove($e1); - - $this->_em->flush(); - $this->_em->clear(); - - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e1); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e2); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e3); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $e4); - - // Retreave - $e1 = $this->_em->find('Doctrine\Tests\Models\Quote\Group', $e1Id); - $e2 = $this->_em->find('Doctrine\Tests\Models\Quote\Group', $e2Id); - $e3 = $this->_em->find('Doctrine\Tests\Models\Quote\Group', $e3Id); - $e4 = $this->_em->find('Doctrine\Tests\Models\Quote\Group', $e4Id); - - $this->assertNull($e1); - $this->assertNull($e2); - $this->assertNull($e3); - $this->assertNull($e4); - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php deleted file mode 100755 index 9d158155da..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php +++ /dev/null @@ -1,171 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\User'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Group'), - $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\Address'), - )); - } catch(\Exception $e) { - } - - $user = new User(); - $user->name = "FabioBatSilva"; - $user->email = "fabio.bat.silva@gmail.com"; - $user->groups[] = new Group('G 1'); - $user->groups[] = new Group('G 2'); - $this->user = $user; - - // Create - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - } - - public function testCreateRetreaveUpdateDelete() - { - $user = $this->user; - $g1 = $user->getGroups()->get(0); - $g2 = $user->getGroups()->get(1); - - $u1Id = $user->id; - $g1Id = $g1->id; - $g2Id = $g2->id; - - // Retreave - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $u1Id); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); - - $this->assertCount(2, $user->groups); - - $g1 = $user->getGroups()->get(0); - $g2 = $user->getGroups()->get(1); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $g1); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $g2); - - $g1->name = 'Bar 11'; - $g2->name = 'Foo 22'; - - // Update - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $u1Id); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); - - // Delete - $this->_em->remove($user); - - $this->_em->flush(); - $this->_em->clear(); - - $this->assertNull($this->_em->find('Doctrine\Tests\Models\Quote\User', $u1Id)); - $this->assertNull($this->_em->find('Doctrine\Tests\Models\Quote\Group', $g1Id)); - $this->assertNull($this->_em->find('Doctrine\Tests\Models\Quote\Group', $g2Id)); - } - - public function testRemoveItem() - { - $user = $this->user; - $u1Id = $user->id; - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $u1Id); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); - - $this->assertCount(2, $user->groups); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $user->getGroups()->get(0)); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $user->getGroups()->get(1)); - - $user->getGroups()->remove(0); - - // Update - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $u1Id); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); - - $this->assertCount(1, $user->getGroups()); - } - - public function testClearAll() - { - $user = $this->user; - $u1Id = $user->id; - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $u1Id); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); - - $this->assertCount(2, $user->groups); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $user->getGroups()->get(0)); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $user->getGroups()->get(1)); - - $user->getGroups()->clear(); - - // Update - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $u1Id); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); - - $this->assertCount(0, $user->getGroups()); - } - - public function testCountExtraLazy() - { - $user = $this->user; - $u1Id = $user->id; - $user = $this->_em->find('Doctrine\Tests\Models\Quote\User', $u1Id); - - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\User', $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); - - $this->assertCount(0, $user->extraLazyGroups); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $user->getGroups()->get(0)); - $this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $user->getGroups()->get(1)); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php deleted file mode 100755 index 64b3ad48db..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php +++ /dev/null @@ -1,62 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testLastPageCorrect() - { - $groups = array(); - for ($i = 0; $i < 3; $i++) { - $group = new CmsGroup(); - $group->name = "test"; - $this->_em->persist($group); - - $groups[] = $group; - } - - for ($i = 0; $i < 10; $i++) { - $user = new CmsUser(); - $user->username = "user$i"; - $user->name = "user$i"; - $user->status = "active"; - $user->groups = $groups; - - $this->_em->persist($user); - } - - $this->_em->flush(); - - $query = $this->_em->createQuery('SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'); - $query->setFirstResult(6); - $query->setMaxResults(3); - - $paginator = new Paginator($query, true); - $this->assertEquals(3, count(iterator_to_array($paginator))); - - $query->setFirstResult(8); - $query->setMaxResults(3); - - $paginator = new Paginator($query, true); - $this->assertEquals(2, count(iterator_to_array($paginator))); - - $query->setFirstResult(10); - $query->setMaxResults(3); - - $paginator = new Paginator($query, true); - $this->assertEquals(0, count(iterator_to_array($paginator))); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php deleted file mode 100755 index 18eb76943c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php +++ /dev/null @@ -1,65 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC192User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC192Phonenumber') - )); - } -} - - -/** - * @Entity @Table(name="ddc192_users") - */ -class DDC192User -{ - /** - * @Id @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @Column(name="name", type="string") - */ - public $name; -} - - -/** - * @Entity @Table(name="ddc192_phonenumbers") - */ -class DDC192Phonenumber -{ - /** - * @Id @Column(name="phone", type="string", length=40) - */ - protected $phone; - - /** - * @Id - * @ManyToOne(targetEntity="DDC192User") - * @JoinColumn(name="userId", referencedColumnName="id") - */ - protected $User; - - - public function setPhone($value) { $this->phone = $value; } - - public function getPhone() { return $this->phone; } - - public function setUser(User $user) - { - $this->User = $user; - } - - public function getUser() { return $this->User; } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php deleted file mode 100755 index 9084ec0a63..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php +++ /dev/null @@ -1,100 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC199ParentClass'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC199ChildClass'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC199RelatedClass') - )); - } - - public function testPolymorphicLoading() - { - $child = new DDC199ChildClass; - $child->parentData = 'parentData'; - $child->childData = 'childData'; - $this->_em->persist($child); - - $related1 = new DDC199RelatedClass; - $related1->relatedData = 'related1'; - $related1->parent = $child; - $this->_em->persist($related1); - - $related2 = new DDC199RelatedClass; - $related2->relatedData = 'related2'; - $related2->parent = $child; - $this->_em->persist($related2); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery('select e,r from Doctrine\Tests\ORM\Functional\Ticket\DDC199ParentClass e join e.relatedEntities r'); - $result = $query->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199ParentClass', $result[0]); - $this->assertTrue($result[0]->relatedEntities->isInitialized()); - $this->assertEquals(2, $result[0]->relatedEntities->count()); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199RelatedClass', $result[0]->relatedEntities[0]); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199RelatedClass', $result[0]->relatedEntities[1]); - } -} - - -/** - * @Entity @Table(name="ddc199_entities") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"parent" = "DDC199ParentClass", "child" = "DDC199ChildClass"}) - */ -class DDC199ParentClass -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @Column(type="string") - */ - public $parentData; - - /** - * @OneToMany(targetEntity="DDC199RelatedClass", mappedBy="parent") - */ - public $relatedEntities; -} - - -/** @Entity */ -class DDC199ChildClass extends DDC199ParentClass -{ - /** - * @Column - */ - public $childData; -} - -/** @Entity @Table(name="ddc199_relatedclass") */ -class DDC199RelatedClass -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @Column */ - public $relatedData; - - /** - * @ManyToOne(targetEntity="DDC199ParentClass", inversedBy="relatedEntities") - * @JoinColumn(name="parent_id", referencedColumnName="id") - */ - public $parent; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php deleted file mode 100755 index eca15cea3f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ /dev/null @@ -1,177 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2012Item'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2012ItemPerson'), - )); - } - - public function testIssue() - { - $item = new DDC2012ItemPerson(); - $item->tsv = array('word1', 'word2', 'word3'); - - $this->_em->persist($item); - $this->_em->flush(); - $this->_em->clear(); - - $item = $this->_em->find(get_class($item), $item->id); - - $this->assertArrayHasKey('convertToDatabaseValueSQL', DDC2012TsVectorType::$calls); - $this->assertArrayHasKey('convertToDatabaseValue', DDC2012TsVectorType::$calls); - $this->assertArrayHasKey('convertToPHPValue', DDC2012TsVectorType::$calls); - - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValue']); - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToPHPValue']); - - $this->assertInstanceOf(__NAMESPACE__ . '\DDC2012Item', $item); - $this->assertEquals(array('word1', 'word2', 'word3'), $item->tsv); - - - $item->tsv = array('word1', 'word2'); - - $this->_em->persist($item); - $this->_em->flush(); - $this->_em->clear(); - - $item = $this->_em->find(get_class($item), $item->id); - - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValue']); - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToPHPValue']); - - $this->assertInstanceOf(__NAMESPACE__ . '\DDC2012Item', $item); - $this->assertEquals(array('word1', 'word2'), $item->tsv); - } -} - -/** - * @Table(name="ddc2010_item") - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type_id", type="smallint") - * @DiscriminatorMap({ - * 1 = "DDC2012ItemPerson" - * }) - */ -class DDC2012Item -{ - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - */ - public $id; - - /** - * @Column(name="tsv", type="tsvector", nullable=true) - */ - public $tsv; -} - -/** - * @Table(name="ddc2010_item_person") - * @Entity - */ -class DDC2012ItemPerson extends DDC2012Item -{ - -} - -class DDC2012TsVectorType extends Type -{ - const MYTYPE = 'tsvector'; - - public static $calls = array(); - - /** - * {@inheritdoc} - */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) - { - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); - } - - /** - * {@inheritdoc} - */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) - { - if (is_array($value)) { - $value = implode(" ", $value); - } - - self::$calls[__FUNCTION__][] = array( - 'value' => $value, - 'platform' => $platform, - ); - - return $value; - } - - /** - * {@inheritdoc} - */ - public function convertToPHPValue($value, AbstractPlatform $platform) - { - self::$calls[__FUNCTION__][] = array( - 'value' => $value, - 'platform' => $platform, - ); - - return explode(" ", strtolower($value)); - } - - /** - * {@inheritdoc} - */ - public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) - { - self::$calls[__FUNCTION__][] = array( - 'sqlExpr' => $sqlExpr, - 'platform' => $platform, - ); - - // changed to upper expression to keep the test compatible with other Databases - //sprintf('to_tsvector(%s)', $sqlExpr); - - return $platform->getUpperExpression($sqlExpr); - } - - /** - * {@inheritdoc} - */ - public function canRequireSQLConversion() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return self::MYTYPE; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php deleted file mode 100755 index 5538ee3d49..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php +++ /dev/null @@ -1,29 +0,0 @@ -_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); - $product = new ECommerceProduct(); - $category = new ECommerceCategory(); - $collection = new PersistentCollection($this->_em, $class, new ArrayCollection(array($category))); - $collection->setOwner($product, $class->associationMappings['categories']); - - $uow = $this->_em->getUnitOfWork(); - $clonedCollection = clone $collection; - $clonedCollection->clear(); - - $this->assertEquals(0, count($uow->getScheduledCollectionDeletions())); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php deleted file mode 100755 index c5da3deaeb..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php +++ /dev/null @@ -1,110 +0,0 @@ -useModelSet('company'); - parent::setUp(); - } - - public function testIssue() - { - $className = 'Doctrine\Tests\Models\Company\CompanyEmployee'; - $date1 = new \DateTime('2011-11-11 11:11:11'); - $date2 = new \DateTime('2012-12-12 12:12:12'); - $employee1 = new CompanyEmployee; - $employee2 = new CompanyEmployee; - - $employee1->setName("Fabio B. Silva"); - $employee1->setStartDate(new \DateTime('yesterday')); - $employee1->setDepartment("R&D"); - $employee1->setSalary(100); - - $employee2->setName("Doctrine Bot"); - $employee1->setStartDate(new \DateTime('yesterday')); - $employee2->setDepartment("QA"); - $employee2->setSalary(100); - - $this->_em->persist($employee1); - $this->_em->persist($employee2); - $this->_em->flush(); - $this->_em->clear(); - - $this->_em->createQueryBuilder() - ->update($className, 'e') - ->set('e.startDate', ':date') - ->set('e.salary', ':salary') - ->where('e = :e') - ->setParameters(array( - 'e' => $employee1, - 'date' => $date1, - 'salary' => 101, - )) - ->getQuery() - ->useQueryCache(true) - ->execute(); - - $this->_em->createQueryBuilder() - ->update($className, 'e') - ->set('e.startDate', ':date') - ->set('e.salary', ':salary') - ->where('e = :e') - ->setParameters(array( - 'e' => $employee2, - 'date' => $date2, - 'salary' => 102, - )) - ->getQuery() - ->useQueryCache(true) - ->execute(); - - $this->_em->clear(); - - $e1 = $this->_em->find($className, $employee1->getId()); - $e2 = $this->_em->find($className, $employee2->getId()); - - $this->assertEquals(101, $e1->getSalary()); - $this->assertEquals(102, $e2->getSalary()); - $this->assertEquals($date1, $e1->getStartDate()); - $this->assertEquals($date2, $e2->getStartDate()); - - $this->_em->createQueryBuilder() - ->update($className, 'e') - ->set('e.startDate', '?1') - ->set('e.salary', '?2') - ->where('e = ?0') - ->setParameters(array($employee1, $date1, 101)) - ->getQuery() - ->useQueryCache(true) - ->execute(); - - $this->_em->createQueryBuilder() - ->update($className, 'e') - ->set('e.startDate', '?1') - ->set('e.salary', '?2') - ->where('e = ?0') - ->setParameters(array($employee2, $date2, 102)) - ->getQuery() - ->useQueryCache(true) - ->execute(); - - - $this->_em->clear(); - - $e1 = $this->_em->find($className, $employee1->getId()); - $e2 = $this->_em->find($className, $employee2->getId()); - - $this->assertEquals(101, $e1->getSalary()); - $this->assertEquals(102, $e2->getSalary()); - $this->assertEquals($date1, $e1->getStartDate()); - $this->assertEquals($date2, $e2->getStartDate()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php deleted file mode 100755 index 6104c9cae0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php +++ /dev/null @@ -1,116 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC211User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC211Group') - )); - } - - public function testIssue() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $user = new DDC211User; - $user->setName('John Doe'); - - $this->_em->persist($user); - $this->_em->flush(); - - $groupNames = array('group 1', 'group 2', 'group 3', 'group 4'); - foreach ($groupNames as $name) { - - $group = new DDC211Group; - $group->setName($name); - $this->_em->persist($group); - $this->_em->flush(); - - if (!$user->getGroups()->contains($group)) { - $user->getGroups()->add($group); - $group->getUsers()->add($user); - $this->_em->flush(); - } - } - - $this->assertEquals(4, $user->getGroups()->count()); - - } -} - - -/** - * @Entity - * @Table(name="ddc211_users") -*/ -class DDC211User -{ - /** - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - protected $id; - - /** - * @Column(name="name", type="string") - */ - protected $name; - - /** - * @ManyToMany(targetEntity="DDC211Group", inversedBy="users") - * @JoinTable(name="user_groups", - * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")} - * ) - */ - protected $groups; - - public function __construct() { - $this->groups = new \Doctrine\Common\Collections\ArrayCollection(); - } - - public function setName($name) { $this->name = $name; } - - public function getGroups() { return $this->groups; } -} - -/** - * @Entity - * @Table(name="ddc211_groups") - */ -class DDC211Group -{ - /** - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - protected $id; - - /** - * @Column(name="name", type="string") - */ - protected $name; - - /** - * @ManyToMany(targetEntity="DDC211User", mappedBy="groups") - */ - protected $users; - - public function __construct() { - $this->users = new \Doctrine\Common\Collections\ArrayCollection(); - } - - public function setName($name) { $this->name = $name; } - - public function getUsers() { return $this->users; } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php deleted file mode 100755 index 178685b391..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php +++ /dev/null @@ -1,62 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2175Entity'), - )); - } - - public function testIssue() - { - $entity = new DDC2175Entity(); - $entity->field = "foo"; - - $this->_em->persist($entity); - $this->_em->flush(); - - $this->assertEquals(1, $entity->version); - - $entity->field = "bar"; - $this->_em->flush(); - - $this->assertEquals(2, $entity->version); - - $entity->field = "baz"; - $this->_em->flush(); - - $this->assertEquals(3, $entity->version); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({"entity": "DDC2175Entity"}) - */ -class DDC2175Entity -{ - /** - * @Id @GeneratedValue @Column(type="integer") - */ - public $id; - - /** - * @Column(type="string") - */ - public $field; - - /** - * @Version - * @Column(type="integer") - */ - public $version; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php deleted file mode 100755 index e450b60a8c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ /dev/null @@ -1,52 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->getName() != 'mysql') { - $this->markTestSkipped("This test is useful for all databases, but designed only for mysql."); - } - - $sql = $this->_schemaTool->getCreateSchemaSql(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2182OptionParent'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2182OptionChild'), - )); - - $this->assertEquals("CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[0]); - $this->assertEquals("CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[1]); - $this->assertEquals("ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)", $sql[2]); - } -} - -/** - * @Entity - * @Table - */ -class DDC2182OptionParent -{ - /** @Id @Column(type="integer", options={"unsigned": true}) */ - private $id; -} - -/** - * @Entity - * @Table - */ -class DDC2182OptionChild -{ - /** @Id @Column */ - private $id; - - /** - * @ManyToOne(targetEntity="DDC2182OptionParent") - * @JoinColumn(referencedColumnName="id") - */ - private $parent; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php deleted file mode 100755 index b222e0218f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php +++ /dev/null @@ -1,71 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2231EntityY'), - )); - } - - public function testInjectObjectManagerInProxyIfInitializedInUow() - { - $y1 = new DDC2231EntityY; - - $this->_em->persist($y1); - - $this->_em->flush(); - $this->_em->clear(); - - $y1ref = $this->_em->getReference(get_class($y1), $y1->id); - - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $y1ref); - $this->assertFalse($y1ref->__isInitialized__); - - $id = $y1ref->doSomething(); - - $this->assertTrue($y1ref->__isInitialized__); - $this->assertEquals($this->_em, $y1ref->om); - } -} - - -/** @Entity @Table(name="ddc2231_y") */ -class DDC2231EntityY implements ObjectManagerAware -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; - - public $om; - - public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata) - { - $this->om = $objectManager; - } - - public function getId() - { - return $this->id; - } - - public function doSomething() - { - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php deleted file mode 100755 index 491cf3bd6a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ /dev/null @@ -1,229 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC2252User'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC2252Privilege'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC2252Membership'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC2252MerchantAccount'), - )); - - $this->loadFixtures(); - } - - public function loadFixtures() - { - $this->user = new DDC2252User; - $this->merchant = new DDC2252MerchantAccount; - $this->membership = new DDC2252Membership($this->user, $this->merchant); - - $this->privileges[] = new DDC2252Privilege; - $this->privileges[] = new DDC2252Privilege; - $this->privileges[] = new DDC2252Privilege; - - $this->membership->addPrivilege($this->privileges[0]); - $this->membership->addPrivilege($this->privileges[1]); - $this->membership->addPrivilege($this->privileges[2]); - - $this->_em->persist($this->user); - $this->_em->persist($this->merchant); - $this->_em->persist($this->privileges[0]); - $this->_em->persist($this->privileges[1]); - $this->_em->persist($this->privileges[2]); - $this->_em->flush(); - - $this->_em->persist($this->membership); - $this->_em->flush(); - $this->_em->clear(); - } - - public function testIssue() - { - $identifier = array( - 'merchantAccount' => $this->merchant->getAccountid(), - 'userAccount' => $this->user->getUid(), - ); - - $class = 'Doctrine\Tests\ORM\Functional\Ticket\DDC2252Membership'; - $membership = $this->_em->find($class, $identifier); - - $this->assertInstanceOf($class, $membership); - $this->assertCount(3, $membership->getPrivileges()); - - $membership->getPrivileges()->remove(2); - $this->_em->persist($membership); - $this->_em->flush(); - $this->_em->clear(); - - $membership = $this->_em->find($class, $identifier); - - $this->assertInstanceOf($class, $membership); - $this->assertCount(2, $membership->getPrivileges()); - - $membership->getPrivileges()->clear(); - $this->_em->persist($membership); - $this->_em->flush(); - $this->_em->clear(); - - $membership = $this->_em->find($class, $identifier); - - $this->assertInstanceOf($class, $membership); - $this->assertCount(0, $membership->getPrivileges()); - - $membership->addPrivilege($privilege3 = new DDC2252Privilege); - $this->_em->persist($privilege3); - $this->_em->persist($membership); - $this->_em->flush(); - $this->_em->clear(); - - $membership = $this->_em->find($class, $identifier); - - $this->assertInstanceOf($class, $membership); - $this->assertCount(1, $membership->getPrivileges()); - } -} - -/** - * @Entity() - * @Table(name="ddc2252_acl_privilege") - */ -class DDC2252Privilege -{ - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - */ - protected $privilegeid; - - public function getPrivilegeid() - { - return $this->privilegeid; - } -} - -/** - * @Entity - * @Table(name="ddc2252_mch_account") - */ -class DDC2252MerchantAccount -{ - /** - * @Id - * @Column(type="integer") - */ - protected $accountid = 111; - - public function getAccountid() - { - return $this->accountid; - } -} - -/** - * @Entity - * @Table(name="ddc2252_user_account") - */ -class DDC2252User { - /** - * @Id - * @Column(type="integer") - */ - protected $uid = 222; - - /** - * @OneToMany(targetEntity="DDC2252Membership", mappedBy="userAccount", cascade={"persist"}) - * @JoinColumn(name="uid", referencedColumnName="uid") - */ - protected $memberships; - - public function __construct() - { - $this->memberships = new ArrayCollection; - } - - public function getUid() - { - return $this->uid; - } - - public function getMemberships() - { - return $this->memberships; - } - - public function addMembership(DDC2252Membership $membership) - { - $this->memberships[] = $membership; - } -} - -/** - * @Entity - * @Table(name="ddc2252_mch_account_member") - * @HasLifecycleCallbacks - */ -class DDC2252Membership -{ - /** - * @Id - * @ManyToOne(targetEntity="DDC2252User", inversedBy="memberships") - * @JoinColumn(name="uid", referencedColumnName="uid") - */ - protected $userAccount; - - /** - * @Id - * @ManyToOne(targetEntity="DDC2252MerchantAccount") - * @JoinColumn(name="mch_accountid", referencedColumnName="accountid") - */ - protected $merchantAccount; - - /** - * @ManyToMany(targetEntity="DDC2252Privilege", indexBy="privilegeid") - * @JoinTable(name="ddc2252_user_mch_account_privilege", - * joinColumns={ - * @JoinColumn(name="mch_accountid", referencedColumnName="mch_accountid"), - * @JoinColumn(name="uid", referencedColumnName="uid") - * }, - * inverseJoinColumns={ - * @JoinColumn(name="privilegeid", referencedColumnName="privilegeid") - * } - * ) - */ - protected $privileges; - - public function __construct(DDC2252User $user, DDC2252MerchantAccount $merchantAccount) - { - $this->userAccount = $user; - $this->merchantAccount = $merchantAccount; - $this->privileges = new ArrayCollection(); - } - - public function addPrivilege($privilege) - { - $this->privileges[] = $privilege; - } - - public function getPrivileges() - { - return $this->privileges; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php deleted file mode 100755 index 8bc803f295..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ /dev/null @@ -1,109 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2346Foo'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2346Bar'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2346Baz'), - )); - - $this->logger = new DebugStack(); - } - - /** - * Verifies that fetching a OneToMany association with fetch="EAGER" does not cause N+1 queries - */ - public function testIssue() - { - $foo1 = new DDC2346Foo(); - $foo2 = new DDC2346Foo(); - - $baz1 = new DDC2346Baz(); - $baz2 = new DDC2346Baz(); - - $baz1->foo = $foo1; - $baz2->foo = $foo2; - - $foo1->bars[] = $baz1; - $foo1->bars[] = $baz2; - - $this->_em->persist($foo1); - $this->_em->persist($foo2); - $this->_em->persist($baz1); - $this->_em->persist($baz2); - - $this->_em->flush(); - $this->_em->clear(); - - $this->_em->getConnection()->getConfiguration()->setSQLLogger($this->logger); - - $fetchedBazs = $this->_em->getRepository(__NAMESPACE__ . '\\DDC2346Baz')->findAll(); - - $this->assertCount(2, $fetchedBazs); - $this->assertCount(2, $this->logger->queries, 'The total number of executed queries is 2, and not n+1'); - } -} - -/** @Entity */ -class DDC2346Foo -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - - /** - * @var DDC2346Bar[]|\Doctrine\Common\Collections\Collection - * - * @OneToMany(targetEntity="DDC2346Bar", mappedBy="foo") - */ - public $bars; - - /** Constructor */ - public function __construct() { - $this->bars = new ArrayCollection(); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"baz" = "DDC2346Baz"}) - */ -class DDC2346Bar -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - - /** @ManyToOne(targetEntity="DDC2346Foo", inversedBy="bars", fetch="EAGER") */ - public $foo; -} - - -/** - * @Entity - */ -class DDC2346Baz extends DDC2346Bar -{ - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php deleted file mode 100755 index 413e564136..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ /dev/null @@ -1,112 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC237EntityX'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC237EntityY'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC237EntityZ') - )); - } - - public function testUninitializedProxyIsInitializedOnFetchJoin() - { - $x = new DDC237EntityX; - $y = new DDC237EntityY; - $z = new DDC237EntityZ; - - $x->data = 'X'; - $y->data = 'Y'; - $z->data = 'Z'; - - $x->y = $y; - $z->y = $y; - - $this->_em->persist($x); - $this->_em->persist($y); - $this->_em->persist($z); - - $this->_em->flush(); - $this->_em->clear(); - - $x2 = $this->_em->find(get_class($x), $x->id); // proxy injected for Y - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $x2->y); - $this->assertFalse($x2->y->__isInitialized__); - - // proxy for Y is in identity map - - $z2 = $this->_em->createQuery('select z,y from ' . get_class($z) . ' z join z.y y where z.id = ?1') - ->setParameter(1, $z->id) - ->getSingleResult(); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $z2->y); - $this->assertTrue($z2->y->__isInitialized__); - $this->assertEquals('Y', $z2->y->data); - $this->assertEquals($y->id, $z2->y->id); - - // since the Y is the same, the instance from the identity map is - // used, even if it is a proxy. - - $this->assertNotSame($x, $x2); - $this->assertNotSame($z, $z2); - $this->assertSame($z2->y, $x2->y); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $z2->y); - - } -} - - -/** - * @Entity @Table(name="ddc237_x") - */ -class DDC237EntityX -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; - /** - * @Column(type="string") - */ - public $data; - /** - * @OneToOne(targetEntity="DDC237EntityY") - * @JoinColumn(name="y_id", referencedColumnName="id") - */ - public $y; -} - - -/** @Entity @Table(name="ddc237_y") */ -class DDC237EntityY -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; - /** - * @Column(type="string") - */ - public $data; -} - -/** @Entity @Table(name="ddc237_z") */ -class DDC237EntityZ -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @Column(type="string") */ - public $data; - - /** - * @OneToOne(targetEntity="DDC237EntityY") - * @JoinColumn(name="y_id", referencedColumnName="id") - */ - public $y; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php deleted file mode 100755 index f74d4e15cf..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php +++ /dev/null @@ -1,30 +0,0 @@ -addColumn('id', 'integer'); - $product->setPrimaryKey(array('id')); - - $attributes = new \Doctrine\DBAL\Schema\Table('ddc2387_attributes'); - $attributes->addColumn('product_id', 'integer'); - $attributes->addColumn('attribute_name', 'string'); - $attributes->setPrimaryKey(array('product_id', 'attribute_name')); - $attributes->addForeignKeyConstraint('ddc2387_product', array('product_id'), array('product_id')); - - $metadata = $this->convertToClassMetadata(array($product, $attributes), array()); - - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $metadata['Ddc2387Attributes']->generatorType); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_AUTO, $metadata['Ddc2387Product']->generatorType); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php deleted file mode 100755 index c8b85f24fc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php +++ /dev/null @@ -1,72 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testIssue() - { - $em = $this->_em; - $uow = $em->getUnitOfWork(); - - $originalArticle = new CmsArticle(); - $originalUser = new CmsUser(); - - $originalArticle->topic = 'Unit Test'; - $originalArticle->text = 'How to write a test'; - - $originalUser->name = 'Doctrine Bot'; - $originalUser->username = 'DoctrineBot'; - $originalUser->status = 'active'; - - $originalUser->addArticle($originalArticle); - - $em->persist($originalUser); - $em->persist($originalArticle); - $em->flush(); - $em->clear(); - - $article = $em->find('Doctrine\Tests\Models\CMS\CmsArticle', $originalArticle->id); - $user = new CmsUser(); - - $user->name = 'Doctrine Bot 2.0'; - $user->username = 'BotDoctrine2'; - $user->status = 'new'; - - $article->setAuthor($user); - - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalArticle)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalUser)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($article)); - $this->assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); - - $em->detach($user); - $em->detach($article); - - $userMerged = $em->merge($user); - $articleMerged = $em->merge($article); - - $this->assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($article)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($userMerged)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($articleMerged)); - - $this->assertNotSame($user, $userMerged); - $this->assertNotSame($article, $articleMerged); - $this->assertNotSame($userMerged, $articleMerged->user); - $this->assertSame($user, $articleMerged->user); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php deleted file mode 100755 index 0d766eaa09..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ /dev/null @@ -1,142 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Super'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class1'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class2'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class3'), - )); - } - - /** - * @group DDC-258 - */ - public function testIssue() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $c1 = new DDC258Class1(); - $c1->title = "Foo"; - $c1->description = "Foo"; - - $c2 = new DDC258Class2(); - $c2->title = "Bar"; - $c2->description = "Bar"; - $c2->text = "Bar"; - - $c3 = new DDC258Class3(); - $c3->apples = "Baz"; - $c3->bananas = "Baz"; - - $this->_em->persist($c1); - $this->_em->persist($c2); - $this->_em->persist($c3); - $this->_em->flush(); - $this->_em->clear(); - - $e2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC258Super', $c2->id); - - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC258Class2', $e2); - $this->assertEquals('Bar', $e2->title); - $this->assertEquals('Bar', $e2->description); - $this->assertEquals('Bar', $e2->text); - - $all = $this->_em->getRepository(__NAMESPACE__.'\DDC258Super')->findAll(); - - foreach ($all as $obj) { - if ($obj instanceof DDC258Class1) { - $this->assertEquals('Foo', $obj->title); - $this->assertEquals('Foo', $obj->description); - } else if ($obj instanceof DDC258Class2) { - $this->assertTrue($e2 === $obj); - $this->assertEquals('Bar', $obj->title); - $this->assertEquals('Bar', $obj->description); - $this->assertEquals('Bar', $obj->text); - } else if ($obj instanceof DDC258Class3) { - $this->assertEquals('Baz', $obj->apples); - $this->assertEquals('Baz', $obj->bananas); - } else { - $this->fail('Instance of DDC258Class1, DDC258Class2 or DDC258Class3 expected.'); - } - } - } -} - -/** - * @Entity - * @Table(name="DDC258Super") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"class1" = "DDC258Class1", "class2" = "DDC258Class2", "class3"="DDC258Class3"}) - */ -abstract class DDC258Super -{ - /** - * @Id @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; -} - -/** - * @Entity - */ -class DDC258Class1 extends DDC258Super -{ - /** - * @Column(name="title", type="string", length=150) - */ - public $title; - - /** - * @Column(name="content", type="string", length=500) - */ - public $description; -} - -/** - * @Entity - */ -class DDC258Class2 extends DDC258Super -{ - /** - * @Column(name="title", type="string", length=150) - */ - public $title; - - /** - * @Column(name="content", type="string", length=500) - */ - public $description; - - /** - * @Column(name="text", type="text") - */ - public $text; -} - -/** - * An extra class to demonstrate why title and description aren't in Super - * - * @Entity - */ -class DDC258Class3 extends DDC258Super -{ - /** - * @Column(name="title", type="string", length=150) - */ - public $apples; - - /** - * @Column(name="content", type="string", length=500) - */ - public $bananas; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php deleted file mode 100755 index 6d41ea8d81..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php +++ /dev/null @@ -1,133 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC279EntityXAbstract'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC279EntityX'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC279EntityY'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC279EntityZ'), - )); - } - - /** - * @group DDC-279 - */ - public function testDDC279() - { - $x = new DDC279EntityX(); - $y = new DDC279EntityY(); - $z = new DDC279EntityZ(); - - $x->data = 'X'; - $y->data = 'Y'; - $z->data = 'Z'; - - $x->y = $y; - $y->z = $z; - - $this->_em->persist($x); - $this->_em->persist($y); - $this->_em->persist($z); - - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery( - 'SELECT x, y, z FROM Doctrine\Tests\ORM\Functional\Ticket\DDC279EntityX x '. - 'INNER JOIN x.y y INNER JOIN y.z z WHERE x.id = ?1' - )->setParameter(1, $x->id); - - $result = $query->getResult(); - - $expected1 = 'Y'; - $expected2 = 'Z'; - - $this->assertEquals(1, count($result)); - - $this->assertEquals($expected1, $result[0]->y->data); - $this->assertEquals($expected2, $result[0]->y->z->data); - } -} - - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"DDC279EntityX" = "DDC279EntityX"}) - */ -abstract class DDC279EntityXAbstract -{ - /** - * @Id - * @GeneratedValue - * @Column(name="id", type="integer") - */ - public $id; - - /** - * @column(type="string") - */ - public $data; - -} - -/** - * @Entity - */ -class DDC279EntityX extends DDC279EntityXAbstract -{ - /** - * @OneToOne(targetEntity="DDC279EntityY") - * @JoinColumn(name="y_id", referencedColumnName="id") - */ - public $y; -} - -/** - * @Entity - */ -class DDC279EntityY -{ - /** - * @Id @GeneratedValue - * @Column(name="id", type="integer") - */ - public $id; - - /** - * @column(type="string") - */ - public $data; - - /** - * @OneToOne(targetEntity="DDC279EntityZ") - * @JoinColumn(name="z_id", referencedColumnName="id") - */ - public $z; -} - -/** - * @Entity - */ -class DDC279EntityZ -{ - /** - * @Id @GeneratedValue - * @Column(name="id", type="integer") - */ - public $id; - - /** - * @column(type="string") - */ - public $data; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php deleted file mode 100755 index 325ce8d756..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php +++ /dev/null @@ -1,73 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC309Country'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC309User'), - )); - } - - public function testTwoIterateHydrations() - { - $c1 = new DDC309Country(); - $c2 = new DDC309Country(); - $u1 = new DDC309User(); - $u2 = new DDC309User(); - - $this->_em->persist($c1); - $this->_em->persist($c2); - $this->_em->persist($u1); - $this->_em->persist($u2); - $this->_em->flush(); - $this->_em->clear(); - - $q = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309Country c')->iterate(); - $c = $q->next(); - - $this->assertEquals(1, $c[0]->id); - - $r = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309User u')->iterate(); - $u = $r->next(); // This line breaks - - $this->assertEquals(1, $u[0]->id); - - $c = $q->next(); - $u = $r->next(); - - $this->assertEquals(2, $c[0]->id); - $this->assertEquals(2, $u[0]->id); - } -} - -/** - * @Entity - */ -class DDC309Country -{ - /** - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue - */ - public $id; -} - -/** - * @Entity - */ -class DDC309User -{ - /** - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue - */ - public $id; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php deleted file mode 100755 index 2db32b9b8a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -class DDC331Test extends \Doctrine\Tests\OrmFunctionalTestCase -{ - protected function setUp() { - $this->useModelSet('company'); - parent::setUp(); - } - - /** - * @group DDC-331 - */ - public function testSelectFieldOnRootEntity() - { - $q = $this->_em->createQuery('SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e'); - $this->assertEquals( - strtolower('SELECT c0_.name AS name0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id'), - strtolower($q->getSql()) - ); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php deleted file mode 100755 index 757b5ab0b9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ /dev/null @@ -1,157 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC345User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC345Group'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC345Membership'), - )); - } - - public function testTwoIterateHydrations() - { - // Create User - $user = new DDC345User; - $user->name = 'Test User'; - $this->_em->persist($user); // $em->flush() does not change much here - - // Create Group - $group = new DDC345Group; - $group->name = 'Test Group'; - $this->_em->persist($group); // $em->flush() does not change much here - - $membership = new DDC345Membership; - $membership->group = $group; - $membership->user = $user; - $membership->state = 'active'; - - //$this->_em->persist($membership); // COMMENT OUT TO SEE BUG - /* - This should be not necessary, but without, its PrePersist is called twice, - $membership seems to be persisted twice, but all properties but the - ones set by LifecycleCallbacks are deleted. - */ - - $user->Memberships->add($membership); - $group->Memberships->add($membership); - - $this->_em->flush(); - - $this->assertEquals(1, $membership->prePersistCallCount); - $this->assertEquals(0, $membership->preUpdateCallCount); - $this->assertInstanceOf('DateTime', $membership->updated); - } -} - -/** - * @Entity - */ -class DDC345User -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** @Column(type="string") */ - public $name; - - /** @OneToMany(targetEntity="DDC345Membership", mappedBy="user", cascade={"persist"}) */ - public $Memberships; - - public function __construct() - { - $this->Memberships = new \Doctrine\Common\Collections\ArrayCollection; - } -} - -/** - * @Entity - */ -class DDC345Group -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** @Column(type="string") */ - public $name; - - /** @OneToMany(targetEntity="DDC345Membership", mappedBy="group", cascade={"persist"}) */ - public $Memberships; - - - public function __construct() - { - $this->Memberships = new \Doctrine\Common\Collections\ArrayCollection; - } -} - -/** - * @Entity - * @HasLifecycleCallbacks - * @Table(name="ddc345_memberships", uniqueConstraints={ - * @UniqueConstraint(name="ddc345_memship_fks", columns={"user_id","group_id"}) - * }) - */ -class DDC345Membership -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** - * @OneToOne(targetEntity="DDC345User", inversedBy="Memberships") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) - */ - public $user; - - /** - * @OneToOne(targetEntity="DDC345Group", inversedBy="Memberships") - * @JoinColumn(name="group_id", referencedColumnName="id", nullable=false) - */ - public $group; - - /** @Column(type="string") */ - public $state; - - /** @Column(type="datetime") */ - public $updated; - - public $prePersistCallCount = 0; - public $preUpdateCallCount = 0; - - /** @PrePersist */ - public function doStuffOnPrePersist() - { - //echo "***** PrePersist\n"; - ++$this->prePersistCallCount; - $this->updated = new \DateTime; - } - - /** @PreUpdate */ - public function doStuffOnPreUpdate() - { - //echo "***** PreUpdate\n"; - ++$this->preUpdateCallCount; - $this->updated = new \DateTime; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php deleted file mode 100755 index df783593aa..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ /dev/null @@ -1,150 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC353File'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC353Picture'), - )); - } catch(\Exception $ignored) {} - } - - public function testWorkingCase() - { - $file = new DDC353File; - - $picture = new DDC353Picture; - $picture->setFile($file); - - $em = $this->_em; - $em->persist($picture); - $em->flush(); - $em->clear(); - - $fileId = $file->getFileId(); - $this->assertTrue($fileId > 0); - - $file = $em->getReference('Doctrine\Tests\ORM\Functional\Ticket\DDC353File', $fileId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($file), "Reference Proxy should be marked MANAGED."); - - $picture = $em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC353Picture', $picture->getPictureId()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), "Lazy Proxy should be marked MANAGED."); - - $em->remove($picture); - $em->flush(); - } - - public function testFailingCase() - { - $file = new DDC353File; - - $picture = new DDC353Picture; - $picture->setFile($file); - - $em = $this->_em; - $em->persist($picture); - $em->flush(); - $em->clear(); - - $fileId = $file->getFileId(); - $pictureId = $picture->getPictureId(); - - $this->assertTrue($fileId > 0); - - $picture = $em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC353Picture', $pictureId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), "Lazy Proxy should be marked MANAGED."); - - $em->remove($picture); - $em->flush(); - } -} - -/** - * @Entity - */ -class DDC353Picture -{ - /** - * @Column(name="picture_id", type="integer") - * @Id @GeneratedValue - */ - private $pictureId; - - /** - * @ManyToOne(targetEntity="DDC353File", cascade={"persist", "remove"}) - * @JoinColumns({ - * @JoinColumn(name="file_id", referencedColumnName="file_id") - * }) - */ - private $file; - - /** - * Get pictureId - */ - public function getPictureId() - { - return $this->pictureId; - } - - /** - * Set product - */ - public function setProduct($value) - { - $this->product = $value; - } - - /** - * Get product - */ - public function getProduct() - { - return $this->product; - } - - /** - * Set file - */ - public function setFile($value) - { - $this->file = $value; - } - - /** - * Get file - */ - public function getFile() - { - return $this->file; - } -} - -/** - * @Entity - */ -class DDC353File -{ - /** - * @Column(name="file_id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - public $fileId; - - /** - * Get fileId - */ - public function getFileId() - { - return $this->fileId; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php deleted file mode 100755 index 2a99519cb7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ /dev/null @@ -1,72 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Parent'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Child') - )); - } - - public function testIssue() - { - $parent = new DDC371Parent; - $parent->data = 'parent'; - $parent->children = new \Doctrine\Common\Collections\ArrayCollection; - - $child = new DDC371Child; - $child->data = 'child'; - - $child->parent = $parent; - $parent->children->add($child); - - $this->_em->persist($parent); - $this->_em->persist($child); - - $this->_em->flush(); - $this->_em->clear(); - - $children = $this->_em->createQuery('select c,p from '.__NAMESPACE__.'\DDC371Child c ' - . 'left join c.parent p where c.id = 1 and p.id = 1') - ->setHint(Query::HINT_REFRESH, true) - ->getResult(); - - $this->assertEquals(1, count($children)); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $children[0]->parent); - $this->assertFalse($children[0]->parent->children->isInitialized()); - $this->assertEquals(0, $children[0]->parent->children->unwrap()->count()); - } -} - -/** @Entity */ -class DDC371Child { - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - /** @Column(type="string") */ - public $data; - /** @ManyToOne(targetEntity="DDC371Parent", inversedBy="children") @JoinColumn(name="parentId") */ - public $parent; -} - -/** @Entity */ -class DDC371Parent { - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - /** @Column(type="string") */ - public $data; - /** @OneToMany(targetEntity="DDC371Child", mappedBy="parent") */ - public $children; -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php deleted file mode 100755 index 9b47bc842b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php +++ /dev/null @@ -1,63 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC381Entity'), - )); - } catch(\Exception $e) { - - } - } - - public function testCallUnserializedProxyMethods() - { - $entity = new DDC381Entity(); - - $this->_em->persist($entity); - $this->_em->flush(); - $this->_em->clear(); - $persistedId = $entity->getId(); - - $entity = $this->_em->getReference('Doctrine\Tests\ORM\Functional\Ticket\DDC381Entity', $persistedId); - - // explicitly load proxy (getId() does not trigger reload of proxy) - $id = $entity->getOtherMethod(); - - $data = serialize($entity); - $entity = unserialize($data); - - $this->assertEquals($persistedId, $entity->getId()); - } -} - -/** - * @Entity - */ -class DDC381Entity -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - protected $id; - - public function getId() - { - return $this->id; - } - - public function getOtherMethod() - { - - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php deleted file mode 100755 index 3a6dbdb4c3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ /dev/null @@ -1,75 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Guest'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Customer'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Contact') - )); - } - - /** - * @group DDC-422 - */ - public function testIssue() - { - $customer = new DDC422Customer; - $this->_em->persist($customer); - $this->_em->flush(); - $this->_em->clear(); - - $customer = $this->_em->find(get_class($customer), $customer->id); - - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $customer->contacts); - $this->assertFalse($customer->contacts->isInitialized()); - $contact = new DDC422Contact; - $customer->contacts->add($contact); - $this->assertTrue($customer->contacts->isDirty()); - $this->assertFalse($customer->contacts->isInitialized()); - $this->_em->flush(); - - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select count(*) from ddc422_customers_contacts")); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"guest" = "DDC422Guest", "customer" = "DDC422Customer"}) - */ -class DDC422Guest { - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; -} - -/** @Entity */ -class DDC422Customer extends DDC422Guest { - /** - * @ManyToMany(targetEntity="DDC422Contact", cascade={"persist","remove"}) - * @JoinTable(name="ddc422_customers_contacts", - * joinColumns={@JoinColumn(name="customer_id", referencedColumnName="id", onDelete="cascade" )}, - * inverseJoinColumns={@JoinColumn(name="contact_id", referencedColumnName="id", onDelete="cascade" )} - * ) - */ - public $contacts; - - public function __construct() { - $this->contacts = new \Doctrine\Common\Collections\ArrayCollection; - } -} - -/** @Entity */ -class DDC422Contact { - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php deleted file mode 100755 index 084da5623c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php +++ /dev/null @@ -1,43 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC425Entity'), - //$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC425Other') - )); - } - - /** - * @group DDC-425 - */ - public function testIssue() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $num = $this->_em->createQuery('DELETE '.__NAMESPACE__.'\DDC425Entity e WHERE e.someDatetimeField > ?1') - ->setParameter(1, new DateTime, Type::DATETIME) - ->getResult(); - $this->assertEquals(0, $num); - } -} - -/** @Entity */ -class DDC425Entity { - /** - * @Id @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** @Column(type="datetime") */ - public $someDatetimeField; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php deleted file mode 100755 index 2b374a85d4..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ /dev/null @@ -1,216 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - - /** - * @group DDC-440 - */ - public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations() - { - - - /* The key of the problem is that the first phone is fetched via two association, main_phone and phones. - * - * You will notice that the original_entity_datas are not loaded for the first phone. (They are for the second) - * - * In the Client entity definition, if you define the main_phone relation after the phones relation, both assertions pass. - * (for the sake or this test, I defined the main_phone relation before the phones relation) - * - */ - - //Initialize some data - $client = new DDC440Client; - $client->setName('Client1'); - - $phone = new DDC440Phone; - $phone->setNumber('418 111-1111'); - $phone->setClient($client); - - $phone2 = new DDC440Phone; - $phone2->setNumber('418 222-2222'); - $phone2->setClient($client); - - $client->setMainPhone($phone); - - $this->_em->persist($client); - $this->_em->flush(); - $id = $client->getId(); - $this->_em->clear(); - - $uw = $this->_em->getUnitOfWork(); - $client = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client', $id); - $clientPhones = $client->getPhones(); - $p1 = $clientPhones[0]; - $p2 = $clientPhones[1]; - - // Test the first phone. The assertion actually failed because original entity data is not set properly. - // This was because it is also set as MainPhone and that one is created as a proxy, not the - // original object when the find on Client is called. However loading proxies did not work correctly. - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p1); - $originalData = $uw->getOriginalEntityData($p1); - $this->assertEquals($phone->getNumber(), $originalData['number']); - - - //If you comment out previous test, this one should pass - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p2); - $originalData = $uw->getOriginalEntityData($p2); - $this->assertEquals($phone2->getNumber(), $originalData['number']); - } - -} - -/** - * @Entity - * @Table(name="phone") - */ -class DDC440Phone -{ - - /** - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - protected $id; - /** - * @ManyToOne(targetEntity="DDC440Client",inversedBy="phones") - * @JoinColumns({ - * @JoinColumn(name="client_id", referencedColumnName="id") - * }) - */ - protected $client; - /** - * @Column(name="phonenumber", type="string") - */ - protected $number; - - public function setNumber($value) - { - $this->number = $value; - } - - public function getNumber() - { - return $this->number; - } - - public function setClient(DDC440Client $value, $update_inverse=true) - { - $this->client = $value; - if ($update_inverse) { - $value->addPhone($this); - } - } - - public function getClient() - { - return $this->client; - } - - public function getId() - { - return $this->id; - } - - public function setId($value) - { - $this->id = $value; - } - -} - -/** - * @Entity - * @Table(name="client") - */ -class DDC440Client -{ - - /** - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - protected $id; - /** - * @OneToOne(targetEntity="DDC440Phone", fetch="EAGER") - * @JoinColumns({ - * @JoinColumn(name="main_phone_id", referencedColumnName="id",onDelete="SET NULL") - * }) - */ - protected $main_phone; - /** - * @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER") - * @orderBy({"number"="ASC"}) - */ - protected $phones; - /** - * @Column(name="name", type="string") - */ - protected $name; - - public function __construct() - { - - } - - public function setName($value) - { - $this->name = $value; - } - - public function getName() - { - return $this->name; - } - - public function addPhone(DDC440Phone $value) - { - $this->phones[] = $value; - $value->setClient($this, false); - } - - public function getPhones() - { - return $this->phones; - } - - public function setMainPhone(DDC440Phone $value) - { - $this->main_phone = $value; - } - - public function getMainPhone() - { - return $this->main_phone; - } - - public function getId() - { - return $this->id; - } - - public function setId($value) - { - $this->id = $value; - } - -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php deleted file mode 100755 index d89e67a2f3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php +++ /dev/null @@ -1,77 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC444User'), - )); - } - - public function testExplicitPolicy() - { - $classname = __NAMESPACE__ . "\DDC444User"; - - $u = new $classname; - $u->name = "Initial value"; - - $this->_em->persist($u); - $this->_em->flush(); - $this->_em->clear(); - - $q = $this->_em->createQuery("SELECT u FROM $classname u"); - $u = $q->getSingleResult(); - $this->assertEquals("Initial value", $u->name); - - $u->name = "Modified value"; - - // This should be NOOP as the change hasn't been persisted - $this->_em->flush(); - $this->_em->clear(); - - - $u = $this->_em->createQuery("SELECT u FROM $classname u"); - $u = $q->getSingleResult(); - - $this->assertEquals("Initial value", $u->name); - - - $u->name = "Modified value"; - $this->_em->persist($u); - // Now we however persisted it, and this should have updated our friend - $this->_em->flush(); - - $q = $this->_em->createQuery("SELECT u FROM $classname u"); - $u = $q->getSingleResult(); - - $this->assertEquals("Modified value", $u->name); - } -} - - -/** - * @Entity @Table(name="ddc444") - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ -class DDC444User -{ - /** - * @Id @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @Column(name="name", type="string") - */ - public $name; -} - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php deleted file mode 100755 index 4ea830863e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ /dev/null @@ -1,74 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC448MainTable'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC448ConnectedClass'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC448SubTable'), - )); - } - - public function testIssue() - { - $q = $this->_em->createQuery("select b from ".__NAMESPACE__."\\DDC448SubTable b where b.connectedClassId = ?1"); - $this->assertEquals( - strtolower('SELECT d0_.id AS id0, d0_.discr AS discr1, d0_.connectedClassId AS connectedClassId2 FROM SubTable s1_ INNER JOIN DDC448MainTable d0_ ON s1_.id = d0_.id WHERE d0_.connectedClassId = ?'), - strtolower($q->getSQL()) - ); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="smallint") - * @DiscriminatorMap({ - * "0" = "DDC448MainTable", - * "1" = "DDC448SubTable" - * }) - */ -class DDC448MainTable -{ - /** - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @ManyToOne(targetEntity="DDC448ConnectedClass", cascade={"all"}, fetch="EAGER") - * @JoinColumn(name="connectedClassId", referencedColumnName="id", onDelete="CASCADE", nullable=true) - */ - private $connectedClassId; -} - -/** - * @Entity - * @Table(name="connectedClass") - * @HasLifecycleCallbacks - */ -class DDC448ConnectedClass -{ - /** - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - protected $id; // connected with DDC448MainTable -} - -/** - * @Entity - * @Table(name="SubTable") - */ -class DDC448SubTable extends DDC448MainTable -{ -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php deleted file mode 100755 index 9e8d58be92..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php +++ /dev/null @@ -1,72 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Customer'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Distributor'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Contact') - )); - } - - public function testIssue() - { - $q = $this->_em->createQuery("select u, c.data from ".__NAMESPACE__."\\DDC493Distributor u JOIN u.contact c"); - $this->assertEquals( - strtolower('SELECT d0_.id AS id0, d1_.data AS data1, d0_.discr AS discr2, d0_.contact AS contact3 FROM DDC493Distributor d2_ INNER JOIN DDC493Customer d0_ ON d2_.id = d0_.id INNER JOIN DDC493Contact d1_ ON d0_.contact = d1_.id'), - strtolower($q->getSQL()) - ); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"distributor" = "DDC493Distributor", "customer" = "DDC493Customer"}) - */ -class DDC493Customer { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - /** - * @OneToOne(targetEntity="DDC493Contact", cascade={"remove","persist"}) - * @JoinColumn(name="contact", referencedColumnName="id") - */ - public $contact; - -} - -/** - * @Entity - */ -class DDC493Distributor extends DDC493Customer { -} - -/** - * @Entity - */ -class DDC493Contact -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - /** @Column(type="string") */ - public $data; -} - - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php deleted file mode 100755 index 22897eed98..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php +++ /dev/null @@ -1,124 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testMergeUnitializedManyToManyAndOneToManyCollections() - { - // Create User - $user = $this->createAndPersistUser(); - $this->_em->flush(); - - $this->assertTrue($this->_em->contains($user)); - $this->_em->clear(); - $this->assertFalse($this->_em->contains($user)); - - unset($user); - - // Reload User from DB *without* any associations (i.e. an uninitialized PersistantCollection) - $userReloaded = $this->loadUserFromEntityManager(); - - $this->assertTrue($this->_em->contains($userReloaded)); - $this->_em->clear(); - $this->assertFalse($this->_em->contains($userReloaded)); - - // freeze and unfreeze - $userClone = unserialize(serialize($userReloaded)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $userClone); - - // detached user can't know about his phonenumbers - $this->assertEquals(0, count($userClone->getPhonenumbers())); - $this->assertFalse($userClone->getPhonenumbers()->isInitialized(), "User::phonenumbers should not be marked initialized."); - - // detached user can't know about his groups either - $this->assertEquals(0, count($userClone->getGroups())); - $this->assertFalse($userClone->getGroups()->isInitialized(), "User::groups should not be marked initialized."); - - // Merge back and flush - $userClone = $this->_em->merge($userClone); - - // Back in managed world I would expect to have my phonenumbers back but they aren't! - // Remember I didn't touch (and propably didn't need) them at all while in detached mode. - $this->assertEquals(4, count($userClone->getPhonenumbers()), 'Phonenumbers are not available anymore'); - - // This works fine as long as cmUser::groups doesn't cascade "merge" - $this->assertEquals(2, count($userClone->getGroups())); - - $this->_em->flush(); - $this->_em->clear(); - - $this->assertFalse($this->_em->contains($userClone)); - - // Reload user from DB - $userFromEntityManager = $this->loadUserFromEntityManager(); - - //Strange: Now the phonenumbers are back again - $this->assertEquals(4, count($userFromEntityManager->getPhonenumbers())); - - // This works fine as long as cmUser::groups doesn't cascade "merge" - // Otherwise group memberships are physically deleted now! - $this->assertEquals(2, count($userClone->getGroups())); - } - - protected function createAndPersistUser() - { - $user = new CmsUser(); - $user->name = 'Luka'; - $user->username = 'lukacho'; - $user->status = 'developer'; - - foreach(array(1111,2222,3333,4444) as $number) { - $phone = new CmsPhonenumber; - $phone->phonenumber = $number; - $user->addPhonenumber($phone); - } - - foreach(array('Moshers', 'Headbangers') as $groupName) { - $group = new CmsGroup; - $group->setName($groupName); - $user->addGroup($group); - } - - $this->_em->persist($user); - - return $user; - } - - /** - * @return Doctrine\Tests\Models\CMS\CmsUser - */ - protected function loadUserFromEntityManager() - { - return $this->_em - ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name like :name') - ->setParameter('name', 'Luka') - ->getSingleResult(); - } - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php deleted file mode 100755 index 97245efa70..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php +++ /dev/null @@ -1,94 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512Customer'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512OfferItem'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512Item'), - )); - } - - public function testIssue() - { - $customer1 = new DDC512Customer(); - $item = new DDC512OfferItem(); - $customer1->item = $item; - $this->_em->persist($customer1); - - $customer2 = new DDC512Customer(); - $this->_em->persist($customer2); - - $this->_em->flush(); - $this->_em->clear(); - - $q = $this->_em->createQuery("select u,i from ".__NAMESPACE__."\\DDC512Customer u left join u.item i"); - $result = $q->getResult(); - - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC512Customer', $result[0]); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC512Customer', $result[1]); - if ($result[0]->id == $customer1->id) { - $this->assertInstanceOf(__NAMESPACE__ . '\DDC512OfferItem', $result[0]->item); - $this->assertEquals($item->id, $result[0]->item->id); - $this->assertNull($result[1]->item); - } else { - $this->assertInstanceOf(__NAMESPACE__ . '\DDC512OfferItem', $result[1]->item); - $this->assertNull($result[0]->item); - } - } -} - -/** - * @Entity - */ -class DDC512Customer { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * NOTE that we can currently not name the join column the same as the field - * (item = item), this currently confuses Doctrine. - * - * @OneToOne(targetEntity="DDC512OfferItem", cascade={"remove","persist"}) - * @JoinColumn(name="item_id", referencedColumnName="id") - */ - public $item; -} - -/** - * @Entity - */ -class DDC512OfferItem extends DDC512Item -{ -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"item" = "DDC512Item", "offerItem" = "DDC512OfferItem"}) - */ -class DDC512Item -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; -} - - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php deleted file mode 100755 index b71d674cc0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php +++ /dev/null @@ -1,74 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC513OfferItem'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC513Item'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC513Price'), - )); - } - - public function testIssue() - { - $q = $this->_em->createQuery("select u from ".__NAMESPACE__."\\DDC513OfferItem u left join u.price p"); - $this->assertEquals( - strtolower('SELECT d0_.id AS id0, d0_.discr AS discr1, d0_.price AS price2 FROM DDC513OfferItem d1_ INNER JOIN DDC513Item d0_ ON d1_.id = d0_.id LEFT JOIN DDC513Price d2_ ON d0_.price = d2_.id'), - strtolower($q->getSQL()) - ); - } -} - -/** - * @Entity - */ -class DDC513OfferItem extends DDC513Item -{ -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"item" = "DDC513Item", "offerItem" = "DDC513OfferItem"}) - */ -class DDC513Item -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @OneToOne(targetEntity="DDC513Price", cascade={"remove","persist"}) - * @JoinColumn(name="price", referencedColumnName="id") - */ - public $price; -} - -/** - * @Entity - */ -class DDC513Price { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** @Column(type="string") */ - public $data; -} - - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php deleted file mode 100755 index 2a34506664..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php +++ /dev/null @@ -1,36 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testMergeWithRelatedNew() - { - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); - $article->text = "foo"; - $article->topic = "bar"; - - $this->_em->persist($article); - $this->_em->flush(); - $this->_em->detach($article); - $this->_em->clear(); - - $user = new \Doctrine\Tests\Models\CMS\CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin Eberlei"; - $user->status = "active"; - $article->user = $user; - - $this->_em->persist($user); - $managedArticle = $this->_em->merge($article); - - $this->assertSame($article->user, $managedArticle->user); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php deleted file mode 100755 index f029e95e95..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ /dev/null @@ -1,121 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522Customer'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522Cart'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522ForeignKeyTest') - )); - } catch(\Exception $e) { - - } - } - - /** - * @group DDC-522 - */ - public function testJoinColumnWithSameNameAsAssociationField() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $cust = new DDC522Customer; - $cust->name = "name"; - $cart = new DDC522Cart; - $cart->total = 0; - $cust->cart = $cart; - $cart->customer = $cust; - $this->_em->persist($cust); - $this->_em->persist($cart); - $this->_em->flush(); - - $this->_em->clear(); - - $r = $this->_em->createQuery("select ca,c from ".get_class($cart)." ca join ca.customer c") - ->getResult(); - - $this->assertInstanceOf(__NAMESPACE__ . '\DDC522Cart', $r[0]); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC522Customer', $r[0]->customer); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $r[0]->customer); - $this->assertEquals('name', $r[0]->customer->name); - - $fkt = new DDC522ForeignKeyTest(); - $fkt->cartId = $r[0]->id; // ignored for persistence - $fkt->cart = $r[0]; // must be set properly - $this->_em->persist($fkt); - $this->_em->flush(); - $this->_em->clear(); - - $fkt2 = $this->_em->find(get_class($fkt), $fkt->id); - $this->assertEquals($fkt->cart->id, $fkt2->cartId); - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $fkt2->cart); - $this->assertFalse($fkt2->cart->__isInitialized__); - } - - /** - * @group DDC-522 - * @group DDC-762 - */ - public function testJoinColumnWithNullSameNameAssociationField() - { - $fkCust = new DDC522ForeignKeyTest; - $fkCust->name = "name"; - $fkCust->cart = null; - - $this->_em->persist($fkCust); - $this->_em->flush(); - $this->_em->clear(); - - $newCust = $this->_em->find(get_class($fkCust), $fkCust->id); - } -} - -/** @Entity */ -class DDC522Customer { - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @Column */ - public $name; - /** @OneToOne(targetEntity="DDC522Cart", mappedBy="customer") */ - public $cart; -} - -/** @Entity */ -class DDC522Cart { - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @Column(type="integer") */ - public $total; - /** - * @OneToOne(targetEntity="DDC522Customer", inversedBy="cart") - * @JoinColumn(name="customer", referencedColumnName="id") - */ - public $customer; -} - -/** @Entity */ -class DDC522ForeignKeyTest { - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - /** @Column(type="integer", name="cart_id", nullable=true) */ - public $cartId; - /** - * @OneToOne(targetEntity="DDC522Cart") - * @JoinColumn(name="cart_id", referencedColumnName="id") - */ - public $cart; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php deleted file mode 100755 index 5e22c2cbe6..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php +++ /dev/null @@ -1,88 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC531Item'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC531SubItem'), - )); - } - - public function testIssue() - { - $item1 = new DDC531Item; - $item2 = new DDC531Item; - $item2->parent = $item1; - $item1->getChildren()->add($item2); - $this->_em->persist($item1); - $this->_em->persist($item2); - $this->_em->flush(); - $this->_em->clear(); - - $item3 = $this->_em->find(__NAMESPACE__ . '\DDC531Item', $item2->id); // Load child item first (id 2) - // parent will already be loaded, cannot be lazy because it has mapped subclasses and we would not - // know which proxy type to put in. - $this->assertInstanceOf(__NAMESPACE__ . '\DDC531Item', $item3->parent); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $item3->parent); - $item4 = $this->_em->find(__NAMESPACE__ . '\DDC531Item', $item1->id); // Load parent item (id 1) - $this->assertNull($item4->parent); - $this->assertNotNull($item4->getChildren()); - $this->assertTrue($item4->getChildren()->contains($item3)); // lazy-loads children - } -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="integer") - * @DiscriminatorMap({"0" = "DDC531Item", "1" = "DDC531SubItem"}) - */ -class DDC531Item -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @OneToMany(targetEntity="DDC531Item", mappedBy="parent") - */ - protected $children; - - /** - * @ManyToOne(targetEntity="DDC531Item", inversedBy="children") - * @JoinColumn(name="parentId", referencedColumnName="id") - */ - public $parent; - - public function __construct() - { - $this->children = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function getParent() - { - return $this->parent; - } - - public function getChildren() - { - return $this->children; - } -} - -/** - * @Entity - */ -class DDC531SubItem extends DDC531Item -{ -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php deleted file mode 100755 index 3f899d7867..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php +++ /dev/null @@ -1,48 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC588Site'), - )); - } - - public function testIssue() - { - $site = new DDC588Site('Foo'); - - $this->_em->persist($site); - $this->_em->flush(); - // Following should not result in exception - $this->_em->refresh($site); - } -} - -/** - * @Entity - */ -class DDC588Site -{ - /** - * @Id - * @Column(type="integer", name="site_id") - * @GeneratedValue - */ - public $id; - - /** - * @Column(type="string", length=45) - */ - protected $name = null; - - public function __construct($name = '') - { - $this->name = $name; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php deleted file mode 100755 index b342796ccb..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ /dev/null @@ -1,132 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - try { - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC599Item'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC599Subitem'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC599Child'), - )); - } catch (\Exception $ignored) {} - } - - public function testCascadeRemoveOnInheritanceHierachy() - { - $item = new DDC599Subitem; - $item->elem = "foo"; - $child = new DDC599Child; - $child->parent = $item; - $item->getChildren()->add($child); - $this->_em->persist($item); - $this->_em->persist($child); - $this->_em->flush(); - $this->_em->clear(); - - $item = $this->_em->find(__NAMESPACE__ . '\DDC599Item', $item->id); - - $this->_em->remove($item); - $this->_em->flush(); // Should not fail - - $this->assertFalse($this->_em->contains($item)); - $children = $item->getChildren(); - $this->assertFalse($this->_em->contains($children[0])); - - $this->_em->clear(); - - - $item2 = new DDC599Subitem; - $item2->elem = "bar"; - $this->_em->persist($item2); - $this->_em->flush(); - - $child2 = new DDC599Child; - $child2->parent = $item2; - $item2->getChildren()->add($child2); - $this->_em->persist($child2); - $this->_em->flush(); - - $this->_em->remove($item2); - $this->_em->flush(); // should not fail - - $this->assertFalse($this->_em->contains($item)); - $children = $item->getChildren(); - $this->assertFalse($this->_em->contains($children[0])); - } - - public function testCascadeRemoveOnChildren() - { - $class = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC599Subitem'); - - $this->assertArrayHasKey('children', $class->associationMappings); - $this->assertTrue($class->associationMappings['children']['isCascadeRemove']); - } -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="integer") - * @DiscriminatorMap({"0" = "DDC599Item", "1" = "DDC599Subitem"}) - */ -class DDC599Item -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @OneToMany(targetEntity="DDC599Child", mappedBy="parent", cascade={"remove"}) - */ - protected $children; - - public function __construct() - { - $this->children = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function getChildren() - { - return $this->children; - } -} - -/** - * @Entity - */ -class DDC599Subitem extends DDC599Item -{ - /** - * @Column(type="string") - */ - public $elem; -} - -/** - * @Entity - */ -class DDC599Child -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @ManyToOne(targetEntity="DDC599Item", inversedBy="children") - * @JoinColumn(name="parentId", referencedColumnName="id") - */ - public $parent; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php deleted file mode 100755 index b51ed39ba5..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ /dev/null @@ -1,185 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC618Author'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC618Book') - )); - - // Create author 10/Joe with two books 22/JoeA and 20/JoeB - $author = new DDC618Author(); - $author->id = 10; - $author->name = 'Joe'; - $this->_em->persist($author); - - // Create author 11/Alice with two books 21/AliceA and 23/AliceB - $author = new DDC618Author(); - $author->id = 11; - $author->name = 'Alice'; - $author->addBook('In Wonderland'); - $author->addBook('Reloaded'); - $author->addBook('Test'); - - $this->_em->persist($author); - - $this->_em->flush(); - $this->_em->clear(); - } catch(\Exception $e) { - - } - } - - public function testIndexByHydrateObject() - { - $dql = 'SELECT A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A INDEX BY A.name ORDER BY A.name ASC'; - $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT); - - $joe = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', 10); - $alice = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', 11); - - $this->assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); - $this->assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); - } - - public function testIndexByHydrateArray() - { - $dql = 'SELECT A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A INDEX BY A.name ORDER BY A.name ASC'; - $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); - - $joe = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', 10); - $alice = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', 11); - - $this->assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); - $this->assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); - } - - /** - * @group DDC-1018 - */ - public function testIndexByJoin() - { - $dql = 'SELECT A, B FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A '. - 'INNER JOIN A.books B INDEX BY B.title ORDER BY A.name ASC'; - $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT); - - $this->assertEquals(3, count($result[0]->books)); // Alice, Joe doesnt appear because he has no books. - $this->assertEquals('Alice', $result[0]->name); - $this->assertTrue( isset($result[0]->books["In Wonderland"] ), "Indexing by title should have books by title."); - $this->assertTrue( isset($result[0]->books["Reloaded"] ), "Indexing by title should have books by title."); - $this->assertTrue( isset($result[0]->books["Test"] ), "Indexing by title should have books by title."); - - $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); - - $this->assertEquals(3, count($result[0]['books'])); // Alice, Joe doesnt appear because he has no books. - $this->assertEquals('Alice', $result[0]['name']); - $this->assertTrue( isset($result[0]['books']["In Wonderland"] ), "Indexing by title should have books by title."); - $this->assertTrue( isset($result[0]['books']["Reloaded"] ), "Indexing by title should have books by title."); - $this->assertTrue( isset($result[0]['books']["Test"] ), "Indexing by title should have books by title."); - } - - /** - * @group DDC-1018 - */ - public function testIndexByToOneJoinSilentlyIgnored() - { - $dql = 'SELECT B, A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Book B '. - 'INNER JOIN B.author A INDEX BY A.name ORDER BY A.name ASC'; - $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT); - - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC618Book', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', $result[0]->author); - - $dql = 'SELECT B, A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Book B '. - 'INNER JOIN B.author A INDEX BY A.name ORDER BY A.name ASC'; - $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); - - $this->assertEquals("Alice", $result[0]['author']['name']); - } - - /** - * @group DDC-1018 - */ - public function testCombineIndexBy() - { - $dql = 'SELECT A, B FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A INDEX BY A.id '. - 'INNER JOIN A.books B INDEX BY B.title ORDER BY A.name ASC'; - $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT); - - $this->assertArrayHasKey(11, $result); // Alice - - $this->assertEquals(3, count($result[11]->books)); // Alice, Joe doesnt appear because he has no books. - $this->assertEquals('Alice', $result[11]->name); - $this->assertTrue( isset($result[11]->books["In Wonderland"] ), "Indexing by title should have books by title."); - $this->assertTrue( isset($result[11]->books["Reloaded"] ), "Indexing by title should have books by title."); - $this->assertTrue( isset($result[11]->books["Test"] ), "Indexing by title should have books by title."); - } -} - -/** - * @Entity - */ -class DDC618Author -{ - /** - * @Id - * @Column(type="integer") - */ - public $id; - - /** @Column(type="string") */ - public $name; - - /** - * @OneToMany(targetEntity="DDC618Book", mappedBy="author", cascade={"persist"}) - */ - public $books; - - public function __construct() - { - $this->books = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function addBook($title) - { - $book = new DDC618Book($title, $this); - $this->books[] = $book; - } -} - -/** - * @Entity - */ -class DDC618Book -{ - /** - * @Id @GeneratedValue - * @Column(type="integer") - */ - public $id; - - /** @column(type="string") */ - public $title; - - /** @ManyToOne(targetEntity="DDC618Author", inversedBy="books") */ - public $author; - - function __construct($title, $author) - { - $this->title = $title; - $this->author = $author; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php deleted file mode 100755 index 2ec4383256..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php +++ /dev/null @@ -1,102 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC633Patient'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC633Appointment'), - )); - } catch(\Exception $e) { - - } - } - - /** - * @group DDC-633 - * @group DDC-952 - * @group DDC-914 - */ - public function testOneToOneEager() - { - $app = new DDC633Appointment(); - $pat = new DDC633Patient(); - $app->patient = $pat; - $pat->appointment = $app; - - $this->_em->persist($app); - $this->_em->persist($pat); - $this->_em->flush(); - $this->_em->clear(); - - $eagerAppointment = $this->_em->find(__NAMESPACE__ . '\DDC633Appointment', $app->id); - - // Eager loading of one to one leads to fetch-join - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient); - $this->assertTrue($this->_em->contains($eagerAppointment->patient)); - } - - /** - * @group DDC-633 - * @group DDC-952 - */ - public function testDQLDeferredEagerLoad() - { - for ($i = 0; $i < 10; $i++) { - $app = new DDC633Appointment(); - $pat = new DDC633Patient(); - $app->patient = $pat; - $pat->appointment = $app; - - $this->_em->persist($app); - $this->_em->persist($pat); - } - $this->_em->flush(); - $this->_em->clear(); - - $appointments = $this->_em->createQuery("SELECT a FROM " . __NAMESPACE__ . "\DDC633Appointment a")->getResult(); - - foreach ($appointments AS $eagerAppointment) { - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient); - $this->assertTrue($eagerAppointment->patient->__isInitialized__, "Proxy should already be initialized due to eager loading!"); - } - } -} - -/** - * @Entity - */ -class DDC633Appointment -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - - /** - * @OneToOne(targetEntity="DDC633Patient", inversedBy="appointment", fetch="EAGER") - */ - public $patient; - -} - -/** - * @Entity - */ -class DDC633Patient -{ - /** @Id @Column(type="integer") @GeneratedValue */ - public $id; - - /** - * @OneToOne(targetEntity="DDC633Appointment", mappedBy="patient") - */ - public $appointment; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php deleted file mode 100755 index f2bbc2aa94..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ /dev/null @@ -1,82 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC656Entity') - )); - } catch(\Exception $e) { - - } - } - - public function testRecomputeSingleEntityChangeSet_PreservesFieldOrder() - { - $entity = new DDC656Entity(); - $entity->setName('test1'); - $entity->setType('type1'); - $this->_em->persist($entity); - - $this->_em->getUnitOfWork()->computeChangeSet($this->_em->getClassMetadata(get_class($entity)), $entity); - $data1 = $this->_em->getUnitOfWork()->getEntityChangeset($entity); - $entity->setType('type2'); - $this->_em->getUnitOfWork()->recomputeSingleEntityChangeSet($this->_em->getClassMetadata(get_class($entity)), $entity); - $data2 = $this->_em->getUnitOfWork()->getEntityChangeset($entity); - - $this->assertEquals(array_keys($data1), array_keys($data2)); - - $this->_em->flush(); - $this->_em->clear(); - - $persistedEntity = $this->_em->find(get_class($entity), $entity->specificationId); - $this->assertEquals('type2', $persistedEntity->getType()); - $this->assertEquals('test1', $persistedEntity->getName()); - } -} - -/** - * @Entity - */ -class DDC656Entity -{ - /** - * @Column(type="string") - */ - public $name; - - /** - * @Column(type="string") - */ - public $type; - - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $specificationId; - - public function getName() { - return $this->name; - } - - public function setName($name) { - $this->name = $name; - } - - public function getType() { - return $this->type; - } - - public function setType($type) { - $this->type = $type; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php deleted file mode 100755 index 2d4279ba34..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php +++ /dev/null @@ -1,120 +0,0 @@ -useModelSet('generic'); - parent::setUp(); - - $this->loadFixtures(); - } - - public function testEntitySingleResult() - { - $query = $this->_em->createQuery('SELECT d FROM ' . self::NS . '\DateTimeModel d'); - $datetime = $query->setMaxResults(1)->getSingleResult(); - - $this->assertInstanceOf('Doctrine\Tests\Models\Generic\DateTimeModel', $datetime); - - $this->assertInstanceOf('DateTime', $datetime->datetime); - $this->assertInstanceOf('DateTime', $datetime->time); - $this->assertInstanceOf('DateTime', $datetime->date); - } - - public function testScalarResult() - { - $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC'); - $result = $query->getScalarResult(); - - $this->assertCount(2,$result); - - $this->assertContains('11:11:11', $result[0]['time']); - $this->assertContains('2010-01-01', $result[0]['date']); - $this->assertContains('2010-01-01 11:11:11', $result[0]['datetime']); - - $this->assertContains('12:12:12', $result[1]['time']); - $this->assertContains('2010-02-02', $result[1]['date']); - $this->assertContains('2010-02-02 12:12:12', $result[1]['datetime']); - } - - public function testaTicketEntityArrayResult() - { - $query = $this->_em->createQuery('SELECT d FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC'); - $result = $query->getArrayResult(); - - $this->assertCount(2,$result); - - $this->assertInstanceOf('DateTime', $result[0]['datetime']); - $this->assertInstanceOf('DateTime', $result[0]['time']); - $this->assertInstanceOf('DateTime', $result[0]['date']); - - $this->assertInstanceOf('DateTime', $result[1]['datetime']); - $this->assertInstanceOf('DateTime', $result[1]['time']); - $this->assertInstanceOf('DateTime', $result[1]['date']); - } - - public function testTicketSingleResult() - { - $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC'); - $datetime = $query->setMaxResults(1)->getSingleResult(); - - $this->assertTrue(is_array($datetime)); - - $this->assertInstanceOf('DateTime', $datetime['datetime']); - $this->assertInstanceOf('DateTime', $datetime['time']); - $this->assertInstanceOf('DateTime', $datetime['date']); - } - - public function testTicketResult() - { - $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC'); - $result = $query->getResult(); - - $this->assertCount(2,$result); - - $this->assertInstanceOf('DateTime', $result[0]['time']); - $this->assertInstanceOf('DateTime', $result[0]['date']); - $this->assertInstanceOf('DateTime', $result[0]['datetime']); - - $this->assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d G:i:s')); - - $this->assertInstanceOf('DateTime', $result[1]['time']); - $this->assertInstanceOf('DateTime', $result[1]['date']); - $this->assertInstanceOf('DateTime', $result[1]['datetime']); - - $this->assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d G:i:s')); - } - - public function loadFixtures() - { - $timezone = new \DateTimeZone('America/Sao_Paulo'); - - $dateTime1 = new DateTimeModel(); - $dateTime2 = new DateTimeModel(); - - $dateTime1->date = new \DateTime('2010-01-01', $timezone); - $dateTime1->time = new \DateTime('2010-01-01 11:11:11', $timezone); - $dateTime1->datetime= new \DateTime('2010-01-01 11:11:11', $timezone); - - $dateTime2->date = new \DateTime('2010-02-02', $timezone); - $dateTime2->time = new \DateTime('2010-02-02 12:12:12', $timezone); - $dateTime2->datetime= new \DateTime('2010-02-02 12:12:12', $timezone); - - $this->_em->persist($dateTime1); - $this->_em->persist($dateTime2); - - $this->_em->flush(); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php deleted file mode 100755 index 4786cc176d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php +++ /dev/null @@ -1,107 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC698Role'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC698Privilege') - )); - } catch(\Exception $e) { - - } - } - - public function testTicket() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('p', 'r') - ->from(__NAMESPACE__ . '\DDC698Privilege', 'p') - ->leftJoin('p.roles', 'r'); - - $sql = $qb->getQuery()->getSQL(); - - $this->assertEquals( - strtolower('SELECT p0_.privilegeID AS privilegeID0, p0_.name AS name1, r1_.roleID AS roleID2, r1_.name AS name3, r1_.shortName AS shortName4 FROM Privileges p0_ LEFT JOIN RolePrivileges r2_ ON p0_.privilegeID = r2_.privilegeID LEFT JOIN Roles r1_ ON r1_.roleID = r2_.roleID'), - strtolower($sql) - ); - } -} - -/** - * - * @Table(name="Roles") - * @Entity - */ -class DDC698Role -{ - /** - * @Id @Column(name="roleID", type="integer") - * @GeneratedValue(strategy="AUTO") - * - */ - protected $roleID; - - /** - * @Column(name="name", type="string", length=45) - * - * - */ - protected $name; - - /** - * @Column(name="shortName", type="string", length=45) - * - * - */ - protected $shortName; - - - - /** - * @ManyToMany(targetEntity="DDC698Privilege", inversedBy="roles") - * @JoinTable(name="RolePrivileges", - * joinColumns={@JoinColumn(name="roleID", referencedColumnName="roleID")}, - * inverseJoinColumns={@JoinColumn(name="privilegeID", referencedColumnName="privilegeID")} - * ) - */ - protected $privilege; - -} - - -/** - * - * @Table(name="Privileges") - * @Entity() - */ -class DDC698Privilege -{ - /** - * @Id @Column(name="privilegeID", type="integer") - * @GeneratedValue(strategy="AUTO") - * - */ - protected $privilegeID; - - /** - * @Column(name="name", type="string", length=45) - * - * - */ - protected $name; - - /** - * @ManyToMany(targetEntity="DDC698Role", mappedBy="privilege") - */ - protected $roles; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php deleted file mode 100755 index 6bd18ef980..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ /dev/null @@ -1,112 +0,0 @@ -_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC719Group'), - )); - } - - public function testIsEmptySqlGeneration() - { - $q = $this->_em->createQuery('SELECT g, c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC719Group g LEFT JOIN g.children c WHERE g.parents IS EMPTY'); - - $this->assertEquals( - strtolower('SELECT g0_.name AS name0, g0_.description AS description1, g0_.id AS id2, g1_.name AS name3, g1_.description AS description4, g1_.id AS id5 FROM groups g0_ LEFT JOIN groups_groups g2_ ON g0_.id = g2_.parent_id LEFT JOIN groups g1_ ON g1_.id = g2_.child_id WHERE (SELECT COUNT(*) FROM groups_groups g3_ WHERE g3_.child_id = g0_.id) = 0'), - strtolower($q->getSQL()) - ); - } -} - -/** - * @MappedSuperclass - */ -class Entity -{ - /** - * @Id @GeneratedValue - * @Column(type="integer") - */ - protected $id; - - public function getId() { return $this->id; } -} - -/** - * @Entity - * @Table(name="groups") - */ -class DDC719Group extends Entity { - /** @Column(type="string", nullable=false) */ - protected $name; - - /** @Column(type="string", nullable=true) */ - protected $description; - - /** - * @ManyToMany(targetEntity="DDC719Group", inversedBy="parents") - * @JoinTable(name="groups_groups", - * joinColumns={@JoinColumn(name="parent_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="child_id", referencedColumnName="id")} - * ) - */ - protected $children = NULL; - - /** - * @ManyToMany(targetEntity="DDC719Group", mappedBy="children") - */ - protected $parents = NULL; - - /** - * construct - */ - public function __construct() { - parent::__construct(); - - $this->channels = new ArrayCollection(); - $this->children = new ArrayCollection(); - $this->parents = new ArrayCollection(); - } - - /** - * adds group as new child - * - * @param Group $child - */ - public function addGroup(Group $child) { - if ( ! $this->children->contains($child)) { - $this->children->add($child); - $child->addGroup($this); - } - } - - /** - * adds channel as new child - * - * @param Channel $child - */ - public function addChannel(Channel $child) { - if ( ! $this->channels->contains($child)) { - $this->channels->add($child); - } - } - - /** - * getter & setter - */ - public function getName() { return $this->name; } - public function setName($name) { $this->name = $name; } - public function getDescription() { return $this->description; } - public function setDescription($description) { $this->description = $description; } - public function getChildren() { return $this->children; } - public function getParents() { return $this->parents; } - public function getChannels() { return $this->channels; } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php deleted file mode 100755 index 3762497458..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php +++ /dev/null @@ -1,182 +0,0 @@ -_em); - $schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC729A'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC729B'), - )); - } catch(\Exception $e) { - - } - } - - public function testMergeManyToMany() - { - $a = new DDC729A(); - $b = new DDC729B(); - $a->related[] = $b; - - $this->_em->persist($a); - $this->_em->persist($b); - $this->_em->flush(); - $this->_em->clear(); - $aId = $a->id; - - $a = new DDC729A(); - $a->id = $aId; - - $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $a->related); - - $a = $this->_em->merge($a); - - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $a->related); - - $this->assertFalse($a->related->isInitialized(), "Collection should not be marked initialized."); - $this->assertFalse($a->related->isDirty(), "Collection should not be marked as dirty."); - - $this->_em->flush(); - $this->_em->clear(); - - $a = $this->_em->find(__NAMESPACE__ . '\DDC729A', $aId); - $this->assertEquals(1, count($a->related)); - } - - public function testUnidirectionalMergeManyToMany() - { - $a = new DDC729A(); - $b1 = new DDC729B(); - $b2 = new DDC729B(); - $a->related[] = $b1; - - $this->_em->persist($a); - $this->_em->persist($b1); - $this->_em->persist($b2); - $this->_em->flush(); - $this->_em->clear(); - $aId = $a->id; - - $a = new DDC729A(); - $a->id = $aId; - - $a = $this->_em->merge($a); - - $a->related->set(0, $this->_em->merge($b1)); - - $a->related->set(1, $this->_em->merge($b2)); - - $this->_em->flush(); - $this->_em->clear(); - - $a = $this->_em->find(__NAMESPACE__ . '\DDC729A', $aId); - $this->assertEquals(2, count($a->related)); - } - - public function testBidirectionalMergeManyToMany() - { - $a = new DDC729A(); - $b1 = new DDC729B(); - $b2 = new DDC729B(); - $a->related[] = $b1; - - $this->_em->persist($a); - $this->_em->persist($b1); - $this->_em->persist($b2); - $this->_em->flush(); - $this->_em->clear(); - $aId = $a->id; - - $a = new DDC729A(); - $a->id = $aId; - - $a = $this->_em->merge($a); - - $a->related->set(0, $this->_em->merge($b1)); - $b1->related->set(0, $a); - - $a->related->set(1, $this->_em->merge($b2)); - $b2->related->set(0, $a); - - $this->_em->flush(); - $this->_em->clear(); - - $a = $this->_em->find(__NAMESPACE__ . '\DDC729A', $aId); - $this->assertEquals(2, count($a->related)); - } - - public function testBidirectionalMultiMergeManyToMany() - { - $a = new DDC729A(); - $b1 = new DDC729B(); - $b2 = new DDC729B(); - $a->related[] = $b1; - - $this->_em->persist($a); - $this->_em->persist($b1); - $this->_em->persist($b2); - $this->_em->flush(); - $this->_em->clear(); - $aId = $a->id; - - $a = new DDC729A(); - $a->id = $aId; - - $a = $this->_em->merge($a); - - $a->related->set(0, $this->_em->merge($b1)); - $b1->related->set(0, $this->_em->merge($a)); - - $a->related->set(1, $this->_em->merge($b2)); - $b2->related->set(0, $this->_em->merge($a)); - - $this->_em->flush(); - $this->_em->clear(); - - $a = $this->_em->find(__NAMESPACE__ . '\DDC729A', $aId); - $this->assertEquals(2, count($a->related)); - } -} - -/** - * @Entity - */ -class DDC729A -{ - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; - - /** @ManyToMany(targetEntity="DDC729B", inversedBy="related") */ - public $related; - - public function __construct() - { - $this->related = new \Doctrine\Common\Collections\ArrayCollection(); - } -} - -/** - * @Entity - */ -class DDC729B -{ - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; - - /** @ManyToMany(targetEntity="DDC729B", mappedBy="related") */ - public $related; - - public function __construct() - { - $this->related = new \Doctrine\Common\Collections\ArrayCollection(); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php deleted file mode 100755 index 77ef6e148f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ /dev/null @@ -1,122 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC735Product'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC735Review') - )); - } catch(\Exception $e) { - - } - } - - public function testRemoveElement_AppliesOrphanRemoval() - { - // Create a product and its first review - $product = new DDC735Product; - $review = new DDC735Review($product); - - // Persist and flush - $this->_em->persist($product); - $this->_em->flush(); - - // Now you see it - $this->assertEquals(1, count($product->getReviews())); - - // Remove the review - $reviewId = $review->getId(); - $product->removeReview($review); - $this->_em->flush(); - - // Now you don't - $this->assertEquals(0, count($product->getReviews()), 'count($reviews) should be 0 after removing its only Review'); - - // Refresh - $this->_em->refresh($product); - - // It should still be 0 - $this->assertEquals(0, count($product->getReviews()), 'count($reviews) should still be 0 after the refresh'); - - // Review should also not be available anymore - $this->assertNull($this->_em->find(__NAMESPACE__.'\DDC735Review', $reviewId)); - } -} - -/** - * @Entity - */ -class DDC735Product -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - protected $id; - - /** - * @OneToMany( - * targetEntity="DDC735Review", - * mappedBy="product", - * cascade={"persist"}, - * orphanRemoval=true - * ) - */ - protected $reviews; - - public function __construct() - { - $this->reviews = new ArrayCollection; - } - - public function getReviews() - { - return $this->reviews; - } - - public function addReview(DDC735Review $review) - { - $this->reviews->add($review); - } - - public function removeReview(DDC735Review $review) - { - $this->reviews->removeElement($review); - } -} - -/** - * @Entity - */ -class DDC735Review -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - protected $id; - - /** - * @ManyToOne(targetEntity="DDC735Product", inversedBy="reviews") - */ - protected $product; - - public function __construct(DDC735Product $product) - { - $this->product = $product; - $product->addReview($this); - } - - public function getId() - { - return $this->id; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php deleted file mode 100755 index 2dfeeec6d8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php +++ /dev/null @@ -1,100 +0,0 @@ -useModelSet('ecommerce'); - parent::setUp(); - } - - /** - * @group DDC-736 - */ - public function testReorderEntityFetchJoinForHydration() - { - $cust = new ECommerceCustomer; - $cust->setName('roman'); - - $cart = new ECommerceCart; - $cart->setPayment('cash'); - $cart->setCustomer($cust); - - $this->_em->persist($cust); - $this->_em->persist($cart); - $this->_em->flush(); - $this->_em->clear(); - - $result = $this->_em->createQuery("select c, c.name, ca, ca.payment from Doctrine\Tests\Models\ECommerce\ECommerceCart ca join ca.customer c") - ->getSingleResult(/*\Doctrine\ORM\Query::HYDRATE_ARRAY*/); - - $cart2 = $result[0]; - unset($result[0]); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $cart2); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $cart2->getCustomer()); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart2->getCustomer()); - $this->assertEquals(array('name' => 'roman', 'payment' => 'cash'), $result); - } - - /** - * @group DDC-736 - * @group DDC-925 - * @group DDC-915 - */ - public function testDqlTreeWalkerReordering() - { - $cust = new ECommerceCustomer; - $cust->setName('roman'); - - $cart = new ECommerceCart; - $cart->setPayment('cash'); - $cart->setCustomer($cust); - - $this->_em->persist($cust); - $this->_em->persist($cart); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "select c, c.name, ca, ca.payment from Doctrine\Tests\Models\ECommerce\ECommerceCart ca join ca.customer c"; - $result = $this->_em->createQuery($dql) - ->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\Tests\ORM\Functional\Ticket\DisableFetchJoinTreeWalker')) - ->getResult(); - - /* @var $cart2 Doctrine\Tests\Models\ECommerce\ECommerceCart */ - $cart2 = $result[0][0]; - $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $cart2->getCustomer()); - } -} - -class DisableFetchJoinTreeWalker extends \Doctrine\ORM\Query\TreeWalkerAdapter -{ - public function walkSelectStatement(AST\SelectStatement $AST) - { - $this->walkSelectClause($AST->selectClause); - } - - /** - * @param \Doctrine\ORM\Query\AST\SelectClause $selectClause - */ - public function walkSelectClause($selectClause) - { - foreach ($selectClause->selectExpressions AS $key => $selectExpr) { - /* @var $selectExpr \Doctrine\ORM\Query\AST\SelectExpression */ - if ($selectExpr->expression == "c") { - unset($selectClause->selectExpressions[$key]); - break; - } - } - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php deleted file mode 100755 index 7e6e200d95..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php +++ /dev/null @@ -1,130 +0,0 @@ -addServer('localhost'); - $memcache->flush(); - - $cacheDriver = new \Doctrine\Common\Cache\MemcacheCache(); - $cacheDriver->setMemcache($memcache); - - $this->_em->getMetadataFactory()->setCacheDriver($cacheDriver); - } else if (\extension_loaded('apc')) { - $this->_em->getMetadataFactory()->setCacheDriver(new \Doctrine\Common\Cache\ApcCache()); - } - - try { - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC742User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC742Comment') - )); - } catch(\Exception $e) { - - } - - // make sure classes will be deserialized from caches - $this->_em->getMetadataFactory()->setMetadataFor(__NAMESPACE__ . '\DDC742User', null); - $this->_em->getMetadataFactory()->setMetadataFor(__NAMESPACE__ . '\DDC742Comment', null); - } - - public function testIssue() - { - $user = new DDC742User(); - $user->title = "Foo"; - $user->favoriteComments = new ArrayCollection(); - - $comment1 = new DDC742Comment(); - $comment1->content = "foo"; - - $comment2 = new DDC742Comment(); - $comment2->content = "bar"; - - $comment3 = new DDC742Comment(); - $comment3->content = "baz"; - - $user->favoriteComments->add($comment1); - $user->favoriteComments->add($comment2); - - $this->_em->persist($user); - $this->_em->persist($comment1); - $this->_em->persist($comment2); - $this->_em->persist($comment3); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(get_class($user), $user->id); - $comment3 = $this->_em->find(get_class($comment3), $comment3->id); - $user->favoriteComments->add($comment3); - $this->_em->flush(); - } -} - -/** - * @Entity - * @Table(name="users") - */ -class DDC742User -{ - /** - * User Id - * - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - * @var integer - */ - public $id; - /** - * @Column(length=100, type="string") - * @var string - */ - public $title; - /** - * @ManyToMany(targetEntity="DDC742Comment", cascade={"persist"}, fetch="EAGER") - * @JoinTable( - * name="user_comments", - * joinColumns={@JoinColumn(name="user_id",referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="comment_id", referencedColumnName="id")} - * ) - * - * @var Doctrine\ORM\PersistentCollection - */ - public $favoriteComments; -} - -/** - * @Entity - * @Table(name="comments") - */ -class DDC742Comment -{ - /** - * User Id - * - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - * @var integer - */ - public $id; - /** - * @Column(length=100, type="string") - * @var string - */ - public $content; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php deleted file mode 100755 index 9954a697bc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php +++ /dev/null @@ -1,64 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testRefreshWithManyToOne() - { - $user = new CmsUser(); - $user->name = "beberlei"; - $user->status = "active"; - $user->username = "beberlei"; - - $article = new CmsArticle(); - $article->setAuthor($user); - $article->text = "foo"; - $article->topic = "bar"; - - $this->_em->persist($user); - $this->_em->persist($article); - $this->_em->flush(); - - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $user->articles); - $this->_em->refresh($article); - $this->assertTrue($article !== $user->articles, "The article should not be replaced on the inverse side of the relation."); - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $user->articles); - } - - public function testRefreshOneToOne() - { - $user = new CmsUser(); - $user->name = "beberlei"; - $user->status = "active"; - $user->username = "beberlei"; - - $address = new CmsAddress(); - $address->city = "Bonn"; - $address->country = "Germany"; - $address->street = "A street"; - $address->zip = 12345; - $address->setUser($user); - - $this->_em->persist($user); - $this->_em->persist($address); - $this->_em->flush(); - - $this->_em->refresh($address); - $this->assertSame($user, $address->user); - $this->assertSame($user->address, $address); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php deleted file mode 100755 index 76bb3bba84..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php +++ /dev/null @@ -1,185 +0,0 @@ -markTestSkipped('Destroys testsuite'); - $this->useModelSet("cms"); - - parent::setUp(); - } - - /** - * Helper method to set cascade to merge only - */ - private function setCascadeMergeFor($class) - { - $metadata = $this->_em->getMetadataFactory()->getMetaDataFor($class); - foreach ($metadata->associationMappings as $key => $associationMapping) { - $metadata->associationMappings[$key]["isCascadePersist"] = false; - $metadata->associationMappings[$key]["isCascadeMerge"] = true; - $metadata->associationMappings[$key]["isCascadeRemove"] = false; - $metadata->associationMappings[$key]["isCascadeDetach"] = false; - } - } - - /** - * Test that changing associations on detached entities and then cascade merging them - * causes the database to be updated with the new associations. - * This specifically tests adding new associations. - */ - public function testManyToManyMergeAssociationAdds() - { - $this->setCascadeMergeFor('Doctrine\Tests\Models\CMS\CmsUser'); - $this->setCascadeMergeFor('Doctrine\Tests\Models\CMS\CmsGroup'); - - // Put entities in the database - $cmsUser = new CmsUser(); - $cmsUser->username = "dave"; - $cmsUser->name = "Dave Keen"; - $cmsUser->status = "testing"; - - $group1 = new CmsGroup(); - $group1->name = "Group 1"; - - $group2 = new CmsGroup(); - $group2->name = "Group 2"; - - $this->_em->persist($cmsUser); - $this->_em->persist($group1); - $this->_em->persist($group2); - $this->_em->flush(); - - $cmsUserId = $cmsUser->id; - $group1Id = $group1->id; - $group2Id = $group2->id; - - $this->_em->clear(); - - // Now create detached versions of the entities with some new associations. - $cmsUser = new CmsUser(); - $cmsUser->id = $cmsUserId; - $cmsUser->username = "dave"; - $cmsUser->name = "Dave Keen"; - $cmsUser->status = "testing"; - $cmsUser->groups = new ArrayCollection(); - - $group1 = new CmsGroup(); - $group1->id = $group1Id; - $group1->name = "Group 1"; - $group1->users = new ArrayCollection(); - - $group2 = new CmsGroup(); - $group2->id = $group2Id; - $group2->name = "Group 2"; - $group2->users = new ArrayCollection(); - - $cmsUser->addGroup($group1); - $cmsUser->addGroup($group2); - - // Cascade merge of cmsUser followed by a flush should add in the birectional new many-to-many associations between the user and the groups - $this->_em->merge($cmsUser); - $this->_em->flush(); - - $this->_em->clear(); - - $cmsUsers = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); - $cmsGroups = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll(); - - // Check the entities are in the database - $this->assertEquals(1, sizeof($cmsUsers)); - $this->assertEquals(2, sizeof($cmsGroups)); - - // Check the associations between the entities are now in the database - $this->assertEquals(2, sizeof($cmsUsers[0]->groups)); - $this->assertEquals(1, sizeof($cmsGroups[0]->users)); - $this->assertEquals(1, sizeof($cmsGroups[1]->users)); - - $this->assertSame($cmsUsers[0]->groups[0], $cmsGroups[0]); - $this->assertSame($cmsUsers[0]->groups[1], $cmsGroups[1]); - $this->assertSame($cmsGroups[0]->users[0], $cmsUsers[0]); - $this->assertSame($cmsGroups[1]->users[0], $cmsUsers[0]); - } - - /** - * Test that changing associations on detached entities and then cascade merging them causes the - * database to be updated with the new associations. - */ - public function testManyToManyMergeAssociationRemoves() - { - $this->setCascadeMergeFor('Doctrine\Tests\Models\CMS\CmsUser'); - $this->setCascadeMergeFor('Doctrine\Tests\Models\CMS\CmsGroup'); - - $cmsUser = new CmsUser(); - $cmsUser->username = "dave"; - $cmsUser->name = "Dave Keen"; - $cmsUser->status = "testing"; - - $group1 = new CmsGroup(); - $group1->name = "Group 1"; - - $group2 = new CmsGroup(); - $group2->name = "Group 2"; - - $cmsUser->addGroup($group1); - $cmsUser->addGroup($group2); - - $this->_em->persist($cmsUser); - $this->_em->persist($group1); - $this->_em->persist($group2); - $this->_em->flush(); - - $cmsUserId = $cmsUser->id; - $group1Id = $group1->id; - $group2Id = $group2->id; - - $this->_em->clear(); - - // Now create detached versions of the entities with NO associations. - $cmsUser = new CmsUser(); - $cmsUser->id = $cmsUserId; - $cmsUser->username = "dave"; - $cmsUser->name = "Dave Keen"; - $cmsUser->status = "testing"; - $cmsUser->groups = new ArrayCollection(); - - $group1 = new CmsGroup(); - $group1->id = $group1Id; - $group1->name = "Group 1"; - $group1->users = new ArrayCollection(); - - $group2 = new CmsGroup(); - $group2->id = $group2Id; - $group2->name = "Group 2"; - $group2->users = new ArrayCollection(); - - // Cascade merge of cmsUser followed by a flush should result in the association array collection being empty - $this->_em->merge($cmsUser); - $this->_em->flush(); - - $this->_em->clear(); - - $cmsUsers = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); - $cmsGroups = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll(); - - // Check the entities are in the database - $this->assertEquals(1, sizeof($cmsUsers)); - $this->assertEquals(2, sizeof($cmsGroups)); - - // Check the associations between the entities are now in the database - $this->assertEquals(0, sizeof($cmsUsers[0]->groups)); - $this->assertEquals(0, sizeof($cmsGroups[0]->users)); - $this->assertEquals(0, sizeof($cmsGroups[1]->users)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php deleted file mode 100755 index 7ba337ecd7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php +++ /dev/null @@ -1,74 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - /** - * @group DDC-767 - */ - public function testCollectionChangesInsideTransaction() - { - $user = new CmsUser(); - $user->name = "beberlei"; - $user->status = "active"; - $user->username = "beberlei"; - - $group1 = new CmsGroup(); - $group1->name = "foo"; - - $group2 = new CmsGroup(); - $group2->name = "bar"; - - $group3 = new CmsGroup(); - $group3->name = "baz"; - - $user->addGroup($group1); - $user->addGroup($group2); - - $this->_em->persist($user); - $this->_em->persist($group1); - $this->_em->persist($group2); - $this->_em->persist($group3); - - $this->_em->flush(); - $this->_em->clear(); - - /* @var $pUser CmsUser */ - $pUser = $this->_em->find(get_class($user), $user->id); - - $this->assertNotNull($pUser, "User not retrieved from database."); - - $groups = array(2, 3); - - try { - $this->_em->beginTransaction(); - - $pUser->groups->clear(); - - $this->_em->flush(); - - // Add new - foreach ($groups as $groupId) { - $pUser->addGroup($this->_em->find(get_class($group1), $groupId)); - } - - $this->_em->flush(); - $this->_em->commit(); - } catch(\Exception $e) { - $this->_em->rollback(); - } - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php deleted file mode 100755 index c586afac68..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php +++ /dev/null @@ -1,109 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC809Variant'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC809SpecificationValue') - )); - - $conn = $this->_em->getConnection(); - $conn->insert('specification_value_test', array('specification_value_id' => 94589)); - $conn->insert('specification_value_test', array('specification_value_id' => 94593)); - $conn->insert('specification_value_test', array('specification_value_id' => 94606)); - $conn->insert('specification_value_test', array('specification_value_id' => 94607)); - $conn->insert('specification_value_test', array('specification_value_id' => 94609)); - $conn->insert('specification_value_test', array('specification_value_id' => 94711)); - - $conn->insert('variant_test', array('variant_id' => 545208)); - $conn->insert('variant_test', array('variant_id' => 545209)); - - $conn->insert('var_spec_value_test', array('variant_id' => 545208, 'specification_value_id' => 94606)); - $conn->insert('var_spec_value_test', array('variant_id' => 545208, 'specification_value_id' => 94607)); - $conn->insert('var_spec_value_test', array('variant_id' => 545208, 'specification_value_id' => 94609)); - $conn->insert('var_spec_value_test', array('variant_id' => 545208, 'specification_value_id' => 94711)); - - $conn->insert('var_spec_value_test', array('variant_id' => 545209, 'specification_value_id' => 94589)); - $conn->insert('var_spec_value_test', array('variant_id' => 545209, 'specification_value_id' => 94593)); - $conn->insert('var_spec_value_test', array('variant_id' => 545209, 'specification_value_id' => 94606)); - $conn->insert('var_spec_value_test', array('variant_id' => 545209, 'specification_value_id' => 94607)); - } - - /** - * @group DDC-809 - */ - public function testIssue() - { - $result = $this->_em->createQueryBuilder() - ->select('Variant, SpecificationValue') - ->from('Doctrine\Tests\ORM\Functional\Ticket\DDC809Variant', 'Variant') - ->leftJoin('Variant.SpecificationValues', 'SpecificationValue') - ->getQuery() - ->getResult(); - - $this->assertEquals(4, count($result[0]->getSpecificationValues()), "Works in test-setup."); - $this->assertEquals(4, count($result[1]->getSpecificationValues()), "Only returns 2 in the case of the hydration bug."); - } -} - -/** - * @Table(name="variant_test") - * @Entity - */ -class DDC809Variant -{ - /** - * @Column(name="variant_id", type="integer") - * @Id - */ - protected $variantId; - - /** - * @ManyToMany(targetEntity="DDC809SpecificationValue", inversedBy="Variants") - * @JoinTable(name="var_spec_value_test", - * joinColumns={ - * @JoinColumn(name="variant_id", referencedColumnName="variant_id") - * }, - * inverseJoinColumns={ - * @JoinColumn(name="specification_value_id", referencedColumnName="specification_value_id") - * } - * ) - */ - protected $SpecificationValues; - - public function getSpecificationValues() - { - return $this->SpecificationValues; - } -} - -/** - * @Table(name="specification_value_test") - * @Entity - */ -class DDC809SpecificationValue -{ - /** - * @Column(name="specification_value_id", type="integer") - * @Id - */ - protected $specificationValueId; - - /** - * @var Variant - * - * @ManyToMany(targetEntity="DDC809Variant", mappedBy="SpecificationValues") - */ - protected $Variants; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php deleted file mode 100755 index 4a80358d4f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php +++ /dev/null @@ -1,48 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - /** - * @group DDC-812 - */ - public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManagedEntity() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - $article = new CmsArticle; - $article->topic = "hello"; - $article->text = "talk talk talk"; - - $comment = new CmsComment; - $comment->topic = "good!"; - $comment->text = "stuff!"; - $comment->article = $article; - - $this->_em->persist($article); - $this->_em->persist($comment); - $this->_em->flush(); - $this->_em->clear(); - - $article2 = $this->_em->find(get_class($article), $article->id); - - $article2Again = $this->_em->createQuery( - "select a, c from Doctrine\Tests\Models\CMS\CmsArticle a join a.comments c where a.id = ?1") - ->setParameter(1, $article->id) - ->getSingleResult(); - - $this->assertTrue($article2Again === $article2); - $this->assertTrue($article2Again->comments->isInitialized()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php deleted file mode 100755 index 599218b079..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ /dev/null @@ -1,194 +0,0 @@ -_em->getConnection()->getDatabasePlatform(); - if ($platform->getName() == "oracle") { - $this->markTestSkipped('Doesnt run on Oracle.'); - } - - $this->_em->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); - try { - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832JoinedIndex'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832JoinedTreeIndex'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832Like'), - )); - } catch(\Exception $e) { - - } - } - - public function tearDown() - { - /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ - $platform = $this->_em->getConnection()->getDatabasePlatform(); - $sm = $this->_em->getConnection()->getSchemaManager(); - $sm->dropTable($platform->quoteIdentifier('TREE_INDEX')); - $sm->dropTable($platform->quoteIdentifier('INDEX')); - $sm->dropTable($platform->quoteIdentifier('LIKE')); - } - - /** - * @group DDC-832 - */ - public function testQuotedTableBasicUpdate() - { - $like = new DDC832Like("test"); - $this->_em->persist($like); - $this->_em->flush(); - - $like->word = "test2"; - $this->_em->flush(); - } - - /** - * @group DDC-832 - */ - public function testQuotedTableBasicRemove() - { - $like = new DDC832Like("test"); - $this->_em->persist($like); - $this->_em->flush(); - - $this->_em->remove($like); - $this->_em->flush(); - } - - /** - * @group DDC-832 - */ - public function testQuotedTableJoinedUpdate() - { - $index = new DDC832JoinedIndex("test"); - $this->_em->persist($index); - $this->_em->flush(); - - $index->name = "asdf"; - $this->_em->flush(); - } - - /** - * @group DDC-832 - */ - public function testQuotedTableJoinedRemove() - { - $index = new DDC832JoinedIndex("test"); - $this->_em->persist($index); - $this->_em->flush(); - - $this->_em->remove($index); - $this->_em->flush(); - } - - /** - * @group DDC-832 - */ - public function testQuotedTableJoinedChildUpdate() - { - $index = new DDC832JoinedTreeIndex("test", 1, 2); - $this->_em->persist($index); - $this->_em->flush(); - - $index->name = "asdf"; - $this->_em->flush(); - } - - /** - * @group DDC-832 - */ - public function testQuotedTableJoinedChildRemove() - { - $index = new DDC832JoinedTreeIndex("test", 1, 2); - $this->_em->persist($index); - $this->_em->flush(); - - $this->_em->remove($index); - $this->_em->flush(); - } -} - -/** - * @Entity - * @Table(name="`LIKE`") - */ -class DDC832Like -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; - - /** @Column(type="string") */ - public $word; - - /** - * @version - * @Column(type="integer") - */ - public $version; - - public function __construct($word) - { - $this->word = $word; - } -} - -/** - * @Entity - * @Table(name="`INDEX`") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"like" = "DDC832JoinedIndex", "fuzzy" = "DDC832JoinedTreeIndex"}) - */ -class DDC832JoinedIndex -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - public $id; - - /** @Column(type="string") */ - public $name; - - /** - * @version - * @Column(type="integer") - */ - public $version; - - public function __construct($name) - { - $this->name = $name; - } -} - -/** - * @Entity - * @Table(name="`TREE_INDEX`") - */ -class DDC832JoinedTreeIndex extends DDC832JoinedIndex -{ - /** @Column(type="integer") */ - public $lft; - /** @Column(type="integer") */ - public $rgt; - - public function __construct($name, $lft, $rgt) - { - $this->name = $name; - $this->lft = $lft; - $this->rgt = $rgt; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php deleted file mode 100755 index d44c3af7df..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ /dev/null @@ -1,198 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Super'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Class1'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Class2'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Class3'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Aggregate'), - )); - } - - /** - * @group DDC-837 - */ - public function testIssue() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $c1 = new DDC837Class1(); - $c1->title = "Foo"; - $c1->description = "Foo"; - $aggregate1 = new DDC837Aggregate('test1'); - $c1->aggregate = $aggregate1; - - $c2 = new DDC837Class2(); - $c2->title = "Bar"; - $c2->description = "Bar"; - $c2->text = "Bar"; - $aggregate2 = new DDC837Aggregate('test2'); - $c2->aggregate = $aggregate2; - - $c3 = new DDC837Class3(); - $c3->apples = "Baz"; - $c3->bananas = "Baz"; - - $this->_em->persist($c1); - $this->_em->persist($aggregate1); - $this->_em->persist($c2); - $this->_em->persist($aggregate2); - $this->_em->persist($c3); - $this->_em->flush(); - $this->_em->clear(); - - // Test Class1 - $e1 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC837Super', $c1->id); - - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC837Class1', $e1); - $this->assertEquals('Foo', $e1->title); - $this->assertEquals('Foo', $e1->description); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC837Aggregate', $e1->aggregate); - $this->assertEquals('test1', $e1->aggregate->getSysname()); - - // Test Class 2 - $e2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC837Super', $c2->id); - - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC837Class2', $e2); - $this->assertEquals('Bar', $e2->title); - $this->assertEquals('Bar', $e2->description); - $this->assertEquals('Bar', $e2->text); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC837Aggregate', $e2->aggregate); - $this->assertEquals('test2', $e2->aggregate->getSysname()); - - $all = $this->_em->getRepository(__NAMESPACE__.'\DDC837Super')->findAll(); - - foreach ($all as $obj) { - if ($obj instanceof DDC837Class1) { - $this->assertEquals('Foo', $obj->title); - $this->assertEquals('Foo', $obj->description); - } else if ($obj instanceof DDC837Class2) { - $this->assertTrue($e2 === $obj); - $this->assertEquals('Bar', $obj->title); - $this->assertEquals('Bar', $obj->description); - $this->assertEquals('Bar', $obj->text); - } else if ($obj instanceof DDC837Class3) { - $this->assertEquals('Baz', $obj->apples); - $this->assertEquals('Baz', $obj->bananas); - } else { - $this->fail('Instance of DDC837Class1, DDC837Class2 or DDC837Class3 expected.'); - } - } - } -} - -/** - * @Entity - * @Table(name="DDC837Super") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"class1" = "DDC837Class1", "class2" = "DDC837Class2", "class3"="DDC837Class3"}) - */ -abstract class DDC837Super -{ - /** - * @Id @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; -} - -/** - * @Entity - */ -class DDC837Class1 extends DDC837Super -{ - /** - * @Column(name="title", type="string", length=150) - */ - public $title; - - /** - * @Column(name="content", type="string", length=500) - */ - public $description; - - /** - * @OneToOne(targetEntity="DDC837Aggregate") - */ - public $aggregate; -} - -/** - * @Entity - */ -class DDC837Class2 extends DDC837Super -{ - /** - * @Column(name="title", type="string", length=150) - */ - public $title; - - /** - * @Column(name="content", type="string", length=500) - */ - public $description; - - /** - * @Column(name="text", type="text") - */ - public $text; - - /** - * @OneToOne(targetEntity="DDC837Aggregate") - */ - public $aggregate; -} - -/** - * An extra class to demonstrate why title and description aren't in Super - * - * @Entity - */ -class DDC837Class3 extends DDC837Super -{ - /** - * @Column(name="title", type="string", length=150) - */ - public $apples; - - /** - * @Column(name="content", type="string", length=500) - */ - public $bananas; -} - -/** - * @Entity - */ -class DDC837Aggregate -{ - /** - * @Id @Column(name="id", type="integer") - * @GeneratedValue - */ - public $id; - - /** - * @Column(name="sysname", type="string") - */ - protected $sysname; - - public function __construct($sysname) - { - $this->sysname = $sysname; - } - - public function getSysname() - { - return $this->sysname; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php deleted file mode 100755 index b17e60566d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php +++ /dev/null @@ -1,84 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - - $this->user = new CmsUser(); - $this->user->username = "beberlei"; - $this->user->name = "Benjamin"; - $this->user->status = "active"; - - $this->group1 = new CmsGroup(); - $this->group1->name = "Group 1"; - $this->group2 = new CmsGroup(); - $this->group2->name = "Group 2"; - - $this->user->addGroup($this->group1); - $this->user->addGroup($this->group2); - - $this->_em->persist($this->user); - $this->_em->persist($this->group1); - $this->_em->persist($this->group2); - - $this->_em->flush(); - $this->_em->clear(); - - $this->user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->user->getId()); - } - - public function testRemoveContains() - { - $group1 = $this->user->groups[0]; - $group2 = $this->user->groups[1]; - - $this->assertTrue($this->user->groups->contains($group1)); - $this->assertTrue($this->user->groups->contains($group2)); - - $this->user->groups->removeElement($group1); - $this->user->groups->remove(1); - - $this->assertFalse($this->user->groups->contains($group1)); - $this->assertFalse($this->user->groups->contains($group2)); - } - - public function testClearCount() - { - $this->user->addGroup(new CmsGroup); - $this->assertEquals(3, count($this->user->groups)); - - $this->user->groups->clear(); - - $this->assertEquals(0, $this->user->groups->count()); - $this->assertEquals(0, count($this->user->groups)); - } - - public function testClearContains() - { - $group1 = $this->user->groups[0]; - $group2 = $this->user->groups[1]; - - $this->assertTrue($this->user->groups->contains($group1)); - $this->assertTrue($this->user->groups->contains($group2)); - - $this->user->groups->clear(); - - $this->assertFalse($this->user->groups->contains($group1)); - $this->assertFalse($this->user->groups->contains($group2)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php deleted file mode 100755 index 4ef3c08fa5..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ /dev/null @@ -1,215 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC881User'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC881Phonenumber'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC881Phonecall'), - )); - } catch (\Exception $e) { - - } - } - - /** - * @group DDC-117 - * @group DDC-881 - */ - public function testIssue() - { - /* Create two test users: albert and alfons */ - $albert = new DDC881User; - $albert->setName("albert"); - $this->_em->persist($albert); - - $alfons = new DDC881User; - $alfons->setName("alfons"); - $this->_em->persist($alfons); - - $this->_em->flush(); - - /* Assign two phone numbers to each user */ - $phoneAlbert1 = new DDC881PhoneNumber(); - $phoneAlbert1->setUser($albert); - $phoneAlbert1->setId(1); - $phoneAlbert1->setPhoneNumber("albert home: 012345"); - $this->_em->persist($phoneAlbert1); - - $phoneAlbert2 = new DDC881PhoneNumber(); - $phoneAlbert2->setUser($albert); - $phoneAlbert2->setId(2); - $phoneAlbert2->setPhoneNumber("albert mobile: 67890"); - $this->_em->persist($phoneAlbert2); - - $phoneAlfons1 = new DDC881PhoneNumber(); - $phoneAlfons1->setId(1); - $phoneAlfons1->setUser($alfons); - $phoneAlfons1->setPhoneNumber("alfons home: 012345"); - $this->_em->persist($phoneAlfons1); - - $phoneAlfons2 = new DDC881PhoneNumber(); - $phoneAlfons2->setId(2); - $phoneAlfons2->setUser($alfons); - $phoneAlfons2->setPhoneNumber("alfons mobile: 67890"); - $this->_em->persist($phoneAlfons2); - - /* We call alfons and albert once on their mobile numbers */ - $call1 = new DDC881PhoneCall(); - $call1->setPhoneNumber($phoneAlfons2); - $this->_em->persist($call1); - - $call2 = new DDC881PhoneCall(); - $call2->setPhoneNumber($phoneAlbert2); - $this->_em->persist($call2); - - $this->_em->flush(); - $this->_em->clear(); - - // fetch-join that foreign-key/primary-key entity association - $dql = "SELECT c, p FROM " . __NAMESPACE__ . "\DDC881PhoneCall c JOIN c.phonenumber p"; - $calls = $this->_em->createQuery($dql)->getResult(); - - $this->assertEquals(2, count($calls)); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $calls[0]->getPhoneNumber()); - $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $calls[1]->getPhoneNumber()); - - $dql = "SELECT p, c FROM " . __NAMESPACE__ . "\DDC881PhoneNumber p JOIN p.calls c"; - $numbers = $this->_em->createQuery($dql)->getResult(); - - $this->assertEquals(2, count($numbers)); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $numbers[0]->getCalls()); - $this->assertTrue($numbers[0]->getCalls()->isInitialized()); - } - -} - -/** - * @Entity - */ -class DDC881User -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - /** - * @Column(type="string") - */ - private $name; - /** - * @OneToMany(targetEntity="DDC881PhoneNumber",mappedBy="id") - */ - private $phoneNumbers; - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } -} - -/** - * @Entity - */ -class DDC881PhoneNumber -{ - - /** - * @Id - * @Column(type="integer") - */ - private $id; - /** - * @Id - * @ManyToOne(targetEntity="DDC881User",cascade={"all"}) - */ - private $user; - /** - * @Column(type="string") - */ - private $phonenumber; - - /** - * @OneToMany(targetEntity="DDC881PhoneCall", mappedBy="phonenumber") - */ - private $calls; - - public function __construct() - { - $this->calls = new \Doctrine\Common\Collections\ArrayCollection(); - } - - public function setId($id) - { - $this->id = $id; - } - - public function setUser(DDC881User $user) - { - $this->user = $user; - } - - public function setPhoneNumber($phoneNumber) - { - $this->phonenumber = $phoneNumber; - } - - public function getCalls() - { - return $this->calls; - } -} - -/** - * @Entity - */ -class DDC881PhoneCall -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - /** - * @ManyToOne(targetEntity="DDC881PhoneNumber", inversedBy="calls", cascade={"all"}) - * @JoinColumns({ - * @JoinColumn(name="phonenumber_id", referencedColumnName="id"), - * @JoinColumn(name="user_id", referencedColumnName="user_id") - * }) - */ - private $phonenumber; - /** - * @Column(type="string",nullable=true) - */ - private $callDate; - - public function setPhoneNumber(DDC881PhoneNumber $phoneNumber) - { - $this->phonenumber = $phoneNumber; - } - - public function getPhoneNumber() - { - return $this->phonenumber; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php deleted file mode 100755 index cd2b584ea3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php +++ /dev/null @@ -1,39 +0,0 @@ -useModelSet('company'); - parent::setUp(); - } - - /** - * @group DDC-933 - */ - public function testLockCTIClass() - { - //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); - - $manager = new \Doctrine\Tests\Models\Company\CompanyManager(); - $manager->setName('beberlei'); - $manager->setSalary(1234); - $manager->setTitle('Vice Precident of This Test'); - $manager->setDepartment("Foo"); - - $this->_em->persist($manager); - $this->_em->flush(); - - $this->_em->beginTransaction(); - $this->_em->lock($manager, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ); - $this->_em->rollback(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php deleted file mode 100755 index a3734b75ae..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php +++ /dev/null @@ -1,43 +0,0 @@ -useModelSet('generic'); - parent::setUp(); - } - - /** - * @group DDC-949 - */ - public function testBooleanThroughRepository() - { - $true = new BooleanModel(); - $true->booleanField = true; - - $false = new BooleanModel(); - $false->booleanField = false; - - $this->_em->persist($true); - $this->_em->persist($false); - $this->_em->flush(); - $this->_em->clear(); - - $true = $this->_em->getRepository('Doctrine\Tests\Models\Generic\BooleanModel')->findOneBy(array('booleanField' => true)); - $false = $this->_em->getRepository('Doctrine\Tests\Models\Generic\BooleanModel')->findOneBy(array('booleanField' => false)); - - $this->assertInstanceOf('Doctrine\Tests\Models\Generic\BooleanModel', $true, "True model not found"); - $this->assertTrue($true->booleanField, "True Boolean Model should be true."); - - $this->assertInstanceOf('Doctrine\Tests\Models\Generic\BooleanModel', $false, "False model not found"); - $this->assertFalse($false->booleanField, "False Boolean Model should be false."); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php deleted file mode 100755 index 99a29a57ac..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ /dev/null @@ -1,92 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC960Root'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC960Child') - )); - } catch(\Exception $e) { - - } - } - - /** - * @group DDC-960 - */ - public function testUpdateRootVersion() - { - $child = new DDC960Child('Test'); - $this->_em->persist($child); - $this->_em->flush(); - - $child->setName("Test2"); - - $this->_em->flush(); - - $this->assertEquals(2, $child->getVersion()); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({ - * "root" = "DDC960Root", - * "child" = "DDC960Child" - * }) - */ -class DDC960Root -{ - /** - * @Id @GeneratedValue @Column(type="integer") - */ - private $id; - - /** - * @Column(type="integer") @Version - */ - private $version; - - public function getId() - { - return $this->id; - } - - public function getVersion() - { - return $this->version; - } -} - -/** - * @Entity - */ -class DDC960Child extends DDC960Root -{ - /** - * @column(type="string") - * @var string - */ - private $name; - - public function __construct($name) - { - $this->name = $name; - } - - public function setName($name) - { - $this->name = $name; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php deleted file mode 100755 index 001e3801f8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ /dev/null @@ -1,147 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC992Role'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC992Parent'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC992Child'), - )); - } catch(\Exception $e) { - - } - } - - public function testIssue() - { - $role = new DDC992Role(); - $role->name = "Parent"; - $child = new DDC992Role(); - $child->name = "child"; - - $role->extendedBy[] = $child; - $child->extends[] = $role; - - $this->_em->persist($role); - $this->_em->persist($child); - $this->_em->flush(); - $this->_em->clear(); - - $child = $this->_em->getRepository(get_class($role))->find($child->roleID); - $parents = count($child->extends); - $this->assertEquals(1, $parents); - foreach ($child->extends AS $parent) { - $this->assertEquals($role->getRoleID(), $parent->getRoleID()); - } - } - - public function testOneToManyChild() - { - $parent = new DDC992Parent(); - $child = new DDC992Child(); - $child->parent = $parent; - $parent->childs[] = $child; - - $this->_em->persist($parent); - $this->_em->persist($child); - $this->_em->flush(); - $this->_em->clear(); - - $parentRepository = $this->_em->getRepository(get_class($parent)); - $childRepository = $this->_em->getRepository(get_class($child)); - - $parent = $parentRepository->find($parent->id); - $this->assertEquals(1, count($parent->childs)); - $this->assertEquals(0, count($parent->childs[0]->childs())); - - $child = $parentRepository->findOneBy(array("id" => $child->id)); - $this->assertSame($parent->childs[0], $child); - - $this->_em->clear(); - - $child = $parentRepository->find($child->id); - $this->assertEquals(0, count($child->childs)); - - $this->_em->clear(); - - $child = $childRepository->find($child->id); - $this->assertEquals(0, count($child->childs)); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({"child" = "DDC992Child", "parent" = "DDC992Parent"}) - */ -class DDC992Parent -{ - /** @Id @GeneratedValue @Column(type="integer") */ - public $id; - /** @ManyToOne(targetEntity="DDC992Parent", inversedBy="childs") */ - public $parent; - /** @OneToMany(targetEntity="DDC992Child", mappedBy="parent") */ - public $childs; -} - -/** - * @Entity - */ -class DDC992Child extends DDC992Parent -{ - public function childs() - { - return $this->childs; - } -} - -/** - * @Entity - */ -class DDC992Role -{ - public function getRoleID() - { - return $this->roleID; - } - - /** - * @Id @Column(name="roleID", type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $roleID; - /** - * @Column (name="name", type="string", length=45) - */ - public $name; - /** - * @ManyToMany (targetEntity="DDC992Role", mappedBy="extends") - */ - public $extendedBy; - /** - * @ManyToMany (targetEntity="DDC992Role", inversedBy="extendedBy") - * @JoinTable (name="RoleRelations", - * joinColumns={@JoinColumn(name="roleID", referencedColumnName="roleID")}, - * inverseJoinColumns={@JoinColumn(name="extendsRoleID", referencedColumnName="roleID")} - * ) - */ - public $extends; - - public function __construct() { - $this->extends = new ArrayCollection; - $this->extendedBy = new ArrayCollection; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php deleted file mode 100755 index e18310244d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php +++ /dev/null @@ -1,44 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\Ticket2481Product') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - $this->_conn = $this->_em->getConnection(); - } - - public function testEmptyInsert() - { - $test = new Ticket2481Product(); - $this->_em->persist($test); - $this->_em->flush(); - - $this->assertTrue($test->id > 0); - } -} - -/** - * @Entity - * @Table(name="ticket_2481_products") - */ -class Ticket2481Product -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php deleted file mode 100755 index 1ca35115d3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php +++ /dev/null @@ -1,427 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\Lemma'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\Relation'), - $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\RelationType') - )); - } catch (\Exception $e) { - // Swallow all exceptions. We do not test the schema tool here. - } - } - - public function testIssue() - { - //setup - $lemma1 = new Lemma; - $lemma1->setLemma('foo'); - - $lemma2 = new Lemma; - $lemma2->setLemma('bar'); - - $lemma3 = new Lemma; - $lemma3->setLemma('batz'); - - $lemma4 = new Lemma; - $lemma4->setLemma('bla'); - - $type1 = new RelationType; - $type1->setType('nonsense'); - $type1->setAbbreviation('non'); - - $type2 = new RelationType; - $type2->setType('quatsch'); - $type2->setAbbreviation('qu'); - - $relation1 = new Relation; - $relation1->setParent($lemma1); - $relation1->setChild($lemma2); - $relation1->setType($type1); - - $relation2 = new Relation; - $relation2->setParent($lemma1); - $relation2->setChild($lemma3); - $relation2->setType($type1); - - $relation3 = new Relation; - $relation3->setParent($lemma1); - $relation3->setChild($lemma4); - $relation3->setType($type2); - - $lemma1->addRelation($relation1); - $lemma1->addRelation($relation2); - $lemma1->addRelation($relation3); - - $this->_em->persist($type1); - $this->_em->persist($type2); - $this->_em->persist($lemma1); - $this->_em->persist($lemma2); - $this->_em->persist($lemma3); - $this->_em->persist($lemma4); - - $this->_em->flush(); - $this->_em->clear(); - //end setup - - // test One To Many - $query = $this->_em->createQuery("SELECT l FROM Doctrine\Tests\ORM\Functional\Ticket\Lemma l Where l.lemma = 'foo'"); - $res = $query->getResult(); - $lemma = $res[0]; - - $this->assertEquals('foo', $lemma->getLemma()); - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\Lemma', $lemma); - $relations = $lemma->getRelations(); - - foreach($relations as $relation) { - $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\Relation', $relation); - $this->assertTrue($relation->getType()->getType() != ''); - } - - $this->_em->clear(); - - } -} - -/** - * @Entity - * @Table(name="lemma") - */ -class Lemma { - - const CLASS_NAME = __CLASS__; - - /** - * @var int - * @Id - * @Column(type="integer", name="lemma_id") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * - * @var string - * @Column(type="string", name="lemma_name", unique=true, length=255) - */ - private $lemma; - - - /** - * @var kateglo\application\utilities\collections\ArrayCollection - * @OneToMany(targetEntity="Relation", mappedBy="parent", cascade={"persist"}) - */ - private $relations; - - public function __construct() { - $this->types = new \Doctrine\Common\Collections\ArrayCollection(); - $this->relations = new \Doctrine\Common\Collections\ArrayCollection(); - } - - - /** - * - * @return int - */ - public function getId() { - return $this->id; - } - - /** - * - * @param string $lemma - * @return void - */ - public function setLemma($lemma) { - $this->lemma = $lemma; - } - - /** - * - * @return string - */ - public function getLemma() { - return $this->lemma; - } - - - /** - * - * @param Relation $relation - * @return void - */ - public function addRelation(Relation $relation) { - $this->relations[] = $relation; - $relation->setParent($this); - } - - /** - * - * @param Relation $relation - * @return void - */ - public function removeRelation(Relation $relation) { - /*@var $removed Relation */ - $removed = $this->relations->removeElement($relation); - if ($removed !== null) { - $removed->removeParent(); - } - } - - /** - * - * @return kateglo\application\utilities\collections\ArrayCollection - */ - public function getRelations() { - return $this->relations; - } - -} - -/** - * - * @Entity - * @Table(name="relation") - */ -class Relation { - - const CLASS_NAME = __CLASS__; - - /** - * @var int - * @Id - * @Column(type="integer", name="relation_id") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @var Lemma - * @ManyToOne(targetEntity="Lemma", inversedBy="relations") - * @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id") - */ - private $parent; - - /** - * @var Lemma - * @OneToOne(targetEntity="Lemma") - * @JoinColumn(name="relation_child_id", referencedColumnName="lemma_id") - */ - private $child; - - /** - * @var RelationType - * @ManyToOne(targetEntity="RelationType", inversedBy="relations") - * @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id") - */ - private $type; - - /** - * - * @param Lemma $parent - * @return void - */ - public function setParent(Lemma $parent) { - $this->parent = $parent; - } - - /** - * - * @return Phrase - */ - public function getParent() { - return $this->parent; - } - - /** - * - * @return void - */ - public function removeParent() { - if ($this->lemma !== null) { - /*@var $phrase Lemma */ - $lemma = $this->parent; - $this->parent = null; - $lemma->removeRelation($this); - } - } - - /** - * - * @param Lemma $child - * @return void - */ - public function setChild(Lemma $child) { - $this->child = $child; - } - - /** - * - * @return Lemma - */ - public function getChild() { - return $this->child; - } - - /** - * - * @param RelationType $type - * @return void - */ - public function setType(RelationType $type) { - $this->type = $type; - } - - /** - * - * @return RelationType - */ - public function getType() { - return $this->type; - } - - /** - * - * @return void - */ - public function removeType() { - if ($this->type !== null) { - /*@var $phrase RelationType */ - $type = $this->type; - $this->type = null; - $type->removeRelation($this); - } - } -} - -/** - * - * @Entity - * @Table(name="relation_type") - */ -class RelationType { - - const CLASS_NAME = __CLASS__; - - /** - * - * @var int - * @Id - * @Column(type="integer", name="relation_type_id") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * - * @var string - * @Column(type="string", name="relation_type_name", unique=true, length=255) - */ - private $type; - - /** - * - * @var string - * @Column(type="string", name="relation_type_abbreviation", unique=true, length=255) - */ - private $abbreviation; - - /** - * @var kateglo\application\utilities\collections\ArrayCollection - * @OneToMany(targetEntity="Relation", mappedBy="type", cascade={"persist"}) - */ - private $relations; - - public function __construct() { - $relations = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * - * @return int - */ - public function getId() { - return $this->id; - } - - /** - * - * @param string $type - * @return void - */ - public function setType($type) { - $this->type = $type; - } - - /** - * - * @return string - */ - public function getType() { - return $this->type; - } - - /** - * - * @param string $abbreviation - * @return void - */ - public function setAbbreviation($abbreviation) { - $this->abbreviation = $abbreviation; - } - - /** - * - * @return string - */ - public function getAbbreviation() { - return $this->abbreviation; - } - - /** - * - * @param Relation $relation - * @return void - */ - public function addRelation(Relation $relation) { - $this->relations[] = $relation; - $relation->setType($this); - } - - /** - * - * @param Relation $relation - * @return void - */ - public function removeRelation(Relation $relation) { - /*@var $removed Relation */ - $removed = $this->relations->removeElement($relation); - if ($removed !== null) { - $removed->removeLemma(); - } - } - - /** - * - * @return kateglo\application\utilities\collections\ArrayCollection - */ - public function getRelations() { - return $this->relations; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeTest.php deleted file mode 100755 index 9ed8cf0506..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ /dev/null @@ -1,182 +0,0 @@ -useModelSet('generic'); - parent::setUp(); - } - - public function testDecimal() - { - $decimal = new DecimalModel(); - $decimal->decimal = 0.15; - $decimal->highScale = 0.1515; - - $this->_em->persist($decimal); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT d FROM Doctrine\Tests\Models\Generic\DecimalModel d"; - $decimal = $this->_em->createQuery($dql)->getSingleResult(); - - $this->assertEquals(0.15, $decimal->decimal); - $this->assertEquals(0.1515, $decimal->highScale); - } - - /** - * @group DDC-1394 - * @return void - */ - public function testBoolean() - { - $bool = new BooleanModel(); - $bool->booleanField = true; - - $this->_em->persist($bool); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true"; - $bool = $this->_em->createQuery($dql)->getSingleResult(); - - $this->assertTrue($bool->booleanField); - - $bool->booleanField = false; - - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false"; - $bool = $this->_em->createQuery($dql)->getSingleResult(); - - $this->assertFalse($bool->booleanField); - } - - public function testArray() - { - $serialize = new SerializationModel(); - $serialize->array["foo"] = "bar"; - $serialize->array["bar"] = "baz"; - - $this->_em->persist($serialize); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT s FROM Doctrine\Tests\Models\Generic\SerializationModel s"; - $serialize = $this->_em->createQuery($dql)->getSingleResult(); - - $this->assertEquals(array("foo" => "bar", "bar" => "baz"), $serialize->array); - } - - public function testObject() - { - $serialize = new SerializationModel(); - $serialize->object = new \stdClass(); - - $this->_em->persist($serialize); - $this->_em->flush(); - $this->_em->clear(); - - $dql = "SELECT s FROM Doctrine\Tests\Models\Generic\SerializationModel s"; - $serialize = $this->_em->createQuery($dql)->getSingleResult(); - - $this->assertInstanceOf('stdClass', $serialize->object); - } - - public function testDate() - { - $dateTime = new DateTimeModel(); - $dateTime->date = new \DateTime('2009-10-01', new \DateTimeZone('Europe/Berlin')); - - $this->_em->persist($dateTime); - $this->_em->flush(); - $this->_em->clear(); - - $dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id); - - $this->assertInstanceOf('DateTime', $dateTimeDb->date); - $this->assertEquals('2009-10-01', $dateTimeDb->date->format('Y-m-d')); - } - - public function testDateTime() - { - $dateTime = new DateTimeModel(); - $dateTime->datetime = new \DateTime('2009-10-02 20:10:52', new \DateTimeZone('Europe/Berlin')); - - $this->_em->persist($dateTime); - $this->_em->flush(); - $this->_em->clear(); - - $dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id); - - $this->assertInstanceOf('DateTime', $dateTimeDb->datetime); - $this->assertEquals('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); - - $articles = $this->_em->getRepository( 'Doctrine\Tests\Models\Generic\DateTimeModel' )->findBy( array( 'datetime' => new \DateTime( "now" ) ) ); - $this->assertEquals( 0, count( $articles ) ); - } - - public function testDqlQueryBindDateTimeInstance() - { - $date = new \DateTime('2009-10-02 20:10:52', new \DateTimeZone('Europe/Berlin')); - - $dateTime = new DateTimeModel(); - $dateTime->datetime = $date; - - $this->_em->persist($dateTime); - $this->_em->flush(); - $this->_em->clear(); - - $dateTimeDb = $this->_em->createQuery('SELECT d FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime = ?1') - ->setParameter(1, $date, DBALType::DATETIME) - ->getSingleResult(); - } - - public function testDqlQueryBuilderBindDateTimeInstance() - { - $date = new \DateTime('2009-10-02 20:10:52', new \DateTimeZone('Europe/Berlin')); - - $dateTime = new DateTimeModel(); - $dateTime->datetime = $date; - - $this->_em->persist($dateTime); - $this->_em->flush(); - $this->_em->clear(); - - $dateTimeDb = $this->_em->createQueryBuilder() - ->select('d') - ->from('Doctrine\Tests\Models\Generic\DateTimeModel', 'd') - ->where('d.datetime = ?1') - ->setParameter(1, $date, DBALType::DATETIME) - ->getQuery()->getSingleResult(); - } - - public function testTime() - { - $dateTime = new DateTimeModel(); - $dateTime->time = new \DateTime('2010-01-01 19:27:20'); - - $this->_em->persist($dateTime); - $this->_em->flush(); - $this->_em->clear(); - - $dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id); - - $this->assertInstanceOf('DateTime', $dateTime->time); - $this->assertEquals('19:27:20', $dateTime->time->format('H:i:s')); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php deleted file mode 100755 index 537f238ca9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php +++ /dev/null @@ -1,142 +0,0 @@ -useModelSet('customtype'); - parent::setUp(); - } - - public function testUpperCaseStringType() - { - $entity = new CustomTypeUpperCase(); - $entity->lowerCaseString = 'foo'; - - $this->_em->persist($entity); - $this->_em->flush(); - - $id = $entity->id; - - $this->_em->clear(); - - $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - - $this->assertEquals('foo', $entity->lowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn("select lowerCaseString from customtype_uppercases where id=".$entity->id.""), 'Database holds uppercase string'); - } - - /** - * @group DDC-1642 - */ - public function testUpperCaseStringTypeWhenColumnNameIsDefined() - { - - $entity = new CustomTypeUpperCase(); - $entity->lowerCaseString = 'Some Value'; - $entity->namedLowerCaseString = 'foo'; - - $this->_em->persist($entity); - $this->_em->flush(); - - $id = $entity->id; - - $this->_em->clear(); - - $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - $this->assertEquals('foo', $entity->namedLowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn("select named_lower_case_string from customtype_uppercases where id=".$entity->id.""), 'Database holds uppercase string'); - - - $entity->namedLowerCaseString = 'bar'; - - $this->_em->persist($entity); - $this->_em->flush(); - - $id = $entity->id; - - $this->_em->clear(); - - - $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - $this->assertEquals('bar', $entity->namedLowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('BAR', $this->_em->getConnection()->fetchColumn("select named_lower_case_string from customtype_uppercases where id=".$entity->id.""), 'Database holds uppercase string'); - } - - public function testTypeValueSqlWithAssociations() - { - $parent = new CustomTypeParent(); - $parent->customInteger = -1; - $parent->child = new CustomTypeChild(); - - $friend1 = new CustomTypeParent(); - $friend2 = new CustomTypeParent(); - - $parent->addMyFriend($friend1); - $parent->addMyFriend($friend2); - - $this->_em->persist($parent); - $this->_em->persist($friend1); - $this->_em->persist($friend2); - $this->_em->flush(); - - $parentId = $parent->id; - - $this->_em->clear(); - - $entity = $this->_em->find('Doctrine\Tests\Models\CustomType\CustomTypeParent', $parentId); - - $this->assertTrue($entity->customInteger < 0, 'Fetched customInteger negative'); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select customInteger from customtype_parents where id=".$entity->id.""), 'Database has stored customInteger positive'); - - $this->assertNotNull($parent->child, 'Child attached'); - $this->assertCount(2, $entity->getMyFriends(), '2 friends attached'); - } - - public function testSelectDQL() - { - $parent = new CustomTypeParent(); - $parent->customInteger = -1; - $parent->child = new CustomTypeChild(); - - $this->_em->persist($parent); - $this->_em->flush(); - - $parentId = $parent->id; - - $this->_em->clear(); - - $query = $this->_em->createQuery("SELECT p, p.customInteger, c from Doctrine\Tests\Models\CustomType\CustomTypeParent p JOIN p.child c where p.id = " . $parentId); - - $result = $query->getResult(); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\CustomType\CustomTypeParent', $result[0][0]); - $this->assertEquals(-1, $result[0][0]->customInteger); - - $this->assertEquals(-1, $result[0]['customInteger']); - - $this->assertEquals('foo', $result[0][0]->child->lowerCaseString); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php deleted file mode 100755 index 5fa237ee4d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php +++ /dev/null @@ -1,48 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->getName() != 'mysql') { - $this->markTestSkipped('Currently restricted to MySQL platform.'); - } - - $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\UUIDEntity') - )); - } - - public function testGenerateUUID() - { - $entity = new UUIDEntity(); - - $this->_em->persist($entity); - $this->assertNotNull($entity->getId()); - $this->assertTrue(strlen($entity->getId()) > 0); - } -} - -/** - * @Entity - */ -class UUIDEntity -{ - /** @Id @Column(type="string") @GeneratedValue(strategy="UUID") */ - private $id; - /** - * Get id. - * - * @return id. - */ - public function getId() - { - return $this->id; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php deleted file mode 100755 index 08e3720ca0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php +++ /dev/null @@ -1,71 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testScheduleInsertManaged() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin"; - $user->status = "active"; - $this->_em->persist($user); - $this->_em->flush(); - - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "A managed+dirty entity Doctrine\Tests\Models\CMS\CmsUser"); - $this->_em->getUnitOfWork()->scheduleForInsert($user); - } - - public function testScheduleInsertDeleted() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin"; - $user->status = "active"; - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->remove($user); - - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "Removed entity Doctrine\Tests\Models\CMS\CmsUser"); - $this->_em->getUnitOfWork()->scheduleForInsert($user); - } - - public function testScheduleInsertTwice() - { - $user = new CmsUser(); - $user->username = "beberlei"; - $user->name = "Benjamin"; - $user->status = "active"; - - $this->_em->getUnitOfWork()->scheduleForInsert($user); - - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "Entity Doctrine\Tests\Models\CMS\CmsUser"); - $this->_em->getUnitOfWork()->scheduleForInsert($user); - } - - public function testAddToIdentityMapWithoutIdentity() - { - $user = new CmsUser(); - - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "The given entity of type 'Doctrine\Tests\Models\CMS\CmsUser' (Doctrine\Tests\Models\CMS\CmsUser@"); - $this->_em->getUnitOfWork()->registerManaged($user, array(), array()); - } - - public function testMarkReadOnlyNonManaged() - { - $user = new CmsUser(); - - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "Only managed entities can be marked or checked as read only. But Doctrine\Tests\Models\CMS\CmsUser@"); - $this->_em->getUnitOfWork()->markReadOnly($user); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php deleted file mode 100755 index b72e361539..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php +++ /dev/null @@ -1,1147 +0,0 @@ -addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - - $this->assertTrue(is_array($result)); - - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); - - $this->assertEquals(2, $result[1]['id']); - $this->assertEquals('jwage', $result[1]['name']); - } - - /** - * SELECT PARTIAL u.{id, name} AS user - * FROM Doctrine\Tests\Models\CMS\CmsUser u - */ - public function testSimpleEntityQueryWithAliasedUserEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - - $this->assertTrue(is_array($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); - - $this->assertArrayHasKey('user', $result[1]); - $this->assertEquals(2, $result[1]['user']['id']); - $this->assertEquals('jwage', $result[1]['user']['name']); - } - - /** - * SELECT PARTIAL u.{id, name}, PARTIAL a.{id, topic} - * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a - */ - public function testSimpleMultipleRootEntityQuery() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'a__id' => '1', - 'a__topic' => 'Cool things.' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'a__id' => '2', - 'a__topic' => 'Cool things II.' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(4, count($result)); - - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); - - $this->assertEquals(1, $result[1]['id']); - $this->assertEquals('Cool things.', $result[1]['topic']); - - $this->assertEquals(2, $result[2]['id']); - $this->assertEquals('jwage', $result[2]['name']); - - $this->assertEquals(2, $result[3]['id']); - $this->assertEquals('Cool things II.', $result[3]['topic']); - } - - /** - * SELECT PARTIAL u.{id, name} AS user, PARTIAL a.{id, topic} - * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a - */ - public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'a__id' => '1', - 'a__topic' => 'Cool things.' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'a__id' => '2', - 'a__topic' => 'Cool things II.' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); - - $this->assertArrayHasKey(0, $result[1]); - $this->assertEquals(1, $result[1][0]['id']); - $this->assertEquals('Cool things.', $result[1][0]['topic']); - - $this->assertArrayHasKey('user', $result[2]); - $this->assertEquals(2, $result[2]['user']['id']); - $this->assertEquals('jwage', $result[2]['user']['name']); - - $this->assertArrayHasKey(0, $result[3]); - $this->assertEquals(2, $result[3][0]['id']); - $this->assertEquals('Cool things II.', $result[3][0]['topic']); - } - - /** - * SELECT PARTIAL u.{id, name}, PARTIAL a.{id, topic} AS article - * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a - */ - public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'a__id' => '1', - 'a__topic' => 'Cool things.' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'a__id' => '2', - 'a__topic' => 'Cool things II.' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey(0, $result[0]); - $this->assertEquals(1, $result[0][0]['id']); - $this->assertEquals('romanb', $result[0][0]['name']); - - $this->assertArrayHasKey('article', $result[1]); - $this->assertEquals(1, $result[1]['article']['id']); - $this->assertEquals('Cool things.', $result[1]['article']['topic']); - - $this->assertArrayHasKey(0, $result[2]); - $this->assertEquals(2, $result[2][0]['id']); - $this->assertEquals('jwage', $result[2][0]['name']); - - $this->assertArrayHasKey('article', $result[3]); - $this->assertEquals(2, $result[3]['article']['id']); - $this->assertEquals('Cool things II.', $result[3]['article']['topic']); - } - - /** - * SELECT PARTIAL u.{id, name} AS user, PARTIAL a.{id, topic} AS article - * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a - */ - public function testSimpleMultipleRootEntityQueryWithAliasedEntities() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'a__id' => '1', - 'a__topic' => 'Cool things.' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'a__id' => '2', - 'a__topic' => 'Cool things II.' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); - - $this->assertArrayHasKey('article', $result[1]); - $this->assertEquals(1, $result[1]['article']['id']); - $this->assertEquals('Cool things.', $result[1]['article']['topic']); - - $this->assertArrayHasKey('user', $result[2]); - $this->assertEquals(2, $result[2]['user']['id']); - $this->assertEquals('jwage', $result[2]['user']['name']); - - $this->assertArrayHasKey('article', $result[3]); - $this->assertEquals(2, $result[3]['article']['id']); - $this->assertEquals('Cool things II.', $result[3]['article']['topic']); - } - - /** - * SELECT PARTIAL u.{id, status}, COUNT(p.phonenumber) AS numPhones - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * JOIN u.phonenumbers p - * GROUP BY u.status, u.id - * - * @dataProvider provideDataForUserEntityResult - */ - public function testMixedQueryNormalJoin($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'numPhones'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => '2', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => '1', - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - - // first user => 2 phonenumbers - $this->assertArrayHasKey($userEntityKey, $result[0]); - $this->assertEquals(2, $result[0]['numPhones']); - - // second user => 1 phonenumber - $this->assertArrayHasKey($userEntityKey, $result[1]); - $this->assertEquals(1, $result[1]['numPhones']); - } - - /** - * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) AS nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * JOIN u.phonenumbers p - * - * @dataProvider provideDataForUserEntityResult - */ - public function testMixedQueryFetchJoin($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - - // first user => 2 phonenumbers - $this->assertEquals(2, count($result[0][$userEntityKey]['phonenumbers'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - - // second user => 1 phonenumber - $this->assertEquals(1, count($result[1][$userEntityKey]['phonenumbers'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); - - $this->assertEquals(42, $result[0][$userEntityKey]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][$userEntityKey]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][$userEntityKey]['phonenumbers'][0]['phonenumber']); - } - - /** - * SELECT PARTIAL u.{id, status}, UPPER(u.name) nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * INDEX BY u.id - * JOIN u.phonenumbers p - * INDEX BY p.phonenumber - * - * @dataProvider provideDataForUserEntityResult - */ - public function testMixedQueryFetchJoinCustomIndex($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - $rsm->addIndexBy('u', 'id'); - $rsm->addIndexBy('p', 'phonenumber'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91' - ) - ); - - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[1])); - $this->assertTrue(is_array($result[2])); - - // test the scalar values - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); - - // first user => 2 phonenumbers. notice the custom indexing by user id - $this->assertEquals(2, count($result[1][$userEntityKey]['phonenumbers'])); - - // second user => 1 phonenumber. notice the custom indexing by user id - $this->assertEquals(1, count($result[2][$userEntityKey]['phonenumbers'])); - - // test the custom indexing of the phonenumbers - $this->assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['42'])); - $this->assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['43'])); - $this->assertTrue(isset($result[2][$userEntityKey]['phonenumbers']['91'])); - } - - /** - * select u.id, u.status, p.phonenumber, upper(u.name) nameUpper, a.id, a.topic - * from User u - * join u.phonenumbers p - * join u.articles a - * = - * select u.id, u.status, p.phonenumber, upper(u.name) as u__0, a.id, a.topic - * from USERS u - * inner join PHONENUMBERS p ON u.id = p.user_id - * inner join ARTICLES a ON u.id = a.user_id - */ - public function testMixedQueryMultipleFetchJoin() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsArticle', - 'a', - 'u', - 'articles' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '1', - 'a__topic' => 'Getting things done!' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - 'a__id' => '1', - 'a__topic' => 'Getting things done!' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '2', - 'a__topic' => 'ZendCon' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - 'a__id' => '2', - 'a__topic' => 'ZendCon' - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - 'a__id' => '3', - 'a__topic' => 'LINQ' - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - 'a__id' => '4', - 'a__topic' => 'PHP6' - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - // first user => 2 phonenumbers, 2 articles - $this->assertEquals(2, count($result[0][0]['phonenumbers'])); - $this->assertEquals(2, count($result[0][0]['articles'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - // second user => 1 phonenumber, 2 articles - $this->assertEquals(1, count($result[1][0]['phonenumbers'])); - $this->assertEquals(2, count($result[1][0]['articles'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); - - $this->assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); - - $this->assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); - $this->assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); - $this->assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); - $this->assertEquals('PHP6', $result[1][0]['articles'][1]['topic']); - } - - /** - * select u.id, u.status, p.phonenumber, upper(u.name) nameUpper, a.id, a.topic, - * c.id, c.topic - * from User u - * join u.phonenumbers p - * join u.articles a - * left join a.comments c - * = - * select u.id, u.status, p.phonenumber, upper(u.name) as u__0, a.id, a.topic, - * c.id, c.topic - * from USERS u - * inner join PHONENUMBERS p ON u.id = p.user_id - * inner join ARTICLES a ON u.id = a.user_id - * left outer join COMMENTS c ON a.id = c.article_id - */ - public function testMixedQueryMultipleDeepMixedFetchJoin() - { - - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsArticle', - 'a', - 'u', - 'articles' - ); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsComment', - 'c', - 'a', - 'comments' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - $rsm->addFieldResult('c', 'c__id', 'id'); - $rsm->addFieldResult('c', 'c__topic', 'topic'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '1', - 'a__topic' => 'Getting things done!', - 'c__id' => '1', - 'c__topic' => 'First!' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - 'a__id' => '1', - 'a__topic' => 'Getting things done!', - 'c__id' => '1', - 'c__topic' => 'First!' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '2', - 'a__topic' => 'ZendCon', - 'c__id' => null, - 'c__topic' => null - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - 'a__id' => '2', - 'a__topic' => 'ZendCon', - 'c__id' => null, - 'c__topic' => null - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - 'a__id' => '3', - 'a__topic' => 'LINQ', - 'c__id' => null, - 'c__topic' => null - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - 'a__id' => '4', - 'a__topic' => 'PHP6', - 'c__id' => null, - 'c__topic' => null - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - - // first user => 2 phonenumbers, 2 articles, 1 comment on first article - $this->assertEquals(2, count($result[0][0]['phonenumbers'])); - $this->assertEquals(2, count($result[0][0]['articles'])); - $this->assertEquals(1, count($result[0][0]['articles'][0]['comments'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - // second user => 1 phonenumber, 2 articles, no comments - $this->assertEquals(1, count($result[1][0]['phonenumbers'])); - $this->assertEquals(2, count($result[1][0]['articles'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); - - $this->assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); - - $this->assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); - $this->assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); - $this->assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); - $this->assertEquals('PHP6', $result[1][0]['articles'][1]['topic']); - - $this->assertEquals('First!', $result[0][0]['articles'][0]['comments'][0]['topic']); - - $this->assertTrue(isset($result[0][0]['articles'][0]['comments'])); - - // empty comment collections - $this->assertTrue(is_array($result[0][0]['articles'][1]['comments'])); - $this->assertEquals(0, count($result[0][0]['articles'][1]['comments'])); - $this->assertTrue(is_array($result[1][0]['articles'][0]['comments'])); - $this->assertEquals(0, count($result[1][0]['articles'][0]['comments'])); - $this->assertTrue(is_array($result[1][0]['articles'][1]['comments'])); - $this->assertEquals(0, count($result[1][0]['articles'][1]['comments'])); - } - - /** - * Tests that the hydrator does not rely on a particular order of the rows - * in the result set. - * - * DQL: - * select c.id, c.position, c.name, b.id, b.position - * from \Doctrine\Tests\Models\Forum\ForumCategory c inner join c.boards b - * order by c.position asc, b.position asc - * - * Checks whether the boards are correctly assigned to the categories. - * - * The 'evil' result set that confuses the object population is displayed below. - * - * c.id | c.position | c.name | boardPos | b.id | b.category_id (just for clarity) - * 1 | 0 | First | 0 | 1 | 1 - * 2 | 0 | Second | 0 | 2 | 2 <-- - * 1 | 0 | First | 1 | 3 | 1 - * 1 | 0 | First | 2 | 4 | 1 - */ - public function testEntityQueryCustomResultSetOrder() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\Forum\ForumCategory', 'c'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\Forum\ForumBoard', - 'b', - 'c', - 'boards' - ); - - $rsm->addFieldResult('c', 'c__id', 'id'); - $rsm->addFieldResult('c', 'c__position', 'position'); - $rsm->addFieldResult('c', 'c__name', 'name'); - $rsm->addFieldResult('b', 'b__id', 'id'); - $rsm->addFieldResult('b', 'b__position', 'position'); - - // Faked result set - $resultSet = array( - array( - 'c__id' => '1', - 'c__position' => '0', - 'c__name' => 'First', - 'b__id' => '1', - 'b__position' => '0', - //'b__category_id' => '1' - ), - array( - 'c__id' => '2', - 'c__position' => '0', - 'c__name' => 'Second', - 'b__id' => '2', - 'b__position' => '0', - //'b__category_id' => '2' - ), - array( - 'c__id' => '1', - 'c__position' => '0', - 'c__name' => 'First', - 'b__id' => '3', - 'b__position' => '1', - //'b__category_id' => '1' - ), - array( - 'c__id' => '1', - 'c__position' => '0', - 'c__name' => 'First', - 'b__id' => '4', - 'b__position' => '2', - //'b__category_id' => '1' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - $this->assertTrue(isset($result[0]['boards'])); - $this->assertEquals(3, count($result[0]['boards'])); - $this->assertTrue(isset($result[1]['boards'])); - $this->assertEquals(1, count($result[1]['boards'])); - } - - /** - * SELECT PARTIAL u.{id,status}, a.id, a.topic, c.id as cid, c.topic as ctopic - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * LEFT JOIN u.articles a - * LEFT JOIN a.comments c - * - * @dataProvider provideDataForUserEntityResult - */ - public function testChainedJoinWithScalars($entityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $entityKey ?: null); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('a__id', 'id'); - $rsm->addScalarResult('a__topic', 'topic'); - $rsm->addScalarResult('c__id', 'cid'); - $rsm->addScalarResult('c__topic', 'ctopic'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'a__id' => '1', - 'a__topic' => 'The First', - 'c__id' => '1', - 'c__topic' => 'First Comment' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'a__id' => '1', - 'a__topic' => 'The First', - 'c__id' => '2', - 'c__topic' => 'Second Comment' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'a__id' => '42', - 'a__topic' => 'The Answer', - 'c__id' => null, - 'c__topic' => null - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(3, count($result)); - - $this->assertEquals(2, count($result[0][$entityKey])); // User array - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('The First', $result[0]['topic']); - $this->assertEquals(1, $result[0]['cid']); - $this->assertEquals('First Comment', $result[0]['ctopic']); - - $this->assertEquals(2, count($result[1][$entityKey])); // User array, duplicated - $this->assertEquals(1, $result[1]['id']); // duplicated - $this->assertEquals('The First', $result[1]['topic']); // duplicated - $this->assertEquals(2, $result[1]['cid']); - $this->assertEquals('Second Comment', $result[1]['ctopic']); - - $this->assertEquals(2, count($result[2][$entityKey])); // User array, duplicated - $this->assertEquals(42, $result[2]['id']); - $this->assertEquals('The Answer', $result[2]['topic']); - $this->assertNull($result[2]['cid']); - $this->assertNull($result[2]['ctopic']); - } - - /** - * SELECT PARTIAL u.{id, status} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - */ - public function testResultIteration() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $iterator = $hydrator->iterate($stmt, $rsm); - $rowNum = 0; - - while (($row = $iterator->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertTrue(is_array($row[0])); - - if ($rowNum == 0) { - $this->assertEquals(1, $row[0]['id']); - $this->assertEquals('romanb', $row[0]['name']); - } else if ($rowNum == 1) { - $this->assertEquals(2, $row[0]['id']); - $this->assertEquals('jwage', $row[0]['name']); - } - - ++$rowNum; - } - } - - /** - * SELECT PARTIAL u.{id, status} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - */ - public function testResultIterationWithAliasedUserEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $iterator = $hydrator->iterate($stmt, $rsm); - $rowNum = 0; - - while (($row = $iterator->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertArrayHasKey(0, $row); - $this->assertArrayHasKey('user', $row[0]); - - if ($rowNum == 0) { - $this->assertEquals(1, $row[0]['user']['id']); - $this->assertEquals('romanb', $row[0]['user']['name']); - } else if ($rowNum == 1) { - $this->assertEquals(2, $row[0]['user']['id']); - $this->assertEquals('jwage', $row[0]['user']['name']); - } - - ++$rowNum; - } - } - - /** - * SELECT PARTIAL u.{id, name} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-644 - */ - public function testSkipUnknownColumns() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'foo' => 'bar', // unknown! - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(1, count($result)); - $this->assertArrayHasKey('id', $result[0]); - $this->assertArrayHasKey('name', $result[0]); - $this->assertArrayNotHasKey('foo', $result[0]); - } - - /** - * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-1358 - * @dataProvider provideDataForUserEntityResult - */ - public function testMissingIdForRootEntity($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - ), - array( - 'u__id' => null, - 'u__status' => null, - 'sclr0' => 'ROMANB', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - ), - array( - 'u__id' => null, - 'u__status' => null, - 'sclr0' => 'JWAGE', - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(4, count($result), "Should hydrate four results."); - - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); - $this->assertEquals('JWAGE', $result[3]['nameUpper']); - - $this->assertEquals(array('id' => 1, 'status' => 'developer'), $result[0][$userEntityKey]); - $this->assertNull($result[1][$userEntityKey]); - $this->assertEquals(array('id' => 2, 'status' => 'developer'), $result[2][$userEntityKey]); - $this->assertNull($result[3][$userEntityKey]); - } - - /** - * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * INDEX BY u.id - * - * @group DDC-1385 - * @dataProvider provideDataForUserEntityResult - */ - public function testIndexByAndMixedResult($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addIndexBy('u', 'id'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(2, count($result)); - - $this->assertTrue(isset($result[1])); - $this->assertEquals(1, $result[1][$userEntityKey]['id']); - - $this->assertTrue(isset($result[2])); - $this->assertEquals(2, $result[2][$userEntityKey]['id']); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php deleted file mode 100755 index 09be6bcd37..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php +++ /dev/null @@ -1,29 +0,0 @@ -_getTestEntityManager(); - $config = $em->getConfiguration(); - $config->addCustomHydrationMode('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator'); - - $hydrator = $em->newHydrator('CustomHydrator'); - $this->assertInstanceOf('Doctrine\Tests\ORM\Hydration\CustomHydrator', $hydrator); - $this->assertNull($config->getCustomHydrationMode('does not exist')); - } -} - -class CustomHydrator extends AbstractHydrator -{ - protected function hydrateAllData() - { - return $this->_stmt->fetchAll(PDO::FETCH_ASSOC); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php deleted file mode 100755 index 6602403917..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php +++ /dev/null @@ -1,30 +0,0 @@ -_em = $this->_getTestEntityManager(); - } - - /** Helper method */ - protected function _createParserResult($resultSetMapping, $isMixedQuery = false) - { - $parserResult = new ParserResult; - $parserResult->setResultSetMapping($resultSetMapping); - //$parserResult->setDefaultQueryComponentAlias(key($queryComponents)); - //$parserResult->setTableAliasMap($tableToClassAliasMap); - $parserResult->setMixedQuery($isMixedQuery); - return $parserResult; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php deleted file mode 100755 index 33636b4ec6..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ /dev/null @@ -1,1931 +0,0 @@ -addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]); - - $this->assertEquals(1, $result[0]->id); - $this->assertEquals('romanb', $result[0]->name); - - $this->assertEquals(2, $result[1]->id); - $this->assertEquals('jwage', $result[1]->name); - } - - /** - * SELECT PARTIAL u.{id,name} AS user - * FROM Doctrine\Tests\Models\CMS\CmsUser u - */ - public function testSimpleEntityQueryWithAliasedUserEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); - - $this->assertArrayHasKey('user', $result[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]['user']); - - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); - - $this->assertEquals(2, $result[1]['user']->id); - $this->assertEquals('jwage', $result[1]['user']->name); - } - - /** - * SELECT PARTIAL u.{id, name}, PARTIAL a.{id, topic} - * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a - */ - public function testSimpleMultipleRootEntityQuery() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'a__id' => '1', - 'a__topic' => 'Cool things.' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'a__id' => '2', - 'a__topic' => 'Cool things II.' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(4, count($result)); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3]); - - $this->assertEquals(1, $result[0]->id); - $this->assertEquals('romanb', $result[0]->name); - - $this->assertEquals(1, $result[1]->id); - $this->assertEquals('Cool things.', $result[1]->topic); - - $this->assertEquals(2, $result[2]->id); - $this->assertEquals('jwage', $result[2]->name); - - $this->assertEquals(2, $result[3]->id); - $this->assertEquals('Cool things II.', $result[3]->topic); - } - - /** - * SELECT PARTIAL u.{id, name} AS user, PARTIAL a.{id, topic} - * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a - */ - public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'a__id' => '1', - 'a__topic' => 'Cool things.' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'a__id' => '2', - 'a__topic' => 'Cool things II.' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertArrayNotHasKey(0, $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); - - $this->assertArrayHasKey(0, $result[1]); - $this->assertArrayNotHasKey('user', $result[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]); - $this->assertEquals(1, $result[1][0]->id); - $this->assertEquals('Cool things.', $result[1][0]->topic); - - $this->assertArrayHasKey('user', $result[2]); - $this->assertArrayNotHasKey(0, $result[2]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2]['user']); - $this->assertEquals(2, $result[2]['user']->id); - $this->assertEquals('jwage', $result[2]['user']->name); - - $this->assertArrayHasKey(0, $result[3]); - $this->assertArrayNotHasKey('user', $result[3]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3][0]); - $this->assertEquals(2, $result[3][0]->id); - $this->assertEquals('Cool things II.', $result[3][0]->topic); - } - - /** - * SELECT PARTIAL u.{id, name}, PARTIAL a.{id, topic} AS article - * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a - */ - public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'a__id' => '1', - 'a__topic' => 'Cool things.' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'a__id' => '2', - 'a__topic' => 'Cool things II.' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey(0, $result[0]); - $this->assertArrayNotHasKey('article', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); - $this->assertEquals(1, $result[0][0]->id); - $this->assertEquals('romanb', $result[0][0]->name); - - $this->assertArrayHasKey('article', $result[1]); - $this->assertArrayNotHasKey(0, $result[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1]['article']); - $this->assertEquals(1, $result[1]['article']->id); - $this->assertEquals('Cool things.', $result[1]['article']->topic); - - $this->assertArrayHasKey(0, $result[2]); - $this->assertArrayNotHasKey('article', $result[2]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2][0]); - $this->assertEquals(2, $result[2][0]->id); - $this->assertEquals('jwage', $result[2][0]->name); - - $this->assertArrayHasKey('article', $result[3]); - $this->assertArrayNotHasKey(0, $result[3]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3]['article']); - $this->assertEquals(2, $result[3]['article']->id); - $this->assertEquals('Cool things II.', $result[3]['article']->topic); - } - - /** - * SELECT PARTIAL u.{id, name} AS user, PARTIAL a.{id, topic} AS article - * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a - */ - public function testSimpleMultipleRootEntityQueryWithAliasedEntities() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'a__id' => '1', - 'a__topic' => 'Cool things.' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'a__id' => '2', - 'a__topic' => 'Cool things II.' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertArrayNotHasKey('article', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); - - $this->assertArrayHasKey('article', $result[1]); - $this->assertArrayNotHasKey('user', $result[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1]['article']); - $this->assertEquals(1, $result[1]['article']->id); - $this->assertEquals('Cool things.', $result[1]['article']->topic); - - $this->assertArrayHasKey('user', $result[2]); - $this->assertArrayNotHasKey('article', $result[2]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2]['user']); - $this->assertEquals(2, $result[2]['user']->id); - $this->assertEquals('jwage', $result[2]['user']->name); - - $this->assertArrayHasKey('article', $result[3]); - $this->assertArrayNotHasKey('user', $result[3]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3]['article']); - $this->assertEquals(2, $result[3]['article']->id); - $this->assertEquals('Cool things II.', $result[3]['article']->topic); - } - - /** - * SELECT PARTIAL u.{id, status}, COUNT(p.phonenumber) numPhones - * FROM User u - * JOIN u.phonenumbers p - * GROUP BY u.id - * - * @dataProvider provideDataForUserEntityResult - */ - public function testMixedQueryNormalJoin($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'numPhones'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => '2', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => '1', - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInternalType('array', $result); - $this->assertInternalType('array', $result[0]); - $this->assertInternalType('array', $result[1]); - - // first user => 2 phonenumbers - $this->assertEquals(2, $result[0]['numPhones']); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); - - // second user => 1 phonenumber - $this->assertEquals(1, $result[1]['numPhones']); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); - } - - /** - * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * JOIN u.phonenumbers p - * - * @dataProvider provideDataForUserEntityResult - */ - public function testMixedQueryFetchJoin($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'p__phonenumber' => '42', - 'sclr0' => 'ROMANB', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'p__phonenumber' => '43', - 'sclr0' => 'ROMANB', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'p__phonenumber' => '91', - 'sclr0' => 'JWAGE', - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInternalType('array', $result); - $this->assertInternalType('array', $result[0]); - $this->assertInternalType('array', $result[1]); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[0]); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[1]); - - // first user => 2 phonenumbers - $this->assertEquals(2, count($result[0][$userEntityKey]->phonenumbers)); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - - // second user => 1 phonenumber - $this->assertEquals(1, count($result[1][$userEntityKey]->phonenumbers)); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); - - $this->assertEquals(42, $result[0][$userEntityKey]->phonenumbers[0]->phonenumber); - $this->assertEquals(43, $result[0][$userEntityKey]->phonenumbers[1]->phonenumber); - $this->assertEquals(91, $result[1][$userEntityKey]->phonenumbers[0]->phonenumber); - } - - /** - * SELECT u, p, UPPER(u.name) nameUpper - * FROM User u - * INDEX BY u.id - * JOIN u.phonenumbers p - * INDEX BY p.phonenumber - * - * @dataProvider provideDataForUserEntityResult - */ - public function testMixedQueryFetchJoinCustomIndex($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - $rsm->addIndexBy('u', 'id'); - $rsm->addIndexBy('p', 'phonenumber'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91' - ) - ); - - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInternalType('array', $result); - $this->assertInternalType('array', $result[1]); - $this->assertInternalType('array', $result[2]); - - // test the scalar values - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2][$userEntityKey]); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->phonenumbers); - - // first user => 2 phonenumbers. notice the custom indexing by user id - $this->assertEquals(2, count($result[1][$userEntityKey]->phonenumbers)); - - // second user => 1 phonenumber. notice the custom indexing by user id - $this->assertEquals(1, count($result[2][$userEntityKey]->phonenumbers)); - - // test the custom indexing of the phonenumbers - $this->assertTrue(isset($result[1][$userEntityKey]->phonenumbers['42'])); - $this->assertTrue(isset($result[1][$userEntityKey]->phonenumbers['43'])); - $this->assertTrue(isset($result[2][$userEntityKey]->phonenumbers['91'])); - } - - /** - * SELECT u, p, UPPER(u.name) nameUpper, a - * FROM User u - * JOIN u.phonenumbers p - * JOIN u.articles a - * - * @dataProvider provideDataForUserEntityResult - */ - public function testMixedQueryMultipleFetchJoin($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsArticle', - 'a', - 'u', - 'articles' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '1', - 'a__topic' => 'Getting things done!' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - 'a__id' => '1', - 'a__topic' => 'Getting things done!' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '2', - 'a__topic' => 'ZendCon' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - 'a__id' => '2', - 'a__topic' => 'ZendCon' - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - 'a__id' => '3', - 'a__topic' => 'LINQ' - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - 'a__id' => '4', - 'a__topic' => 'PHP6' - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[1]); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->articles); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][$userEntityKey]->articles[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][$userEntityKey]->articles[1]); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[1][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][$userEntityKey]->articles[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][$userEntityKey]->articles[1]); - } - - /** - * SELECT u, p, UPPER(u.name) nameUpper, a, c - * FROM User u - * JOIN u.phonenumbers p - * JOIN u.articles a - * LEFT JOIN a.comments c - * - * @dataProvider provideDataForUserEntityResult - */ - public function testMixedQueryMultipleDeepMixedFetchJoin($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsArticle', - 'a', - 'u', - 'articles' - ); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsComment', - 'c', - 'a', - 'comments' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - $rsm->addFieldResult('c', 'c__id', 'id'); - $rsm->addFieldResult('c', 'c__topic', 'topic'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '1', - 'a__topic' => 'Getting things done!', - 'c__id' => '1', - 'c__topic' => 'First!' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - 'a__id' => '1', - 'a__topic' => 'Getting things done!', - 'c__id' => '1', - 'c__topic' => 'First!' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '2', - 'a__topic' => 'ZendCon', - 'c__id' => null, - 'c__topic' => null - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - 'a__id' => '2', - 'a__topic' => 'ZendCon', - 'c__id' => null, - 'c__topic' => null - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - 'a__id' => '3', - 'a__topic' => 'LINQ', - 'c__id' => null, - 'c__topic' => null - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - 'a__id' => '4', - 'a__topic' => 'PHP6', - 'c__id' => null, - 'c__topic' => null - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); - - // phonenumbers - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[1]); - - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[1][$userEntityKey]->phonenumbers[0]); - - // articles - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->articles); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][$userEntityKey]->articles[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][$userEntityKey]->articles[1]); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][$userEntityKey]->articles[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][$userEntityKey]->articles[1]); - - // article comments - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->articles[0]->comments); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsComment', $result[0][$userEntityKey]->articles[0]->comments[0]); - - // empty comment collections - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->articles[1]->comments); - $this->assertEquals(0, count($result[0][$userEntityKey]->articles[1]->comments)); - - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->articles[0]->comments); - $this->assertEquals(0, count($result[1][$userEntityKey]->articles[0]->comments)); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->articles[1]->comments); - $this->assertEquals(0, count($result[1][$userEntityKey]->articles[1]->comments)); - } - - /** - * Tests that the hydrator does not rely on a particular order of the rows - * in the result set. - * - * DQL: - * select c, b from Doctrine\Tests\Models\Forum\ForumCategory c inner join c.boards b - * order by c.position asc, b.position asc - * - * Checks whether the boards are correctly assigned to the categories. - * - * The 'evil' result set that confuses the object population is displayed below. - * - * c.id | c.position | c.name | boardPos | b.id | b.category_id (just for clarity) - * 1 | 0 | First | 0 | 1 | 1 - * 2 | 0 | Second | 0 | 2 | 2 <-- - * 1 | 0 | First | 1 | 3 | 1 - * 1 | 0 | First | 2 | 4 | 1 - */ - public function testEntityQueryCustomResultSetOrder() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\Forum\ForumCategory', 'c'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\Forum\ForumBoard', - 'b', - 'c', - 'boards' - ); - $rsm->addFieldResult('c', 'c__id', 'id'); - $rsm->addFieldResult('c', 'c__position', 'position'); - $rsm->addFieldResult('c', 'c__name', 'name'); - $rsm->addFieldResult('b', 'b__id', 'id'); - $rsm->addFieldResult('b', 'b__position', 'position'); - - // Faked result set - $resultSet = array( - array( - 'c__id' => '1', - 'c__position' => '0', - 'c__name' => 'First', - 'b__id' => '1', - 'b__position' => '0', - //'b__category_id' => '1' - ), - array( - 'c__id' => '2', - 'c__position' => '0', - 'c__name' => 'Second', - 'b__id' => '2', - 'b__position' => '0', - //'b__category_id' => '2' - ), - array( - 'c__id' => '1', - 'c__position' => '0', - 'c__name' => 'First', - 'b__id' => '3', - 'b__position' => '1', - //'b__category_id' => '1' - ), - array( - 'c__id' => '1', - 'c__position' => '0', - 'c__name' => 'First', - 'b__id' => '4', - 'b__position' => '2', - //'b__category_id' => '1' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInstanceOf('Doctrine\Tests\Models\Forum\ForumCategory', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\Forum\ForumCategory', $result[1]); - - $this->assertTrue($result[0] !== $result[1]); - - $this->assertEquals(1, $result[0]->getId()); - $this->assertEquals(2, $result[1]->getId()); - - $this->assertTrue(isset($result[0]->boards)); - $this->assertEquals(3, count($result[0]->boards)); - - $this->assertTrue(isset($result[1]->boards)); - $this->assertEquals(1, count($result[1]->boards)); - } - - /** - * SELECT PARTIAL u.{id,name} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-644 - */ - public function testSkipUnknownColumns() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'foo' => 'bar', // unknown! - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(1, count($result)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - } - - /** - * SELECT u.id, u.name - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @dataProvider provideDataForUserEntityResult - */ - public function testScalarQueryWithoutResultVariables($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addScalarResult('sclr0', 'id'); - $rsm->addScalarResult('sclr1', 'name'); - - // Faked result set - $resultSet = array( - array( - 'sclr0' => '1', - 'sclr1' => 'romanb' - ), - array( - 'sclr0' => '2', - 'sclr1' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInternalType('array', $result[0]); - $this->assertInternalType('array', $result[1]); - - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); - - $this->assertEquals(2, $result[1]['id']); - $this->assertEquals('jwage', $result[1]['name']); - } - - /** - * SELECT p - * FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p - */ - public function testCreatesProxyForLazyLoadingWithForeignKeys() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\ECommerce\ECommerceProduct', 'p'); - $rsm->addFieldResult('p', 'p__id', 'id'); - $rsm->addFieldResult('p', 'p__name', 'name'); - $rsm->addMetaResult('p', 'p__shipping_id', 'shipping_id'); - - // Faked result set - $resultSet = array( - array( - 'p__id' => '1', - 'p__name' => 'Doctrine Book', - 'p__shipping_id' => 42 - ) - ); - - $proxyInstance = new \Doctrine\Tests\Models\ECommerce\ECommerceShipping(); - - // mocking the proxy factory - $proxyFactory = $this->getMock('Doctrine\ORM\Proxy\ProxyFactory', array('getProxy'), array(), '', false, false, false); - $proxyFactory->expects($this->once()) - ->method('getProxy') - ->with($this->equalTo('Doctrine\Tests\Models\ECommerce\ECommerceShipping'), array('id' => 42)) - ->will($this->returnValue($proxyInstance)); - - $this->_em->setProxyFactory($proxyFactory); - - // configuring lazy loading - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); - $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(1, count($result)); - - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $result[0]); - } - - /** - * SELECT p AS product - * FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p - */ - public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\ECommerce\ECommerceProduct', 'p', 'product'); - $rsm->addFieldResult('p', 'p__id', 'id'); - $rsm->addFieldResult('p', 'p__name', 'name'); - $rsm->addMetaResult('p', 'p__shipping_id', 'shipping_id'); - - // Faked result set - $resultSet = array( - array( - 'p__id' => '1', - 'p__name' => 'Doctrine Book', - 'p__shipping_id' => 42 - ) - ); - - $proxyInstance = new \Doctrine\Tests\Models\ECommerce\ECommerceShipping(); - - // mocking the proxy factory - $proxyFactory = $this->getMock('Doctrine\ORM\Proxy\ProxyFactory', array('getProxy'), array(), '', false, false, false); - $proxyFactory->expects($this->once()) - ->method('getProxy') - ->with($this->equalTo('Doctrine\Tests\Models\ECommerce\ECommerceShipping'), array('id' => 42)) - ->will($this->returnValue($proxyInstance)); - - $this->_em->setProxyFactory($proxyFactory); - - // configuring lazy loading - $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); - $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertEquals(1, count($result)); - - $this->assertInternalType('array', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $result[0]['product']); - } - - /** - * SELECT PARTIAL u.{id, status}, PARTIAL a.{id, topic}, PARTIAL c.{id, topic} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * LEFT JOIN u.articles a - * LEFT JOIN a.comments c - */ - public function testChainedJoinWithEmptyCollections() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsArticle', - 'a', - 'u', - 'articles' - ); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsComment', - 'c', - 'a', - 'comments' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - $rsm->addFieldResult('c', 'c__id', 'id'); - $rsm->addFieldResult('c', 'c__topic', 'topic'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'a__id' => null, - 'a__topic' => null, - 'c__id' => null, - 'c__topic' => null - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'a__id' => null, - 'a__topic' => null, - 'c__id' => null, - 'c__topic' => null - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]); - - $this->assertEquals(0, $result[0]->articles->count()); - $this->assertEquals(0, $result[1]->articles->count()); - } - - /** - * SELECT PARTIAL u.{id, status} AS user, PARTIAL a.{id, topic}, PARTIAL c.{id, topic} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * LEFT JOIN u.articles a - * LEFT JOIN a.comments c - */ - public function testChainedJoinWithEmptyCollectionsWithAliasedUserEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsArticle', - 'a', - 'u', - 'articles' - ); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsComment', - 'c', - 'a', - 'comments' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__topic', 'topic'); - $rsm->addFieldResult('c', 'c__id', 'id'); - $rsm->addFieldResult('c', 'c__topic', 'topic'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'a__id' => null, - 'a__topic' => null, - 'c__id' => null, - 'c__topic' => null - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'a__id' => null, - 'a__topic' => null, - 'c__id' => null, - 'c__topic' => null - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInternalType('array', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); - - $this->assertInternalType('array', $result[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]['user']); - - $this->assertEquals(0, $result[0]['user']->articles->count()); - $this->assertEquals(0, $result[1]['user']->articles->count()); - } - - /** - * SELECT PARTIAL u.{id,status}, a.id, a.topic, c.id as cid, c.topic as ctopic - * FROM CmsUser u - * LEFT JOIN u.articles a - * LEFT JOIN a.comments c - * - * @group bubu - * @dataProvider provideDataForUserEntityResult - */ - /*public function testChainedJoinWithScalars($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('a__id', 'id'); - $rsm->addScalarResult('a__topic', 'topic'); - $rsm->addScalarResult('c__id', 'cid'); - $rsm->addScalarResult('c__topic', 'ctopic'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'a__id' => '1', - 'a__topic' => 'The First', - 'c__id' => '1', - 'c__topic' => 'First Comment' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'a__id' => '1', - 'a__topic' => 'The First', - 'c__id' => '2', - 'c__topic' => 'Second Comment' - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'a__id' => '42', - 'a__topic' => 'The Answer', - 'c__id' => null, - 'c__topic' => null - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - \Doctrine\Common\Util\Debug::dump($result, 3); - - $this->assertEquals(1, count($result)); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); // User object - $this->assertEquals(42, $result[0]['id']); - $this->assertEquals('The First', $result[0]['topic']); - $this->assertEquals(1, $result[0]['cid']); - $this->assertEquals('First Comment', $result[0]['ctopic']); - }*/ - - /** - * SELECT PARTIAL u.{id, name} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - */ - public function testResultIteration() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $iterableResult = $hydrator->iterate($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - $rowNum = 0; - - while (($row = $iterableResult->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $row[0]); - - if ($rowNum == 0) { - $this->assertEquals(1, $row[0]->id); - $this->assertEquals('romanb', $row[0]->name); - } else if ($rowNum == 1) { - $this->assertEquals(2, $row[0]->id); - $this->assertEquals('jwage', $row[0]->name); - } - - ++$rowNum; - } - } - - /** - * SELECT PARTIAL u.{id, name} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - */ - public function testResultIterationWithAliasedUserEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $iterableResult = $hydrator->iterate($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - $rowNum = 0; - - while (($row = $iterableResult->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertArrayHasKey(0, $row); - $this->assertArrayHasKey('user', $row[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $row[0]['user']); - - if ($rowNum == 0) { - $this->assertEquals(1, $row[0]['user']->id); - $this->assertEquals('romanb', $row[0]['user']->name); - } else if ($rowNum == 1) { - $this->assertEquals(2, $row[0]['user']->id); - $this->assertEquals('jwage', $row[0]['user']->name); - } - - ++$rowNum; - } - } - - /** - * Checks if multiple joined multiple-valued collections is hydrated correctly. - * - * SELECT PARTIAL u.{id, status}, PARTIAL g.{id, name}, PARTIAL p.{phonenumber} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-809 - */ - public function testManyToManyHydration() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsGroup', 'g', 'u', 'groups'); - $rsm->addFieldResult('g', 'g__id', 'id'); - $rsm->addFieldResult('g', 'g__name', 'name'); - $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'g__id' => '3', - 'g__name' => 'TestGroupB', - 'p__phonenumber' => 1111, - ), - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'g__id' => '5', - 'g__name' => 'TestGroupD', - 'p__phonenumber' => 1111, - ), - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'g__id' => '3', - 'g__name' => 'TestGroupB', - 'p__phonenumber' => 2222, - ), - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'g__id' => '5', - 'g__name' => 'TestGroupD', - 'p__phonenumber' => 2222, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '2', - 'g__name' => 'TestGroupA', - 'p__phonenumber' => 3333, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '3', - 'g__name' => 'TestGroupB', - 'p__phonenumber' => 3333, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '4', - 'g__name' => 'TestGroupC', - 'p__phonenumber' => 3333, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '5', - 'g__name' => 'TestGroupD', - 'p__phonenumber' => 3333, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '2', - 'g__name' => 'TestGroupA', - 'p__phonenumber' => 4444, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '3', - 'g__name' => 'TestGroupB', - 'p__phonenumber' => 4444, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '4', - 'g__name' => 'TestGroupC', - 'p__phonenumber' => 4444, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '5', - 'g__name' => 'TestGroupD', - 'p__phonenumber' => 4444, - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $result); - - $this->assertEquals(2, count($result[0]->groups)); - $this->assertEquals(2, count($result[0]->phonenumbers)); - - $this->assertEquals(4, count($result[1]->groups)); - $this->assertEquals(2, count($result[1]->phonenumbers)); - } - - /** - * Checks if multiple joined multiple-valued collections is hydrated correctly. - * - * SELECT PARTIAL u.{id, status} As user, PARTIAL g.{id, name}, PARTIAL p.{phonenumber} - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-809 - */ - public function testManyToManyHydrationWithAliasedUserEntity() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsGroup', 'g', 'u', 'groups'); - $rsm->addFieldResult('g', 'g__id', 'id'); - $rsm->addFieldResult('g', 'g__name', 'name'); - $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'g__id' => '3', - 'g__name' => 'TestGroupB', - 'p__phonenumber' => 1111, - ), - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'g__id' => '5', - 'g__name' => 'TestGroupD', - 'p__phonenumber' => 1111, - ), - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'g__id' => '3', - 'g__name' => 'TestGroupB', - 'p__phonenumber' => 2222, - ), - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'g__id' => '5', - 'g__name' => 'TestGroupD', - 'p__phonenumber' => 2222, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '2', - 'g__name' => 'TestGroupA', - 'p__phonenumber' => 3333, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '3', - 'g__name' => 'TestGroupB', - 'p__phonenumber' => 3333, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '4', - 'g__name' => 'TestGroupC', - 'p__phonenumber' => 3333, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '5', - 'g__name' => 'TestGroupD', - 'p__phonenumber' => 3333, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '2', - 'g__name' => 'TestGroupA', - 'p__phonenumber' => 4444, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '3', - 'g__name' => 'TestGroupB', - 'p__phonenumber' => 4444, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '4', - 'g__name' => 'TestGroupC', - 'p__phonenumber' => 4444, - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage', - 'g__id' => '5', - 'g__name' => 'TestGroupD', - 'p__phonenumber' => 4444, - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInternalType('array', $result[0]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); - $this->assertInternalType('array', $result[1]); - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]['user']); - - $this->assertEquals(2, count($result[0]['user']->groups)); - $this->assertEquals(2, count($result[0]['user']->phonenumbers)); - - $this->assertEquals(4, count($result[1]['user']->groups)); - $this->assertEquals(2, count($result[1]['user']->phonenumbers)); - } - - /** - * SELECT PARTIAL u.{id, status}, UPPER(u.name) as nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-1358 - * @dataProvider provideDataForUserEntityResult - */ - public function testMissingIdForRootEntity($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - ), - array( - 'u__id' => null, - 'u__status' => null, - 'sclr0' => 'ROMANB', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - ), - array( - 'u__id' => null, - 'u__status' => null, - 'sclr0' => 'JWAGE', - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(4, count($result), "Should hydrate four results."); - - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); - $this->assertEquals('JWAGE', $result[3]['nameUpper']); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); - $this->assertNull($result[1][$userEntityKey]); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2][$userEntityKey]); - $this->assertNull($result[3][$userEntityKey]); - } - - /** - * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) AS nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * LEFT JOIN u.phonenumbers u - * - * @group DDC-1358 - * @dataProvider provideDataForUserEntityResult - */ - public function testMissingIdForCollectionValuedChildEntity($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => null - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91' - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => null - ) - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertEquals(1, $result[0][$userEntityKey]->phonenumbers->count()); - $this->assertEquals(1, $result[1][$userEntityKey]->phonenumbers->count()); - } - - /** - * SELECT PARTIAL u.{id, status}, PARTIAL a.{id, city}, UPPER(u.name) AS nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * JOIN u.address a - * - * @group DDC-1358 - * @dataProvider provideDataForUserEntityResult - */ - public function testMissingIdForSingleValuedChildEntity($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsAddress', - 'a', - 'u', - 'address' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__city', 'city'); - $rsm->addMetaResult('a', 'user_id', 'user_id'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - 'a__id' => 1, - 'a__city' => 'Berlin', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'BENJAMIN', - 'a__id' => null, - 'a__city' => null, - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $result[0][$userEntityKey]->address); - $this->assertNull($result[1][$userEntityKey]->address); - } - - /** - * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * INDEX BY u.id - * - * @group DDC-1385 - * @dataProvider provideDataForUserEntityResult - */ - public function testIndexByAndMixedResult($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addIndexBy('u', 'id'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'sclr0' => 'ROMANB', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'sclr0' => 'JWAGE', - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals(2, count($result)); - - $this->assertTrue(isset($result[1])); - $this->assertEquals(1, $result[1][$userEntityKey]->id); - - $this->assertTrue(isset($result[2])); - $this->assertEquals(2, $result[2][$userEntityKey]->id); - } - - /** - * SELECT UPPER(u.name) AS nameUpper - * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-1385 - * @dataProvider provideDataForUserEntityResult - */ - public function testIndexByScalarsOnly($userEntityKey) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addIndexByScalar('sclr0'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'sclr0' => 'ROMANB', - ), - array( - 'sclr0' => 'JWAGE', - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - - $this->assertEquals( - array( - 'ROMANB' => array('nameUpper' => 'ROMANB'), - 'JWAGE' => array('nameUpper' => 'JWAGE') - ), - $result - ); - } - - - /** - * @group DDC-1470 - * - * @expectedException \Doctrine\ORM\Internal\Hydration\HydrationException - * @expectedExceptionMessage The meta mapping for the discriminator column "c_discr" is missing for "Doctrine\Tests\Models\Company\CompanyFixContract" using the DQL alias "c". - */ - public function testMissingMetaMappingException() - { - $rsm = new ResultSetMapping; - - $rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyFixContract', 'c'); - $rsm->addJoinedEntityResult('Doctrine\Tests\Models\Company\CompanyEmployee', 'e', 'c', 'salesPerson'); - - $rsm->addFieldResult('c', 'c__id', 'id'); - $rsm->setDiscriminatorColumn('c', 'c_discr'); - - $resultSet = array( - array( - 'c__id' => '1', - 'c_discr' => 'fix', - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $hydrator->hydrateAll($stmt, $rsm); - } - - /** - * @group DDC-1470 - * - * @expectedException \Doctrine\ORM\Internal\Hydration\HydrationException - * @expectedExceptionMessage The discriminator column "discr" is missing for "Doctrine\Tests\Models\Company\CompanyEmployee" using the DQL alias "e". - */ - public function testMissingDiscriminatorColumnException() - { - $rsm = new ResultSetMapping; - - $rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyFixContract', 'c'); - $rsm->addJoinedEntityResult('Doctrine\Tests\Models\Company\CompanyEmployee', 'e', 'c', 'salesPerson'); - - $rsm->addFieldResult('c', 'c__id', 'id'); - $rsm->addMetaResult('c', 'c_discr', 'discr'); - $rsm->setDiscriminatorColumn('c', 'c_discr'); - - $rsm->addFieldResult('e', 'e__id', 'id'); - $rsm->addFieldResult('e', 'e__name', 'name'); - $rsm->addMetaResult('e ', 'e_discr', 'discr'); - $rsm->setDiscriminatorColumn('e', 'e_discr'); - - $resultSet = array( - array( - 'c__id' => '1', - 'c_discr' => 'fix', - 'e__id' => '1', - 'e__name' => 'Fabio B. Silva' - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - $hydrator->hydrateAll($stmt, $rsm); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php deleted file mode 100755 index 801937f2d2..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php +++ /dev/null @@ -1,259 +0,0 @@ -_rsm = new ResultSetMapping; - $this->_em = $this->_getTestEntityManager(); - } - - /** - * For SQL: SELECT id, status, username, name FROM cms_users - */ - public function testBasicResultSetMapping() - { - $this->_rsm->addEntityResult( - 'Doctrine\Tests\Models\CMS\CmsUser', - 'u' - ); - $this->_rsm->addFieldResult('u', 'id', 'id'); - $this->_rsm->addFieldResult('u', 'status', 'status'); - $this->_rsm->addFieldResult('u', 'username', 'username'); - $this->_rsm->addFieldResult('u', 'name', 'name'); - - $this->assertFalse($this->_rsm->isScalarResult('id')); - $this->assertFalse($this->_rsm->isScalarResult('status')); - $this->assertFalse($this->_rsm->isScalarResult('username')); - $this->assertFalse($this->_rsm->isScalarResult('name')); - - $this->assertTrue($this->_rsm->getClassName('u') == 'Doctrine\Tests\Models\CMS\CmsUser'); - $class = $this->_rsm->getDeclaringClass('id'); - $this->assertTrue($class == 'Doctrine\Tests\Models\CMS\CmsUser'); - - $this->assertEquals('u', $this->_rsm->getEntityAlias('id')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('status')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('username')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('name')); - - $this->assertEquals('id', $this->_rsm->getFieldName('id')); - $this->assertEquals('status', $this->_rsm->getFieldName('status')); - $this->assertEquals('username', $this->_rsm->getFieldName('username')); - $this->assertEquals('name', $this->_rsm->getFieldName('name')); - } - - /** - * @group DDC-1057 - * - * Fluent interface test, not a real result set mapping - */ - public function testFluentInterface() - { - $rms = $this->_rsm; - - $rms->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser','u') - ->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber','p','u','phonenumbers') - ->addFieldResult('u', 'id', 'id') - ->addFieldResult('u', 'name', 'name') - ->setDiscriminatorColumn('name', 'name') - ->addIndexByColumn('id', 'id') - ->addIndexBy('username', 'username') - ->addIndexByScalar('sclr0') - ->addScalarResult('sclr0', 'numPhones') - ->addMetaResult('a', 'user_id', 'user_id'); - - - $this->assertTrue($rms->hasIndexBy('id')); - $this->assertTrue($rms->isFieldResult('id')); - $this->assertTrue($rms->isFieldResult('name')); - $this->assertTrue($rms->isScalarResult('sclr0')); - $this->assertTrue($rms->isRelation('p')); - $this->assertTrue($rms->hasParentAlias('p')); - $this->assertTrue($rms->isMixedResult()); - } - - /** - * @group DDC-1663 - */ - public function testAddNamedNativeQueryResultSetMapping() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapOneToOne(array( - 'fieldName' => 'email', - 'targetEntity' => 'Doctrine\Tests\Models\CMS\CmsEmail', - 'cascade' => array('persist'), - 'inversedBy' => 'user', - 'orphanRemoval' => false, - 'joinColumns' => array(array( - 'nullable' => true, - 'referencedColumnName' => 'id', - ) - ) - )); - - $cm->addNamedNativeQuery(array( - 'name' => 'find-all', - 'query' => 'SELECT u.id AS user_id, e.id AS email_id, u.name, e.email, u.id + e.id AS scalarColumn FROM cms_users u INNER JOIN cms_emails e ON e.id = u.email_id', - 'resultSetMapping' => 'find-all', - )); - $cm->addSqlResultSetMapping(array( - 'name' => 'find-all', - 'entities' => array( - array( - 'entityClass' => '__CLASS__', - 'fields' => array( - array( - 'name' => 'id', - 'column'=> 'user_id' - ), - array( - 'name' => 'name', - 'column'=> 'name' - ) - ) - ), - array( - 'entityClass' => 'CmsEmail', - 'fields' => array( - array( - 'name' => 'id', - 'column'=> 'email_id' - ), - array( - 'name' => 'email', - 'column'=> 'email' - ) - ) - ) - ), - 'columns' => array( - array( - 'name' => 'scalarColumn' - ) - ) - )); - - - $queryMapping = $cm->getNamedNativeQuery('find-all'); - - $rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em); - $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - - $this->assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); - - $this->assertEquals('c0', $rsm->getEntityAlias('user_id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getClassName('c0')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('name')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('user_id')); - - - $this->assertEquals('c1', $rsm->getEntityAlias('email_id')); - $this->assertEquals('c1', $rsm->getEntityAlias('email')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsEmail', $rsm->getClassName('c1')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsEmail', $rsm->getDeclaringClass('email')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsEmail', $rsm->getDeclaringClass('email_id')); - } - - /** - * @group DDC-1663 - */ - public function testAddNamedNativeQueryResultSetMappingWithoutFields() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->addNamedNativeQuery(array( - 'name' => 'find-all', - 'query' => 'SELECT u.id AS user_id, e.id AS email_id, u.name, e.email, u.id + e.id AS scalarColumn FROM cms_users u INNER JOIN cms_emails e ON e.id = u.email_id', - 'resultSetMapping' => 'find-all', - )); - $cm->addSqlResultSetMapping(array( - 'name' => 'find-all', - 'entities' => array( - array( - 'entityClass' => '__CLASS__', - ) - ), - 'columns' => array( - array( - 'name' => 'scalarColumn' - ) - ) - )); - - - $queryMapping = $cm->getNamedNativeQuery('find-all'); - - $rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em); - $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - - $this->assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); - - $this->assertEquals('c0', $rsm->getEntityAlias('id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals('c0', $rsm->getEntityAlias('status')); - $this->assertEquals('c0', $rsm->getEntityAlias('username')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getClassName('c0')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('id')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('name')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('status')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('username')); - } - - /** - * @group DDC-1663 - */ - public function testAddNamedNativeQueryResultClass() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->addNamedNativeQuery(array( - 'name' => 'find-all', - 'resultClass' => '__CLASS__', - 'query' => 'SELECT * FROM cms_users', - )); - - $queryMapping = $cm->getNamedNativeQuery('find-all'); - - $rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em); - $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - - - $this->assertEquals('c0', $rsm->getEntityAlias('id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals('c0', $rsm->getEntityAlias('status')); - $this->assertEquals('c0', $rsm->getEntityAlias('username')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getClassName('c0')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('id')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('name')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('status')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $rsm->getDeclaringClass('username')); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php deleted file mode 100755 index c8c376f7cd..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php +++ /dev/null @@ -1,101 +0,0 @@ -addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ), - array( - 'u__id' => '2', - 'u__name' => 'jwage' - ) - ); - - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); - - $result = $hydrator->hydrateAll($stmt, $rsm); - - $this->assertTrue(is_array($result)); - $this->assertEquals(2, count($result)); - $this->assertEquals('romanb', $result[0]['u_name']); - $this->assertEquals(1, $result[0]['u_id']); - $this->assertEquals('jwage', $result[1]['u_name']); - $this->assertEquals(2, $result[1]['u_id']); - } - - /** - * @group DDC-407 - */ - public function testHydrateScalarResults() - { - $rsm = new ResultSetMapping(); - $rsm->addScalarResult('foo1', 'foo'); - $rsm->addScalarResult('bar2', 'bar'); - $rsm->addScalarResult('baz3', 'baz'); - - $resultSet = array( - array( - 'foo1' => 'A', - 'bar2' => 'B', - 'baz3' => 'C', - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); - - $result = $hydrator->hydrateAll($stmt, $rsm); - } - - /** - * @group DDC-644 - */ - public function testSkipUnknownColumns() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addScalarResult('foo1', 'foo'); - $rsm->addScalarResult('bar2', 'bar'); - $rsm->addScalarResult('baz3', 'baz'); - - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'romanb', - 'foo1' => 'A', - 'bar2' => 'B', - 'baz3' => 'C', - 'foo' => 'bar', // Unknown! - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); - - $result = $hydrator->hydrateAll($stmt, $rsm); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php deleted file mode 100755 index 400b5829f7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ /dev/null @@ -1,61 +0,0 @@ -addEntityResult('Doctrine\Tests\Models\Company\CompanyPerson', 'p'); - $rsm->addFieldResult('p', 'p__id', 'id'); - $rsm->addFieldResult('p', 'p__name', 'name'); - $rsm->addMetaResult('p ', 'discr', 'discr'); - $rsm->setDiscriminatorColumn('p', 'discr'); - $resultSet = array( - array( - 'u__id' => '1', - 'u__name' => 'Fabio B. Silva' - ), - ); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator($this->_em); - $hydrator->hydrateAll($stmt, $rsm); - } - - public function testExtraFieldInResultSetShouldBeIgnore() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsAddress', 'a'); - $rsm->addFieldResult('a', 'a__id', 'id'); - $rsm->addFieldResult('a', 'a__city', 'city'); - $resultSet = array( - array( - 'a__id' => '1', - 'a__city' => 'Cracow', - 'doctrine_rownum' => '1' - ), - ); - - $expectedEntity = new \Doctrine\Tests\Models\CMS\CmsAddress(); - $expectedEntity->id = 1; - $expectedEntity->city = 'Cracow'; - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator($this->_em); - $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals($result[0], $expectedEntity); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php deleted file mode 100755 index f6abe2471b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php +++ /dev/null @@ -1,78 +0,0 @@ - 'result1', - 'resultSet' => array( - array( - 'u__name' => 'romanb' - ) - )), - // valid - array('name' => 'result2', - 'resultSet' => array( - array( - 'u__id' => '1' - ) - )), - // invalid - array('name' => 'result3', - 'resultSet' => array( - array( - 'u__id' => '1', - 'u__name' => 'romanb' - ) - )), - // invalid - array('name' => 'result4', - 'resultSet' => array( - array( - 'u__id' => '1' - ), - array( - 'u__id' => '2' - ) - )), - ); - } - - /** - * select u.name from CmsUser u where u.id = 1 - * - * @dataProvider singleScalarResultSetProvider - */ - public function testHydrateSingleScalar($name, $resultSet) - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\SingleScalarHydrator($this->_em); - - if ($name == 'result1') { - $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals('romanb', $result); - } else if ($name == 'result2') { - $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, $result); - } else if ($name == 'result3' || $name == 'result4') { - try { - $result = $hydrator->hydrateAll($stmt, $rsm); - $this->fail(); - } catch (\Doctrine\ORM\NonUniqueResultException $e) {} - } - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php deleted file mode 100755 index 3a009e5eab..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ /dev/null @@ -1,67 +0,0 @@ -_em = $this->_getTestEntityManager(); - $this->_assignedGen = new AssignedGenerator; - } - - public function testThrowsExceptionIfIdNotAssigned() - { - try { - $entity = new AssignedSingleIdEntity; - $this->_assignedGen->generate($this->_em, $entity); - $this->fail('Assigned generator did not throw exception even though ID was missing.'); - } catch (\Doctrine\ORM\ORMException $expected) {} - - try { - $entity = new AssignedCompositeIdEntity; - $this->_assignedGen->generate($this->_em, $entity); - $this->fail('Assigned generator did not throw exception even though ID was missing.'); - } catch (\Doctrine\ORM\ORMException $expected) {} - } - - public function testCorrectIdGeneration() - { - $entity = new AssignedSingleIdEntity; - $entity->myId = 1; - $id = $this->_assignedGen->generate($this->_em, $entity); - $this->assertEquals(array('myId' => 1), $id); - - $entity = new AssignedCompositeIdEntity; - $entity->myId2 = 2; - $entity->myId1 = 4; - $id = $this->_assignedGen->generate($this->_em, $entity); - $this->assertEquals(array('myId1' => 4, 'myId2' => 2), $id); - } -} - -/** @Entity */ -class AssignedSingleIdEntity { - /** @Id @Column(type="integer") */ - public $myId; -} - -/** @Entity */ -class AssignedCompositeIdEntity { - /** @Id @Column(type="integer") */ - public $myId1; - /** @Id @Column(type="integer") */ - public $myId2; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php deleted file mode 100755 index 6e50d5ad00..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php +++ /dev/null @@ -1,40 +0,0 @@ -_em = $this->_getTestEntityManager(); - $this->_seqGen = new SequenceGenerator('seq', 10); - } - - public function testGeneration() - { - for ($i=0; $i < 42; ++$i) { - if ($i % 10 == 0) { - $this->_em->getConnection()->setFetchOneResult((int)($i / 10) * 10); - } - $id = $this->_seqGen->generate($this->_em, null); - $this->assertEquals($i, $id); - $this->assertEquals((int)($i / 10) * 10 + 10, $this->_seqGen->getCurrentMaxValue()); - $this->assertEquals($i + 1, $this->_seqGen->getNextValue()); - } - - - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php deleted file mode 100755 index 7300a3ad40..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ /dev/null @@ -1,1098 +0,0 @@ -_loadDriver(); - - $class = new ClassMetadata($entityClassName); - $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $mappingDriver->loadMetadataForClass($entityClassName, $class); - - return $class; - } - - /** - * @param \Doctrine\ORM\EntityManager $entityClassName - * @return \Doctrine\ORM\Mapping\ClassMetadataFactory - */ - protected function createClassMetadataFactory(\Doctrine\ORM\EntityManager $em = null) - { - $driver = $this->_loadDriver(); - $em = $em ?: $this->_getTestEntityManager(); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $em->getConfiguration()->setMetadataDriverImpl($driver); - $factory->setEntityManager($em); - - return $factory; - } - - public function testLoadMapping() - { - $entityClassName = 'Doctrine\Tests\ORM\Mapping\User'; - return $this->createClassMetadata($entityClassName); - } - - /** - * @depends testLoadMapping - * @param ClassMetadata $class - */ - public function testEntityTableNameAndInheritance($class) - { - $this->assertEquals('cms_users', $class->getTableName()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType); - - return $class; - } - - /** - * @depends testEntityTableNameAndInheritance - * @param ClassMetadata $class - */ - public function testEntityIndexes($class) - { - $this->assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.'); - $this->assertEquals(array( - 'name_idx' => array('columns' => array('name')), - 0 => array('columns' => array('user_email')) - ), $class->table['indexes']); - - return $class; - } - - /** - * @depends testEntityTableNameAndInheritance - * @param ClassMetadata $class - */ - public function testEntityUniqueConstraints($class) - { - $this->assertArrayHasKey('uniqueConstraints', $class->table, - 'ClassMetadata should have uniqueConstraints key in table property when Unique Constraints are set.'); - - $this->assertEquals(array( - "search_idx" => array("columns" => array("name", "user_email")) - ), $class->table['uniqueConstraints']); - - return $class; - } - - /** - * @depends testEntityTableNameAndInheritance - * @param ClassMetadata $class - */ - public function testEntityOptions($class) - { - $this->assertArrayHasKey('options', $class->table, 'ClassMetadata should have options key in table property.'); - - $this->assertEquals(array( - 'foo' => 'bar', 'baz' => array('key' => 'val') - ), $class->table['options']); - - return $class; - } - - /** - * @depends testEntityOptions - * @param ClassMetadata $class - */ - public function testEntitySequence($class) - { - $this->assertInternalType('array', $class->sequenceGeneratorDefinition, 'No Sequence Definition set on this driver.'); - $this->assertEquals( - array( - 'sequenceName' => 'tablename_seq', - 'allocationSize' => 100, - 'initialValue' => 1, - ), - $class->sequenceGeneratorDefinition - ); - } - - public function testEntityCustomGenerator() - { - $class = $this->createClassMetadata('Doctrine\Tests\ORM\Mapping\Animal'); - - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, - $class->generatorType, "Generator Type"); - $this->assertEquals( - array("class" => "stdClass"), - $class->customGeneratorDefinition, - "Custom Generator Definition"); - } - - - /** - * @depends testEntityTableNameAndInheritance - * @param ClassMetadata $class - */ - public function testFieldMappings($class) - { - $this->assertEquals(4, count($class->fieldMappings)); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['name'])); - $this->assertTrue(isset($class->fieldMappings['email'])); - $this->assertTrue(isset($class->fieldMappings['version'])); - - return $class; - } - - /** - * @depends testFieldMappings - * @param ClassMetadata $class - */ - public function testVersionedField($class) - { - $this->assertTrue($class->isVersioned); - $this->assertEquals("version", $class->versionField); - - $this->assertFalse(isset($class->fieldMappings['version']['version'])); - } - - /** - * @depends testEntityTableNameAndInheritance - * @param ClassMetadata $class - */ - public function testFieldMappingsColumnNames($class) - { - $this->assertEquals("id", $class->fieldMappings['id']['columnName']); - $this->assertEquals("name", $class->fieldMappings['name']['columnName']); - $this->assertEquals("user_email", $class->fieldMappings['email']['columnName']); - - return $class; - } - - /** - * @depends testEntityTableNameAndInheritance - * @param ClassMetadata $class - */ - public function testStringFieldMappings($class) - { - $this->assertEquals('string', $class->fieldMappings['name']['type']); - $this->assertEquals(50, $class->fieldMappings['name']['length']); - $this->assertTrue($class->fieldMappings['name']['nullable']); - $this->assertTrue($class->fieldMappings['name']['unique']); - - $expected = array('foo' => 'bar', 'baz' => array('key' => 'val')); - $this->assertEquals($expected, $class->fieldMappings['name']['options']); - - return $class; - } - - /** - * @depends testFieldMappings - * @param ClassMetadata $class - */ - public function testIdentifier($class) - { - $this->assertEquals(array('id'), $class->identifier); - $this->assertEquals('integer', $class->fieldMappings['id']['type']); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, "ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO"); - - return $class; - } - - /** - * @depends testIdentifier - * @param ClassMetadata $class - */ - public function testAssocations($class) - { - $this->assertEquals(3, count($class->associationMappings)); - - return $class; - } - - /** - * @depends testAssocations - * @param ClassMetadata $class - */ - public function testOwningOneToOneAssocation($class) - { - $this->assertTrue(isset($class->associationMappings['address'])); - $this->assertTrue($class->associationMappings['address']['isOwningSide']); - $this->assertEquals('user', $class->associationMappings['address']['inversedBy']); - // Check cascading - $this->assertTrue($class->associationMappings['address']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['address']['isCascadePersist']); - $this->assertFalse($class->associationMappings['address']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['address']['isCascadeDetach']); - $this->assertFalse($class->associationMappings['address']['isCascadeMerge']); - - return $class; - } - - /** - * @depends testOwningOneToOneAssocation - * @param ClassMetadata $class - */ - public function testInverseOneToManyAssociation($class) - { - $this->assertTrue(isset($class->associationMappings['phonenumbers'])); - $this->assertFalse($class->associationMappings['phonenumbers']['isOwningSide']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); - - // Test Order By - $this->assertEquals(array('number' => 'ASC'), $class->associationMappings['phonenumbers']['orderBy']); - - return $class; - } - - /** - * @depends testInverseOneToManyAssociation - * @param ClassMetadata $class - */ - public function testManyToManyAssociationWithCascadeAll($class) - { - $this->assertTrue(isset($class->associationMappings['groups'])); - $this->assertTrue($class->associationMappings['groups']['isOwningSide']); - // Make sure that cascade-all works as expected - $this->assertTrue($class->associationMappings['groups']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['groups']['isCascadePersist']); - $this->assertTrue($class->associationMappings['groups']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['groups']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['groups']['isCascadeMerge']); - - $this->assertFalse(isset($class->associationMappings['groups']['orderBy'])); - - return $class; - } - - /** - * @depends testManyToManyAssociationWithCascadeAll - * @param ClassMetadata $class - */ - public function testLifecycleCallbacks($class) - { - $this->assertEquals(count($class->lifecycleCallbacks), 2); - $this->assertEquals($class->lifecycleCallbacks['prePersist'][0], 'doStuffOnPrePersist'); - $this->assertEquals($class->lifecycleCallbacks['postPersist'][0], 'doStuffOnPostPersist'); - - return $class; - } - - /** - * @depends testManyToManyAssociationWithCascadeAll - * @param ClassMetadata $class - */ - public function testLifecycleCallbacksSupportMultipleMethodNames($class) - { - $this->assertEquals(count($class->lifecycleCallbacks['prePersist']), 2); - $this->assertEquals($class->lifecycleCallbacks['prePersist'][1], 'doOtherStuffOnPrePersistToo'); - - return $class; - } - - /** - * @depends testLifecycleCallbacksSupportMultipleMethodNames - * @param ClassMetadata $class - */ - public function testJoinColumnUniqueAndNullable($class) - { - // Non-Nullability of Join Column - $this->assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['nullable']); - $this->assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['unique']); - - return $class; - } - - /** - * @depends testJoinColumnUniqueAndNullable - * @param ClassMetadata $class - */ - public function testColumnDefinition($class) - { - $this->assertEquals("CHAR(32) NOT NULL", $class->fieldMappings['email']['columnDefinition']); - $this->assertEquals("INT NULL", $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); - - return $class; - } - - /** - * @depends testColumnDefinition - * @param ClassMetadata $class - */ - public function testJoinColumnOnDelete($class) - { - $this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); - - return $class; - } - - /** - * @group DDC-514 - */ - public function testDiscriminatorColumnDefaults() - { - if (strpos(get_class($this), 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); - } - - $class = $this->createClassMetadata('Doctrine\Tests\ORM\Mapping\Animal'); - - $this->assertEquals( - array('name' => 'discr', 'type' => 'string', 'length' => '32', 'fieldName' => 'discr', 'columnDefinition' => null), - $class->discriminatorColumn - ); - } - - /** - * @group DDC-869 - */ - public function testMappedSuperclassWithRepository() - { - $em = $this->_getTestEntityManager(); - $factory = $this->createClassMetadataFactory($em); - - - $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment'); - - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertTrue(isset($class->fieldMappings['creditCardNumber'])); - $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository", - $em->getRepository("Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment")); - $this->assertTrue($em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")->isTrue()); - - - - $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869ChequePayment'); - - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertTrue(isset($class->fieldMappings['serialNumber'])); - $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); - $this->assertInstanceOf("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository", - $em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")); - $this->assertTrue($em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")->isTrue()); - } - - /** - * @group DDC-1476 - */ - public function testDefaultFieldType() - { - $factory = $this->createClassMetadataFactory(); - $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType'); - - - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('name', $class->fieldMappings); - - - $this->assertArrayHasKey('type', $class->fieldMappings['id']); - $this->assertArrayHasKey('type', $class->fieldMappings['name']); - - $this->assertEquals('string', $class->fieldMappings['id']['type']); - $this->assertEquals('string', $class->fieldMappings['name']['type']); - - - - $this->assertArrayHasKey('fieldName', $class->fieldMappings['id']); - $this->assertArrayHasKey('fieldName', $class->fieldMappings['name']); - - $this->assertEquals('id', $class->fieldMappings['id']['fieldName']); - $this->assertEquals('name', $class->fieldMappings['name']['fieldName']); - - - - $this->assertArrayHasKey('columnName', $class->fieldMappings['id']); - $this->assertArrayHasKey('columnName', $class->fieldMappings['name']); - - $this->assertEquals('id', $class->fieldMappings['id']['columnName']); - $this->assertEquals('name', $class->fieldMappings['name']['columnName']); - - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType); - } - - /** - * @group DDC-1170 - */ - public function testIdentifierColumnDefinition() - { - $class = $this->createClassMetadata(__NAMESPACE__ . '\DDC1170Entity'); - - - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); - - $this->assertArrayHasKey('columnDefinition', $class->fieldMappings['id']); - $this->assertArrayHasKey('columnDefinition', $class->fieldMappings['value']); - - $this->assertEquals("INT unsigned NOT NULL", $class->fieldMappings['id']['columnDefinition']); - $this->assertEquals("VARCHAR(255) NOT NULL", $class->fieldMappings['value']['columnDefinition']); - } - - /** - * @group DDC-559 - */ - public function testNamingStrategy() - { - $em = $this->_getTestEntityManager(); - $factory = $this->createClassMetadataFactory($em); - - - $this->assertInstanceOf('Doctrine\ORM\Mapping\DefaultNamingStrategy', $em->getConfiguration()->getNamingStrategy()); - $em->getConfiguration()->setNamingStrategy(new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy(CASE_UPPER)); - $this->assertInstanceOf('Doctrine\ORM\Mapping\UnderscoreNamingStrategy', $em->getConfiguration()->getNamingStrategy()); - - $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType'); - - $this->assertEquals('ID', $class->columnNames['id']); - $this->assertEquals('NAME', $class->columnNames['name']); - $this->assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); - } - - /** - * @group DDC-807 - * @group DDC-553 - */ - public function testDiscriminatorColumnDefinition() - { - $class = $this->createClassMetadata(__NAMESPACE__ . '\DDC807Entity'); - - $this->assertArrayHasKey('columnDefinition', $class->discriminatorColumn); - $this->assertArrayHasKey('name', $class->discriminatorColumn); - - $this->assertEquals("ENUM('ONE','TWO')", $class->discriminatorColumn['columnDefinition']); - $this->assertEquals("dtype", $class->discriminatorColumn['name']); - } - - /** - * @group DDC-889 - */ - public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses() - { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'Class "Doctrine\Tests\Models\DDC889\DDC889Class" sub class of "Doctrine\Tests\Models\DDC889\DDC889SuperClass" is not a valid entity or mapped super class.'); - - $this->createClassMetadata('Doctrine\Tests\Models\DDC889\DDC889Class'); - } - - /** - * @group DDC-889 - */ - public function testIdentifierRequiredShouldMentionParentClasses() - { - $factory = $this->createClassMetadataFactory(); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'No identifier/primary key specified for Entity "Doctrine\Tests\Models\DDC889\DDC889Entity" sub class of "Doctrine\Tests\Models\DDC889\DDC889SuperClass". Every Entity must have an identifier/primary key.'); - $factory->getMetadataFor('Doctrine\Tests\Models\DDC889\DDC889Entity'); - } - - public function testNamedQuery() - { - $driver = $this->_loadDriver(); - $class = $this->createClassMetadata(__NAMESPACE__.'\User'); - - $this->assertCount(1, $class->getNamedQueries(), sprintf("Named queries not processed correctly by driver %s", get_class($driver))); - } - - /** - * @group DDC-1663 - */ - public function testNamedNativeQuery() - { - - $class = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - - //named native query - $this->assertCount(3, $class->namedNativeQueries); - $this->assertArrayHasKey('find-all', $class->namedNativeQueries); - $this->assertArrayHasKey('find-by-id', $class->namedNativeQueries); - - - $findAllQuery = $class->getNamedNativeQuery('find-all'); - $this->assertEquals('find-all', $findAllQuery['name']); - $this->assertEquals('mapping-find-all', $findAllQuery['resultSetMapping']); - $this->assertEquals('SELECT id, country, city FROM cms_addresses', $findAllQuery['query']); - - $findByIdQuery = $class->getNamedNativeQuery('find-by-id'); - $this->assertEquals('find-by-id', $findByIdQuery['name']); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsAddress',$findByIdQuery['resultClass']); - $this->assertEquals('SELECT * FROM cms_addresses WHERE id = ?', $findByIdQuery['query']); - - $countQuery = $class->getNamedNativeQuery('count'); - $this->assertEquals('count', $countQuery['name']); - $this->assertEquals('mapping-count', $countQuery['resultSetMapping']); - $this->assertEquals('SELECT COUNT(*) AS count FROM cms_addresses', $countQuery['query']); - - // result set mapping - $this->assertCount(3, $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-count', $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-find-all', $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-without-fields', $class->sqlResultSetMappings); - - $findAllMapping = $class->getSqlResultSetMapping('mapping-find-all'); - $this->assertEquals('mapping-find-all', $findAllMapping['name']); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsAddress', $findAllMapping['entities'][0]['entityClass']); - $this->assertEquals(array('name'=>'id','column'=>'id'), $findAllMapping['entities'][0]['fields'][0]); - $this->assertEquals(array('name'=>'city','column'=>'city'), $findAllMapping['entities'][0]['fields'][1]); - $this->assertEquals(array('name'=>'country','column'=>'country'), $findAllMapping['entities'][0]['fields'][2]); - - $withoutFieldsMapping = $class->getSqlResultSetMapping('mapping-without-fields'); - $this->assertEquals('mapping-without-fields', $withoutFieldsMapping['name']); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsAddress', $withoutFieldsMapping['entities'][0]['entityClass']); - $this->assertEquals(array(), $withoutFieldsMapping['entities'][0]['fields']); - - $countMapping = $class->getSqlResultSetMapping('mapping-count'); - $this->assertEquals('mapping-count', $countMapping['name']); - $this->assertEquals(array('name'=>'count'), $countMapping['columns'][0]); - - } - - /** - * @group DDC-1663 - */ - public function testSqlResultSetMapping() - { - - $userMetadata = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $personMetadata = $this->createClassMetadata('Doctrine\Tests\Models\Company\CompanyPerson'); - - // user asserts - $this->assertCount(4, $userMetadata->getSqlResultSetMappings()); - - $mapping = $userMetadata->getSqlResultSetMapping('mappingJoinedAddress'); - $this->assertEquals(array(),$mapping['columns']); - $this->assertEquals('mappingJoinedAddress', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(array('name'=>'id','column'=>'id'), $mapping['entities'][0]['fields'][0]); - $this->assertEquals(array('name'=>'name','column'=>'name'), $mapping['entities'][0]['fields'][1]); - $this->assertEquals(array('name'=>'status','column'=>'status'), $mapping['entities'][0]['fields'][2]); - $this->assertEquals(array('name'=>'address.zip','column'=>'zip'), $mapping['entities'][0]['fields'][3]); - $this->assertEquals(array('name'=>'address.city','column'=>'city'), $mapping['entities'][0]['fields'][4]); - $this->assertEquals(array('name'=>'address.country','column'=>'country'), $mapping['entities'][0]['fields'][5]); - $this->assertEquals(array('name'=>'address.id','column'=>'a_id'), $mapping['entities'][0]['fields'][6]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - - - $mapping = $userMetadata->getSqlResultSetMapping('mappingJoinedPhonenumber'); - $this->assertEquals(array(),$mapping['columns']); - $this->assertEquals('mappingJoinedPhonenumber', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(array('name'=>'id','column'=>'id'), $mapping['entities'][0]['fields'][0]); - $this->assertEquals(array('name'=>'name','column'=>'name'), $mapping['entities'][0]['fields'][1]); - $this->assertEquals(array('name'=>'status','column'=>'status'), $mapping['entities'][0]['fields'][2]); - $this->assertEquals(array('name'=>'phonenumbers.phonenumber','column'=>'number'), $mapping['entities'][0]['fields'][3]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - - $mapping = $userMetadata->getSqlResultSetMapping('mappingUserPhonenumberCount'); - $this->assertEquals(array('name'=>'numphones'),$mapping['columns'][0]); - $this->assertEquals('mappingUserPhonenumberCount', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(array('name'=>'id','column'=>'id'), $mapping['entities'][0]['fields'][0]); - $this->assertEquals(array('name'=>'name','column'=>'name'), $mapping['entities'][0]['fields'][1]); - $this->assertEquals(array('name'=>'status','column'=>'status'), $mapping['entities'][0]['fields'][2]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - - $mapping = $userMetadata->getSqlResultSetMapping('mappingMultipleJoinsEntityResults'); - $this->assertEquals(array('name'=>'numphones'),$mapping['columns'][0]); - $this->assertEquals('mappingMultipleJoinsEntityResults', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(array('name'=>'id','column'=>'u_id'), $mapping['entities'][0]['fields'][0]); - $this->assertEquals(array('name'=>'name','column'=>'u_name'), $mapping['entities'][0]['fields'][1]); - $this->assertEquals(array('name'=>'status','column'=>'u_status'), $mapping['entities'][0]['fields'][2]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - $this->assertNull($mapping['entities'][1]['discriminatorColumn']); - $this->assertEquals(array('name'=>'id','column'=>'a_id'), $mapping['entities'][1]['fields'][0]); - $this->assertEquals(array('name'=>'zip','column'=>'a_zip'), $mapping['entities'][1]['fields'][1]); - $this->assertEquals(array('name'=>'country','column'=>'a_country'), $mapping['entities'][1]['fields'][2]); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsAddress', $mapping['entities'][1]['entityClass']); - - //person asserts - $this->assertCount(1, $personMetadata->getSqlResultSetMappings()); - - $mapping = $personMetadata->getSqlResultSetMapping('mappingFetchAll'); - $this->assertEquals(array(),$mapping['columns']); - $this->assertEquals('mappingFetchAll', $mapping['name']); - $this->assertEquals('discriminator', $mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(array('name'=>'id','column'=>'id'), $mapping['entities'][0]['fields'][0]); - $this->assertEquals(array('name'=>'name','column'=>'name'), $mapping['entities'][0]['fields'][1]); - $this->assertEquals($personMetadata->name, $mapping['entities'][0]['entityClass']); - } - - /* - * @group DDC-964 - */ - public function testAssociationOverridesMapping() - { - - $factory = $this->createClassMetadataFactory(); - $adminMetadata = $factory->getMetadataFor('Doctrine\Tests\Models\DDC964\DDC964Admin'); - $guestMetadata = $factory->getMetadataFor('Doctrine\Tests\Models\DDC964\DDC964Guest'); - - - // assert groups association mappings - $this->assertArrayHasKey('groups', $guestMetadata->associationMappings); - $this->assertArrayHasKey('groups', $adminMetadata->associationMappings); - - $guestGroups = $guestMetadata->associationMappings['groups']; - $adminGroups = $adminMetadata->associationMappings['groups']; - - // assert not override attributes - $this->assertEquals($guestGroups['fieldName'], $adminGroups['fieldName']); - $this->assertEquals($guestGroups['type'], $adminGroups['type']); - $this->assertEquals($guestGroups['mappedBy'], $adminGroups['mappedBy']); - $this->assertEquals($guestGroups['inversedBy'], $adminGroups['inversedBy']); - $this->assertEquals($guestGroups['isOwningSide'], $adminGroups['isOwningSide']); - $this->assertEquals($guestGroups['fetch'], $adminGroups['fetch']); - $this->assertEquals($guestGroups['isCascadeRemove'], $adminGroups['isCascadeRemove']); - $this->assertEquals($guestGroups['isCascadePersist'], $adminGroups['isCascadePersist']); - $this->assertEquals($guestGroups['isCascadeRefresh'], $adminGroups['isCascadeRefresh']); - $this->assertEquals($guestGroups['isCascadeMerge'], $adminGroups['isCascadeMerge']); - $this->assertEquals($guestGroups['isCascadeDetach'], $adminGroups['isCascadeDetach']); - - // assert not override attributes - $this->assertEquals('ddc964_users_groups', $guestGroups['joinTable']['name']); - $this->assertEquals('user_id', $guestGroups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('group_id', $guestGroups['joinTable']['inverseJoinColumns'][0]['name']); - - $this->assertEquals(array('user_id'=>'id'), $guestGroups['relationToSourceKeyColumns']); - $this->assertEquals(array('group_id'=>'id'), $guestGroups['relationToTargetKeyColumns']); - $this->assertEquals(array('user_id','group_id'), $guestGroups['joinTableColumns']); - - - $this->assertEquals('ddc964_users_admingroups', $adminGroups['joinTable']['name']); - $this->assertEquals('adminuser_id', $adminGroups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('admingroup_id', $adminGroups['joinTable']['inverseJoinColumns'][0]['name']); - - $this->assertEquals(array('adminuser_id'=>'id'), $adminGroups['relationToSourceKeyColumns']); - $this->assertEquals(array('admingroup_id'=>'id'), $adminGroups['relationToTargetKeyColumns']); - $this->assertEquals(array('adminuser_id','admingroup_id'), $adminGroups['joinTableColumns']); - - - // assert address association mappings - $this->assertArrayHasKey('address', $guestMetadata->associationMappings); - $this->assertArrayHasKey('address', $adminMetadata->associationMappings); - - $guestAddress = $guestMetadata->associationMappings['address']; - $adminAddress = $adminMetadata->associationMappings['address']; - - // assert not override attributes - $this->assertEquals($guestAddress['fieldName'], $adminAddress['fieldName']); - $this->assertEquals($guestAddress['type'], $adminAddress['type']); - $this->assertEquals($guestAddress['mappedBy'], $adminAddress['mappedBy']); - $this->assertEquals($guestAddress['inversedBy'], $adminAddress['inversedBy']); - $this->assertEquals($guestAddress['isOwningSide'], $adminAddress['isOwningSide']); - $this->assertEquals($guestAddress['fetch'], $adminAddress['fetch']); - $this->assertEquals($guestAddress['isCascadeRemove'], $adminAddress['isCascadeRemove']); - $this->assertEquals($guestAddress['isCascadePersist'], $adminAddress['isCascadePersist']); - $this->assertEquals($guestAddress['isCascadeRefresh'], $adminAddress['isCascadeRefresh']); - $this->assertEquals($guestAddress['isCascadeMerge'], $adminAddress['isCascadeMerge']); - $this->assertEquals($guestAddress['isCascadeDetach'], $adminAddress['isCascadeDetach']); - - // assert override - $this->assertEquals('address_id', $guestAddress['joinColumns'][0]['name']); - $this->assertEquals(array('address_id'=>'id'), $guestAddress['sourceToTargetKeyColumns']); - $this->assertEquals(array('address_id'=>'address_id'), $guestAddress['joinColumnFieldNames']); - $this->assertEquals(array('id'=>'address_id'), $guestAddress['targetToSourceKeyColumns']); - - - $this->assertEquals('adminaddress_id', $adminAddress['joinColumns'][0]['name']); - $this->assertEquals(array('adminaddress_id'=>'id'), $adminAddress['sourceToTargetKeyColumns']); - $this->assertEquals(array('adminaddress_id'=>'adminaddress_id'), $adminAddress['joinColumnFieldNames']); - $this->assertEquals(array('id'=>'adminaddress_id'), $adminAddress['targetToSourceKeyColumns']); - } - - /** - * @group DDC-964 - */ - public function testAttributeOverridesMapping() - { - - $factory = $this->createClassMetadataFactory(); - $guestMetadata = $factory->getMetadataFor('Doctrine\Tests\Models\DDC964\DDC964Guest'); - $adminMetadata = $factory->getMetadataFor('Doctrine\Tests\Models\DDC964\DDC964Admin'); - - $this->assertTrue($adminMetadata->fieldMappings['id']['id']); - $this->assertEquals('id', $adminMetadata->fieldMappings['id']['fieldName']); - $this->assertEquals('user_id', $adminMetadata->fieldMappings['id']['columnName']); - $this->assertEquals(array('user_id'=>'id','user_name'=>'name'), $adminMetadata->fieldNames); - $this->assertEquals(array('id'=>'user_id','name'=>'user_name'), $adminMetadata->columnNames); - $this->assertEquals(150, $adminMetadata->fieldMappings['id']['length']); - - - $this->assertEquals('name', $adminMetadata->fieldMappings['name']['fieldName']); - $this->assertEquals('user_name', $adminMetadata->fieldMappings['name']['columnName']); - $this->assertEquals(250, $adminMetadata->fieldMappings['name']['length']); - $this->assertTrue($adminMetadata->fieldMappings['name']['nullable']); - $this->assertFalse($adminMetadata->fieldMappings['name']['unique']); - - - $this->assertTrue($guestMetadata->fieldMappings['id']['id']); - $this->assertEquals('guest_id', $guestMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('id', $guestMetadata->fieldMappings['id']['fieldName']); - $this->assertEquals(array('guest_id'=>'id','guest_name'=>'name'), $guestMetadata->fieldNames); - $this->assertEquals(array('id'=>'guest_id','name'=>'guest_name'), $guestMetadata->columnNames); - $this->assertEquals(140, $guestMetadata->fieldMappings['id']['length']); - - $this->assertEquals('name', $guestMetadata->fieldMappings['name']['fieldName']); - $this->assertEquals('guest_name', $guestMetadata->fieldMappings['name']['columnName']); - $this->assertEquals(240, $guestMetadata->fieldMappings['name']['length']); - $this->assertFalse($guestMetadata->fieldMappings['name']['nullable']); - $this->assertTrue($guestMetadata->fieldMappings['name']['unique']); - } - -} - -/** - * @Entity - * @HasLifecycleCallbacks - * @Table( - * name="cms_users", - * uniqueConstraints={@UniqueConstraint(name="search_idx", columns={"name", "user_email"})}, - * indexes={@Index(name="name_idx", columns={"name"}), @Index(name="0", columns={"user_email"})}, - * options={"foo": "bar", "baz": {"key": "val"}} - * ) - * @NamedQueries({@NamedQuery(name="all", query="SELECT u FROM __CLASS__ u")}) - */ -class User -{ - /** - * @Id - * @Column(type="integer") - * @generatedValue(strategy="AUTO") - * @SequenceGenerator(sequenceName="tablename_seq", initialValue=1, allocationSize=100) - **/ - public $id; - - /** - * @Column(length=50, nullable=true, unique=true, options={"foo": "bar", "baz": {"key": "val"}}) - */ - public $name; - - /** - * @Column(name="user_email", columnDefinition="CHAR(32) NOT NULL") - */ - public $email; - - /** - * @OneToOne(targetEntity="Address", cascade={"remove"}, inversedBy="user") - * @JoinColumn(onDelete="CASCADE") - */ - public $address; - - /** - * @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"}, orphanRemoval=true) - * @OrderBy({"number"="ASC"}) - */ - public $phonenumbers; - - /** - * @ManyToMany(targetEntity="Group", cascade={"all"}) - * @JoinTable(name="cms_user_groups", - * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id", nullable=false, unique=false)}, - * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id", columnDefinition="INT NULL")} - * ) - */ - public $groups; - - /** - * @Column(type="integer") - * @Version - */ - public $version; - - - /** - * @PrePersist - */ - public function doStuffOnPrePersist() - { - } - - /** - * @PrePersist - */ - public function doOtherStuffOnPrePersistToo() { - } - - /** - * @PostPersist - */ - public function doStuffOnPostPersist() - { - - } - - public static function loadMetadata(ClassMetadataInfo $metadata) - { - $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); - $metadata->setPrimaryTable(array( - 'name' => 'cms_users', - 'options' => array('foo' => 'bar', 'baz' => array('key' => 'val')), - )); - $metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); - $metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist'); - $metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist'); - $metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist'); - $metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - )); - $metadata->mapField(array( - 'fieldName' => 'name', - 'type' => 'string', - 'length' => 50, - 'unique' => true, - 'nullable' => true, - 'columnName' => 'name', - 'options' => array('foo' => 'bar', 'baz' => array('key' => 'val')), - )); - $metadata->mapField(array( - 'fieldName' => 'email', - 'type' => 'string', - 'columnName' => 'user_email', - 'columnDefinition' => 'CHAR(32) NOT NULL', - )); - $mapping = array('fieldName' => 'version', 'type' => 'integer'); - $metadata->setVersionMapping($mapping); - $metadata->mapField($mapping); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - $metadata->mapOneToOne(array( - 'fieldName' => 'address', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Address', - 'cascade' => - array( - 0 => 'remove', - ), - 'mappedBy' => NULL, - 'inversedBy' => 'user', - 'joinColumns' => - array( - 0 => - array( - 'name' => 'address_id', - 'referencedColumnName' => 'id', - 'onDelete' => 'CASCADE', - ), - ), - 'orphanRemoval' => false, - )); - $metadata->mapOneToMany(array( - 'fieldName' => 'phonenumbers', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Phonenumber', - 'cascade' => - array( - 1 => 'persist', - ), - 'mappedBy' => 'user', - 'orphanRemoval' => true, - 'orderBy' => - array( - 'number' => 'ASC', - ), - )); - $metadata->mapManyToMany(array( - 'fieldName' => 'groups', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Group', - 'cascade' => - array( - 0 => 'remove', - 1 => 'persist', - 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', - ), - 'mappedBy' => NULL, - 'joinTable' => - array( - 'name' => 'cms_users_groups', - 'joinColumns' => - array( - 0 => - array( - 'name' => 'user_id', - 'referencedColumnName' => 'id', - 'unique' => false, - 'nullable' => false, - ), - ), - 'inverseJoinColumns' => - array( - 0 => - array( - 'name' => 'group_id', - 'referencedColumnName' => 'id', - 'columnDefinition' => 'INT NULL', - ), - ), - ), - 'orderBy' => NULL, - )); - $metadata->table['uniqueConstraints'] = array( - 'search_idx' => array('columns' => array('name', 'user_email')), - ); - $metadata->table['indexes'] = array( - 'name_idx' => array('columns' => array('name')), 0 => array('columns' => array('user_email')) - ); - $metadata->setSequenceGeneratorDefinition(array( - 'sequenceName' => 'tablename_seq', - 'allocationSize' => 100, - 'initialValue' => 1, - )); - $metadata->addNamedQuery(array( - 'name' => 'all', - 'query' => 'SELECT u FROM __CLASS__ u' - )); - } -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"cat" = "Cat", "dog" = "Dog"}) - * @DiscriminatorColumn(name="discr", length=32, type="string") - */ -abstract class Animal -{ - /** - * @Id @Column(type="string") @GeneratedValue(strategy="CUSTOM") - * @CustomIdGenerator(class="stdClass") - */ - public $id; - - public static function loadMetadata(ClassMetadataInfo $metadata) - { - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_CUSTOM); - $metadata->setCustomGeneratorDefinition(array("class" => "stdClass")); - } -} - -/** @Entity */ -class Cat extends Animal -{ - public static function loadMetadata(ClassMetadataInfo $metadata) - { - - } -} - -/** @Entity */ -class Dog extends Animal -{ - public static function loadMetadata(ClassMetadataInfo $metadata) - { - - } -} - - -/** - * @Entity - */ -class DDC1170Entity -{ - - /** - * @param string $value - */ - function __construct($value = null) - { - $this->value = $value; - } - - /** - * @Id - * @GeneratedValue(strategy="NONE") - * @Column(type="integer", columnDefinition = "INT unsigned NOT NULL") - **/ - private $id; - - /** - * @Column(columnDefinition = "VARCHAR(255) NOT NULL") - */ - private $value; - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * @return string - */ - public function getValue() - { - return $this->value; - } - - public static function loadMetadata(ClassMetadataInfo $metadata) - { - $metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'columnDefinition' => 'INT unsigned NOT NULL', - )); - - $metadata->mapField(array( - 'fieldName' => 'value', - 'columnDefinition' => 'VARCHAR(255) NOT NULL' - )); - - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); - } - -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"ONE" = "DDC807SubClasse1", "TWO" = "DDC807SubClasse2"}) - * @DiscriminatorColumn(name = "dtype", columnDefinition="ENUM('ONE','TWO')") - */ -class DDC807Entity -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - **/ - public $id; - - public static function loadMetadata(ClassMetadataInfo $metadata) - { - $metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', - )); - - $metadata->setDiscriminatorColumn(array( - 'name' => "dtype", - 'type' => "string", - 'columnDefinition' => "ENUM('ONE','TWO')" - )); - - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); - } -} - - -class DDC807SubClasse1 {} -class DDC807SubClasse2 {} - -class Address {} -class Phonenumber {} -class Group {} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php deleted file mode 100755 index 4d7715ebb8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ /dev/null @@ -1,340 +0,0 @@ -initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache()); - $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $annotationDriver->loadMetadataForClass('stdClass', $cm); - } - - /** - * @group DDC-268 - */ - public function testColumnWithMissingTypeDefaultsToString() - { - $cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ColumnWithoutType'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $annotationDriver = $this->_loadDriver(); - - $annotationDriver->loadMetadataForClass('Doctrine\Tests\ORM\Mapping\InvalidColumn', $cm); - $this->assertEquals('string', $cm->fieldMappings['id']['type']); - } - - /** - * @group DDC-318 - */ - public function testGetAllClassNamesIsIdempotent() - { - $annotationDriver = $this->_loadDriverForCMSModels(); - $original = $annotationDriver->getAllClassNames(); - - $annotationDriver = $this->_loadDriverForCMSModels(); - $afterTestReset = $annotationDriver->getAllClassNames(); - - $this->assertEquals($original, $afterTestReset); - } - - /** - * @group DDC-318 - */ - public function testGetAllClassNamesIsIdempotentEvenWithDifferentDriverInstances() - { - $annotationDriver = $this->_loadDriverForCMSModels(); - $original = $annotationDriver->getAllClassNames(); - - $annotationDriver = $this->_loadDriverForCMSModels(); - $afterTestReset = $annotationDriver->getAllClassNames(); - - $this->assertEquals($original, $afterTestReset); - } - - /** - * @group DDC-318 - */ - public function testGetAllClassNamesReturnsAlreadyLoadedClassesIfAppropriate() - { - $rightClassName = 'Doctrine\Tests\Models\CMS\CmsUser'; - $this->_ensureIsLoaded($rightClassName); - - $annotationDriver = $this->_loadDriverForCMSModels(); - $classes = $annotationDriver->getAllClassNames(); - - $this->assertContains($rightClassName, $classes); - } - - /** - * @group DDC-318 - */ - public function testGetClassNamesReturnsOnlyTheAppropriateClasses() - { - $extraneousClassName = 'Doctrine\Tests\Models\ECommerce\ECommerceCart'; - $this->_ensureIsLoaded($extraneousClassName); - - $annotationDriver = $this->_loadDriverForCMSModels(); - $classes = $annotationDriver->getAllClassNames(); - - $this->assertNotContains($extraneousClassName, $classes); - } - - protected function _loadDriverForCMSModels() - { - $annotationDriver = $this->_loadDriver(); - $annotationDriver->addPaths(array(__DIR__ . '/../../Models/CMS/')); - return $annotationDriver; - } - - protected function _loadDriver() - { - return $this->createAnnotationDriver(); - } - - protected function _ensureIsLoaded($entityClassName) - { - new $entityClassName; - } - - /** - * @group DDC-671 - * - * Entities for this test are in AbstractMappingDriverTest - */ - public function testJoinTablesWithMappedSuperclassForAnnotationDriver() - { - $annotationDriver = $this->_loadDriver(); - $annotationDriver->addPaths(array(__DIR__ . '/../../Models/DirectoryTree/')); - - $em = $this->_getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $factory->setEntityManager($em); - - $classPage = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\File'); - $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\File', $classPage->associationMappings['parentDirectory']['sourceEntity']); - - $classDirectory = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\Directory'); - $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']); - } - - /** - * @group DDC-945 - */ - public function testInvalidMappedSuperClassWithManyToManyAssociation() - { - $annotationDriver = $this->_loadDriver(); - - $em = $this->_getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $factory->setEntityManager($em); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "It is illegal to put an inverse side one-to-many or many-to-many association on ". - "mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'"); - $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\UsingInvalidMappedSuperClass'); - } - - /** - * @group DDC-1050 - */ - public function testInvalidMappedSuperClassWithInheritanceInformation() - { - $annotationDriver = $this->_loadDriver(); - - $em = $this->_getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $factory->setEntityManager($em); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "Its not supported to define inheritance information on a mapped ". - "superclass 'Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'."); - $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'); - } - - /** - * @group DDC-1034 - */ - public function testInheritanceSkipsParentLifecycleCallbacks() - { - $annotationDriver = $this->_loadDriver(); - - $cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\AnnotationChild'); - $em = $this->_getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $factory->setEntityManager($em); - - $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\AnnotationChild'); - $this->assertEquals(array("postLoad" => array("postLoad"), "preUpdate" => array("preUpdate")), $cm->lifecycleCallbacks); - - $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\AnnotationParent'); - $this->assertEquals(array("postLoad" => array("postLoad"), "preUpdate" => array("preUpdate")), $cm->lifecycleCallbacks); - } - - /** - * @group DDC-1156 - */ - public function testMappedSuperclassInMiddleOfInheritanceHierachy() - { - $annotationDriver = $this->_loadDriver(); - - $em = $this->_getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $factory->setEntityManager($em); - - $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\ChildEntity'); - } - - public function testInvalidFetchOptionThrowsException() - { - $annotationDriver = $this->_loadDriver(); - - $em = $this->_getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $factory->setEntityManager($em); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "Entity 'Doctrine\Tests\ORM\Mapping\InvalidFetchOption' has a mapping with invalid fetch mode 'eager"); - $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\InvalidFetchOption'); - } -} - -/** - * @Entity - */ -class ColumnWithoutType -{ - /** @Id @Column */ - public $id; -} - -/** - * @MappedSuperclass - */ -class InvalidMappedSuperClass -{ - /** - * @ManyToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", mappedBy="invalid") - */ - private $users; -} - -/** - * @Entity - */ -class UsingInvalidMappedSuperClass extends InvalidMappedSuperClass -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - private $id; -} - -/** - * @MappedSuperclass - * @InheritanceType("JOINED") - * @DiscriminatorMap({"test" = "ColumnWithoutType"}) - */ -class MappedSuperClassInheritence -{ - -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({"parent" = "AnnotationParent", "child" = "AnnotationChild"}) - * @HasLifecycleCallbacks - */ -class AnnotationParent -{ - /** - * @Id @Column(type="integer") @GeneratedValue - */ - private $id; - - /** - * @PostLoad - */ - public function postLoad() - { - - } - - /** - * @PreUpdate - */ - public function preUpdate() - { - - } -} - -/** - * @Entity - * @HasLifecycleCallbacks - */ -class AnnotationChild extends AnnotationParent -{ - -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"s"="SuperEntity", "c"="ChildEntity"}) - */ -class SuperEntity -{ - /** @Id @Column(type="string") */ - private $id; -} - -/** - * @MappedSuperclass - */ -class MiddleMappedSuperclass extends SuperEntity -{ - /** @Column(type="string") */ - private $name; -} - -/** - * @Entity - */ -class ChildEntity extends MiddleMappedSuperclass -{ - /** - * @Column(type="string") - */ - private $text; -} - -/** - * @Entity - */ -class InvalidFetchOption -{ - /** - * @OneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", fetch="eager") - */ - private $collection; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php deleted file mode 100755 index ff7f040487..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ /dev/null @@ -1,319 +0,0 @@ -_factory = new ClassMetadataFactory(); - $this->_factory->setEntityManager($this->_getTestEntityManager()); - } - - /** - * @expectedException Doctrine\ORM\Mapping\MappingException - */ - public function testGetMetadataForTransientClassThrowsException() - { - $this->_factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\TransientBaseClass'); - } - - public function testGetMetadataForSubclassWithTransientBaseClass() - { - $class = $this->_factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\EntitySubClass'); - - $this->assertTrue(empty($class->subClasses)); - $this->assertTrue(empty($class->parentClasses)); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['name'])); - } - - public function testGetMetadataForSubclassWithMappedSuperclass() - { - $class = $this->_factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\EntitySubClass2'); - - $this->assertTrue(empty($class->subClasses)); - $this->assertTrue(empty($class->parentClasses)); - - $this->assertTrue(isset($class->fieldMappings['mapped1'])); - $this->assertTrue(isset($class->fieldMappings['mapped2'])); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['name'])); - - $this->assertFalse(isset($class->fieldMappings['mapped1']['inherited'])); - $this->assertFalse(isset($class->fieldMappings['mapped2']['inherited'])); - $this->assertFalse(isset($class->fieldMappings['transient'])); - - $this->assertTrue(isset($class->associationMappings['mappedRelated1'])); - } - - /** - * @group DDC-869 - */ - public function testGetMetadataForSubclassWithMappedSuperclassWhithRepository() - { - $class = $this->_factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment'); - - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertTrue(isset($class->fieldMappings['creditCardNumber'])); - $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); - - - $class = $this->_factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869ChequePayment'); - - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertTrue(isset($class->fieldMappings['serialNumber'])); - $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); - - - // override repositoryClass - $class = $this->_factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\SubclassWithRepository'); - - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertEquals($class->customRepositoryClassName, "Doctrine\ORM\EntityRepository"); - } - - /** - * @group DDC-388 - */ - public function testSerializationWithPrivateFieldsFromMappedSuperclass() - { - - $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\EntitySubClass2'); - - $class2 = unserialize(serialize($class)); - $class2->wakeupReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $this->assertTrue(isset($class2->reflFields['mapped1'])); - $this->assertTrue(isset($class2->reflFields['mapped2'])); - $this->assertTrue(isset($class2->reflFields['mappedRelated1'])); - } - - /** - * @group DDC-1203 - */ - public function testUnmappedSuperclassInHierachy() - { - $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\HierachyD'); - - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['a'])); - $this->assertTrue(isset($class->fieldMappings['d'])); - } - - /** - * @group DDC-1204 - */ - public function testUnmappedEntityInHierachy() - { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "Entity 'Doctrine\Tests\ORM\Mapping\HierachyBEntity' has to be part of the discriminator map of 'Doctrine\Tests\ORM\Mapping\HierachyBase' to be properly mapped in the inheritance hierachy. Alternatively you can make 'Doctrine\Tests\ORM\Mapping\HierachyBEntity' an abstract class to avoid this exception from occuring."); - - $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\HierachyE'); - } - - /** - * @group DDC-1204 - * @group DDC-1203 - */ - public function testMappedSuperclassWithId() - { - $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\SuperclassEntity'); - - $this->assertTrue(isset($class->fieldMappings['id'])); - } - - /** - * @group DDC-1156 - * @group DDC-1218 - */ - public function testGeneratedValueFromMappedSuperclass() - { - $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\SuperclassEntity'); - /* @var $class ClassMetadataInfo */ - - $this->assertInstanceOf('Doctrine\ORM\Id\SequenceGenerator', $class->idGenerator); - $this->assertEquals(array('allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'), $class->sequenceGeneratorDefinition); - } - - /** - * @group DDC-1156 - * @group DDC-1218 - */ - public function testSequenceDefinitionInHierachyWithSandwichMappedSuperclass() - { - $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\HierachyD'); - /* @var $class ClassMetadataInfo */ - - $this->assertInstanceOf('Doctrine\ORM\Id\SequenceGenerator', $class->idGenerator); - $this->assertEquals(array('allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'), $class->sequenceGeneratorDefinition); - } - - /** - * @group DDC-1156 - * @group DDC-1218 - */ - public function testMultipleMappedSuperclasses() - { - $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\MediumSuperclassEntity'); - /* @var $class ClassMetadataInfo */ - - $this->assertInstanceOf('Doctrine\ORM\Id\SequenceGenerator', $class->idGenerator); - $this->assertEquals(array('allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'), $class->sequenceGeneratorDefinition); - } -} - -class TransientBaseClass { - private $transient1; - private $transient2; -} - -/** @Entity */ -class EntitySubClass extends TransientBaseClass -{ - /** @Id @Column(type="integer") */ - private $id; - /** @Column(type="string") */ - private $name; -} - -/** @MappedSuperclass */ -class MappedSuperclassBase { - /** @Column(type="integer") */ - private $mapped1; - /** @Column(type="string") */ - private $mapped2; - /** - * @OneToOne(targetEntity="MappedSuperclassRelated1") - * @JoinColumn(name="related1_id", referencedColumnName="id") - */ - private $mappedRelated1; - private $transient; -} -class MappedSuperclassRelated1 {} - -/** @Entity */ -class EntitySubClass2 extends MappedSuperclassBase { - /** @Id @Column(type="integer") */ - private $id; - /** @Column(type="string") */ - private $name; -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="string", length=20) - * @DiscriminatorMap({ - * "c" = "HierachyC", - * "d" = "HierachyD", - * "e" = "HierachyE" - * }) - */ -abstract class HierachyBase -{ - /** - * @Column(type="integer") @Id @GeneratedValue(strategy="SEQUENCE") - * @SequenceGenerator(sequenceName="foo", initialValue=10) - * @var int - */ - public $id; -} - -/** - * @MappedSuperclass - */ -abstract class HierachyASuperclass extends HierachyBase -{ - /** @Column(type="string") */ - public $a; -} - -/** - * @Entity - */ -class HierachyBEntity extends HierachyBase -{ - /** @Column(type="string") */ - public $b; -} - -/** - * @Entity - */ -class HierachyC extends HierachyBase -{ - /** @Column(type="string") */ - public $c; -} - -/** - * @Entity - */ -class HierachyD extends HierachyASuperclass -{ - /** @Column(type="string") */ - public $d; -} - -/** - * @Entity - */ -class HierachyE extends HierachyBEntity -{ - /** @Column(type="string") */ - public $e; -} - -/** - * @Entity - */ -class SuperclassEntity extends SuperclassBase -{ - -} - -/** - * @MappedSuperclass - */ -abstract class SuperclassBase -{ - /** - * @Column(type="integer") @Id @GeneratedValue(strategy="SEQUENCE") - * @SequenceGenerator(sequenceName="foo", initialValue=10) - * @var int - */ - public $id; -} - -/** - * @MappedSuperclass - */ -abstract class MediumSuperclassBase extends SuperclassBase -{ - -} - -/** - * @Entity - */ -class MediumSuperclassEntity extends MediumSuperclassBase -{ - -} - -/** - * @Entity(repositoryClass = "Doctrine\ORM\EntityRepository") - */ -class SubclassWithRepository extends \Doctrine\Tests\Models\DDC869\DDC869Payment -{ - -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php deleted file mode 100755 index f14b60b3f8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ /dev/null @@ -1,428 +0,0 @@ -. - */ - - -namespace Doctrine\Tests\ORM\Mapping; - -use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; - -/** - * @group DDC-659 - */ -class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase -{ - /** - * @var ClassMetadata - */ - private $cm; - /** - * @var ClassMetadataBuilder - */ - private $builder; - - public function setUp() - { - $this->cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $this->cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $this->builder = new ClassMetadataBuilder($this->cm); - } - - public function testSetMappedSuperClass() - { - $this->assertIsFluent($this->builder->setMappedSuperClass()); - $this->assertTrue($this->cm->isMappedSuperclass); - } - - public function testSetCustomRepositoryClass() - { - $this->assertIsFluent($this->builder->setCustomRepositoryClass('Doctrine\Tests\Models\CMS\CmsGroup')); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsGroup', $this->cm->customRepositoryClassName); - } - - public function testSetReadOnly() - { - $this->assertIsFluent($this->builder->setReadOnly()); - $this->assertTrue($this->cm->isReadOnly); - } - - public function testSetTable() - { - $this->assertIsFluent($this->builder->setTable('users')); - $this->assertEquals('users', $this->cm->table['name']); - } - - public function testAddIndex() - { - $this->assertIsFluent($this->builder->addIndex(array('username', 'name'), 'users_idx')); - $this->assertEquals(array('users_idx' => array('columns' => array('username', 'name'))), $this->cm->table['indexes']); - } - - public function testAddUniqueConstraint() - { - $this->assertIsFluent($this->builder->addUniqueConstraint(array('username', 'name'), 'users_idx')); - $this->assertEquals(array('users_idx' => array('columns' => array('username', 'name'))), $this->cm->table['uniqueConstraints']); - } - - public function testSetPrimaryTableRelated() - { - $this->builder->addUniqueConstraint(array('username', 'name'), 'users_idx'); - $this->builder->addIndex(array('username', 'name'), 'users_idx'); - $this->builder->setTable('users'); - - $this->assertEquals( - array( - 'name' => 'users', - 'indexes' => array('users_idx' => array('columns' => array('username', 'name'))), - 'uniqueConstraints' => array('users_idx' => array('columns' => array('username', 'name'))), - ), - $this->cm->table - ); - } - - public function testSetInheritanceJoined() - { - $this->assertIsFluent($this->builder->setJoinedTableInheritance()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_JOINED, $this->cm->inheritanceType); - } - - public function testSetInheritanceSingleTable() - { - $this->assertIsFluent($this->builder->setSingleTableInheritance()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE, $this->cm->inheritanceType); - } - - public function testSetDiscriminatorColumn() - { - $this->assertIsFluent($this->builder->setDiscriminatorColumn('discr', 'string', '124')); - $this->assertEquals(array('fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => '124'), $this->cm->discriminatorColumn); - } - - public function testAddDiscriminatorMapClass() - { - $this->assertIsFluent($this->builder->addDiscriminatorMapClass('test', 'Doctrine\Tests\Models\CMS\CmsUser')); - $this->assertIsFluent($this->builder->addDiscriminatorMapClass('test2', 'Doctrine\Tests\Models\CMS\CmsGroup')); - - $this->assertEquals(array('test' => 'Doctrine\Tests\Models\CMS\CmsUser', 'test2' => 'Doctrine\Tests\Models\CMS\CmsGroup'), $this->cm->discriminatorMap); - $this->assertEquals('test', $this->cm->discriminatorValue); - } - - public function testChangeTrackingPolicyExplicit() - { - $this->assertIsFluent($this->builder->setChangeTrackingPolicyDeferredExplicit()); - $this->assertEquals(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT, $this->cm->changeTrackingPolicy); - } - - public function testChangeTrackingPolicyNotify() - { - $this->assertIsFluent($this->builder->setChangeTrackingPolicyNotify()); - $this->assertEquals(ClassMetadata::CHANGETRACKING_NOTIFY, $this->cm->changeTrackingPolicy); - } - - public function testAddField() - { - $this->assertIsFluent($this->builder->addField('name', 'string')); - $this->assertEquals(array('columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'), $this->cm->fieldMappings['name']); - } - - public function testCreateField() - { - $fieldBuilder = ($this->builder->createField('name', 'string')); - $this->assertInstanceOf('Doctrine\ORM\Mapping\Builder\FieldBuilder', $fieldBuilder); - - $this->assertFalse(isset($this->cm->fieldMappings['name'])); - $this->assertIsFluent($fieldBuilder->build()); - $this->assertEquals(array('columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'), $this->cm->fieldMappings['name']); - } - - public function testCreateVersionedField() - { - $this->builder->createField('name', 'integer')->columnName('username')->length(124)->nullable()->columnDefinition('foobar')->unique()->isVersionField()->build(); - $this->assertEquals(array( - 'columnDefinition' => 'foobar', - 'columnName' => 'username', - 'default' => 1, - 'fieldName' => 'name', - 'length' => 124, - 'type' => 'integer', - 'nullable' => true, - 'unique' => true, - ), $this->cm->fieldMappings['name']); - } - - public function testCreatePrimaryField() - { - $this->builder->createField('id', 'integer')->isPrimaryKey()->generatedValue()->build(); - - $this->assertEquals(array('id'), $this->cm->identifier); - $this->assertEquals(array('columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'), $this->cm->fieldMappings['id']); - } - - public function testAddLifecycleEvent() - { - $this->builder->addLifecycleEvent('getStatus', 'postLoad'); - - $this->assertEquals(array('postLoad' => array('getStatus')), $this->cm->lifecycleCallbacks); - } - - public function testCreateManyToOne() - { - $this->assertIsFluent( - $this->builder->createManyToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') - ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') - ->cascadeAll() - ->fetchExtraLazy() - ->build() - ); - - $this->assertEquals(array('groups' => array ( - 'fieldName' => 'groups', - 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', - 'cascade' => array ( - 0 => 'remove', - 1 => 'persist', - 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', - ), - 'fetch' => 4, - 'joinColumns' => array ( - 0 => - array ( - 'name' => 'group_id', - 'referencedColumnName' => 'id', - 'nullable' => true, - 'unique' => false, - 'onDelete' => 'CASCADE', - 'columnDefinition' => NULL, - ), - ), - 'type' => 2, - 'mappedBy' => NULL, - 'inversedBy' => NULL, - 'isOwningSide' => true, - 'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', - 'isCascadeRemove' => true, - 'isCascadePersist' => true, - 'isCascadeRefresh' => true, - 'isCascadeMerge' => true, - 'isCascadeDetach' => true, - 'sourceToTargetKeyColumns' => - array ( - 'group_id' => 'id', - ), - 'joinColumnFieldNames' => - array ( - 'group_id' => 'group_id', - ), - 'targetToSourceKeyColumns' => - array ( - 'id' => 'group_id', - ), - 'orphanRemoval' => false, - ), - ), $this->cm->associationMappings); - } - - public function testCreateOneToOne() - { - $this->assertIsFluent( - $this->builder->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') - ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') - ->cascadeAll() - ->fetchExtraLazy() - ->build() - ); - - $this->assertEquals(array('groups' => array ( - 'fieldName' => 'groups', - 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', - 'cascade' => array ( - 0 => 'remove', - 1 => 'persist', - 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', - ), - 'fetch' => 4, - 'joinColumns' => array ( - 0 => - array ( - 'name' => 'group_id', - 'referencedColumnName' => 'id', - 'nullable' => true, - 'unique' => true, - 'onDelete' => 'CASCADE', - 'columnDefinition' => NULL, - ), - ), - 'type' => 1, - 'mappedBy' => NULL, - 'inversedBy' => NULL, - 'isOwningSide' => true, - 'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', - 'isCascadeRemove' => true, - 'isCascadePersist' => true, - 'isCascadeRefresh' => true, - 'isCascadeMerge' => true, - 'isCascadeDetach' => true, - 'sourceToTargetKeyColumns' => - array ( - 'group_id' => 'id', - ), - 'joinColumnFieldNames' => - array ( - 'group_id' => 'group_id', - ), - 'targetToSourceKeyColumns' => - array ( - 'id' => 'group_id', - ), - 'orphanRemoval' => false, - ), - ), $this->cm->associationMappings); - } - - public function testCreateManyToMany() - { - $this->assertIsFluent( - $this->builder->createManyToMany('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') - ->setJoinTable('groups_users') - ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') - ->addInverseJoinColumn('user_id', 'id') - ->cascadeAll() - ->fetchExtraLazy() - ->build() - ); - - $this->assertEquals(array( - 'groups' => - array( - 'fieldName' => 'groups', - 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', - 'cascade' => - array( - 0 => 'remove', - 1 => 'persist', - 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', - ), - 'fetch' => 4, - 'joinTable' => - array( - 'joinColumns' => - array( - 0 => - array( - 'name' => 'group_id', - 'referencedColumnName' => 'id', - 'nullable' => true, - 'unique' => false, - 'onDelete' => 'CASCADE', - 'columnDefinition' => NULL, - ), - ), - 'inverseJoinColumns' => - array( - 0 => - array( - 'name' => 'user_id', - 'referencedColumnName' => 'id', - 'nullable' => true, - 'unique' => false, - 'onDelete' => NULL, - 'columnDefinition' => NULL, - ), - ), - 'name' => 'groups_users', - ), - 'type' => 8, - 'mappedBy' => NULL, - 'inversedBy' => NULL, - 'isOwningSide' => true, - 'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', - 'isCascadeRemove' => true, - 'isCascadePersist' => true, - 'isCascadeRefresh' => true, - 'isCascadeMerge' => true, - 'isCascadeDetach' => true, - 'isOnDeleteCascade' => true, - 'relationToSourceKeyColumns' => - array( - 'group_id' => 'id', - ), - 'joinTableColumns' => - array( - 0 => 'group_id', - 1 => 'user_id', - ), - 'relationToTargetKeyColumns' => - array( - 'user_id' => 'id', - ), - 'orphanRemoval' => false, - ), - ), $this->cm->associationMappings); - } - - public function testCreateOneToMany() - { - $this->assertIsFluent( - $this->builder->createOneToMany('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') - ->mappedBy('test') - ->setOrderBy(array('test')) - ->setIndexBy('test') - ->build() - ); - - $this->assertEquals(array( - 'groups' => - array( - 'fieldName' => 'groups', - 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', - 'mappedBy' => 'test', - 'orderBy' => - array( - 0 => 'test', - ), - 'indexBy' => 'test', - 'type' => 4, - 'inversedBy' => NULL, - 'isOwningSide' => false, - 'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', - 'fetch' => 2, - 'cascade' => - array( - ), - 'isCascadeRemove' => false, - 'isCascadePersist' => false, - 'isCascadeRefresh' => false, - 'isCascadeMerge' => false, - 'isCascadeDetach' => false, - 'orphanRemoval' => false, - ), - ), $this->cm->associationMappings); - } - - public function assertIsFluent($ret) - { - $this->assertSame($this->builder, $ret, "Return Value has to be same instance as used builder"); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php deleted file mode 100755 index 100e4df854..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ /dev/null @@ -1,368 +0,0 @@ -_createEntityManager($mockDriver); - - $conn = $entityManager->getConnection(); - $mockPlatform = $conn->getDatabasePlatform(); - $mockPlatform->setPrefersSequences(true); - $mockPlatform->setPrefersIdentityColumns(false); - - $cm1 = $this->_createValidClassMetadata(); - - // SUT - $cmf = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $cmf->setEntityManager($entityManager); - $cmf->setMetadataFor($cm1->name, $cm1); - - // Prechecks - $this->assertEquals(array(), $cm1->parentClasses); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType); - $this->assertTrue($cm1->hasField('name')); - $this->assertEquals(2, count($cm1->associationMappings)); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType); - $this->assertEquals('group', $cm1->table['name']); - - // Go - $cmMap1 = $cmf->getMetadataFor($cm1->name); - - $this->assertSame($cm1, $cmMap1); - $this->assertEquals('group', $cmMap1->table['name']); - $this->assertTrue($cmMap1->table['quoted']); - $this->assertEquals(array(), $cmMap1->parentClasses); - $this->assertTrue($cmMap1->hasField('name')); - } - - public function testGetMetadataFor_ReturnsLoadedCustomIdGenerator() - { - $cm1 = $this->_createValidClassMetadata(); - $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); - $cm1->customGeneratorDefinition = array( - "class" => "Doctrine\Tests\ORM\Mapping\CustomIdGenerator"); - $cmf = $this->_createTestFactory(); - $cmf->setMetadataForClass($cm1->name, $cm1); - - $actual = $cmf->getMetadataFor($cm1->name); - - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, - $actual->generatorType); - $this->assertInstanceOf("Doctrine\Tests\ORM\Mapping\CustomIdGenerator", - $actual->idGenerator); - } - - public function testGetMetadataFor_ThrowsExceptionOnUnknownCustomGeneratorClass() - { - $cm1 = $this->_createValidClassMetadata(); - $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); - $cm1->customGeneratorDefinition = array("class" => "NotExistingGenerator"); - $cmf = $this->_createTestFactory(); - $cmf->setMetadataForClass($cm1->name, $cm1); - $this->setExpectedException("Doctrine\ORM\ORMException"); - - $actual = $cmf->getMetadataFor($cm1->name); - } - - public function testGetMetadataFor_ThrowsExceptionOnMissingCustomGeneratorDefinition() - { - $cm1 = $this->_createValidClassMetadata(); - $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); - $cmf = $this->_createTestFactory(); - $cmf->setMetadataForClass($cm1->name, $cm1); - $this->setExpectedException("Doctrine\ORM\ORMException"); - - $actual = $cmf->getMetadataFor($cm1->name); - } - - public function testHasGetMetadata_NamespaceSeperatorIsNotNormalized() - { - require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; - - $metadataDriver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/Global/')); - - $entityManager = $this->_createEntityManager($metadataDriver); - - $mf = $entityManager->getMetadataFactory(); - $m1 = $mf->getMetadataFor("DoctrineGlobal_Article"); - $h1 = $mf->hasMetadataFor("DoctrineGlobal_Article"); - $h2 = $mf->hasMetadataFor("\DoctrineGlobal_Article"); - $m2 = $mf->getMetadataFor("\DoctrineGlobal_Article"); - - $this->assertNotSame($m1, $m2); - $this->assertFalse($h2); - $this->assertTrue($h1); - } - - /** - * @group DDC-1512 - */ - public function testIsTransient() - { - $cmf = new ClassMetadataFactory(); - $driver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $driver->expects($this->at(0)) - ->method('isTransient') - ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsUser')) - ->will($this->returnValue(true)); - $driver->expects($this->at(1)) - ->method('isTransient') - ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) - ->will($this->returnValue(false)); - - $em = $this->_createEntityManager($driver); - - $this->assertTrue($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsUser')); - $this->assertFalse($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsArticle')); - } - - /** - * @group DDC-1512 - */ - public function testIsTransientEntityNamespace() - { - $cmf = new ClassMetadataFactory(); - $driver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $driver->expects($this->at(0)) - ->method('isTransient') - ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsUser')) - ->will($this->returnValue(true)); - $driver->expects($this->at(1)) - ->method('isTransient') - ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) - ->will($this->returnValue(false)); - - $em = $this->_createEntityManager($driver); - $em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - - $this->assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); - $this->assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); - } - - public function testAddDefaultDiscriminatorMap() - { - $cmf = new ClassMetadataFactory(); - $driver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/JoinedInheritanceType/')); - $em = $this->_createEntityManager($driver); - $cmf->setEntityManager($em); - - $rootMetadata = $cmf->getMetadataFor('Doctrine\Tests\Models\JoinedInheritanceType\RootClass'); - $childMetadata = $cmf->getMetadataFor('Doctrine\Tests\Models\JoinedInheritanceType\ChildClass'); - $anotherChildMetadata = $cmf->getMetadataFor('Doctrine\Tests\Models\JoinedInheritanceType\AnotherChildClass'); - $rootDiscriminatorMap = $rootMetadata->discriminatorMap; - $childDiscriminatorMap = $childMetadata->discriminatorMap; - $anotherChildDiscriminatorMap = $anotherChildMetadata->discriminatorMap; - - $rootClass = 'Doctrine\Tests\Models\JoinedInheritanceType\RootClass'; - $childClass = 'Doctrine\Tests\Models\JoinedInheritanceType\ChildClass'; - $anotherChildClass = 'Doctrine\Tests\Models\JoinedInheritanceType\AnotherChildClass'; - - $rootClassKey = array_search($rootClass, $rootDiscriminatorMap); - $childClassKey = array_search($childClass, $rootDiscriminatorMap); - $anotherChildClassKey = array_search($anotherChildClass, $rootDiscriminatorMap); - - $this->assertEquals('rootclass', $rootClassKey); - $this->assertEquals('childclass', $childClassKey); - $this->assertEquals('anotherchildclass', $anotherChildClassKey); - - $this->assertEquals($childDiscriminatorMap, $rootDiscriminatorMap); - $this->assertEquals($anotherChildDiscriminatorMap, $rootDiscriminatorMap); - - // ClassMetadataFactory::addDefaultDiscriminatorMap shouldn't be called again, because the - // discriminator map is already cached - $cmf = $this->getMock('Doctrine\ORM\Mapping\ClassMetadataFactory', array('addDefaultDiscriminatorMap')); - $cmf->setEntityManager($em); - $cmf->expects($this->never()) - ->method('addDefaultDiscriminatorMap'); - - $rootMetadata = $cmf->getMetadataFor('Doctrine\Tests\Models\JoinedInheritanceType\RootClass'); - } - - protected function _createEntityManager($metadataDriver) - { - $driverMock = new DriverMock(); - $config = new \Doctrine\ORM\Configuration(); - $config->setProxyDir(__DIR__ . '/../../Proxies'); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $eventManager = new EventManager(); - $conn = new ConnectionMock(array(), $driverMock, $config, $eventManager); - $mockDriver = new MetadataDriverMock(); - $config->setMetadataDriverImpl($metadataDriver); - - return EntityManagerMock::create($conn, $config, $eventManager); - } - - /** - * @return ClassMetadataFactoryTestSubject - */ - protected function _createTestFactory() - { - $mockDriver = new MetadataDriverMock(); - $entityManager = $this->_createEntityManager($mockDriver); - $cmf = new ClassMetadataFactoryTestSubject(); - $cmf->setEntityManager($entityManager); - return $cmf; - } - - /** - * @param string $class - * @return ClassMetadata - */ - protected function _createValidClassMetadata() - { - // Self-made metadata - $cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1'); - $cm1->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm1->setPrimaryTable(array('name' => '`group`')); - // Add a mapped field - $cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar')); - // Add a mapped field - $cm1->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); - // and a mapped association - $cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'TestEntity1', 'mappedBy' => 'this')); - // and an association on the owning side - $joinColumns = array( - array('name' => 'other_id', 'referencedColumnName' => 'id') - ); - $cm1->mapOneToOne(array('fieldName' => 'association', 'targetEntity' => 'TestEntity1', 'joinColumns' => $joinColumns)); - // and an id generator type - $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); - return $cm1; - } - - /** - * @group DDC-1845 - */ - public function testQuoteMetadata() - { - $cmf = new ClassMetadataFactory(); - $driver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/Quote/')); - $em = $this->_createEntityManager($driver); - $cmf->setEntityManager($em); - - - $userMetadata = $cmf->getMetadataFor('Doctrine\Tests\Models\Quote\User'); - $phoneMetadata = $cmf->getMetadataFor('Doctrine\Tests\Models\Quote\Phone'); - $groupMetadata = $cmf->getMetadataFor('Doctrine\Tests\Models\Quote\Group'); - $addressMetadata = $cmf->getMetadataFor('Doctrine\Tests\Models\Quote\Address'); - - - // Phone Class Metadata - $this->assertTrue($phoneMetadata->fieldMappings['number']['quoted']); - $this->assertEquals('phone-number', $phoneMetadata->fieldMappings['number']['columnName']); - - $user = $phoneMetadata->associationMappings['user']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('user-id', $user['joinColumns'][0]['name']); - $this->assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); - - - - // User Group Metadata - $this->assertTrue($groupMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($groupMetadata->fieldMappings['name']['quoted']); - - $this->assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); - - $user = $groupMetadata->associationMappings['parent']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('parent-id', $user['joinColumns'][0]['name']); - $this->assertEquals('group-id', $user['joinColumns'][0]['referencedColumnName']); - - - // Address Class Metadata - $this->assertTrue($addressMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($addressMetadata->fieldMappings['zip']['quoted']); - - $this->assertEquals('address-id', $addressMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('address-zip', $addressMetadata->fieldMappings['zip']['columnName']); - - $user = $addressMetadata->associationMappings['user']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('user-id', $user['joinColumns'][0]['name']); - $this->assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); - - - - // User Class Metadata - $this->assertTrue($userMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($userMetadata->fieldMappings['name']['quoted']); - - $this->assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); - - - $address = $userMetadata->associationMappings['address']; - $this->assertTrue($address['joinColumns'][0]['quoted']); - $this->assertEquals('address-id', $address['joinColumns'][0]['name']); - $this->assertEquals('address-id', $address['joinColumns'][0]['referencedColumnName']); - - $groups = $userMetadata->associationMappings['groups']; - $this->assertTrue($groups['joinTable']['quoted']); - $this->assertTrue($groups['joinTable']['joinColumns'][0]['quoted']); - $this->assertEquals('quote-users-groups', $groups['joinTable']['name']); - $this->assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['referencedColumnName']); - - $this->assertTrue($groups['joinTable']['inverseJoinColumns'][0]['quoted']); - $this->assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); - } -} - -/* Test subject class with overriden factory method for mocking purposes */ -class ClassMetadataFactoryTestSubject extends \Doctrine\ORM\Mapping\ClassMetadataFactory -{ - private $mockMetadata = array(); - private $requestedClasses = array(); - - /** @override */ - protected function newClassMetadataInstance($className) - { - $this->requestedClasses[] = $className; - if ( ! isset($this->mockMetadata[$className])) { - throw new InvalidArgumentException("No mock metadata found for class $className."); - } - return $this->mockMetadata[$className]; - } - - public function setMetadataForClass($className, $metadata) - { - $this->mockMetadata[$className] = $metadata; - } - - public function getRequestedClasses() - { - return $this->requestedClasses; - } -} - -class TestEntity1 -{ - private $id; - private $name; - private $other; - private $association; -} - -class CustomIdGenerator extends \Doctrine\ORM\Id\AbstractIdGenerator -{ - public function generate(\Doctrine\ORM\EntityManager $em, $entity) - { - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php deleted file mode 100755 index 70aae70d4d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ /dev/null @@ -1,56 +0,0 @@ -_getTestEntityManager(); - $metadataFactory = $em->getMetadataFactory(); - $evm = $em->getEventManager(); - $evm->addEventListener(Events::loadClassMetadata, $this); - $classMetadata = $metadataFactory->getMetadataFor('Doctrine\Tests\ORM\Mapping\LoadEventTestEntity'); - $this->assertTrue($classMetadata->hasField('about')); - $this->assertArrayHasKey('about', $classMetadata->reflFields); - $this->assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); - } - - public function loadClassMetadata(\Doctrine\ORM\Event\LoadClassMetadataEventArgs $eventArgs) - { - $classMetadata = $eventArgs->getClassMetadata(); - $field = array( - 'fieldName' => 'about', - 'type' => 'string', - 'length' => 255 - ); - $classMetadata->mapField($field); - } -} - -/** - * @Entity - * @Table(name="load_event_test_entity") - */ -class LoadEventTestEntity -{ - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - /** - * @Column(type="string", length=255) - */ - private $name; - - private $about; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php deleted file mode 100755 index 954985e1fa..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ /dev/null @@ -1,995 +0,0 @@ -initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - // Test initial state - $this->assertTrue(count($cm->getReflectionProperties()) == 0); - $this->assertInstanceOf('ReflectionClass', $cm->reflClass); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->rootEntityName); - $this->assertEquals(array(), $cm->subClasses); - $this->assertEquals(array(), $cm->parentClasses); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType); - - // Customize state - $cm->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE); - $cm->setSubclasses(array("One", "Two", "Three")); - $cm->setParentClasses(array("UserParent")); - $cm->setCustomRepositoryClass("UserRepository"); - $cm->setDiscriminatorColumn(array('name' => 'disc', 'type' => 'integer')); - $cm->mapOneToOne(array('fieldName' => 'phonenumbers', 'targetEntity' => 'CmsAddress', 'mappedBy' => 'foo')); - $cm->markReadOnly(); - $cm->addNamedQuery(array('name' => 'dql', 'query' => 'foo')); - $this->assertEquals(1, count($cm->associationMappings)); - - $serialized = serialize($cm); - $cm = unserialize($serialized); - $cm->wakeupReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - // Check state - $this->assertTrue(count($cm->getReflectionProperties()) > 0); - $this->assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace); - $this->assertInstanceOf('ReflectionClass', $cm->reflClass); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name); - $this->assertEquals('UserParent', $cm->rootEntityName); - $this->assertEquals(array('Doctrine\Tests\Models\CMS\One', 'Doctrine\Tests\Models\CMS\Two', 'Doctrine\Tests\Models\CMS\Three'), $cm->subClasses); - $this->assertEquals(array('UserParent'), $cm->parentClasses); - $this->assertEquals('Doctrine\Tests\Models\CMS\UserRepository', $cm->customRepositoryClassName); - $this->assertEquals(array('name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'), $cm->discriminatorColumn); - $this->assertTrue($cm->associationMappings['phonenumbers']['type'] == ClassMetadata::ONE_TO_ONE); - $this->assertEquals(1, count($cm->associationMappings)); - $oneOneMapping = $cm->getAssociationMapping('phonenumbers'); - $this->assertTrue($oneOneMapping['fetch'] == ClassMetadata::FETCH_LAZY); - $this->assertEquals('phonenumbers', $oneOneMapping['fieldName']); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsAddress', $oneOneMapping['targetEntity']); - $this->assertTrue($cm->isReadOnly); - $this->assertEquals(array('dql' => array('name'=>'dql','query'=>'foo','dql'=>'foo')), $cm->namedQueries); - } - - public function testFieldIsNullable() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - // Explicit Nullable - $cm->mapField(array('fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50)); - $this->assertTrue($cm->isNullable('status')); - - // Explicit Not Nullable - $cm->mapField(array('fieldName' => 'username', 'nullable' => false, 'type' => 'string', 'length' => 50)); - $this->assertFalse($cm->isNullable('username')); - - // Implicit Not Nullable - $cm->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 50)); - $this->assertFalse($cm->isNullable('name'), "By default a field should not be nullable."); - } - - /** - * @group DDC-115 - */ - public function testMapAssocationInGlobalNamespace() - { - require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; - - $cm = new ClassMetadata('DoctrineGlobal_Article'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->mapManyToMany(array( - 'fieldName' => 'author', - 'targetEntity' => 'DoctrineGlobal_User', - 'joinTable' => array( - 'name' => 'bar', - 'joinColumns' => array(array('name' => 'bar_id', 'referencedColumnName' => 'id')), - 'inverseJoinColumns' => array(array('name' => 'baz_id', 'referencedColumnName' => 'id')), - ), - )); - - $this->assertEquals("DoctrineGlobal_User", $cm->associationMappings['author']['targetEntity']); - } - - public function testMapManyToManyJoinTableDefaults() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->mapManyToMany( - array( - 'fieldName' => 'groups', - 'targetEntity' => 'CmsGroup' - )); - - $assoc = $cm->associationMappings['groups']; - //$this->assertInstanceOf('Doctrine\ORM\Mapping\ManyToManyMapping', $assoc); - $this->assertEquals(array( - 'name' => 'cmsuser_cmsgroup', - 'joinColumns' => array(array('name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')), - 'inverseJoinColumns' => array(array('name' => 'cmsgroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')) - ), $assoc['joinTable']); - $this->assertTrue($assoc['isOnDeleteCascade']); - } - - public function testSerializeManyToManyJoinTableCascade() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->mapManyToMany( - array( - 'fieldName' => 'groups', - 'targetEntity' => 'CmsGroup' - )); - - /* @var $assoc \Doctrine\ORM\Mapping\ManyToManyMapping */ - $assoc = $cm->associationMappings['groups']; - $assoc = unserialize(serialize($assoc)); - - $this->assertTrue($assoc['isOnDeleteCascade']); - } - - /** - * @group DDC-115 - */ - public function testSetDiscriminatorMapInGlobalNamespace() - { - require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; - - $cm = new ClassMetadata('DoctrineGlobal_User'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->setDiscriminatorMap(array('descr' => 'DoctrineGlobal_Article', 'foo' => 'DoctrineGlobal_User')); - - $this->assertEquals("DoctrineGlobal_Article", $cm->discriminatorMap['descr']); - $this->assertEquals("DoctrineGlobal_User", $cm->discriminatorMap['foo']); - } - - /** - * @group DDC-115 - */ - public function testSetSubClassesInGlobalNamespace() - { - require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; - - $cm = new ClassMetadata('DoctrineGlobal_User'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->setSubclasses(array('DoctrineGlobal_Article')); - - $this->assertEquals("DoctrineGlobal_Article", $cm->subClasses[0]); - } - - /** - * @group DDC-268 - */ - public function testSetInvalidVersionMapping_ThrowsException() - { - $field = array(); - $field['fieldName'] = 'foo'; - $field['type'] = 'string'; - - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $cm->setVersionMapping($field); - } - - public function testGetSingleIdentifierFieldName_MultipleIdentifierEntity_ThrowsException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->isIdentifierComposite = true; - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $cm->getSingleIdentifierFieldName(); - } - - public function testDuplicateAssociationMappingException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $a1 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'); - $a2 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'); - - $cm->addInheritedAssociationMapping($a1); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $cm->addInheritedAssociationMapping($a2); - } - - public function testDuplicateColumnName_ThrowsMappingException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $cm->mapField(array('fieldName' => 'username', 'columnName' => 'name')); - } - - public function testDuplicateColumnName_DiscriminatorColumn_ThrowsMappingException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $cm->setDiscriminatorColumn(array('name' => 'name')); - } - - public function testDuplicateColumnName_DiscriminatorColumn2_ThrowsMappingException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->setDiscriminatorColumn(array('name' => 'name')); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); - } - - public function testDuplicateFieldAndAssocationMapping1_ThrowsException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); - } - - public function testDuplicateFieldAndAssocationMapping2_ThrowsException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); - $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); - } - - /** - * @group DDC-1224 - */ - public function testGetTemporaryTableNameSchema() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->setTableName('foo.bar'); - - $this->assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName()); - } - - public function testDefaultTableName() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - // When table's name is not given - $primaryTable = array(); - $cm->setPrimaryTable($primaryTable); - - $this->assertEquals('CmsUser', $cm->getTableName()); - $this->assertEquals('CmsUser', $cm->table['name']); - - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - // When joinTable's name is not given - $cm->mapManyToMany(array( - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser', - 'inversedBy' => 'users', - 'joinTable' => array('joinColumns' => array(array('referencedColumnName' => 'id')), - 'inverseJoinColumns' => array(array('referencedColumnName' => 'id'))))); - $this->assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']); - } - - public function testDefaultJoinColumnName() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - // this is really dirty, but it's the simpliest way to test whether - // joinColumn's name will be automatically set to user_id - $cm->mapOneToOne(array( - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser', - 'joinColumns' => array(array('referencedColumnName' => 'id')))); - $this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); - - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->mapManyToMany(array( - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser', - 'inversedBy' => 'users', - 'joinTable' => array('name' => 'user_CmsUser', - 'joinColumns' => array(array('referencedColumnName' => 'id')), - 'inverseJoinColumns' => array(array('referencedColumnName' => 'id'))))); - $this->assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); - } - - /** - * @group DDC-559 - */ - public function testUnderscoreNamingStrategyDefaults() - { - $namingStrategy = new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy(CASE_UPPER); - $oneToOneMetadata = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', $namingStrategy); - $manyToManyMetadata = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', $namingStrategy); - - $oneToOneMetadata->mapOneToOne(array( - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser' - )); - - $manyToManyMetadata->mapManyToMany(array( - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser' - )); - - $this->assertEquals(array('USER_ID'=>'ID'), $oneToOneMetadata->associationMappings['user']['sourceToTargetKeyColumns']); - $this->assertEquals(array('USER_ID'=>'USER_ID'), $oneToOneMetadata->associationMappings['user']['joinColumnFieldNames']); - $this->assertEquals(array('ID'=>'USER_ID'), $oneToOneMetadata->associationMappings['user']['targetToSourceKeyColumns']); - - $this->assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['name']); - $this->assertEquals('ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['referencedColumnName']); - - - $this->assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']['joinTable']['name']); - - $this->assertEquals(array('CMS_ADDRESS_ID','CMS_USER_ID'), $manyToManyMetadata->associationMappings['user']['joinTableColumns']); - $this->assertEquals(array('CMS_ADDRESS_ID'=>'ID'), $manyToManyMetadata->associationMappings['user']['relationToSourceKeyColumns']); - $this->assertEquals(array('CMS_USER_ID'=>'ID'), $manyToManyMetadata->associationMappings['user']['relationToTargetKeyColumns']); - - $this->assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); - - $this->assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); - - - $cm = new ClassMetadata('DoctrineGlobal_Article', $namingStrategy); - $cm->mapManyToMany(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\Tests\Models\CMS\CmsUser')); - $this->assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); - } - - /** - * @group DDC-886 - */ - public function testSetMultipleIdentifierSetsComposite() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapField(array('fieldName' => 'name')); - $cm->mapField(array('fieldName' => 'username')); - - $cm->setIdentifier(array('name', 'username')); - $this->assertTrue($cm->isIdentifierComposite); - } - - /** - * @group DDC-944 - */ - public function testMappingNotFound() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "No mapping found for field 'foo' on class 'Doctrine\Tests\Models\CMS\CmsUser'."); - $cm->getFieldMapping('foo'); - } - - /** - * @group DDC-961 - */ - public function testJoinTableMappingDefaults() - { - $cm = new ClassMetadata('DoctrineGlobal_Article'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapManyToMany(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\Tests\Models\CMS\CmsUser')); - - $this->assertEquals('doctrineglobal_article_cmsuser', $cm->associationMappings['author']['joinTable']['name']); - } - - /** - * @group DDC-117 - */ - public function testMapIdentifierAssociation() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapOneToOne(array( - 'fieldName' => 'article', - 'id' => true, - 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', - 'joinColumns' => array(), - )); - - $this->assertTrue($cm->containsForeignIdentifier, "Identifier Association should set 'containsForeignIdentifier' boolean flag."); - $this->assertEquals(array("article"), $cm->identifier); - } - - /** - * @group DDC-117 - */ - public function testOrphanRemovalIdentifierAssociation() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'The orphan removal option is not allowed on an association that'); - $cm->mapOneToOne(array( - 'fieldName' => 'article', - 'id' => true, - 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', - 'orphanRemoval' => true, - 'joinColumns' => array(), - )); - } - - /** - * @group DDC-117 - */ - public function testInverseIdentifierAssocation() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'An inverse association is not allowed to be identifier in'); - $cm->mapOneToOne(array( - 'fieldName' => 'article', - 'id' => true, - 'mappedBy' => 'details', // INVERSE! - 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', - 'joinColumns' => array(), - )); - } - - /** - * @group DDC-117 - */ - public function testIdentifierAssocationManyToMany() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'Many-to-many or one-to-many associations are not allowed to be identifier in'); - $cm->mapManyToMany(array( - 'fieldName' => 'article', - 'id' => true, - 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', - 'joinColumns' => array(), - )); - } - - /** - * @group DDC-996 - */ - public function testEmptyFieldNameThrowsException() - { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "The field or association mapping misses the 'fieldName' attribute in entity 'Doctrine\Tests\Models\CMS\CmsUser'."); - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->mapField(array('fieldName' => '')); - } - - public function testRetrievalOfNamedQueries() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - - $this->assertEquals(0, count($cm->getNamedQueries())); - - $cm->addNamedQuery(array( - 'name' => 'userById', - 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1' - )); - - $this->assertEquals(1, count($cm->getNamedQueries())); - } - - /** - * @group DDC-1663 - */ - public function testRetrievalOfResultSetMappings() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - - $this->assertEquals(0, count($cm->getSqlResultSetMappings())); - - $cm->addSqlResultSetMapping(array( - 'name' => 'find-all', - 'entities' => array( - array( - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - ), - ), - )); - - $this->assertEquals(1, count($cm->getSqlResultSetMappings())); - } - - public function testExistanceOfNamedQuery() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - - $cm->addNamedQuery(array( - 'name' => 'all', - 'query' => 'SELECT u FROM __CLASS__ u' - )); - - $this->assertTrue($cm->hasNamedQuery('all')); - $this->assertFalse($cm->hasNamedQuery('userById')); - } - - /** - * @group DDC-1663 - */ - public function testRetrieveOfNamedNativeQuery() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->addNamedNativeQuery(array( - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultSetMapping' => 'result-mapping-name', - 'resultClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - )); - - $cm->addNamedNativeQuery(array( - 'name' => 'find-by-id', - 'query' => 'SELECT * FROM cms_users WHERE id = ?', - 'resultClass' => '__CLASS__', - 'resultSetMapping' => 'result-mapping-name', - )); - - $mapping = $cm->getNamedNativeQuery('find-all'); - $this->assertEquals('SELECT * FROM cms_users', $mapping['query']); - $this->assertEquals('result-mapping-name', $mapping['resultSetMapping']); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $mapping['resultClass']); - - $mapping = $cm->getNamedNativeQuery('find-by-id'); - $this->assertEquals('SELECT * FROM cms_users WHERE id = ?', $mapping['query']); - $this->assertEquals('result-mapping-name', $mapping['resultSetMapping']); - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $mapping['resultClass']); - } - - /** - * @group DDC-1663 - */ - public function testRetrieveOfSqlResultSetMapping() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->addSqlResultSetMapping(array( - 'name' => 'find-all', - 'entities' => array( - array( - 'entityClass' => '__CLASS__', - 'fields' => array( - array( - 'name' => 'id', - 'column'=> 'id' - ), - array( - 'name' => 'name', - 'column'=> 'name' - ) - ) - ), - array( - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsEmail', - 'fields' => array( - array( - 'name' => 'id', - 'column'=> 'id' - ), - array( - 'name' => 'email', - 'column'=> 'email' - ) - ) - ) - ), - 'columns' => array( - array( - 'name' => 'scalarColumn' - ) - ) - )); - - $mapping = $cm->getSqlResultSetMapping('find-all'); - - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $mapping['entities'][0]['entityClass']); - $this->assertEquals(array('name'=>'id','column'=>'id'), $mapping['entities'][0]['fields'][0]); - $this->assertEquals(array('name'=>'name','column'=>'name'), $mapping['entities'][0]['fields'][1]); - - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsEmail', $mapping['entities'][1]['entityClass']); - $this->assertEquals(array('name'=>'id','column'=>'id'), $mapping['entities'][1]['fields'][0]); - $this->assertEquals(array('name'=>'email','column'=>'email'), $mapping['entities'][1]['fields'][1]); - - $this->assertEquals('scalarColumn', $mapping['columns'][0]['name']); - } - - /** - * @group DDC-1663 - */ - public function testExistanceOfSqlResultSetMapping() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->addSqlResultSetMapping(array( - 'name' => 'find-all', - 'entities' => array( - array( - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - ), - ), - )); - - $this->assertTrue($cm->hasSqlResultSetMapping('find-all')); - $this->assertFalse($cm->hasSqlResultSetMapping('find-by-id')); - } - - /** - * @group DDC-1663 - */ - public function testExistanceOfNamedNativeQuery() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - - $cm->addNamedNativeQuery(array( - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'resultSetMapping' => 'result-mapping-name' - )); - - $this->assertTrue($cm->hasNamedNativeQuery('find-all')); - $this->assertFalse($cm->hasNamedNativeQuery('find-by-id')); - } - - public function testRetrieveOfNamedQuery() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - - $cm->addNamedQuery(array( - 'name' => 'userById', - 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1' - )); - - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', $cm->getNamedQuery('userById')); - } - - /** - * @group DDC-1663 - */ - public function testRetrievalOfNamedNativeQueries() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $this->assertEquals(0, count($cm->getNamedNativeQueries())); - - $cm->addNamedNativeQuery(array( - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'resultSetMapping' => 'result-mapping-name' - )); - - $this->assertEquals(1, count($cm->getNamedNativeQueries())); - } - - /** - * @expectedException \Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Query named "userById" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once - */ - public function testNamingCollisionNamedQueryShouldThrowException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->addNamedQuery(array( - 'name' => 'userById', - 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1' - )); - - $cm->addNamedQuery(array( - 'name' => 'userById', - 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1' - )); - } - - /** - * @group DDC-1663 - * - * @expectedException \Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Query named "find-all" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once - */ - public function testNamingCollisionNamedNativeQueryShouldThrowException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->addNamedNativeQuery(array( - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'resultSetMapping' => 'result-mapping-name' - )); - - $cm->addNamedNativeQuery(array( - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'resultSetMapping' => 'result-mapping-name' - )); - } - - /** - * @group DDC-1663 - * - * @expectedException \Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Result set mapping named "find-all" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once - */ - public function testNamingCollisionSqlResultSetMappingShouldThrowException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $cm->addSqlResultSetMapping(array( - 'name' => 'find-all', - 'entities' => array( - array( - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - ), - ), - )); - - $cm->addSqlResultSetMapping(array( - 'name' => 'find-all', - 'entities' => array( - array( - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - ), - ), - )); - } - - /** - * @group DDC-1068 - */ - public function testClassCaseSensitivity() - { - $user = new \Doctrine\Tests\Models\CMS\CmsUser(); - $cm = new ClassMetadata('DOCTRINE\TESTS\MODELS\CMS\CMSUSER'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name); - } - - /** - * @group DDC-659 - */ - public function testLifecycleCallbackNotFound() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->addLifecycleCallback('notfound', 'postLoad'); - - $this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "Entity 'Doctrine\Tests\Models\CMS\CmsUser' has no method 'notfound' to be registered as lifecycle callback."); - $cm->validateLifecycleCallbacks(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - } - - /** - * @group ImproveErrorMessages - */ - public function testTargetEntityNotFound() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass')); - - $this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "The target-entity Doctrine\Tests\Models\CMS\UnknownClass cannot be found in 'Doctrine\Tests\Models\CMS\CmsUser#address'."); - $cm->validateAssocations(); - } - - /** - * @group DDC-1663 - * - * @expectedException \Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Query name on entity class 'Doctrine\Tests\Models\CMS\CmsUser' is not defined. - */ - public function testNameIsMandatoryForNamedQueryMappingException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->addNamedQuery(array( - 'query' => 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', - )); - } - - /** - * @group DDC-1663 - * - * @expectedException \Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Query name on entity class 'Doctrine\Tests\Models\CMS\CmsUser' is not defined. - */ - public function testNameIsMandatoryForNameNativeQueryMappingException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->addNamedQuery(array( - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'resultSetMapping' => 'result-mapping-name' - )); - } - - /** - * @group DDC-1663 - * - * @expectedException \Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Result set mapping named "find-all" in "Doctrine\Tests\Models\CMS\CmsUser requires a entity class name. - */ - public function testNameIsMandatoryForEntityNameSqlResultSetMappingException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->addSqlResultSetMapping(array( - 'name' => 'find-all', - 'entities' => array( - array( - 'fields' => array() - ) - ), - )); - } - - /** - * @expectedException \Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Discriminator column name on entity class 'Doctrine\Tests\Models\CMS\CmsUser' is not defined. - */ - public function testNameIsMandatoryForDiscriminatorColumnsMappingException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->setDiscriminatorColumn(array()); - } - - /** - * @group DDC-984 - * @group DDC-559 - * @group DDC-1575 - */ - public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy() - { - $namingStrategy = new MyNamespacedNamingStrategy(); - $addressMetadata = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', $namingStrategy); - $articleMetadata = new ClassMetadata('DoctrineGlobal_Article', $namingStrategy); - $routingMetadata = new ClassMetadata('Doctrine\Tests\Models\Routing\RoutingLeg',$namingStrategy); - - $addressMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $articleMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $routingMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $addressMetadata->mapManyToMany(array( - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser' - )); - - $articleMetadata->mapManyToMany(array( - 'fieldName' => 'author', - 'targetEntity' => 'Doctrine\Tests\Models\CMS\CmsUser' - )); - - $this->assertEquals('routing_routingleg', $routingMetadata->table['name']); - $this->assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']['joinTable']['name']); - $this->assertEquals('doctrineglobal_article_cms_cmsuser', $articleMetadata->associationMappings['author']['joinTable']['name']); - } - - /** - * @group DDC-1746 - */ - public function testInvalidCascade() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "You have specified invalid cascade options for Doctrine\Tests\Models\CMS\CmsUser::\$address: 'invalid'; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'"); - - - $cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass', 'cascade' => array('invalid'))); - } - - /** - * @group DDC-964 - * @expectedException Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Invalid field override named 'invalidPropertyName' for class 'Doctrine\Tests\Models\DDC964\DDC964Admin - */ - public function testInvalidPropertyAssociationOverrideNameException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\DDC964\DDC964Admin'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'DDC964Address')); - - $cm->setAssociationOverride('invalidPropertyName', array()); - } - - /** - * @group DDC-964 - * @expectedException Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage Invalid field override named 'invalidPropertyName' for class 'Doctrine\Tests\Models\DDC964\DDC964Guest'. - */ - public function testInvalidPropertyAttributeOverrideNameException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\DDC964\DDC964Guest'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->mapField(array('fieldName' => 'name')); - - $cm->setAttributeOverride('invalidPropertyName', array()); - } - - /** - * @group DDC-964 - * @expectedException Doctrine\ORM\Mapping\MappingException - * @expectedExceptionMessage The column type of attribute 'name' on class 'Doctrine\Tests\Models\DDC964\DDC964Guest' could not be changed. - */ - public function testInvalidOverrideAttributeFieldTypeException() - { - $cm = new ClassMetadata('Doctrine\Tests\Models\DDC964\DDC964Guest'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->mapField(array('fieldName' => 'name', 'type'=>'string')); - - $cm->setAttributeOverride('name', array('type'=>'date')); - } -} - -class MyNamespacedNamingStrategy extends \Doctrine\ORM\Mapping\DefaultNamingStrategy -{ - /** - * {@inheritdoc} - */ - public function classToTableName($className) - { - if (strpos($className, '\\') !== false) { - $className = str_replace('\\', '_', str_replace('Doctrine\Tests\Models\\', '', $className)); - } - - return strtolower($className); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php deleted file mode 100755 index 0c56aa8107..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php +++ /dev/null @@ -1,298 +0,0 @@ -assertEquals($expected, $strategy->classToTableName($className)); - } - - /** - * Data Provider for NamingStrategy#propertyToColumnName - * - * @return array - */ - static public function dataPropertyToColumnName() - { - return array( - // DefaultNamingStrategy - array(self::defaultNaming(), 'someProperty', - 'someProperty' - ), - array(self::defaultNaming(), 'SOME_PROPERTY', - 'SOME_PROPERTY' - ), - array(self::defaultNaming(), 'some_property', - 'some_property' - ), - - // UnderscoreNamingStrategy - array(self::underscoreNamingLower(), 'some_property', - 'someProperty' - ), - array(self::underscoreNamingUpper(), 'SOME_PROPERTY', - 'someProperty' - ), - array(self::underscoreNamingUpper(), 'SOME_PROPERTY', - 'some_property' - ), - array(self::underscoreNamingUpper(), 'SOME_PROPERTY', - 'SOME_PROPERTY' - ), - ); - } - - /** - * @dataProvider dataPropertyToColumnName - * - * @param NamingStrategy $strategy - * @param string $expected - * @param string $propertyName - */ - public function testPropertyToColumnName(NamingStrategy $strategy, $expected, $propertyName) - { - $this->assertEquals($expected, $strategy->propertyToColumnName($propertyName)); - } - - /** - * Data Provider for NamingStrategy#referenceColumnName - * - * @return array - */ - static public function dataReferenceColumnName() - { - return array( - // DefaultNamingStrategy - array(self::defaultNaming(), 'id'), - - // UnderscoreNamingStrategy - array(self::underscoreNamingLower(), 'id'), - array(self::underscoreNamingUpper(), 'ID'), - ); - } - - /** - * @dataProvider dataReferenceColumnName - * - * @param NamingStrategy $strategy - * @param string $expected - */ - public function testReferenceColumnName(NamingStrategy $strategy, $expected) - { - $this->assertEquals($expected, $strategy->referenceColumnName()); - } - - /** - * Data Provider for NamingStrategy#joinColumnName - * - * @return array - */ - static public function dataJoinColumnName() - { - return array( - // DefaultNamingStrategy - array(self::defaultNaming(), 'someColumn_id', - 'someColumn', null, - ), - array(self::defaultNaming(), 'some_column_id', - 'some_column', null, - ), - - // UnderscoreNamingStrategy - array(self::underscoreNamingLower(), 'some_column_id', - 'someColumn', null, - ), - array(self::underscoreNamingUpper(), 'SOME_COLUMN_ID', - 'someColumn', null, - ), - ); - } - - /** - * @dataProvider dataJoinColumnName - * - * @param NamingStrategy $strategy - * @param string $expected - * @param string $propertyName - */ - public function testJoinColumnName(NamingStrategy $strategy, $expected, $propertyName) - { - $this->assertEquals($expected, $strategy->joinColumnName($propertyName)); - } - - /** - * Data Provider for NamingStrategy#joinTableName - * - * @return array - */ - static public function dataJoinTableName() - { - return array( - // DefaultNamingStrategy - array(self::defaultNaming(), 'someclassname_classname', - 'SomeClassName', 'Some\ClassName', null, - ), - array(self::defaultNaming(), 'someclassname_classname', - '\SomeClassName', 'ClassName', null, - ), - array(self::defaultNaming(), 'name_classname', - '\Some\Class\Name', 'ClassName', null, - ), - - // UnderscoreNamingStrategy - array(self::underscoreNamingLower(), 'some_class_name_class_name', - 'SomeClassName', 'Some\ClassName', null, - ), - array(self::underscoreNamingLower(), 'some_class_name_class_name', - '\SomeClassName', 'ClassName', null, - ), - array(self::underscoreNamingLower(), 'name_class_name', - '\Some\Class\Name', 'ClassName', null, - ), - - array(self::underscoreNamingUpper(), 'SOME_CLASS_NAME_CLASS_NAME', - 'SomeClassName', 'Some\ClassName', null, - ), - array(self::underscoreNamingUpper(), 'SOME_CLASS_NAME_CLASS_NAME', - '\SomeClassName', 'ClassName', null, - ), - array(self::underscoreNamingUpper(), 'NAME_CLASS_NAME', - '\Some\Class\Name', 'ClassName', null, - ), - ); - } - - /** - * @dataProvider dataJoinTableName - * - * @param NamingStrategy $strategy - * @param string $expected - * @param string $ownerEntity - * @param string $associatedEntity - * @param string $propertyName - */ - public function testJoinTableName(NamingStrategy $strategy, $expected, $ownerEntity, $associatedEntity, $propertyName = null) - { - $this->assertEquals($expected, $strategy->joinTableName($ownerEntity, $associatedEntity, $propertyName)); - } - - /** - * Data Provider for NamingStrategy#joinKeyColumnName - * - * @return array - */ - static public function dataJoinKeyColumnName() - { - return array( - // DefaultNamingStrategy - array(self::defaultNaming(), 'someclassname_id', - 'SomeClassName', null, null, - ), - array(self::defaultNaming(), 'name_identifier', - '\Some\Class\Name', 'identifier', null, - ), - - // UnderscoreNamingStrategy - array(self::underscoreNamingLower(), 'some_class_name_id', - 'SomeClassName', null, null, - ), - array(self::underscoreNamingLower(), 'class_name_identifier', - '\Some\Class\ClassName', 'identifier', null, - ), - - array(self::underscoreNamingUpper(), 'SOME_CLASS_NAME_ID', - 'SomeClassName', null, null, - ), - array(self::underscoreNamingUpper(), 'CLASS_NAME_IDENTIFIER', - '\Some\Class\ClassName', 'IDENTIFIER', null, - ), - ); - } - - /** - * @dataProvider dataJoinKeyColumnName - * - * @param NamingStrategy $strategy - * @param string $expected - * @param string $propertyEntityName - * @param string $referencedColumnName - * @param string $propertyName - */ - public function testJoinKeyColumnName(NamingStrategy $strategy, $expected, $propertyEntityName, $referencedColumnName = null, $propertyName = null) - { - $this->assertEquals($expected, $strategy->joinKeyColumnName($propertyEntityName, $referencedColumnName, $propertyName)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php deleted file mode 100755 index c9da3dc7a3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php +++ /dev/null @@ -1,38 +0,0 @@ -createAnnotationDriver(); -// $driver->loadMetadataForClass("Doctrine\Tests\ORM\Mapping\Animal", $meta); -// $exporter = $cme->getExporter('php', $path); -// echo $exporter->exportClassMetadata($meta); - - return new PHPDriver($path); - } - - /** - * All class are entitier for php driver - * - * @group DDC-889 - */ - public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses() - { - $this->createClassMetadata('Doctrine\Tests\Models\DDC889\DDC889Class'); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php deleted file mode 100755 index 23f02b4519..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ /dev/null @@ -1,197 +0,0 @@ -_getTestEntityManager(); - $this->platform = $em->getConnection()->getDatabasePlatform(); - $this->strategy = new DefaultQuoteStrategy(); - } - - /** - * @param string $className - * @return \Doctrine\ORM\Mapping\ClassMetadata - */ - private function createClassMetadata($className) - { - $cm = new ClassMetadata($className); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - return $cm; - } - - public function testConfiguration() - { - $em = $this->_getTestEntityManager(); - $config = $em->getConfiguration(); - - $this->assertInstanceOf('Doctrine\ORM\Mapping\QuoteStrategy', $config->getQuoteStrategy()); - $this->assertInstanceOf('Doctrine\ORM\Mapping\DefaultQuoteStrategy', $config->getQuoteStrategy()); - - $config->setQuoteStrategy(new MyQuoteStrategy()); - - $this->assertInstanceOf('Doctrine\ORM\Mapping\QuoteStrategy', $config->getQuoteStrategy()); - $this->assertInstanceOf('Doctrine\Tests\ORM\Mapping\MyQuoteStrategy', $config->getQuoteStrategy()); - } - - public function testGetColumnName() - { - $cm = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->mapField(array('fieldName' => 'name', 'columnName' => '`name`')); - $cm->mapField(array('fieldName' => 'id', 'columnName' => 'id')); - - $this->assertEquals('id' ,$this->strategy->getColumnName('id', $cm, $this->platform)); - $this->assertEquals('"name"' ,$this->strategy->getColumnName('name', $cm, $this->platform)); - } - - public function testGetTableName() - { - $cm = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->setPrimaryTable(array('name'=>'`cms_user`')); - $this->assertEquals('"cms_user"' ,$this->strategy->getTableName($cm, $this->platform)); - - $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $cm->setPrimaryTable(array('name'=>'cms_user')); - $this->assertEquals('cms_user' ,$this->strategy->getTableName($cm, $this->platform)); - } - - public function testJoinTableName() - { - $cm1 = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - $cm2 = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - - $cm1->mapManyToMany(array( - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser', - 'inversedBy' => 'users', - 'joinTable' => array( - 'name' => '`cmsaddress_cmsuser`' - ) - )); - - $cm2->mapManyToMany(array( - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser', - 'inversedBy' => 'users', - 'joinTable' => array( - 'name' => 'cmsaddress_cmsuser' - ) - ) - ); - - $this->assertEquals('"cmsaddress_cmsuser"', $this->strategy->getJoinTableName($cm1->associationMappings['user'], $cm1, $this->platform)); - $this->assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($cm2->associationMappings['user'], $cm2, $this->platform)); - - } - - public function testIdentifierColumnNames() - { - $cm1 = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - $cm2 = $this->createClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); - - $cm1->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'columnName' => '`id`', - )); - - $cm2->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'columnName' => 'id', - )); - - $this->assertEquals(array('"id"'), $this->strategy->getIdentifierColumnNames($cm1, $this->platform)); - $this->assertEquals(array('id'), $this->strategy->getIdentifierColumnNames($cm2, $this->platform)); - } - - - public function testColumnAlias() - { - $i = 0; - $this->assertEquals('columnName0', $this->strategy->getColumnAlias('columnName', $i++, $this->platform)); - $this->assertEquals('column_name1', $this->strategy->getColumnAlias('column_name', $i++, $this->platform)); - $this->assertEquals('COLUMN_NAME2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++, $this->platform)); - $this->assertEquals('COLUMNNAME3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++, $this->platform)); - } - - public function testQuoteIdentifierJoinColumns() - { - $cm = $this->createClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); - - $cm->mapOneToOne(array( - 'id' => true, - 'fieldName' => 'article', - 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', - 'joinColumns' => array(array( - 'name' => '`article`' - )), - )); - - $this->assertEquals(array('"article"'), $this->strategy->getIdentifierColumnNames($cm, $this->platform)); - } - - public function testJoinColumnName() - { - $cm = $this->createClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); - - $cm->mapOneToOne(array( - 'id' => true, - 'fieldName' => 'article', - 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', - 'joinColumns' => array(array( - 'name' => '`article`' - )), - )); - - $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('"article"',$this->strategy->getJoinColumnName($joinColumn, $cm, $this->platform)); - } - - public function testReferencedJoinColumnName() - { - $cm = $this->createClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); - - $cm->mapOneToOne(array( - 'id' => true, - 'fieldName' => 'article', - 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', - 'joinColumns' => array(array( - 'name' => '`article`' - )), - )); - - $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('"id"',$this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); - } -} - -class MyQuoteStrategy extends \Doctrine\ORM\Mapping\DefaultQuoteStrategy -{ - -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php deleted file mode 100755 index 77eafe1272..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php +++ /dev/null @@ -1,28 +0,0 @@ -createClassMetadata('Doctrine\Tests\Models\DDC889\DDC889Class'); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php deleted file mode 100755 index 405260185b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php +++ /dev/null @@ -1,113 +0,0 @@ -. -*/ - -namespace Doctrine\Tests\ORM\Mapping\Symfony; - -/** - * @group DDC-1418 - */ -abstract class AbstractDriverTest extends \PHPUnit_Framework_TestCase -{ - public function testFindMappingFile() - { - $driver = $this->getDriver(array( - 'MyNamespace\MySubnamespace\EntityFoo' => 'foo', - 'MyNamespace\MySubnamespace\Entity' => $this->dir, - )); - - touch($filename = $this->dir.'/Foo'.$this->getFileExtension()); - $this->assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo')); - } - - public function testFindMappingFileInSubnamespace() - { - $driver = $this->getDriver(array( - 'MyNamespace\MySubnamespace\Entity' => $this->dir, - )); - - touch($filename = $this->dir.'/Foo.Bar'.$this->getFileExtension()); - $this->assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo\Bar')); - } - - public function testFindMappingFileNamespacedFoundFileNotFound() - { - $this->setExpectedException( - 'Doctrine\Common\Persistence\Mapping\MappingException', - "No mapping file found named '".$this->dir."/Foo".$this->getFileExtension()."' for class 'MyNamespace\MySubnamespace\Entity\Foo'." - ); - - $driver = $this->getDriver(array( - 'MyNamespace\MySubnamespace\Entity' => $this->dir, - )); - - $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo'); - } - - public function testFindMappingNamespaceNotFound() - { - $this->setExpectedException( - 'Doctrine\Common\Persistence\Mapping\MappingException', - "No mapping file found named 'Foo".$this->getFileExtension()."' for class 'MyOtherNamespace\MySubnamespace\Entity\Foo'." - ); - - $driver = $this->getDriver(array( - 'MyNamespace\MySubnamespace\Entity' => $this->dir, - )); - - $driver->getLocator()->findMappingFile('MyOtherNamespace\MySubnamespace\Entity\Foo'); - } - - protected function setUp() - { - $this->dir = sys_get_temp_dir().'/abstract_driver_test'; - @mkdir($this->dir, 0777, true); - } - - protected function tearDown() - { - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->dir), \RecursiveIteratorIterator::CHILD_FIRST); - - foreach ($iterator as $path) { - if ($path->isDir()) { - @rmdir($path); - } else { - @unlink($path); - } - } - - @rmdir($this->dir); - } - - abstract protected function getFileExtension(); - abstract protected function getDriver(array $paths = array()); - - private function setField($obj, $field, $value) - { - $ref = new \ReflectionProperty($obj, $field); - $ref->setAccessible(true); - $ref->setValue($obj, $value); - } - - private function invoke($obj, $method, array $args = array()) { - $ref = new \ReflectionMethod($obj, $method); - $ref->setAccessible(true); - - return $ref->invokeArgs($obj, $args); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php deleted file mode 100755 index c5d8d1cd1b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php +++ /dev/null @@ -1,40 +0,0 @@ -. -*/ - -namespace Doctrine\Tests\ORM\Mapping\Symfony; - -use \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver; - -/** - * @group DDC-1418 - */ -class YamlDriverTest extends AbstractDriverTest -{ - protected function getFileExtension() - { - return '.orm.yml'; - } - - protected function getDriver(array $paths = array()) - { - $driver = new SimplifiedYamlDriver(array_flip($paths)); - - return $driver; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php deleted file mode 100755 index e69f23a35c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ /dev/null @@ -1,106 +0,0 @@ -_loadDriver(); - - $class = new ClassMetadata($className); - $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $mappingDriver->loadMetadataForClass($className, $class); - - $expectedMap = array( - "foo" => "Doctrine\Tests\ORM\Mapping\CTIFoo", - "bar" => "Doctrine\Tests\ORM\Mapping\CTIBar", - "baz" => "Doctrine\Tests\ORM\Mapping\CTIBaz", - ); - - $this->assertEquals(3, count($class->discriminatorMap)); - $this->assertEquals($expectedMap, $class->discriminatorMap); - } - - public function testIdentifierWithAssociationKey() - { - $driver = $this->_loadDriver(); - $em = $this->_getTestEntityManager(); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - - $em->getConfiguration()->setMetadataDriverImpl($driver); - $factory->setEntityManager($em); - - $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC117\DDC117Translation'); - - $this->assertEquals(array('language', 'article'), $class->identifier); - $this->assertArrayHasKey('article', $class->associationMappings); - - $this->assertArrayHasKey('id', $class->associationMappings['article']); - $this->assertTrue($class->associationMappings['article']['id']); - } - - /** - * @group DDC-1468 - * - * @expectedException Doctrine\Common\Persistence\Mapping\MappingException - * @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'. - */ - public function testInvalidMappingFileException() - { - $this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel'); - } - - /** - * @param string $xmlMappingFile - * @dataProvider dataValidSchema - */ - public function testValidateXmlSchema($xmlMappingFile) - { - $xsdSchemaFile = __DIR__ . "/../../../../../doctrine-mapping.xsd"; - - $dom = new \DOMDocument('UTF-8'); - $dom->load($xmlMappingFile); - $this->assertTrue($dom->schemaValidate($xsdSchemaFile)); - } - - static public function dataValidSchema() - { - return array( - array(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml"), - array(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml"), - array(__DIR__ . "/xml/CatNoId.dcm.xml"), - ); - } - - /** - * @group DDC-889 - * @expectedException Doctrine\Common\Persistence\Mapping\MappingException - * @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml' for class 'Doctrine\Tests\Models\DDC889\DDC889Class'. - */ - public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses() - { - $this->createClassMetadata('Doctrine\Tests\Models\DDC889\DDC889Class'); - } -} - -class CTI -{ - public $id; -} - -class CTIFoo extends CTI {} -class CTIBar extends CTI {} -class CTIBaz extends CTI {} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php deleted file mode 100755 index 5551844589..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ /dev/null @@ -1,88 +0,0 @@ -markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); - } - - return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'); - } - - /** - * @group DDC-671 - * - * Entities for this test are in AbstractMappingDriverTest - */ - public function testJoinTablesWithMappedSuperclassForYamlDriver() - { - $yamlDriver = $this->_loadDriver(); - $yamlDriver->getLocator()->addPaths(array(__DIR__ . DIRECTORY_SEPARATOR . 'yaml')); - - $em = $this->_getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($yamlDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); - $factory->setEntityManager($em); - - $classPage = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\File'); - $classPage = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\File'); - $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\File', $classPage->associationMappings['parentDirectory']['sourceEntity']); - - $classDirectory = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\Directory'); - $classDirectory = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\Directory'); - $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']); - } - - /** - * @group DDC-1468 - * - * @expectedException Doctrine\Common\Persistence\Mapping\MappingException - * @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'. - */ - public function testInvalidMappingFileException() - { - $this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel'); - } - - /** - * @group DDC-2069 - */ - public function testSpacesShouldBeIgnoredWhenUseExplode() - { - $metadata = $this->createClassMetadata(__NAMESPACE__.'\DDC2069Entity'); - $unique = $metadata->table['uniqueConstraints'][0]['columns']; - $indexes = $metadata->table['indexes'][0]['columns']; - - $nameField = $metadata->fieldMappings['name']; - $valueField = $metadata->fieldMappings['value']; - - $this->assertEquals('name', $unique[0]); - $this->assertEquals('value', $unique[1]); - - $this->assertEquals('value', $indexes[0]); - $this->assertEquals('name', $indexes[1]); - - $this->assertEquals(255, $nameField['length']); - $this->assertEquals(255, $valueField['length']); - } - -} - -class DDC2069Entity -{ - public $id; - - public $name; - - public $value; -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsAddress.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsAddress.php deleted file mode 100755 index 964065cbd9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsAddress.php +++ /dev/null @@ -1,69 +0,0 @@ -setPrimaryTable(array( - 'name' => 'company_person', -)); - - -$metadata->addNamedNativeQuery(array ( - 'name' => 'find-all', - 'query' => 'SELECT id, country, city FROM cms_addresses', - 'resultSetMapping' => 'mapping-find-all', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'find-by-id', - 'query' => 'SELECT * FROM cms_addresses WHERE id = ?', - 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'count', - 'query' => 'SELECT COUNT(*) AS count FROM cms_addresses', - 'resultSetMapping' => 'mapping-count', -)); - - -$metadata->addSqlResultSetMapping(array ( - 'name' => 'mapping-find-all', - 'columns' => array(), - 'entities' => array ( array ( - 'fields' => array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'city', - 'column' => 'city', - ), - array ( - 'name' => 'country', - 'column' => 'country', - ), - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress', - ), - ), -)); - -$metadata->addSqlResultSetMapping(array ( - 'name' => 'mapping-without-fields', - 'columns' => array(), - 'entities' => array(array ( - 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', - 'fields' => array() - ) - ) -)); - -$metadata->addSqlResultSetMapping(array ( - 'name' => 'mapping-count', - 'columns' =>array ( - array ( - 'name' => 'count', - ), - ) -)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsUser.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsUser.php deleted file mode 100755 index 9484bf750f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsUser.php +++ /dev/null @@ -1,186 +0,0 @@ -setPrimaryTable(array( - 'name' => 'cms_users', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'fetchIdAndUsernameWithResultClass', - 'query' => 'SELECT id, username FROM cms_users WHERE username = ?', - 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'fetchAllColumns', - 'query' => 'SELECT * FROM cms_users WHERE username = ?', - 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'fetchJoinedAddress', - 'query' => 'SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', - 'resultSetMapping' => 'mappingJoinedAddress', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'fetchJoinedPhonenumber', - 'query' => 'SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', - 'resultSetMapping' => 'mappingJoinedPhonenumber', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'fetchUserPhonenumberCount', - 'query' => 'SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username', - 'resultSetMapping' => 'mappingUserPhonenumberCount', -)); - -$metadata->addNamedNativeQuery(array ( - "name" => "fetchMultipleJoinsEntityResults", - "resultSetMapping" => "mappingMultipleJoinsEntityResults", - "query" => "SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username" -)); - -$metadata->addSqlResultSetMapping(array ( - 'name' => 'mappingJoinedAddress', - 'columns' => array(), - 'entities' => array(array ( - 'fields'=> array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'name', - 'column' => 'name', - ), - array ( - 'name' => 'status', - 'column' => 'status', - ), - array ( - 'name' => 'address.zip', - 'column' => 'zip', - ), - array ( - 'name' => 'address.city', - 'column' => 'city', - ), - array ( - 'name' => 'address.country', - 'column' => 'country', - ), - array ( - 'name' => 'address.id', - 'column' => 'a_id', - ), - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'discriminatorColumn' => null - ), - ), -)); - -$metadata->addSqlResultSetMapping(array ( - 'name' => 'mappingJoinedPhonenumber', - 'columns' => array(), - 'entities' => array(array( - 'fields'=> array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'name', - 'column' => 'name', - ), - array ( - 'name' => 'status', - 'column' => 'status', - ), - array ( - 'name' => 'phonenumbers.phonenumber', - 'column' => 'number', - ), - ), - 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', - 'discriminatorColumn' => null - ), - ), -)); - -$metadata->addSqlResultSetMapping(array ( - 'name' => 'mappingUserPhonenumberCount', - 'columns' => array(), - 'entities' => array ( - array( - 'fields' => array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'name', - 'column' => 'name', - ), - array ( - 'name' => 'status', - 'column' => 'status', - ) - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'discriminatorColumn' => null - ) - ), - 'columns' => array ( - array ( - 'name' => 'numphones', - ) - ) -)); - -$metadata->addSqlResultSetMapping(array( - 'name' => 'mappingMultipleJoinsEntityResults', - 'entities' => array(array( - 'fields' => array( - array( - 'name' => 'id', - 'column' => 'u_id', - ), - array( - 'name' => 'name', - 'column' => 'u_name', - ), - array( - 'name' => 'status', - 'column' => 'u_status', - ) - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', - 'discriminatorColumn' => null, - ), - array( - 'fields' => array( - array( - 'name' => 'id', - 'column' => 'a_id', - ), - array( - 'name' => 'zip', - 'column' => 'a_zip', - ), - array( - 'name' => 'country', - 'column' => 'a_country', - ), - ), - 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress', - 'discriminatorColumn' => null, - ), - ), - 'columns' => array(array( - 'name' => 'numphones', - ) - ) -)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyPerson.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyPerson.php deleted file mode 100755 index 68703f40a4..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyPerson.php +++ /dev/null @@ -1,39 +0,0 @@ -setPrimaryTable(array( - 'name' => 'company_person', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'fetchAllWithResultClass', - 'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name', - 'resultClass' => 'Doctrine\\Tests\\Models\\Company\\CompanyPerson', -)); - -$metadata->addNamedNativeQuery(array ( - 'name' => 'fetchAllWithSqlResultSetMapping', - 'query' => 'SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name', - 'resultSetMapping' => 'mappingFetchAll', -)); - -$metadata->addSqlResultSetMapping(array ( - 'name' => 'mappingFetchAll', - 'columns' => array(), - 'entities' => array ( array ( - 'fields' => array ( - array ( - 'name' => 'id', - 'column' => 'id', - ), - array ( - 'name' => 'name', - 'column' => 'name', - ), - ), - 'entityClass' => 'Doctrine\Tests\Models\Company\CompanyPerson', - 'discriminatorColumn' => 'discriminator', - ), - ), -)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php deleted file mode 100755 index 56a99633a8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php +++ /dev/null @@ -1,12 +0,0 @@ -mapField(array( - 'id' => true, - 'fieldName' => 'id', -)); -$metadata->mapField(array( - 'fieldName' => 'name' -)); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php deleted file mode 100755 index ad8b86d9e5..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php +++ /dev/null @@ -1,5 +0,0 @@ -mapField(array( - 'fieldName' => 'serialNumber', - 'type' => 'string', -)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php deleted file mode 100755 index 1318333a8f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php +++ /dev/null @@ -1,5 +0,0 @@ -mapField(array( - 'fieldName' => 'creditCardNumber', - 'type' => 'string', -)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php deleted file mode 100755 index 1d1f551ba3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php +++ /dev/null @@ -1,17 +0,0 @@ -mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', -)); -$metadata->mapField(array( - 'fieldName' => 'value', - 'type' => 'float', - )); -$metadata->isMappedSuperclass = true; -$metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Class.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Class.php deleted file mode 100755 index 90cfdc10bf..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Class.php +++ /dev/null @@ -1,12 +0,0 @@ -mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', -)); - -//$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Entity.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Entity.php deleted file mode 100755 index a14f3e7ea1..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Entity.php +++ /dev/null @@ -1,3 +0,0 @@ -mapField(array( - 'fieldName' => 'name', - 'type' => 'string', - )); -$metadata->isMappedSuperclass = true; -$metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC889\DDC889SuperClass"); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Admin.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Admin.php deleted file mode 100755 index bb8920e767..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Admin.php +++ /dev/null @@ -1,21 +0,0 @@ -setAssociationOverride('address',array( - 'joinColumns'=>array(array( - 'name' => 'adminaddress_id', - 'referencedColumnName' => 'id', - )) -)); - -$metadata->setAssociationOverride('groups',array( - 'joinTable' => array ( - 'name' => 'ddc964_users_admingroups', - 'joinColumns' => array(array( - 'name' => 'adminuser_id', - )), - - 'inverseJoinColumns' =>array (array ( - 'name' => 'admingroup_id', - )) - ) -)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Guest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Guest.php deleted file mode 100755 index 5094ecddf4..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Guest.php +++ /dev/null @@ -1,13 +0,0 @@ -setAttributeOverride('id', array( - 'columnName' => 'guest_id', - 'type' => 'integer', - 'length' => 140, -)); - -$metadata->setAttributeOverride('name',array( - 'columnName' => 'guest_name', - 'nullable' => false, - 'unique' => true, - 'length' => 240, -)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964User.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964User.php deleted file mode 100755 index 7b66deef0c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964User.php +++ /dev/null @@ -1,46 +0,0 @@ -mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'user_id', - 'length' => 150, -)); -$metadata->mapField(array( - 'fieldName' => 'name', - 'type' => 'string', - 'columnName'=> 'user_name', - 'nullable' => true, - 'unique' => false, - 'length' => 250, -)); - -$metadata->mapManyToOne(array( - 'fieldName' => 'address', - 'targetEntity' => 'DDC964Address', - 'cascade' => array('persist','merge'), - 'joinColumn' => array('name'=>'address_id', 'referencedColumnMame'=>'id'), -)); - -$metadata->mapManyToMany(array( - 'fieldName' => 'groups', - 'targetEntity' => 'DDC964Group', - 'inversedBy' => 'users', - 'cascade' => array('persist','merge','detach'), - 'joinTable' => array( - 'name' => 'ddc964_users_groups', - 'joinColumns' => array(array( - 'name'=>'user_id', - 'referencedColumnName'=>'id', - )), - 'inverseJoinColumns'=>array(array( - 'name'=>'group_id', - 'referencedColumnName'=>'id', - )) - ) -)); - -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Animal.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Animal.php deleted file mode 100755 index 005178eede..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Animal.php +++ /dev/null @@ -1,30 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE); -$metadata->setDiscriminatorColumn(array( - 'name' => 'dtype', - 'type' => 'string', - 'length' => 255, - 'fieldName' => 'dtype', - )); -$metadata->setDiscriminatorMap(array( - 'cat' => 'Doctrine\\Tests\\ORM\\Mapping\\Cat', - 'dog' => 'Doctrine\\Tests\\ORM\\Mapping\\Dog', - )); -$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); -$metadata->mapField(array( - 'fieldName' => 'id', - 'type' => 'string', - 'length' => NULL, - 'precision' => 0, - 'scale' => 0, - 'nullable' => false, - 'unique' => false, - 'id' => true, - 'columnName' => 'id', - )); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_CUSTOM); -$metadata->setCustomGeneratorDefinition(array("class" => "stdClass")); diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php deleted file mode 100755 index 97f4624bad..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php +++ /dev/null @@ -1,16 +0,0 @@ -mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'columnDefinition' => 'INT unsigned NOT NULL', -)); - -$metadata->mapField(array( - 'fieldName' => 'value', - 'columnDefinition' => 'VARCHAR(255) NOT NULL' -)); - -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC807Entity.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC807Entity.php deleted file mode 100755 index 1682d7a0de..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC807Entity.php +++ /dev/null @@ -1,15 +0,0 @@ -mapField(array( - 'id' => true, - 'fieldName' => 'id', -)); - -$metadata->setDiscriminatorColumn(array( - 'name' => "dtype", - 'columnDefinition' => "ENUM('ONE','TWO')" -)); - -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php deleted file mode 100755 index 815523cc12..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php +++ /dev/null @@ -1,127 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); -$metadata->setPrimaryTable(array( - 'name' => 'cms_users', - )); -$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); -$metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist'); -$metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist'); -$metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist'); -$metadata->addNamedQuery(array( - 'name' => 'all', - 'query' => 'SELECT u FROM __CLASS__ u' -)); -$metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - )); -$metadata->mapField(array( - 'fieldName' => 'name', - 'type' => 'string', - 'length' => 50, - 'unique' => true, - 'nullable' => true, - 'columnName' => 'name', - 'options' => array('foo' => 'bar', 'baz' => array('key' => 'val')), - )); -$metadata->mapField(array( - 'fieldName' => 'email', - 'type' => 'string', - 'columnName' => 'user_email', - 'columnDefinition' => 'CHAR(32) NOT NULL', - )); -$mapping = array('fieldName' => 'version', 'type' => 'integer'); -$metadata->setVersionMapping($mapping); -$metadata->mapField($mapping); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); -$metadata->mapOneToOne(array( - 'fieldName' => 'address', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Address', - 'cascade' => - array( - 0 => 'remove', - ), - 'mappedBy' => NULL, - 'inversedBy' => 'user', - 'joinColumns' => - array( - 0 => - array( - 'name' => 'address_id', - 'referencedColumnName' => 'id', - 'onDelete' => 'CASCADE', - ), - ), - 'orphanRemoval' => false, - )); -$metadata->mapOneToMany(array( - 'fieldName' => 'phonenumbers', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Phonenumber', - 'cascade' => - array( - 1 => 'persist', - ), - 'mappedBy' => 'user', - 'orphanRemoval' => true, - 'orderBy' => - array( - 'number' => 'ASC', - ), - )); -$metadata->mapManyToMany(array( - 'fieldName' => 'groups', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Group', - 'cascade' => - array( - 0 => 'remove', - 1 => 'persist', - 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', - ), - 'mappedBy' => NULL, - 'joinTable' => - array( - 'name' => 'cms_users_groups', - 'joinColumns' => - array( - 0 => - array( - 'name' => 'user_id', - 'referencedColumnName' => 'id', - 'unique' => false, - 'nullable' => false, - ), - ), - 'inverseJoinColumns' => - array( - 0 => - array( - 'name' => 'group_id', - 'referencedColumnName' => 'id', - 'columnDefinition' => 'INT NULL', - ), - ), - ), - 'orderBy' => NULL, - )); -$metadata->table['options'] = array( - 'foo' => 'bar', - 'baz' => array('key' => 'val') -); -$metadata->table['uniqueConstraints'] = array( - 'search_idx' => array('columns' => array('name', 'user_email')), -); -$metadata->table['indexes'] = array( - 'name_idx' => array('columns' => array('name')), 0 => array('columns' => array('user_email')) -); -$metadata->setSequenceGeneratorDefinition(array( - 'sequenceName' => 'tablename_seq', - 'allocationSize' => 100, - 'initialValue' => 1, - )); diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml deleted file mode 100755 index 6025d350f1..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml deleted file mode 100755 index 0af5facdaa..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - SELECT id, country, city FROM cms_addresses - - - - SELECT * FROM cms_addresses WHERE id = ? - - - - SELECT COUNT(*) AS count FROM cms_addresses - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml deleted file mode 100755 index 64a545df6b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - SELECT id, username FROM cms_users WHERE username = ? - - - - SELECT * FROM cms_users WHERE username = ? - - - - SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ? - - - - SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ? - - - - SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username - - - - SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml deleted file mode 100755 index c573504e03..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - SELECT id, name, discr FROM company_persons ORDER BY name - - - - SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml deleted file mode 100755 index c0df0886af..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml deleted file mode 100755 index 29b5f1db5c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml deleted file mode 100755 index 05e2540eff..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml deleted file mode 100755 index daf01f0340..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml deleted file mode 100755 index be9f760b95..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml deleted file mode 100755 index 4a8935c9a7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.xml deleted file mode 100755 index 686bdbfc76..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.xml deleted file mode 100755 index 48fa4fb83f..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.xml deleted file mode 100755 index f4bb4ebce0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.xml deleted file mode 100755 index 561066f6b8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml deleted file mode 100755 index 68db74b48e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml deleted file mode 100755 index 36af855f2a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml deleted file mode 100755 index 3f67a6b825..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml deleted file mode 100755 index 14abaef734..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml deleted file mode 100755 index 9f5ad7fac6..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.xml deleted file mode 100755 index 3dc9135c5d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml deleted file mode 100755 index f2ef7d8141..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml deleted file mode 100755 index 604acb293a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml +++ /dev/null @@ -1,62 +0,0 @@ -Doctrine\Tests\Models\CMS\CmsAddress: - type: entity - table: cms_address - namedNativeQueries: - find-all: - resultSetMapping: mapping-find-all - query: SELECT id, country, city FROM cms_addresses - find-by-id: - name: find-by-id - resultClass: CmsAddress - query: SELECT * FROM cms_addresses WHERE id = ? - count: - name: count - resultSetMapping: mapping-count - query: SELECT COUNT(*) AS count FROM cms_addresses - - sqlResultSetMappings: - mapping-find-all: - entityResult: - address: - entityClass: CmsAddress - fieldResult: - 0: - name: id - column: id - 1: - name: city - column: city - 2: - name: country - column: country - mapping-without-fields: - name: mapping-without-fields - entityResult: - address: - entityClass: CmsAddress - mapping-count: - name: mapping-count - columnResult: - count: - name: count - id: - id: - type: integer - generator: - strategy: AUTO - fields: - country: - type: string - length: 50 - city: - type: string - length: 50 - zip: - type: string - length: 50 - oneToOne: - address: - targetEntity: CmsUser - inversedBy: address - joinColumn: - referencedColumnName: id \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsUser.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsUser.dcm.yml deleted file mode 100755 index 3a03dd6c32..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsUser.dcm.yml +++ /dev/null @@ -1,158 +0,0 @@ -Doctrine\Tests\Models\CMS\CmsUser: - type: entity - table: cms_users - namedQueries: - all: SELECT u FROM __CLASS__ u - namedNativeQueries: - fetchIdAndUsernameWithResultClass: - resultClass: CmsUser - query: SELECT id, username FROM cms_users WHERE username = ? - fetchAllColumns: - name: fetchAllColumns - resultClass: CmsUser - query: SELECT * FROM cms_users WHERE username = ? - fetchJoinedAddress: - name: fetchJoinedAddress - resultSetMapping: mappingJoinedAddress - query: SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ? - fetchJoinedPhonenumber: - name: fetchJoinedPhonenumber - resultSetMapping: mappingJoinedPhonenumber - query: SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ? - fetchUserPhonenumberCount: - name: fetchUserPhonenumberCount - resultSetMapping: mappingUserPhonenumberCount - query: SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username - fetchMultipleJoinsEntityResults: - name: fetchMultipleJoinsEntityResults - resultSetMapping: mappingMultipleJoinsEntityResults - query: SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username - - sqlResultSetMappings: - mappingJoinedAddress: - entityResult: - 0: - entityClass: __CLASS__ - fieldResult: - 0: - name: id - 1: - name: name - 2: - name: status - 3: - name: address.zip - 4: - name: address.city - 5: - name: address.country - 6: - name: address.id - column: a_id - mappingJoinedPhonenumber: - name: mappingJoinedPhonenumber - entityResult: - user: - entityClass: CmsUser - fieldResult: - 0: - name: id - 1: - name: name - 2: - name: status - 3: - name: phonenumbers.phonenumber - column: number - mappingUserPhonenumberCount: - name: mappingUserPhonenumberCount - columnResult: - 0: - name: numphones - entityResult: - user_0: - entityClass: CmsUser - fieldResult: - 0: - name: id - 1: - name: name - 2: - name: status - mappingMultipleJoinsEntityResults: - name: mappingMultipleJoinsEntityResults - columnResult: - 0: - name: numphones - entityResult: - 0: - entityClass: __CLASS__ - fieldResult: - 0: - name: id - column: u_id - 1: - name: name - column: u_name - 2: - name: status - column: u_status - 1: - entityClass: CmsAddress - fieldResult: - 0: - name: id - column: a_id - 1: - name: zip - column: a_zip - 2: - name: country - column: a_country - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 255 - username: - type: string - length: 255 - unique: true - status: - type: string - length: 50 - unique: true - oneToOne: - address: - targetEntity: CmsAddress - orphanRemoval: true - inversedBy: user - joinColumn: - name: address_id - referencedColumnName: id - cascade: [ persist ] - oneToOne: - email: - targetEntity: CmsEmail - orphanRemoval: true - inversedBy: user - joinColumn: - nullable: true - referencedColumnName: id - cascade: [ persist ] - manyToMany: - groups: - targetEntity: CmsGroup - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - cascade: [ persist , detach, merge] \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.yml deleted file mode 100755 index 26846c5deb..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.yml +++ /dev/null @@ -1,75 +0,0 @@ -Doctrine\Tests\Models\Company\CompanyPerson: - type: entity - table: company_persons - inheritanceType: JOINED - discriminatorMap: - person: CompanyPerson - manager: CompanyManager - employee: CompanyEmployee - namedNativeQueries: - fetchAllWithResultClass: - resultClass: __CLASS__ - query: SELECT id, name, discr FROM company_persons ORDER BY name - fetchAllWithSqlResultSetMapping: - name: fetchAllWithSqlResultSetMapping - resultSetMapping: mappingFetchAll - query: SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name - - sqlResultSetMappings: - mappingFetchAll: - entityResult: - 0: - entityClass: __CLASS__ - discriminatorColumn: discriminator - fieldResult: - 0: - name: id - 1: - name: name - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 255 - username: - type: string - length: 255 - unique: true - status: - type: string - length: 50 - unique: true - oneToOne: - address: - targetEntity: CmsAddress - orphanRemoval: true - inversedBy: user - joinColumn: - name: address_id - referencedColumnName: id - cascade: [ persist ] - oneToOne: - email: - targetEntity: CmsEmail - orphanRemoval: true - inversedBy: user - joinColumn: - nullable: true - referencedColumnName: id - cascade: [ persist ] - manyToMany: - groups: - targetEntity: CmsGroup - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - cascade: [ persist , detach, merge] \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml deleted file mode 100755 index 674328cd52..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml +++ /dev/null @@ -1,8 +0,0 @@ -Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType: - type: entity - id: - id: - generator: - strategy: NONE - fields: - name: ~ diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml deleted file mode 100755 index 94f2698175..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\DDC869\DDC869ChequePayment: - type: entity - fields: - serialNumber: - type: string \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml deleted file mode 100755 index 153a99fa7e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment: - type: entity - fields: - creditCardNumber: - type: string \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml deleted file mode 100755 index b776664e1d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml +++ /dev/null @@ -1,12 +0,0 @@ -Doctrine\Tests\Models\DDC869\DDC869Payment: - type: mappedSuperclass - repositoryClass : Doctrine\Tests\Models\DDC869\DDC869PaymentRepository - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO - fields: - value: - type: float \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.yml deleted file mode 100755 index 567e5d585c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.yml +++ /dev/null @@ -1,8 +0,0 @@ -Doctrine\Tests\Models\DDC889\DDC889Class: - type: class - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.yml deleted file mode 100755 index aa932db214..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.yml +++ /dev/null @@ -1,2 +0,0 @@ -Doctrine\Tests\Models\DDC889\DDC889Entity: - type: entity \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.yml deleted file mode 100755 index 7974d552d0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\DDC889\DDC889SuperClass: - type: mappedSuperclass - fields: - name: - type: string \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.yml deleted file mode 100755 index 0b8051d964..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.yml +++ /dev/null @@ -1,17 +0,0 @@ -Doctrine\Tests\Models\DDC964\DDC964Admin: - type: entity - associationOverride: - address: - joinColumn: - adminaddress_id: - name: adminaddress_id - referencedColumnName: id - groups: - joinTable: - name: ddc964_users_admingroups - joinColumns: - adminuser_id: - referencedColumnName: id - inverseJoinColumns: - admingroup_id: - referencedColumnName: id \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.yml deleted file mode 100755 index ec7936f4a7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.yml +++ /dev/null @@ -1,13 +0,0 @@ -Doctrine\Tests\Models\DDC964\DDC964Guest: - type: entity - attributeOverride: - id: - column: guest_id - type: integer - length: 140 - name: - column: guest_name - type: string - length: 240 - nullable: false - unique: true \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.yml deleted file mode 100755 index 3a9ebbf9d7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.yml +++ /dev/null @@ -1,35 +0,0 @@ -Doctrine\Tests\Models\DDC964\DDC964User: - type: mappedSuperclass - id: - id: - type: integer - column: user_id - length: 150 - generator: - strategy: AUTO - fields: - name: - type: string - column: user_name - length: 250 - nullable: true - unique: false - manyToOne: - address: - targetEntity: DDC964Address - joinColumn: - name: address_id - referencedColumnName: id - cascade: [ persist, merge ] - manyToMany: - groups: - targetEntity: DDC964Group - joinTable: - name: ddc964_users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - cascade: [ persist, merge, detach ] \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml deleted file mode 100755 index 9c573a561d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml +++ /dev/null @@ -1,14 +0,0 @@ -Doctrine\Tests\Models\DirectoryTree\AbstractContentItem: - type: mappedSuperclass - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO - fields: - name: - type: string - manyToOne: - parentDirectory: - targetEntity: Doctrine\Tests\Models\DirectoryTree\Directory diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml deleted file mode 100755 index d2b93d4901..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml +++ /dev/null @@ -1,6 +0,0 @@ -Doctrine\Tests\Models\DirectoryTree\Directory: - type: entity - fields: - path: - type: string - length: 255 diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml deleted file mode 100755 index cbc8edfec4..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml +++ /dev/null @@ -1,6 +0,0 @@ -Doctrine\Tests\Models\DirectoryTree\File: - type: entity - fields: - extension: - type: string - length: 10 diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml deleted file mode 100755 index 64f74b55f9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml +++ /dev/null @@ -1,13 +0,0 @@ -\stdClass: - type: entity - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO - fields: - array: - type: array - object: - type: object \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml deleted file mode 100755 index 7bdad82403..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml +++ /dev/null @@ -1,17 +0,0 @@ -Doctrine\Tests\ORM\Mapping\Animal: - type: entity - inheritanceType: SINGLE_TABLE - discriminatorMap: - cat: Cat - dog: Dog - discriminatorColumn: - type: string - name: discr - length: 32 - id: - id: - type: integer - generator: - strategy: CUSTOM - customIdGenerator: - class: stdClass diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml deleted file mode 100755 index 8b2ac518bc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml +++ /dev/null @@ -1,10 +0,0 @@ -Doctrine\Tests\ORM\Mapping\DDC1170Entity: - type: entity - id: - id: - columnDefinition: INT unsigned NOT NULL - generator: - strategy: NONE - fields: - value: - columnDefinition: VARCHAR(255) NOT NULL \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC2069Entity.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC2069Entity.dcm.yml deleted file mode 100755 index 5b16c12bc9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC2069Entity.dcm.yml +++ /dev/null @@ -1,15 +0,0 @@ -Doctrine\Tests\ORM\Mapping\DDC2069Entity: - type: entity - id: - id: ~ - fields: - name: - type: string ( 255 ) - value: - type: string ( 255 ) - uniqueConstraints: - 0: - columns: name, value - indexes: - 0: - columns: value, name diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.yml deleted file mode 100755 index 20db3c328e..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.yml +++ /dev/null @@ -1,13 +0,0 @@ -Doctrine\Tests\ORM\Mapping\DDC807Entity: - type: entity - inheritanceType: SINGLE_TABLE - discriminatorMap: - ONE: DDC807SubClasse1 - TWO: DDC807SubClasse2 - discriminatorColumn: - name: dtype - columnDefinition: ENUM('ONE','TWO') - id: - id: - generator: - strategy: NONE \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml deleted file mode 100755 index 3655db20ff..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml +++ /dev/null @@ -1,79 +0,0 @@ -Doctrine\Tests\ORM\Mapping\User: - type: entity - table: cms_users - options: - foo: bar - baz: - key: val - namedQueries: - all: SELECT u FROM __CLASS__ u - id: - id: - type: integer - generator: - strategy: AUTO - sequenceGenerator: - sequenceName: tablename_seq - allocationSize: 100 - initialValue: 1 - fields: - name: - type: string - length: 50 - nullable: true - unique: true - options: - foo: bar - baz: - key: val - email: - type: string - column: user_email - columnDefinition: CHAR(32) NOT NULL - version: - type: integer - version: true - oneToOne: - address: - targetEntity: Address - inversedBy: user - joinColumn: - name: address_id - referencedColumnName: id - onDelete: CASCADE - cascade: [ remove ] - oneToMany: - phonenumbers: - targetEntity: Phonenumber - orphanRemoval: true - mappedBy: user - orderBy: - number: ASC - cascade: [ persist ] - manyToMany: - groups: - targetEntity: Group - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - nullable: false - unique: false - inverseJoinColumns: - group_id: - referencedColumnName: id - columnDefinition: INT NULL - cascade: - - all - lifecycleCallbacks: - prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] - postPersist: [ doStuffOnPostPersist ] - uniqueConstraints: - search_idx: - columns: name,user_email - indexes: - name_idx: - columns: name - 0: - columns: user_email diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php deleted file mode 100755 index 07a202e4ab..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php +++ /dev/null @@ -1,461 +0,0 @@ - 0.7 seconds] - * - * MAXIMUM TIME: 1 second - */ - public function testSimpleQueryScalarHydrationPerformance10000Rows() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('u', 'u__username', 'username'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ) - ); - - for ($i = 4; $i < 10000; ++$i) { - $resultSet[] = array( - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - ); - } - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); - - $this->setMaxRunningTime(1); - $s = microtime(true); - $result = $hydrator->hydrateAll($stmt, $rsm); - $e = microtime(true); - echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; - } - - /** - * Times for comparison: - * - * [romanb: 10000 rows => 1 second] - * - * MAXIMUM TIME: 2 seconds - */ - public function testSimpleQueryArrayHydrationPerformance10000Rows() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('u', 'u__username', 'username'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ) - ); - - for ($i = 4; $i < 10000; ++$i) { - $resultSet[] = array( - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - ); - } - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - - $this->setMaxRunningTime(2); - $s = microtime(true); - $result = $hydrator->hydrateAll($stmt, $rsm); - $e = microtime(true); - echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; - } - - /** - * Times for comparison: - * - * [romanb: 10000 rows => 1.4 seconds] - * - * MAXIMUM TIME: 3 seconds - */ - public function testMixedQueryFetchJoinArrayHydrationPerformance10000Rows() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('u', 'u__username', 'username'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91' - ) - ); - - for ($i = 4; $i < 10000; ++$i) { - $resultSet[] = array( - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - 'sclr0' => 'JWAGE' . $i, - 'p__phonenumber' => '91' - ); - } - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); - - $this->setMaxRunningTime(3); - $s = microtime(true); - $result = $hydrator->hydrateAll($stmt, $rsm); - $e = microtime(true); - echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; - } - - /** - * [romanb: 10000 rows => 1.5 seconds] - * - * MAXIMUM TIME: 3 seconds - */ - public function testSimpleQueryPartialObjectHydrationPerformance10000Rows() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('u', 'u__username', 'username'); - $rsm->addFieldResult('u', 'u__name', 'name'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ) - ); - - for ($i = 4; $i < 10000; ++$i) { - $resultSet[] = array( - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - ); - } - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - - $this->setMaxRunningTime(3); - $s = microtime(true); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - $e = microtime(true); - echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; - } - - /** - * [romanb: 10000 rows => 3 seconds] - * - * MAXIMUM TIME: 4.5 seconds - */ - public function testSimpleQueryFullObjectHydrationPerformance10000Rows() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('u', 'u__username', 'username'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsAddress', - 'a', - 'u', - 'address' - ); - $rsm->addFieldResult('a', 'a__id', 'id'); - //$rsm->addFieldResult('a', 'a__country', 'country'); - //$rsm->addFieldResult('a', 'a__zip', 'zip'); - //$rsm->addFieldResult('a', 'a__city', 'city'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'a__id' => '1' - ) - ); - - for ($i = 2; $i < 10000; ++$i) { - $resultSet[] = array( - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - 'a__id' => $i - ); - } - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - - $this->setMaxRunningTime(5); - $s = microtime(true); - $result = $hydrator->hydrateAll($stmt, $rsm); - $e = microtime(true); - echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; - } - - /** - * [romanb: 2000 rows => 0.4 seconds] - * - * MAXIMUM TIME: 1 second - */ - public function testMixedQueryFetchJoinPartialObjectHydrationPerformance2000Rows() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('u', 'u__username', 'username'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - ), - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - ), - array( - 'u__id' => '2', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91' - ) - ); - - for ($i = 4; $i < 2000; ++$i) { - $resultSet[] = array( - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - 'sclr0' => 'JWAGE' . $i, - 'p__phonenumber' => '91' - ); - } - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - - $this->setMaxRunningTime(1); - $s = microtime(true); - $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); - $e = microtime(true); - echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; - } - - /** - * [romanb: 2000 rows => 0.6 seconds] - * - * MAXIMUM TIME: 1 second - */ - public function testMixedQueryFetchJoinFullObjectHydrationPerformance2000Rows() - { - $rsm = new ResultSetMapping; - $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'p', - 'u', - 'phonenumbers' - ); - $rsm->addFieldResult('u', 'u__id', 'id'); - $rsm->addFieldResult('u', 'u__status', 'status'); - $rsm->addFieldResult('u', 'u__username', 'username'); - $rsm->addFieldResult('u', 'u__name', 'name'); - $rsm->addScalarResult('sclr0', 'nameUpper'); - $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - $rsm->addJoinedEntityResult( - 'Doctrine\Tests\Models\CMS\CmsAddress', - 'a', - 'u', - 'address' - ); - $rsm->addFieldResult('a', 'a__id', 'id'); - - // Faked result set - $resultSet = array( - //row1 - array( - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - 'a__id' => '1' - ) - ); - - for ($i = 2; $i < 2000; ++$i) { - $resultSet[] = array( - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - 'sclr0' => 'JWAGE' . $i, - 'p__phonenumber' => '91', - 'a__id' => $i - ); - } - - $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); - - $this->setMaxRunningTime(1); - $s = microtime(true); - $result = $hydrator->hydrateAll($stmt, $rsm); - $e = microtime(true); - echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php deleted file mode 100755 index 1c192648af..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php +++ /dev/null @@ -1,66 +0,0 @@ -useModelSet('company'); - parent::setUp(); - } - - public function testCompanyContract() - { - $person = new \Doctrine\Tests\Models\Company\CompanyEmployee(); - $person->setName('Poor Sales Guy'); - $person->setDepartment('Sales'); - $person->setSalary(100); - $this->_em->persist($person); - - for ($i = 0; $i < 33; $i++) { - $fix = new \Doctrine\Tests\Models\Company\CompanyFixContract(); - $fix->setFixPrice(1000); - $fix->setSalesPerson($person); - $fix->markCompleted(); - $this->_em->persist($fix); - - $flex = new \Doctrine\Tests\Models\Company\CompanyFlexContract(); - $flex->setSalesPerson($person); - $flex->setHoursWorked(100); - $flex->setPricePerHour(100); - $flex->markCompleted(); - $this->_em->persist($flex); - - $ultra = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); - $ultra->setSalesPerson($person); - $ultra->setHoursWorked(150); - $ultra->setPricePerHour(150); - $ultra->setMaxPrice(7000); - $this->_em->persist($ultra); - } - - $this->_em->flush(); - $this->_em->clear(); - - $start = microtime(true); - $contracts = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyContract')->findAll(); - echo "99 CompanyContract: " . number_format(microtime(true) - $start, 6) . "\n"; - $this->assertEquals(99, count($contracts)); - - $this->_em->clear(); - - $start = microtime(true); - $contracts = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyContract')->findAll(); - echo "99 CompanyContract: " . number_format(microtime(true) - $start, 6) . "\n"; - $this->assertEquals(99, count($contracts)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php deleted file mode 100755 index 1c378df6dd..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php +++ /dev/null @@ -1,56 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - /** - * [romanb: 10000 objects in ~8 seconds] - */ - public function testInsertPerformance() - { - $s = microtime(true); - - $conn = $this->_em->getConnection(); - - $this->setMaxRunningTime(10); - - //echo "Memory usage before: " . (memory_get_usage() / 1024) . " KB" . PHP_EOL; - - $batchSize = 20; - for ($i=1; $i<=10000; ++$i) { - $user = new CmsUser; - $user->status = 'user'; - $user->username = 'user' . $i; - $user->name = 'Mr.Smith-' . $i; - $this->_em->persist($user); - if (($i % $batchSize) == 0) { - $this->_em->flush(); - $this->_em->clear(); - } - } - - //gc_collect_cycles(); - //echo "Memory usage after: " . (memory_get_usage() / 1024) . " KB" . PHP_EOL; - - $e = microtime(true); - - echo ' Inserted 10000 objects in ' . ($e - $s) . ' seconds' . PHP_EOL; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php deleted file mode 100755 index ec432689d6..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php +++ /dev/null @@ -1,121 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testFindCmsArticle() - { - $author = new CmsUser(); - $author->name = "beberlei"; - $author->status = "active"; - $author->username = "beberlei"; - $this->_em->persist($author); - - $ids = array(); - for ($i = 0; $i < 100; $i++) { - $article = new CmsArticle(); - $article->text = "foo"; - $article->topic = "bar"; - $article->user = $author; - $this->_em->persist($article); - $ids[] = $article; - } - $this->_em->flush(); - $this->_em->clear(); - - $start = microtime(true); - $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle')->findAll(); - echo "100 CmsArticle findAll(): " . number_format(microtime(true) - $start, 6) . "\n"; - - $this->_em->clear(); - - $start = microtime(true); - $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle')->findAll(); - echo "100 CmsArticle findAll(): " . number_format(microtime(true) - $start, 6) . "\n"; - - $this->_em->clear(); - - $start = microtime(true); - for ($i = 0; $i < 100; $i++) { - $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle')->find($ids[$i]->id); - } - echo "100 CmsArticle find(): " . number_format(microtime(true) - $start, 6) . "\n"; - - $this->_em->clear(); - - $start = microtime(true); - for ($i = 0; $i < 100; $i++) { - $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle')->find($ids[$i]->id); - } - echo "100 CmsArticle find(): " . number_format(microtime(true) - $start, 6) . "\n"; - } - - public function testFindCmsGroup() - { - for ($i = 0; $i < 100; $i++) { - $group = new CmsGroup(); - $group->name = "foo" . $i; - $this->_em->persist($group); - } - $this->_em->flush(); - $this->_em->clear(); - - $start = microtime(true); - $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll(); - echo "100 CmsGroup: " . number_format(microtime(true) - $start, 6) . "\n"; - - $this->_em->clear(); - - $start = microtime(true); - $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll(); - echo "100 CmsGroup: " . number_format(microtime(true) - $start, 6) . "\n"; - } - - public function testFindCmsUser() - { - for ($i = 0; $i < 100; $i++) { - $user = new CmsUser(); - $user->name = "beberlei"; - $user->status = "active"; - $user->username = "beberlei".$i; - $this->_em->persist($user); - } - - $this->_em->flush(); - $this->_em->clear(); - - $start = microtime(true); - $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); - echo "100 CmsUser: " . number_format(microtime(true) - $start, 6) . "\n"; - - $this->_em->clear(); - - $start = microtime(true); - $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); - echo "100 CmsUser: " . number_format(microtime(true) - $start, 6) . "\n"; - } -} - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php deleted file mode 100755 index 9320828134..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php +++ /dev/null @@ -1,51 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testComputeChanges() - { - $n = 100; - - $users = array(); - for ($i=1; $i<=$n; ++$i) { - $user = new CmsUser; - $user->status = 'user'; - $user->username = 'user' . $i; - $user->name = 'Mr.Smith-' . $i; - $this->_em->persist($user); - $users[] = $user; - } - $this->_em->flush(); - - - foreach ($users AS $user) { - $user->status = 'other'; - $user->username = $user->username . '++'; - $user->name = str_replace('Mr.', 'Mrs.', $user->name); - } - - $s = microtime(true); - $this->_em->flush(); - $e = microtime(true); - - echo ' Compute ChangeSet '.$n.' objects in ' . ($e - $s) . ' seconds' . PHP_EOL; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php deleted file mode 100755 index fd0dffbf29..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -class PersistentCollectionTest extends \Doctrine\Tests\OrmTestCase -{ - private $_connectionMock; - private $_emMock; - - protected function setUp() - { - parent::setUp(); - // SUT - $this->_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock()); - $this->_emMock = EntityManagerMock::create($this->_connectionMock); - } - - public function testCanBePutInLazyLoadingMode() - { - $class = $this->_emMock->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); - $collection = new PersistentCollection($this->_emMock, $class, new ArrayCollection); - $collection->setInitialized(false); - $this->assertFalse($collection->isInitialized()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php deleted file mode 100755 index 9f00090aa3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ /dev/null @@ -1,101 +0,0 @@ -_em = $this->_getTestEntityManager(); - - $this->_persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata("Doctrine\Tests\Models\CustomType\CustomTypeParent")); - } - - public function testGetInsertSQLUsesTypeValuesSQL() - { - $method = new \ReflectionMethod($this->_persister, '_getInsertSQL'); - $method->setAccessible(true); - - $sql = $method->invoke($this->_persister); - - $this->assertEquals('INSERT INTO customtype_parents (customInteger, child_id) VALUES (ABS(?), ?)', $sql); - } - - public function testUpdateUsesTypeValuesSQL() - { - $child = new CustomTypeChild(); - - $parent = new CustomTypeParent(); - $parent->customInteger = 1; - $parent->child = $child; - - $this->_em->getUnitOfWork()->registerManaged($parent, array('id' => 1), array('customInteger' => 0, 'child' => null)); - $this->_em->getUnitOfWork()->registerManaged($child, array('id' => 1), array()); - - $this->_em->getUnitOfWork()->propertyChanged($parent, 'customInteger', 0, 1); - $this->_em->getUnitOfWork()->propertyChanged($parent, 'child', null, $child); - - $this->_persister->update($parent); - - $executeUpdates = $this->_em->getConnection()->getExecuteUpdates(); - - $this->assertEquals('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?', $executeUpdates[0]['query']); - } - - public function testGetSelectConditionSQLUsesTypeValuesSQL() - { - $method = new \ReflectionMethod($this->_persister, '_getSelectConditionSQL'); - $method->setAccessible(true); - - $sql = $method->invoke($this->_persister, array('customInteger' => 1, 'child' => 1)); - - $this->assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); - } - - /** - * @group DDC-1719 - */ - public function testStripNonAlphanumericCharactersFromSelectColumnListSQL() - { - $persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\SimpleEntity')); - $method = new \ReflectionMethod($persister, '_getSelectColumnListSQL'); - $method->setAccessible(true); - - $this->assertEquals('t0."simple-entity-id" AS simpleentityid1, t0."simple-entity-value" AS simpleentityvalue2', $method->invoke($persister)); - } - - /** - * @group DDC-2073 - */ - public function testSelectConditionStatementIsNull() - { - $statement = $this->_persister->getSelectConditionStatementSQL('test', null, array(), Comparison::IS); - $this->assertEquals('test IS ?', $statement); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php deleted file mode 100755 index 894d500fe3..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php +++ /dev/null @@ -1,204 +0,0 @@ - - */ -class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase -{ - private $_connectionMock; - private $_uowMock; - private $_emMock; - - /** - * @var \Doctrine\ORM\Proxy\ProxyFactory - */ - private $_proxyFactory; - - protected function setUp() - { - parent::setUp(); - $this->_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock()); - $this->_emMock = EntityManagerMock::create($this->_connectionMock); - $this->_uowMock = new UnitOfWorkMock($this->_emMock); - $this->_emMock->setUnitOfWork($this->_uowMock); - // SUT - $this->_proxyFactory = new ProxyFactory($this->_emMock, __DIR__ . '/generated', 'Proxies', true); - } - - protected function tearDown() - { - foreach (new \DirectoryIterator(__DIR__ . '/generated') as $file) { - if (strstr($file->getFilename(), '.php')) { - unlink($file->getPathname()); - } - } - } - - public function testReferenceProxyDelegatesLoadingToThePersister() - { - $identifier = array('id' => 42); - $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; - $persister = $this->_getMockPersister(); - $this->_uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); - - $proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $identifier); - - $persister->expects($this->atLeastOnce()) - ->method('load') - ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) - ->will($this->returnValue(new \stdClass())); // fake return of entity instance - - $proxy->getDescription(); - } - - public function testReferenceProxyExecutesLoadingOnlyOnce() - { - $identifier = array('id' => 42); - $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; - $persister = $this->_getMockPersister(); - $this->_uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); - $proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $identifier); - - $persister->expects($this->atLeastOnce()) - ->method('load') - ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) - ->will($this->returnValue(new \stdClass())); // fake return of entity instance - $proxy->getDescription(); - $proxy->getProduct(); - } - - public function testReferenceProxyRespectsMethodsParametersTypeHinting() - { - $proxyClass = 'Proxies\DoctrineTestsModelsECommerceECommerceFeatureProxy'; - $persister = $this->_getMockPersister(); - $this->_uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); - $proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', null); - - $method = new \ReflectionMethod(get_class($proxy), 'setProduct'); - $params = $method->getParameters(); - - $this->assertEquals(1, count($params)); - $this->assertEquals('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $params[0]->getClass()->getName()); - } - - /** - * Test that the proxy behaves in regard to methods like &foo() correctly - */ - public function testProxyRespectsMethodsWhichReturnValuesByReference() { - $proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\Forum\ForumEntry', null); - $method = new \ReflectionMethod(get_class($proxy), 'getTopicByReference'); - - $this->assertTrue($method->returnsReference()); - } - - public function testCreatesAssociationProxyAsSubclassOfTheOriginalOne() - { - $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; - $this->assertTrue(is_subclass_of($proxyClass, 'Doctrine\Tests\Models\ECommerce\ECommerceFeature')); - } - - - public function testAllowsConcurrentCreationOfBothProxyTypes() - { - $referenceProxyClass = 'Proxies\DoctrineTestsModelsECommerceECommerceFeatureProxy'; - $associationProxyClass = 'Proxies\DoctrineTestsModelsECommerceECommerceFeatureAProxy'; - $this->assertNotEquals($referenceProxyClass, $associationProxyClass); - } - - public function testNonNamespacedProxyGeneration() - { - require_once dirname(__FILE__)."/fixtures/NonNamespacedProxies.php"; - - $className = "\DoctrineOrmTestEntity"; - $proxyName = "DoctrineOrmTestEntity"; - $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); - $classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $classMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer')); - $classMetadata->setIdentifier(array('id')); - - $this->_proxyFactory->generateProxyClasses(array($classMetadata)); - - $classCode = file_get_contents(dirname(__FILE__)."/generated/__CG__".$proxyName.".php"); - - $this->assertNotContains("class DoctrineOrmTestEntity extends \\\\DoctrineOrmTestEntity", $classCode); - $this->assertContains("class DoctrineOrmTestEntity extends \\DoctrineOrmTestEntity", $classCode); - } - - public function testClassWithSleepProxyGeneration() - { - $className = "\Doctrine\Tests\ORM\Proxy\SleepClass"; - $proxyName = "DoctrineTestsORMProxySleepClass"; - $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); - $classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $classMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer')); - $classMetadata->setIdentifier(array('id')); - - $this->_proxyFactory->generateProxyClasses(array($classMetadata)); - - $classCode = file_get_contents(dirname(__FILE__)."/generated/__CG__".$proxyName.".php"); - - $this->assertEquals(1, substr_count($classCode, 'function __sleep')); - } - - /** - * @group DDC-1771 - */ - public function testSkipAbstractClassesOnGeneration() - { - $cm = new \Doctrine\ORM\Mapping\ClassMetadata(__NAMESPACE__ . '\\AbstractClass'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $this->assertNotNull($cm->reflClass); - - $num = $this->_proxyFactory->generateProxyClasses(array($cm)); - - $this->assertEquals(0, $num, "No proxies generated."); - } - - public function testNoConfigDir_ThrowsException() - { - $this->setExpectedException('Doctrine\ORM\Proxy\ProxyException'); - new ProxyFactory($this->_getTestEntityManager(), null, null); - } - - public function testNoNamespace_ThrowsException() - { - $this->setExpectedException('Doctrine\ORM\Proxy\ProxyException'); - new ProxyFactory($this->_getTestEntityManager(), __DIR__ . '/generated', null); - } - - protected function _getMockPersister() - { - $persister = $this->getMock('Doctrine\ORM\Persisters\BasicEntityPersister', array('load'), array(), '', false); - return $persister; - } -} - -class SleepClass -{ - public $id; - - public function __sleep() - { - return array('id'); - } -} - -abstract class AbstractClass -{ - -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php deleted file mode 100755 index 88c06e4490..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php +++ /dev/null @@ -1,13 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Query; - -require_once __DIR__ . '/../../TestInit.php'; - -/** - * Test case for testing the saving and referencing of query identifiers. - * - * @author Guilherme Blanco - * @author Janne Vanhala - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link http://www.phpdoctrine.org - * @since 2.0 - * @version $Revision$ - * @todo 1) [romanb] We might want to split the SQL generation tests into multiple - * testcases later since we'll have a lot of them and we might want to have special SQL - * generation tests for some dbms specific SQL syntaxes. - */ -class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase -{ - private $_em; - - protected function setUp() { - $this->_em = $this->_getTestEntityManager(); - } - - public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed) - { - try { - $query = $this->_em->createQuery($dqlToBeTested); - parent::assertEquals($sqlToBeConfirmed, $query->getSql()); - $query->free(); - } catch (\Exception $e) { - $this->fail($e->getMessage()); - } - } - - public function testSupportsDeleteWithoutWhereAndFrom() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u', - 'DELETE FROM cms_users' - ); - } - - public function testSupportsDeleteWithoutWhere() - { - $this->assertSqlGeneration( - 'DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'DELETE FROM cms_users' - ); - } - - public function testSupportsWhereClause() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', - 'DELETE FROM cms_users WHERE id = ?' - ); - } - - public function testSupportsWhereOrExpressions() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 OR u.name = ?2', - 'DELETE FROM cms_users WHERE username = ? OR name = ?' - ); - } - - public function testSupportsWhereNestedConditionalExpressions() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR ( u.username = ?2 OR u.name = ?3)', - 'DELETE FROM cms_users WHERE id = ? OR (username = ? OR name = ?)' - ); - - //$this->assertSqlGeneration( - // 'DELETE FROM Doctrine\Tests\Models\CMS\CmsUser WHERE id = ?1', - // 'DELETE FROM cms_users WHERE id = ?' - //); - } - - public function testIsCaseAgnostic() - { - $this->assertSqlGeneration( - "delete from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1", - "DELETE FROM cms_users WHERE username = ?" - ); - } - - public function testSupportsAndCondition() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 AND u.name = ?2", - "DELETE FROM cms_users WHERE username = ? AND name = ?" - ); - } - - public function testSupportsWhereNot() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT u.id != ?1", - "DELETE FROM cms_users WHERE NOT id <> ?" - ); - } - - public function testSupportsWhereNotWithParentheses() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 )", - "DELETE FROM cms_users WHERE NOT (id <> ?)" - ); - } - - public function testSupportsWhereNotWithAndExpression() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 AND u.username = ?2 )", - "DELETE FROM cms_users WHERE NOT (id <> ? AND username = ?)" - ); - } - - // ConditionalPrimary was already tested (see testSupportsWhereClause() and testSupportsWhereNot()) - - public function testSupportsGreaterThanComparisonClause() - { - // id = ? was already tested (see testDeleteWithWhere()) - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ?1", - "DELETE FROM cms_users WHERE id > ?" - ); - } - - public function testSupportsGreaterThanOrEqualToComparisonClause() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id >= ?1", - "DELETE FROM cms_users WHERE id >= ?" - ); - } - - public function testSupportsLessThanComparisonClause() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id < ?1", - "DELETE FROM cms_users WHERE id < ?" - ); - } - - public function testSupportsLessThanOrEqualToComparisonClause() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <= ?1", - "DELETE FROM cms_users WHERE id <= ?" - ); - } - - public function testSupportsNotEqualToComparisonClause() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <> ?1", - "DELETE FROM cms_users WHERE id <> ?" - ); - } - - public function testSupportsNotEqualToComparisonClauseExpressedWithExclamationMark() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id != ?1", - "DELETE FROM cms_users WHERE id <> ?" - ); - } - - public function testSupportsNotBetweenClause() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT BETWEEN ?1 AND ?2", - "DELETE FROM cms_users WHERE id NOT BETWEEN ? AND ?" - ); - } - - public function testSupportsBetweenClauseUsedWithAndClause() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2 AND u.username != ?3", - "DELETE FROM cms_users WHERE id BETWEEN ? AND ? AND username <> ?" - ); - } - - public function testSupportsNotLikeClause() - { - // "WHERE" Expression LikeExpression - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username NOT LIKE ?1', - 'DELETE FROM cms_users WHERE username NOT LIKE ?' - ); - } - - public function testSupportsLikeClauseWithEscapeExpression() - { - $this->assertSqlGeneration( - "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username LIKE ?1 ESCAPE '\\'", - "DELETE FROM cms_users WHERE username LIKE ? ESCAPE '\\'" - ); - } - - public function testSupportsIsNullClause() - { - // "WHERE" Expression NullComparisonExpression - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NULL', - 'DELETE FROM cms_users WHERE name IS NULL' - ); - } - - public function testSupportsIsNotNullClause() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NOT NULL', - 'DELETE FROM cms_users WHERE name IS NOT NULL' - ); - } - - public function testSupportsAtomExpressionAsClause() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE 1 = 1', - 'DELETE FROM cms_users WHERE 1 = 1' - ); - } - - public function testSupportsParameterizedAtomExpression() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE ?1 = 1', - 'DELETE FROM cms_users WHERE ? = 1' - ); - } - - public function testSupportsInClause() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN ( ?1, ?2, ?3, ?4 )', - 'DELETE FROM cms_users WHERE id IN (?, ?, ?, ?)' - ); - } - - public function testSupportsNotInClause() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN ( ?1, ?2 )', - 'DELETE FROM cms_users WHERE id NOT IN (?, ?)' - ); - } - - /** - * @group DDC-980 - */ - public function testSubselectTableAliasReferencing() - { - $this->assertSqlGeneration( - 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) = 10', - 'DELETE FROM cms_users WHERE (SELECT COUNT(*) FROM cms_users_groups c0_ WHERE c0_.user_id = cms_users.id) = 10' - ); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ExprTest.php deleted file mode 100755 index f35b5d4073..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ /dev/null @@ -1,426 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Query; - -use Doctrine\ORM\Query\Expr; -use Doctrine\ORM\Query; - -require_once __DIR__ . '/../../TestInit.php'; - -/** - * Test case for the DQL Expr class used for generating DQL snippets through - * a programmatic interface - * - * @author Jonathan H. Wage - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link http://www.phpdoctrine.org - * @since 2.0 - * @version $Revision$ - */ -class ExprTest extends \Doctrine\Tests\OrmTestCase -{ - private $_em; - - protected function setUp() - { - $this->_em = $this->_getTestEntityManager(); - $this->_expr = new Expr; - } - - public function testAvgExpr() - { - $this->assertEquals('AVG(u.id)', (string) $this->_expr->avg('u.id')); - } - - public function testMaxExpr() - { - $this->assertEquals('MAX(u.id)', (string) $this->_expr->max('u.id')); - } - - public function testMinExpr() - { - $this->assertEquals('MIN(u.id)', (string) $this->_expr->min('u.id')); - } - - public function testCountExpr() - { - $this->assertEquals('MAX(u.id)', (string) $this->_expr->max('u.id')); - } - - public function testCountDistinctExpr() - { - $this->assertEquals('COUNT(DISTINCT u.id)', (string) $this->_expr->countDistinct('u.id')); - } - - public function testExistsExpr() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - - $this->assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->exists($qb)); - } - - public function testAllExpr() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - - $this->assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->all($qb)); - } - - public function testSomeExpr() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - - $this->assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->some($qb)); - } - - public function testAnyExpr() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - - $this->assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->any($qb)); - } - - public function testNotExpr() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - - $this->assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->not($qb)); - } - - public function testAndExpr() - { - $this->assertEquals('1 = 1 AND 2 = 2', (string) $this->_expr->andx((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2))); - } - - public function testIntelligentParenthesisPreventionAndExpr() - { - $this->assertEquals( - '1 = 1 AND 2 = 2', - (string) $this->_expr->andx($this->_expr->orx($this->_expr->andx($this->_expr->eq(1, 1))), (string) $this->_expr->eq(2, 2)) - ); - } - - public function testOrExpr() - { - $this->assertEquals('1 = 1 OR 2 = 2', (string) $this->_expr->orx((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2))); - } - - public function testAbsExpr() - { - $this->assertEquals('ABS(1)', (string) $this->_expr->abs(1)); - } - - public function testProdExpr() - { - $this->assertEquals('1 * 2', (string) $this->_expr->prod(1, 2)); - } - - public function testDiffExpr() - { - $this->assertEquals('1 - 2', (string) $this->_expr->diff(1, 2)); - } - - public function testSumExpr() - { - $this->assertEquals('1 + 2', (string) $this->_expr->sum(1, 2)); - } - - public function testQuotientExpr() - { - $this->assertEquals('10 / 2', (string) $this->_expr->quot(10, 2)); - } - - public function testScopeInArithmeticExpr() - { - $this->assertEquals('(100 - 20) / 2', (string) $this->_expr->quot($this->_expr->diff(100, 20), 2)); - $this->assertEquals('100 - (20 / 2)', (string) $this->_expr->diff(100, $this->_expr->quot(20, 2))); - } - - public function testSquareRootExpr() - { - $this->assertEquals('SQRT(1)', (string) $this->_expr->sqrt(1)); - } - - public function testEqualExpr() - { - $this->assertEquals('1 = 1', (string) $this->_expr->eq(1, 1)); - } - - public function testLikeExpr() - { - $this->assertEquals('a.description LIKE :description', (string) $this->_expr->like('a.description', ':description')); - } - - public function testConcatExpr() - { - $this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.last_name')); - } - - public function testSubstringExpr() - { - $this->assertEquals('SUBSTRING(a.title, 0, 25)', (string) $this->_expr->substring('a.title', 0, 25)); - } - - /** - * @group regression - * @group DDC-612 - */ - public function testSubstringExprAcceptsTwoArguments() - { - $this->assertEquals('SUBSTRING(a.title, 5)', (string) $this->_expr->substring('a.title', 5)); - } - - public function testLowerExpr() - { - $this->assertEquals('LOWER(u.first_name)', (string) $this->_expr->lower('u.first_name')); - } - - public function testUpperExpr() - { - $this->assertEquals('UPPER(u.first_name)', (string) $this->_expr->upper('u.first_name')); - } - - public function testLengthExpr() - { - $this->assertEquals('LENGTH(u.first_name)', (string) $this->_expr->length('u.first_name')); - } - - public function testGreaterThanExpr() - { - $this->assertEquals('5 > 2', (string) $this->_expr->gt(5, 2)); - } - - public function testLessThanExpr() - { - $this->assertEquals('2 < 5', (string) $this->_expr->lt(2, 5)); - } - - public function testStringLiteralExpr() - { - $this->assertEquals("'word'", (string) $this->_expr->literal('word')); - } - - public function testNumericLiteralExpr() - { - $this->assertEquals(5, (string) $this->_expr->literal(5)); - } - - /** - * @group regression - * @group DDC-610 - */ - public function testLiteralExprProperlyQuotesStrings() - { - $this->assertEquals("'00010001'", (string) $this->_expr->literal('00010001')); - } - - public function testGreaterThanOrEqualToExpr() - { - $this->assertEquals('5 >= 2', (string) $this->_expr->gte(5, 2)); - } - - public function testLessThanOrEqualTo() - { - $this->assertEquals('2 <= 5', (string) $this->_expr->lte(2, 5)); - } - - public function testBetweenExpr() - { - $this->assertEquals('u.id BETWEEN 3 AND 6', (string) $this->_expr->between('u.id', 3, 6)); - } - - public function testTrimExpr() - { - $this->assertEquals('TRIM(u.id)', (string) $this->_expr->trim('u.id')); - } - - public function testIsNullExpr() - { - $this->assertEquals('u.id IS NULL', (string) $this->_expr->isNull('u.id')); - } - - public function testIsNotNullExpr() - { - $this->assertEquals('u.id IS NOT NULL', (string) $this->_expr->isNotNull('u.id')); - } - - public function testInExpr() - { - $this->assertEquals('u.id IN(1, 2, 3)', (string) $this->_expr->in('u.id', array(1, 2, 3))); - } - - public function testInLiteralExpr() - { - $this->assertEquals("u.type IN('foo', 'bar')", (string) $this->_expr->in('u.type', array('foo', 'bar'))); - } - - public function testNotInExpr() - { - $this->assertEquals('u.id NOT IN(1, 2, 3)', (string) $this->_expr->notIn('u.id', array(1, 2, 3))); - } - - public function testNotInLiteralExpr() - { - $this->assertEquals("u.type NOT IN('foo', 'bar')", (string) $this->_expr->notIn('u.type', array('foo', 'bar'))); - } - - public function testAndxOrxExpr() - { - $andExpr = $this->_expr->andx(); - $andExpr->add($this->_expr->eq(1, 1)); - $andExpr->add($this->_expr->lt(1, 5)); - - $orExpr = $this->_expr->orx(); - $orExpr->add($andExpr); - $orExpr->add($this->_expr->eq(1, 1)); - - $this->assertEquals('(1 = 1 AND 1 < 5) OR 1 = 1', (string) $orExpr); - } - - public function testOrxExpr() - { - $orExpr = $this->_expr->orx(); - $orExpr->add($this->_expr->eq(1, 1)); - $orExpr->add($this->_expr->lt(1, 5)); - - $this->assertEquals('1 = 1 OR 1 < 5', (string) $orExpr); - } - - public function testOrderByCountExpr() - { - $orderExpr = $this->_expr->desc('u.username'); - - $this->assertEquals($orderExpr->count(), 1); - $this->assertEquals('u.username DESC', (string) $orderExpr); - } - - public function testOrderByOrder() - { - $orderExpr = $this->_expr->desc('u.username'); - $this->assertEquals('u.username DESC', (string) $orderExpr); - } - - public function testOrderByAsc() - { - $orderExpr = $this->_expr->asc('u.username'); - $this->assertEquals('u.username ASC', (string) $orderExpr); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testAddThrowsException() - { - $orExpr = $this->_expr->orx(); - $orExpr->add($this->_expr->quot(5, 2)); - } - - /** - * @group DDC-1683 - */ - public function testBooleanLiteral() - { - $this->assertEquals('true', $this->_expr->literal(true)); - $this->assertEquals('false', $this->_expr->literal(false)); - } - - - /** - * @group DDC-1686 - */ - public function testExpressionGetter() - { - - // Andx - $andx = new Expr\Andx(array('1 = 1', '2 = 2')); - $this->assertEquals(array('1 = 1', '2 = 2'), $andx->getParts()); - - // Comparison - $comparison = new Expr\Comparison('foo', Expr\Comparison::EQ, 'bar'); - $this->assertEquals('foo', $comparison->getLeftExpr()); - $this->assertEquals('bar', $comparison->getRightExpr()); - $this->assertEquals(Expr\Comparison::EQ, $comparison->getOperator()); - - // From - $from = new Expr\From('Foo', 'f', 'f.id'); - $this->assertEquals('f', $from->getAlias()); - $this->assertEquals('Foo', $from->getFrom()); - $this->assertEquals('f.id', $from->getIndexBy()); - - // Func - $func = new Expr\Func('MAX', array('f.id')); - $this->assertEquals('MAX', $func->getName()); - $this->assertEquals(array('f.id'), $func->getArguments()); - - // GroupBy - $group = new Expr\GroupBy(array('foo DESC', 'bar ASC')); - $this->assertEquals(array('foo DESC', 'bar ASC'), $group->getParts()); - - // Join - $join = new Expr\Join(Expr\Join::INNER_JOIN, 'f.bar', 'b', Expr\Join::ON, 'b.bar_id = 1', 'b.bar_id'); - $this->assertEquals(Expr\Join::INNER_JOIN, $join->getJoinType()); - $this->assertEquals(Expr\Join::ON, $join->getConditionType()); - $this->assertEquals('b.bar_id = 1', $join->getCondition()); - $this->assertEquals('b.bar_id', $join->getIndexBy()); - $this->assertEquals('f.bar', $join->getJoin()); - $this->assertEquals('b', $join->getAlias()); - - // Literal - $literal = new Expr\Literal(array('foo')); - $this->assertEquals(array('foo'), $literal->getParts()); - - // Math - $math = new Expr\Math(10, '+', 20); - $this->assertEquals(10, $math->getLeftExpr()); - $this->assertEquals(20, $math->getRightExpr()); - $this->assertEquals('+', $math->getOperator()); - - // OrderBy - $order = new Expr\OrderBy('foo', 'DESC'); - $this->assertEquals(array('foo DESC'), $order->getParts()); - - // Andx - $orx = new Expr\Orx(array('foo = 1', 'bar = 2')); - $this->assertEquals(array('foo = 1', 'bar = 2'), $orx->getParts()); - - // Select - $select = new Expr\Select(array('foo', 'bar')); - $this->assertEquals(array('foo', 'bar'), $select->getParts()); - } - - public function testAddEmpty() { - $andExpr = $this->_expr->andx(); - $andExpr->add($this->_expr->andx()); - - $this->assertEquals(0, $andExpr->count()); - } - - public function testAddNull() { - $andExpr = $this->_expr->andx(); - $andExpr->add(null); - - $this->assertEquals(0, $andExpr->count()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php deleted file mode 100755 index 1f0445c080..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ /dev/null @@ -1,606 +0,0 @@ -_em = $this->_getTestEntityManager(); - } - - public function assertValidDQL($dql, $debug = false) - { - try { - $parserResult = $this->parseDql($dql); - } catch (QueryException $e) { - if ($debug) { - echo $e->getTraceAsString() . PHP_EOL; - } - - $this->fail($e->getMessage()); - } - } - - public function assertInvalidDQL($dql, $debug = false) - { - try { - $parserResult = $this->parseDql($dql); - - $this->fail('No syntax errors were detected, when syntax errors were expected'); - } catch (QueryException $e) { - if ($debug) { - echo $e->getMessage() . PHP_EOL; - echo $e->getTraceAsString() . PHP_EOL; - } - } - } - - public function parseDql($dql, $hints = array()) - { - $query = $this->_em->createQuery($dql); - $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - $query->setDql($dql); - - foreach ($hints as $key => $value) { - $query->setHint($key, $value); - } - - $parser = new \Doctrine\ORM\Query\Parser($query); - - // We do NOT test SQL output here. That only unnecessarily slows down the tests! - $parser->setCustomOutputTreeWalker('Doctrine\Tests\Mocks\MockTreeWalker'); - - return $parser->parse(); - } - - public function testEmptyQueryString() - { - $this->assertInvalidDQL(''); - } - - public function testPlainFromClauseWithAlias() - { - $this->assertValidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testSelectSingleComponentWithAsterisk() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testSelectSingleComponentWithMultipleColumns() - { - $this->assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testSelectMultipleComponentsUsingMultipleFrom() - { - $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user'); - } - - public function testSelectMultipleComponentsWithAsterisk() - { - $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p'); - } - - public function testSelectDistinctIsSupported() - { - $this->assertValidDQL('SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testAggregateFunctionInSelect() - { - $this->assertValidDQL('SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testDuplicatedAliasInAggregateFunction() - { - $this->assertInvalidDQL('SELECT COUNT(u.id) AS num, SUM(u.id) AS num FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testAggregateFunctionWithDistinctInSelect() - { - $this->assertValidDQL('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testFunctionalExpressionsSupportedInWherePart() - { - $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'"); - } - - public function testArithmeticExpressionsSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000'); - } - - public function testInExpressionSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)'); - } - - public function testInExpressionWithoutSpacesSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1,2,3)'); - } - - public function testNotInExpressionSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)'); - } - - public function testInExpressionWithSingleValuedAssociationPathExpression() - { - $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)"); - } - - public function testInvalidInExpressionWithCollectionValuedAssociationPathExpression() - { - $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IN (?1, ?2)"); - } - - public function testInstanceOfExpressionSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee'); - } - - public function testInstanceOfExpressionWithInputParamSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1'); - } - - public function testNotInstanceOfExpressionSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u NOT INSTANCE OF ?1'); - } - - public function testExistsExpressionSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)'); - } - - public function testNotExistsExpressionSupportedInWherePart() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)'); - } - - public function testAggregateFunctionInHavingClause() - { - $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING COUNT(p.phonenumber) > 2'); - $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'romanb'"); - } - - public function testLeftJoin() - { - $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p'); - } - - public function testJoin() - { - $this->assertValidDQL('SELECT u,p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p'); - } - - public function testInnerJoin() - { - $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p'); - } - - public function testMultipleLeftJoin() - { - $this->assertValidDQL('SELECT u, a, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a LEFT JOIN u.phonenumbers p'); - } - - public function testMultipleInnerJoin() - { - $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INNER JOIN u.phonenumbers p'); - } - - public function testMixingOfJoins() - { - $this->assertValidDQL('SELECT u.name, a.topic, p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a LEFT JOIN u.phonenumbers p'); - } - - public function testJoinClassPath() - { - $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WITH a.user = u.id'); - } - - public function testOrderBySingleColumn() - { - $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name'); - } - - public function testOrderBySingleColumnAscending() - { - $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name ASC'); - } - - public function testOrderBySingleColumnDescending() - { - $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name DESC'); - } - - public function testOrderByMultipleColumns() - { - $this->assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username DESC, u.name DESC'); - } - - public function testSubselectInInExpression() - { - $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = 'zYne')"); - } - - public function testSubselectInSelectPart() - { - $this->assertValidDQL("SELECT u.name, (SELECT COUNT(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234) pcount FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); - } - - public function testArithmeticExpressionInSelectPart() - { - $this->assertValidDQL("SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u"); - } - - public function testArithmeticExpressionInSubselectPart() - { - $this->assertValidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); - } - - public function testArithmeticExpressionWithParenthesisInSubselectPart() - { - $this->assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); - } - - /** - * @group DDC-1079 - */ - public function testSelectLiteralInSubselect() - { - $this->assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u'); - $this->assertValidDQL('SELECT (SELECT 0 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - /** - * @group DDC-1077 - */ - public function testConstantValueInSelect() - { - $this->assertValidDQL("SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", true); - } - - public function testDuplicateAliasInSubselectPart() - { - $this->assertInvalidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u2) foo FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); - } - - public function testPositionalInputParameter() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1'); - } - - public function testNamedInputParameter() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id'); - } - - public function testJoinConditionOverrideNotSupported() - { - $this->assertInvalidDQL("SELECT u.name, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'"); - } - - public function testIndexByClauseWithOneComponent() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id'); - } - - public function testIndexBySupportsJoins() - { - $this->assertValidDQL('SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a INDEX BY a.id'); // INDEX BY is now referring to articles - } - - public function testIndexBySupportsJoins2() - { - $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p INDEX BY p.phonenumber'); - } - - public function testBetweenExpressionSupported() - { - $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name BETWEEN 'jepso' AND 'zYne'"); - } - - public function testNotBetweenExpressionSupported() - { - $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'"); - } - - public function testLikeExpression() - { - $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'"); - } - - public function testNotLikeExpression() - { - $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT LIKE 'z%'"); - } - - public function testLikeExpressionWithCustomEscapeCharacter() - { - $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'"); - } - - public function testFieldComparisonWithoutAlias() - { - $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE id = 1"); - } - - public function testDuplicatedAliasDeclaration() - { - $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles u WHERE u.id = 1"); - } - - public function testImplicitJoinInWhereOnSingleValuedAssociationPathExpression() - { - // This should be allowed because avatar is a single-value association. - // SQL: SELECT ... FROM forum_user fu INNER JOIN forum_avatar fa ON fu.avatar_id = fa.id WHERE fa.id = ? - $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a WHERE a.id = ?1"); - } - - public function testImplicitJoinInWhereOnCollectionValuedPathExpression() - { - // This should be forbidden, because articles is a collection - $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a WHERE a.title = ?"); - } - - public function testInvalidSyntaxIsRejected() - { - $this->assertInvalidDQL("FOOBAR CmsUser"); - $this->assertInvalidDQL("DELETE FROM Doctrine\Tests\Models\CMS\CmsUser.articles"); - $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles.comments"); - - // Currently UNDEFINED OFFSET error - $this->assertInvalidDQL("SELECT c FROM CmsUser.articles.comments c"); - } - - public function testUpdateWorksWithOneField() - { - $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone'"); - } - - public function testUpdateWorksWithMultipleFields() - { - $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone', u.username = 'some'"); - } - - public function testUpdateSupportsConditions() - { - $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone' WHERE u.id = 5"); - } - - public function testDeleteAll() - { - $this->assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testDeleteWithCondition() - { - $this->assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = 3'); - } - - /** - * The main use case for this generalized style of join is when a join condition - * does not involve a foreign key relationship that is mapped to an entity relationship. - */ - public function testImplicitJoinWithCartesianProductAndConditionInWhere() - { - $this->assertValidDQL("SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.name = a.topic"); - } - - public function testAllExpressionWithCorrelatedSubquery() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ALL (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)'); - } - - public function testCustomJoinsAndWithKeywordSupported() - { - $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p WITH p.phonenumber = 123 WHERE u.id = 1'); - } - - public function testAnyExpressionWithCorrelatedSubquery() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ANY (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)'); - } - - public function testSomeExpressionWithCorrelatedSubquery() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > SOME (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)'); - } - - public function testArithmeticExpressionWithoutParenthesisInWhereClause() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) + 1 > 10'); - } - - public function testMemberOfExpression() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers'); - //$this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE 'Joe' MEMBER OF u.nicknames"); - } - - public function testSizeFunction() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1'); - } - - public function testEmptyCollectionComparisonExpression() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY'); - } - - public function testSingleValuedAssociationFieldInWhere() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1'); - $this->assertValidDQL('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1'); - } - - public function testBooleanLiteralInWhere() - { - $this->assertValidDQL('SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true'); - } - - public function testSubqueryInSelectExpression() - { - $this->assertValidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testUsageOfQComponentOutsideSubquery() - { - $this->assertInvalidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u WHERE p.user = ?1'); - } - - public function testUnknownAbstractSchemaName() - { - $this->assertInvalidDQL('SELECT u FROM UnknownClassName u'); - } - - public function testCorrectPartialObjectLoad() - { - $this->assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testIncorrectPartialObjectLoadBecauseOfMissingIdentifier() - { - $this->assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testScalarExpressionInSelect() - { - $this->assertValidDQL('SELECT u, 42 + u.id AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testInputParameterInSelect() - { - $this->assertValidDQL('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - /** - * @group DDC-1091 - */ - public function testCustomFunctionsReturningStringInStringPrimary() - { - $this->_em->getConfiguration()->addCustomStringFunction('CC', 'Doctrine\ORM\Query\AST\Functions\ConcatFunction'); - - $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'", true); - } - - /** - * @group DDC-505 - */ - public function testDQLKeywordInJoinIsAllowed() - { - $this->assertValidDQL('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g'); - } - - /** - * @group DDC-505 - */ - public function testDQLKeywordInConditionIsAllowed() - { - $this->assertValidDQL('SELECT g FROM ' . __NAMESPACE__ . '\DQLKeywordsModelGroup g WHERE g.from=0'); - } - - /* The exception is currently thrown in the SQLWalker, not earlier. - public function testInverseSideSingleValuedAssociationPathNotAllowed() - { - $this->assertInvalidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1'); - } - */ - - /** - * @group DDC-617 - */ - public function testSelectOnlyNonRootEntityAlias() - { - $this->assertInvalidDQL('SELECT g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'); - } - - /** - * @group DDC-1108 - */ - public function testInputParameterSingleChar() - { - $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :q'); - } - - /** - * @group DDC-1053 - */ - public function testGroupBy() - { - $this->assertValidDQL('SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id'); - } - - /** - * @group DDC-1053 - */ - public function testGroupByIdentificationVariable() - { - $this->assertValidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g'); - } - - /** - * @group DDC-1053 - */ - public function testGroupByUnknownIdentificationVariable() - { - $this->assertInvalidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY m'); - } - - /** - * @group DDC-117 - */ - public function testSizeOfForeignKeyOneToManyPrimaryKeyEntity() - { - $this->assertValidDQL("SELECT a, t FROM Doctrine\Tests\Models\DDC117\DDC117Article a JOIN a.translations t WHERE SIZE(a.translations) > 0"); - } - - /** - * @group DDC-117 - */ - public function testSizeOfForeignKeyManyToManyPrimaryKeyEntity() - { - $this->assertValidDQL("SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE SIZE(e.reviewingTranslations) > 0"); - } - - public function testCaseSupportContainingNullIfExpression() - { - $this->assertValidDQL("SELECT u.id, NULLIF(u.name, u.name) AS shouldBeNull FROM Doctrine\Tests\Models\CMS\CmsUser u"); - } - - public function testCaseSupportContainingCoalesceExpression() - { - $this->assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u"); - } -} - -/** @Entity */ -class DQLKeywordsModelUser -{ - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - /** @OneToOne(targetEntity="DQLKeywordsModelGroup") */ - private $group; -} - -/** @Entity */ -class DQLKeywordsModelGroup -{ - /** @Id @Column(type="integer") @GeneratedValue */ - private $id; - /** @Column */ - private $from; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LexerTest.php deleted file mode 100755 index 29bba4bae7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ /dev/null @@ -1,234 +0,0 @@ -moveNext(); - $token = $lexer->lookahead; - - $this->assertEquals(Lexer::T_IDENTIFIER, $token['type']); - $this->assertEquals('u', $token['value']); - } - - public function testScannerRecognizesIdentifierConsistingOfLetters() - { - $lexer = new Lexer('someIdentifier'); - - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_IDENTIFIER, $token['type']); - $this->assertEquals('someIdentifier', $token['value']); - } - - public function testScannerRecognizesIdentifierIncludingDigits() - { - $lexer = new Lexer('s0m31d3nt1f13r'); - - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_IDENTIFIER, $token['type']); - $this->assertEquals('s0m31d3nt1f13r', $token['value']); - } - - public function testScannerRecognizesIdentifierIncludingUnderscore() - { - $lexer = new Lexer('some_identifier'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_IDENTIFIER, $token['type']); - $this->assertEquals('some_identifier', $token['value']); - } - - public function testScannerRecognizesDecimalInteger() - { - $lexer = new Lexer('1234'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INTEGER, $token['type']); - $this->assertEquals(1234, $token['value']); - } - - public function testScannerRecognizesFloat() - { - $lexer = new Lexer('1.234'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.234, $token['value']); - } - - public function testScannerRecognizesFloatWithExponent() - { - $lexer = new Lexer('1.2e3'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.2e3, $token['value']); - } - - public function testScannerRecognizesFloatWithExponent2() - { - $lexer = new Lexer('0.2e3'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(.2e3, $token['value']); - } - - public function testScannerRecognizesFloatWithNegativeExponent() - { - $lexer = new Lexer('7E-10'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(7E-10, $token['value']); - } - - public function testScannerRecognizesFloatBig() - { - $lexer = new Lexer('123456789.01'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.2345678901e8, $token['value']); - } - - public function testScannerRecognizesFloatContainingWhitespace() - { - $lexer = new Lexer('- 1.234e2'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_MINUS, $token['type']); - $this->assertEquals('-', $token['value']); - - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertNotEquals(-1.234e2, $token['value']); - $this->assertEquals(1.234e2, $token['value']); - } - - public function testScannerRecognizesStringContainingWhitespace() - { - $lexer = new Lexer("'This is a string.'"); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_STRING, $token['type']); - $this->assertEquals("This is a string.", $token['value']); - } - - public function testScannerRecognizesStringContainingSingleQuotes() - { - $lexer = new Lexer("'abc''defg'''"); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_STRING, $token['type']); - $this->assertEquals("abc'defg'", $token['value']); - } - - public function testScannerRecognizesInputParameter() - { - $lexer = new Lexer('?1'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); - $this->assertEquals('?1', $token['value']); - } - - public function testScannerRecognizesNamedInputParameter() - { - $lexer = new Lexer(':name'); - $lexer->moveNext(); - $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); - $this->assertEquals(':name', $token['value']); - } - - public function testScannerTokenizesASimpleQueryCorrectly() - { - $dql = "SELECT u FROM My\Namespace\User u WHERE u.name = 'Jack O''Neil'"; - $lexer = new Lexer($dql); - - $tokens = array( - array( - 'value' => 'SELECT', - 'type' => Lexer::T_SELECT, - 'position' => 0 - ), - array( - 'value' => 'u', - 'type' => Lexer::T_IDENTIFIER, - 'position' => 7 - ), - array( - 'value' => 'FROM', - 'type' => Lexer::T_FROM, - 'position' => 9 - ), - array( - 'value' => 'My\Namespace\User', - 'type' => Lexer::T_IDENTIFIER, - 'position' => 14 - ), - array( - 'value' => 'u', - 'type' => Lexer::T_IDENTIFIER, - 'position' => 32 - ), - array( - 'value' => 'WHERE', - 'type' => Lexer::T_WHERE, - 'position' => 34 - ), - array( - 'value' => 'u', - 'type' => Lexer::T_IDENTIFIER, - 'position' => 40 - ), - array( - 'value' => '.', - 'type' => Lexer::T_DOT, - 'position' => 41 - ), - array( - 'value' => 'name', - 'type' => Lexer::T_IDENTIFIER, - 'position' => 42 - ), - array( - 'value' => '=', - 'type' => Lexer::T_EQUALS, - 'position' => 47 - ), - array( - 'value' => "Jack O'Neil", - 'type' => Lexer::T_STRING, - 'position' => 49 - ) - ); - - foreach ($tokens as $expected) { - $lexer->moveNext(); - $actual = $lexer->lookahead; - $this->assertEquals($expected['value'], $actual['value']); - $this->assertEquals($expected['type'], $actual['type']); - $this->assertEquals($expected['position'], $actual['position']); - } - - $this->assertFalse($lexer->moveNext()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php deleted file mode 100755 index 60b118570b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ /dev/null @@ -1,53 +0,0 @@ -. - */ -namespace Doctrine\Tests\ORM\Query; - -use Doctrine\ORM\Query\ParameterTypeInferer; -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Types\Type; -use PDO; - -require_once __DIR__ . '/../../TestInit.php'; - -class ParameterTypeInfererTest extends \Doctrine\Tests\OrmTestCase -{ - - public function providerParameterTypeInferer() - { - return array( - array(1, Type::INTEGER), - array("bar", PDO::PARAM_STR), - array("1", PDO::PARAM_STR), - array(new \DateTime, Type::DATETIME), - array(array(2), Connection::PARAM_INT_ARRAY), - array(array("foo"), Connection::PARAM_STR_ARRAY), - array(array("1","2"), Connection::PARAM_STR_ARRAY), - array(array(), Connection::PARAM_STR_ARRAY), - ); - } - - /** - * @dataProvider providerParameterTypeInferer - */ - - public function testParameterTypeInferer($value, $expected) - { - $this->assertEquals($expected, ParameterTypeInferer::inferType($value)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php deleted file mode 100755 index 64f3afb0f6..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php +++ /dev/null @@ -1,48 +0,0 @@ -parserResult = new ParserResult(); - } - - public function testGetRsm() - { - $this->assertInstanceOf( - 'Doctrine\ORM\Query\ResultSetMapping', - $this->parserResult->getResultSetMapping() - ); - } - - public function testSetGetSqlExecutor() - { - $this->assertNull($this->parserResult->getSqlExecutor()); - - $executor = $this->getMock('Doctrine\ORM\Query\Exec\AbstractSqlExecutor', array('execute')); - $this->parserResult->setSqlExecutor($executor); - $this->assertSame($executor, $this->parserResult->getSqlExecutor()); - } - - public function testGetSqlParameterPosition() - { - $this->parserResult->addParameterMapping(1, 1); - $this->parserResult->addParameterMapping(1, 2); - $this->assertEquals(array(1, 2), $this->parserResult->getSqlParameterPositions(1)); - } - - public function testGetParameterMappings() - { - $this->assertInternalType('array', $this->parserResult->getParameterMappings()); - - $this->parserResult->addParameterMapping(1, 1); - $this->parserResult->addParameterMapping(1, 2); - $this->assertEquals(array(1 => array(1, 2)), $this->parserResult->getParameterMappings()); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/QueryTest.php deleted file mode 100755 index 9617fa8739..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ /dev/null @@ -1,178 +0,0 @@ -_em = $this->_getTestEntityManager(); - } - - public function testGetParameters() - { - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); - - $parameters = new ArrayCollection(); - - $this->assertEquals($parameters, $query->getParameters()); - } - - public function testGetParameters_HasSomeAlready() - { - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); - $query->setParameter(2, 84); - - $parameters = new ArrayCollection(); - $parameters->add(new Parameter(2, 84)); - - $this->assertEquals($parameters, $query->getParameters()); - } - - public function testSetParameters() - { - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); - - $parameters = new ArrayCollection(); - $parameters->add(new Parameter(1, 'foo')); - $parameters->add(new Parameter(2, 'bar')); - - $query->setParameters($parameters); - - $this->assertEquals($parameters, $query->getParameters()); - } - - public function testFree() - { - $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); - $query->setParameter(2, 84, \PDO::PARAM_INT); - - $query->free(); - - $this->assertEquals(0, count($query->getParameters())); - } - - public function testClone() - { - $dql = "select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"; - - $query = $this->_em->createQuery($dql); - $query->setParameter(2, 84, \PDO::PARAM_INT); - $query->setHint('foo', 'bar'); - - $cloned = clone $query; - - $this->assertEquals($dql, $cloned->getDql()); - $this->assertEquals(0, count($cloned->getParameters())); - $this->assertFalse($cloned->getHint('foo')); - } - - public function testFluentQueryInterface() - { - $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); - $q2 = $q->expireQueryCache(true) - ->setQueryCacheLifetime(3600) - ->setQueryCacheDriver(null) - ->expireResultCache(true) - ->setHint('foo', 'bar') - ->setHint('bar', 'baz') - ->setParameter(1, 'bar') - ->setParameters(new ArrayCollection(array(new Parameter(2, 'baz')))) - ->setResultCacheDriver(null) - ->setResultCacheId('foo') - ->setDql('foo') - ->setFirstResult(10) - ->setMaxResults(10); - - $this->assertSame($q2, $q); - } - - /** - * @group DDC-968 - */ - public function testHints() - { - $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); - $q->setHint('foo', 'bar')->setHint('bar', 'baz'); - - $this->assertEquals('bar', $q->getHint('foo')); - $this->assertEquals('baz', $q->getHint('bar')); - $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints()); - } - - /** - * @group DDC-1588 - */ - public function testQueryDefaultResultCache() - { - $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); - $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); - $q->useResultCache(true); - $this->assertSame($this->_em->getConfiguration()->getResultCacheImpl(), $q->getQueryCacheProfile()->getResultCacheDriver()); - } - - /** - * @expectedException Doctrine\ORM\Query\QueryException - **/ - public function testIterateWithNoDistinctAndWrongSelectClause() - { - $q = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a"); - $q->iterate(); - } - - /** - * @expectedException Doctrine\ORM\Query\QueryException - **/ - public function testIterateWithNoDistinctAndWithValidSelectClause() - { - $q = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a"); - $q->iterate(); - } - - public function testIterateWithDistinct() - { - $q = $this->_em->createQuery("SELECT DISTINCT u from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a"); - $q->iterate(); - } - - /** - * @group DDC-1697 - */ - public function testCollectionParameters() - { - $cities = array( - 0 => "Paris", - 3 => "Canne", - 9 => "St Julien" - ); - - $query = $this->_em - ->createQuery("SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)") - ->setParameter('cities', $cities); - - $parameters = $query->getParameters(); - $parameter = $parameters->first(); - - $this->assertEquals('cities', $parameter->getName()); - $this->assertEquals($cities, $parameter->getValue()); - } - - /** - * @group DDC-2224 - */ - public function testProcessParameterValueClassMetadata() - { - $query = $this->_em->createQuery("SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)"); - $this->assertEquals( - 'Doctrine\Tests\Models\CMS\CmsAddress', - $query->processParameterValue($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress')) - ); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php deleted file mode 100755 index b06b96ecd8..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ /dev/null @@ -1,1807 +0,0 @@ -_em = $this->_getTestEntityManager(); - } - - /** - * Assert a valid SQL generation. - * - * @param string $dqlToBeTested - * @param string $sqlToBeConfirmed - * @param array $queryHints - * @param array $queryParams - */ - public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed, array $queryHints = array(), array $queryParams = array()) - { - try { - $query = $this->_em->createQuery($dqlToBeTested); - - foreach ($queryParams AS $name => $value) { - $query->setParameter($name, $value); - } - - $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) - ->useQueryCache(false); - - foreach ($queryHints AS $name => $value) { - $query->setHint($name, $value); - } - - $sqlGenerated = $query->getSQL(); - - parent::assertEquals( - $sqlToBeConfirmed, - $sqlGenerated, - sprintf('"%s" is not equal of "%s"', $sqlGenerated, $sqlToBeConfirmed) - ); - - $query->free(); - } catch (\Exception $e) { - $this->fail($e->getMessage() ."\n".$e->getTraceAsString()); - } - } - - /** - * Asser an invalid SQL generation. - * - * @param string $dqlToBeTested - * @param string $expectedException - * @param array $queryHints - * @param array $queryParams - */ - public function assertInvalidSqlGeneration($dqlToBeTested, $expectedException, array $queryHints = array(), array $queryParams = array()) - { - $this->setExpectedException($expectedException); - - $query = $this->_em->createQuery($dqlToBeTested); - - foreach ($queryParams AS $name => $value) { - $query->setParameter($name, $value); - } - - $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) - ->useQueryCache(false); - - foreach ($queryHints AS $name => $value) { - $query->setHint($name, $value); - } - - $sql = $query->getSql(); - $query->free(); - - // If we reached here, test failed - $this->fail($sql); - } - - - public function testSupportsSelectForAllFields() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_' - ); - } - - public function testSupportsSelectForOneField() - { - $this->assertSqlGeneration( - 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id0 FROM cms_users c0_' - ); - } - - public function testSupportsSelectForOneNestedField() - { - $this->assertSqlGeneration( - 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u', - 'SELECT c0_.id AS id0 FROM cms_articles c1_ INNER JOIN cms_users c0_ ON c1_.user_id = c0_.id' - ); - } - - public function testSupportsSelectForAllNestedField() - { - $this->assertSqlGeneration( - 'SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u ORDER BY u.name ASC', - 'SELECT c0_.id AS id0, c0_.topic AS topic1, c0_.text AS text2, c0_.version AS version3 FROM cms_articles c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id ORDER BY c1_.name ASC' - ); - } - - public function testSupportsSelectForMultipleColumnsOfASingleComponent() - { - $this->assertSqlGeneration( - 'SELECT u.username, u.name FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.username AS username0, c0_.name AS name1 FROM cms_users c0_' - ); - } - - public function testSupportsSelectUsingMultipleFromComponents() - { - $this->assertSqlGeneration( - 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.phonenumber AS phonenumber4 FROM cms_users c0_, cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id' - ); - } - - public function testSupportsJoinOnMultipleComponents() - { - $this->assertSqlGeneration( - 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsPhonenumber p WITH u = p.user', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.phonenumber AS phonenumber4 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON (c0_.id = c1_.user_id)' - ); - } - - public function testSupportsJoinOnMultipleComponentsWithJoinedInheritanceType() - { - $this->assertSqlGeneration( - 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e JOIN Doctrine\Tests\Models\Company\CompanyManager m WITH e.id = m.id', - 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id INNER JOIN company_managers c2_ INNER JOIN company_employees c3_ ON c2_.id = c3_.id INNER JOIN company_persons c4_ ON c2_.id = c4_.id AND (c0_.id = c4_.id)' - ); - - $this->assertSqlGeneration( - 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e LEFT JOIN Doctrine\Tests\Models\Company\CompanyManager m WITH e.id = m.id', - 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ INNER JOIN company_employees c3_ ON c2_.id = c3_.id INNER JOIN company_persons c4_ ON c2_.id = c4_.id ON (c0_.id = c4_.id)' - ); - } - - public function testSupportsSelectWithCollectionAssociationJoin() - { - $this->assertSqlGeneration( - 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.phonenumber AS phonenumber4 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON c0_.id = c1_.user_id' - ); - } - - public function testSupportsSelectWithSingleValuedAssociationJoin() - { - $this->assertSqlGeneration( - 'SELECT u, a FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a', - 'SELECT f0_.id AS id0, f0_.username AS username1, f1_.id AS id2 FROM forum_users f0_ INNER JOIN forum_avatars f1_ ON f0_.avatar_id = f1_.id' - ); - } - - public function testSelectCorrelatedSubqueryComplexMathematicalExpression() - { - $this->assertSqlGeneration( - 'SELECT (SELECT (count(p.phonenumber)+5)*10 FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p JOIN p.user ui WHERE ui.id = u.id) AS c FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT (SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr1 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = c2_.id) AS sclr0 FROM cms_users c2_' - ); - } - - public function testSelectComplexMathematicalExpression() - { - $this->assertSqlGeneration( - 'SELECT (count(p.phonenumber)+5)*10 FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p JOIN p.user ui WHERE ui.id = ?1', - 'SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr0 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = ?' - ); - } - - /* NOT (YET?) SUPPORTED. - Can be supported if SimpleSelectExpresion supports SingleValuedPathExpression instead of StateFieldPathExpression. - - public function testSingleAssociationPathExpressionInSubselect() - { - $this->assertSqlGeneration( - 'SELECT (SELECT p.user FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = u) user_id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', - 'SELECT (SELECT c0_.user_id FROM cms_phonenumbers c0_ WHERE c0_.user_id = c1_.id) AS sclr0 FROM cms_users c1_ WHERE c1_.id = ?' - ); - }*/ - - /** - * @group DDC-1077 - */ - public function testConstantValueInSelect() - { - $this->assertSqlGeneration( - "SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", - "SELECT c0_.name AS name0, 'foo' AS sclr1 FROM cms_users c0_" - ); - } - - public function testSupportsOrderByWithAscAsDefault() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id', - 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ ORDER BY f0_.id ASC' - ); - } - - public function testSupportsOrderByAsc() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id asc', - 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ ORDER BY f0_.id ASC' - ); - } - public function testSupportsOrderByDesc() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id desc', - 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ ORDER BY f0_.id DESC' - ); - } - - public function testSupportsSelectDistinct() - { - $this->assertSqlGeneration( - 'SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT DISTINCT c0_.name AS name0 FROM cms_users c0_' - ); - } - - public function testSupportsAggregateFunctionInSelectedFields() - { - $this->assertSqlGeneration( - 'SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id', - 'SELECT COUNT(c0_.id) AS sclr0 FROM cms_users c0_ GROUP BY c0_.id' - ); - } - - public function testSupportsAggregateFunctionWithSimpleArithmetic() - { - $this->assertSqlGeneration( - 'SELECT MAX(u.id + 4) * 2 FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT MAX(c0_.id + 4) * 2 AS sclr0 FROM cms_users c0_' - ); - } - - public function testSupportsWhereClauseWithPositionalParameter() - { - $this->assertSqlGeneration( - 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.id = ?1', - 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE f0_.id = ?' - ); - } - - public function testSupportsWhereClauseWithNamedParameter() - { - $this->assertSqlGeneration( - 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.username = :name', - 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE f0_.username = ?' - ); - } - - public function testSupportsWhereAndClauseWithNamedParameters() - { - $this->assertSqlGeneration( - 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.username = :name and u.username = :name2', - 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE f0_.username = ? AND f0_.username = ?' - ); - } - - public function testSupportsCombinedWhereClauseWithNamedParameter() - { - $this->assertSqlGeneration( - 'select u from Doctrine\Tests\Models\Forum\ForumUser u where (u.username = :name OR u.username = :name2) AND u.id = :id', - 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE (f0_.username = ? OR f0_.username = ?) AND f0_.id = ?' - ); - } - - public function testSupportsAggregateFunctionInASelectDistinct() - { - $this->assertSqlGeneration( - 'SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT COUNT(DISTINCT c0_.name) AS sclr0 FROM cms_users c0_' - ); - } - - // Ticket #668 - public function testSupportsASqlKeywordInAStringLiteralParam() - { - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE '%foo OR bar%'", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE c0_.name LIKE '%foo OR bar%'" - ); - } - - public function testSupportsArithmeticExpressionsInWherePart() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id + 5000) * c0_.id + 3 < 10000000' - ); - } - - public function testSupportsMultipleEntitiesInFromClause() - { - $this->assertSqlGeneration( - 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u2 WHERE u.id = u2.id', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.id AS id4, c1_.topic AS topic5, c1_.text AS text6, c1_.version AS version7 FROM cms_users c0_, cms_articles c1_ INNER JOIN cms_users c2_ ON c1_.user_id = c2_.id WHERE c0_.id = c2_.id' - ); - } - - public function testSupportsMultipleEntitiesInFromClauseUsingPathExpression() - { - $this->assertSqlGeneration( - 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.id = a.user', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.id AS id4, c1_.topic AS topic5, c1_.text AS text6, c1_.version AS version7 FROM cms_users c0_, cms_articles c1_ WHERE c0_.id = c1_.user_id' - ); - } - - public function testSupportsPlainJoinWithoutClause() - { - $this->assertSqlGeneration( - 'SELECT u.id, a.id from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a', - 'SELECT c0_.id AS id0, c1_.id AS id1 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id' - ); - $this->assertSqlGeneration( - 'SELECT u.id, a.id from Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a', - 'SELECT c0_.id AS id0, c1_.id AS id1 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id' - ); - } - - /** - * @group DDC-135 - */ - public function testSupportsJoinAndWithClauseRestriction() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic LIKE '%foo%'", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')" - ); - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a WITH a.topic LIKE '%foo%'", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')" - ); - } - - /** - * @group DDC-135 - * @group DDC-177 - */ - public function testJoinOnClause_NotYetSupported_ThrowsException() - { - $this->setExpectedException('Doctrine\ORM\Query\QueryException'); - - $sql = $this->_em->createQuery( - "SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a ON a.topic LIKE '%foo%'" - )->getSql(); - } - - public function testSupportsMultipleJoins() - { - $this->assertSqlGeneration( - 'SELECT u.id, a.id, p.phonenumber, c.id from Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a JOIN u.phonenumbers p JOIN a.comments c', - 'SELECT c0_.id AS id0, c1_.id AS id1, c2_.phonenumber AS phonenumber2, c3_.id AS id3 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id INNER JOIN cms_phonenumbers c2_ ON c0_.id = c2_.user_id INNER JOIN cms_comments c3_ ON c1_.id = c3_.article_id' - ); - } - - public function testSupportsTrimFunction() - { - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(TRAILING ' ' FROM u.name) = 'someone'", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE TRIM(TRAILING ' ' FROM c0_.name) = 'someone'" - ); - } - - // Ticket 894 - public function testSupportsBetweenClauseWithPositionalParameters() - { - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE c0_.id BETWEEN ? AND ?" - ); - } - - /** - * @group DDC-1802 - */ - public function testSupportsNotBetweenForSizeFunction() - { - $this->assertSqlGeneration( - "SELECT m.name FROM Doctrine\Tests\Models\StockExchange\Market m WHERE SIZE(m.stocks) NOT BETWEEN ?1 AND ?2", - "SELECT e0_.name AS name0 FROM exchange_markets e0_ WHERE (SELECT COUNT(*) FROM exchange_stocks e1_ WHERE e1_.market_id = e0_.id) NOT BETWEEN ? AND ?" - ); - } - - public function testSupportsFunctionalExpressionsInWherePart() - { - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'", - // String quoting in the SQL usually depends on the database platform. - // This test works with a mock connection which uses ' for string quoting. - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE TRIM(c0_.name) = 'someone'" - ); - } - - public function testSupportsInstanceOfExpressionsInWherePart() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee", - "SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee')" - ); - } - - public function testSupportsInstanceOfExpressionInWherePartWithMultipleValues() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF (Doctrine\Tests\Models\Company\CompanyEmployee, \Doctrine\Tests\Models\Company\CompanyManager)", - "SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee', 'manager')" - ); - } - - /** - * @group DDC-1194 - */ - public function testSupportsInstanceOfExpressionsInWherePartPrefixedSlash() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF \Doctrine\Tests\Models\Company\CompanyEmployee", - "SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee')" - ); - } - - /** - * @group DDC-1194 - */ - public function testSupportsInstanceOfExpressionsInWherePartWithUnrelatedClass() - { - $this->assertInvalidSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF \Doctrine\Tests\Models\CMS\CmsUser", - "Doctrine\ORM\Query\QueryException" - ); - } - - public function testSupportsInstanceOfExpressionsInWherePartInDeeperLevel() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\Company\CompanyEmployee u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyManager", - "SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id WHERE c0_.discr IN ('manager')" - ); - } - - public function testSupportsInstanceOfExpressionsInWherePartInDeepestLevel() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\Company\CompanyManager u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyManager", - "SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c2_.title AS title5, c0_.discr AS discr6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id WHERE c0_.discr IN ('manager')" - ); - } - - public function testSupportsInstanceOfExpressionsUsingInputParameterInWherePart() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1", - "SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN (?)", - array(), array(1 => $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyEmployee')) - ); - } - - // Ticket #973 - public function testSupportsSingleValuedInExpressionWithoutSpacesInWherePart() - { - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE IDENTITY(u.email) IN(46)", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE c0_.email_id IN (46)" - ); - } - - public function testSupportsMultipleValuedInExpressionInWherePart() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.id IN (1, 2)' - ); - } - - public function testSupportsNotInExpressionInWherePart() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :id NOT IN (1)', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE ? NOT IN (1)' - ); - } - - /** - * @group DDC-1802 - */ - public function testSupportsNotInExpressionForModFunction() - { - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE MOD(u.id, 5) NOT IN(1,3,4)", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE MOD(c0_.id, 5) NOT IN (1, 3, 4)" - ); - } - - public function testInExpressionWithSingleValuedAssociationPathExpressionInWherePart() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)', - 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE f0_.avatar_id IN (?, ?)' - ); - } - - public function testInvalidInExpressionWithSingleValuedAssociationPathExpressionOnInverseSide() - { - // We do not support SingleValuedAssociationPathExpression on inverse side - $this->assertInvalidSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address IN (?1, ?2)", - "Doctrine\ORM\Query\QueryException" - ); - } - - public function testSupportsConcatFunctionForMysqlAndPostgresql() - { - $connMock = $this->_em->getConnection(); - $orgPlatform = $connMock->getDatabasePlatform(); - - $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); - $this->assertSqlGeneration( - "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", - "SELECT c0_.id AS id0 FROM cms_users c0_ WHERE CONCAT(c0_.name, 's') = ?" - ); - $this->assertSqlGeneration( - "SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1", - "SELECT CONCAT(c0_.id, c0_.name) AS sclr0 FROM cms_users c0_ WHERE c0_.id = ?" - ); - - $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); - $this->assertSqlGeneration( - "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", - "SELECT c0_.id AS id0 FROM cms_users c0_ WHERE c0_.name || 's' = ?" - ); - $this->assertSqlGeneration( - "SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1", - "SELECT c0_.id || c0_.name AS sclr0 FROM cms_users c0_ WHERE c0_.id = ?" - ); - - $connMock->setDatabasePlatform($orgPlatform); - } - - public function testSupportsExistsExpressionInWherePartWithCorrelatedSubquery() - { - $this->assertSqlGeneration( - 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = u.id)', - 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT c1_.phonenumber FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = c0_.id)' - ); - } - - /** - * @group DDC-593 - */ - public function testSubqueriesInComparisonExpression() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id >= (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = :name)) AND (u.id <= (SELECT u3.id FROM Doctrine\Tests\Models\CMS\CmsUser u3 WHERE u3.name = :name))', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id >= (SELECT c1_.id FROM cms_users c1_ WHERE c1_.name = ?)) AND (c0_.id <= (SELECT c2_.id FROM cms_users c2_ WHERE c2_.name = ?))' - ); - } - - public function testSupportsMemberOfExpressionOneToMany() - { - // "Get all users who have $phone as a phonenumber." (*cough* doesnt really make sense...) - $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - - $phone = new \Doctrine\Tests\Models\CMS\CmsPhonenumber; - $phone->phonenumber = 101; - $q->setParameter('param', $phone); - - $this->assertEquals( - 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id AND c1_.phonenumber = ?)', - $q->getSql() - ); - } - - public function testSupportsMemberOfExpressionManyToMany() - { - // "Get all users who are members of $group." - $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.groups'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - - $group = new \Doctrine\Tests\Models\CMS\CmsGroup; - $group->id = 101; - $q->setParameter('param', $group); - - $this->assertEquals( - 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ INNER JOIN cms_groups c2_ ON c1_.group_id = c2_.id WHERE c1_.user_id = c0_.id AND c2_.id = ?)', - $q->getSql() - ); - } - - public function testSupportsMemberOfExpressionSelfReferencing() - { - // "Get all persons who have $person as a friend." - // Tough one: Many-many self-referencing ("friends") with class table inheritance - $q = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p WHERE :param MEMBER OF p.friends'); - $person = new \Doctrine\Tests\Models\Company\CompanyPerson; - $this->_em->getClassMetadata(get_class($person))->setIdentifierValues($person, array('id' => 101)); - $q->setParameter('param', $person); - $this->assertEquals( - 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c2_.salary AS salary3, c2_.department AS department4, c2_.startDate AS startDate5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7, c1_.car_id AS car_id8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ INNER JOIN company_persons c4_ ON c3_.friend_id = c4_.id WHERE c3_.person_id = c0_.id AND c4_.id = ?)', - $q->getSql() - ); - } - - public function testSupportsMemberOfWithSingleValuedAssociation() - { - // Impossible example, but it illustrates the purpose - $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.email MEMBER OF u.groups'); - - $this->assertEquals( - 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ INNER JOIN cms_groups c2_ ON c1_.group_id = c2_.id WHERE c1_.user_id = c0_.id AND c2_.id = c0_.email_id)', - $q->getSql() - ); - } - - public function testSupportsMemberOfWithIdentificationVariable() - { - // Impossible example, but it illustrates the purpose - $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u MEMBER OF u.groups'); - - $this->assertEquals( - 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ INNER JOIN cms_groups c2_ ON c1_.group_id = c2_.id WHERE c1_.user_id = c0_.id AND c2_.id = c0_.id)', - $q->getSql() - ); - } - - public function testSupportsCurrentDateFunction() - { - $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_date()'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_DATE', $q->getSql()); - } - - public function testSupportsCurrentTimeFunction() - { - $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.time > current_time()'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id0 FROM date_time_model d0_ WHERE d0_.col_time > CURRENT_TIME', $q->getSql()); - } - - public function testSupportsCurrentTimestampFunction() - { - $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_timestamp()'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_TIMESTAMP', $q->getSql()); - } - - public function testExistsExpressionInWhereCorrelatedSubqueryAssocCondition() - { - $this->assertSqlGeneration( - // DQL - // The result of this query consists of all employees whose spouses are also employees. - 'SELECT DISTINCT emp FROM Doctrine\Tests\Models\CMS\CmsEmployee emp - WHERE EXISTS ( - SELECT spouseEmp - FROM Doctrine\Tests\Models\CMS\CmsEmployee spouseEmp - WHERE spouseEmp = emp.spouse)', - // SQL - 'SELECT DISTINCT c0_.id AS id0, c0_.name AS name1 FROM cms_employees c0_' - . ' WHERE EXISTS (' - . 'SELECT c1_.id FROM cms_employees c1_ WHERE c1_.id = c0_.spouse_id' - . ')' - ); - } - - public function testExistsExpressionWithSimpleSelectReturningScalar() - { - $this->assertSqlGeneration( - // DQL - // The result of this query consists of all employees whose spouses are also employees. - 'SELECT DISTINCT emp FROM Doctrine\Tests\Models\CMS\CmsEmployee emp - WHERE EXISTS ( - SELECT 1 - FROM Doctrine\Tests\Models\CMS\CmsEmployee spouseEmp - WHERE spouseEmp = emp.spouse)', - // SQL - 'SELECT DISTINCT c0_.id AS id0, c0_.name AS name1 FROM cms_employees c0_' - . ' WHERE EXISTS (' - . 'SELECT 1 AS sclr2 FROM cms_employees c1_ WHERE c1_.id = c0_.spouse_id' - . ')' - ); - } - - public function testLimitFromQueryClass() - { - $q = $this->_em - ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') - ->setMaxResults(10); - - $this->assertEquals('SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ LIMIT 10', $q->getSql()); - } - - public function testLimitAndOffsetFromQueryClass() - { - $q = $this->_em - ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') - ->setMaxResults(10) - ->setFirstResult(0); - - $this->assertEquals('SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ LIMIT 10 OFFSET 0', $q->getSql()); - } - - public function testSizeFunction() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 1" - ); - } - - public function testSizeFunctionSupportsManyToMany() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) > 1", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id) > 1" - ); - } - - public function testEmptyCollectionComparisonExpression() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) = 0" - ); - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS NOT EMPTY", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 0" - ); - } - - public function testNestedExpressions() - { - $this->assertSqlGeneration( - "select u from Doctrine\Tests\Models\CMS\CmsUser u where u.id > 10 and u.id < 42 and ((u.id * 2) > 5)", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.id > 10 AND c0_.id < 42 AND (c0_.id * 2 > 5)" - ); - } - - public function testNestedExpressions2() - { - $this->assertSqlGeneration( - "select u from Doctrine\Tests\Models\CMS\CmsUser u where (u.id > 10) and (u.id < 42 and ((u.id * 2) > 5)) or u.id <> 42", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id < 42 AND (c0_.id * 2 > 5)) OR c0_.id <> 42" - ); - } - - public function testNestedExpressions3() - { - $this->assertSqlGeneration( - "select u from Doctrine\Tests\Models\CMS\CmsUser u where (u.id > 10) and (u.id between 1 and 10 or u.id in (1, 2, 3, 4, 5))", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id BETWEEN 1 AND 10 OR c0_.id IN (1, 2, 3, 4, 5))" - ); - } - - public function testOrderByCollectionAssociationSize() - { - $this->assertSqlGeneration( - "select u, size(u.articles) as numArticles from Doctrine\Tests\Models\CMS\CmsUser u order by numArticles", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT COUNT(*) FROM cms_articles c1_ WHERE c1_.user_id = c0_.id) AS sclr4 FROM cms_users c0_ ORDER BY sclr4 ASC" - ); - } - - public function testOrderBySupportsSingleValuedPathExpressionOwningSide() - { - $this->assertSqlGeneration( - "select a from Doctrine\Tests\Models\CMS\CmsArticle a order by a.user", - "SELECT c0_.id AS id0, c0_.topic AS topic1, c0_.text AS text2, c0_.version AS version3 FROM cms_articles c0_ ORDER BY c0_.user_id ASC" - ); - } - - /** - * @expectedException Doctrine\ORM\Query\QueryException - */ - public function testOrderBySupportsSingleValuedPathExpressionInverseSide() - { - $q = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u order by u.address"); - $q->getSQL(); - } - - public function testBooleanLiteralInWhereOnSqlite() - { - $oldPlat = $this->_em->getConnection()->getDatabasePlatform(); - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SqlitePlatform); - - $this->assertSqlGeneration( - "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true", - "SELECT b0_.id AS id0, b0_.booleanField AS booleanField1 FROM boolean_model b0_ WHERE b0_.booleanField = 1" - ); - - $this->assertSqlGeneration( - "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false", - "SELECT b0_.id AS id0, b0_.booleanField AS booleanField1 FROM boolean_model b0_ WHERE b0_.booleanField = 0" - ); - - $this->_em->getConnection()->setDatabasePlatform($oldPlat); - } - - public function testBooleanLiteralInWhereOnPostgres() - { - $oldPlat = $this->_em->getConnection()->getDatabasePlatform(); - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); - - $this->assertSqlGeneration( - "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true", - "SELECT b0_.id AS id0, b0_.booleanField AS booleanfield1 FROM boolean_model b0_ WHERE b0_.booleanField = true" - ); - - $this->assertSqlGeneration( - "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false", - "SELECT b0_.id AS id0, b0_.booleanField AS booleanfield1 FROM boolean_model b0_ WHERE b0_.booleanField = false" - ); - - $this->_em->getConnection()->setDatabasePlatform($oldPlat); - } - - public function testSingleValuedAssociationFieldInWhere() - { - $this->assertSqlGeneration( - "SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1", - "SELECT c0_.phonenumber AS phonenumber0 FROM cms_phonenumbers c0_ WHERE c0_.user_id = ?" - ); - } - - public function testSingleValuedAssociationNullCheckOnOwningSide() - { - $this->assertSqlGeneration( - "SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.user IS NULL", - "SELECT c0_.id AS id0, c0_.country AS country1, c0_.zip AS zip2, c0_.city AS city3 FROM cms_addresses c0_ WHERE c0_.user_id IS NULL" - ); - } - - // Null check on inverse side has to happen through explicit JOIN. - // "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address IS NULL" - // where the CmsUser is the inverse side is not supported. - public function testSingleValuedAssociationNullCheckOnInverseSide() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.address a WHERE a.id IS NULL", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL" - ); - } - - /** - * @group DDC-339 - * @group DDC-1572 - */ - public function testStringFunctionLikeExpression() - { - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) LIKE '%foo OR bar%'", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE '%foo OR bar%'" - ); - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) LIKE :str", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE ?" - ); - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(UPPER(u.name), '_moo') LIKE :str", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE UPPER(c0_.name) || '_moo' LIKE ?" - ); - - // DDC-1572 - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE UPPER(u.name) LIKE UPPER(:str)", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE UPPER(c0_.name) LIKE UPPER(?)" - ); - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE UPPER(LOWER(u.name)) LIKE UPPER(LOWER(:str))", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE UPPER(LOWER(c0_.name)) LIKE UPPER(LOWER(?))" - ); - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic LIKE u.name", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE c0_.name)" - ); - } - - /** - * @group DDC-1802 - */ - public function testStringFunctionNotLikeExpression() - { - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) NOT LIKE '%foo OR bar%'", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE LOWER(c0_.name) NOT LIKE '%foo OR bar%'" - ); - - $this->assertSqlGeneration( - "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE UPPER(LOWER(u.name)) NOT LIKE UPPER(LOWER(:str))", - "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE UPPER(LOWER(c0_.name)) NOT LIKE UPPER(LOWER(?))" - ); - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic NOT LIKE u.name", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic NOT LIKE c0_.name)" - ); - } - - /** - * @group DDC-338 - */ - public function testOrderedCollectionFetchJoined() - { - $this->assertSqlGeneration( - "SELECT r, l FROM Doctrine\Tests\Models\Routing\RoutingRoute r JOIN r.legs l", - "SELECT r0_.id AS id0, r1_.id AS id1, r1_.departureDate AS departureDate2, r1_.arrivalDate AS arrivalDate3 FROM RoutingRoute r0_ INNER JOIN RoutingRouteLegs r2_ ON r0_.id = r2_.route_id INNER JOIN RoutingLeg r1_ ON r1_.id = r2_.leg_id ". - "ORDER BY r1_.departureDate ASC" - ); - } - - public function testSubselectInSelect() - { - $this->assertSqlGeneration( - "SELECT u.name, (SELECT COUNT(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234) pcount FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'", - "SELECT c0_.name AS name0, (SELECT COUNT(c1_.phonenumber) AS dctrn__1 FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = 1234) AS sclr1 FROM cms_users c0_ WHERE c0_.name = 'jon'" - ); - } - - /** - * @group locking - * @group DDC-178 - */ - public function testPessimisticWriteLockQueryHint() - { - if ($this->_em->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { - $this->markTestSkipped('SqLite does not support Row locking at all.'); - } - - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ". - "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) - ); - } - - /** - * @group locking - * @group DDC-178 - */ - public function testPessimisticReadLockQueryHintPostgreSql() - { - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); - - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ". - "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR SHARE", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) - ); - } - - /** - * @group DDC-1693 - * @group locking - */ - public function testLockModeNoneQueryHint() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ". - "FROM cms_users c0_ WHERE c0_.username = 'gblanco'", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::NONE) - ); - } - - /** - * @group DDC-430 - */ - public function testSupportSelectWithMoreThan10InputParameters() - { - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR u.id = ?2 OR u.id = ?3 OR u.id = ?4 OR u.id = ?5 OR u.id = ?6 OR u.id = ?7 OR u.id = ?8 OR u.id = ?9 OR u.id = ?10 OR u.id = ?11", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ?" - ); - } - - /** - * @group locking - * @group DDC-178 - */ - public function testPessimisticReadLockQueryHintMySql() - { - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); - - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ". - "FROM cms_users c0_ WHERE c0_.username = 'gblanco' LOCK IN SHARE MODE", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) - ); - } - - /** - * @group locking - * @group DDC-178 - */ - public function testPessimisticReadLockQueryHintOracle() - { - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\OraclePlatform); - - $this->assertSqlGeneration( - "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", - "SELECT c0_.id AS ID0, c0_.status AS STATUS1, c0_.username AS USERNAME2, c0_.name AS NAME3 ". - "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) - ); - } - - /** - * @group DDC-431 - */ - public function testSupportToCustomDQLFunctions() - { - $config = $this->_em->getConfiguration(); - $config->addCustomNumericFunction('MYABS', 'Doctrine\Tests\ORM\Query\MyAbsFunction'); - - $this->assertSqlGeneration( - 'SELECT MYABS(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p', - 'SELECT ABS(c0_.phonenumber) AS sclr0 FROM cms_phonenumbers c0_' - ); - - $config->setCustomNumericFunctions(array()); - } - - /** - * @group DDC-826 - */ - public function testMappedSuperclassAssociationJoin() - { - $this->assertSqlGeneration( - 'SELECT f FROM Doctrine\Tests\Models\DirectoryTree\File f JOIN f.parentDirectory d WHERE f.id = ?1', - 'SELECT f0_.id AS id0, f0_.extension AS extension1, f0_.name AS name2 FROM "file" f0_ INNER JOIN Directory d1_ ON f0_.parentDirectory_id = d1_.id WHERE f0_.id = ?' - ); - } - - /** - * @group DDC-1053 - */ - public function testGroupBy() - { - $this->assertSqlGeneration( - 'SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id', - 'SELECT c0_.id AS id0, count(c1_.id) AS sclr1 FROM cms_groups c0_ INNER JOIN cms_users_groups c2_ ON c0_.id = c2_.group_id INNER JOIN cms_users c1_ ON c1_.id = c2_.user_id GROUP BY c0_.id' - ); - } - - /** - * @group DDC-1053 - */ - public function testGroupByIdentificationVariable() - { - $this->assertSqlGeneration( - 'SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g', - 'SELECT c0_.id AS id0, c0_.name AS name1, count(c1_.id) AS sclr2 FROM cms_groups c0_ INNER JOIN cms_users_groups c2_ ON c0_.id = c2_.group_id INNER JOIN cms_users c1_ ON c1_.id = c2_.user_id GROUP BY c0_.id, c0_.name' - ); - } - - public function testCaseContainingNullIf() - { - $this->assertSqlGeneration( - "SELECT NULLIF(g.id, g.name) AS NullIfEqual FROM Doctrine\Tests\Models\CMS\CmsGroup g", - 'SELECT NULLIF(c0_.id, c0_.name) AS sclr0 FROM cms_groups c0_' - ); - } - - public function testCaseContainingCoalesce() - { - $this->assertSqlGeneration( - "SELECT COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u", - "SELECT COALESCE(NULLIF(c0_.name, ''), c0_.username) AS sclr0 FROM cms_users c0_" - ); - } - - /** - * Test that the right discriminator data is inserted in a subquery. - */ - public function testSubSelectDiscriminator() - { - $this->assertSqlGeneration( - "SELECT u.name, (SELECT COUNT(cfc.id) total FROM Doctrine\Tests\Models\Company\CompanyFixContract cfc) as cfc_count FROM Doctrine\Tests\Models\CMS\CmsUser u", - "SELECT c0_.name AS name0, (SELECT COUNT(c1_.id) AS dctrn__total FROM company_contracts c1_ WHERE c1_.discr IN ('fix')) AS sclr1 FROM cms_users c0_" - ); - } - - public function testIdVariableResultVariableReuse() - { - $exceptionThrown = false; - try { - $query = $this->_em->createQuery("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN (SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u)"); - - $query->getSql(); - $query->free(); - } catch (\Exception $e) { - $exceptionThrown = true; - } - - $this->assertTrue($exceptionThrown); - - } - - public function testSubSelectAliasesFromOuterQuery() - { - $this->assertSqlGeneration( - "SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr4 FROM cms_users c0_" - ); - } - - public function testSubSelectAliasesFromOuterQueryWithSubquery() - { - $this->assertSqlGeneration( - "SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id AND ui.name IN (SELECT uii.name FROM Doctrine\Tests\Models\CMS\CmsUser uii)) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id AND c1_.name IN (SELECT c2_.name FROM cms_users c2_)) AS sclr4 FROM cms_users c0_" - ); - } - - public function testSubSelectAliasesFromOuterQueryReuseInWhereClause() - { - $this->assertSqlGeneration( - "SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo WHERE bar = ?0", - "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr4 FROM cms_users c0_ WHERE sclr4 = ?" - ); - } - - /** - * @group DDC-1298 - */ - public function testSelectForeignKeyPKWithoutFields() - { - $this->assertSqlGeneration( - "SELECT t, s, l FROM Doctrine\Tests\Models\DDC117\DDC117Link l INNER JOIN l.target t INNER JOIN l.source s", - "SELECT d0_.article_id AS article_id0, d0_.title AS title1, d1_.article_id AS article_id2, d1_.title AS title3, d2_.source_id AS source_id4, d2_.target_id AS target_id5 FROM DDC117Link d2_ INNER JOIN DDC117Article d0_ ON d2_.target_id = d0_.article_id INNER JOIN DDC117Article d1_ ON d2_.source_id = d1_.article_id" - ); - } - - public function testGeneralCaseWithSingleWhenClause() - { - $this->assertSqlGeneration( - "SELECT g.id, CASE WHEN ((g.id / 2) > 18) THEN 1 ELSE 0 END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT c0_.id AS id0, CASE WHEN (c0_.id / 2 > 18) THEN 1 ELSE 0 END AS sclr1 FROM cms_groups c0_" - ); - } - - public function testGeneralCaseWithMultipleWhenClause() - { - $this->assertSqlGeneration( - "SELECT g.id, CASE WHEN (g.id / 2 < 10) THEN 2 WHEN ((g.id / 2) > 20) THEN 1 ELSE 0 END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT c0_.id AS id0, CASE WHEN (c0_.id / 2 < 10) THEN 2 WHEN (c0_.id / 2 > 20) THEN 1 ELSE 0 END AS sclr1 FROM cms_groups c0_" - ); - } - - public function testSimpleCaseWithSingleWhenClause() - { - $this->assertSqlGeneration( - "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id = CASE g.name WHEN 'admin' THEN 1 ELSE 2 END", - "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id = CASE c0_.name WHEN 'admin' THEN 1 ELSE 2 END" - ); - } - - public function testSimpleCaseWithMultipleWhenClause() - { - $this->assertSqlGeneration( - "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id = (CASE g.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END)", - "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id = CASE c0_.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END" - ); - } - - public function testGeneralCaseWithSingleWhenClauseInSubselect() - { - $this->assertSqlGeneration( - "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE WHEN ((g2.id / 2) > 18) THEN 2 ELSE 1 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", - "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE WHEN (c1_.id / 2 > 18) THEN 2 ELSE 1 END AS sclr2 FROM cms_groups c1_)" - ); - } - - public function testGeneralCaseWithMultipleWhenClauseInSubselect() - { - $this->assertSqlGeneration( - "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE WHEN (g.id / 2 < 10) THEN 3 WHEN ((g.id / 2) > 20) THEN 2 ELSE 1 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", - "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE WHEN (c0_.id / 2 < 10) THEN 3 WHEN (c0_.id / 2 > 20) THEN 2 ELSE 1 END AS sclr2 FROM cms_groups c1_)" - ); - } - - public function testSimpleCaseWithSingleWhenClauseInSubselect() - { - $this->assertSqlGeneration( - "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE g2.name WHEN 'admin' THEN 1 ELSE 2 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", - "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE c1_.name WHEN 'admin' THEN 1 ELSE 2 END AS sclr2 FROM cms_groups c1_)" - ); - } - - public function testSimpleCaseWithMultipleWhenClauseInSubselect() - { - $this->assertSqlGeneration( - "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE g2.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", - "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE c1_.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END AS sclr2 FROM cms_groups c1_)" - ); - } - - /** - * @group DDC-1696 - */ - public function testSimpleCaseWithStringPrimary() - { - $this->assertSqlGeneration( - "SELECT g.id, CASE WHEN ((g.id / 2) > 18) THEN 'Foo' ELSE 'Bar' END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT c0_.id AS id0, CASE WHEN (c0_.id / 2 > 18) THEN 'Foo' ELSE 'Bar' END AS sclr1 FROM cms_groups c0_" - ); - } - - /** - * @group DDC-1339 - */ - public function testIdentityFunctionInSelectClause() - { - $this->assertSqlGeneration( - "SELECT IDENTITY(u.email) as email_id FROM Doctrine\Tests\Models\CMS\CmsUser u", - "SELECT c0_.email_id AS sclr0 FROM cms_users c0_" - ); - } - - /** - * @group DDC-1339 - */ - public function testIdentityFunctionDoesNotAcceptStateField() - { - $this->assertInvalidSqlGeneration( - "SELECT IDENTITY(u.name) as name FROM Doctrine\Tests\Models\CMS\CmsUser u", - "Doctrine\ORM\Query\QueryException" - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeJoinInRootClassWithDisabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', - 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c2_.salary AS salary3, c2_.department AS department4, c2_.startDate AS startDate5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7, c1_.car_id AS car_id8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => false) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeJoinInRootClassWithEnabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', - 'SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_', - array(Query::HINT_FORCE_PARTIAL_LOAD => true) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeJoinInChildClassWithDisabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', - 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c2_.title AS title5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7, c2_.car_id AS car_id8 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => false) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeJoinInChildClassWithEnabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', - 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => true) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeJoinInLeafClassWithDisabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', - 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c2_.title AS title5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7, c2_.car_id AS car_id8 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => false) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeJoinInLeafClassWithEnabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', - 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c2_.title AS title5, c0_.discr AS discr6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => true) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeSingleTableInRootClassWithDisabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', - "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.fixPrice AS fixPrice2, c0_.hoursWorked AS hoursWorked3, c0_.pricePerHour AS pricePerHour4, c0_.maxPrice AS maxPrice5, c0_.discr AS discr6, c0_.salesPerson_id AS salesPerson_id7 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => false) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeSingleTableInRootClassWithEnabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', - "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.fixPrice AS fixPrice2, c0_.hoursWorked AS hoursWorked3, c0_.pricePerHour AS pricePerHour4, c0_.maxPrice AS maxPrice5, c0_.discr AS discr6 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => true) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeSingleTableInChildClassWithDisabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', - "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.hoursWorked AS hoursWorked2, c0_.pricePerHour AS pricePerHour3, c0_.maxPrice AS maxPrice4, c0_.discr AS discr5, c0_.salesPerson_id AS salesPerson_id6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => false) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeSingleTableInChildClassWithEnabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', - "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.hoursWorked AS hoursWorked2, c0_.pricePerHour AS pricePerHour3, c0_.maxPrice AS maxPrice4, c0_.discr AS discr5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => true) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeSingleTableInLeafClassWithDisabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', - "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.hoursWorked AS hoursWorked2, c0_.pricePerHour AS pricePerHour3, c0_.maxPrice AS maxPrice4, c0_.discr AS discr5, c0_.salesPerson_id AS salesPerson_id6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => false) - ); - } - - /** - * @group DDC-1389 - */ - public function testInheritanceTypeSingleTableInLeafClassWithEnabledForcePartialLoad() - { - $this->assertSqlGeneration( - 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', - "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.hoursWorked AS hoursWorked2, c0_.pricePerHour AS pricePerHour3, c0_.maxPrice AS maxPrice4, c0_.discr AS discr5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => true) - ); - } - - /** - * @group DDC-1161 - */ - public function testSelfReferenceWithOneToOneDoesNotDuplicateAlias() - { - $this->assertSqlGeneration( - 'SELECT p, pp FROM Doctrine\Tests\Models\Company\CompanyPerson p JOIN p.spouse pp', - "SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c2_.salary AS salary3, c2_.department AS department4, c2_.startDate AS startDate5, c3_.id AS id6, c3_.name AS name7, c4_.title AS title8, c5_.salary AS salary9, c5_.department AS department10, c5_.startDate AS startDate11, c0_.discr AS discr12, c0_.spouse_id AS spouse_id13, c1_.car_id AS car_id14, c3_.discr AS discr15, c3_.spouse_id AS spouse_id16, c4_.car_id AS car_id17 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id INNER JOIN company_persons c3_ ON c0_.spouse_id = c3_.id LEFT JOIN company_managers c4_ ON c3_.id = c4_.id LEFT JOIN company_employees c5_ ON c3_.id = c5_.id", - array(Query::HINT_FORCE_PARTIAL_LOAD => false) - ); - } - - /** - * @group DDC-1384 - */ - public function testAliasDoesNotExceedPlatformDefinedLength() - { - $this->assertSqlGeneration( - 'SELECT m FROM ' . __NAMESPACE__ . '\\DDC1384Model m', - "SELECT d0_.aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalker_fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo AS fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo0 FROM DDC1384Model d0_" - ); - } - - /** - * @group DDC-331 - * @group DDC-1384 - */ - public function testIssue331() - { - $this->assertSqlGeneration( - 'SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e', - 'SELECT c0_.name AS name0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id' - ); - } - /** - * @group DDC-1435 - */ - public function testForeignKeyAsPrimaryKeySubselect() - { - $this->assertSqlGeneration( - "SELECT s FROM Doctrine\Tests\Models\DDC117\DDC117Article s WHERE EXISTS (SELECT r FROM Doctrine\Tests\Models\DDC117\DDC117Reference r WHERE r.source = s)", - "SELECT d0_.article_id AS article_id0, d0_.title AS title1 FROM DDC117Article d0_ WHERE EXISTS (SELECT d1_.source_id, d1_.target_id FROM DDC117Reference d1_ WHERE d1_.source_id = d0_.article_id)" - ); - } - - /** - * @group DDC-1474 - */ - public function testSelectWithArithmeticExpressionBeforeField() - { - $this->assertSqlGeneration( - 'SELECT - e.value AS value, e.id FROM ' . __NAMESPACE__ . '\DDC1474Entity e', - 'SELECT -d0_.value AS sclr0, d0_.id AS id1 FROM DDC1474Entity d0_' - ); - - $this->assertSqlGeneration( - 'SELECT e.id, + e.value AS value FROM ' . __NAMESPACE__ . '\DDC1474Entity e', - 'SELECT d0_.id AS id0, +d0_.value AS sclr1 FROM DDC1474Entity d0_' - ); - } - - /** - * @group DDC-1430 - */ - public function testGroupByAllFieldsWhenObjectHasForeignKeys() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ GROUP BY c0_.id, c0_.status, c0_.username, c0_.name, c0_.email_id' - ); - - $this->assertSqlGeneration( - 'SELECT e FROM Doctrine\Tests\Models\CMS\CmsEmployee e GROUP BY e', - 'SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_employees c0_ GROUP BY c0_.id, c0_.name, c0_.spouse_id' - ); - } - - /** - * @group DDC-1236 - */ - public function testGroupBySupportsResultVariable() - { - $this->assertSqlGeneration( - 'SELECT u, u.status AS st FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY st', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.status AS status4 FROM cms_users c0_ GROUP BY status4' - ); - } - - /** - * @group DDC-1236 - */ - public function testGroupBySupportsIdentificationVariable() - { - $this->assertSqlGeneration( - 'SELECT u AS user FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY user', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ GROUP BY id0, status1, username2, name3' - ); - } - - /** - * @group DDC-1213 - */ - public function testSupportsBitComparison() - { - $this->assertSqlGeneration( - 'SELECT BIT_OR(4,2), BIT_AND(4,2), u FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT (4 | 2) AS sclr0, (4 & 2) AS sclr1, c0_.id AS id2, c0_.status AS status3, c0_.username AS username4, c0_.name AS name5 FROM cms_users c0_' - ); - $this->assertSqlGeneration( - 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_OR(u.id,2) > 0', - 'SELECT (c0_.id | 2) AS sclr0, (c0_.id & 2) AS sclr1 FROM cms_users c0_ WHERE (c0_.id | 2) > 0' - ); - $this->assertSqlGeneration( - 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_AND(u.id , 4) > 0', - 'SELECT (c0_.id | 2) AS sclr0, (c0_.id & 2) AS sclr1 FROM cms_users c0_ WHERE (c0_.id & 4) > 0' - ); - $this->assertSqlGeneration( - 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_OR(u.id , 2) > 0 OR BIT_AND(u.id , 4) > 0', - 'SELECT (c0_.id | 2) AS sclr0, (c0_.id & 2) AS sclr1 FROM cms_users c0_ WHERE (c0_.id | 2) > 0 OR (c0_.id & 4) > 0' - ); - } - - /** - * @group DDC-1539 - */ - public function testParenthesesOnTheLeftHandOfComparison() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where ( (u.id + u.id) * u.id ) > 100', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id + c0_.id) * c0_.id > 100' - ); - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where (u.id + u.id) * u.id > 100', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id + c0_.id) * c0_.id > 100' - ); - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where 100 < (u.id + u.id) * u.id ', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE 100 < (c0_.id + c0_.id) * c0_.id' - ); - } - - /** - * @group DDC-1557 - */ - public function testSupportsSubSqlFunction() - { - $this->assertSqlGeneration( - 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.name IN ( SELECT TRIM(u2.name) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr4 FROM cms_users c1_)' - ); - $this->assertSqlGeneration( - 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.name IN ( SELECT TRIM(u2.name) FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE LOWER(u2.name) LIKE \'%fabio%\')', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr4 FROM cms_users c1_ WHERE LOWER(c1_.name) LIKE \'%fabio%\')' - ); - $this->assertSqlGeneration( - 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.email IN ( SELECT TRIM(IDENTITY(u2.email)) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT TRIM(c1_.email_id) AS sclr4 FROM cms_users c1_)' - ); - $this->assertSqlGeneration( - 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.email IN ( SELECT IDENTITY(u2.email) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT c1_.email_id AS sclr4 FROM cms_users c1_)' - ); - $this->assertSqlGeneration( - 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE COUNT(u1.id) = ( SELECT SUM(u2.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE COUNT(c0_.id) = (SELECT SUM(c1_.id) AS dctrn__1 FROM cms_users c1_)' - ); - $this->assertSqlGeneration( - 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE COUNT(u1.id) <= ( SELECT SUM(u2.id) + COUNT(u2.email) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE COUNT(c0_.id) <= (SELECT SUM(c1_.id) + COUNT(c1_.email_id) AS sclr4 FROM cms_users c1_)' - ); - } - - public function testCustomTypeValueSql() - { - if (DBALType::hasType('negative_to_positive')) { - DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } else { - DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } - - $this->assertSqlGeneration( - 'SELECT p.customInteger FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p WHERE p.id = 1', - 'SELECT -(c0_.customInteger) AS customInteger0 FROM customtype_parents c0_ WHERE c0_.id = 1' - ); - } - - public function testCustomTypeValueSqlIgnoresIdentifierColumn() - { - if (DBALType::hasType('negative_to_positive')) { - DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } else { - DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } - - $this->assertSqlGeneration( - 'SELECT p.id FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p WHERE p.id = 1', - 'SELECT c0_.id AS id0 FROM customtype_parents c0_ WHERE c0_.id = 1' - ); - } - - public function testCustomTypeValueSqlForAllFields() - { - if (DBALType::hasType('negative_to_positive')) { - DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } else { - DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } - - $this->assertSqlGeneration( - 'SELECT p FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', - 'SELECT c0_.id AS id0, -(c0_.customInteger) AS customInteger1 FROM customtype_parents c0_' - ); - } - - public function testCustomTypeValueSqlForPartialObject() - { - if (DBALType::hasType('negative_to_positive')) { - DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } else { - DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } - - $this->assertSqlGeneration( - 'SELECT partial p.{id, customInteger} FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', - 'SELECT c0_.id AS id0, -(c0_.customInteger) AS customInteger1 FROM customtype_parents c0_' - ); - } - - /** - * @group DDC-1529 - */ - public function testMultipleFromAndInheritanceCondition() - { - $this->assertSqlGeneration( - 'SELECT fix, flex FROM Doctrine\Tests\Models\Company\CompanyFixContract fix, Doctrine\Tests\Models\Company\CompanyFlexContract flex', - "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.fixPrice AS fixPrice2, c1_.id AS id3, c1_.completed AS completed4, c1_.hoursWorked AS hoursWorked5, c1_.pricePerHour AS pricePerHour6, c1_.maxPrice AS maxPrice7, c0_.discr AS discr8, c1_.discr AS discr9 FROM company_contracts c0_, company_contracts c1_ WHERE (c0_.discr IN ('fix') AND c1_.discr IN ('flexible', 'flexultra'))" - ); - } - - /** - * @group DDC-775 - */ - public function testOrderByClauseSupportsSimpleArithmeticExpression() - { - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.id + 1 ', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY c0_.id + 1 ASC' - ); - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY ( ( (u.id + 1) * (u.id - 1) ) / 2)', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY (c0_.id + 1) * (c0_.id - 1) / 2 ASC' - ); - $this->assertSqlGeneration( - 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY ((u.id + 5000) * u.id + 3) ', - 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ ORDER BY (c0_.id + 5000) * c0_.id + 3 ASC' - ); - } - - /** - * @group DDC-1719 - */ - public function testStripNonAlphanumericCharactersFromAlias() - { - $this->assertSqlGeneration( - 'SELECT e FROM Doctrine\Tests\Models\Quote\SimpleEntity e', - 'SELECT d0_."simple-entity-id" AS simpleentityid0, d0_."simple-entity-value" AS simpleentityvalue1 FROM "ddc-1719-simple-entity" d0_' - ); - - $this->assertSqlGeneration( - 'SELECT e.value FROM Doctrine\Tests\Models\Quote\SimpleEntity e ORDER BY e.value', - 'SELECT d0_."simple-entity-value" AS simpleentityvalue0 FROM "ddc-1719-simple-entity" d0_ ORDER BY d0_."simple-entity-value" ASC' - ); - - $this->assertSqlGeneration( - 'SELECT TRIM(e.value) FROM Doctrine\Tests\Models\Quote\SimpleEntity e ORDER BY e.value', - 'SELECT TRIM(d0_."simple-entity-value") AS sclr0 FROM "ddc-1719-simple-entity" d0_ ORDER BY d0_."simple-entity-value" ASC' - ); - } - - /** - * @group DDC-1845 - */ - public function testQuotedWalkJoinVariableDeclaration() - { - $this->assertSqlGeneration( - 'SELECT u, a FROM Doctrine\Tests\Models\Quote\User u JOIN u.address a', - 'SELECT q0_."user-id" AS userid0, q0_."user-name" AS username1, q1_."address-id" AS addressid2, q1_."address-zip" AS addresszip3 FROM "quote-user" q0_ INNER JOIN "quote-address" q1_ ON q0_."address-id" = q1_."address-id"' - ); - - $this->assertSqlGeneration( - 'SELECT u, p FROM Doctrine\Tests\Models\Quote\User u JOIN u.phones p', - 'SELECT q0_."user-id" AS userid0, q0_."user-name" AS username1, q1_."phone-number" AS phonenumber2 FROM "quote-user" q0_ INNER JOIN "quote-phone" q1_ ON q0_."user-id" = q1_."user-id"' - ); - - $this->assertSqlGeneration( - 'SELECT u, g FROM Doctrine\Tests\Models\Quote\User u JOIN u.groups g', - 'SELECT q0_."user-id" AS userid0, q0_."user-name" AS username1, q1_."group-id" AS groupid2, q1_."group-name" AS groupname3 FROM "quote-user" q0_ INNER JOIN "quote-users-groups" q2_ ON q0_."user-id" = q2_."user-id" INNER JOIN "quote-group" q1_ ON q1_."group-id" = q2_."group-id"' - ); - - $this->assertSqlGeneration( - 'SELECT a, u FROM Doctrine\Tests\Models\Quote\Address a JOIN a.user u', - 'SELECT q0_."address-id" AS addressid0, q0_."address-zip" AS addresszip1, q1_."user-id" AS userid2, q1_."user-name" AS username3 FROM "quote-address" q0_ INNER JOIN "quote-user" q1_ ON q0_."user-id" = q1_."user-id"' - ); - - $this->assertSqlGeneration( - 'SELECT g, u FROM Doctrine\Tests\Models\Quote\Group g JOIN g.users u', - 'SELECT q0_."group-id" AS groupid0, q0_."group-name" AS groupname1, q1_."user-id" AS userid2, q1_."user-name" AS username3 FROM "quote-group" q0_ INNER JOIN "quote-users-groups" q2_ ON q0_."group-id" = q2_."group-id" INNER JOIN "quote-user" q1_ ON q1_."user-id" = q2_."user-id"' - ); - - $this->assertSqlGeneration( - 'SELECT g, p FROM Doctrine\Tests\Models\Quote\Group g JOIN g.parent p', - 'SELECT q0_."group-id" AS groupid0, q0_."group-name" AS groupname1, q1_."group-id" AS groupid2, q1_."group-name" AS groupname3 FROM "quote-group" q0_ INNER JOIN "quote-group" q1_ ON q0_."parent-id" = q1_."group-id"' - ); - } -} - -class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode -{ - public $simpleArithmeticExpression; - - /** - * @override - */ - public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) - { - return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) . ')'; - } - - /** - * @override - */ - public function parse(\Doctrine\ORM\Query\Parser $parser) - { - $lexer = $parser->getLexer(); - - $parser->match(\Doctrine\ORM\Query\Lexer::T_IDENTIFIER); - $parser->match(\Doctrine\ORM\Query\Lexer::T_OPEN_PARENTHESIS); - - $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - - $parser->match(\Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS); - } -} -/** - * @Entity - */ -class DDC1384Model -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - protected $aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalker_fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; -} - - -/** - * @Entity - */ -class DDC1474Entity -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue() - */ - protected $id; - - /** - * @column(type="float") - */ - private $value; - - /** - * @param string $float - */ - public function __construct($float) - { - $this->value = $float; - } - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * @return float - */ - public function getValue() - { - return $this->value; - } - - /** - * @param float $value - */ - public function setValue($value) - { - $this->value = $value; - } - -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php deleted file mode 100755 index a65efe079c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ /dev/null @@ -1,205 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Query; - -use Doctrine\DBAL\Types\Type as DBALType; - -require_once __DIR__ . '/../../TestInit.php'; - -/** - * Test case for testing the saving and referencing of query identifiers. - * - * @author Guilherme Blanco - * @author Janne Vanhala - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link http://www.phpdoctrine.org - * @since 2.0 - * @version $Revision$ - * @todo 1) [romanb] We might want to split the SQL generation tests into multiple - * testcases later since we'll have a lot of them and we might want to have special SQL - * generation tests for some dbms specific SQL syntaxes. - */ -class UpdateSqlGenerationTest extends \Doctrine\Tests\OrmTestCase -{ - private $_em; - - protected function setUp() { - if (DBALType::hasType('negative_to_positive')) { - DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } else { - DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); - } - - $this->_em = $this->_getTestEntityManager(); - } - - public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed) - { - try { - $query = $this->_em->createQuery($dqlToBeTested); - parent::assertEquals($sqlToBeConfirmed, $query->getSql()); - $query->free(); - } catch (\Exception $e) { - $this->fail($e->getMessage()); - } - } - - public function testSupportsQueriesWithoutWhere() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1', - 'UPDATE cms_users SET name = ?' - ); - } - - public function testSupportsMultipleFieldsWithoutWhere() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1, u.username = ?2', - 'UPDATE cms_users SET name = ?, username = ?' - ); - } - - public function testSupportsWhereClauses() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id = ?2', - 'UPDATE cms_users SET name = ? WHERE id = ?' - ); - } - - public function testSupportsWhereClausesOnTheUpdatedField() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.name = ?2', - 'UPDATE cms_users SET name = ? WHERE name = ?' - ); - } - - public function testSupportsMultipleWhereClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.name = ?2 AND u.status = ?3', - 'UPDATE cms_users SET name = ? WHERE name = ? AND status = ?' - ); - } - - public function testSupportsInClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id IN (1, 3, 4)', - 'UPDATE cms_users SET name = ? WHERE id IN (1, 3, 4)' - ); - } - - public function testSupportsParametrizedInClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id IN (?2, ?3, ?4)', - 'UPDATE cms_users SET name = ? WHERE id IN (?, ?, ?)' - ); - } - - public function testSupportsNotInClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id NOT IN (1, 3, 4)', - 'UPDATE cms_users SET name = ? WHERE id NOT IN (1, 3, 4)' - ); - } - - public function testSupportsGreatherThanClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id > ?2', - 'UPDATE cms_users SET status = ? WHERE id > ?' - ); - } - - public function testSupportsGreatherThanOrEqualToClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id >= ?2', - 'UPDATE cms_users SET status = ? WHERE id >= ?' - ); - } - - public function testSupportsLessThanClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id < ?2', - 'UPDATE cms_users SET status = ? WHERE id < ?' - ); - } - - public function testSupportsLessThanOrEqualToClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id <= ?2', - 'UPDATE cms_users SET status = ? WHERE id <= ?' - ); - } - - public function testSupportsBetweenClause() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id BETWEEN :from AND :to', - 'UPDATE cms_users SET status = ? WHERE id BETWEEN ? AND ?' - ); - } - - public function testSingleValuedAssociationFieldInWhere() - { - $this->assertSqlGeneration( - "UPDATE Doctrine\Tests\Models\CMS\CmsPhonenumber p SET p.phonenumber = 1234 WHERE p.user = ?1", - "UPDATE cms_phonenumbers SET phonenumber = 1234 WHERE user_id = ?" - ); - } - - public function testSingleValuedAssociationFieldInSetClause() - { - $this->assertSqlGeneration( - "update Doctrine\Tests\Models\CMS\CmsComment c set c.article = null where c.article=?1", - "UPDATE cms_comments SET article_id = NULL WHERE article_id = ?" - ); - } - - /** - * @group DDC-980 - */ - public function testSubselectTableAliasReferencing() - { - $this->assertSqlGeneration( - "UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = 'inactive' WHERE SIZE(u.groups) = 10", - "UPDATE cms_users SET status = 'inactive' WHERE (SELECT COUNT(*) FROM cms_users_groups c0_ WHERE c0_.user_id = cms_users.id) = 10" - ); - } - - public function testCustomTypeValueSqlCompletelyIgnoredInUpdateStatements() - { - $this->assertSqlGeneration( - 'UPDATE Doctrine\Tests\Models\CustomType\CustomTypeParent p SET p.customInteger = 1 WHERE p.id = 1', - 'UPDATE customtype_parents SET customInteger = 1 WHERE id = 1' - ); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/QueryBuilderTest.php deleted file mode 100755 index 7398d2e88c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ /dev/null @@ -1,797 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM; - -use Doctrine\Common\Collections\ArrayCollection; - -use Doctrine\ORM\QueryBuilder, - Doctrine\ORM\Query\Expr, - Doctrine\ORM\Query\Parameter, - Doctrine\ORM\Query\ParameterTypeInferer; - -require_once __DIR__ . '/../TestInit.php'; - -/** - * Test case for the QueryBuilder class used to build DQL query string in a - * object oriented way. - * - * @author Jonathan H. Wage - * @author Roman Borschel _em = $this->_getTestEntityManager(); - } - - protected function assertValidQueryBuilder(QueryBuilder $qb, $expectedDql) - { - $dql = $qb->getDql(); - $q = $qb->getQuery(); - - $this->assertEquals($expectedDql, $dql); - } - - public function testSelectSetsType() - { - $qb = $this->_em->createQueryBuilder() - ->delete('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->select('u.id', 'u.username'); - - $this->assertEquals($qb->getType(), QueryBuilder::SELECT); - } - - public function testEmptySelectSetsType() - { - $qb = $this->_em->createQueryBuilder() - ->delete('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->select(); - - $this->assertEquals($qb->getType(), QueryBuilder::SELECT); - } - - public function testDeleteSetsType() - { - $qb = $this->_em->createQueryBuilder() - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->delete(); - - $this->assertEquals($qb->getType(), QueryBuilder::DELETE); - } - - public function testUpdateSetsType() - { - $qb = $this->_em->createQueryBuilder() - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->update(); - - $this->assertEquals($qb->getType(), QueryBuilder::UPDATE); - } - - public function testSimpleSelect() - { - $qb = $this->_em->createQueryBuilder() - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->select('u.id', 'u.username'); - - $this->assertValidQueryBuilder($qb, 'SELECT u.id, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testSimpleDelete() - { - $qb = $this->_em->createQueryBuilder() - ->delete('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - - $this->assertValidQueryBuilder($qb, 'DELETE Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testSimpleUpdate() - { - $qb = $this->_em->createQueryBuilder() - ->update('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->set('u.username', ':username'); - - $this->assertValidQueryBuilder($qb, 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.username = :username'); - } - - public function testInnerJoin() - { - $qb = $this->_em->createQueryBuilder() - ->select('u', 'a') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->innerJoin('u.articles', 'a'); - - $this->assertValidQueryBuilder($qb, 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a'); - } - - public function testComplexInnerJoin() - { - $qb = $this->_em->createQueryBuilder() - ->select('u', 'a') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->innerJoin('u.articles', 'a', 'ON', 'u.id = a.author_id'); - - $this->assertValidQueryBuilder( - $qb, - 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id' - ); - } - - public function testComplexInnerJoinWithIndexBy() - { - $qb = $this->_em->createQueryBuilder() - ->select('u', 'a') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->innerJoin('u.articles', 'a', 'ON', 'u.id = a.author_id', 'a.name'); - - $this->assertValidQueryBuilder( - $qb, - 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INDEX BY a.name ON u.id = a.author_id' - ); - } - - public function testLeftJoin() - { - $qb = $this->_em->createQueryBuilder() - ->select('u', 'a') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->leftJoin('u.articles', 'a'); - - $this->assertValidQueryBuilder($qb, 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a'); - } - - public function testLeftJoinWithIndexBy() - { - $qb = $this->_em->createQueryBuilder() - ->select('u', 'a') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->leftJoin('u.articles', 'a', null, null, 'a.name'); - - $this->assertValidQueryBuilder($qb, 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a INDEX BY a.name'); - } - - public function testMultipleFrom() - { - $qb = $this->_em->createQueryBuilder() - ->select('u', 'g') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->from('Doctrine\Tests\Models\CMS\CmsGroup', 'g'); - - $this->assertValidQueryBuilder($qb, 'SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsGroup g'); - } - - public function testMultipleFromWithJoin() - { - $qb = $this->_em->createQueryBuilder() - ->select('u', 'g') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->from('Doctrine\Tests\Models\CMS\CmsGroup', 'g') - ->innerJoin('u.articles', 'a', 'ON', 'u.id = a.author_id'); - - $this->assertValidQueryBuilder($qb, 'SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id, Doctrine\Tests\Models\CMS\CmsGroup g'); - } - - public function testMultipleFromWithMultipleJoin() - { - $qb = $this->_em->createQueryBuilder() - ->select('u', 'g') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->from('Doctrine\Tests\Models\CMS\CmsArticle', 'a') - ->innerJoin('u.groups', 'g') - ->leftJoin('u.address', 'ad') - ->innerJoin('a.comments', 'c'); - - $this->assertValidQueryBuilder($qb, 'SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g LEFT JOIN u.address ad, Doctrine\Tests\Models\CMS\CmsArticle a INNER JOIN a.comments c'); - } - - public function testWhere() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid'); - } - - public function testComplexAndWhere() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid OR u.id = :uid2 OR u.id = :uid3') - ->andWhere('u.name = :name'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid OR u.id = :uid2 OR u.id = :uid3) AND u.name = :name'); - } - - public function testAndWhere() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid') - ->andWhere('u.id = :uid2'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id = :uid2'); - } - - public function testOrWhere() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid') - ->orWhere('u.id = :uid2'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid OR u.id = :uid2'); - } - - public function testComplexAndWhereOrWhereNesting() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid') - ->orWhere('u.id = :uid2') - ->andWhere('u.id = :uid3') - ->orWhere('u.name = :name1', 'u.name = :name2') - ->andWhere('u.name <> :noname'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (((u.id = :uid OR u.id = :uid2) AND u.id = :uid3) OR u.name = :name1 OR u.name = :name2) AND u.name <> :noname'); - } - - public function testAndWhereIn() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid') - ->andWhere($qb->expr()->in('u.id', array(1, 2, 3))); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id IN(1, 2, 3)'); - } - - public function testOrWhereIn() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid') - ->orWhere($qb->expr()->in('u.id', array(1, 2, 3))); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid OR u.id IN(1, 2, 3)'); - } - - public function testAndWhereNotIn() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid') - ->andWhere($qb->expr()->notIn('u.id', array(1, 2, 3))); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id NOT IN(1, 2, 3)'); - } - - public function testOrWhereNotIn() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid') - ->orWhere($qb->expr()->notIn('u.id', array(1, 2, 3))); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid OR u.id NOT IN(1, 2, 3)'); - } - - public function testGroupBy() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->groupBy('u.id') - ->addGroupBy('u.username'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id, u.username'); - } - - public function testHaving() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->groupBy('u.id') - ->having('COUNT(u.id) > 1'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id HAVING COUNT(u.id) > 1'); - } - - public function testAndHaving() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->groupBy('u.id') - ->having('COUNT(u.id) > 1') - ->andHaving('COUNT(u.id) < 1'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id HAVING COUNT(u.id) > 1 AND COUNT(u.id) < 1'); - } - - public function testOrHaving() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->groupBy('u.id') - ->having('COUNT(u.id) > 1') - ->andHaving('COUNT(u.id) < 1') - ->orHaving('COUNT(u.id) > 1'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id HAVING (COUNT(u.id) > 1 AND COUNT(u.id) < 1) OR COUNT(u.id) > 1'); - } - - public function testOrderBy() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->orderBy('u.username', 'ASC'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username ASC'); - } - - public function testOrderByWithExpression() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->orderBy($qb->expr()->asc('u.username')); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username ASC'); - } - - public function testAddOrderBy() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->orderBy('u.username', 'ASC') - ->addOrderBy('u.username', 'DESC'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username ASC, u.username DESC'); - } - - public function testGetQuery() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $q = $qb->getQuery(); - - $this->assertEquals('Doctrine\ORM\Query', get_class($q)); - } - - public function testSetParameter() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :id') - ->setParameter('id', 1); - - $parameter = new Parameter('id', 1, ParameterTypeInferer::inferType(1)); - - $this->assertEquals($parameter, $qb->getParameter('id')); - } - - public function testSetParameters() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($qb->expr()->orx('u.username = :username', 'u.username = :username2')); - - $parameters = new ArrayCollection(); - $parameters->add(new Parameter('username', 'jwage')); - $parameters->add(new Parameter('username2', 'jonwage')); - - $qb->setParameters($parameters); - - $this->assertEquals($parameters, $qb->getQuery()->getParameters()); - } - - - public function testGetParameters() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :id'); - - $parameters = new ArrayCollection(); - $parameters->add(new Parameter('id', 1)); - - $qb->setParameters($parameters); - - $this->assertEquals($parameters, $qb->getParameters()); - } - - public function testGetParameter() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :id'); - - $parameters = new ArrayCollection(); - $parameters->add(new Parameter('id', 1)); - - $qb->setParameters($parameters); - - $this->assertEquals($parameters->first(), $qb->getParameter('id')); - } - - public function testMultipleWhere() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.id = :uid', 'u.id = :uid2'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id = :uid2'); - } - - public function testMultipleAndWhere() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->andWhere('u.id = :uid', 'u.id = :uid2'); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id = :uid2'); - } - - public function testMultipleOrWhere() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->orWhere('u.id = :uid', $qb->expr()->eq('u.id', ':uid2')); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid OR u.id = :uid2'); - } - - public function testComplexWhere() - { - $qb = $this->_em->createQueryBuilder(); - $orExpr = $qb->expr()->orX(); - $orExpr->add($qb->expr()->eq('u.id', ':uid3')); - $orExpr->add($qb->expr()->in('u.id', array(1))); - - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($orExpr); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid3 OR u.id IN(1)'); - } - - public function testWhereInWithStringLiterals() - { - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($qb->expr()->in('u.name', array('one', 'two', 'three'))); - - $this->assertValidQueryBuilder($qb, "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN('one', 'two', 'three')"); - - $qb->where($qb->expr()->in('u.name', array("O'Reilly", "O'Neil", 'Smith'))); - - $this->assertValidQueryBuilder($qb, "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN('O''Reilly', 'O''Neil', 'Smith')"); - } - - public function testWhereInWithObjectLiterals() - { - $qb = $this->_em->createQueryBuilder(); - $expr = $this->_em->getExpressionBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($expr->in('u.name', array($expr->literal('one'), $expr->literal('two'), $expr->literal('three')))); - - $this->assertValidQueryBuilder($qb, "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN('one', 'two', 'three')"); - - $qb->where($expr->in('u.name', array($expr->literal("O'Reilly"), $expr->literal("O'Neil"), $expr->literal('Smith')))); - - $this->assertValidQueryBuilder($qb, "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN('O''Reilly', 'O''Neil', 'Smith')"); - } - - public function testNegation() - { - $expr = $this->_em->getExpressionBuilder(); - $orExpr = $expr->orX(); - $orExpr->add($expr->eq('u.id', ':uid3')); - $orExpr->add($expr->not($expr->in('u.id', array(1)))); - - $qb = $this->_em->createQueryBuilder(); - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($orExpr); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid3 OR NOT(u.id IN(1))'); - } - - public function testSomeAllAny() - { - $qb = $this->_em->createQueryBuilder(); - $expr = $this->_em->getExpressionBuilder(); - - //$subquery = $qb->subquery('Doctrine\Tests\Models\CMS\CmsArticle', 'a')->select('a.id'); - - $qb->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($expr->gt('u.id', $expr->all('select a.id from Doctrine\Tests\Models\CMS\CmsArticle a'))); - - $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ALL(select a.id from Doctrine\Tests\Models\CMS\CmsArticle a)'); - - } - - public function testMultipleIsolatedQueryConstruction() - { - $qb = $this->_em->createQueryBuilder(); - $expr = $this->_em->getExpressionBuilder(); - - $qb->select('u')->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - $qb->where($expr->eq('u.name', ':name')); - $qb->setParameter('name', 'romanb'); - - $q1 = $qb->getQuery(); - - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name', $q1->getDql()); - $this->assertEquals(1, count($q1->getParameters())); - - // add another condition and construct a second query - $qb->andWhere($expr->eq('u.id', ':id')); - $qb->setParameter('id', 42); - - $q2 = $qb->getQuery(); - - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name AND u.id = :id', $q2->getDql()); - $this->assertTrue($q1 !== $q2); // two different, independent queries - $this->assertEquals(2, count($q2->getParameters())); - $this->assertEquals(1, count($q1->getParameters())); // $q1 unaffected - } - - public function testGetEntityManager() - { - $qb = $this->_em->createQueryBuilder(); - $this->assertEquals($this->_em, $qb->getEntityManager()); - } - - public function testInitialStateIsClean() - { - $qb = $this->_em->createQueryBuilder(); - $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); - } - - public function testAlteringQueryChangesStateToDirty() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - - $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); - } - - public function testSelectWithFuncExpression() - { - $qb = $this->_em->createQueryBuilder(); - $expr = $qb->expr(); - $qb->select($expr->count('e.id')); - - $this->assertValidQueryBuilder($qb, 'SELECT COUNT(e.id)'); - } - - public function testResetDQLPart() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.username = ?1')->orderBy('u.username'); - - $this->assertEquals('u.username = ?1', (string)$qb->getDQLPart('where')); - $this->assertEquals(1, count($qb->getDQLPart('orderBy'))); - - $qb->resetDqlPart('where')->resetDqlPart('orderBy'); - - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); - } - - public function testResetDQLParts() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.username = ?1')->orderBy('u.username'); - - $qb->resetDQLParts(array('where', 'orderBy')); - - $this->assertEquals(1, count($qb->getDQLPart('select'))); - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); - } - - public function testResetAllDQLParts() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where('u.username = ?1')->orderBy('u.username'); - - $qb->resetDQLParts(); - - $this->assertEquals(0, count($qb->getDQLPart('select'))); - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); - } - - /** - * @group DDC-867 - */ - public function testDeepClone() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->andWhere('u.username = ?1') - ->andWhere('u.status = ?2'); - - $expr = $qb->getDQLPart('where'); - $this->assertEquals(2, $expr->count(), "Modifying the second query should affect the first one."); - - $qb2 = clone $qb; - $qb2->andWhere('u.name = ?3'); - - $this->assertEquals(2, $expr->count(), "Modifying the second query should affect the first one."); - } - - /** - * @group DDC-1933 - */ - public function testParametersAreCloned() - { - $originalQb = new QueryBuilder($this->_em); - - $originalQb->setParameter('parameter1', 'value1'); - - $copy = clone $originalQb; - $copy->setParameter('parameter2', 'value2'); - - $this->assertCount(1, $originalQb->getParameters()); - $this->assertSame('value1', $copy->getParameter('parameter1')->getValue()); - $this->assertSame('value2', $copy->getParameter('parameter2')->getValue()); - } - - public function testGetRootAlias() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - - $this->assertEquals('u', $qb->getRootAlias()); - } - - public function testGetRootAliases() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - - $this->assertEquals(array('u'), $qb->getRootAliases()); - } - - public function testGetRootEntities() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - - $this->assertEquals(array('Doctrine\Tests\Models\CMS\CmsUser'), $qb->getRootEntities()); - } - - public function testGetSeveralRootAliases() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u2'); - - $this->assertEquals(array('u', 'u2'), $qb->getRootAliases()); - $this->assertEquals('u', $qb->getRootAlias()); - } - - public function testBCAddJoinWithoutRootAlias() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->add('join', array('INNER JOIN u.groups g'), true); - - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL()); - } - - /** - * @group DDC-1211 - */ - public function testEmptyStringLiteral() - { - $expr = $this->_em->getExpressionBuilder(); - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($expr->eq('u.username', $expr->literal(""))); - - $this->assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL()); - } - - /** - * @group DDC-1211 - */ - public function testEmptyNumericLiteral() - { - $expr = $this->_em->getExpressionBuilder(); - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($expr->eq('u.username', $expr->literal(0))); - - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL()); - } - - /** - * @group DDC-1227 - */ - public function testAddFromString() - { - $qb = $this->_em->createQueryBuilder() - ->add('select', 'u') - ->add('from', 'Doctrine\Tests\Models\CMS\CmsUser u'); - - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); - } - - /** - * @group DDC-1619 - */ - public function testAddDistinct() - { - $qb = $this->_em->createQueryBuilder() - ->select('u') - ->distinct() - ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); - - $this->assertEquals('SELECT DISTINCT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php deleted file mode 100755 index a17073162c..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php +++ /dev/null @@ -1,23 +0,0 @@ -getMock('Doctrine\ORM\Tools\EntityGenerator'); - $metadataExporter = $this->getMock('Doctrine\ORM\Tools\Export\ClassMetadataExporter'); - $command = new ConvertDoctrine1SchemaCommand(); - $command->setEntityGenerator($entityGenerator); - - $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $output->expects($this->once()) - ->method('write') - ->with($this->equalTo('No Metadata Classes to process.' . PHP_EOL)); - - $command->convertDoctrine1Schema($this->_getTestEntityManager(), array(), sys_get_temp_dir(), 'annotation', 4, null, $output); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php deleted file mode 100755 index c0af3a7f30..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php +++ /dev/null @@ -1,108 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Tools; - -use Doctrine\ORM\Tools\Export\ClassMetadataExporter; -use Doctrine\ORM\Tools\ConvertDoctrine1Schema; -use Doctrine\Tests\Mocks\MetadataDriverMock; -use Doctrine\Tests\Mocks\DatabasePlatformMock; -use Doctrine\Tests\Mocks\EntityManagerMock; -use Doctrine\Tests\Mocks\ConnectionMock; -use Doctrine\Tests\Mocks\DriverMock; -use Doctrine\Common\EventManager; -use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; - -require_once __DIR__ . '/../../TestInit.php'; - -/** - * Test case for converting a Doctrine 1 style schema to Doctrine 2 mapping files - * - * @author Jonathan H. Wage - * @author Roman Borschel setProxyDir(__DIR__ . '/../../Proxies'); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $eventManager = new EventManager(); - $conn = new ConnectionMock(array(), $driverMock, $config, $eventManager); - $mockDriver = new MetadataDriverMock(); - $config->setMetadataDriverImpl($metadataDriver); - - return EntityManagerMock::create($conn, $config, $eventManager); - } - - public function testTest() - { - if ( ! class_exists('Symfony\Component\Yaml\Yaml', true)) { - $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); - } - - $cme = new ClassMetadataExporter(); - $converter = new ConvertDoctrine1Schema(__DIR__ . '/doctrine1schema'); - - $exporter = $cme->getExporter('yml', __DIR__ . '/convert'); - $exporter->setOverwriteExistingFiles(true); - $exporter->setMetadata($converter->getMetadata()); - $exporter->export(); - - $this->assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml')); - $this->assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml')); - - $metadataDriver = new \Doctrine\ORM\Mapping\Driver\YamlDriver(__DIR__ . '/convert'); - $em = $this->_createEntityManager($metadataDriver); - $cmf = new DisconnectedClassMetadataFactory(); - $cmf->setEntityManager($em); - $metadata = $cmf->getAllMetadata(); - $profileClass = $cmf->getMetadataFor('Profile'); - $userClass = $cmf->getMetadataFor('User'); - - $this->assertEquals(2, count($metadata)); - $this->assertEquals('Profile', $profileClass->name); - $this->assertEquals('User', $userClass->name); - $this->assertEquals(4, count($profileClass->fieldMappings)); - $this->assertEquals(5, count($userClass->fieldMappings)); - $this->assertEquals('text', $userClass->fieldMappings['clob']['type']); - $this->assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']); - $this->assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']); - - $this->assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']); - $this->assertEquals('User', $profileClass->associationMappings['User']['targetEntity']); - - $this->assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]); - } - - public function tearDown() - { - @unlink(__DIR__ . '/convert/User.dcm.yml'); - @unlink(__DIR__ . '/convert/Profile.dcm.yml'); - @rmdir(__DIR__ . '/convert'); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php deleted file mode 100755 index d8dfa1b566..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ /dev/null @@ -1,590 +0,0 @@ -_namespace = uniqid("doctrine_"); - $this->_tmpDir = \sys_get_temp_dir(); - \mkdir($this->_tmpDir . \DIRECTORY_SEPARATOR . $this->_namespace); - $this->_generator = new EntityGenerator(); - $this->_generator->setAnnotationPrefix(""); - $this->_generator->setGenerateAnnotations(true); - $this->_generator->setGenerateStubMethods(true); - $this->_generator->setRegenerateEntityIfExists(false); - $this->_generator->setUpdateEntityIfExists(true); - $this->_generator->setFieldVisibility(EntityGenerator::FIELD_VISIBLE_PROTECTED); - } - - public function tearDown() - { - $ri = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->_tmpDir . '/' . $this->_namespace)); - foreach ($ri AS $file) { - /* @var $file \SplFileInfo */ - if ($file->isFile()) { - \unlink($file->getPathname()); - } - } - rmdir($this->_tmpDir . '/' . $this->_namespace); - } - - public function generateBookEntityFixture() - { - $metadata = new ClassMetadataInfo($this->_namespace . '\EntityGeneratorBook'); - $metadata->namespace = $this->_namespace; - $metadata->customRepositoryClassName = $this->_namespace . '\EntityGeneratorBookRepository'; - - $metadata->table['name'] = 'book'; - $metadata->table['uniqueConstraints']['name_uniq'] = array('columns' => array('name')); - $metadata->table['indexes']['status_idx'] = array('columns' => array('status')); - $metadata->mapField(array('fieldName' => 'name', 'type' => 'string')); - $metadata->mapField(array('fieldName' => 'status', 'type' => 'string', 'default' => 'published')); - $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); - $metadata->mapOneToOne(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', 'mappedBy' => 'book')); - $joinColumns = array( - array('name' => 'author_id', 'referencedColumnName' => 'id') - ); - $metadata->mapManyToMany(array( - 'fieldName' => 'comments', - 'targetEntity' => 'Doctrine\Tests\ORM\Tools\EntityGeneratorComment', - 'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY, - 'joinTable' => array( - 'name' => 'book_comment', - 'joinColumns' => array(array('name' => 'book_id', 'referencedColumnName' => 'id')), - 'inverseJoinColumns' => array(array('name' => 'comment_id', 'referencedColumnName' => 'id')), - ), - )); - $metadata->addLifecycleCallback('loading', 'postLoad'); - $metadata->addLifecycleCallback('willBeRemoved', 'preRemove'); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - - $this->_generator->writeEntityClass($metadata, $this->_tmpDir); - - return $metadata; - } - - private function generateEntityTypeFixture(array $field) - { - $metadata = new ClassMetadataInfo($this->_namespace . '\EntityType'); - $metadata->namespace = $this->_namespace; - - $metadata->table['name'] = 'entity_type'; - $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - - $name = $field['fieldName']; - $type = $field['dbType']; - $metadata->mapField(array('fieldName' => $name, 'type' => $type)); - - $this->_generator->writeEntityClass($metadata, $this->_tmpDir); - - return $metadata; - } - - /** - * @param ClassMetadataInfo $metadata - * @return EntityGeneratorBook - */ - public function newInstance($metadata) - { - $path = $this->_tmpDir . '/'. $this->_namespace . '/EntityGeneratorBook.php'; - $this->assertFileExists($path); - require_once $path; - - return new $metadata->name; - } - - public function testGeneratedEntityClass() - { - $metadata = $this->generateBookEntityFixture(); - - $book = $this->newInstance($metadata); - $this->assertTrue(class_exists($metadata->name), "Class does not exist."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', '__construct'), "EntityGeneratorBook::__construct() missing."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getId'), "EntityGeneratorBook::getId() missing."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setName'), "EntityGeneratorBook::setName() missing."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getName'), "EntityGeneratorBook::getName() missing."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), "EntityGeneratorBook::setAuthor() missing."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), "EntityGeneratorBook::getAuthor() missing."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), "EntityGeneratorBook::getComments() missing."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addComment'), "EntityGeneratorBook::addComment() missing."); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'removeComment'), "EntityGeneratorBook::removeComment() missing."); - - $this->assertEquals('published', $book->getStatus()); - - $book->setName('Jonathan H. Wage'); - $this->assertEquals('Jonathan H. Wage', $book->getName()); - - $author = new EntityGeneratorAuthor(); - $book->setAuthor($author); - $this->assertEquals($author, $book->getAuthor()); - - $comment = new EntityGeneratorComment(); - $book->addComment($comment); - $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $book->getComments()); - $this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(array($comment)), $book->getComments()); - $book->removeComment($comment); - $this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(array()), $book->getComments()); - } - - public function testEntityUpdatingWorks() - { - $metadata = $this->generateBookEntityFixture(); - $metadata->mapField(array('fieldName' => 'test', 'type' => 'string')); - - $this->_generator->writeEntityClass($metadata, $this->_tmpDir); - - $this->assertFileExists($this->_tmpDir . "/" . $this->_namespace . "/EntityGeneratorBook.php~"); - - $book = $this->newInstance($metadata); - $reflClass = new \ReflectionClass($metadata->name); - - $this->assertTrue($reflClass->hasProperty('name'), "Regenerating keeps property 'name'."); - $this->assertTrue($reflClass->hasProperty('status'), "Regenerating keeps property 'status'."); - $this->assertTrue($reflClass->hasProperty('id'), "Regenerating keeps property 'id'."); - - $this->assertTrue($reflClass->hasProperty('test'), "Check for property test failed."); - $this->assertTrue($reflClass->getProperty('test')->isProtected(), "Check for protected property test failed."); - $this->assertTrue($reflClass->hasMethod('getTest'), "Check for method 'getTest' failed."); - $this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); - $this->assertTrue($reflClass->hasMethod('setTest'), "Check for method 'getTest' failed."); - $this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); - } - - /** - * @group DDC-2121 - */ - public function testMethodDocBlockShouldStartWithBackSlash() - { - $metadata = $this->generateBookEntityFixture(); - $book = $this->newInstance($metadata); - - $this->assertPhpDocVarType('\Doctrine\Common\Collections\Collection', new \ReflectionProperty($book, 'comments')); - $this->assertPhpDocReturnType('\Doctrine\Common\Collections\Collection', new \ReflectionMethod($book, 'getComments')); - $this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorComment', new \ReflectionMethod($book, 'addComment')); - $this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorComment', new \ReflectionMethod($book, 'removeComment')); - - $this->assertPhpDocVarType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionProperty($book, 'author')); - $this->assertPhpDocReturnType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionMethod($book, 'getAuthor')); - $this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionMethod($book, 'setAuthor')); - } - - public function testEntityExtendsStdClass() - { - $this->_generator->setClassToExtend('stdClass'); - $metadata = $this->generateBookEntityFixture(); - - $book = $this->newInstance($metadata); - $this->assertInstanceOf('stdClass', $book); - } - - public function testLifecycleCallbacks() - { - $metadata = $this->generateBookEntityFixture(); - - $book = $this->newInstance($metadata); - $reflClass = new \ReflectionClass($metadata->name); - - $this->assertTrue($reflClass->hasMethod('loading'), "Check for postLoad lifecycle callback."); - $this->assertTrue($reflClass->hasMethod('willBeRemoved'), "Check for preRemove lifecycle callback."); - } - - public function testLoadMetadata() - { - $metadata = $this->generateBookEntityFixture(); - - $book = $this->newInstance($metadata); - - $cm = new \Doctrine\ORM\Mapping\ClassMetadata($metadata->name); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $driver = $this->createAnnotationDriver(); - $driver->loadMetadataForClass($cm->name, $cm); - - $this->assertEquals($cm->columnNames, $metadata->columnNames); - $this->assertEquals($cm->getTableName(), $metadata->getTableName()); - $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); - $this->assertEquals($cm->identifier, $metadata->identifier); - $this->assertEquals($cm->idGenerator, $metadata->idGenerator); - $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); - - $this->assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']); - } - - public function testLoadPrefixedMetadata() - { - $this->_generator->setAnnotationPrefix('ORM\\'); - $metadata = $this->generateBookEntityFixture(); - - $reader = new \Doctrine\Common\Annotations\AnnotationReader(); - $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array()); - - $book = $this->newInstance($metadata); - - $cm = new \Doctrine\ORM\Mapping\ClassMetadata($metadata->name); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - - $driver->loadMetadataForClass($cm->name, $cm); - - $this->assertEquals($cm->columnNames, $metadata->columnNames); - $this->assertEquals($cm->getTableName(), $metadata->getTableName()); - $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); - $this->assertEquals($cm->identifier, $metadata->identifier); - $this->assertEquals($cm->idGenerator, $metadata->idGenerator); - $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); - } - - /** - * @dataProvider getParseTokensInEntityFileData - */ - public function testParseTokensInEntityFile($php, $classes) - { - $r = new \ReflectionObject($this->_generator); - $m = $r->getMethod('parseTokensInEntityFile'); - $m->setAccessible(true); - - $p = $r->getProperty('staticReflection'); - $p->setAccessible(true); - - $ret = $m->invoke($this->_generator, $php); - $this->assertEquals($classes, array_keys($p->getValue($this->_generator))); - } - - /** - * @group DDC-1784 - */ - public function testGenerateEntityWithSequenceGenerator() - { - $metadata = new ClassMetadataInfo($this->_namespace . '\DDC1784Entity'); - $metadata->namespace = $this->_namespace; - $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); - $metadata->setSequenceGeneratorDefinition(array( - 'sequenceName' => 'DDC1784_ID_SEQ', - 'allocationSize' => 1, - 'initialValue' => 2 - )); - $this->_generator->writeEntityClass($metadata, $this->_tmpDir); - - $filename = $this->_tmpDir . DIRECTORY_SEPARATOR - . $this->_namespace . DIRECTORY_SEPARATOR . 'DDC1784Entity.php'; - - $this->assertFileExists($filename); - require_once $filename; - - - $reflection = new \ReflectionProperty($metadata->name, 'id'); - $docComment = $reflection->getDocComment(); - - $this->assertContains('@Id', $docComment); - $this->assertContains('@Column(name="id", type="integer")', $docComment); - $this->assertContains('@GeneratedValue(strategy="SEQUENCE")', $docComment); - $this->assertContains('@SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment); - } - - /** - * @group DDC-2079 - */ - public function testGenerateEntityWithMultipleInverseJoinColumns() - { - $metadata = new ClassMetadataInfo($this->_namespace . '\DDC2079Entity'); - $metadata->namespace = $this->_namespace; - $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); - $metadata->mapManyToMany(array( - 'fieldName' => 'centroCustos', - 'targetEntity' => 'DDC2079CentroCusto', - 'joinTable' => array( - 'name' => 'unidade_centro_custo', - 'joinColumns' => array( - array('name' => 'idorcamento', 'referencedColumnName' => 'idorcamento'), - array('name' => 'idunidade', 'referencedColumnName' => 'idunidade') - ), - 'inverseJoinColumns' => array( - array('name' => 'idcentrocusto', 'referencedColumnName' => 'idcentrocusto'), - array('name' => 'idpais', 'referencedColumnName' => 'idpais'), - ), - ), - )); - $this->_generator->writeEntityClass($metadata, $this->_tmpDir); - - $filename = $this->_tmpDir . DIRECTORY_SEPARATOR - . $this->_namespace . DIRECTORY_SEPARATOR . 'DDC2079Entity.php'; - - $this->assertFileExists($filename); - require_once $filename; - - $property = new \ReflectionProperty($metadata->name, 'centroCustos'); - $docComment = $property->getDocComment(); - - //joinColumns - $this->assertContains('@JoinColumn(name="idorcamento", referencedColumnName="idorcamento"),', $docComment); - $this->assertContains('@JoinColumn(name="idunidade", referencedColumnName="idunidade")', $docComment); - //inverseJoinColumns - $this->assertContains('@JoinColumn(name="idcentrocusto", referencedColumnName="idcentrocusto"),', $docComment); - $this->assertContains('@JoinColumn(name="idpais", referencedColumnName="idpais")', $docComment); - - } - - /** - * @group DDC-2172 - */ - public function testGetInheritanceTypeString() - { - $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata'); - $method = new \ReflectionMethod($this->_generator, 'getInheritanceTypeString'); - $constants = $reflection->getConstants(); - $pattern = '/^INHERITANCE_TYPE_/'; - - $method->setAccessible(true); - - foreach ($constants as $name => $value) { - if( ! preg_match($pattern, $name)) { - continue; - } - - $expected = preg_replace($pattern, '', $name); - $actual = $method->invoke($this->_generator, $value); - - $this->assertEquals($expected, $actual); - } - - $this->setExpectedException('\InvalidArgumentException', 'Invalid provided InheritanceType: INVALID'); - $method->invoke($this->_generator, 'INVALID'); - } - - /** - * @group DDC-2172 - */ - public function testGetChangeTrackingPolicyString() - { - $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata'); - $method = new \ReflectionMethod($this->_generator, 'getChangeTrackingPolicyString'); - $constants = $reflection->getConstants(); - $pattern = '/^CHANGETRACKING_/'; - - $method->setAccessible(true); - - foreach ($constants as $name => $value) { - if( ! preg_match($pattern, $name)) { - continue; - } - - $expected = preg_replace($pattern, '', $name); - $actual = $method->invoke($this->_generator, $value); - - $this->assertEquals($expected, $actual); - } - - $this->setExpectedException('\InvalidArgumentException', 'Invalid provided ChangeTrackingPolicy: INVALID'); - $method->invoke($this->_generator, 'INVALID'); - } - - /** - * @group DDC-2172 - */ - public function testGetIdGeneratorTypeString() - { - $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata'); - $method = new \ReflectionMethod($this->_generator, 'getIdGeneratorTypeString'); - $constants = $reflection->getConstants(); - $pattern = '/^GENERATOR_TYPE_/'; - - $method->setAccessible(true); - - foreach ($constants as $name => $value) { - if( ! preg_match($pattern, $name)) { - continue; - } - - $expected = preg_replace($pattern, '', $name); - $actual = $method->invoke($this->_generator, $value); - - $this->assertEquals($expected, $actual); - } - - $this->setExpectedException('\InvalidArgumentException', 'Invalid provided IdGeneratorType: INVALID'); - $method->invoke($this->_generator, 'INVALID'); - } - - /** - * @dataProvider getEntityTypeAliasDataProvider - * - * @group DDC-1694 - */ - public function testEntityTypeAlias(array $field) - { - $metadata = $this->generateEntityTypeFixture($field); - $path = $this->_tmpDir . '/'. $this->_namespace . '/EntityType.php'; - - $this->assertFileExists($path); - require_once $path; - - $entity = new $metadata->name; - $reflClass = new \ReflectionClass($metadata->name); - - $type = $field['phpType']; - $name = $field['fieldName']; - $value = $field['value']; - $getter = "get" . ucfirst($name); - $setter = "set" . ucfirst($name); - - $this->assertPhpDocVarType($type, $reflClass->getProperty($name)); - $this->assertPhpDocParamType($type, $reflClass->getMethod($setter)); - $this->assertPhpDocReturnType($type, $reflClass->getMethod($getter)); - - $this->assertSame($entity, $entity->{$setter}($value)); - $this->assertEquals($value, $entity->{$getter}()); - } - - /** - * @return array - */ - public function getEntityTypeAliasDataProvider() - { - return array( - array(array( - 'fieldName' => 'datetimetz', - 'phpType' => '\\DateTime', - 'dbType' => 'datetimetz', - 'value' => new \DateTime - )), - array(array( - 'fieldName' => 'datetime', - 'phpType' => '\\DateTime', - 'dbType' => 'datetime', - 'value' => new \DateTime - )), - array(array( - 'fieldName' => 'date', - 'phpType' => '\\DateTime', - 'dbType' => 'date', - 'value' => new \DateTime - )), - array(array( - 'fieldName' => 'time', - 'phpType' => '\DateTime', - 'dbType' => 'time', - 'value' => new \DateTime - )), - array(array( - 'fieldName' => 'object', - 'phpType' => '\stdClass', - 'dbType' => 'object', - 'value' => new \stdClass() - )), - array(array( - 'fieldName' => 'bigint', - 'phpType' => 'integer', - 'dbType' => 'bigint', - 'value' => 11 - )), - array(array( - 'fieldName' => 'smallint', - 'phpType' => 'integer', - 'dbType' => 'smallint', - 'value' => 22 - )), - array(array( - 'fieldName' => 'text', - 'phpType' => 'string', - 'dbType' => 'text', - 'value' => 'text' - )), - array(array( - 'fieldName' => 'blob', - 'phpType' => 'string', - 'dbType' => 'blob', - 'value' => 'blob' - )), - array(array( - 'fieldName' => 'decimal', - 'phpType' => 'float', - 'dbType' => 'decimal', - 'value' => 33.33 - ), - )); - } - - public function getParseTokensInEntityFileData() - { - return array( - array( - 'assertEquals(1, preg_match('/@var\s+([^\s]+)/',$property->getDocComment(), $matches)); - $this->assertEquals($type, $matches[1]); - } - - /** - * @param string $type - * @param \ReflectionProperty $method - */ - private function assertPhpDocReturnType($type, \ReflectionMethod $method) - { - $this->assertEquals(1, preg_match('/@return\s+([^\s]+)/', $method->getDocComment(), $matches)); - $this->assertEquals($type, $matches[1]); - } - - /** - * @param string $type - * @param \ReflectionProperty $method - */ - private function assertPhpDocParamType($type, \ReflectionMethod $method) - { - $this->assertEquals(1, preg_match('/@param\s+([^\s]+)/', $method->getDocComment(), $matches)); - $this->assertEquals($type, $matches[1]); - } -} - -class EntityGeneratorAuthor {} -class EntityGeneratorComment {} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php deleted file mode 100755 index 525bdaa657..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ /dev/null @@ -1,391 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Tools\Export; - -use Doctrine\ORM\Tools\Export\ClassMetadataExporter; -use Doctrine\ORM\Mapping\ClassMetadataInfo; -use Doctrine\ORM\Tools\EntityGenerator; -use Doctrine\Tests\Mocks\MetadataDriverMock; -use Doctrine\Tests\Mocks\DatabasePlatformMock; -use Doctrine\Tests\Mocks\EntityManagerMock; -use Doctrine\Tests\Mocks\ConnectionMock; -use Doctrine\Tests\Mocks\DriverMock; -use Doctrine\Common\EventManager; -use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; -use Doctrine\ORM\Mapping\ClassMetadataFactory; - -require_once __DIR__ . '/../../../TestInit.php'; - -/** - * Test case for ClassMetadataExporter - * - * @author Jonathan H. Wage - * @author Roman Borschel setProxyDir(__DIR__ . '/../../Proxies'); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $eventManager = new EventManager(); - $conn = new ConnectionMock(array(), $driverMock, $config, $eventManager); - $mockDriver = new MetadataDriverMock(); - $config->setMetadataDriverImpl($metadataDriver); - - return EntityManagerMock::create($conn, $config, $eventManager); - } - - protected function _createMetadataDriver($type, $path) - { - $mappingDriver = array( - 'php' => 'Doctrine\Common\Persistence\Mapping\Driver\PHPDriver', - 'annotation' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', - 'xml' => 'Doctrine\ORM\Mapping\Driver\XmlDriver', - 'yaml' => 'Doctrine\ORM\Mapping\Driver\YamlDriver', - ); - $this->assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'."); - $class = $mappingDriver[$type]; - - if ($type === 'annotation') { - $driver = $this->createAnnotationDriver(array($path)); - } else { - $driver = new $class($path); - } - return $driver; - } - - protected function _createClassMetadataFactory($em, $type) - { - if ($type === 'annotation') { - $factory = new ClassMetadataFactory(); - } else { - $factory = new DisconnectedClassMetadataFactory(); - } - $factory->setEntityManager($em); - return $factory; - } - - public function testExportDirectoryAndFilesAreCreated() - { - $this->_deleteDirectory(__DIR__ . '/export/'.$this->_getType()); - - $type = $this->_getType(); - $metadataDriver = $this->_createMetadataDriver($type, __DIR__ . '/' . $type); - $em = $this->_createEntityManager($metadataDriver); - $cmf = $this->_createClassMetadataFactory($em, $type); - $metadata = $cmf->getAllMetadata(); - - $metadata[0]->name = 'Doctrine\Tests\ORM\Tools\Export\ExportedUser'; - - $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\ExportedUser', $metadata[0]->name); - - $type = $this->_getType(); - $cme = new ClassMetadataExporter(); - $exporter = $cme->getExporter($type, __DIR__ . '/export/' . $type); - if ($type === 'annotation') { - $entityGenerator = new EntityGenerator(); - $entityGenerator->setAnnotationPrefix(""); - $exporter->setEntityGenerator($entityGenerator); - } - $this->_extension = $exporter->getExtension(); - - $exporter->setMetadata($metadata); - $exporter->export(); - - if ($type == 'annotation') { - $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/'.str_replace('\\', '/', 'Doctrine\Tests\ORM\Tools\Export\ExportedUser').$this->_extension)); - } else { - $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser'.$this->_extension)); - } - } - - /** - * @depends testExportDirectoryAndFilesAreCreated - */ - public function testExportedMetadataCanBeReadBackIn() - { - $type = $this->_getType(); - - $metadataDriver = $this->_createMetadataDriver($type, __DIR__ . '/export/' . $type); - $em = $this->_createEntityManager($metadataDriver); - $cmf = $this->_createClassMetadataFactory($em, $type); - $metadata = $cmf->getAllMetadata(); - - $this->assertEquals(1, count($metadata)); - - $class = current($metadata); - - $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\ExportedUser', $class->name); - - return $class; - } - - /** - * @depends testExportedMetadataCanBeReadBackIn - * @param ClassMetadataInfo $class - */ - public function testTableIsExported($class) - { - $this->assertEquals('cms_users', $class->table['name']); - - return $class; - } - - /** - * @depends testTableIsExported - * @param ClassMetadataInfo $class - */ - public function testTypeIsExported($class) - { - $this->assertFalse($class->isMappedSuperclass); - - return $class; - } - - /** - * @depends testTypeIsExported - * @param ClassMetadataInfo $class - */ - public function testIdentifierIsExported($class) - { - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY, $class->generatorType); - $this->assertEquals(array('id'), $class->identifier); - $this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); - - return $class; - } - - /** - * @depends testIdentifierIsExported - * @param ClassMetadataInfo $class - */ - public function testFieldsAreExported($class) - { - $this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); - $this->assertEquals('id', $class->fieldMappings['id']['fieldName']); - $this->assertEquals('integer', $class->fieldMappings['id']['type']); - $this->assertEquals('id', $class->fieldMappings['id']['columnName']); - - $this->assertEquals('name', $class->fieldMappings['name']['fieldName']); - $this->assertEquals('string', $class->fieldMappings['name']['type']); - $this->assertEquals(50, $class->fieldMappings['name']['length']); - $this->assertEquals('name', $class->fieldMappings['name']['columnName']); - - $this->assertEquals('email', $class->fieldMappings['email']['fieldName']); - $this->assertEquals('string', $class->fieldMappings['email']['type']); - $this->assertEquals('user_email', $class->fieldMappings['email']['columnName']); - $this->assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); - - return $class; - } - - /** - * @depends testFieldsAreExported - * @param ClassMetadataInfo $class - */ - public function testOneToOneAssociationsAreExported($class) - { - $this->assertTrue(isset($class->associationMappings['address'])); - $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Address', $class->associationMappings['address']['targetEntity']); - $this->assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); - - $this->assertTrue($class->associationMappings['address']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['address']['isCascadePersist']); - $this->assertFalse($class->associationMappings['address']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['address']['isCascadeMerge']); - $this->assertFalse($class->associationMappings['address']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['address']['orphanRemoval']); - - return $class; - } - - /** - * @depends testFieldsAreExported - */ - public function testManyToOneAssociationsAreExported($class) - { - $this->assertTrue(isset($class->associationMappings['mainGroup'])); - $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Group', $class->associationMappings['mainGroup']['targetEntity']); - } - - /** - * @depends testOneToOneAssociationsAreExported - * @param ClassMetadataInfo $class - */ - public function testOneToManyAssociationsAreExported($class) - { - $this->assertTrue(isset($class->associationMappings['phonenumbers'])); - //$this->assertInstanceOf('Doctrine\ORM\Mapping\OneToManyMapping', $class->associationMappings['phonenumbers']); - $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Phonenumber', $class->associationMappings['phonenumbers']['targetEntity']); - $this->assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']); - $this->assertEquals(array('number' => 'ASC'), $class->associationMappings['phonenumbers']['orderBy']); - - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); - - return $class; - } - - /** - * @depends testOneToManyAssociationsAreExported - * @param ClassMetadataInfo $metadata - */ - public function testManyToManyAssociationsAreExported($class) - { - $this->assertTrue(isset($class->associationMappings['groups'])); - //$this->assertInstanceOf('Doctrine\ORM\Mapping\ManyToManyMapping', $class->associationMappings['groups']); - $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Group', $class->associationMappings['groups']['targetEntity']); - $this->assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']); - - $this->assertEquals('user_id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['referencedColumnName']); - - $this->assertEquals('group_id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); - $this->assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); - - $this->assertTrue($class->associationMappings['groups']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['groups']['isCascadePersist']); - $this->assertTrue($class->associationMappings['groups']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['groups']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['groups']['isCascadeDetach']); - - return $class; - } - - /** - * @depends testManyToManyAssociationsAreExported - * @param ClassMetadataInfo $class - */ - public function testLifecycleCallbacksAreExported($class) - { - $this->assertTrue(isset($class->lifecycleCallbacks['prePersist'])); - $this->assertEquals(2, count($class->lifecycleCallbacks['prePersist'])); - $this->assertEquals('doStuffOnPrePersist', $class->lifecycleCallbacks['prePersist'][0]); - $this->assertEquals('doOtherStuffOnPrePersistToo', $class->lifecycleCallbacks['prePersist'][1]); - - $this->assertTrue(isset($class->lifecycleCallbacks['postPersist'])); - $this->assertEquals(1, count($class->lifecycleCallbacks['postPersist'])); - $this->assertEquals('doStuffOnPostPersist', $class->lifecycleCallbacks['postPersist'][0]); - - return $class; - } - - /** - * @depends testLifecycleCallbacksAreExported - * @param ClassMetadataInfo $class - */ - public function testCascadeIsExported($class) - { - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); - - return $class; - } - - /** - * @depends testCascadeIsExported - * @param ClassMetadataInfo $class - */ - public function testInversedByIsExported($class) - { - $this->assertEquals('user', $class->associationMappings['address']['inversedBy']); - } - /** - * @depends testExportDirectoryAndFilesAreCreated - */ - public function testCascadeAllCollapsed() - { - $type = $this->_getType(); - if ($type == 'xml') { - $xml = simplexml_load_file(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml'); - - $xml->registerXPathNamespace("d", "http://doctrine-project.org/schemas/orm/doctrine-mapping"); - $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:one-to-many[@field='interests']/d:cascade/d:*"); - $this->assertEquals(1, count($nodes)); - - $this->assertEquals('cascade-all', $nodes[0]->getName()); - } elseif ($type == 'yaml') { - - $yaml = new \Symfony\Component\Yaml\Parser(); - $value = $yaml->parse(file_get_contents(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.yml')); - - $this->assertTrue(isset($value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'])); - $this->assertEquals(1, count($value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'])); - $this->assertEquals('all', $value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'][0]); - - } else { - $this->markTestSkipped('Test aviable only for '.$type.' dirver'); - } - } - public function __destruct() - { -# $this->_deleteDirectory(__DIR__ . '/export/'.$this->_getType()); - } - - protected function _deleteDirectory($path) - { - if (is_file($path)) { - return unlink($path); - } else if (is_dir($path)) { - $files = glob(rtrim($path,'/').'/*'); - foreach ($files as $file){ - $this->_deleteDirectory($file); - } - return rmdir($path); - } - } -} - -class Address -{ - -} -class Phonenumber -{ - -} -class Group -{ - -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php deleted file mode 100755 index c60281cf39..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -namespace Doctrine\Tests\ORM\Tools\Export; - -require_once __DIR__ . '/../../../TestInit.php'; - -/** - * Test case for AnnotationClassMetadataExporterTest - * - * @author Jonathan H. Wage - * @author Roman Borschel . - */ - -namespace Doctrine\Tests\ORM\Tools\Export; - -require_once __DIR__ . '/../../../TestInit.php'; - -/** - * Test case for PhpClassMetadataExporterTest - * - * @author Jonathan H. Wage - * @author Roman Borschel . - */ - -namespace Doctrine\Tests\ORM\Tools\Export; - -require_once __DIR__ . '/../../../TestInit.php'; - -/** - * Test case for XmlClassMetadataExporterTest - * - * @author Jonathan H. Wage - * @author Roman Borschel . - */ - -namespace Doctrine\Tests\ORM\Tools\Export; - -require_once __DIR__ . '/../../../TestInit.php'; - -/** - * Test case for YamlClassMetadataExporterTest - * - * @author Jonathan H. Wage - * @author Roman Borschel markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); - } - - return 'yaml'; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/annotation/Doctrine.Tests.ORM.Tools.Export.User.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/annotation/Doctrine.Tests.ORM.Tools.Export.User.php deleted file mode 100755 index 5a82cc6f11..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/annotation/Doctrine.Tests.ORM.Tools.Export.User.php +++ /dev/null @@ -1,73 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); -$metadata->setPrimaryTable(array( - 'name' => 'cms_users', - )); -$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); -$metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist'); -$metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist'); -$metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist'); -$metadata->mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - )); -$metadata->mapField(array( - 'fieldName' => 'name', - 'type' => 'string', - 'length' => 50, - 'unique' => true, - 'nullable' => true, - 'columnName' => 'name', - )); -$metadata->mapField(array( - 'fieldName' => 'email', - 'type' => 'string', - 'columnName' => 'user_email', - 'columnDefinition' => 'CHAR(32) NOT NULL', - )); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); -$metadata->mapManyToOne(array( - 'fieldName' => 'mainGroup', - 'targetEntity' => 'Doctrine\\Tests\\ORM\Tools\\Export\\Group', -)); -$metadata->mapOneToOne(array( - 'fieldName' => 'address', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Address', - 'inversedBy' => 'user', - 'cascade' => - array( - 0 => 'persist', - ), - 'mappedBy' => NULL, - 'joinColumns' => - array( - 0 => - array( - 'name' => 'address_id', - 'referencedColumnName' => 'id', - 'onDelete' => 'CASCADE', - ), - ), - 'orphanRemoval' => true, - )); -$metadata->mapOneToMany(array( - 'fieldName' => 'phonenumbers', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Phonenumber', - 'cascade' => - array( - 1 => 'persist', - 2 => 'merge', - ), - 'mappedBy' => 'user', - 'orphanRemoval' => true, - 'orderBy' => - array( - 'number' => 'ASC', - ), - )); -$metadata->mapManyToMany(array( - 'fieldName' => 'groups', - 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Group', - 'cascade' => - array( - 0 => 'remove', - 1 => 'persist', - 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', - ), - 'mappedBy' => NULL, - 'joinTable' => - array( - 'name' => 'cms_users_groups', - 'joinColumns' => - array( - 0 => - array( - 'name' => 'user_id', - 'referencedColumnName' => 'id', - 'unique' => false, - 'nullable' => false, - ), - ), - 'inverseJoinColumns' => - array( - 0 => - array( - 'name' => 'group_id', - 'referencedColumnName' => 'id', - 'columnDefinition' => 'INT NULL', - ), - ), - ), - 'orderBy' => NULL, - )); diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml deleted file mode 100755 index 22d2852b00..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml deleted file mode 100755 index 25071d9b37..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml +++ /dev/null @@ -1,63 +0,0 @@ -Doctrine\Tests\ORM\Tools\Export\User: - type: entity - table: cms_users - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 50 - nullable: true - unique: true - email: - type: string - column: user_email - columnDefinition: CHAR(32) NOT NULL - oneToOne: - address: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Address - joinColumn: - name: address_id - referencedColumnName: id - onDelete: CASCADE - cascade: [ persist ] - inversedBy: user - orphanRemoval: true - manyToOne: - mainGroup: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Group - oneToMany: - phonenumbers: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Phonenumber - mappedBy: user - orderBy: - number: ASC - cascade: [ persist, merge ] - orphanRemoval: true - interests: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Interests - mappedBy: user - cascade: [ persist, merge, remove, refresh, detach ] - orphanRemoval: true - manyToMany: - groups: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Group - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - nullable: false - unique: false - inverseJoinColumns: - group_id: - referencedColumnName: id - columnDefinition: INT NULL - cascade: - - all - lifecycleCallbacks: - prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] - postPersist: [ doStuffOnPostPersist ] diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php deleted file mode 100755 index f3c2e1b50a..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php +++ /dev/null @@ -1,62 +0,0 @@ -entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a'); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id0 FROM (SELECT b0_.id AS id0, c1_.id AS id1, a2_.id AS id2, a2_.name AS name3, b0_.author_id AS author_id4, b0_.category_id AS category_id5 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id) dctrn_result) dctrn_table", $query->getSql() - ); - } - - public function testCountQuery_MixedResultsWithName() - { - $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a'); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id0 FROM (SELECT a0_.id AS id0, a0_.name AS name1, sum(a0_.name) AS sclr2 FROM Author a0_) dctrn_result) dctrn_table", $query->getSql() - ); - } - - public function testCountQuery_Having() - { - $query = $this->entityManager->createQuery( - 'SELECT g, u, count(u.id) AS userCount FROM Doctrine\Tests\ORM\Tools\Pagination\Group g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0'); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id1 FROM (SELECT count(u0_.id) AS sclr0, g1_.id AS id1, u0_.id AS id2 FROM groups g1_ LEFT JOIN user_group u2_ ON g1_.id = u2_.group_id LEFT JOIN User u0_ ON u0_.id = u2_.user_id GROUP BY g1_.id HAVING sclr0 > 0) dctrn_result) dctrn_table", $query->getSql() - ); - } - - public function testCountQueryOrderBySqlServer() - { - if ($this->entityManager->getConnection()->getDatabasePlatform()->getName() !== "mssql") { - $this->markTestSkipped('SQLServer only test.'); - } - - $query = $this->entityManager->createQuery( - 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p ORDER BY p.id'); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id0 FROM (SELECT b0_.id AS id0, b0_.author_id AS author_id1, b0_.category_id AS category_id2 FROM BlogPost b0_) dctrn_result) dctrn_table", - $query->getSql() - ); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php deleted file mode 100755 index 405b63a1f0..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ /dev/null @@ -1,94 +0,0 @@ -entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a'); - $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); - $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSql() - ); - } - - public function testCountQuery_MixedResultsWithName() - { - $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a'); - $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); - $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT count(DISTINCT a0_.id) AS sclr0 FROM Author a0_", $query->getSql() - ); - } - - public function testCountQuery_KeepsGroupBy() - { - $query = $this->entityManager->createQuery( - 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b GROUP BY b.id'); - $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); - $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr0 FROM BlogPost b0_ GROUP BY b0_.id", $query->getSql() - ); - } - - public function testCountQuery_RemovesOrderBy() - { - $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a ORDER BY a.name'); - $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); - $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSql() - ); - } - - public function testCountQuery_RemovesLimits() - { - $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a'); - $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); - $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); - - $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSql() - ); - } - - public function testCountQuery_HavingException() - { - $query = $this->entityManager->createQuery( - "SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0" - ); - $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); - $query->setFirstResult(null)->setMaxResults(null); - - $this->setExpectedException( - 'RuntimeException', - 'Cannot count query that uses a HAVING clause. Use the output walkers for pagination' - ); - - $query->getSql(); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php deleted file mode 100755 index 362ffc0c8d..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ /dev/null @@ -1,61 +0,0 @@ -entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a'); - $query->expireQueryCache(true); - $limitQuery = clone $query; - $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); - - $this->assertEquals( - "SELECT DISTINCT id0 FROM (SELECT m0_.id AS id0, m0_.title AS title1, c1_.id AS id2, a2_.id AS id3, a2_.name AS name4, m0_.author_id AS author_id5, m0_.category_id AS category_id6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result", $limitQuery->getSql() - ); - } - - public function testLimitSubqueryWithSortPg() - { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); - - $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title'); - $limitQuery = clone $query; - $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); - - $this->assertEquals( - "SELECT DISTINCT id0, title1 FROM (SELECT m0_.id AS id0, m0_.title AS title1, c1_.id AS id2, a2_.id AS id3, a2_.name AS name4, m0_.author_id AS author_id5, m0_.category_id AS category_id6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC) dctrn_result ORDER BY title1 ASC", $limitQuery->getSql() - ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); - } - - public function testLimitSubqueryPg() - { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); - - $this->testLimitSubquery(); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); - } - - public function testCountQuery_MixedResultsWithName() - { - $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a'); - $limitQuery = clone $query; - $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); - - $this->assertEquals( - "SELECT DISTINCT id0 FROM (SELECT a0_.id AS id0, a0_.name AS name1, sum(a0_.name) AS sclr2 FROM Author a0_) dctrn_result", $limitQuery->getSql() - ); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php deleted file mode 100755 index bfec024614..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php +++ /dev/null @@ -1,48 +0,0 @@ -entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a'); - $limitQuery = clone $query; - $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker')); - - $this->assertEquals( - "SELECT DISTINCT m0_.id AS id0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id", $limitQuery->getSql() - ); - } - - public function testLimitSubqueryWithSort() - { - $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title'); - $limitQuery = clone $query; - $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker')); - - $this->assertEquals( - "SELECT DISTINCT m0_.id AS id0, m0_.title AS title1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC", $limitQuery->getSql() - ); - } - - public function testCountQuery_MixedResultsWithName() - { - $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a'); - $limitQuery = clone $query; - $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker')); - - $this->assertEquals( - "SELECT DISTINCT a0_.id AS id0, sum(a0_.name) AS sclr1 FROM Author a0_", $limitQuery->getSql() - ); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php deleted file mode 100755 index d503e81aac..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php +++ /dev/null @@ -1,144 +0,0 @@ -entityManager = $this->_getTestEntityManager(); - } -} - - -/** -* @Entity -*/ -class MyBlogPost -{ - - /** @Id @column(type="integer") @generatedValue */ - public $id; - /** - * @ManyToOne(targetEntity="Author") - */ - public $author; - /** - * @ManyToOne(targetEntity="Category") - */ - public $category; - /** @column(type="string") */ - public $title; -} - -/** - * @Entity - */ -class MyAuthor -{ - - /** @Id @column(type="integer") @generatedValue */ - public $id; - -} - -/** -* @Entity -*/ -class MyCategory -{ - - /** @id @column(type="integer") @generatedValue */ - public $id; - -} - - -/** - * @Entity - */ -class BlogPost -{ - - /** @Id @column(type="integer") @generatedValue */ - public $id; - /** - * @ManyToOne(targetEntity="Author") - */ - public $author; - /** - * @ManyToOne(targetEntity="Category") - */ - public $category; -} - -/** - * @Entity - */ -class Author -{ - - /** @Id @column(type="integer") @generatedValue */ - public $id; - /** @Column(type="string") */ - public $name; - -} - -/** - * @Entity - */ -class Person -{ - - /** @Id @column(type="integer") @generatedValue */ - public $id; - /** @Column(type="string") */ - public $name; - /** @Column(type="string") */ - public $biography; - -} - -/** - * @Entity - */ -class Category -{ - - /** @id @column(type="integer") @generatedValue */ - public $id; - -} - - -/** @Entity @Table(name="groups") */ -class Group -{ - - /** @Id @column(type="integer") @generatedValue */ - public $id; - /** @ManyToMany(targetEntity="User", mappedBy="groups") */ - public $users; -} - -/** @Entity */ -class User -{ - - /** @Id @column(type="integer") @generatedValue */ - public $id; - /** - * @ManyToMany(targetEntity="Group", inversedBy="users") - * @JoinTable( - * name="user_group", - * joinColumns = {@JoinColumn(name="user_id", referencedColumnName="id")}, - * inverseJoinColumns = {@JoinColumn(name="group_id", referencedColumnName="id")} - * ) - */ - public $groups; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php deleted file mode 100755 index 3ec8093ab9..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php +++ /dev/null @@ -1,125 +0,0 @@ -entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g' - ); - $whereInQuery = clone $query; - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); - $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); - - $this->assertEquals( - "SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE u0_.id IN (?)", $whereInQuery->getSql() - ); - } - - public function testCountQuery_MixedResultsWithName() - { - $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a' - ); - $whereInQuery = clone $query; - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); - $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); - - $this->assertEquals( - "SELECT a0_.id AS id0, a0_.name AS name1, sum(a0_.name) AS sclr2 FROM Author a0_ WHERE a0_.id IN (?)", $whereInQuery->getSql() - ); - } - - public function testWhereInQuery_SingleWhere() - { - $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1' - ); - $whereInQuery = clone $query; - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); - $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); - - $this->assertEquals( - "SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND u0_.id IN (?)", $whereInQuery->getSql() - ); - } - - public function testWhereInQuery_MultipleWhereWithAnd() - { - $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 AND 2 = 2' - ); - $whereInQuery = clone $query; - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); - $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); - - $this->assertEquals( - "SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND 2 = 2 AND u0_.id IN (?)", $whereInQuery->getSql() - ); - } - - public function testWhereInQuery_MultipleWhereWithOr() - { - $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 OR 2 = 2' - ); - $whereInQuery = clone $query; - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); - $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); - - $this->assertEquals( - "SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND u0_.id IN (?)", $whereInQuery->getSql() - ); - } - - public function testWhereInQuery_MultipleWhereWithMixed_1() - { - $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE (1 = 1 OR 2 = 2) AND 3 = 3' - ); - $whereInQuery = clone $query; - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); - $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); - - $this->assertEquals( - "SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND 3 = 3 AND u0_.id IN (?)", $whereInQuery->getSql() - ); - } - - public function testWhereInQuery_MultipleWhereWithMixed_2() - { - $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 AND 2 = 2 OR 3 = 3' - ); - $whereInQuery = clone $query; - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); - $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); - - $this->assertEquals( - "SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 AND 2 = 2 OR 3 = 3) AND u0_.id IN (?)", $whereInQuery->getSql() - ); - } - - public function testWhereInQuery_WhereNot() - { - $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE NOT 1 = 2' - ); - $whereInQuery = clone $query; - $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); - $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); - - $this->assertEquals( - "SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (NOT 1 = 2) AND u0_.id IN (?)", $whereInQuery->getSql() - ); - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php deleted file mode 100755 index 66b3ac43e7..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ /dev/null @@ -1,154 +0,0 @@ -createAnnotationDriver(); - - $this->em = $this->_getTestEntityManager(); - $this->em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $this->factory = new ClassMetadataFactory; - $this->factory->setEntityManager($this->em); - $this->listener = new ResolveTargetEntityListener; - } - - /** - * @group DDC-1544 - */ - public function testResolveTargetEntityListenerCanResolveTargetEntity() - { - $evm = $this->em->getEventManager(); - $this->listener->addResolveTargetEntity( - 'Doctrine\Tests\ORM\Tools\ResolveTargetInterface', - 'Doctrine\Tests\ORM\Tools\ResolveTargetEntity', - array() - ); - $this->listener->addResolveTargetEntity( - 'Doctrine\Tests\ORM\Tools\TargetInterface', - 'Doctrine\Tests\ORM\Tools\TargetEntity', - array() - ); - $evm->addEventListener(Events::loadClassMetadata, $this->listener); - $cm = $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetEntity'); - $meta = $cm->associationMappings; - $this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['manyToMany']['targetEntity']); - $this->assertSame('Doctrine\Tests\ORM\Tools\ResolveTargetEntity', $meta['manyToOne']['targetEntity']); - $this->assertSame('Doctrine\Tests\ORM\Tools\ResolveTargetEntity', $meta['oneToMany']['targetEntity']); - $this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['oneToOne']['targetEntity']); - } - - /** - * @group DDC-2109 - */ - public function testAssertTableColumnsAreNotAddedInManyToMany() - { - $evm = $this->em->getEventManager(); - $this->listener->addResolveTargetEntity( - 'Doctrine\Tests\ORM\Tools\ResolveTargetInterface', - 'Doctrine\Tests\ORM\Tools\ResolveTargetEntity', - array() - ); - $this->listener->addResolveTargetEntity( - 'Doctrine\Tests\ORM\Tools\TargetInterface', - 'Doctrine\Tests\ORM\Tools\TargetEntity', - array() - ); - - $evm->addEventListener(Events::loadClassMetadata, $this->listener); - $cm = $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetEntity'); - $meta = $cm->associationMappings['manyToMany']; - - $this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['targetEntity']); - $this->assertEquals(array('resolvetargetentity_id', 'targetinterface_id'), $meta['joinTableColumns']); - } -} - -interface ResolveTargetInterface -{ - public function getId(); -} - -interface TargetInterface extends ResolveTargetInterface -{ -} - -/** - * @Entity - */ -class ResolveTargetEntity implements ResolveTargetInterface -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @ManyToMany(targetEntity="Doctrine\Tests\ORM\Tools\TargetInterface") - */ - private $manyToMany; - - /** - * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTargetInterface", inversedBy="oneToMany") - */ - private $manyToOne; - - /** - * @OneToMany(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTargetInterface", mappedBy="manyToOne") - */ - private $oneToMany; - - /** - * @OneToOne(targetEntity="Doctrine\Tests\ORM\Tools\TargetInterface") - * @JoinColumn(name="target_entity_id", referencedColumnName="id") - */ - private $oneToOne; - - public function getId() - { - return $this->id; - } -} - -/** - * @Entity - */ -class TargetEntity implements TargetInterface -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - public function getId() - { - return $this->id; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php deleted file mode 100755 index f1420ffe47..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ /dev/null @@ -1,135 +0,0 @@ -_getTestEntityManager(); - $schemaTool = new SchemaTool($em); - - $classes = array( - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsComment'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmployee'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), - ); - - $schema = $schemaTool->getSchemaFromMetadata($classes); - - $this->assertTrue($schema->hasTable('cms_users'), "Table cms_users should exist."); - $this->assertTrue($schema->getTable('cms_users')->columnsAreIndexed(array('username')), "username column should be indexed."); - } - - public function testAnnotationOptionsAttribute() - { - $em = $this->_getTestEntityManager(); - $schemaTool = new SchemaTool($em); - - $classes = array( - $em->getClassMetadata(__NAMESPACE__ . '\\TestEntityWithAnnotationOptionsAttribute'), - ); - - $schema = $schemaTool->getSchemaFromMetadata($classes); - - $expected = array('foo' => 'bar', 'baz' => array('key' => 'val')); - - $this->assertEquals($expected, $schema->getTable('TestEntityWithAnnotationOptionsAttribute')->getOptions(), "options annotation are passed to the tables options"); - $this->assertEquals($expected, $schema->getTable('TestEntityWithAnnotationOptionsAttribute')->getColumn('test')->getCustomSchemaOptions(), "options annotation are passed to the columns customSchemaOptions"); - } - - /** - * @group DDC-200 - */ - public function testPassColumnDefinitionToJoinColumn() - { - $customColumnDef = "MEDIUMINT(6) UNSIGNED NOT NULL"; - - $em = $this->_getTestEntityManager(); - $schemaTool = new SchemaTool($em); - - $avatar = $em->getClassMetadata('Doctrine\Tests\Models\Forum\ForumAvatar'); - $avatar->fieldMappings['id']['columnDefinition'] = $customColumnDef; - $user = $em->getClassMetadata('Doctrine\Tests\Models\Forum\ForumUser'); - - $classes = array($avatar, $user); - - $schema = $schemaTool->getSchemaFromMetadata($classes); - - $this->assertTrue($schema->hasTable('forum_users')); - $table = $schema->getTable("forum_users"); - $this->assertTrue($table->hasColumn('avatar_id')); - $this->assertEquals($customColumnDef, $table->getColumn('avatar_id')->getColumnDefinition()); - } - - /** - * @group DDC-283 - */ - public function testPostGenerateEvents() - { - $listener = new GenerateSchemaEventListener(); - - $em = $this->_getTestEntityManager(); - $em->getEventManager()->addEventListener( - array(ToolEvents::postGenerateSchemaTable, ToolEvents::postGenerateSchema), $listener - ); - $schemaTool = new SchemaTool($em); - - $classes = array( - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsComment'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmployee'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), - $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), - ); - - $schema = $schemaTool->getSchemaFromMetadata($classes); - - $this->assertEquals(count($classes), $listener->tableCalls); - $this->assertTrue($listener->schemaCalled); - } -} - -/** - * @Entity - * @Table(options={"foo": "bar", "baz": {"key": "val"}}) - */ -class TestEntityWithAnnotationOptionsAttribute -{ - /** @Id @Column */ - private $id; - - /** - * @Column(type="string", options={"foo": "bar", "baz": {"key": "val"}}) - */ - private $test; -} - -class GenerateSchemaEventListener -{ - public $tableCalls = 0; - public $schemaCalled = false; - - public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs) - { - $this->tableCalls++; - } - - public function postGenerateSchema(GenerateSchemaEventArgs $eventArgs) - { - $this->schemaCalled = true; - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php deleted file mode 100755 index 6f2e912361..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ /dev/null @@ -1,267 +0,0 @@ -em = $this->_getTestEntityManager(); - $this->validator = new SchemaValidator($this->em); - } - - public function testCmsModelSet() - { - $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( - __DIR__ . "/../../Models/CMS" - )); - $this->validator->validateMapping(); - } - - public function testCompanyModelSet() - { - $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( - __DIR__ . "/../../Models/Company" - )); - $this->validator->validateMapping(); - } - - public function testECommerceModelSet() - { - $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( - __DIR__ . "/../../Models/ECommerce" - )); - $this->validator->validateMapping(); - } - - public function testForumModelSet() - { - $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( - __DIR__ . "/../../Models/Forum" - )); - $this->validator->validateMapping(); - } - - public function testNavigationModelSet() - { - $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( - __DIR__ . "/../../Models/Navigation" - )); - $this->validator->validateMapping(); - } - - public function testRoutingModelSet() - { - $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( - __DIR__ . "/../../Models/Routing" - )); - $this->validator->validateMapping(); - } - - /** - * @group DDC-1439 - */ - public function testInvalidManyToManyJoinColumnSchema() - { - $class1 = $this->em->getClassMetadata(__NAMESPACE__ . '\InvalidEntity1'); - $class2 = $this->em->getClassMetadata(__NAMESPACE__ . '\InvalidEntity2'); - - $ce = $this->validator->validateClass($class1); - - $this->assertEquals( - array( - "The inverse join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity2', however 'key4' are missing.", - "The join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the source entity 'Doctrine\Tests\ORM\Tools\InvalidEntity1', however 'key2' are missing." - ), - $ce - ); - } - - /** - * @group DDC-1439 - */ - public function testInvalidToOneJoinColumnSchema() - { - $class1 = $this->em->getClassMetadata(__NAMESPACE__ . '\InvalidEntity1'); - $class2 = $this->em->getClassMetadata(__NAMESPACE__ . '\InvalidEntity2'); - - $ce = $this->validator->validateClass($class2); - - $this->assertEquals( - array( - "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\InvalidEntity1'.", - "The join columns of the association 'assoc' have to match to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity2', however 'key1, key2' are missing." - ), - $ce - ); - } - - /** - * @group DDC-1587 - */ - public function testValidOneToOneAsIdentifierSchema() - { - $class1 = $this->em->getClassMetadata(__NAMESPACE__ . '\DDC1587ValidEntity2'); - $class2 = $this->em->getClassMetadata(__NAMESPACE__ . '\DDC1587ValidEntity1'); - - $ce = $this->validator->validateClass($class1); - - $this->assertEquals(array(), $ce); - } - - /** - * @group DDC-1649 - */ - public function testInvalidTripleAssociationAsKeyMapping() - { - $classThree = $this->em->getClassMetadata(__NAMESPACE__ . '\DDC1649Three'); - $ce = $this->validator->validateClass($classThree); - - $this->assertEquals(Array( - "Cannot map association 'Doctrine\Tests\ORM\Tools\DDC1649Three#two as identifier, because the target entity 'Doctrine\Tests\ORM\Tools\DDC1649Two' also maps an association as identifier.", - "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\DDC1649Two'." - ), $ce); - } -} - -/** - * @Entity - */ -class InvalidEntity1 -{ - /** - * @Id @Column - */ - protected $key1; - /** - * @Id @Column - */ - protected $key2; - /** - * @ManyToMany (targetEntity="InvalidEntity2") - * @JoinTable (name="Entity1Entity2", - * joinColumns={@JoinColumn(name="key1", referencedColumnName="key1")}, - * inverseJoinColumns={@JoinColumn(name="key3", referencedColumnName="key3")} - * ) - */ - protected $entity2; -} - -/** - * @Entity - */ -class InvalidEntity2 -{ - /** - * @Id @Column - */ - protected $key3; - - /** - * @Id @Column - */ - protected $key4; - - /** - * @ManyToOne(targetEntity="InvalidEntity1") - */ - protected $assoc; -} - -/** - * @Entity(repositoryClass="Entity\Repository\Agent") - * @Table(name="agent") - */ -class DDC1587ValidEntity1 -{ - /** - * @var int - * - * @Id @GeneratedValue - * @Column(name="pk", type="integer") - */ - private $pk; - - /** - * @var string - * - * @Column(name="name", type="string", length=32) - */ - private $name; - - /** - * @var Identifier - * - * @OneToOne(targetEntity="DDC1587ValidEntity2", cascade={"all"}, mappedBy="agent") - * @JoinColumn(name="pk", referencedColumnName="pk_agent") - */ - private $identifier; -} - -/** - * @Entity - * @Table - */ -class DDC1587ValidEntity2 -{ - /** - * @var DDC1587ValidEntity1 - * - * @Id - * @OneToOne(targetEntity="DDC1587ValidEntity1", inversedBy="identifier") - * @JoinColumn(name="pk_agent", referencedColumnName="pk", nullable=false) - */ - private $agent; - - /** - * @var string - * - * @Column(name="num", type="string", length=16, nullable=true) - */ - private $num; -} - -/** - * @Entity - */ -class DDC1649One -{ - /** - * @Id @Column @GeneratedValue - */ - public $id; -} - -/** - * @Entity - */ -class DDC1649Two -{ - /** @Id @ManyToOne(targetEntity="DDC1649One")@JoinColumn(name="id", referencedColumnName="id") */ - public $one; -} - -/** - * @Entity - */ -class DDC1649Three -{ - /** @Id @ManyToOne(targetEntity="DDC1649Two") @JoinColumn(name="id", - * referencedColumnName="id") */ - private $two; -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SetupTest.php deleted file mode 100755 index 50db4b2e15..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ /dev/null @@ -1,110 +0,0 @@ -markTestSkipped("Test only runs in a dev-installation from Github"); - } - - $this->originalAutoloaderCount = count(spl_autoload_functions()); - $this->originalIncludePath = get_include_path(); - } - - public function tearDown() - { - if ( ! $this->originalIncludePath) { - return; - } - - set_include_path($this->originalIncludePath); - $loaders = spl_autoload_functions(); - for ($i = 0; $i < count($loaders); $i++) { - if ($i > $this->originalAutoloaderCount+1) { - spl_autoload_unregister($loaders[$i]); - } - } - } - - public function testGitAutoload() - { - Setup::registerAutoloadGit(__DIR__ . "/../../../../../"); - - $this->assertEquals($this->originalAutoloaderCount + 4, count(spl_autoload_functions())); - } - - public function testPEARAutoload() - { - set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . "/../../../../../lib/vendor/doctrine-common/lib"); - - Setup::registerAutoloadPEAR(); - - $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); - } - - public function testDirectoryAutoload() - { - Setup::registerAutoloadDirectory(__DIR__ . "/../../../../../lib/vendor/doctrine-common/lib"); - - $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); - } - - public function testAnnotationConfiguration() - { - $config = Setup::createAnnotationMetadataConfiguration(array(), true); - - $this->assertInstanceOf('Doctrine\ORM\Configuration', $config); - $this->assertEquals(sys_get_temp_dir(), $config->getProxyDir()); - $this->assertEquals('DoctrineProxies', $config->getProxyNamespace()); - $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $config->getMetadataDriverImpl()); - } - - public function testXMLConfiguration() - { - $config = Setup::createXMLMetadataConfiguration(array(), true); - - $this->assertInstanceOf('Doctrine\ORM\Configuration', $config); - $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\XmlDriver', $config->getMetadataDriverImpl()); - } - - public function testYAMLConfiguration() - { - $config = Setup::createYAMLMetadataConfiguration(array(), true); - - $this->assertInstanceOf('Doctrine\ORM\Configuration', $config); - $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\YamlDriver', $config->getMetadataDriverImpl()); - } - - /** - * @group DDC-1350 - */ - public function testConfigureProxyDir() - { - $config = Setup::createAnnotationMetadataConfiguration(array(), true, "/foo"); - $this->assertEquals('/foo', $config->getProxyDir()); - } - - /** - * @group DDC-1350 - */ - public function testConfigureCache() - { - $cache = new ArrayCache(); - $config = Setup::createAnnotationMetadataConfiguration(array(), true, null, $cache); - - $this->assertSame($cache, $config->getResultCacheImpl()); - $this->assertSame($cache, $config->getMetadataCacheImpl()); - $this->assertSame($cache, $config->getQueryCacheImpl()); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml deleted file mode 100755 index efa24c7916..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml +++ /dev/null @@ -1,28 +0,0 @@ -User: - tableName: users - columns: - username: - type: string(255) - length: 100 - notnull: true - unique: true - password: - type: string(255) - clob: clob - test_alias as theAlias: - type: string(255) - indexes: - username: - fields: [username] - type: unique - -Profile: - columns: - first_name: string(255) - last_name: string(255) - user_id: integer - relations: - User: - onDelete: CASCADE - foreignType: one - type: one \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php deleted file mode 100755 index a09382b30b..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ /dev/null @@ -1,344 +0,0 @@ -_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock()); - $this->_emMock = EntityManagerMock::create($this->_connectionMock); - // SUT - $this->_unitOfWork = new UnitOfWorkMock($this->_emMock); - $this->_emMock->setUnitOfWork($this->_unitOfWork); - } - - protected function tearDown() { - } - - public function testRegisterRemovedOnNewEntityIsIgnored() - { - $user = new ForumUser(); - $user->username = 'romanb'; - $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user)); - $this->_unitOfWork->scheduleForDelete($user); - $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user)); - } - - - /* Operational tests */ - - public function testSavingSingleEntityWithIdentityColumnForcesInsert() - { - // Setup fake persister and id generator for identity generation - $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser")); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister); - //$idGeneratorMock = new IdentityIdGeneratorMock($this->_emMock); - //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $idGeneratorMock); - $userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY); - - // Test - $user = new ForumUser(); - $user->username = 'romanb'; - $this->_unitOfWork->persist($user); - - // Check - $this->assertEquals(0, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); - $this->assertFalse($this->_unitOfWork->isInIdentityMap($user)); - // should no longer be scheduled for insert - $this->assertTrue($this->_unitOfWork->isScheduledForInsert($user)); - - // Now lets check whether a subsequent commit() does anything - $userPersister->reset(); - - // Test - $this->_unitOfWork->commit(); - - // Check. - $this->assertEquals(1, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); - - // should have an id - $this->assertTrue(is_numeric($user->id)); - } - - /** - * Tests a scenario where a save() operation is cascaded from a ForumUser - * to its associated ForumAvatar, both entities using IDENTITY id generation. - */ - public function testCascadedIdentityColumnInsert() - { - // Setup fake persister and id generator for identity generation - //ForumUser - $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser")); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister); - //$userIdGeneratorMock = new IdentityIdGeneratorMock($this->_emMock); - //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $userIdGeneratorMock); - $userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY); - // ForumAvatar - $avatarPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumAvatar")); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumAvatar', $avatarPersister); - //$avatarIdGeneratorMock = new IdentityIdGeneratorMock($this->_emMock); - //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumAvatar', $avatarIdGeneratorMock); - $avatarPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY); - - // Test - $user = new ForumUser(); - $user->username = 'romanb'; - $avatar = new ForumAvatar(); - $user->avatar = $avatar; - $this->_unitOfWork->persist($user); // save cascaded to avatar - - $this->_unitOfWork->commit(); - - $this->assertTrue(is_numeric($user->id)); - $this->assertTrue(is_numeric($avatar->id)); - - $this->assertEquals(1, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); - - $this->assertEquals(1, count($avatarPersister->getInserts())); - $this->assertEquals(0, count($avatarPersister->getUpdates())); - $this->assertEquals(0, count($avatarPersister->getDeletes())); - } - - public function testChangeTrackingNotify() - { - $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\ORM\NotifyChangedEntity")); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\ORM\NotifyChangedEntity', $persister); - $itemPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\ORM\NotifyChangedRelatedItem")); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\ORM\NotifyChangedRelatedItem', $itemPersister); - - $entity = new NotifyChangedEntity; - $entity->setData('thedata'); - $this->_unitOfWork->persist($entity); - - $this->_unitOfWork->commit(); - $this->assertEquals(1, count($persister->getInserts())); - $persister->reset(); - - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); - - $entity->setData('newdata'); - $entity->setTransient('newtransientvalue'); - - $this->assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity)); - - $this->assertEquals(array('data' => array('thedata', 'newdata')), $this->_unitOfWork->getEntityChangeSet($entity)); - - $item = new NotifyChangedRelatedItem(); - $entity->getItems()->add($item); - $item->setOwner($entity); - $this->_unitOfWork->persist($item); - - $this->_unitOfWork->commit(); - $this->assertEquals(1, count($itemPersister->getInserts())); - $persister->reset(); - $itemPersister->reset(); - - - $entity->getItems()->removeElement($item); - $item->setOwner(null); - $this->assertTrue($entity->getItems()->isDirty()); - $this->_unitOfWork->commit(); - $updates = $itemPersister->getUpdates(); - $this->assertEquals(1, count($updates)); - $this->assertTrue($updates[0] === $item); - } - - public function testGetEntityStateOnVersionedEntityWithAssignedIdentifier() - { - $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\ORM\VersionedAssignedIdentifierEntity")); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\ORM\VersionedAssignedIdentifierEntity', $persister); - - $e = new VersionedAssignedIdentifierEntity(); - $e->id = 42; - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($e)); - $this->assertFalse($persister->isExistsCalled()); - } - - public function testGetEntityStateWithAssignedIdentity() - { - $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\CMS\CmsPhonenumber")); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\CMS\CmsPhonenumber', $persister); - - $ph = new \Doctrine\Tests\Models\CMS\CmsPhonenumber(); - $ph->phonenumber = '12345'; - - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($ph)); - $this->assertTrue($persister->isExistsCalled()); - - $persister->reset(); - - // if the entity is already managed the exists() check should be skipped - $this->_unitOfWork->registerManaged($ph, array('phonenumber' => '12345'), array()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_unitOfWork->getEntityState($ph)); - $this->assertFalse($persister->isExistsCalled()); - $ph2 = new \Doctrine\Tests\Models\CMS\CmsPhonenumber(); - $ph2->phonenumber = '12345'; - $this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); - $this->assertFalse($persister->isExistsCalled()); - } - - /** - * DDC-2086 [GH-484] Prevented "Undefined index" notice when updating. - */ - public function testNoUndefinedIndexNoticeOnScheduleForUpdateWithoutChanges() - { - // Setup fake persister and id generator - $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser")); - $userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister); - - // Create a test user - $user = new ForumUser(); - $user->name = 'Jasper'; - $this->_unitOfWork->persist($user); - $this->_unitOfWork->commit(); - - // Schedule user for update without changes - $this->_unitOfWork->scheduleForUpdate($user); - - // This commit should not raise an E_NOTICE - $this->_unitOfWork->commit(); - } - - /** - * @group DDC-1984 - */ - public function testLockWithoutEntityThrowsException() - { - $this->setExpectedException('InvalidArgumentException'); - $this->_unitOfWork->lock(null, null, null); - } -} - -/** - * @Entity - */ -class NotifyChangedEntity implements \Doctrine\Common\NotifyPropertyChanged -{ - private $_listeners = array(); - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - private $id; - /** - * @Column(type="string") - */ - private $data; - - private $transient; // not persisted - - /** @OneToMany(targetEntity="NotifyChangedRelatedItem", mappedBy="owner") */ - private $items; - - public function __construct() { - $this->items = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function getId() { - return $this->id; - } - - public function getItems() { - return $this->items; - } - - public function setTransient($value) { - if ($value != $this->transient) { - $this->_onPropertyChanged('transient', $this->transient, $value); - $this->transient = $value; - } - } - - public function getData() { - return $this->data; - } - - public function setData($data) { - if ($data != $this->data) { - $this->_onPropertyChanged('data', $this->data, $data); - $this->data = $data; - } - } - - public function addPropertyChangedListener(\Doctrine\Common\PropertyChangedListener $listener) - { - $this->_listeners[] = $listener; - } - - protected function _onPropertyChanged($propName, $oldValue, $newValue) { - if ($this->_listeners) { - foreach ($this->_listeners as $listener) { - $listener->propertyChanged($this, $propName, $oldValue, $newValue); - } - } - } -} - -/** @Entity */ -class NotifyChangedRelatedItem -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - private $id; - - /** @ManyToOne(targetEntity="NotifyChangedEntity", inversedBy="items") */ - private $owner; - - public function getId() { - return $this->id; - } - - public function getOwner() { - return $this->owner; - } - - public function setOwner($owner) { - $this->owner = $owner; - } -} - -/** @Entity */ -class VersionedAssignedIdentifierEntity -{ - /** - * @Id @Column(type="integer") - */ - public $id; - /** - * @Version @Column(type="integer") - */ - public $version; -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmFunctionalTestCase.php deleted file mode 100755 index 4b72a9a276..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ /dev/null @@ -1,416 +0,0 @@ - array( - 'Doctrine\Tests\Models\CMS\CmsUser', - 'Doctrine\Tests\Models\CMS\CmsPhonenumber', - 'Doctrine\Tests\Models\CMS\CmsAddress', - 'Doctrine\Tests\Models\CMS\CmsEmail', - 'Doctrine\Tests\Models\CMS\CmsGroup', - 'Doctrine\Tests\Models\CMS\CmsArticle', - 'Doctrine\Tests\Models\CMS\CmsComment', - ), - 'forum' => array(), - 'company' => array( - 'Doctrine\Tests\Models\Company\CompanyPerson', - 'Doctrine\Tests\Models\Company\CompanyEmployee', - 'Doctrine\Tests\Models\Company\CompanyManager', - 'Doctrine\Tests\Models\Company\CompanyOrganization', - 'Doctrine\Tests\Models\Company\CompanyEvent', - 'Doctrine\Tests\Models\Company\CompanyAuction', - 'Doctrine\Tests\Models\Company\CompanyRaffle', - 'Doctrine\Tests\Models\Company\CompanyCar', - 'Doctrine\Tests\Models\Company\CompanyContract', - ), - 'ecommerce' => array( - 'Doctrine\Tests\Models\ECommerce\ECommerceCart', - 'Doctrine\Tests\Models\ECommerce\ECommerceCustomer', - 'Doctrine\Tests\Models\ECommerce\ECommerceProduct', - 'Doctrine\Tests\Models\ECommerce\ECommerceShipping', - 'Doctrine\Tests\Models\ECommerce\ECommerceFeature', - 'Doctrine\Tests\Models\ECommerce\ECommerceCategory' - ), - 'generic' => array( - 'Doctrine\Tests\Models\Generic\BooleanModel', - 'Doctrine\Tests\Models\Generic\DateTimeModel', - 'Doctrine\Tests\Models\Generic\DecimalModel', - 'Doctrine\Tests\Models\Generic\SerializationModel', - ), - 'routing' => array( - 'Doctrine\Tests\Models\Routing\RoutingLeg', - 'Doctrine\Tests\Models\Routing\RoutingLocation', - 'Doctrine\Tests\Models\Routing\RoutingRoute', - 'Doctrine\Tests\Models\Routing\RoutingRouteBooking', - ), - 'navigation' => array( - 'Doctrine\Tests\Models\Navigation\NavUser', - 'Doctrine\Tests\Models\Navigation\NavCountry', - 'Doctrine\Tests\Models\Navigation\NavPhotos', - 'Doctrine\Tests\Models\Navigation\NavTour', - 'Doctrine\Tests\Models\Navigation\NavPointOfInterest', - ), - 'directorytree' => array( - 'Doctrine\Tests\Models\DirectoryTree\AbstractContentItem', - 'Doctrine\Tests\Models\DirectoryTree\File', - 'Doctrine\Tests\Models\DirectoryTree\Directory', - ), - 'ddc117' => array( - 'Doctrine\Tests\Models\DDC117\DDC117Article', - 'Doctrine\Tests\Models\DDC117\DDC117Reference', - 'Doctrine\Tests\Models\DDC117\DDC117Translation', - 'Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', - 'Doctrine\Tests\Models\DDC117\DDC117ApproveChanges', - 'Doctrine\Tests\Models\DDC117\DDC117Editor', - 'Doctrine\Tests\Models\DDC117\DDC117Link', - ), - 'stockexchange' => array( - 'Doctrine\Tests\Models\StockExchange\Bond', - 'Doctrine\Tests\Models\StockExchange\Stock', - 'Doctrine\Tests\Models\StockExchange\Market', - ), - 'legacy' => array( - 'Doctrine\Tests\Models\Legacy\LegacyUser', - 'Doctrine\Tests\Models\Legacy\LegacyUserReference', - 'Doctrine\Tests\Models\Legacy\LegacyArticle', - 'Doctrine\Tests\Models\Legacy\LegacyCar', - ), - 'customtype' => array( - 'Doctrine\Tests\Models\CustomType\CustomTypeChild', - 'Doctrine\Tests\Models\CustomType\CustomTypeParent', - 'Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', - ), - ); - - protected function useModelSet($setName) - { - $this->_usedModelSets[$setName] = true; - } - - /** - * Sweeps the database tables and clears the EntityManager. - */ - protected function tearDown() - { - $conn = static::$_sharedConn; - - $this->_sqlLoggerStack->enabled = false; - - if (isset($this->_usedModelSets['cms'])) { - $conn->executeUpdate('DELETE FROM cms_users_groups'); - $conn->executeUpdate('DELETE FROM cms_groups'); - $conn->executeUpdate('DELETE FROM cms_addresses'); - $conn->executeUpdate('DELETE FROM cms_phonenumbers'); - $conn->executeUpdate('DELETE FROM cms_comments'); - $conn->executeUpdate('DELETE FROM cms_articles'); - $conn->executeUpdate('DELETE FROM cms_users'); - $conn->executeUpdate('DELETE FROM cms_emails'); - } - - if (isset($this->_usedModelSets['ecommerce'])) { - $conn->executeUpdate('DELETE FROM ecommerce_carts_products'); - $conn->executeUpdate('DELETE FROM ecommerce_products_categories'); - $conn->executeUpdate('DELETE FROM ecommerce_products_related'); - $conn->executeUpdate('DELETE FROM ecommerce_carts'); - $conn->executeUpdate('DELETE FROM ecommerce_customers'); - $conn->executeUpdate('DELETE FROM ecommerce_features'); - $conn->executeUpdate('DELETE FROM ecommerce_products'); - $conn->executeUpdate('DELETE FROM ecommerce_shippings'); - $conn->executeUpdate('UPDATE ecommerce_categories SET parent_id = NULL'); - $conn->executeUpdate('DELETE FROM ecommerce_categories'); - } - - if (isset($this->_usedModelSets['company'])) { - $conn->executeUpdate('DELETE FROM company_contract_employees'); - $conn->executeUpdate('DELETE FROM company_contract_managers'); - $conn->executeUpdate('DELETE FROM company_contracts'); - $conn->executeUpdate('DELETE FROM company_persons_friends'); - $conn->executeUpdate('DELETE FROM company_managers'); - $conn->executeUpdate('DELETE FROM company_employees'); - $conn->executeUpdate('UPDATE company_persons SET spouse_id = NULL'); - $conn->executeUpdate('DELETE FROM company_persons'); - $conn->executeUpdate('DELETE FROM company_raffles'); - $conn->executeUpdate('DELETE FROM company_auctions'); - $conn->executeUpdate('UPDATE company_organizations SET main_event_id = NULL'); - $conn->executeUpdate('DELETE FROM company_events'); - $conn->executeUpdate('DELETE FROM company_organizations'); - } - - if (isset($this->_usedModelSets['generic'])) { - $conn->executeUpdate('DELETE FROM boolean_model'); - $conn->executeUpdate('DELETE FROM date_time_model'); - $conn->executeUpdate('DELETE FROM decimal_model'); - $conn->executeUpdate('DELETE FROM serialize_model'); - } - - if (isset($this->_usedModelSets['routing'])) { - $conn->executeUpdate('DELETE FROM RoutingRouteLegs'); - $conn->executeUpdate('DELETE FROM RoutingRouteBooking'); - $conn->executeUpdate('DELETE FROM RoutingRoute'); - $conn->executeUpdate('DELETE FROM RoutingLeg'); - $conn->executeUpdate('DELETE FROM RoutingLocation'); - } - - if(isset($this->_usedModelSets['navigation'])) { - $conn->executeUpdate('DELETE FROM navigation_tour_pois'); - $conn->executeUpdate('DELETE FROM navigation_photos'); - $conn->executeUpdate('DELETE FROM navigation_pois'); - $conn->executeUpdate('DELETE FROM navigation_tours'); - $conn->executeUpdate('DELETE FROM navigation_countries'); - } - if (isset($this->_usedModelSets['directorytree'])) { - $conn->executeUpdate('DELETE FROM ' . $this->_em->getConnection()->getDatabasePlatform()->quoteIdentifier("file")); - // MySQL doesnt know deferred deletions therefore only executing the second query gives errors. - $conn->executeUpdate('DELETE FROM Directory WHERE parentDirectory_id IS NOT NULL'); - $conn->executeUpdate('DELETE FROM Directory'); - } - if (isset($this->_usedModelSets['ddc117'])) { - $conn->executeUpdate('DELETE FROM ddc117editor_ddc117translation'); - $conn->executeUpdate('DELETE FROM DDC117Editor'); - $conn->executeUpdate('DELETE FROM DDC117ApproveChanges'); - $conn->executeUpdate('DELETE FROM DDC117Link'); - $conn->executeUpdate('DELETE FROM DDC117Reference'); - $conn->executeUpdate('DELETE FROM DDC117ArticleDetails'); - $conn->executeUpdate('DELETE FROM DDC117Translation'); - $conn->executeUpdate('DELETE FROM DDC117Article'); - } - if (isset($this->_usedModelSets['stockexchange'])) { - $conn->executeUpdate('DELETE FROM exchange_bonds_stocks'); - $conn->executeUpdate('DELETE FROM exchange_bonds'); - $conn->executeUpdate('DELETE FROM exchange_stocks'); - $conn->executeUpdate('DELETE FROM exchange_markets'); - } - if (isset($this->_usedModelSets['legacy'])) { - $conn->executeUpdate('DELETE FROM legacy_users_cars'); - $conn->executeUpdate('DELETE FROM legacy_users_reference'); - $conn->executeUpdate('DELETE FROM legacy_articles'); - $conn->executeUpdate('DELETE FROM legacy_cars'); - $conn->executeUpdate('DELETE FROM legacy_users'); - } - - if (isset($this->_usedModelSets['customtype'])) { - $conn->executeUpdate('DELETE FROM customtype_parent_friends'); - $conn->executeUpdate('DELETE FROM customtype_parents'); - $conn->executeUpdate('DELETE FROM customtype_children'); - $conn->executeUpdate('DELETE FROM customtype_uppercases'); - } - - $this->_em->clear(); - } - - protected function setUpEntitySchema(array $classNames) - { - if ($this->_em === null) { - throw new \RuntimeException("EntityManager not set, you have to call parent::setUp() before invoking this method."); - } - - $classes = array(); - foreach ($classNames as $className) { - if ( ! isset(static::$_entityTablesCreated[$className])) { - static::$_entityTablesCreated[$className] = true; - $classes[] = $this->_em->getClassMetadata($className); - } - } - - if ($classes) { - $this->_schemaTool->createSchema($classes); - } - } - - /** - * Creates a connection to the test database, if there is none yet, and - * creates the necessary tables. - */ - protected function setUp() - { - $forceCreateTables = false; - - if ( ! isset(static::$_sharedConn)) { - static::$_sharedConn = TestUtil::getConnection(); - - if (static::$_sharedConn->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) { - $forceCreateTables = true; - } - } - - if (isset($GLOBALS['DOCTRINE_MARK_SQL_LOGS'])) { - if (in_array(static::$_sharedConn->getDatabasePlatform()->getName(), array("mysql", "postgresql"))) { - static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/'); - } else if (static::$_sharedConn->getDatabasePlatform()->getName() == "oracle") { - static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/ FROM dual'); - } - } - - if ( ! $this->_em) { - $this->_em = $this->_getEntityManager(); - $this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em); - } - - $classes = array(); - - foreach ($this->_usedModelSets as $setName => $bool) { - if ( ! isset(static::$_tablesCreated[$setName])/* || $forceCreateTables*/) { - foreach (static::$_modelSets[$setName] as $className) { - $classes[] = $this->_em->getClassMetadata($className); - } - - static::$_tablesCreated[$setName] = true; - } - } - - if ($classes) { - $this->_schemaTool->createSchema($classes); - } - - $this->_sqlLoggerStack->enabled = true; - } - - /** - * Gets an EntityManager for testing purposes. - * - * @param Configuration $config The Configuration to pass to the EntityManager. - * @param EventManager $eventManager The EventManager to pass to the EntityManager. - * @return EntityManager - */ - protected function _getEntityManager($config = null, $eventManager = null) { - // NOTE: Functional tests use their own shared metadata cache, because - // the actual database platform used during execution has effect on some - // metadata mapping behaviors (like the choice of the ID generation). - if (is_null(self::$_metadataCacheImpl)) { - if (isset($GLOBALS['DOCTRINE_CACHE_IMPL'])) { - self::$_metadataCacheImpl = new $GLOBALS['DOCTRINE_CACHE_IMPL']; - } else { - self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; - } - } - - if (is_null(self::$_queryCacheImpl)) { - self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; - } - - $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack(); - $this->_sqlLoggerStack->enabled = false; - - //FIXME: two different configs! $conn and the created entity manager have - // different configs. - $config = new \Doctrine\ORM\Configuration(); - $config->setMetadataCacheImpl(self::$_metadataCacheImpl); - $config->setQueryCacheImpl(self::$_queryCacheImpl); - $config->setProxyDir(__DIR__ . '/Proxies'); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - - $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(), true)); - - $conn = static::$_sharedConn; - $conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); - - // get rid of more global state - $evm = $conn->getEventManager(); - foreach ($evm->getListeners() AS $event => $listeners) { - foreach ($listeners AS $listener) { - $evm->removeEventListener(array($event), $listener); - } - } - - if (isset($GLOBALS['db_event_subscribers'])) { - foreach (explode(",", $GLOBALS['db_event_subscribers']) AS $subscriberClass) { - $subscriberInstance = new $subscriberClass(); - $evm->addEventSubscriber($subscriberInstance); - } - } - - if (isset($GLOBALS['debug_uow_listener'])) { - $evm->addEventListener(array('onFlush'), new \Doctrine\ORM\Tools\DebugUnitOfWorkListener()); - } - - return \Doctrine\ORM\EntityManager::create($conn, $config); - } - - protected function onNotSuccessfulTest(\Exception $e) - { - if ($e instanceof \PHPUnit_Framework_AssertionFailedError) { - throw $e; - } - - if(isset($this->_sqlLoggerStack->queries) && count($this->_sqlLoggerStack->queries)) { - $queries = ""; - for($i = count($this->_sqlLoggerStack->queries)-1; $i > max(count($this->_sqlLoggerStack->queries)-25, 0) && isset($this->_sqlLoggerStack->queries[$i]); $i--) { - $query = $this->_sqlLoggerStack->queries[$i]; - $params = array_map(function($p) { if (is_object($p)) return get_class($p); else return "'".$p."'"; }, $query['params'] ?: array()); - $queries .= ($i+1).". SQL: '".$query['sql']."' Params: ".implode(", ", $params).PHP_EOL; - } - - $trace = $e->getTrace(); - $traceMsg = ""; - foreach($trace AS $part) { - if(isset($part['file'])) { - if(strpos($part['file'], "PHPUnit/") !== false) { - // Beginning with PHPUnit files we don't print the trace anymore. - break; - } - - $traceMsg .= $part['file'].":".$part['line'].PHP_EOL; - } - } - - $message = "[".get_class($e)."] ".$e->getMessage().PHP_EOL.PHP_EOL."With queries:".PHP_EOL.$queries.PHP_EOL."Trace:".PHP_EOL.$traceMsg; - - throw new \Exception($message, (int)$e->getCode(), $e); - } - throw $e; - } - - /** - * Using the SQL Logger Stack this method retrieves the current query count executed in this test. - * - * @return int - */ - protected function getCurrentQueryCount() - { - return count($this->_sqlLoggerStack->queries); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmPerformanceTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmPerformanceTestCase.php deleted file mode 100755 index ab8fcf5030..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmPerformanceTestCase.php +++ /dev/null @@ -1,60 +0,0 @@ -maxRunningTime != 0 && $time > $this->maxRunningTime) { - $this->fail( - sprintf( - 'expected running time: <= %s but was: %s', - - $this->maxRunningTime, - $time - ) - ); - } - } - - /** - * @param integer $maxRunningTime - * @throws InvalidArgumentException - * @since Method available since Release 2.3.0 - */ - public function setMaxRunningTime($maxRunningTime) - { - if (is_integer($maxRunningTime) && $maxRunningTime >= 0) { - $this->maxRunningTime = $maxRunningTime; - } else { - throw new \InvalidArgumentException; - } - } - - /** - * @return integer - * @since Method available since Release 2.3.0 - */ - public function getMaxRunningTime() - { - return $this->maxRunningTime; - } -} - diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php deleted file mode 100755 index 4ad60d68bc..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php +++ /dev/null @@ -1,117 +0,0 @@ -=')) { - $reader = new \Doctrine\Common\Annotations\CachedReader( - new \Doctrine\Common\Annotations\AnnotationReader(), new ArrayCache() - ); - } - else if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) { - // Register the ORM Annotations in the AnnotationRegistry - $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); - $reader->addNamespace('Doctrine\ORM\Mapping'); - $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); - } - else if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) { - $reader = new \Doctrine\Common\Annotations\AnnotationReader(); - $reader->setIgnoreNotImportedAnnotations(true); - $reader->setEnableParsePhpImports(false); - if ($alias) { - $reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias); - } else { - $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); - } - $reader = new \Doctrine\Common\Annotations\CachedReader( - new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() - ); - } else { - $reader = new \Doctrine\Common\Annotations\AnnotationReader(); - if ($alias) { - $reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias); - } else { - $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); - } - } - \Doctrine\Common\Annotations\AnnotationRegistry::registerFile( - __DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); - return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array)$paths); - } - - /** - * Creates an EntityManager for testing purposes. - * - * NOTE: The created EntityManager will have its dependant DBAL parts completely - * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then - * be configured in the tests to simulate the DBAL behavior that is desired - * for a particular test, - * - * @return Doctrine\ORM\EntityManager - */ - protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true) - { - $metadataCache = $withSharedMetadata - ? self::getSharedMetadataCacheImpl() - : new \Doctrine\Common\Cache\ArrayCache; - - $config = new \Doctrine\ORM\Configuration(); - - $config->setMetadataCacheImpl($metadataCache); - $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(), true)); - $config->setQueryCacheImpl(self::getSharedQueryCacheImpl()); - $config->setProxyDir(__DIR__ . '/Proxies'); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - - if ($conn === null) { - $conn = array( - 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock', - 'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock', - 'user' => 'john', - 'password' => 'wayne' - ); - } - - if (is_array($conn)) { - $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager); - } - - return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager); - } - - private static function getSharedMetadataCacheImpl() - { - if (self::$_metadataCacheImpl === null) { - self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; - } - - return self::$_metadataCacheImpl; - } - - private static function getSharedQueryCacheImpl() - { - if (self::$_queryCacheImpl === null) { - self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; - } - - return self::$_queryCacheImpl; - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/TestInit.php b/vendor/doctrine/orm/tests/Doctrine/Tests/TestInit.php deleted file mode 100755 index 3a35c21042..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/TestInit.php +++ /dev/null @@ -1,43 +0,0 @@ -register(); - -if (isset($GLOBALS['DOCTRINE_DBAL_PATH'])) { - $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', $GLOBALS['DOCTRINE_DBAL_PATH']); -} else { - $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', __DIR__ . '/../../../lib/vendor/doctrine-dbal/lib'); -} -$classLoader->register(); - -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', __DIR__ . '/../../../lib'); -$classLoader->register(); - -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Tests', __DIR__ . '/../../'); -$classLoader->register(); - -$classLoader = new \Doctrine\Common\ClassLoader('Symfony', __DIR__ . "/../../../lib/vendor"); -$classLoader->register(); - -if (!file_exists(__DIR__."/Proxies")) { - if (!mkdir(__DIR__."/Proxies")) { - throw new Exception("Could not create " . __DIR__."/Proxies Folder."); - } -} -if (!file_exists(__DIR__."/ORM/Proxy/generated")) { - if (!mkdir(__DIR__."/ORM/Proxy/generated")) { - throw new Exception("Could not create " . __DIR__."/ORM/Proxy/generated Folder."); - } -} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/TestUtil.php b/vendor/doctrine/orm/tests/Doctrine/Tests/TestUtil.php deleted file mode 100755 index b78d06e4ee..0000000000 --- a/vendor/doctrine/orm/tests/Doctrine/Tests/TestUtil.php +++ /dev/null @@ -1,119 +0,0 @@ -real database connection using the following parameters - * of the $GLOBALS array: - * - * 'db_type' : The name of the Doctrine DBAL database driver to use. - * 'db_username' : The username to use for connecting. - * 'db_password' : The password to use for connecting. - * 'db_host' : The hostname of the database to connect to. - * 'db_name' : The name of the database to connect to. - * 'db_port' : The port of the database to connect to. - * - * Usually these variables of the $GLOBALS array are filled by PHPUnit based - * on an XML configuration file. If no such parameters exist, an SQLite - * in-memory database is used. - * - * IMPORTANT: - * 1) Each invocation of this method returns a NEW database connection. - * 2) The database is dropped and recreated to ensure it's clean. - * - * @return Doctrine\DBAL\Connection The database connection instance. - */ - public static function getConnection() - { - if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'], - $GLOBALS['db_host'], $GLOBALS['db_name'], $GLOBALS['db_port']) && - isset($GLOBALS['tmpdb_type'], $GLOBALS['tmpdb_username'], $GLOBALS['tmpdb_password'], - $GLOBALS['tmpdb_host'], $GLOBALS['tmpdb_name'], $GLOBALS['tmpdb_port'])) { - $realDbParams = array( - 'driver' => $GLOBALS['db_type'], - 'user' => $GLOBALS['db_username'], - 'password' => $GLOBALS['db_password'], - 'host' => $GLOBALS['db_host'], - 'dbname' => $GLOBALS['db_name'], - 'port' => $GLOBALS['db_port'] - ); - $tmpDbParams = array( - 'driver' => $GLOBALS['tmpdb_type'], - 'user' => $GLOBALS['tmpdb_username'], - 'password' => $GLOBALS['tmpdb_password'], - 'host' => $GLOBALS['tmpdb_host'], - 'dbname' => $GLOBALS['tmpdb_name'], - 'port' => $GLOBALS['tmpdb_port'] - ); - - $realConn = \Doctrine\DBAL\DriverManager::getConnection($realDbParams); - - $platform = $realConn->getDatabasePlatform(); - - if ($platform->supportsCreateDropDatabase()) { - $dbname = $realConn->getDatabase(); - // Connect to tmpdb in order to drop and create the real test db. - $tmpConn = \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); - $realConn->close(); - - $tmpConn->getSchemaManager()->dropDatabase($dbname); - $tmpConn->getSchemaManager()->createDatabase($dbname); - - $tmpConn->close(); - } else { - $sm = $realConn->getSchemaManager(); - - /* @var $schema Schema */ - $schema = $sm->createSchema(); - $stmts = $schema->toDropSql($realConn->getDatabasePlatform()); - - foreach ($stmts AS $stmt) { - try { - $realConn->exec($stmt); - } catch(\Exception $e) { - // TODO: Now is this a real good idea? - } - } - } - - $conn = \Doctrine\DBAL\DriverManager::getConnection($realDbParams, null, null); - } else { - $params = array( - 'driver' => 'pdo_sqlite', - 'memory' => true - ); - if (isset($GLOBALS['db_path'])) { - $params['path'] = $GLOBALS['db_path']; - unlink($GLOBALS['db_path']); - } - $conn = \Doctrine\DBAL\DriverManager::getConnection($params); - } - - return $conn; - } - - /** - * @return \Doctrine\DBAL\Connection - */ - public static function getTempConnection() - { - $tmpDbParams = array( - 'driver' => $GLOBALS['tmpdb_type'], - 'user' => $GLOBALS['tmpdb_username'], - 'password' => $GLOBALS['tmpdb_password'], - 'host' => $GLOBALS['tmpdb_host'], - 'dbname' => $GLOBALS['tmpdb_name'], - 'port' => $GLOBALS['tmpdb_port'] - ); - - // Connect to tmpdb in order to drop and create the real test db. - return \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/NativePhpunitTask.php b/vendor/doctrine/orm/tests/NativePhpunitTask.php deleted file mode 100755 index 8a3b190c7f..0000000000 --- a/vendor/doctrine/orm/tests/NativePhpunitTask.php +++ /dev/null @@ -1,249 +0,0 @@ - - */ -class NativePhpunitTask extends Task -{ - private $test; - private $testfile; - private $testdirectory; - private $configuration = null; - private $coverageClover = null; - private $junitlogfile = null; - private $haltonfailure = true; - private $haltonerror = true; - - public function setTestdirectory($directory) { - $this->testdirectory = $directory; - } - - public function setTest($test) { - $this->test = $test; - } - - public function setTestfile($testfile) { - $this->testfile = $testfile; - } - - public function setJunitlogfile($junitlogfile) { - if (strlen($junitlogfile) == 0) { - $junitlogfile = NULL; - } - - $this->junitlogfile = $junitlogfile; - } - - public function setConfiguration($configuration) { - if (strlen($configuration) == 0) { - $configuration = NULL; - } - - $this->configuration = $configuration; - } - - public function setCoverageClover($coverageClover) { - if (strlen($coverageClover) == 0) { - $coverageClover = NULL; - } - - $this->coverageClover = $coverageClover; - } - - public function setHaltonfailure($haltonfailures) { - $this->haltonfailure = $haltonfailures; - } - - public function setHaltonerror($haltonerrors) { - $this->haltonerror = $haltonerrors; - } - - public function init() - { - require_once "PHPUnit/Runner/Version.php"; - $version = PHPUnit_Runner_Version::id(); - - if (version_compare($version, '3.4.0') < 0) - { - throw new BuildException("NativePHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation()); - } - - require_once 'PHPUnit/Util/Filter.php'; - - // point PHPUnit_MAIN_METHOD define to non-existing method - if (!defined('PHPUnit_MAIN_METHOD')) - { - define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined'); - } - } - - public function main() - { - if (!is_dir(realpath($this->testdirectory))) { - throw new BuildException("NativePHPUnitTask requires a Test Directory path given, '".$this->testdirectory."' given."); - } - set_include_path(realpath($this->testdirectory) . PATH_SEPARATOR . get_include_path()); - - $printer = new NativePhpunitPrinter(); - - $arguments = array( - 'configuration' => $this->configuration, - 'coverageClover' => $this->coverageClover, - 'junitLogfile' => $this->junitlogfile, - 'printer' => $printer, - ); - - require_once "PHPUnit/TextUI/TestRunner.php"; - $runner = new PHPUnit_TextUI_TestRunner(); - $suite = $runner->getTest($this->test, $this->testfile, true); - - try { - $result = $runner->doRun($suite, $arguments); - /* @var $result PHPUnit_Framework_TestResult */ - - if ( ($this->haltonfailure && $result->failureCount() > 0) || ($this->haltonerror && $result->errorCount() > 0) ) { - throw new BuildException("PHPUnit: ".$result->failureCount()." Failures and ".$result->errorCount()." Errors, ". - "last failure message: ".$printer->getMessages()); - } - - $this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ". - "failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)"); - - // Hudson for example doesn't like the backslash in class names - if (file_exists($this->coverageClover)) { - $this->log("Generated Clover Coverage XML to: ".$this->coverageClover); - $content = file_get_contents($this->coverageClover); - $content = str_replace("\\", ".", $content); - file_put_contents($this->coverageClover, $content); - unset($content); - } - - } catch(\Exception $e) { - throw new BuildException("NativePhpunitTask failed: ".$e->getMessage()); - } - } -} - -class NativePhpunitPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener -{ - private $_messages = array(); - - public function write($buffer) - { - // do nothing - } - - public function getMessages() - { - return $this->_messages; - } - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->_messages[] = "Test ERROR: ".$test->getName().": ".$e->getMessage(); - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - $this->_messages[] = "Test FAILED: ".$test->getName().": ".$e->getMessage(); - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - - } - - /** - * A test suite started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - - } - - /** - * A test suite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/README.markdown b/vendor/doctrine/orm/tests/README.markdown deleted file mode 100755 index c1027acedd..0000000000 --- a/vendor/doctrine/orm/tests/README.markdown +++ /dev/null @@ -1,25 +0,0 @@ -# Running the Doctrine 2 Testsuite - -## Setting up a PHPUnit Configuration XML - -.. - -## Testing Lock-Support - -The Lock support in Doctrine 2 is tested using Gearman, which allows to run concurrent tasks in parallel. -Install Gearman with PHP as follows: - -1. Go to http://www.gearman.org and download the latest Gearman Server -2. Compile it and then call ldconfig -3. Start it up "gearmand -vvvv" -4. Install pecl/gearman by calling "gearman-beta" - -You can then go into tests/ and start up two workers: - - php Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php - -Then run the locking test-suite: - - phpunit --configuration Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php - -This can run considerable time, because it is using sleep() to test for the timing ranges of locks. \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/dbproperties.xml.dev b/vendor/doctrine/orm/tests/dbproperties.xml.dev deleted file mode 100755 index 503cb858eb..0000000000 --- a/vendor/doctrine/orm/tests/dbproperties.xml.dev +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/travis/mysql.travis.xml b/vendor/doctrine/orm/tests/travis/mysql.travis.xml deleted file mode 100755 index f17a4b87d9..0000000000 --- a/vendor/doctrine/orm/tests/travis/mysql.travis.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ./../Doctrine/Tests/ORM - - - - - performance - locking_functional - - - - - diff --git a/vendor/doctrine/orm/tests/travis/pgsql.travis.xml b/vendor/doctrine/orm/tests/travis/pgsql.travis.xml deleted file mode 100755 index fa0581acbb..0000000000 --- a/vendor/doctrine/orm/tests/travis/pgsql.travis.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - ./../Doctrine/Tests/ORM - - - - - - performance - locking_functional - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/travis/sqlite.travis.xml b/vendor/doctrine/orm/tests/travis/sqlite.travis.xml deleted file mode 100755 index 5d310c3276..0000000000 --- a/vendor/doctrine/orm/tests/travis/sqlite.travis.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - ./../Doctrine/Tests/ORM - - - - - performance - locking_functional - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/Entities/Address.php b/vendor/doctrine/orm/tools/sandbox/Entities/Address.php deleted file mode 100755 index 717ea63a10..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/Entities/Address.php +++ /dev/null @@ -1,45 +0,0 @@ -id; - } - - public function getStreet() - { - return $this->street; - } - - public function setStreet($street) - { - $this->street = $street; - } - - public function getUser() - { - return $this->user; - } - - public function setUser(User $user) - { - if ($this->user !== $user) { - $this->user = $user; - $user->setAddress($this); - } - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/Entities/User.php b/vendor/doctrine/orm/tools/sandbox/Entities/User.php deleted file mode 100755 index cd184212c0..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/Entities/User.php +++ /dev/null @@ -1,48 +0,0 @@ -id; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getAddress() - { - return $this->address; - } - - public function setAddress(Address $address) - { - if ($this->address !== $address) { - $this->address = $address; - $address->setUser($this); - } - } -} \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/cli-config.php b/vendor/doctrine/orm/tools/sandbox/cli-config.php deleted file mode 100755 index 2a34fd89bf..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/cli-config.php +++ /dev/null @@ -1,36 +0,0 @@ -register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); -$classLoader->register(); - -$config = new \Doctrine\ORM\Configuration(); -$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); -$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); -$config->setMetadataDriverImpl($driverImpl); - -$config->setProxyDir(__DIR__ . '/Proxies'); -$config->setProxyNamespace('Proxies'); - -$connectionOptions = array( - 'driver' => 'pdo_sqlite', - 'path' => 'database.sqlite' -); - -$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); - -$helpers = new Symfony\Component\Console\Helper\HelperSet(array( - 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), - 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) -)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/doctrine b/vendor/doctrine/orm/tools/sandbox/doctrine deleted file mode 100755 index 92f323f8c8..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/doctrine +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env php -register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); -$classLoader->register(); - -// Variable $helperSet is defined inside cli-config.php -require __DIR__ . '/cli-config.php'; - -$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION); -$cli->setCatchExceptions(true); -$helperSet = $cli->getHelperSet(); -foreach ($helpers as $name => $helper) { - $helperSet->set($helper, $name); -} -$cli->addCommands(array( - // DBAL Commands - new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), - new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), - - // ORM Commands - new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), - new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), - new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), - new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), - new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), - new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), - new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), - new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), - new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), - new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), - new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), - new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), - new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), - new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(), - -)); -$cli->run(); diff --git a/vendor/doctrine/orm/tools/sandbox/index.php b/vendor/doctrine/orm/tools/sandbox/index.php deleted file mode 100755 index ad1cb9d6b1..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/index.php +++ /dev/null @@ -1,62 +0,0 @@ -register(); -$classLoader = new ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); -$classLoader->register(); -$classLoader = new ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); -$classLoader->register(); -$classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); -$classLoader->register(); -$classLoader = new ClassLoader('Entities', __DIR__); -$classLoader->register(); -$classLoader = new ClassLoader('Proxies', __DIR__); -$classLoader->register(); - -// Set up caches -$config = new Configuration; -$cache = new ApcCache; -$config->setMetadataCacheImpl($cache); -$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); -$config->setMetadataDriverImpl($driverImpl); -$config->setQueryCacheImpl($cache); - -// Proxy configuration -$config->setProxyDir(__DIR__ . '/Proxies'); -$config->setProxyNamespace('Proxies'); -$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); - -// Database connection information -$connectionOptions = array( - 'driver' => 'pdo_sqlite', - 'path' => 'database.sqlite' -); - -// Create EntityManager -$em = EntityManager::create($connectionOptions, $config); - -## PUT YOUR TEST CODE BELOW - -$user = new User; -$address = new Address; - -echo 'Hello World!' . PHP_EOL; diff --git a/vendor/doctrine/orm/tools/sandbox/xml/Entities.Address.dcm.xml b/vendor/doctrine/orm/tools/sandbox/xml/Entities.Address.dcm.xml deleted file mode 100755 index 7e8dd01834..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/xml/Entities.Address.dcm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/xml/Entities.User.dcm.xml b/vendor/doctrine/orm/tools/sandbox/xml/Entities.User.dcm.xml deleted file mode 100755 index e548fd1a77..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/xml/Entities.User.dcm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - diff --git a/vendor/doctrine/orm/tools/sandbox/yaml/Entities.Address.dcm.yml b/vendor/doctrine/orm/tools/sandbox/yaml/Entities.Address.dcm.yml deleted file mode 100755 index 140e90224b..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/yaml/Entities.Address.dcm.yml +++ /dev/null @@ -1,16 +0,0 @@ -Entities\Address: - type: entity - table: addresses - id: - id: - type: integer - generator: - strategy: AUTO - fields: - street: - type: string - length: 255 - oneToOne: - user: - targetEntity: User - mappedBy: address \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/yaml/Entities.User.dcm.yml b/vendor/doctrine/orm/tools/sandbox/yaml/Entities.User.dcm.yml deleted file mode 100755 index a93d48f9f7..0000000000 --- a/vendor/doctrine/orm/tools/sandbox/yaml/Entities.User.dcm.yml +++ /dev/null @@ -1,18 +0,0 @@ -Entities\User: - type: entity - table: users - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 50 - oneToOne: - address: - targetEntity: Address - joinColumn: - name: address_id - referencedColumnName: id diff --git a/vendor/phpunit/php-code-coverage/.gitattributes b/vendor/phpunit/php-code-coverage/.gitattributes old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/.gitignore b/vendor/phpunit/php-code-coverage/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/.travis.yml b/vendor/phpunit/php-code-coverage/.travis.yml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/CONTRIBUTING.md b/vendor/phpunit/php-code-coverage/CONTRIBUTING.md old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/LICENSE b/vendor/phpunit/php-code-coverage/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php.in b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Autoload.php.in old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Driver.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Driver.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Driver/Xdebug.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Driver/Xdebug.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Exception.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Exception.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Filter.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Filter.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Clover.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Clover.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Factory.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Dashboard.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Dashboard.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Directory.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Directory.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/File.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/File.php old mode 100755 new mode 100644 index 351028b985..081213c8cf --- a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/File.php +++ b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/File.php @@ -148,7 +148,7 @@ class PHP_CodeCoverage_Report_HTML_Renderer_File extends PHP_CodeCoverage_Report 'testedMethodsPercentAsString' => $node->getTestedMethodsPercent(), 'testedClassesPercent' => $node->getTestedClassesAndTraitsPercent(FALSE), 'testedClassesPercentAsString' => $node->getTestedClassesAndTraitsPercent(), - 'crap' => 'CRAP' + 'crap' => 'CRAP' ) ); diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/coverage_bar.html.dist b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/coverage_bar.html.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/css/bootstrap-responsive.min.css b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/css/bootstrap-responsive.min.css old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/css/bootstrap.min.css b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/css/bootstrap.min.css old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/css/style.css b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/css/style.css old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist old mode 100755 new mode 100644 index a15adf37f0..89e1265912 --- a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist +++ b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/dashboard.html.dist @@ -72,11 +72,13 @@ $(document).ready(function() { labels: {style: {fontSize: '8px'}}, categories: [ '0%','0-10%','10-20%','20-30%','30-40%','40-50%','50-60%','60-70%','70-80%','80-90%','90-100%','100%' - ] + ], + min: 0 }, yAxis: { title: '', labels: {style: {fontSize: '8px'}}, + min: 0 }, series: [{ data: {ccd_values} @@ -94,10 +96,12 @@ $(document).ready(function() { xAxis: { title: {text: 'Code Coverage (in percent)'}, labels: {enabled: true}, + min: 0 }, yAxis: { title: {text: 'Cyclomatic Complexity'}, labels: {enabled: true}, + min: 0 }, tooltip: { formatter: function() { diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory.html.dist b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory.html.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory_item.html.dist b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/directory_item.html.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/file.html.dist b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/file.html.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/file_item.html.dist b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/file_item.html.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/img/glyphicons-halflings-white.png b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/img/glyphicons-halflings-white.png old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/img/glyphicons-halflings.png b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/img/glyphicons-halflings.png old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/bootstrap.min.js b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/bootstrap.min.js old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/highcharts.js b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/highcharts.js old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/html5shiv.js b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/html5shiv.js old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/jquery.min.js b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/js/jquery.min.js old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/method_item.html.dist b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/HTML/Renderer/Template/method_item.html.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/Directory.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/Directory.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/File.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/File.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/Iterator.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Node/Iterator.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/PHP.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/PHP.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Text.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Report/Text.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util/InvalidArgumentHelper.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util/InvalidArgumentHelper.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Version.php b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Version.php old mode 100755 new mode 100644 index 2c083bdf65..f78627a65b --- a/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Version.php +++ b/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Version.php @@ -56,7 +56,7 @@ */ class PHP_CodeCoverage_Version { - const VERSION = '1.2.12'; + const VERSION = '1.2.13'; protected static $version; /** diff --git a/vendor/phpunit/php-code-coverage/README.markdown b/vendor/phpunit/php-code-coverage/README.markdown old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/FilterTest.php b/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/FilterTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/Report/CloverTest.php b/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/Report/CloverTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/Report/FactoryTest.php b/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/Report/FactoryTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/UtilTest.php b/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverage/UtilTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverageTest.php b/vendor/phpunit/php-code-coverage/Tests/PHP/CodeCoverageTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/TestCase.php b/vendor/phpunit/php-code-coverage/Tests/TestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/BankAccount-clover.xml b/vendor/phpunit/php-code-coverage/Tests/_files/BankAccount-clover.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/BankAccount.php b/vendor/phpunit/php-code-coverage/Tests/_files/BankAccount.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/BankAccountTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/BankAccountTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageClassExtendedTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageClassExtendedTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageClassTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageClassTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesWhitespaceTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionParenthesesWhitespaceTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageFunctionTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodOneLineAnnotationTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodOneLineAnnotationTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesWhitespaceTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodParenthesesWhitespaceTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageMethodTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNoneTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNoneTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNotPrivateTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNotPrivateTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNotProtectedTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNotProtectedTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNotPublicTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNotPublicTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNothingTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageNothingTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoveragePrivateTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoveragePrivateTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageProtectedTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageProtectedTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoveragePublicTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoveragePublicTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoverageTwoDefaultClassAnnotations.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoverageTwoDefaultClassAnnotations.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoveredClass.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoveredClass.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/CoveredFunction.php b/vendor/phpunit/php-code-coverage/Tests/_files/CoveredFunction.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageClassExtendedTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageClassExtendedTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageClassTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageClassTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageCoversClassPublicTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageCoversClassPublicTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageCoversClassTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageCoversClassTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageMethodTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageMethodTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageNotPrivateTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageNotPrivateTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageNotProtectedTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageNotProtectedTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageNotPublicTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageNotPublicTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoveragePrivateTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoveragePrivateTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageProtectedTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoverageProtectedTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoveragePublicTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoveragePublicTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoveredClass.php b/vendor/phpunit/php-code-coverage/Tests/_files/NamespaceCoveredClass.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/NotExistingCoveredElementTest.php b/vendor/phpunit/php-code-coverage/Tests/_files/NotExistingCoveredElementTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/class-with-anonymous-function-clover.xml b/vendor/phpunit/php-code-coverage/Tests/_files/class-with-anonymous-function-clover.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/ignored-lines-clover.xml b/vendor/phpunit/php-code-coverage/Tests/_files/ignored-lines-clover.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/source_with_class_and_anonymous_function.php b/vendor/phpunit/php-code-coverage/Tests/_files/source_with_class_and_anonymous_function.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/source_with_ignore.php b/vendor/phpunit/php-code-coverage/Tests/_files/source_with_ignore.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/source_with_namespace.php b/vendor/phpunit/php-code-coverage/Tests/_files/source_with_namespace.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/source_with_oneline_annotations.php b/vendor/phpunit/php-code-coverage/Tests/_files/source_with_oneline_annotations.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/source_without_ignore.php b/vendor/phpunit/php-code-coverage/Tests/_files/source_without_ignore.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/Tests/_files/source_without_namespace.php b/vendor/phpunit/php-code-coverage/Tests/_files/source_without_namespace.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/build.xml b/vendor/phpunit/php-code-coverage/build.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php b/vendor/phpunit/php-code-coverage/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/build/PHPCS/Sniffs/Whitespace/ConcatenationSpacingSniff.php b/vendor/phpunit/php-code-coverage/build/PHPCS/Sniffs/Whitespace/ConcatenationSpacingSniff.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/build/PHPCS/ruleset.xml b/vendor/phpunit/php-code-coverage/build/PHPCS/ruleset.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/build/phpmd.xml b/vendor/phpunit/php-code-coverage/build/phpmd.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/build/travis-ci.xml b/vendor/phpunit/php-code-coverage/build/travis-ci.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/composer.json b/vendor/phpunit/php-code-coverage/composer.json old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/package.xml b/vendor/phpunit/php-code-coverage/package.xml old mode 100755 new mode 100644 index aba7a63713..89332b43d9 --- a/vendor/phpunit/php-code-coverage/package.xml +++ b/vendor/phpunit/php-code-coverage/package.xml @@ -17,9 +17,9 @@ sb@sebastian-bergmann.de yes - 2013-07-06 + 2013-09-10 - 1.2.12 + 1.2.13 1.2.11 diff --git a/vendor/phpunit/php-code-coverage/phpunit.xml.dist b/vendor/phpunit/php-code-coverage/phpunit.xml.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/scripts/auto_append.php b/vendor/phpunit/php-code-coverage/scripts/auto_append.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-code-coverage/scripts/auto_prepend.php b/vendor/phpunit/php-code-coverage/scripts/auto_prepend.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/.gitattributes b/vendor/phpunit/php-file-iterator/.gitattributes old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/.gitignore b/vendor/phpunit/php-file-iterator/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/ChangeLog.markdown b/vendor/phpunit/php-file-iterator/ChangeLog.markdown old mode 100755 new mode 100644 index 06593b0952..fd9ed1bfe5 --- a/vendor/phpunit/php-file-iterator/ChangeLog.markdown +++ b/vendor/phpunit/php-file-iterator/ChangeLog.markdown @@ -3,6 +3,11 @@ File_Iterator 1.3 This is the list of changes for the File_Iterator 1.3 release series. +File_Iterator 1.3.4 +------------------- + +* Symlinks are now followed. + File_Iterator 1.3.3 ------------------- diff --git a/vendor/phpunit/php-file-iterator/File/Iterator.php b/vendor/phpunit/php-file-iterator/File/Iterator.php old mode 100755 new mode 100644 index 73f19b974e..f898ef51a5 --- a/vendor/phpunit/php-file-iterator/File/Iterator.php +++ b/vendor/phpunit/php-file-iterator/File/Iterator.php @@ -2,7 +2,7 @@ /** * php-file-iterator * - * Copyright (c) 2009-2012, Sebastian Bergmann . + * Copyright (c) 2009-2013, Sebastian Bergmann . * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,8 +35,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package File - * @author Sebastian Bergmann - * @copyright 2009-2012 Sebastian Bergmann + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @since File available since Release 1.0.0 */ @@ -45,8 +45,8 @@ * FilterIterator implementation that filters files based on prefix(es) and/or * suffix(es). Hidden files and files from hidden directories are also filtered. * - * @author Sebastian Bergmann - * @copyright 2009-2012 Sebastian Bergmann + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @version Release: @package_version@ * @link http://github.com/sebastianbergmann/php-file-iterator/tree diff --git a/vendor/phpunit/php-file-iterator/File/Iterator/Autoload.php b/vendor/phpunit/php-file-iterator/File/Iterator/Autoload.php old mode 100755 new mode 100644 index fcb2105998..5a8c01aa68 --- a/vendor/phpunit/php-file-iterator/File/Iterator/Autoload.php +++ b/vendor/phpunit/php-file-iterator/File/Iterator/Autoload.php @@ -2,7 +2,7 @@ /** * php-file-iterator * - * Copyright (c) 2009-2012, Sebastian Bergmann . + * Copyright (c) 2009-2013, Sebastian Bergmann . * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,8 +35,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package File - * @author Sebastian Bergmann - * @copyright 2009-2012 Sebastian Bergmann + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @since File available since Release 1.3.0 */ diff --git a/vendor/phpunit/php-file-iterator/File/Iterator/Autoload.php.in b/vendor/phpunit/php-file-iterator/File/Iterator/Autoload.php.in old mode 100755 new mode 100644 index 20d58b9461..56da6c145a --- a/vendor/phpunit/php-file-iterator/File/Iterator/Autoload.php.in +++ b/vendor/phpunit/php-file-iterator/File/Iterator/Autoload.php.in @@ -2,7 +2,7 @@ /** * php-file-iterator * - * Copyright (c) 2009-2012, Sebastian Bergmann . + * Copyright (c) 2009-2013, Sebastian Bergmann . * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,7 +36,7 @@ * * @package File * @author Sebastian Bergmann - * @copyright 2009-2012 Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @since File available since Release 1.3.0 */ diff --git a/vendor/phpunit/php-file-iterator/File/Iterator/Facade.php b/vendor/phpunit/php-file-iterator/File/Iterator/Facade.php old mode 100755 new mode 100644 index d30283e94b..2b846d09df --- a/vendor/phpunit/php-file-iterator/File/Iterator/Facade.php +++ b/vendor/phpunit/php-file-iterator/File/Iterator/Facade.php @@ -2,7 +2,7 @@ /** * php-file-iterator * - * Copyright (c) 2009-2012, Sebastian Bergmann . + * Copyright (c) 2009-2013, Sebastian Bergmann . * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,8 +35,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package File - * @author Sebastian Bergmann - * @copyright 2009-2012 Sebastian Bergmann + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @since File available since Release 1.3.0 */ @@ -47,8 +47,8 @@ * RecursiveDirectoryIterator for each given path. The list of unique * files is returned as an array. * - * @author Sebastian Bergmann - * @copyright 2009-2012 Sebastian Bergmann + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @version Release: @package_version@ * @link http://github.com/sebastianbergmann/php-file-iterator/tree diff --git a/vendor/phpunit/php-file-iterator/File/Iterator/Factory.php b/vendor/phpunit/php-file-iterator/File/Iterator/Factory.php old mode 100755 new mode 100644 index 47a50ae7b3..3c0166e080 --- a/vendor/phpunit/php-file-iterator/File/Iterator/Factory.php +++ b/vendor/phpunit/php-file-iterator/File/Iterator/Factory.php @@ -2,7 +2,7 @@ /** * php-file-iterator * - * Copyright (c) 2009-2012, Sebastian Bergmann . + * Copyright (c) 2009-2013, Sebastian Bergmann . * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,8 +35,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package File - * @author Sebastian Bergmann - * @copyright 2009-2012 Sebastian Bergmann + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @since File available since Release 1.1.0 */ @@ -46,8 +46,8 @@ * an AppendIterator that contains an RecursiveDirectoryIterator for each given * path. * - * @author Sebastian Bergmann - * @copyright 2009-2012 Sebastian Bergmann + * @author Sebastian Bergmann + * @copyright 2009-2013 Sebastian Bergmann * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License * @version Release: @package_version@ * @link http://github.com/sebastianbergmann/php-file-iterator/tree @@ -104,7 +104,7 @@ class File_Iterator_Factory $iterator->append( new File_Iterator( new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($path) + new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS) ), $suffixes, $prefixes, diff --git a/vendor/phpunit/php-file-iterator/LICENSE b/vendor/phpunit/php-file-iterator/LICENSE old mode 100755 new mode 100644 index 58c57434ee..c392d412c4 --- a/vendor/phpunit/php-file-iterator/LICENSE +++ b/vendor/phpunit/php-file-iterator/LICENSE @@ -1,6 +1,6 @@ File_Iterator -Copyright (c) 2009-2012, Sebastian Bergmann . +Copyright (c) 2009-2013, Sebastian Bergmann . All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/vendor/phpunit/php-file-iterator/README.markdown b/vendor/phpunit/php-file-iterator/README.markdown old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/build.xml b/vendor/phpunit/php-file-iterator/build.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php b/vendor/phpunit/php-file-iterator/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/build/PHPCS/Sniffs/Whitespace/ConcatenationSpacingSniff.php b/vendor/phpunit/php-file-iterator/build/PHPCS/Sniffs/Whitespace/ConcatenationSpacingSniff.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/build/PHPCS/ruleset.xml b/vendor/phpunit/php-file-iterator/build/PHPCS/ruleset.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/build/phpmd.xml b/vendor/phpunit/php-file-iterator/build/phpmd.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-file-iterator/composer.json b/vendor/phpunit/php-file-iterator/composer.json old mode 100755 new mode 100644 index aab32bce25..1ddd5b88bb --- a/vendor/phpunit/php-file-iterator/composer.json +++ b/vendor/phpunit/php-file-iterator/composer.json @@ -6,7 +6,7 @@ "iterator", "filesystem" ], - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", "license": "BSD-3-Clause", "authors": [ { diff --git a/vendor/phpunit/php-file-iterator/package-composer.json b/vendor/phpunit/php-file-iterator/package-composer.json deleted file mode 100755 index c71bad7bf5..0000000000 --- a/vendor/phpunit/php-file-iterator/package-composer.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "phpunit/php-file-iterator", - "keywords": [ "iterator", "filesystem" ], - "license": "BSD-3-Clause", - "homepage": "http://www.phpunit.de/", - "dependency_map": {}, - "support": { - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "irc": "irc://irc.freenode.net/phpunit" - }, - "autoload": { - "classmap": [ "File/" ] - }, - "include_path": [ - "" - ], - "version": false, - "time": false -} \ No newline at end of file diff --git a/vendor/phpunit/php-file-iterator/package.xml b/vendor/phpunit/php-file-iterator/package.xml old mode 100755 new mode 100644 index e08bfd5839..f6ca981b17 --- a/vendor/phpunit/php-file-iterator/package.xml +++ b/vendor/phpunit/php-file-iterator/package.xml @@ -17,9 +17,9 @@ sb@sebastian-bergmann.de yes - 2012-10-05 + 2013-10-10 - 1.3.3 + 1.3.4 1.3.0 diff --git a/vendor/phpunit/php-token-stream/.gitattributes b/vendor/phpunit/php-token-stream/.gitattributes old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/.gitignore b/vendor/phpunit/php-token-stream/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/LICENSE b/vendor/phpunit/php-token-stream/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/PHP/Token.php b/vendor/phpunit/php-token-stream/PHP/Token.php old mode 100755 new mode 100644 index d18258249e..90ea43b390 --- a/vendor/phpunit/php-token-stream/PHP/Token.php +++ b/vendor/phpunit/php-token-stream/PHP/Token.php @@ -647,6 +647,7 @@ class PHP_Token_INTERFACE extends PHP_TokenWithScopeAndVisibility } class PHP_Token_CLASS extends PHP_Token_INTERFACE {} +class PHP_Token_CLASS_NAME_CONSTANT extends PHP_Token {} class PHP_Token_TRAIT extends PHP_Token_INTERFACE {} class PHP_Token_EXTENDS extends PHP_Token {} class PHP_Token_IMPLEMENTS extends PHP_Token {} diff --git a/vendor/phpunit/php-token-stream/PHP/Token/Stream.php b/vendor/phpunit/php-token-stream/PHP/Token/Stream.php old mode 100755 new mode 100644 index 01d4250ae2..6a18235328 --- a/vendor/phpunit/php-token-stream/PHP/Token/Stream.php +++ b/vendor/phpunit/php-token-stream/PHP/Token/Stream.php @@ -195,13 +195,21 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator $tokens = token_get_all($sourceCode); $numTokens = count($tokens); + $lastNonWhitespaceTokenWasDoubleColon = FALSE; + for ($i = 0; $i < $numTokens; ++$i) { $token = $tokens[$i]; unset($tokens[$i]); if (is_array($token)) { - $text = $token[1]; - $tokenClass = 'PHP_Token_' . substr(token_name($token[0]), 2); + $name = substr(token_name($token[0]), 2); + $text = $token[1]; + + if ($lastNonWhitespaceTokenWasDoubleColon && $name == 'CLASS') { + $name = 'CLASS_NAME_CONSTANT'; + } + + $tokenClass = 'PHP_Token_' . $name; } else { $text = $token; $tokenClass = self::$customTokens[$token]; @@ -219,6 +227,14 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator $tokenClass == 'PHP_Token_DOC_COMMENT') { $this->linesOfCode['cloc'] += $lines + 1; } + + if ($name == 'DOUBLE_COLON') { + $lastNonWhitespaceTokenWasDoubleColon = TRUE; + } + + else if ($name != 'WHITESPACE') { + $lastNonWhitespaceTokenWasDoubleColon = FALSE; + } } $this->linesOfCode['loc'] = substr_count($sourceCode, "\n"); diff --git a/vendor/phpunit/php-token-stream/PHP/Token/Stream/Autoload.php b/vendor/phpunit/php-token-stream/PHP/Token/Stream/Autoload.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/PHP/Token/Stream/Autoload.php.in b/vendor/phpunit/php-token-stream/PHP/Token/Stream/Autoload.php.in old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/PHP/Token/Stream/CachingFactory.php b/vendor/phpunit/php-token-stream/PHP/Token/Stream/CachingFactory.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/README.md b/vendor/phpunit/php-token-stream/README.md old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/Token/ClassTest.php b/vendor/phpunit/php-token-stream/Tests/Token/ClassTest.php old mode 100755 new mode 100644 index 62f429bf41..c9ff246b49 --- a/vendor/phpunit/php-token-stream/Tests/Token/ClassTest.php +++ b/vendor/phpunit/php-token-stream/Tests/Token/ClassTest.php @@ -119,4 +119,10 @@ class PHP_Token_ClassTest extends PHPUnit_Framework_TestCase } } } + + public function testIssue30() + { + $ts = new PHP_Token_Stream(TEST_FILES_PATH . 'issue30.php'); + $this->assertCount(1, $ts->getClasses()); + } } diff --git a/vendor/phpunit/php-token-stream/Tests/Token/ClosureTest.php b/vendor/phpunit/php-token-stream/Tests/Token/ClosureTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/Token/FunctionTest.php b/vendor/phpunit/php-token-stream/Tests/Token/FunctionTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/Token/IncludeTest.php b/vendor/phpunit/php-token-stream/Tests/Token/IncludeTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/Token/InterfaceTest.php b/vendor/phpunit/php-token-stream/Tests/Token/InterfaceTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/Token/NamespaceTest.php b/vendor/phpunit/php-token-stream/Tests/Token/NamespaceTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/TokenTest.php b/vendor/phpunit/php-token-stream/Tests/TokenTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/_files/classExtendsNamespacedClass.php b/vendor/phpunit/php-token-stream/Tests/_files/classExtendsNamespacedClass.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/_files/classInNamespace.php b/vendor/phpunit/php-token-stream/Tests/_files/classInNamespace.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/_files/classInScopedNamespace.php b/vendor/phpunit/php-token-stream/Tests/_files/classInScopedNamespace.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/_files/closure.php b/vendor/phpunit/php-token-stream/Tests/_files/closure.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/_files/issue19.php b/vendor/phpunit/php-token-stream/Tests/_files/issue19.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/php-token-stream/Tests/_files/issue30.php b/vendor/phpunit/php-token-stream/Tests/_files/issue30.php new file mode 100644 index 0000000000..0d1f6f354a --- /dev/null +++ b/vendor/phpunit/php-token-stream/Tests/_files/issue30.php @@ -0,0 +1,8 @@ +sb@sebastian-bergmann.de yes - 2013-08-04 + 2013-09-13 - 1.2.0 + 1.2.1 1.2.0 diff --git a/vendor/phpunit/php-token-stream/phpunit.xml.dist b/vendor/phpunit/php-token-stream/phpunit.xml.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/.gitattributes b/vendor/phpunit/phpunit/.gitattributes old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/.gitignore b/vendor/phpunit/phpunit/.gitignore old mode 100755 new mode 100644 index 2aa9c32b28..66eeede0b1 --- a/vendor/phpunit/phpunit/.gitignore +++ b/vendor/phpunit/phpunit/.gitignore @@ -13,6 +13,7 @@ Tests/TextUI/*.out Tests/TextUI/*.php /vendor /composer.lock +/composer.phar phpunit.xml cache.properties .idea diff --git a/vendor/phpunit/phpunit/.travis.yml b/vendor/phpunit/phpunit/.travis.yml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/CONTRIBUTING.md b/vendor/phpunit/phpunit/CONTRIBUTING.md old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/LICENSE b/vendor/phpunit/phpunit/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Autoload.php b/vendor/phpunit/phpunit/PHPUnit/Autoload.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Autoload.php.in b/vendor/phpunit/phpunit/PHPUnit/Autoload.php.in old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Extensions/GroupTestSuite.php b/vendor/phpunit/phpunit/PHPUnit/Extensions/GroupTestSuite.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Extensions/PhptTestCase.php b/vendor/phpunit/phpunit/PHPUnit/Extensions/PhptTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Extensions/PhptTestCase/Logger.php b/vendor/phpunit/phpunit/PHPUnit/Extensions/PhptTestCase/Logger.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Extensions/PhptTestSuite.php b/vendor/phpunit/phpunit/PHPUnit/Extensions/PhptTestSuite.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Extensions/RepeatedTest.php b/vendor/phpunit/phpunit/PHPUnit/Extensions/RepeatedTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Extensions/TestDecorator.php b/vendor/phpunit/phpunit/PHPUnit/Extensions/TestDecorator.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Extensions/TicketListener.php b/vendor/phpunit/phpunit/PHPUnit/Extensions/TicketListener.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php.in b/vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php.in old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/AssertionFailedError.php b/vendor/phpunit/phpunit/PHPUnit/Framework/AssertionFailedError.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Array.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Array.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/DOMDocument.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/DOMDocument.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Double.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Double.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Exception.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Exception.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/MockObject.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/MockObject.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Numeric.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Numeric.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Object.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Object.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Resource.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Resource.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Scalar.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Scalar.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/SplObjectStorage.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/SplObjectStorage.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Type.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Comparator/Type.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/ComparatorFactory.php b/vendor/phpunit/phpunit/PHPUnit/Framework/ComparatorFactory.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/ComparisonFailure.php b/vendor/phpunit/phpunit/PHPUnit/Framework/ComparisonFailure.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/And.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/And.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ArrayHasKey.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ArrayHasKey.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Attribute.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Attribute.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Callback.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Callback.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ClassHasAttribute.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ClassHasAttribute.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ClassHasStaticAttribute.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Composite.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Composite.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Count.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Count.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Exception.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Exception.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ExceptionCode.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ExceptionCode.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ExceptionMessage.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ExceptionMessage.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/FileExists.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/FileExists.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/GreaterThan.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/GreaterThan.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsAnything.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsAnything.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsEmpty.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsEmpty.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsEqual.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsEqual.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsFalse.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsFalse.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsIdentical.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsIdentical.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsInstanceOf.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsInstanceOf.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsJson.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsJson.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsNull.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsNull.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsTrue.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsTrue.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsType.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/IsType.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches/ErrorMessageProvider.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/JsonMatches/ErrorMessageProvider.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/LessThan.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/LessThan.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Not.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Not.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ObjectHasAttribute.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/ObjectHasAttribute.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Or.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Or.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/PCREMatch.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/PCREMatch.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/SameSize.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/SameSize.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/StringContains.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/StringContains.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/StringEndsWith.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/StringEndsWith.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/StringMatches.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/StringMatches.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/StringStartsWith.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/StringStartsWith.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/TraversableContains.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/TraversableContains.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/TraversableContainsOnly.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/TraversableContainsOnly.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Xor.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Constraint/Xor.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Error.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Error.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Error/Deprecated.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Error/Deprecated.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Error/Notice.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Error/Notice.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Error/Warning.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Error/Warning.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Exception.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Exception.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/ExpectationFailedException.php b/vendor/phpunit/phpunit/PHPUnit/Framework/ExpectationFailedException.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/IncompleteTest.php b/vendor/phpunit/phpunit/PHPUnit/Framework/IncompleteTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/IncompleteTestError.php b/vendor/phpunit/phpunit/PHPUnit/Framework/IncompleteTestError.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/OutputError.php b/vendor/phpunit/phpunit/PHPUnit/Framework/OutputError.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist b/vendor/phpunit/phpunit/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/SelfDescribing.php b/vendor/phpunit/phpunit/PHPUnit/Framework/SelfDescribing.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/SkippedTest.php b/vendor/phpunit/phpunit/PHPUnit/Framework/SkippedTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/SkippedTestError.php b/vendor/phpunit/phpunit/PHPUnit/Framework/SkippedTestError.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/SkippedTestSuiteError.php b/vendor/phpunit/phpunit/PHPUnit/Framework/SkippedTestSuiteError.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/SyntheticError.php b/vendor/phpunit/phpunit/PHPUnit/Framework/SyntheticError.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Test.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php b/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/TestFailure.php b/vendor/phpunit/phpunit/PHPUnit/Framework/TestFailure.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/TestListener.php b/vendor/phpunit/phpunit/PHPUnit/Framework/TestListener.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php b/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php b/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite/DataProvider.php b/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite/DataProvider.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Framework/Warning.php b/vendor/phpunit/phpunit/PHPUnit/Framework/Warning.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Runner/BaseTestRunner.php b/vendor/phpunit/phpunit/PHPUnit/Runner/BaseTestRunner.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Runner/StandardTestSuiteLoader.php b/vendor/phpunit/phpunit/PHPUnit/Runner/StandardTestSuiteLoader.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Runner/TestSuiteLoader.php b/vendor/phpunit/phpunit/PHPUnit/Runner/TestSuiteLoader.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Runner/Version.php b/vendor/phpunit/phpunit/PHPUnit/Runner/Version.php old mode 100755 new mode 100644 index 9a83173345..8709390543 --- a/vendor/phpunit/phpunit/PHPUnit/Runner/Version.php +++ b/vendor/phpunit/phpunit/PHPUnit/Runner/Version.php @@ -56,7 +56,7 @@ */ class PHPUnit_Runner_Version { - const VERSION = '3.7.24'; + const VERSION = '3.7.28'; protected static $version; /** diff --git a/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php b/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/TextUI/ResultPrinter.php b/vendor/phpunit/phpunit/PHPUnit/TextUI/ResultPrinter.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php b/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Class.php b/vendor/phpunit/phpunit/PHPUnit/Util/Class.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php b/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/DeprecatedFeature.php b/vendor/phpunit/phpunit/PHPUnit/Util/DeprecatedFeature.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/DeprecatedFeature/Logger.php b/vendor/phpunit/phpunit/PHPUnit/Util/DeprecatedFeature/Logger.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Diff.php b/vendor/phpunit/phpunit/PHPUnit/Util/Diff.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/ErrorHandler.php b/vendor/phpunit/phpunit/PHPUnit/Util/ErrorHandler.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php b/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Filesystem.php b/vendor/phpunit/phpunit/PHPUnit/Util/Filesystem.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Filter.php b/vendor/phpunit/phpunit/PHPUnit/Util/Filter.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Getopt.php b/vendor/phpunit/phpunit/PHPUnit/Util/Getopt.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/GlobalState.php b/vendor/phpunit/phpunit/PHPUnit/Util/GlobalState.php old mode 100755 new mode 100644 index afb64fefa9..4697c9dec8 --- a/vendor/phpunit/phpunit/PHPUnit/Util/GlobalState.php +++ b/vendor/phpunit/phpunit/PHPUnit/Util/GlobalState.php @@ -201,8 +201,8 @@ class PHPUnit_Util_GlobalState for ($i = count($files) - 1; $i > 0; $i--) { $file = $files[$i]; - if ($prefix !== FALSE) { - $file = str_replace($prefix, '', $file); + if ($prefix !== FALSE && strpos($file, $prefix) === 0) { + continue; } if (!isset($blacklist[$file]) && is_file($file)) { @@ -383,6 +383,7 @@ class PHPUnit_Util_GlobalState public static function phpunitFiles() { if (self::$phpunitFiles === NULL) { + self::$phpunitFiles = array(); self::addDirectoryContainingClassToPHPUnitFilesList('File_Iterator'); self::addDirectoryContainingClassToPHPUnitFilesList('PHP_CodeCoverage'); self::addDirectoryContainingClassToPHPUnitFilesList('PHP_Invoker'); diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/InvalidArgumentHelper.php b/vendor/phpunit/phpunit/PHPUnit/Util/InvalidArgumentHelper.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Log/JSON.php b/vendor/phpunit/phpunit/PHPUnit/Util/Log/JSON.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Log/JUnit.php b/vendor/phpunit/phpunit/PHPUnit/Util/Log/JUnit.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Log/TAP.php b/vendor/phpunit/phpunit/PHPUnit/Util/Log/TAP.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/PHP.php b/vendor/phpunit/phpunit/PHPUnit/Util/PHP.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/PHP/Default.php b/vendor/phpunit/phpunit/PHPUnit/Util/PHP/Default.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/PHP/Windows.php b/vendor/phpunit/phpunit/PHPUnit/Util/PHP/Windows.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Printer.php b/vendor/phpunit/phpunit/PHPUnit/Util/Printer.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/String.php b/vendor/phpunit/phpunit/PHPUnit/Util/String.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Test.php b/vendor/phpunit/phpunit/PHPUnit/Util/Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/TestDox/NamePrettifier.php b/vendor/phpunit/phpunit/PHPUnit/Util/TestDox/NamePrettifier.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/TestDox/ResultPrinter.php b/vendor/phpunit/phpunit/PHPUnit/Util/TestDox/ResultPrinter.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/TestDox/ResultPrinter/HTML.php b/vendor/phpunit/phpunit/PHPUnit/Util/TestDox/ResultPrinter/HTML.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/TestDox/ResultPrinter/Text.php b/vendor/phpunit/phpunit/PHPUnit/Util/TestDox/ResultPrinter/Text.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/TestSuiteIterator.php b/vendor/phpunit/phpunit/PHPUnit/Util/TestSuiteIterator.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/Type.php b/vendor/phpunit/phpunit/PHPUnit/Util/Type.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/PHPUnit/Util/XML.php b/vendor/phpunit/phpunit/PHPUnit/Util/XML.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/README.md b/vendor/phpunit/phpunit/README.md old mode 100755 new mode 100644 index 82cb24783a..cce2782733 --- a/vendor/phpunit/phpunit/README.md +++ b/vendor/phpunit/phpunit/README.md @@ -11,20 +11,22 @@ PHPUnit is the de-facto standard for unit testing in PHP projects. It provides b ## Installation -There are three supported ways of installing PHPUnit. +### PHP Archive (PHAR) -You can use the [PEAR Installer](http://pear.php.net/manual/en/guide.users.commandline.cli.php) or [Composer](http://getcomposer.org/) to download and install PHPUnit as well as its dependencies. You can also download a [PHP Archive (PHAR)](http://php.net/phar) of PHPUnit that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file. +The easiest way to obtain PHPUnit is to download a [PHP Archive (PHAR)](http://php.net/phar) that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file: -### PEAR Installer + wget https://phar.phpunit.de/phpunit.phar + chmod +x phpunit.phar + mv phpunit.phar /usr/local/bin/phpunit -The following two commands (which you may have to run as `root`) are all that is required to install PHPUnit using the PEAR Installer: +You can also immediately use the PHAR after you have downloaded it, of course: - pear config-set auto_discover 1 - pear install pear.phpunit.de/PHPUnit + wget https://phar.phpunit.de/phpunit.phar + php phpunit.phar ### Composer -To add PHPUnit as a local, per-project dependency to your project, simply add a dependency on `phpunit/phpunit` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a development-time dependency on PHPUnit 3.7: +Simply add a dependency on `phpunit/phpunit` to your project's `composer.json` file if you use [Composer](http://getcomposer.org/) to manage the dependencies of your project. Here is a minimal example of a `composer.json` file that just defines a development-time dependency on PHPUnit 3.7: { "require-dev": { @@ -32,10 +34,18 @@ To add PHPUnit as a local, per-project dependency to your project, simply add a } } -### PHP Archive (PHAR) +For a system-wide installation via Composer, you can run: - wget http://pear.phpunit.de/get/phpunit.phar - chmod +x phpunit.phar + composer global require 'phpunit/phpunit=3.7.*' + +Make sure you have `~/.composer/vendor/bin/` in your path. + +### PEAR Installer + +The following two commands (which you may have to run as `root`) are all that is required to install PHPUnit using the PEAR Installer: + + pear config-set auto_discover 1 + pear install pear.phpunit.de/PHPUnit ## Documentation @@ -57,6 +67,15 @@ The documentation for PHPUnit is available in different formats: * [Japanese, single HTML file](http://www.phpunit.de/manual/3.7/ja/phpunit-book.html) * [Japanese, PDF](http://www.phpunit.de/manual/3.7/ja/phpunit-book.pdf) * [Japanese, ePub](http://www.phpunit.de/manual/3.7/ja/phpunit-book.epub) +* [Simplified Chinese, multiple HTML files](http://www.phpunit.de/manual/3.7/zh_cn/index.html) +* [Simplified Chinese, single HTML file](http://www.phpunit.de/manual/3.7/zh_cn/phpunit-book.html) +* [Simplified Chinese, PDF](http://www.phpunit.de/manual/3.7/zh_cn/phpunit-book.pdf) +* [Simplified Chinese, ePub](http://www.phpunit.de/manual/3.7/zh_cn/phpunit-book.epub) + +## Mailing Lists + +* [dev@phpunit.de](mailto:dev-subscribe@phpunit.de) is a list for those who want to help out with the development of PHPUnit +* [user@phpunit.de](mailto:user-subscribe@phpunit.de) is a list for general PHPUnit support; ask PHPUnit questions here ## IRC diff --git a/vendor/phpunit/phpunit/Tests/Extensions/RepeatedTestTest.php b/vendor/phpunit/phpunit/Tests/Extensions/RepeatedTestTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/Assert/FunctionsTest.php b/vendor/phpunit/phpunit/Tests/Framework/Assert/FunctionsTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php b/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/ComparatorTest.php b/vendor/phpunit/phpunit/Tests/Framework/ComparatorTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php b/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatchesTest.php b/vendor/phpunit/phpunit/Tests/Framework/Constraint/JsonMatchesTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/ConstraintTest.php b/vendor/phpunit/phpunit/Tests/Framework/ConstraintTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/SuiteTest.php b/vendor/phpunit/phpunit/Tests/Framework/SuiteTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/TestCaseTest.php b/vendor/phpunit/phpunit/Tests/Framework/TestCaseTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/TestFailureTest.php b/vendor/phpunit/phpunit/Tests/Framework/TestFailureTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/TestImplementorTest.php b/vendor/phpunit/phpunit/Tests/Framework/TestImplementorTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Framework/TestListenerTest.php b/vendor/phpunit/phpunit/Tests/Framework/TestListenerTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/1021.phpt b/vendor/phpunit/phpunit/Tests/Regression/1021.phpt old mode 100755 new mode 100644 index b3b9bc7f5a..389e8cf2fe --- a/vendor/phpunit/phpunit/Tests/Regression/1021.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/1021.phpt @@ -14,6 +14,6 @@ PHPUnit %s by Sebastian Bergmann. .. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (2 tests, 1 assertion) diff --git a/vendor/phpunit/phpunit/Tests/Regression/1021/Issue1021Test.php b/vendor/phpunit/phpunit/Tests/Regression/1021/Issue1021Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/523.phpt b/vendor/phpunit/phpunit/Tests/Regression/523.phpt old mode 100755 new mode 100644 index 181c945409..2016dbc5f1 --- a/vendor/phpunit/phpunit/Tests/Regression/523.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/523.phpt @@ -14,6 +14,6 @@ PHPUnit %s by Sebastian Bergmann. . -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (1 test, 1 assertion) diff --git a/vendor/phpunit/phpunit/Tests/Regression/523/Issue523Test.php b/vendor/phpunit/phpunit/Tests/Regression/523/Issue523Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/578.phpt b/vendor/phpunit/phpunit/Tests/Regression/578.phpt old mode 100755 new mode 100644 index b5df4030a7..dca8300335 --- a/vendor/phpunit/phpunit/Tests/Regression/578.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/578.phpt @@ -14,7 +14,7 @@ PHPUnit %s by Sebastian Bergmann. EEE -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There were 3 errors: diff --git a/vendor/phpunit/phpunit/Tests/Regression/578/Issue578Test.php b/vendor/phpunit/phpunit/Tests/Regression/578/Issue578Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/684.phpt b/vendor/phpunit/phpunit/Tests/Regression/684.phpt old mode 100755 new mode 100644 index de26fcd81e..69c5876491 --- a/vendor/phpunit/phpunit/Tests/Regression/684.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/684.phpt @@ -14,7 +14,7 @@ PHPUnit %s by Sebastian Bergmann. F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/Regression/684/Issue684Test.php b/vendor/phpunit/phpunit/Tests/Regression/684/Issue684Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/783.phpt b/vendor/phpunit/phpunit/Tests/Regression/783.phpt old mode 100755 new mode 100644 index 1de4f1ba87..734ac08104 --- a/vendor/phpunit/phpunit/Tests/Regression/783.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/783.phpt @@ -16,6 +16,6 @@ PHPUnit %s by Sebastian Bergmann. .. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (2 tests, 0 assertions) diff --git a/vendor/phpunit/phpunit/Tests/Regression/783/ChildSuite.php b/vendor/phpunit/phpunit/Tests/Regression/783/ChildSuite.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/783/OneTest.php b/vendor/phpunit/phpunit/Tests/Regression/783/OneTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/783/ParentSuite.php b/vendor/phpunit/phpunit/Tests/Regression/783/ParentSuite.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/783/TwoTest.php b/vendor/phpunit/phpunit/Tests/Regression/783/TwoTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/244.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/244.phpt old mode 100755 new mode 100644 index 97082acaf5..e8300f45f2 --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/244.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/244.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. .FFF -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There were 3 failures: diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/244/Issue244Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/244/Issue244Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/322.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/322.phpt old mode 100755 new mode 100644 index ef826acc2d..9642e1dce6 --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/322.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/322.phpt @@ -23,6 +23,6 @@ Configuration read from %s Starting test 'Issue322Test::testOne'. . -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (1 test, 0 assertions) diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/322/Issue322Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/322/Issue322Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/322/phpunit322.xml b/vendor/phpunit/phpunit/Tests/Regression/GitHub/322/phpunit322.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/433.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/433.phpt old mode 100755 new mode 100644 index 8b9df96cb3..211a1a1603 --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/433.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/433.phpt @@ -15,7 +15,7 @@ PHPUnit %s by Sebastian Bergmann. ..F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/433/Issue433Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/433/Issue433Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/445.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/445.phpt old mode 100755 new mode 100644 index bffe7542b3..a641ade302 --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/445.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/445.phpt @@ -16,7 +16,7 @@ PHPUnit %s by Sebastian Bergmann. ..F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/445/Issue445Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/445/Issue445Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/498.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/498.phpt old mode 100755 new mode 100644 index f57e9c655d..c8b62c3901 --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/498.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/498.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/498/Issue498Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/498/Issue498Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/503.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/503.phpt old mode 100755 new mode 100644 index 3ccff27840..36e2d95bf3 --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/503.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/503.phpt @@ -15,7 +15,7 @@ PHPUnit %s by Sebastian Bergmann. F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/503/Issue503Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/503/Issue503Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/581.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/581.phpt old mode 100755 new mode 100644 index 9e6f30424d..29b35f275a --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/581.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/581.phpt @@ -15,7 +15,7 @@ PHPUnit %s by Sebastian Bergmann. F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/581/Issue581Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/581/Issue581Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/74.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/74.phpt old mode 100755 new mode 100644 index 851dfb28d5..b4d6aecfb2 --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/74.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/74.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. E -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 error: diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/74/Issue74Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/74/Issue74Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/74/NewException.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/74/NewException.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/765.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/765.phpt old mode 100755 new mode 100644 index 888dc2cd14..74c7e4dc33 --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/765.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/765.phpt @@ -15,7 +15,7 @@ PHPUnit %s by Sebastian Bergmann. .F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/765/Issue765Test.php b/vendor/phpunit/phpunit/Tests/Regression/GitHub/765/Issue765Test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Regression/GitHub/863.phpt b/vendor/phpunit/phpunit/Tests/Regression/GitHub/863.phpt old mode 100755 new mode 100644 index 56f35fc582..cbb314851e --- a/vendor/phpunit/phpunit/Tests/Regression/GitHub/863.phpt +++ b/vendor/phpunit/phpunit/Tests/Regression/GitHub/863.phpt @@ -19,7 +19,7 @@ PHPUnit %s by Sebastian Bergmann. ............................................................... 126 / 150 ( 84%) ........................ -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (150 tests, 150 assertions) diff --git a/vendor/phpunit/phpunit/Tests/Runner/BaseTestRunnerTest.php b/vendor/phpunit/phpunit/Tests/Runner/BaseTestRunnerTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/TextUI/abstract-test-class.phpt b/vendor/phpunit/phpunit/Tests/TextUI/abstract-test-class.phpt old mode 100755 new mode 100644 index c54fc47226..16829fdd6b --- a/vendor/phpunit/phpunit/Tests/TextUI/abstract-test-class.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/abstract-test-class.phpt @@ -16,7 +16,7 @@ PHPUnit %s by Sebastian Bergmann. F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/concrete-test-class.phpt b/vendor/phpunit/phpunit/Tests/TextUI/concrete-test-class.phpt old mode 100755 new mode 100644 index a46e9c4cf0..1fd8c06ff1 --- a/vendor/phpunit/phpunit/Tests/TextUI/concrete-test-class.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/concrete-test-class.phpt @@ -16,7 +16,7 @@ PHPUnit %s by Sebastian Bergmann. .. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (2 tests, 0 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-log-xml-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-log-xml-isolation.phpt old mode 100755 new mode 100644 index 1d34333ae8..e58c6b595d --- a/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-log-xml-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-log-xml-isolation.phpt @@ -36,7 +36,7 @@ Failed asserting that 2 matches expected 3. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-log-xml.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-log-xml.phpt old mode 100755 new mode 100644 index ce9175326d..850e8c4f85 --- a/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-log-xml.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-log-xml.phpt @@ -36,7 +36,7 @@ Failed asserting that 2 matches expected 3. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-testdox.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dataprovider-testdox.phpt old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/TextUI/debug.phpt b/vendor/phpunit/phpunit/Tests/TextUI/debug.phpt old mode 100755 new mode 100644 index 842c59dfdd..0b2b47deea --- a/vendor/phpunit/phpunit/Tests/TextUI/debug.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/debug.phpt @@ -23,6 +23,6 @@ Starting test 'BankAccountTest::testBalanceCannotBecomeNegative'. Starting test 'BankAccountTest::testBalanceCannotBecomeNegative2'. . -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/default-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/default-isolation.phpt old mode 100755 new mode 100644 index a18cbe5a74..74e36fd1d8 --- a/vendor/phpunit/phpunit/Tests/TextUI/default-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/default-isolation.phpt @@ -17,6 +17,6 @@ PHPUnit %s by Sebastian Bergmann. ... -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/default.phpt b/vendor/phpunit/phpunit/Tests/TextUI/default.phpt old mode 100755 new mode 100644 index 9e010ede38..aa7e603137 --- a/vendor/phpunit/phpunit/Tests/TextUI/default.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/default.phpt @@ -16,6 +16,6 @@ PHPUnit %s by Sebastian Bergmann. ... -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dependencies-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dependencies-isolation.phpt old mode 100755 new mode 100644 index f03170ad88..e9bb037801 --- a/vendor/phpunit/phpunit/Tests/TextUI/dependencies-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/dependencies-isolation.phpt @@ -18,7 +18,7 @@ PHPUnit %s by Sebastian Bergmann. ...FSS -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dependencies.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dependencies.phpt old mode 100755 new mode 100644 index 39dd9be05b..c3f383232b --- a/vendor/phpunit/phpunit/Tests/TextUI/dependencies.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/dependencies.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. ...FSS -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dependencies2-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dependencies2-isolation.phpt old mode 100755 new mode 100644 index 5f9465733c..4eb70eabff --- a/vendor/phpunit/phpunit/Tests/TextUI/dependencies2-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/dependencies2-isolation.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. .. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (2 tests, 5 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dependencies2.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dependencies2.phpt old mode 100755 new mode 100644 index 92c109e87e..f3eb94ea14 --- a/vendor/phpunit/phpunit/Tests/TextUI/dependencies2.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/dependencies2.phpt @@ -16,7 +16,7 @@ PHPUnit %s by Sebastian Bergmann. .. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (2 tests, 5 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dependencies3-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dependencies3-isolation.phpt old mode 100755 new mode 100644 index 5191dc9ff8..a4d116b39a --- a/vendor/phpunit/phpunit/Tests/TextUI/dependencies3-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/dependencies3-isolation.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. ... -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 2 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/dependencies3.phpt b/vendor/phpunit/phpunit/Tests/TextUI/dependencies3.phpt old mode 100755 new mode 100644 index 562b8e4c0e..66daf6cb44 --- a/vendor/phpunit/phpunit/Tests/TextUI/dependencies3.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/dependencies3.phpt @@ -16,6 +16,6 @@ PHPUnit %s by Sebastian Bergmann. ... -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 2 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/empty-testcase.phpt b/vendor/phpunit/phpunit/Tests/TextUI/empty-testcase.phpt old mode 100755 new mode 100644 index d8e4a64437..29b3f3aef2 --- a/vendor/phpunit/phpunit/Tests/TextUI/empty-testcase.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/empty-testcase.phpt @@ -16,7 +16,7 @@ PHPUnit %s by Sebastian Bergmann. F -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 failure: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/exception-stack.phpt b/vendor/phpunit/phpunit/Tests/TextUI/exception-stack.phpt old mode 100755 new mode 100644 index 9f3704d9c8..007bc87456 --- a/vendor/phpunit/phpunit/Tests/TextUI/exception-stack.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/exception-stack.phpt @@ -14,7 +14,7 @@ PHPUnit %s by Sebastian Bergmann. EE -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There were 2 errors: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/exclude-group-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/exclude-group-isolation.phpt old mode 100755 new mode 100644 index c8ebbce216..ec931ee1e0 --- a/vendor/phpunit/phpunit/Tests/TextUI/exclude-group-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/exclude-group-isolation.phpt @@ -19,6 +19,6 @@ PHPUnit %s by Sebastian Bergmann. .. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (2 tests, 2 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/exclude-group.phpt b/vendor/phpunit/phpunit/Tests/TextUI/exclude-group.phpt old mode 100755 new mode 100644 index fa88b5e61f..99514e3a31 --- a/vendor/phpunit/phpunit/Tests/TextUI/exclude-group.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/exclude-group.phpt @@ -18,6 +18,6 @@ PHPUnit %s by Sebastian Bergmann. .. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (2 tests, 2 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/failure-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/failure-isolation.phpt old mode 100755 new mode 100644 index 1f78cd7e75..1a4bb31636 --- a/vendor/phpunit/phpunit/Tests/TextUI/failure-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/failure-isolation.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. FFFFFFFFFFFFF -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There were 13 failures: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/failure.phpt b/vendor/phpunit/phpunit/Tests/TextUI/failure.phpt old mode 100755 new mode 100644 index a341865170..3eda70aa89 --- a/vendor/phpunit/phpunit/Tests/TextUI/failure.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/failure.phpt @@ -16,7 +16,7 @@ PHPUnit %s by Sebastian Bergmann. FFFFFFFFFFFFF -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There were 13 failures: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/fatal-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/fatal-isolation.phpt old mode 100755 new mode 100644 index 3eeb0f3135..5965c079c8 --- a/vendor/phpunit/phpunit/Tests/TextUI/fatal-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/fatal-isolation.phpt @@ -16,7 +16,7 @@ PHPUnit %s by Sebastian Bergmann. E -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb There was 1 error: diff --git a/vendor/phpunit/phpunit/Tests/TextUI/fatal.phpt b/vendor/phpunit/phpunit/Tests/TextUI/fatal.phpt old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/TextUI/filter-class-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/filter-class-isolation.phpt old mode 100755 new mode 100644 index 85fff4e04c..61c4c9fd20 --- a/vendor/phpunit/phpunit/Tests/TextUI/filter-class-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/filter-class-isolation.phpt @@ -19,6 +19,6 @@ PHPUnit %s by Sebastian Bergmann. ... -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/filter-class.phpt b/vendor/phpunit/phpunit/Tests/TextUI/filter-class.phpt old mode 100755 new mode 100644 index 459cf28fda..51883c1721 --- a/vendor/phpunit/phpunit/Tests/TextUI/filter-class.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/filter-class.phpt @@ -18,6 +18,6 @@ PHPUnit %s by Sebastian Bergmann. ... -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/filter-method-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/filter-method-isolation.phpt old mode 100755 new mode 100644 index aede5553d0..0dd5aff35b --- a/vendor/phpunit/phpunit/Tests/TextUI/filter-method-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/filter-method-isolation.phpt @@ -19,6 +19,6 @@ PHPUnit %s by Sebastian Bergmann. . -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (1 test, 1 assertion) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/filter-method.phpt b/vendor/phpunit/phpunit/Tests/TextUI/filter-method.phpt old mode 100755 new mode 100644 index e553a030fb..ccfce148bf --- a/vendor/phpunit/phpunit/Tests/TextUI/filter-method.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/filter-method.phpt @@ -18,6 +18,6 @@ PHPUnit %s by Sebastian Bergmann. . -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (1 test, 1 assertion) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/filter-no-results.phpt b/vendor/phpunit/phpunit/Tests/TextUI/filter-no-results.phpt old mode 100755 new mode 100644 index 03f69957fd..301cef001b --- a/vendor/phpunit/phpunit/Tests/TextUI/filter-no-results.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/filter-no-results.phpt @@ -18,6 +18,6 @@ PHPUnit %s by Sebastian Bergmann. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb No tests executed! diff --git a/vendor/phpunit/phpunit/Tests/TextUI/group-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/group-isolation.phpt old mode 100755 new mode 100644 index 5abbadac92..1238533f98 --- a/vendor/phpunit/phpunit/Tests/TextUI/group-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/group-isolation.phpt @@ -19,6 +19,6 @@ PHPUnit %s by Sebastian Bergmann. . -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (1 test, 1 assertion) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/group.phpt b/vendor/phpunit/phpunit/Tests/TextUI/group.phpt old mode 100755 new mode 100644 index 77003f2e6b..0dd1815b9e --- a/vendor/phpunit/phpunit/Tests/TextUI/group.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/group.phpt @@ -18,6 +18,6 @@ PHPUnit %s by Sebastian Bergmann. . -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (1 test, 1 assertion) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/help.phpt b/vendor/phpunit/phpunit/Tests/TextUI/help.phpt old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/TextUI/help2.phpt b/vendor/phpunit/phpunit/Tests/TextUI/help2.phpt old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/TextUI/list-groups.phpt b/vendor/phpunit/phpunit/Tests/TextUI/list-groups.phpt old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/TextUI/log-json.phpt b/vendor/phpunit/phpunit/Tests/TextUI/log-json.phpt old mode 100755 new mode 100644 index dcc348e760..4e68793b85 --- a/vendor/phpunit/phpunit/Tests/TextUI/log-json.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/log-json.phpt @@ -72,6 +72,6 @@ PHPUnit %s by Sebastian Bergmann. "output": "" } -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/log-tap.phpt b/vendor/phpunit/phpunit/Tests/TextUI/log-tap.phpt old mode 100755 new mode 100644 index 1d965a259c..0ca03b6cfc --- a/vendor/phpunit/phpunit/Tests/TextUI/log-tap.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/log-tap.phpt @@ -23,6 +23,6 @@ TAP version 13 1..3 -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/log-xml.phpt b/vendor/phpunit/phpunit/Tests/TextUI/log-xml.phpt old mode 100755 new mode 100644 index 2c95fa6668..df11ee4de2 --- a/vendor/phpunit/phpunit/Tests/TextUI/log-xml.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/log-xml.phpt @@ -26,6 +26,6 @@ PHPUnit %s by Sebastian Bergmann. -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/strict-incomplete.phpt b/vendor/phpunit/phpunit/Tests/TextUI/strict-incomplete.phpt old mode 100755 new mode 100644 index 5c41497672..3b2f58c044 --- a/vendor/phpunit/phpunit/Tests/TextUI/strict-incomplete.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/strict-incomplete.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. I -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK, but incomplete or skipped tests! Tests: 1, Assertions: 0, Incomplete: 1. diff --git a/vendor/phpunit/phpunit/Tests/TextUI/strict-isolation.phpt b/vendor/phpunit/phpunit/Tests/TextUI/strict-isolation.phpt old mode 100755 new mode 100644 index ef0ae374ac..125febe352 --- a/vendor/phpunit/phpunit/Tests/TextUI/strict-isolation.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/strict-isolation.phpt @@ -18,7 +18,7 @@ PHPUnit %s by Sebastian Bergmann. I -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK, but incomplete or skipped tests! Tests: 1, Assertions: 0, Incomplete: 1. diff --git a/vendor/phpunit/phpunit/Tests/TextUI/strict.phpt b/vendor/phpunit/phpunit/Tests/TextUI/strict.phpt old mode 100755 new mode 100644 index f566ef6fa9..98b3583c65 --- a/vendor/phpunit/phpunit/Tests/TextUI/strict.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/strict.phpt @@ -17,7 +17,7 @@ PHPUnit %s by Sebastian Bergmann. I -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK, but incomplete or skipped tests! Tests: 1, Assertions: 0, Incomplete: 1. diff --git a/vendor/phpunit/phpunit/Tests/TextUI/tap.phpt b/vendor/phpunit/phpunit/Tests/TextUI/tap.phpt old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/TextUI/test-suffix-multiple.phpt b/vendor/phpunit/phpunit/Tests/TextUI/test-suffix-multiple.phpt old mode 100755 new mode 100644 index 145ebeb41d..bdde18efbb --- a/vendor/phpunit/phpunit/Tests/TextUI/test-suffix-multiple.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/test-suffix-multiple.phpt @@ -17,6 +17,6 @@ PHPUnit %s by Sebastian Bergmann. ..... -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (5 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/test-suffix-single.phpt b/vendor/phpunit/phpunit/Tests/TextUI/test-suffix-single.phpt old mode 100755 new mode 100644 index 4d63efac44..b91e51c671 --- a/vendor/phpunit/phpunit/Tests/TextUI/test-suffix-single.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/test-suffix-single.phpt @@ -17,6 +17,6 @@ PHPUnit %s by Sebastian Bergmann. ... -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/testdox-html.phpt b/vendor/phpunit/phpunit/Tests/TextUI/testdox-html.phpt old mode 100755 new mode 100644 index 61de71d7c5..f7e718a0c4 --- a/vendor/phpunit/phpunit/Tests/TextUI/testdox-html.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/testdox-html.phpt @@ -18,6 +18,6 @@ PHPUnit %s by Sebastian Bergmann.

BankAccount

    ...
  • Balance is initially zero
  • Balance cannot become negative
-Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/testdox-text.phpt b/vendor/phpunit/phpunit/Tests/TextUI/testdox-text.phpt old mode 100755 new mode 100644 index 8a57c817f1..eea0bba0f2 --- a/vendor/phpunit/phpunit/Tests/TextUI/testdox-text.phpt +++ b/vendor/phpunit/phpunit/Tests/TextUI/testdox-text.phpt @@ -22,6 +22,6 @@ BankAccount -Time: %i %s, Memory: %sMb +Time: %s, Memory: %sMb OK (3 tests, 3 assertions) diff --git a/vendor/phpunit/phpunit/Tests/TextUI/testdox.phpt b/vendor/phpunit/phpunit/Tests/TextUI/testdox.phpt old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Util/ClassTest.php b/vendor/phpunit/phpunit/Tests/Util/ClassTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Util/ConfigurationTest.php b/vendor/phpunit/phpunit/Tests/Util/ConfigurationTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Util/DiffTest.php b/vendor/phpunit/phpunit/Tests/Util/DiffTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Util/TestDox/NamePrettifierTest.php b/vendor/phpunit/phpunit/Tests/Util/TestDox/NamePrettifierTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Util/TestTest.php b/vendor/phpunit/phpunit/Tests/Util/TestTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Util/TypeTest.php b/vendor/phpunit/phpunit/Tests/Util/TypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/Util/XMLTest.php b/vendor/phpunit/phpunit/Tests/Util/XMLTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/AbstractTest.php b/vendor/phpunit/phpunit/Tests/_files/AbstractTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/Author.php b/vendor/phpunit/phpunit/Tests/_files/Author.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/BankAccount.php b/vendor/phpunit/phpunit/Tests/_files/BankAccount.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/BankAccountTest.php b/vendor/phpunit/phpunit/Tests/_files/BankAccountTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/BankAccountTest.test.php b/vendor/phpunit/phpunit/Tests/_files/BankAccountTest.test.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/Book.php b/vendor/phpunit/phpunit/Tests/_files/Book.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/Calculator.php b/vendor/phpunit/phpunit/Tests/_files/Calculator.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ChangeCurrentWorkingDirectoryTest.php b/vendor/phpunit/phpunit/Tests/_files/ChangeCurrentWorkingDirectoryTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ClassWithNonPublicAttributes.php b/vendor/phpunit/phpunit/Tests/_files/ClassWithNonPublicAttributes.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ClassWithToString.php b/vendor/phpunit/phpunit/Tests/_files/ClassWithToString.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ConcreteTest.my.php b/vendor/phpunit/phpunit/Tests/_files/ConcreteTest.my.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ConcreteTest.php b/vendor/phpunit/phpunit/Tests/_files/ConcreteTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/DataProviderTest.php b/vendor/phpunit/phpunit/Tests/_files/DataProviderTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/DependencyFailureTest.php b/vendor/phpunit/phpunit/Tests/_files/DependencyFailureTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/DependencySuccessTest.php b/vendor/phpunit/phpunit/Tests/_files/DependencySuccessTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/DependencyTestSuite.php b/vendor/phpunit/phpunit/Tests/_files/DependencyTestSuite.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/DoubleTestCase.php b/vendor/phpunit/phpunit/Tests/_files/DoubleTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/EmptyTestCaseTest.php b/vendor/phpunit/phpunit/Tests/_files/EmptyTestCaseTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/Error.php b/vendor/phpunit/phpunit/Tests/_files/Error.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ExceptionInAssertPostConditionsTest.php b/vendor/phpunit/phpunit/Tests/_files/ExceptionInAssertPostConditionsTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ExceptionInAssertPreConditionsTest.php b/vendor/phpunit/phpunit/Tests/_files/ExceptionInAssertPreConditionsTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ExceptionInSetUpTest.php b/vendor/phpunit/phpunit/Tests/_files/ExceptionInSetUpTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ExceptionInTearDownTest.php b/vendor/phpunit/phpunit/Tests/_files/ExceptionInTearDownTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ExceptionInTest.php b/vendor/phpunit/phpunit/Tests/_files/ExceptionInTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ExceptionNamespaceTest.php b/vendor/phpunit/phpunit/Tests/_files/ExceptionNamespaceTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ExceptionStack.php b/vendor/phpunit/phpunit/Tests/_files/ExceptionStack.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ExceptionTest.php b/vendor/phpunit/phpunit/Tests/_files/ExceptionTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/Failure.php b/vendor/phpunit/phpunit/Tests/_files/Failure.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/FailureTest.php b/vendor/phpunit/phpunit/Tests/_files/FailureTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/FatalTest.php b/vendor/phpunit/phpunit/Tests/_files/FatalTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/IncompleteTest.php b/vendor/phpunit/phpunit/Tests/_files/IncompleteTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/InheritedTestCase.php b/vendor/phpunit/phpunit/Tests/_files/InheritedTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/JsonData/arrayObject.js b/vendor/phpunit/phpunit/Tests/_files/JsonData/arrayObject.js old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/JsonData/simpleObject.js b/vendor/phpunit/phpunit/Tests/_files/JsonData/simpleObject.js old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/JsonData/simpleObject2.js b/vendor/phpunit/phpunit/Tests/_files/JsonData/simpleObject2.js old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/MockRunner.php b/vendor/phpunit/phpunit/Tests/_files/MockRunner.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/MultiDependencyTest.php b/vendor/phpunit/phpunit/Tests/_files/MultiDependencyTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/NoArgTestCaseTest.php b/vendor/phpunit/phpunit/Tests/_files/NoArgTestCaseTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/NoTestCaseClass.php b/vendor/phpunit/phpunit/Tests/_files/NoTestCaseClass.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/NoTestCases.php b/vendor/phpunit/phpunit/Tests/_files/NoTestCases.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/NonStatic.php b/vendor/phpunit/phpunit/Tests/_files/NonStatic.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/NotPublicTestCase.php b/vendor/phpunit/phpunit/Tests/_files/NotPublicTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/NotVoidTestCase.php b/vendor/phpunit/phpunit/Tests/_files/NotVoidTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/NothingTest.php b/vendor/phpunit/phpunit/Tests/_files/NothingTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/OneTestCase.php b/vendor/phpunit/phpunit/Tests/_files/OneTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/OutputTestCase.php b/vendor/phpunit/phpunit/Tests/_files/OutputTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/OverrideTestCase.php b/vendor/phpunit/phpunit/Tests/_files/OverrideTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/RequirementsClassDocBlockTest.php b/vendor/phpunit/phpunit/Tests/_files/RequirementsClassDocBlockTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/RequirementsTest.php b/vendor/phpunit/phpunit/Tests/_files/RequirementsTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/SampleClass.php b/vendor/phpunit/phpunit/Tests/_files/SampleClass.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/SelectorAssertionsFixture.html b/vendor/phpunit/phpunit/Tests/_files/SelectorAssertionsFixture.html old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/Singleton.php b/vendor/phpunit/phpunit/Tests/_files/Singleton.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/StackTest.php b/vendor/phpunit/phpunit/Tests/_files/StackTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/Struct.php b/vendor/phpunit/phpunit/Tests/_files/Struct.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/Success.php b/vendor/phpunit/phpunit/Tests/_files/Success.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/TemplateMethodsTest.php b/vendor/phpunit/phpunit/Tests/_files/TemplateMethodsTest.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/TestIterator.php b/vendor/phpunit/phpunit/Tests/_files/TestIterator.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ThrowExceptionTestCase.php b/vendor/phpunit/phpunit/Tests/_files/ThrowExceptionTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/ThrowNoExceptionTestCase.php b/vendor/phpunit/phpunit/Tests/_files/ThrowNoExceptionTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/WasRun.php b/vendor/phpunit/phpunit/Tests/_files/WasRun.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/bar.xml b/vendor/phpunit/phpunit/Tests/_files/bar.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/configuration.xml b/vendor/phpunit/phpunit/Tests/_files/configuration.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/configuration_xinclude.xml b/vendor/phpunit/phpunit/Tests/_files/configuration_xinclude.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/expectedFileFormat.txt b/vendor/phpunit/phpunit/Tests/_files/expectedFileFormat.txt old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/foo.xml b/vendor/phpunit/phpunit/Tests/_files/foo.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/structureAttributesAreSameButValuesAreNot.xml b/vendor/phpunit/phpunit/Tests/_files/structureAttributesAreSameButValuesAreNot.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/structureExpected.xml b/vendor/phpunit/phpunit/Tests/_files/structureExpected.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/structureIgnoreTextNodes.xml b/vendor/phpunit/phpunit/Tests/_files/structureIgnoreTextNodes.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/structureIsSameButDataIsNot.xml b/vendor/phpunit/phpunit/Tests/_files/structureIsSameButDataIsNot.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/structureWrongNumberOfAttributes.xml b/vendor/phpunit/phpunit/Tests/_files/structureWrongNumberOfAttributes.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/Tests/_files/structureWrongNumberOfNodes.xml b/vendor/phpunit/phpunit/Tests/_files/structureWrongNumberOfNodes.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/build.xml b/vendor/phpunit/phpunit/build.xml old mode 100755 new mode 100644 index 5cb31de85c..d7a3a1e7a1 --- a/vendor/phpunit/phpunit/build.xml +++ b/vendor/phpunit/phpunit/build.xml @@ -23,6 +23,10 @@
+ + + + @@ -165,34 +169,135 @@ + depends="phar-prepare,phar-build"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + - - - - - - - - - - - - - - @@ -206,15 +311,5 @@ - - - - - - - - - - diff --git a/vendor/phpunit/phpunit/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php b/vendor/phpunit/phpunit/build/PHPCS/Sniffs/ControlStructures/ControlSignatureSniff.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/build/PHPCS/Sniffs/Whitespace/ConcatenationSpacingSniff.php b/vendor/phpunit/phpunit/build/PHPCS/Sniffs/Whitespace/ConcatenationSpacingSniff.php old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/build/PHPCS/ruleset.xml b/vendor/phpunit/phpunit/build/PHPCS/ruleset.xml old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/build/dependencies/DbUnit-1.2.3.tgz b/vendor/phpunit/phpunit/build/dependencies/DbUnit-1.2.3.tgz deleted file mode 100755 index 85241bc334..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/DbUnit-1.2.3.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/File_Iterator-1.3.3.tgz b/vendor/phpunit/phpunit/build/dependencies/File_Iterator-1.3.3.tgz deleted file mode 100755 index 5146caf783..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/File_Iterator-1.3.3.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/PHPUnit_MockObject-1.2.3.tgz b/vendor/phpunit/phpunit/build/dependencies/PHPUnit_MockObject-1.2.3.tgz deleted file mode 100755 index 4ed09b153c..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/PHPUnit_MockObject-1.2.3.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/PHPUnit_Selenium-1.3.1.tgz b/vendor/phpunit/phpunit/build/dependencies/PHPUnit_Selenium-1.3.1.tgz deleted file mode 100755 index 6cc8a043d1..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/PHPUnit_Selenium-1.3.1.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/PHP_CodeCoverage-1.2.12.tgz b/vendor/phpunit/phpunit/build/dependencies/PHP_CodeCoverage-1.2.12.tgz deleted file mode 100755 index c18e354af2..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/PHP_CodeCoverage-1.2.12.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/PHP_Invoker-1.1.2.tgz b/vendor/phpunit/phpunit/build/dependencies/PHP_Invoker-1.1.2.tgz deleted file mode 100755 index 56f6866a48..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/PHP_Invoker-1.1.2.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/PHP_Timer-1.0.5.tgz b/vendor/phpunit/phpunit/build/dependencies/PHP_Timer-1.0.5.tgz deleted file mode 100755 index 4102a15b84..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/PHP_Timer-1.0.5.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/PHP_TokenStream-1.1.8.tgz b/vendor/phpunit/phpunit/build/dependencies/PHP_TokenStream-1.1.8.tgz deleted file mode 100755 index dc1dd6040c..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/PHP_TokenStream-1.1.8.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/Text_Template-1.1.4.tgz b/vendor/phpunit/phpunit/build/dependencies/Text_Template-1.1.4.tgz deleted file mode 100755 index 2ce0ffeaa6..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/Text_Template-1.1.4.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/dependencies/Yaml-2.2.0.tgz b/vendor/phpunit/phpunit/build/dependencies/Yaml-2.2.0.tgz deleted file mode 100755 index 8aecbcacb0..0000000000 Binary files a/vendor/phpunit/phpunit/build/dependencies/Yaml-2.2.0.tgz and /dev/null differ diff --git a/vendor/phpunit/phpunit/build/phar-autoload.php.in b/vendor/phpunit/phpunit/build/phar-autoload.php.in old mode 100755 new mode 100644 index 9ae1cb91bf..4689791a9b --- a/vendor/phpunit/phpunit/build/phar-autoload.php.in +++ b/vendor/phpunit/phpunit/build/phar-autoload.php.in @@ -1,12 +1,14 @@ #!/usr/bin/env php sebastian@phpunit.de yes - 2013-08-09 + 2013-10-17 - 3.7.24 + 3.7.28 3.7.0 diff --git a/vendor/phpunit/phpunit/phpdox.xml.dist b/vendor/phpunit/phpunit/phpdox.xml.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/phpunit.bat b/vendor/phpunit/phpunit/phpunit.bat old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/phpunit.xml.dist b/vendor/phpunit/phpunit/phpunit.xml.dist old mode 100755 new mode 100644 diff --git a/vendor/phpunit/phpunit/phpunit.xsd b/vendor/phpunit/phpunit/phpunit.xsd old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/.htaccess b/vendor/slim/slim/.htaccess new file mode 100644 index 0000000000..b5f9c3c4a4 --- /dev/null +++ b/vendor/slim/slim/.htaccess @@ -0,0 +1,10 @@ +RewriteEngine On + +# Some hosts may require you to use the `RewriteBase` directive. +# If you need to use the `RewriteBase` directive, it should be the +# absolute physical path to the directory that contains this htaccess file. +# +# RewriteBase / + +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.php [QSA,L] \ No newline at end of file diff --git a/vendor/slim/slim/.travis.yml b/vendor/slim/slim/.travis.yml new file mode 100644 index 0000000000..e5f88b3479 --- /dev/null +++ b/vendor/slim/slim/.travis.yml @@ -0,0 +1,7 @@ +language: php + +php: + - 5.3 + - 5.4 + +script: phpunit --coverage-text diff --git a/vendor/slim/slim/LICENSE b/vendor/slim/slim/LICENSE new file mode 100644 index 0000000000..ec361cbc91 --- /dev/null +++ b/vendor/slim/slim/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 Josh Lockhart + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/slim/slim/README.markdown b/vendor/slim/slim/README.markdown new file mode 100644 index 0000000000..cad57a6121 --- /dev/null +++ b/vendor/slim/slim/README.markdown @@ -0,0 +1,130 @@ +# Slim Framework + +[![Build Status](https://secure.travis-ci.org/codeguy/Slim.png)](http://travis-ci.org/codeguy/Slim) + +Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. +Slim is easy to use for both beginners and professionals. Slim favors cleanliness over terseness and common cases +over edge cases. Its interface is simple, intuitive, and extensively documented — both online and in the code itself. +Thank you for choosing the Slim Framework for your next project. I think you're going to love it. + +## Features + +* Powerful router + * Standard and custom HTTP methods + * Route parameters with wildcards and conditions + * Route redirect, halt, and pass + * Route middleware +* Template rendering with custom views +* Flash messages +* Secure cookies with AES-256 encryption +* HTTP caching +* Logging with custom log writers +* Error handling and debugging +* Middleware and hook architecture +* Simple configuration + +## Getting Started + +### Install + +You may install the Slim Framework with Composer (recommended) or manually. + +[Read how to install Slim](http://docs.slimframework.com/pages/getting-started-install) + +### System Requirements + +You need **PHP >= 5.3.0**. If you use encrypted cookies, you'll also need the `mcrypt` extension. + +### Hello World Tutorial + +Instantiate a Slim application: + + $app = new \Slim\Slim(); + +Define a HTTP GET route: + + $app->get('/hello/:name', function ($name) { + echo "Hello, $name"; + }); + +Run the Slim application: + + $app->run(); + +### Setup your web server + +#### Apache + +Ensure the `.htaccess` and `index.php` files are in the same public-accessible directory. The `.htaccess` file +should contain this code: + + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [QSA,L] + +#### Nginx + +Your nginx configuration file should contain this code (along with other settings you may need) in your `location` block: + + try_files $uri $uri/ /index.php; + +This assumes that Slim's `index.php` is in the root folder of your project (www root). + +#### lighttpd #### + +Your lighttpd configuration file should contain this code (along with other settings you may need). This code requires +lighttpd >= 1.4.24. + + url.rewrite-if-not-file = ("(.*)" => "/index.php/$0") + +This assumes that Slim's `index.php` is in the root folder of your project (www root). + +## Documentation + + + +## How to Contribute + +### Pull Requests + +1. Fork the Slim Framework repository +2. Create a new branch for each feature or improvement +3. Send a pull request from each feature branch to the **develop** branch + +It is very important to separate new features or improvements into separate feature branches, and to send a pull +request for each branch. This allows me to review and pull in new features or improvements individually. + +### Style Guide + +All pull requests must adhere to the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) standard. + +### Unit Testing + +All pull requests must be accompanied by passing unit tests and complete code coverage. The Slim Framework uses +`phpunit` for testing. + +[Learn about PHPUnit](https://github.com/sebastianbergmann/phpunit/) + +## Community + +### Forum and Knowledgebase + +Visit Slim's official forum and knowledge base at where you can find announcements, +chat with fellow Slim users, ask questions, help others, or show off your cool Slim Framework apps. + +### Twitter + +Follow [@slimphp](http://www.twitter.com/slimphp) on Twitter to receive news and updates about the framework. + +## Author + +The Slim Framework is created and maintained by [Josh Lockhart](https://www.joshlockhart.com). Josh is a senior +web developer at [New Media Campaigns](http://www.newmediacampaigns.com/). Josh also created and maintains +[PHP: The Right Way](http://www.phptherightway.com/), a popular movement in the PHP community to introduce new +PHP programmers to best practices and good information. + +## License + +The Slim Framework is released under the MIT public license. + + diff --git a/vendor/Slim/Environment.php b/vendor/slim/slim/Slim/Environment.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Environment.php rename to vendor/slim/slim/Slim/Environment.php diff --git a/vendor/Slim/Exception/Pass.php b/vendor/slim/slim/Slim/Exception/Pass.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Exception/Pass.php rename to vendor/slim/slim/Slim/Exception/Pass.php diff --git a/vendor/Slim/Exception/Stop.php b/vendor/slim/slim/Slim/Exception/Stop.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Exception/Stop.php rename to vendor/slim/slim/Slim/Exception/Stop.php diff --git a/vendor/Slim/Http/Headers.php b/vendor/slim/slim/Slim/Http/Headers.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Http/Headers.php rename to vendor/slim/slim/Slim/Http/Headers.php diff --git a/vendor/Slim/Http/Request.php b/vendor/slim/slim/Slim/Http/Request.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Http/Request.php rename to vendor/slim/slim/Slim/Http/Request.php diff --git a/vendor/Slim/Http/Response.php b/vendor/slim/slim/Slim/Http/Response.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Http/Response.php rename to vendor/slim/slim/Slim/Http/Response.php diff --git a/vendor/Slim/Http/Util.php b/vendor/slim/slim/Slim/Http/Util.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Http/Util.php rename to vendor/slim/slim/Slim/Http/Util.php diff --git a/vendor/Slim/Log.php b/vendor/slim/slim/Slim/Log.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Log.php rename to vendor/slim/slim/Slim/Log.php diff --git a/vendor/Slim/LogWriter.php b/vendor/slim/slim/Slim/LogWriter.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/LogWriter.php rename to vendor/slim/slim/Slim/LogWriter.php diff --git a/vendor/Slim/Middleware.php b/vendor/slim/slim/Slim/Middleware.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Middleware.php rename to vendor/slim/slim/Slim/Middleware.php diff --git a/vendor/Slim/Middleware/ContentTypes.php b/vendor/slim/slim/Slim/Middleware/ContentTypes.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Middleware/ContentTypes.php rename to vendor/slim/slim/Slim/Middleware/ContentTypes.php diff --git a/vendor/Slim/Middleware/Flash.php b/vendor/slim/slim/Slim/Middleware/Flash.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Middleware/Flash.php rename to vendor/slim/slim/Slim/Middleware/Flash.php diff --git a/vendor/Slim/Middleware/MethodOverride.php b/vendor/slim/slim/Slim/Middleware/MethodOverride.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Middleware/MethodOverride.php rename to vendor/slim/slim/Slim/Middleware/MethodOverride.php diff --git a/vendor/Slim/Middleware/PrettyExceptions.php b/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Middleware/PrettyExceptions.php rename to vendor/slim/slim/Slim/Middleware/PrettyExceptions.php diff --git a/vendor/Slim/Middleware/SessionCookie.php b/vendor/slim/slim/Slim/Middleware/SessionCookie.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Middleware/SessionCookie.php rename to vendor/slim/slim/Slim/Middleware/SessionCookie.php diff --git a/vendor/Slim/Route.php b/vendor/slim/slim/Slim/Route.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Route.php rename to vendor/slim/slim/Slim/Route.php diff --git a/vendor/Slim/Router.php b/vendor/slim/slim/Slim/Router.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/Router.php rename to vendor/slim/slim/Slim/Router.php diff --git a/vendor/Slim/Slim.php b/vendor/slim/slim/Slim/Slim.php old mode 100755 new mode 100644 similarity index 99% rename from vendor/Slim/Slim.php rename to vendor/slim/slim/Slim/Slim.php index eb6d97f2b6..4cd2ff8bb4 --- a/vendor/Slim/Slim.php +++ b/vendor/slim/slim/Slim/Slim.php @@ -1165,10 +1165,10 @@ class Slim */ public function run() { - //set_error_handler(array('\Slim\Slim', 'handleErrors')); //Espo: no needs to use this handler + //set_error_handler(array('\Slim\Slim', 'handleErrors')); //Espo: no needs to use this handler //Apply final outer middleware layers - //$this->add(new \Slim\Middleware\PrettyExceptions()); //Espo: no needs to use this handler + //$this->add(new \Slim\Middleware\PrettyExceptions()); //Espo: no needs to use this handler //Invoke middleware and application stack $this->middleware[0]->call(); diff --git a/vendor/Slim/View.php b/vendor/slim/slim/Slim/View.php old mode 100755 new mode 100644 similarity index 100% rename from vendor/Slim/View.php rename to vendor/slim/slim/Slim/View.php diff --git a/vendor/slim/slim/composer.json b/vendor/slim/slim/composer.json new file mode 100644 index 0000000000..a49c05ec20 --- /dev/null +++ b/vendor/slim/slim/composer.json @@ -0,0 +1,21 @@ +{ + "name": "slim/slim", + "type": "library", + "description": "Slim Framework, a PHP micro framework", + "keywords": ["microframework","rest","router"], + "homepage": "http://github.com/codeguy/Slim", + "license": "MIT", + "authors": [ + { + "name": "Josh Lockhart", + "email": "info@joshlockhart.com", + "homepage": "http://www.joshlockhart.com/" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-0": { "Slim": "." } + } +} diff --git a/vendor/slim/slim/index.php b/vendor/slim/slim/index.php new file mode 100644 index 0000000000..c3e67454cd --- /dev/null +++ b/vendor/slim/slim/index.php @@ -0,0 +1,152 @@ +get('/', function () { + $template = << + + + + Slim Framework for PHP 5 + + + +
+ Slim +
+

Welcome to Slim!

+

+ Congratulations! Your Slim application is running. If this is + your first time using Slim, start with this "Hello World" Tutorial. +

+
+

Get Started

+
    +
  1. The application code is in index.php
  2. +
  3. Read the online documentation
  4. +
  5. Follow @slimphp on Twitter
  6. +
+
+
+

Slim Framework Community

+ +

Support Forum and Knowledge Base

+

+ Visit the Slim support forum and knowledge base + to read announcements, chat with fellow Slim users, ask questions, help others, or show off your cool + Slim Framework apps. +

+ +

Twitter

+

+ Follow @slimphp on Twitter to receive the very latest news + and updates about the framework. +

+
+
+

Slim Framework Extras

+

+ Custom View classes for Smarty, Twig, Mustache, and other template + frameworks are available online in a separate repository. +

+

Browse the Extras Repository

+
+ + +EOT; + echo $template; +}); + +// POST route +$app->post('/post', function () { + echo 'This is a POST route'; +}); + +// PUT route +$app->put('/put', function () { + echo 'This is a PUT route'; +}); + +// DELETE route +$app->delete('/delete', function () { + echo 'This is a DELETE route'; +}); + +/** + * Step 4: Run the Slim application + * + * This method should be called last. This executes the Slim application + * and returns the HTTP response to the HTTP client. + */ +$app->run(); diff --git a/vendor/slim/slim/phpunit.xml.dist b/vendor/slim/slim/phpunit.xml.dist new file mode 100644 index 0000000000..c4da17207d --- /dev/null +++ b/vendor/slim/slim/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + + ./tests/ + + + + + + ./Slim/ + + + diff --git a/vendor/slim/slim/tests/EnvironmentTest.php b/vendor/slim/slim/tests/EnvironmentTest.php new file mode 100644 index 0000000000..91505b8ce7 --- /dev/null +++ b/vendor/slim/slim/tests/EnvironmentTest.php @@ -0,0 +1,358 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class EnvironmentTest extends PHPUnit_Framework_TestCase +{ + /** + * Default server settings assume the Slim app is installed + * in a subdirectory `foo/` directly beneath the public document + * root directory; URL rewrite is disabled; requested app + * resource is GET `/bar/xyz` with three query params. + * + * These only provide a common baseline for the following + * tests; tests are free to override these values. + */ + public function setUp() + { + $_SERVER['SERVER_NAME'] = 'slim'; + $_SERVER['SERVER_PORT'] = '80'; + $_SERVER['SCRIPT_NAME'] = '/foo/index.php'; + $_SERVER['REQUEST_URI'] = '/foo/index.php/bar/xyz'; + $_SERVER['PATH_INFO'] = '/bar/xyz'; + $_SERVER['REQUEST_METHOD'] = 'GET'; + $_SERVER['QUERY_STRING'] = 'one=1&two=2&three=3'; + $_SERVER['HTTPS'] = ''; + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; + unset($_SERVER['CONTENT_TYPE'], $_SERVER['CONTENT_LENGTH']); + } + + /** + * Test mock environment + * + * This should return the custom values where specified + * and the default values otherwise. + */ + public function testMockEnvironment() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'PUT' + )); + $env2 = \Slim\Environment::getInstance(); + $this->assertSame($env, $env2); + $this->assertInstanceOf('\Slim\Environment', $env); + $this->assertEquals('PUT', $env['REQUEST_METHOD']); + $this->assertEquals(80, $env['SERVER_PORT']); + $this->assertNull($env['foo']); + } + + /** + * Test sets HTTP method + */ + public function testSetsHttpMethod() + { + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('GET', $env['REQUEST_METHOD']); + } + + /** + * Test parses script name and path info + * + * Pre-conditions: + * URL Rewrite is disabled; + * App installed in subdirectory; + */ + public function testParsesPathsWithoutUrlRewriteInSubdirectory() + { + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('/bar/xyz', $env['PATH_INFO']); + $this->assertEquals('/foo/index.php', $env['SCRIPT_NAME']); + } + + /** + * Test parses script name and path info + * + * Pre-conditions: + * URL Rewrite is disabled; + * App installed in root directory; + */ + public function testParsesPathsWithoutUrlRewriteInRootDirectory() + { + $_SERVER['REQUEST_URI'] = '/index.php/bar/xyz'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('/bar/xyz', $env['PATH_INFO']); + $this->assertEquals('/index.php', $env['SCRIPT_NAME']); + } + + /** + * Test parses script name and path info + * + * Pre-conditions: + * URL Rewrite disabled; + * App installed in root directory; + * Requested resource is "/"; + */ + public function testParsesPathsWithoutUrlRewriteInRootDirectoryForAppRootUri() + { + $_SERVER['REQUEST_URI'] = '/index.php'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; + unset($_SERVER['PATH_INFO']); + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('/', $env['PATH_INFO']); + $this->assertEquals('/index.php', $env['SCRIPT_NAME']); + } + + /** + * Test parses script name and path info + * + * Pre-conditions: + * URL Rewrite enabled; + * App installed in subdirectory; + */ + public function testParsesPathsWithUrlRewriteInSubdirectory() + { + $_SERVER['SCRIPT_NAME'] = '/foo/index.php'; + $_SERVER['REQUEST_URI'] = '/foo/bar/xyz'; + unset($_SERVER['PATH_INFO']); + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('/bar/xyz', $env['PATH_INFO']); + $this->assertEquals('/foo', $env['SCRIPT_NAME']); + } + + /** + * Test parses script name and path info + * + * Pre-conditions: + * URL Rewrite enabled; + * App installed in root directory; + */ + public function testParsesPathsWithUrlRewriteInRootDirectory() + { + $_SERVER['SCRIPT_NAME'] = '/index.php'; + $_SERVER['REQUEST_URI'] = '/bar/xyz'; + unset($_SERVER['PATH_INFO']); + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('/bar/xyz', $env['PATH_INFO']); + $this->assertEquals('', $env['SCRIPT_NAME']); + } + + /** + * Test parses script name and path info + * + * Pre-conditions: + * URL Rewrite enabled; + * App installed in root directory; + * Requested resource is "/" + */ + public function testParsesPathsWithUrlRewriteInRootDirectoryForAppRootUri() + { + $_SERVER['REQUEST_URI'] = '/'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; + unset($_SERVER['PATH_INFO']); + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('/', $env['PATH_INFO']); + $this->assertEquals('', $env['SCRIPT_NAME']); + } + + /** + * Test parses query string + * + * Pre-conditions: + * $_SERVER['QUERY_STRING'] exists and is not empty; + */ + public function testParsesQueryString() + { + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('one=1&two=2&three=3', $env['QUERY_STRING']); + } + + /** + * Test removes query string from PATH_INFO when using URL Rewrite + * + * Pre-conditions: + * $_SERVER['QUERY_STRING'] exists and is not empty; + * URL Rewrite enabled; + */ + public function testRemovesQueryStringFromPathInfo() + { + $_SERVER['SCRIPT_NAME'] = '/foo/index.php'; + $_SERVER['REQUEST_URI'] = '/foo/bar/xyz?one=1&two=2&three=3'; + unset($_SERVER['PATH_INFO']); + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('/bar/xyz', $env['PATH_INFO']); + } + + /** + * Test environment's PATH_INFO retains URL encoded characters (e.g. #) + * + * In earlier version, \Slim\Environment would use PATH_INFO instead + * of REQUEST_URI to determine the root URI and resource URI. + * Unfortunately, the server would URL decode the PATH_INFO string + * before it was handed to PHP. This prevented certain URL-encoded + * characters like the octothorpe from being delivered correctly to + * the Slim application environment. This test ensures the + * REQUEST_URI is used instead and parsed as expected. + */ + public function testPathInfoRetainsUrlEncodedCharacters() + { + $_SERVER['SCRIPT_NAME'] = '/index.php'; + $_SERVER['REQUEST_URI'] = '/foo/%23bar'; //<-- URL-encoded "#bar" + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('/foo/%23bar', $env['PATH_INFO']); + } + + /** + * Test parses query string + * + * Pre-conditions: + * $_SERVER['QUERY_STRING'] does not exist; + */ + public function testParsesQueryStringThatDoesNotExist() + { + unset($_SERVER['QUERY_STRING']); + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('', $env['QUERY_STRING']); + } + + /** + * Test SERVER_NAME is not empty + */ + public function testServerNameIsNotEmpty() + { + $env = \Slim\Environment::getInstance(true); + $this->assertFalse(empty($env['SERVER_NAME'])); + } + + /** + * Test SERVER_PORT is not empty + */ + public function testServerPortIsNotEmpty() + { + $env = \Slim\Environment::getInstance(true); + $this->assertFalse(empty($env['SERVER_PORT'])); + } + + /** + * Test unsets HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH + * + * Pre-conditions: + * HTTP_CONTENT_TYPE is sent with HTTP request; + * HTTP_CONTENT_LENGTH is sent with HTTP request; + */ + public function testUnsetsContentTypeAndContentLength() + { + $_SERVER['HTTP_CONTENT_TYPE'] = 'text/csv'; + $_SERVER['HTTP_CONTENT_LENGTH'] = 150; + $env = \Slim\Environment::getInstance(true); + $this->assertFalse(isset($env['HTTP_CONTENT_TYPE'])); + $this->assertFalse(isset($env['HTTP_CONTENT_LENGTH'])); + } + + /** + * Test sets special request headers if not empty + * + * Pre-conditions: + * CONTENT_TYPE, CONTENT_LENGTH, X_REQUESTED_WITH are sent in client HTTP request; + * CONTENT_TYPE, CONTENT_LENGTH, X_REQUESTED_WITH are not empty; + */ + public function testSetsSpecialHeaders() + { + $_SERVER['CONTENT_TYPE'] = 'text/csv'; + $_SERVER['CONTENT_LENGTH'] = '100'; + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XmlHttpRequest'; + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('text/csv', $env['CONTENT_TYPE']); + $this->assertEquals('100', $env['CONTENT_LENGTH']); + $this->assertEquals('XmlHttpRequest', $env['X_REQUESTED_WITH']); + } + + /** + * Test detects HTTPS + * + * Pre-conditions: + * $_SERVER['HTTPS'] is set to a non-empty value; + */ + public function testHttps() + { + $_SERVER['HTTPS'] = 1; + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('https', $env['slim.url_scheme']); + } + + /** + * Test detects not HTTPS + * + * Pre-conditions: + * $_SERVER['HTTPS'] is set to an empty value; + */ + public function testNotHttps() + { + $_SERVER['HTTPS'] = ''; + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('http', $env['slim.url_scheme']); + } + + /** + * Test detects not HTTPS on IIS + * + * Pre-conditions: + * $_SERVER['HTTPS'] is set to "off"; + */ + public function testNotHttpsIIS() + { + $_SERVER['HTTPS'] = 'off'; + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('http', $env['slim.url_scheme']); + } + + /** + * Test input is an empty string (and not false) + * + * Pre-conditions: + * Input at php://input may only be read once; subsequent attempts + * will return `false`; in which case, use an empty string. + */ + public function testInputIsEmptyString() + { + $env = \Slim\Environment::getInstance(true); + $this->assertEquals('', $env['slim.input']); + } + + /** + * Test valid resource handle to php://stdErr + */ + public function testErrorResource() + { + $env = \Slim\Environment::getInstance(true); + $this->assertTrue(is_resource($env['slim.errors'])); + } +} diff --git a/vendor/slim/slim/tests/Foo.php b/vendor/slim/slim/tests/Foo.php new file mode 100644 index 0000000000..d772d02ece --- /dev/null +++ b/vendor/slim/slim/tests/Foo.php @@ -0,0 +1,7 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class HeadersTest extends PHPUnit_Framework_TestCase +{ + /** + * Test constructor without args + */ + public function testConstructorWithoutArgs() + { + $h = new \Slim\Http\Headers(); + $this->assertEquals(0, count($h)); + } + + /** + * Test constructor with args + */ + public function testConstructorWithArgs() + { + $h = new \Slim\Http\Headers(array('Content-Type' => 'text/html')); + $this->assertEquals(1, count($h)); + } + + /** + * Test get and set header + */ + public function testSetAndGetHeader() + { + $h = new \Slim\Http\Headers(); + $h['Content-Type'] = 'text/html'; + $this->assertEquals('text/html', $h['Content-Type']); + $this->assertEquals('text/html', $h['Content-type']); + $this->assertEquals('text/html', $h['content-type']); + } + + /** + * Test get non-existent header + */ + public function testGetNonExistentHeader() + { + $h = new \Slim\Http\Headers(); + $this->assertNull($h['foo']); + } + + /** + * Test isset header + */ + public function testHeaderIsSet() + { + $h = new \Slim\Http\Headers(); + $h['Content-Type'] = 'text/html'; + $this->assertTrue(isset($h['Content-Type'])); + $this->assertTrue(isset($h['Content-type'])); + $this->assertTrue(isset($h['content-type'])); + $this->assertFalse(isset($h['foo'])); + } + + /** + * Test unset header + */ + public function testUnsetHeader() + { + $h = new \Slim\Http\Headers(); + $h['Content-Type'] = 'text/html'; + $this->assertEquals(1, count($h)); + unset($h['Content-Type']); + $this->assertEquals(0, count($h)); + } + + /** + * Test merge headers + */ + public function testMergeHeaders() + { + $h = new \Slim\Http\Headers(); + $h['Content-Type'] = 'text/html'; + $this->assertEquals(1, count($h)); + $h->merge(array('Content-type' => 'text/csv', 'content-length' => 10)); + $this->assertEquals(2, count($h)); + $this->assertEquals('text/csv', $h['content-type']); + $this->assertEquals(10, $h['Content-length']); + } + + /** + * Test iteration + */ + public function testIteration() + { + $h = new \Slim\Http\Headers(); + $h['One'] = 'Foo'; + $h['Two'] = 'Bar'; + $output = ''; + foreach ($h as $key => $value) { + $output .= $key . $value; + } + $this->assertEquals('OneFooTwoBar', $output); + } + + /** + * Test outputs header name in original form, not canonical form + */ + public function testOutputsOriginalNotCanonicalName() + { + $h = new \Slim\Http\Headers(); + $h['X-Powered-By'] = 'Slim'; + $h['Content-Type'] = 'text/csv'; + $keys = array(); + foreach ($h as $name => $value) { + $keys[] = $name; + } + $this->assertContains('X-Powered-By', $keys); + $this->assertContains('Content-Type', $keys); + } +} diff --git a/vendor/slim/slim/tests/Http/RequestTest.php b/vendor/slim/slim/tests/Http/RequestTest.php new file mode 100644 index 0000000000..b2d3def74c --- /dev/null +++ b/vendor/slim/slim/tests/Http/RequestTest.php @@ -0,0 +1,933 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class RequestTest extends PHPUnit_Framework_TestCase +{ + /** + * Test sets HTTP method + */ + public function testGetMethod() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('GET', $req->getMethod()); + } + + /** + * Test HTTP GET method detection + */ + public function testIsGet() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET' + )); + $req = new \Slim\Http\Request($env); + $this->assertTrue($req->isGet()); + $this->assertFalse($req->isPost()); + $this->assertFalse($req->isPut()); + $this->assertFalse($req->isDelete()); + $this->assertFalse($req->isOptions()); + $this->assertFalse($req->isHead()); + } + + /** + * Test HTTP POST method detection + */ + public function testIsPost() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + )); + $req = new \Slim\Http\Request($env); + $this->assertFalse($req->isGet()); + $this->assertTrue($req->isPost()); + $this->assertFalse($req->isPut()); + $this->assertFalse($req->isDelete()); + $this->assertFalse($req->isOptions()); + $this->assertFalse($req->isHead()); + } + + /** + * Test HTTP PUT method detection + */ + public function testIsPut() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'PUT', + )); + $req = new \Slim\Http\Request($env); + $this->assertFalse($req->isGet()); + $this->assertFalse($req->isPost()); + $this->assertTrue($req->isPut()); + $this->assertFalse($req->isDelete()); + $this->assertFalse($req->isOptions()); + $this->assertFalse($req->isHead()); + } + + /** + * Test HTTP DELETE method detection + */ + public function testIsDelete() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'DELETE', + )); + $req = new \Slim\Http\Request($env); + $this->assertFalse($req->isGet()); + $this->assertFalse($req->isPost()); + $this->assertFalse($req->isPut()); + $this->assertTrue($req->isDelete()); + $this->assertFalse($req->isOptions()); + $this->assertFalse($req->isHead()); + } + + /** + * Test HTTP OPTIONS method detection + */ + public function testIsOptions() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'OPTIONS', + )); + $req = new \Slim\Http\Request($env); + $this->assertFalse($req->isGet()); + $this->assertFalse($req->isPost()); + $this->assertFalse($req->isPut()); + $this->assertFalse($req->isDelete()); + $this->assertTrue($req->isOptions()); + $this->assertFalse($req->isHead()); + } + + /** + * Test HTTP HEAD method detection + */ + public function testIsHead() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'HEAD', + )); + $req = new \Slim\Http\Request($env); + $this->assertFalse($req->isGet()); + $this->assertFalse($req->isPost()); + $this->assertFalse($req->isPut()); + $this->assertFalse($req->isDelete()); + $this->assertFalse($req->isOptions()); + $this->assertTrue($req->isHead()); + } + + /** + * Test AJAX method detection w/ header + */ + public function testIsAjaxWithHeader() + { + $env = \Slim\Environment::mock(array( + 'X_REQUESTED_WITH' => 'XMLHttpRequest' + )); + $req = new \Slim\Http\Request($env); + $this->assertTrue($req->isAjax()); + $this->assertTrue($req->isXhr()); + } + + /** + * Test AJAX method detection w/ query parameter + */ + public function testIsAjaxWithQueryParameter() + { + $env = \Slim\Environment::mock(array( + 'QUERY_STRING' => 'one=1&two=2&three=3&isajax=1', + )); + $req = new \Slim\Http\Request($env); + $this->assertTrue($req->isAjax()); + $this->assertTrue($req->isXhr()); + } + + /** + * Test AJAX method detection wihtout header or query paramter + */ + public function testIsAjaxWithoutHeaderOrQueryParameter() + { + $env = \Slim\Environment::mock(); + $req = new \Slim\Http\Request($env); + $this->assertFalse($req->isAjax()); + $this->assertFalse($req->isXhr()); + } + + /** + * Test AJAX method detection with misspelled header + */ + public function testIsAjaxWithMisspelledHeader() + { + $env = \Slim\Environment::mock(array( + 'X_REQUESTED_WITH' => 'foo' + )); + $req = new \Slim\Http\Request($env); + $this->assertFalse($req->isAjax()); + $this->assertFalse($req->isXhr()); + } + + /** + * Test params from query string + */ + public function testParamsFromQueryString() + { + $env = \Slim\Environment::mock(array( + 'QUERY_STRING' => 'one=1&two=2&three=3' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(3, count($req->params())); + $this->assertEquals('1', $req->params('one')); + $this->assertNull($req->params('foo')); + } + + /** + * Test params from request body + */ + public function testParamsFromRequestBody() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'slim.input' => 'foo=bar&abc=123', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH' => 15 + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(5, count($req->params())); //Union of GET and POST + $this->assertEquals('bar', $req->params('foo')); + } + + /** + * Test fetch GET params + */ + public function testGet() + { + $env = \Slim\Environment::mock(array( + 'QUERY_STRING' => 'one=1&two=2&three=3' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(3, count($req->get())); + $this->assertEquals('1', $req->get('one')); + $this->assertNull($req->get('foo')); + } + + /** + * Test fetch GET params without multibyte + */ + public function testGetWithoutMultibyte() + { + $env = \Slim\Environment::mock(array( + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'slim.tests.ignore_multibyte' => true + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(3, count($req->get())); + $this->assertEquals('1', $req->get('one')); + $this->assertNull($req->get('foo')); + } + + /** + * Test fetch POST params + */ + public function testPost() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'slim.input' => 'foo=bar&abc=123', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH' => 15 + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(2, count($req->post())); + $this->assertEquals('bar', $req->post('foo')); + $this->assertNull($req->post('xyz')); + } + + /** + * Test fetch POST params without multibyte + */ + public function testPostWithoutMultibyte() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'slim.input' => 'foo=bar&abc=123', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH' => 15, + 'slim.tests.ignore_multibyte' => true + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(2, count($req->post())); + $this->assertEquals('bar', $req->post('foo')); + $this->assertNull($req->post('xyz')); + } + + /** + * Test fetch POST without slim.input + */ + public function testPostWithoutInput() + { + $this->setExpectedException('RuntimeException'); + $env = \Slim\Environment::mock(); + unset($env['slim.input']); + $req = new \Slim\Http\Request($env); + $req->post('foo'); + } + + /** + * Test fetch POST params even if multipart/form-data request + */ + public function testPostWithMultipartRequest() + { + $_POST = array('foo' => 'bar'); //<-- Set by PHP + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'slim.input' => '', //<-- "php://input" is empty for multipart/form-data requests + 'CONTENT_TYPE' => 'multipart/form-data', + 'CONTENT_LENGTH' => 0 + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(1, count($req->post())); + $this->assertEquals('bar', $req->post('foo')); + $this->assertNull($req->post('xyz')); + } + + /** + * Test fetch PUT params + */ + public function testPut() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'PUT', + 'slim.input' => 'foo=bar&abc=123', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH' => 15 + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(2, count($req->put())); + $this->assertEquals('bar', $req->put('foo')); + $this->assertEquals('bar', $req->params('foo')); + $this->assertNull($req->put('xyz')); + } + + /** + * Test fetch DELETE params + */ + public function testDelete() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'DELETE', + 'slim.input' => 'foo=bar&abc=123', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH' => 15 + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(2, count($req->delete())); + $this->assertEquals('bar', $req->delete('foo')); + $this->assertEquals('bar', $req->params('foo')); + $this->assertNull($req->delete('xyz')); + } + + /** + * Test fetch COOKIE params + */ + public function testCookies() + { + $env = \Slim\Environment::mock(array( + 'COOKIE' => 'foo=bar; abc=123' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(2, count($req->cookies())); + $this->assertEquals('bar', $req->cookies('foo')); + $this->assertNull($req->cookies('xyz')); + } + + /** + * Test is form data + */ + public function testIsFormDataContentFormUrlencoded() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'PUT', + 'slim.input' => '', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded' + )); + $req = new \Slim\Http\Request($env); + $this->assertTrue($req->isFormData()); + } + + /** + * Test is form data + */ + public function testIsFormDataPostContentUnknown() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'slim.input' => '', + )); + $req = new \Slim\Http\Request($env); + $this->assertTrue($req->isFormData()); + } + + /** + * Test is form data + */ + public function testIsFormDataPostContentUnknownWithMethodOverride() + { + $env = \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'PUT', + )); + $env['slim.method_override.original_method'] = 'POST'; + $req = new \Slim\Http\Request($env); + $this->assertTrue($req->isPut()); + $this->assertTrue($req->isFormData()); + } + + /** + * Test is not form data + */ + public function testIsNotFormData() + { + $env = \Slim\Environment::mock(array( + 'slim.input' => '', + 'CONTENT_TYPE' => 'application/json' + )); + $req = new \Slim\Http\Request($env); + $this->assertFalse($req->isFormData()); + } + + /** + * Test headers + */ + public function testHeaders() + { + $env = \Slim\Environment::mock(array( + 'ACCEPT_ENCODING' => 'gzip' + )); + $req = new \Slim\Http\Request($env); + $headers = $req->headers(); + $this->assertTrue(is_array($headers)); + $this->assertArrayHasKey('ACCEPT_ENCODING', $headers); + $this->assertEquals('gzip', $req->headers('HTTP_ACCEPT_ENCODING')); + $this->assertEquals('gzip', $req->headers('HTTP-ACCEPT-ENCODING')); + $this->assertEquals('gzip', $req->headers('http_accept_encoding')); + $this->assertEquals('gzip', $req->headers('http-accept-encoding')); + $this->assertEquals('gzip', $req->headers('ACCEPT_ENCODING')); + $this->assertEquals('gzip', $req->headers('ACCEPT-ENCODING')); + $this->assertEquals('gzip', $req->headers('accept_encoding')); + $this->assertEquals('gzip', $req->headers('accept-encoding')); + $this->assertNull($req->headers('foo')); + } + + /** + * Test accurately removes HTTP_ prefix from input header name + */ + public function testHeaderRemovesHttpPrefix() + { + $env = \Slim\Environment::mock(array( + 'X_HTTP_METHOD_OVERRIDE' => 'PUT', + 'CONTENT_TYPE' => 'application/json' + )); + //fwrite(fopen('php://stdout', 'w'), print_r($env, true)); + $req = new \Slim\Http\Request($env); + $this->assertEquals('PUT', $req->headers('X_HTTP_METHOD_OVERRIDE')); + $this->assertNull($req->headers('X_METHOD_OVERRIDE')); //<-- Ensures `HTTP_` is not removed if not prefix + $this->assertEquals('application/json', $req->headers('HTTP_CONTENT_TYPE')); //<-- Ensures `HTTP_` is removed if prefix + } + + /** + * Test get body + */ + public function testGetBodyWhenExists() + { + $env = \Slim\Environment::mock(array( + 'slim.input' => 'foo=bar&abc=123', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH' => 15 + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('foo=bar&abc=123', $req->getBody()); + } + + /** + * Test get body + */ + public function testGetBodyWhenNotExists() + { + $env = \Slim\Environment::mock(); + $req = new \Slim\Http\Request($env); + $this->assertEquals('', $req->getBody()); + } + + /** + * Test get content type + */ + public function testGetContentTypeWhenExists() + { + $env = \Slim\Environment::mock(array( + 'slim.input' => '', + 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('application/json; charset=ISO-8859-4', $req->getContentType()); + } + + /** + * Test get content type + */ + public function testGetContentTypeWhenNotExists() + { + $env = \Slim\Environment::mock(); + $req = new \Slim\Http\Request($env); + $this->assertNull($req->getContentType()); + } + + /** + * Test get media type + */ + public function testGetMediaTypeWhenExists() + { + $env = \Slim\Environment::mock(array( + 'CONTENT_TYPE' => 'application/json;charset=utf-8' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('application/json', $req->getMediaType()); + } + + /** + * Test get media type + */ + public function testGetMediaTypeWhenNotExists() + { + $env = \Slim\Environment::mock(); + $req = new \Slim\Http\Request($env); + $this->assertNull($req->getMediaType()); + } + + /** + * Test get media type + */ + public function testGetMediaTypeWhenNoParamsExist() + { + $env = \Slim\Environment::mock(array( + 'slim.input' => '', + 'CONTENT_TYPE' => 'application/json' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('application/json', $req->getMediaType()); + } + + /** + * Test get media type params + */ + public function testGetMediaTypeParams() + { + $env = \Slim\Environment::mock(array( + 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4' + )); + $req = new \Slim\Http\Request($env); + $params = $req->getMediaTypeParams(); + $this->assertEquals(1, count($params)); + $this->assertArrayHasKey('charset', $params); + $this->assertEquals('ISO-8859-4', $params['charset']); + } + + /** + * Test get media type params + */ + public function testGetMediaTypeParamsWhenNotExists() + { + $env = \Slim\Environment::mock(); + $req = new \Slim\Http\Request($env); + $params = $req->getMediaTypeParams(); + $this->assertTrue(is_array($params)); + $this->assertEquals(0, count($params)); + } + + /** + * Test get content charset + */ + public function testGetContentCharset() + { + $env = \Slim\Environment::mock(array( + 'slim.input' => '', + 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('ISO-8859-4', $req->getContentCharset()); + } + + /** + * Test get content charset + */ + public function testGetContentCharsetWhenNotExists() + { + $env = \Slim\Environment::mock(array( + 'slim.input' => '', + 'CONTENT_TYPE' => 'application/json' + )); + $req = new \Slim\Http\Request($env); + $this->assertNull($req->getContentCharset()); + } + + /** + * Test get content length + */ + public function testGetContentLength() + { + $env = \Slim\Environment::mock(array( + 'slim.input' => 'foo=bar&abc=123', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_LENGTH' => 15 + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(15, $req->getContentLength()); + } + + /** + * Test get content length + */ + public function testGetContentLengthWhenNotExists() + { + $env = \Slim\Environment::mock(array( + 'slim.input' => '', + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals(0, $req->getContentLength()); + } + + /** + * Test get host + */ + public function testGetHost() + { + $env = \Slim\Environment::mock(array( + 'SERVER_NAME' => 'slim', + 'HOST' => 'slimframework.com' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('slimframework.com', $req->getHost()); //Uses HTTP_HOST if available + } + + /** + * Test get host when it has a port number + */ + public function testGetHostAndStripPort() + { + $env = \Slim\Environment::mock(array( + 'SERVER_NAME' => 'slim', + 'HOST' => 'slimframework.com:80' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('slimframework.com', $req->getHost()); //Uses HTTP_HOST if available + } + + /** + * Test get host + */ + public function testGetHostWhenNotExists() + { + $env = \Slim\Environment::mock(array( + 'SERVER_NAME' => 'slim', + 'HOST' => 'slimframework.com' + )); + unset($env['HOST']); + $req = new \Slim\Http\Request($env); + $this->assertEquals('slim', $req->getHost()); //Uses SERVER_NAME as backup + } + + /** + * Test get host with port + */ + public function testGetHostWithPort() + { + $env = \Slim\Environment::mock(array( + 'HOST' => 'slimframework.com', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('slimframework.com:80', $req->getHostWithPort()); + } + + /** + * Test get host with port doesn't dulplicate port numbers + */ + public function testGetHostDoesntDulplicatePort() + { + $env = \Slim\Environment::mock(array( + 'HOST' => 'slimframework.com:80', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('slimframework.com:80', $req->getHostWithPort()); + } + + /** + * Test get port + */ + public function testGetPort() + { + $env = \Slim\Environment::mock(array( + 'SERVER_PORT' => 80 + )); + $req = new \Slim\Http\Request($env); + $this->assertTrue(is_integer($req->getPort())); + $this->assertEquals(80, $req->getPort()); + } + + /** + * Test get scheme + */ + public function testGetSchemeIfHttp() + { + $env = \Slim\Environment::mock(array( + 'slim.url_scheme' => 'http' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('http', $req->getScheme()); + } + + /** + * Test get scheme + */ + public function testGetSchemeIfHttps() + { + $env = \Slim\Environment::mock(array( + 'slim.url_scheme' => 'https', + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('https', $req->getScheme()); + } + + /** + * Test get [script name, root uri, path, path info, resource uri] in subdirectory without htaccess + */ + public function testAppPathsInSubdirectoryWithoutHtaccess() + { + $env = \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo/index.php', //<-- Physical + 'PATH_INFO' => '/bar/xyz', //<-- Virtual + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('/foo/index.php', $req->getScriptName()); + $this->assertEquals('/foo/index.php', $req->getRootUri()); + $this->assertEquals('/foo/index.php/bar/xyz', $req->getPath()); + $this->assertEquals('/bar/xyz', $req->getPathInfo()); + $this->assertEquals('/bar/xyz', $req->getResourceUri()); + } + + /** + * Test get [script name, root uri, path, path info, resource uri] in subdirectory with htaccess + */ + public function testAppPathsInSubdirectoryWithHtaccess() + { + $env = \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar/xyz', //<-- Virtual + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('/foo', $req->getScriptName()); + $this->assertEquals('/foo', $req->getRootUri()); + $this->assertEquals('/foo/bar/xyz', $req->getPath()); + $this->assertEquals('/bar/xyz', $req->getPathInfo()); + $this->assertEquals('/bar/xyz', $req->getResourceUri()); + } + + /** + * Test get [script name, root uri, path, path info, resource uri] in root directory without htaccess + */ + public function testAppPathsInRootDirectoryWithoutHtaccess() + { + $env = \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/index.php', //<-- Physical + 'PATH_INFO' => '/bar/xyz', //<-- Virtual + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('/index.php', $req->getScriptName()); + $this->assertEquals('/index.php', $req->getRootUri()); + $this->assertEquals('/index.php/bar/xyz', $req->getPath()); + $this->assertEquals('/bar/xyz', $req->getPathInfo()); + $this->assertEquals('/bar/xyz', $req->getResourceUri()); + } + + /** + * Test get [script name, root uri, path, path info, resource uri] in root directory with htaccess + */ + public function testAppPathsInRootDirectoryWithHtaccess() + { + $env = \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/bar/xyz', //<-- Virtual + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('', $req->getScriptName()); + $this->assertEquals('', $req->getRootUri()); + $this->assertEquals('/bar/xyz', $req->getPath()); + $this->assertEquals('/bar/xyz', $req->getPathInfo()); + $this->assertEquals('/bar/xyz', $req->getResourceUri()); + } + + /** + * Test get URL + */ + public function testGetUrl() + { + $env = \Slim\Environment::mock(array( + 'HOST' => 'slimframework.com', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('http://slimframework.com', $req->getUrl()); + } + + /** + * Test get URL + */ + public function testGetUrlWithCustomPort() + { + $env = \Slim\Environment::mock(array( + 'HOST' => 'slimframework.com', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 8080, + 'slim.url_scheme' => 'http' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('http://slimframework.com:8080', $req->getUrl()); + } + + /** + * Test get URL + */ + public function testGetUrlWithHttps() + { + $env = \Slim\Environment::mock(array( + 'HOST' => 'slimframework.com', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 443, + 'slim.url_scheme' => 'https' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('https://slimframework.com', $req->getUrl()); + } + + /** + * Test get IP + */ + public function testGetIp() + { + $env = \Slim\Environment::mock(array( + 'REMOTE_ADDR' => '127.0.0.1' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('127.0.0.1', $req->getIp()); + } + + /** + * Test get IP with proxy server and Client-Ip header + */ + public function testGetIpWithClientIp() + { + $env = \Slim\Environment::mock(array( + 'REMOTE_ADDR' => '127.0.0.1', + 'CLIENT_IP' => '127.0.0.2' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('127.0.0.2', $req->getIp()); + } + + /** + * Test get IP with proxy server and X-Forwarded-For header + */ + public function testGetIpWithForwardedFor() + { + $env = \Slim\Environment::mock(array( + 'REMOTE_ADDR' => '127.0.0.1', + 'CLIENT_IP' => '127.0.0.2', + 'X_FORWARDED_FOR' => '127.0.0.3' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('127.0.0.3', $req->getIp()); + } + + /** + * Test get refererer + */ + public function testGetReferrer() + { + $env = \Slim\Environment::mock(array( + 'REFERER' => 'http://foo.com' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('http://foo.com', $req->getReferrer()); + $this->assertEquals('http://foo.com', $req->getReferer()); + } + + /** + * Test get refererer + */ + public function testGetReferrerWhenNotExists() + { + $env = \Slim\Environment::mock(); + $req = new \Slim\Http\Request($env); + $this->assertNull($req->getReferrer()); + $this->assertNull($req->getReferer()); + } + + /** + * Test get user agent string + */ + public function testGetUserAgent() + { + $env = \Slim\Environment::mock(array( + 'USER_AGENT' => 'user-agent-string' + )); + $req = new \Slim\Http\Request($env); + $this->assertEquals('user-agent-string', $req->getUserAgent()); + } + + /** + * Test get user agent string when not set + */ + public function testGetUserAgentWhenNotExists() + { + $env = \Slim\Environment::mock(); + unset($env['USER_AGENT']); + $req = new \Slim\Http\Request($env); + $this->assertNull($req->getUserAgent()); + } +} diff --git a/vendor/slim/slim/tests/Http/ResponseTest.php b/vendor/slim/slim/tests/Http/ResponseTest.php new file mode 100644 index 0000000000..2321e613c4 --- /dev/null +++ b/vendor/slim/slim/tests/Http/ResponseTest.php @@ -0,0 +1,574 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class ResponseTest extends PHPUnit_Framework_TestCase +{ + /** + * Test constructor without args + */ + public function testConstructorWithoutArgs() + { + $r = new \Slim\Http\Response(); + $this->assertEquals('', $r->body()); + $this->assertEquals(200, $r->status()); + $this->assertEquals(0, $r->length()); + $this->assertEquals('text/html', $r['Content-Type']); + } + + /** + * Test constructor with args + */ + public function testConstructorWithArgs() + { + $r = new \Slim\Http\Response('Page Not Found', 404, array('Content-Type' => 'application/json', 'X-Created-By' => 'Slim')); + $this->assertEquals('Page Not Found', $r->body()); + $this->assertEquals(404, $r->status()); + $this->assertEquals(14, $r->length()); + $this->assertEquals('application/json', $r['Content-Type']); + $this->assertEquals('Slim', $r['X-Created-By']); + } + + /** + * Test get status + */ + public function testGetStatus() + { + $r = new \Slim\Http\Response(); + $this->assertEquals(200, $r->status()); + } + + /** + * Test set status + */ + public function testSetStatus() + { + $r = new \Slim\Http\Response(); + $r->status(500); + $this->assertEquals(500, $r->status()); + } + + /** + * Test get headers + */ + public function testGetHeaders() + { + $r = new \Slim\Http\Response(); + $headers = $r->headers(); + $this->assertEquals(1, count($headers)); + $this->assertEquals('text/html', $headers['Content-Type']); + } + + /** + * Test get and set header (without Array Access) + */ + public function testGetAndSetHeader() + { + $r = new \Slim\Http\Response(); + $r->header('X-Foo', 'Bar'); + $this->assertEquals('Bar', $r->header('X-Foo')); + } + + /** + * Test get body + */ + public function testGetBody() + { + $r = new \Slim\Http\Response('Foo'); + $this->assertEquals('Foo', $r->body()); + } + + /** + * Test set body + */ + public function testSetBody() + { + $r = new \Slim\Http\Response(); + $r->body('Foo'); + $this->assertEquals('Foo', $r->body()); + } + + /** + * Test get length + */ + public function testGetLength() + { + $r = new \Slim\Http\Response('Foo'); + $this->assertEquals(3, $r->length()); + } + + /** + * Test set length + */ + public function testSetLength() + { + $r = new \Slim\Http\Response(); + $r->length(3); + $this->assertEquals(3, $r->length()); + } + + /** + * Test write for appending + */ + public function testWriteAppend() + { + $r = new \Slim\Http\Response('Foo'); + $r->write('Bar'); + $this->assertEquals('FooBar', $r->body()); + } + + /** + * Test write for replacing + */ + public function testWriteReplace() + { + $r = new \Slim\Http\Response('Foo'); + $r->write('Bar', true); + $this->assertEquals('Bar', $r->body()); + } + + /** + * Test finalize + */ + public function testFinalize() + { + $r = new \Slim\Http\Response(); + $r->status(404); + $r['Content-Type'] = 'application/json'; + $r->write('Foo'); + $result = $r->finalize(); + $this->assertEquals(3, count($result)); + $this->assertEquals(404, $result[0]); + $this->assertFalse(is_null($result[1]['Content-Type'])); + } + + /** + * Test finalize + */ + public function testFinalizeWithoutBody() + { + $r = new \Slim\Http\Response(); + $r->status(204); + $r['Content-Type'] = 'application/json'; + $r->write('Foo'); + $result = $r->finalize(); + $this->assertEquals(3, count($result)); + $this->assertEquals('', $result[2]); + } + + /** + * Test set cookie with only name and value + */ + public function testSetCookieWithNameAndValue() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', 'bar'); + $this->assertEquals('foo=bar', $r['Set-Cookie']); + } + + /** + * Test set multiple cookies with only name and value + */ + public function testSetMultipleCookiesWithNameAndValue() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', 'bar'); + $r->setCookie('abc', '123'); + $this->assertEquals("foo=bar\nabc=123", $r['Set-Cookie']); + } + + /** + * Test set cookie only name and value and expires (as int) + */ + public function testSetMultipleCookiesWithNameAndValueAndExpiresAsInt() + { + $now = time(); + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'expires' => $now + )); + $this->assertEquals("foo=bar; expires=" . gmdate('D, d-M-Y H:i:s e', $now), $r['Set-Cookie']); + } + + /** + * Test set cookie with only name and value and expires (as string) + */ + public function testSetMultipleCookiesWithNameAndValueAndExpiresAsString() + { + $expires = 'next Tuesday'; + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'expires' => $expires + )); + $this->assertEquals("foo=bar; expires=" . gmdate('D, d-M-Y H:i:s e', strtotime($expires)), $r['Set-Cookie']); + } + + /** + * Test set cookie with name, value, domain + */ + public function testSetCookieWithNameAndValueAndDomain() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'domain' => '.slimframework.com' + )); + $this->assertEquals('foo=bar; domain=.slimframework.com', $r['Set-Cookie']); + } + + /** + * Test set cookie with name, value, domain, path + */ + public function testSetCookieWithNameAndValueAndDomainAndPath() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'domain' => '.slimframework.com', + 'path' => '/foo' + )); + $this->assertEquals($r['Set-Cookie'], 'foo=bar; domain=.slimframework.com; path=/foo'); + } + + /** + * Test set cookie with only name and value and secure flag + */ + public function testSetCookieWithNameAndValueAndSecureFlag() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'secure' => true + )); + $this->assertEquals('foo=bar; secure', $r['Set-Cookie']); + } + + /** + * Test set cookie with only name and value and secure flag (as non-truthy) + */ + public function testSetCookieWithNameAndValueAndSecureFlagAsNonTruthy() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'secure' => 0 + )); + $this->assertEquals('foo=bar', $r['Set-Cookie']); + } + + /** + * Test set cookie with only name and value and httponly flag + */ + public function testSetCookieWithNameAndValueAndHttpOnlyFlag() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'httponly' => true + )); + $this->assertEquals('foo=bar; HttpOnly', $r['Set-Cookie']); + } + + /** + * Test set cookie with only name and value and httponly flag (as non-truthy) + */ + public function testSetCookieWithNameAndValueAndHttpOnlyFlagAsNonTruthy() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'httponly' => 0 + )); + $this->assertEquals('foo=bar', $r['Set-Cookie']); + } + + /* + * Test delete cookie by name + */ + public function testDeleteCookieByName() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', 'bar'); + $r->setCookie('abc', '123'); + $r->deleteCookie('foo'); + $this->assertEquals(1, preg_match("@abc=123\nfoo=; expires=@", $r['Set-Cookie'])); + } + + /* + * Test delete cookie by name and domain + */ + public function testDeleteCookieByNameAndDomain1() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', 'bar'); //Note: This does not have domain associated with it + $r->setCookie('abc', '123'); + $r->deleteCookie('foo', array('domain' => '.slimframework.com')); //This SHOULD NOT remove the `foo` cookie + $this->assertEquals(1, preg_match("@foo=bar\nabc=123\nfoo=; domain=.slimframework.com; expires=@", $r['Set-Cookie'])); + } + + /* + * Test delete cookie by name and domain + */ + public function testDeleteCookieByNameAndDomain2() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', array( + 'value' => 'bar', + 'domain' => '.slimframework.com' //Note: This does have domain associated with it + )); + $r->setCookie('abc', '123'); + $r->deleteCookie('foo', array('domain' => '.slimframework.com')); //This SHOULD remove the `foo` cookie + $this->assertEquals(1, preg_match("@abc=123\nfoo=; domain=.slimframework.com; expires=@", $r['Set-Cookie'])); + } + + /** + * Test delete cookie by name and custom props + */ + public function testDeleteCookieByNameAndCustomProps() + { + $r = new \Slim\Http\Response(); + $r->setCookie('foo', 'bar'); + $r->setCookie('abc', '123'); + $r->deleteCookie('foo', array( + 'secure' => true, + 'httponly' => true + )); + $this->assertEquals(1, preg_match("@abc=123\nfoo=; expires=.*; secure; HttpOnly@", $r['Set-Cookie'])); + } + + /** + * Test redirect + */ + public function testRedirect() + { + $r = new \Slim\Http\Response(); + $r->redirect('/foo'); + $this->assertEquals(302, $r->status()); + $this->assertEquals('/foo', $r['Location']); + } + + /** + * Test redirect with custom status + */ + public function testRedirectWithCustomStatus() + { + $r = new \Slim\Http\Response(); + $r->redirect('/foo', 307); + $this->assertEquals(307, $r->status()); + $this->assertEquals('/foo', $r['Location']); + } + + /** + * Test isEmpty + */ + public function testIsEmpty() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r1->status(404); + $r2->status(201); + $this->assertFalse($r1->isEmpty()); + $this->assertTrue($r2->isEmpty()); + } + + /** + * Test isClientError + */ + public function testIsClientError() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r1->status(404); + $r2->status(500); + $this->assertTrue($r1->isClientError()); + $this->assertFalse($r2->isClientError()); + } + + /** + * Test isForbidden + */ + public function testIsForbidden() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r1->status(403); + $r2->status(500); + $this->assertTrue($r1->isForbidden()); + $this->assertFalse($r2->isForbidden()); + } + + /** + * Test isInformational + */ + public function testIsInformational() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r1->status(100); + $r2->status(200); + $this->assertTrue($r1->isInformational()); + $this->assertFalse($r2->isInformational()); + } + + /** + * Test isInformational + */ + public function testIsNotFound() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r1->status(404); + $r2->status(200); + $this->assertTrue($r1->isNotFound()); + $this->assertFalse($r2->isNotFound()); + } + + /** + * Test isOk + */ + public function testIsOk() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r1->status(200); + $r2->status(201); + $this->assertTrue($r1->isOk()); + $this->assertFalse($r2->isOk()); + } + + /** + * Test isSuccessful + */ + public function testIsSuccessful() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r3 = new \Slim\Http\Response(); + $r1->status(200); + $r2->status(201); + $r3->status(302); + $this->assertTrue($r1->isSuccessful()); + $this->assertTrue($r2->isSuccessful()); + $this->assertFalse($r3->isSuccessful()); + } + + /** + * Test isRedirect + */ + public function testIsRedirect() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r1->status(307); + $r2->status(304); + $this->assertTrue($r1->isRedirect()); + $this->assertFalse($r2->isRedirect()); + } + + /** + * Test isRedirection + */ + public function testIsRedirection() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r3 = new \Slim\Http\Response(); + $r1->status(307); + $r2->status(304); + $r3->status(200); + $this->assertTrue($r1->isRedirection()); + $this->assertTrue($r2->isRedirection()); + $this->assertFalse($r3->isRedirection()); + } + + /** + * Test isServerError + */ + public function testIsServerError() + { + $r1 = new \Slim\Http\Response(); + $r2 = new \Slim\Http\Response(); + $r1->status(500); + $r2->status(400); + $this->assertTrue($r1->isServerError()); + $this->assertFalse($r2->isServerError()); + } + + /** + * Test offset exists and offset get + */ + public function testOffsetExistsAndGet() + { + $r = new \Slim\Http\Response(); + $this->assertFalse(empty($r['Content-Type'])); + $this->assertNull($r['foo']); + } + + /** + * Test iteration + */ + public function testIteration() + { + $h = new \Slim\Http\Response(); + $output = ''; + foreach ($h as $key => $value) { + $output .= $key . $value; + } + $this->assertEquals('Content-Typetext/html', $output); + } + + /** + * Test countable + */ + public function testCountable() + { + $r1 = new \Slim\Http\Response(); + $this->assertEquals(1, count($r1)); //Content-Type + } + + /** + * Test message for code when message exists + */ + public function testMessageForCode() + { + $this->assertEquals('200 OK', \Slim\Http\Response::getMessageForCode(200)); + } + + /** + * Test message for code when message exists + */ + public function testMessageForCodeWithInvalidCode() + { + $this->assertNull(\Slim\Http\Response::getMessageForCode(600)); + } +} diff --git a/vendor/slim/slim/tests/Http/UtilTest.php b/vendor/slim/slim/tests/Http/UtilTest.php new file mode 100644 index 0000000000..4eb0b4d30a --- /dev/null +++ b/vendor/slim/slim/tests/Http/UtilTest.php @@ -0,0 +1,388 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class SlimHttpUtilTest extends PHPUnit_Framework_TestCase +{ + /** + * Test strip slashes when magic quotes disabled + */ + public function testStripSlashesWithoutMagicQuotes() + { + $data = "This should have \"quotes\" in it"; + $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, false); + $this->assertEquals($data, $stripped); + } + + /** + * Test strip slashes from array when magic quotes disabled + */ + public function testStripSlashesFromArrayWithoutMagicQuotes() + { + $data = array("This should have \"quotes\" in it", "And this \"too\" has quotes"); + $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, false); + $this->assertEquals($data, $stripped); + } + + /** + * Test strip slashes when magic quotes enabled + */ + public function testStripSlashesWithMagicQuotes() + { + $data = "This should have \"quotes\" in it"; + $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, true); + $this->assertEquals('This should have "quotes" in it', $stripped); + } + + /** + * Test strip slashes from array when magic quotes enabled + */ + public function testStripSlashesFromArrayWithMagicQuotes() + { + $data = array("This should have \"quotes\" in it", "And this \"too\" has quotes"); + $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, true); + $this->assertEquals($data = array('This should have "quotes" in it', 'And this "too" has quotes'), $stripped); + } + + /** + * Test encrypt and decrypt with valid data + */ + public function testEncryptAndDecryptWithValidData() + { + $data = 'foo'; + $key = 'secret'; + $iv = md5('initializationVector'); + $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv); + $decrypted = \Slim\Http\Util::decrypt($encrypted, $key, $iv); + $this->assertEquals($data, $decrypted); + $this->assertTrue($data !== $encrypted); + } + + /** + * Test encrypt when data is empty string + */ + public function testEncryptWhenDataIsEmptyString() + { + $data = ''; + $key = 'secret'; + $iv = md5('initializationVector'); + $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv); + $this->assertEquals('', $encrypted); + } + + /** + * Test decrypt when data is empty string + */ + public function testDecryptWhenDataIsEmptyString() + { + $data = ''; + $key = 'secret'; + $iv = md5('initializationVector'); + $decrypted = \Slim\Http\Util::decrypt($data, $key, $iv); + $this->assertEquals('', $decrypted); + } + + /** + * Test encrypt when IV and key sizes are too long + */ + public function testEncryptAndDecryptWhenKeyAndIvAreTooLong() + { + $data = 'foo'; + $key = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; + $iv = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; + $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv); + $decrypted = \Slim\Http\Util::decrypt($encrypted, $key, $iv); + $this->assertEquals($data, $decrypted); + $this->assertTrue($data !== $encrypted); + } + + public function testEncodeAndDecodeSecureCookieWithValidData() + { + //Prepare cookie value + $value = 'foo'; + $expires = time() + 86400; + $secret = 'password'; + $algorithm = MCRYPT_RIJNDAEL_256; + $mode = MCRYPT_MODE_CBC; + $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode); + $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode); + + //Test secure cookie value + $parts = explode('|', $encodedValue); + $this->assertEquals(3, count($parts)); + $this->assertEquals($expires, $parts[0]); + $this->assertEquals($value, $decodedValue); + } + + /** + * Test encode/decode secure cookie with old expiration + * + * In this test, the expiration date is purposefully set to a time before now. + * When decoding the encoded cookie value, FALSE is returned since the cookie + * will have expired before it is decoded. + */ + public function testEncodeAndDecodeSecureCookieWithOldExpiration() + { + $value = 'foo'; + $expires = time() - 100; + $secret = 'password'; + $algorithm = MCRYPT_RIJNDAEL_256; + $mode = MCRYPT_MODE_CBC; + $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode); + $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode); + $this->assertFalse($decodedValue); + } + + /** + * Test encode/decode secure cookie with tampered data + * + * In this test, the encoded data is purposefully changed to simulate someone + * tampering with the client-side cookie data. When decoding the encoded cookie value, + * FALSE is returned since the verification key will not match. + */ + public function testEncodeAndDecodeSecureCookieWithTamperedData() + { + $value = 'foo'; + $expires = time() + 86400; + $secret = 'password'; + $algorithm = MCRYPT_RIJNDAEL_256; + $mode = MCRYPT_MODE_CBC; + $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode); + $encodedValueParts = explode('|', $encodedValue); + $encodedValueParts[1] = $encodedValueParts[1] . 'changed'; + $encodedValue = implode('|', $encodedValueParts); + $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode); + $this->assertFalse($decodedValue); + } + + public function testSetCookieHeaderWithNameAndValue() + { + $name = 'foo'; + $value = 'bar'; + $header = array(); + \Slim\Http\Util::setCookieHeader($header, $name, $value); + $this->assertEquals('foo=bar', $header['Set-Cookie']); + } + + public function testSetCookieHeaderWithNameAndValueWhenCookieAlreadySet() + { + $name = 'foo'; + $value = 'bar'; + $header = array('Set-Cookie' => 'one=two'); + \Slim\Http\Util::setCookieHeader($header, $name, $value); + $this->assertEquals("one=two\nfoo=bar", $header['Set-Cookie']); + } + + public function testSetCookieHeaderWithNameAndValueAndDomain() + { + $name = 'foo'; + $value = 'bar'; + $domain = 'foo.com'; + $header = array(); + \Slim\Http\Util::setCookieHeader($header, $name, array( + 'value' => $value, + 'domain' => $domain + )); + $this->assertEquals('foo=bar; domain=foo.com', $header['Set-Cookie']); + } + + public function testSetCookieHeaderWithNameAndValueAndDomainAndPath() + { + $name = 'foo'; + $value = 'bar'; + $domain = 'foo.com'; + $path = '/foo'; + $header = array(); + \Slim\Http\Util::setCookieHeader($header, $name, array( + 'value' => $value, + 'domain' => $domain, + 'path' => $path + )); + $this->assertEquals('foo=bar; domain=foo.com; path=/foo', $header['Set-Cookie']); + } + + public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsString() + { + $name = 'foo'; + $value = 'bar'; + $domain = 'foo.com'; + $path = '/foo'; + $expires = '2 days'; + $expiresFormat = gmdate('D, d-M-Y H:i:s e', strtotime($expires)); + $header = array(); + \Slim\Http\Util::setCookieHeader($header, $name, array( + 'value' => $value, + 'domain' => $domain, + 'path' => '/foo', + 'expires' => $expires + )); + $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat, $header['Set-Cookie']); + } + + public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsInteger() + { + $name = 'foo'; + $value = 'bar'; + $domain = 'foo.com'; + $path = '/foo'; + $expires = strtotime('2 days'); + $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires); + $header = array(); + \Slim\Http\Util::setCookieHeader($header, $name, array( + 'value' => $value, + 'domain' => $domain, + 'path' => '/foo', + 'expires' => $expires + )); + $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat, $header['Set-Cookie']); + } + + public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsZero() + { + $name = 'foo'; + $value = 'bar'; + $domain = 'foo.com'; + $path = '/foo'; + $expires = 0; + $header = array(); + \Slim\Http\Util::setCookieHeader($header, $name, array( + 'value' => $value, + 'domain' => $domain, + 'path' => '/foo', + 'expires' => $expires + )); + $this->assertEquals('foo=bar; domain=foo.com; path=/foo', $header['Set-Cookie']); + } + + public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAndSecure() + { + $name = 'foo'; + $value = 'bar'; + $domain = 'foo.com'; + $path = '/foo'; + $expires = strtotime('2 days'); + $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires); + $secure = true; + $header = array(); + \Slim\Http\Util::setCookieHeader($header, $name, array( + 'value' => $value, + 'domain' => $domain, + 'path' => '/foo', + 'expires' => $expires, + 'secure' => $secure + )); + $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat . '; secure', $header['Set-Cookie']); + } + + public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAndSecureAndHttpOnly() + { + $name = 'foo'; + $value = 'bar'; + $domain = 'foo.com'; + $path = '/foo'; + $expires = strtotime('2 days'); + $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires); + $secure = true; + $httpOnly = true; + $header = array(); + \Slim\Http\Util::setCookieHeader($header, $name, array( + 'value' => $value, + 'domain' => $domain, + 'path' => '/foo', + 'expires' => $expires, + 'secure' => $secure, + 'httponly' => $httpOnly + )); + $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat . '; secure; HttpOnly', $header['Set-Cookie']); + } + + public function testDeleteCookieHeaderWithSurvivingCookie() + { + $header = array('Set-Cookie' => "foo=bar\none=two"); + \Slim\Http\Util::deleteCookieHeader($header, 'foo'); + $this->assertEquals(1, preg_match("@^one=two\nfoo=; expires=@", $header['Set-Cookie'])); + } + + public function testDeleteCookieHeaderWithoutSurvivingCookie() + { + $header = array('Set-Cookie' => "foo=bar"); + \Slim\Http\Util::deleteCookieHeader($header, 'foo'); + $this->assertEquals(1, preg_match("@foo=; expires=@", $header['Set-Cookie'])); + } + + public function testDeleteCookieHeaderWithMatchingDomain() + { + $header = array('Set-Cookie' => "foo=bar; domain=foo.com"); + \Slim\Http\Util::deleteCookieHeader($header, 'foo', array( + 'domain' => 'foo.com' + )); + $this->assertEquals(1, preg_match("@foo=; domain=foo.com; expires=@", $header['Set-Cookie'])); + } + + public function testDeleteCookieHeaderWithoutMatchingDomain() + { + $header = array('Set-Cookie' => "foo=bar; domain=foo.com"); + \Slim\Http\Util::deleteCookieHeader($header, 'foo', array( + 'domain' => 'bar.com' + )); + $this->assertEquals(1, preg_match("@foo=bar; domain=foo\.com\nfoo=; domain=bar\.com@", $header['Set-Cookie'])); + } + + /** + * Test parses Cookie: HTTP header + */ + public function testParsesCookieHeader() + { + $header = 'foo=bar; one=two; colors=blue'; + $result = \Slim\Http\Util::parseCookieHeader($header); + $this->assertEquals(3, count($result)); + $this->assertEquals('bar', $result['foo']); + $this->assertEquals('two', $result['one']); + $this->assertEquals('blue', $result['colors']); + } + + public function testParsesCookieHeaderWithCommaSeparator() + { + $header = 'foo=bar, one=two, colors=blue'; + $result = \Slim\Http\Util::parseCookieHeader($header); + $this->assertEquals(3, count($result)); + $this->assertEquals('bar', $result['foo']); + $this->assertEquals('two', $result['one']); + $this->assertEquals('blue', $result['colors']); + } + + public function testPrefersLeftmostCookieWhenManyCookiesWithSameName() + { + $header = 'foo=bar; foo=beer'; + $result = \Slim\Http\Util::parseCookieHeader($header); + $this->assertEquals('bar', $result['foo']); + } +} diff --git a/vendor/slim/slim/tests/LogTest.php b/vendor/slim/slim/tests/LogTest.php new file mode 100644 index 0000000000..d390e45c4c --- /dev/null +++ b/vendor/slim/slim/tests/LogTest.php @@ -0,0 +1,152 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class MyWriter +{ + public function write( $object, $level ) + { + echo (string) $object; + + return true; + } +} + +class LogTest extends PHPUnit_Framework_TestCase +{ + public function testEnabled() + { + $log = new \Slim\Log(new MyWriter()); + $this->assertTrue($log->isEnabled()); //<-- Default case + $log->setEnabled(true); + $this->assertTrue($log->isEnabled()); + $log->setEnabled(false); + $this->assertFalse($log->isEnabled()); + } + + public function testGetLevel() + { + $log = new \Slim\Log(new MyWriter()); + $this->assertEquals(\Slim\Log::DEBUG, $log->getLevel()); + } + + public function testSetLevel() + { + $log = new \Slim\Log(new MyWriter()); + $log->setLevel(\Slim\Log::WARN); + $this->assertEquals(\Slim\Log::WARN, $log->getLevel()); + } + + public function testSetInvalidLevel() + { + $this->setExpectedException('InvalidArgumentException'); + $log = new \Slim\Log(new MyWriter()); + $log->setLevel(\Slim\Log::DEBUG + 1); + } + + public function testLogDebug() + { + $this->expectOutputString('Debug'); + $log = new \Slim\Log(new MyWriter()); + $result = $log->debug('Debug'); + $this->assertTrue($result); + } + + public function testLogDebugExcludedByLevel() + { + $log = new \Slim\Log(new MyWriter()); + $log->setLevel(\Slim\Log::INFO); + $this->assertFalse($log->debug('Debug')); + } + + public function testLogInfo() + { + $this->expectOutputString('Info'); + $log = new \Slim\Log(new MyWriter()); + $result = $log->info('Info'); + $this->assertTrue($result); + } + + public function testLogInfoExcludedByLevel() + { + $log = new \Slim\Log(new MyWriter()); + $log->setLevel(\Slim\Log::WARN); + $this->assertFalse($log->info('Info')); + } + + public function testLogWarn() + { + $this->expectOutputString('Warn'); + $log = new \Slim\Log(new MyWriter()); + $result = $log->warn('Warn'); + $this->assertTrue($result); + } + + public function testLogWarnExcludedByLevel() + { + $log = new \Slim\Log(new MyWriter()); + $log->setLevel(\Slim\Log::ERROR); + $this->assertFalse($log->warn('Warn')); + } + + public function testLogError() + { + $this->expectOutputString('Error'); + $log = new \Slim\Log(new MyWriter()); + $result = $log->error('Error'); + $this->assertTrue($result); + } + + public function testLogErrorExcludedByLevel() + { + $log = new \Slim\Log(new MyWriter()); + $log->setLevel(\Slim\Log::FATAL); + $this->assertFalse($log->error('Error')); + } + + public function testLogFatal() + { + $this->expectOutputString('Fatal'); + $log = new \Slim\Log(new MyWriter()); + $result = $log->fatal('Fatal'); + $this->assertTrue($result); + } + + public function testGetAndSetWriter() + { + $writer1 = new MyWriter(); + $writer2 = new MyWriter(); + $log = new \Slim\Log($writer1); + $this->assertSame($writer1, $log->getWriter()); + $log->setWriter($writer2); + $this->assertSame($writer2, $log->getWriter()); + } +} diff --git a/vendor/slim/slim/tests/LogWriterTest.php b/vendor/slim/slim/tests/LogWriterTest.php new file mode 100644 index 0000000000..3c30d8039b --- /dev/null +++ b/vendor/slim/slim/tests/LogWriterTest.php @@ -0,0 +1,48 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class LogWriterTest extends PHPUnit_Framework_TestCase +{ + public function testInstantiation() + { + $this->expectOutputString('Hello!' . PHP_EOL); + $handle = fopen('php://output', 'w'); + $fw = new \Slim\LogWriter($handle); + $this->assertTrue($fw->write('Hello!') > 0); //<-- Returns number of bytes written if successful + } + + public function testInstantiationWithNonResource() + { + $this->setExpectedException('InvalidArgumentException'); + $fw = new \Slim\LogWriter(@fopen('/foo/bar.txt', 'w')); + } +} diff --git a/vendor/slim/slim/tests/Middleware/ContentTypesTest.php b/vendor/slim/slim/tests/Middleware/ContentTypesTest.php new file mode 100644 index 0000000000..3857b3428c --- /dev/null +++ b/vendor/slim/slim/tests/Middleware/ContentTypesTest.php @@ -0,0 +1,161 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class ContentTypesTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + ob_start(); + } + + public function tearDown() + { + ob_end_clean(); + } + + /** + * Test parses JSON + */ + public function testParsesJson() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'CONTENT_TYPE' => 'application/json', + 'CONENT_LENGTH' => 13, + 'slim.input' => '{"foo":"bar"}' + )); + $s = new \Slim\Slim(); + $s->add(new \Slim\Middleware\ContentTypes()); + $s->run(); + $body = $s->request()->getBody(); + $this->assertTrue(is_array($body)); + $this->assertEquals('bar', $body['foo']); + } + + /** + * Test ignores JSON with errors + */ + public function testParsesJsonWithError() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'CONTENT_TYPE' => 'application/json', + 'CONENT_LENGTH' => 12, + 'slim.input' => '{"foo":"bar"' //<-- This should be incorrect! + )); + $s = new \Slim\Slim(); + $s->add(new \Slim\Middleware\ContentTypes()); + $s->run(); + $body = $s->request()->getBody(); + $this->assertTrue(is_string($body)); + $this->assertEquals('{"foo":"bar"', $body); + } + + /** + * Test parses XML + */ + public function testParsesXml() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'CONTENT_TYPE' => 'application/xml', + 'CONENT_LENGTH' => 68, + 'slim.input' => '1Clive Cussler' + )); + $s = new \Slim\Slim(); + $s->add(new \Slim\Middleware\ContentTypes()); + $s->run(); + $body = $s->request()->getBody(); + $this->assertInstanceOf('SimpleXMLElement', $body); + $this->assertEquals('Clive Cussler', (string) $body->book->author); + } + + /** + * Test ignores XML with errors + */ + public function testParsesXmlWithError() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'CONTENT_TYPE' => 'application/xml', + 'CONENT_LENGTH' => 68, + 'slim.input' => '1Clive Cussler' //<-- This should be incorrect! + )); + $s = new \Slim\Slim(); + $s->add(new \Slim\Middleware\ContentTypes()); + $s->run(); + $body = $s->request()->getBody(); + $this->assertTrue(is_string($body)); + $this->assertEquals('1Clive Cussler', $body); + } + + /** + * Test parses CSV + */ + public function testParsesCsv() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'CONTENT_TYPE' => 'text/csv', + 'CONENT_LENGTH' => 44, + 'slim.input' => "John,Doe,000-111-2222\nJane,Doe,111-222-3333" + )); + $s = new \Slim\Slim(); + $s->add(new \Slim\Middleware\ContentTypes()); + $s->run(); + $body = $s->request()->getBody(); + $this->assertTrue(is_array($body)); + $this->assertEquals(2, count($body)); + $this->assertEquals('000-111-2222', $body[0][2]); + $this->assertEquals('Doe', $body[1][1]); + } + + /** + * Test parses request body based on media-type only, disregarding + * any extra content-type header parameters + */ + public function testParsesRequestBodyWithMediaType() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4', + 'CONENT_LENGTH' => 13, + 'slim.input' => '{"foo":"bar"}' + )); + $s = new \Slim\Slim(); + $s->add(new \Slim\Middleware\ContentTypes()); + $s->run(); + $body = $s->request()->getBody(); + $this->assertTrue(is_array($body)); + $this->assertEquals('bar', $body['foo']); + } +} diff --git a/vendor/slim/slim/tests/Middleware/FlashTest.php b/vendor/slim/slim/tests/Middleware/FlashTest.php new file mode 100644 index 0000000000..09da70a8a9 --- /dev/null +++ b/vendor/slim/slim/tests/Middleware/FlashTest.php @@ -0,0 +1,128 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class SlimFlashTest extends PHPUnit_Framework_TestCase +{ + /** + * Setup + */ + public function setUp() + { + $_SESSION = array(); + } + + /** + * Test set flash message for next request + */ + public function testSetFlashForNextRequest() + { + $f = new \Slim\Middleware\Flash(); + $f->set('foo', 'bar'); + $f->save(); + $this->assertEquals('bar', $_SESSION['slim.flash']['foo']); + } + + /** + * Test set flash message for current request + */ + public function testSetFlashForCurrentRequest() + { + $f = new \Slim\Middleware\Flash(); + $f->now('foo', 'bar'); + $this->assertEquals('bar', $f['foo']); + } + + /** + * Test loads flash from previous request + */ + public function testLoadsFlashFromPreviousRequest() + { + $_SESSION['slim.flash'] = array('info' => 'foo'); + $f = new \Slim\Middleware\Flash(); + $f->loadMessages(); + $this->assertEquals('foo', $f['info']); + } + + /** + * Test keep flash message for next request + */ + public function testKeepFlashFromPreviousRequest() + { + $_SESSION['slim.flash'] = array('info' => 'foo'); + $f = new \Slim\Middleware\Flash(); + $f->loadMessages(); + $f->keep(); + $f->save(); + $this->assertEquals('foo', $_SESSION['slim.flash']['info']); + } + + /** + * Test flash messages from preivous request do not persist to next request + */ + public function testFlashMessagesFromPreviousRequestDoNotPersist() + { + $_SESSION['slim.flash'] = array('info' => 'foo'); + $f = new \Slim\Middleware\Flash(); + $f->save(); + $this->assertEmpty($_SESSION['slim.flash']); + } + + /** + * Test set Flash using array access + */ + public function testFlashArrayAccess() + { + $_SESSION['slim.flash'] = array('info' => 'foo'); + $f = new \Slim\Middleware\Flash(); + $f['info'] = 'bar'; + $f->save(); + $this->assertTrue(isset($f['info'])); + $this->assertEquals('bar', $f['info']); + unset($f['info']); + $this->assertFalse(isset($f['info'])); + } + + /** + * Test iteration + */ + public function testIteration() + { + $_SESSION['slim.flash'] = array('info' => 'foo', 'error' => 'bar'); + $f = new \Slim\Middleware\Flash(); + $f->loadMessages(); + $output = ''; + foreach ($f as $key => $value) { + $output .= $key . $value; + } + $this->assertEquals('infofooerrorbar', $output); + } +} diff --git a/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php b/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php new file mode 100644 index 0000000000..55484883cd --- /dev/null +++ b/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php @@ -0,0 +1,149 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * We use a mock application, instead of a Slim application. + * so that we may easily test the Method Override middleware + * in isolation. + */ +class CustomAppMethod +{ + protected $environment; + + public function __construct() + { + $this->environment = \Slim\Environment::getInstance(); + } + + public function &environment() { + return $this->environment; + } + + public function call() + { + //Do nothing + } +} + +class MethodOverrideTest extends PHPUnit_Framework_TestCase +{ + /** + * Test overrides method as POST + */ + public function testOverrideMethodAsPost() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONENT_LENGTH' => 11, + 'slim.input' => '_METHOD=PUT' + )); + $app = new CustomAppMethod(); + $mw = new \Slim\Middleware\MethodOverride(); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $env =& $app->environment(); + $this->assertEquals('PUT', $env['REQUEST_METHOD']); + $this->assertTrue(isset($env['slim.method_override.original_method'])); + $this->assertEquals('POST', $env['slim.method_override.original_method']); + } + + /** + * Test does not override method if not POST + */ + public function testDoesNotOverrideMethodIfNotPost() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'slim.input' => '' + )); + $app = new CustomAppMethod(); + $mw = new \Slim\Middleware\MethodOverride(); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $env =& $app->environment(); + $this->assertEquals('GET', $env['REQUEST_METHOD']); + $this->assertFalse(isset($env['slim.method_override.original_method'])); + } + + /** + * Test does not override method if no method ovveride parameter + */ + public function testDoesNotOverrideMethodAsPostWithoutParameter() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '/foo/index.php', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'QUERY_STRING' => 'foo=bar', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w') + )); + $app = new CustomAppMethod(); + $mw = new \Slim\Middleware\MethodOverride(); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $env =& $app->environment(); + $this->assertEquals('POST', $env['REQUEST_METHOD']); + $this->assertFalse(isset($env['slim.method_override.original_method'])); + } + + /** + * Test overrides method with X-Http-Method-Override header + */ + public function testOverrideMethodAsHeader() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'CONTENT_TYPE' => 'application/json', + 'CONENT_LENGTH' => 0, + 'slim.input' => '', + 'X_HTTP_METHOD_OVERRIDE' => 'DELETE' + )); + $app = new CustomAppMethod(); + $mw = new \Slim\Middleware\MethodOverride(); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $env =& $app->environment(); + $this->assertEquals('DELETE', $env['REQUEST_METHOD']); + $this->assertTrue(isset($env['slim.method_override.original_method'])); + $this->assertEquals('POST', $env['slim.method_override.original_method']); + } +} diff --git a/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php b/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php new file mode 100644 index 0000000000..4f41b2d523 --- /dev/null +++ b/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php @@ -0,0 +1,125 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class PrettyExceptionsTest extends PHPUnit_Framework_TestCase +{ + /** + * Test middleware returns successful response unchanged + */ + public function testReturnsUnchangedSuccessResponse() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/foo' + )); + $app = new \Slim\Slim(); + $app->get('/foo', function () { + echo "Success"; + }); + $mw = new \Slim\Middleware\PrettyExceptions(); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $this->assertEquals(200, $app->response()->status()); + $this->assertEquals('Success', $app->response()->body()); + } + + /** + * Test middleware returns diagnostic screen for error response + */ + public function testReturnsDiagnosticsForErrorResponse() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/foo' + )); + $app = new \Slim\Slim(array( + 'log.enabled' => false + )); + $app->get('/foo', function () { + throw new \Exception('Test Message', 100); + }); + $mw = new \Slim\Middleware\PrettyExceptions(); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $this->assertEquals(1, preg_match('@Slim Application Error@', $app->response()->body())); + $this->assertEquals(500, $app->response()->status()); + } + + /** + * Test middleware overrides response content type to html + */ + public function testResponseContentTypeIsOverriddenToHtml() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/foo' + )); + $app = new \Slim\Slim(array( + 'log.enabled' => false + )); + $app->get('/foo', function () use ($app) { + $app->contentType('application/json;charset=utf-8'); //<-- set content type to something else + throw new \Exception('Test Message', 100); + }); + $mw = new \Slim\Middleware\PrettyExceptions(); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $response = $app->response(); + $this->assertEquals('text/html', $response['Content-Type']); + } + + /** + * Test exception type is in response body + */ + public function testExceptionTypeIsInResponseBody() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/foo' + )); + $app = new \Slim\Slim(array( + 'log.enabled' => false + )); + $app->get('/foo', function () use ($app) { + throw new \LogicException('Test Message', 100); + }); + $mw = new \Slim\Middleware\PrettyExceptions(); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + + $this->assertContains('LogicException', $app->response()->body()); + } +} diff --git a/vendor/slim/slim/tests/Middleware/SessionCookieTest.php b/vendor/slim/slim/tests/Middleware/SessionCookieTest.php new file mode 100644 index 0000000000..8ef12ef0cb --- /dev/null +++ b/vendor/slim/slim/tests/Middleware/SessionCookieTest.php @@ -0,0 +1,115 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class SessionCookieTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + if ( session_id() !== '' ) { + session_unset(); + session_destroy(); + } + $_SESSION = array(); + } + + /** + * Test session cookie is set and constructed correctly + * + * We test for two things: + * 1) That the HTTP cookie is added to the `Set-Cookie:` response header; + * 2) That the HTTP cookie is constructed in the expected format; + */ + public function testSessionCookieIsCreatedAndEncrypted() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/foo' + )); + $app = new \Slim\Slim(); + $app->get('/foo', function () { + echo "Success"; + }); + $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + list($status, $header, $body) = $app->response()->finalize(); + $matches = array(); + preg_match_all('@^slim_session=.+|.+|.+; expires=@', $header['Set-Cookie'], $matches, PREG_SET_ORDER); + $this->assertEquals(1, count($matches)); + } + + /** + * Test $_SESSION is populated from HTTP cookie + * + * The HTTP cookie in this test was created using the previous test; the encrypted cookie contains + * the serialized array ['foo' => 'bar']. The middleware secret, cipher, and cipher mode are assumed + * to be the default values. + */ + public function testSessionIsPopulatedFromCookie() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/foo', + 'COOKIE' => 'slim_session=1644004961%7CLKkYPwqKIMvBK7MWl6D%2BxeuhLuMaW4quN%2F512ZAaVIY%3D%7Ce0f007fa852c7101e8224bb529e26be4d0dfbd63', + )); + $app = new \Slim\Slim(); + $app->get('/foo', function () { + echo "Success"; + }); + $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $this->assertEquals(array('foo' => 'bar'), $_SESSION); + } + + /** + * Test $_SESSION is populated as empty array if no HTTP cookie + */ + public function testSessionIsPopulatedAsEmptyIfNoCookie() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/foo' + )); + $app = new \Slim\Slim(); + $app->get('/foo', function () { + echo "Success"; + }); + $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); + $mw->setApplication($app); + $mw->setNextMiddleware($app); + $mw->call(); + $this->assertEquals(array(), $_SESSION); + } +} diff --git a/vendor/slim/slim/tests/MiddlewareTest.php b/vendor/slim/slim/tests/MiddlewareTest.php new file mode 100644 index 0000000000..db78918c37 --- /dev/null +++ b/vendor/slim/slim/tests/MiddlewareTest.php @@ -0,0 +1,86 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class My_Middleware extends \Slim\Middleware +{ + public function call() + { + echo "Before"; + $this->next->call(); + echo "After"; + } +} + +class My_Application +{ + public function call() + { + echo "Application"; + } +} + +class MiddlewareTest extends PHPUnit_Framework_TestCase +{ + /** + * Get and set application + */ + public function testGetAndSetApplication() + { + $app = new My_Application(); + $mw = new My_Middleware(); + $mw->setApplication($app); + $this->assertSame($app, $mw->getApplication()); + } + + /** + * Get and set next middleware + */ + public function testGetAndSetNextMiddleware() + { + $mw1 = new My_Middleware(); + $mw2 = new My_Middleware(); + $mw1->setNextMiddleware($mw2); + $this->assertSame($mw2, $mw1->getNextMiddleware()); + } + + /** + * Test call + */ + public function testCall() + { + $this->expectOutputString('BeforeApplicationAfter'); + $app = new My_Application(); + $mw = new My_Middleware(); + $mw->setNextMiddleware($app); + $mw->call(); + } +} diff --git a/vendor/slim/slim/tests/README b/vendor/slim/slim/tests/README new file mode 100644 index 0000000000..7bc611c317 --- /dev/null +++ b/vendor/slim/slim/tests/README @@ -0,0 +1,18 @@ +Slim Framework Unit Tests + +Follow the directions below to run the Slim Framework unit tests. You'll need the latest version of PHPUnit. To save development time, these unit tests require PHP >= 5.3. However, the Slim Framework itself requires only PHP >= 5.2. + +1. Install the latest version of PHPUnit +Visit http://www.phpunit.de/ for installation instructions. + +2. Run PHPUnit +From the filesystem directory that contains the `tests` directory, you may run all unit tests or specific unit tests. Here are several examples. The '$>' in the examples below is your command prompt. + +To run all tests: +$> phpunit tests + +To run all HTTP-related tests: +$> phpunit tests/Http + +To run only the HTTP Request tests: +$> phpunit tests/Http/RequestTest \ No newline at end of file diff --git a/vendor/slim/slim/tests/RouteTest.php b/vendor/slim/slim/tests/RouteTest.php new file mode 100644 index 0000000000..decec7d4fc --- /dev/null +++ b/vendor/slim/slim/tests/RouteTest.php @@ -0,0 +1,559 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +// Used for passing callable via string +function testCallable() {} + +class RouteTest extends PHPUnit_Framework_TestCase +{ + /** + * Route should set name + */ + public function testRouteSetsName() + { + $route = new \Slim\Route('/foo/bar', function () {}); + $route->name('foo'); + $this->assertEquals('foo', $route->getName()); + } + + /** + * Route should set pattern + */ + public function testRouteSetsPattern() + { + $route1 = new \Slim\Route('/foo/bar', function () {}); + $this->assertEquals('/foo/bar', $route1->getPattern()); + } + + /** + * Route sets pattern with params + */ + public function testRouteSetsPatternWithParams() + { + $route = new \Slim\Route('/hello/:first/:last', function () {}); + $this->assertEquals('/hello/:first/:last', $route->getPattern()); + } + + /** + * Route sets custom pattern that overrides pattern + */ + public function testRouteSetsCustomTemplate() + { + $route = new \Slim\Route('/hello/*', function () {}); + $route->setPattern('/hello/:name'); + $this->assertEquals('/hello/:name', $route->getPattern()); + } + + /** + * Route should store a reference to the callable + * anonymous function. + */ + public function testRouteSetsCallableAsFunction() + { + $callable = function () { echo "Foo!"; }; + $route = new \Slim\Route('/foo/bar', $callable); + $this->assertSame($callable, $route->getCallable()); + } + + /** + * Route should store a reference to the callable + * regular function (for PHP 5 < 5.3) + */ + public function testRouteSetsCallableAsString() + { + $route = new \Slim\Route('/foo/bar', 'testCallable'); + $this->assertEquals('testCallable', $route->getCallable()); + } + + /** + * Route should throw exception when creating with an invalid callable + */ + public function testRouteThrowsExecptionWithInvalidCallable() + { + $this->setExpectedException('InvalidArgumentException'); + $route = new \Slim\Route('/foo/bar', 'fnDoesNotExist'); + } + + /** + * Route should throw exception when setting an invalid callable + */ + public function testRouteThrowsExecptionWhenSettingInvalidCallable() + { + $route = new \Slim\Route('/foo/bar', function () {}); + try + { + $route->setCallable('fnDoesNotExist'); + $this->fail('Did not catch InvalidArgumentException when setting invalid callable'); + } catch(\InvalidArgumentException $e) {} + } + + /** + * Test gets all params + */ + public function testGetRouteParams() + { + // Prepare route + $requestUri = '/hello/mr/anderson'; + $route = new \Slim\Route('/hello/:first/:last', function () {}); + + // Parse route params + $this->assertTrue($route->matches($requestUri)); + + // Get params + $params = $route->getParams(); + $this->assertEquals(2, count($params)); + $this->assertEquals('mr', $params['first']); + $this->assertEquals('anderson', $params['last']); + } + + /** + * Test sets all params + */ + public function testSetRouteParams() + { + // Prepare route + $requestUri = '/hello/mr/anderson'; + $route = new \Slim\Route('/hello/:first/:last', function () {}); + + // Parse route params + $this->assertTrue($route->matches($requestUri)); + + // Get params + $params = $route->getParams(); + $this->assertEquals(2, count($params)); + $this->assertEquals('mr', $params['first']); + $this->assertEquals('anderson', $params['last']); + + // Replace params + $route->setParams(array( + 'first' => 'john', + 'last' => 'smith' + )); + + // Get new params + $params = $route->getParams(); + $this->assertEquals(2, count($params)); + $this->assertEquals('john', $params['first']); + $this->assertEquals('smith', $params['last']); + } + + /** + * Test gets param when exists + */ + public function testGetRouteParamWhenExists() + { + // Prepare route + $requestUri = '/hello/mr/anderson'; + $route = new \Slim\Route('/hello/:first/:last', function () {}); + + // Parse route params + $this->assertTrue($route->matches($requestUri)); + + // Get param + $this->assertEquals('anderson', $route->getParam('last')); + } + + /** + * Test gets param when not exists + */ + public function testGetRouteParamWhenNotExists() + { + // Prepare route + $requestUri = '/hello/mr/anderson'; + $route = new \Slim\Route('/hello/:first/:last', function () {}); + + // Parse route params + $this->assertTrue($route->matches($requestUri)); + + // Get param + try { + $param = $route->getParam('foo'); + $this->fail('Did not catch expected InvalidArgumentException'); + } catch ( \InvalidArgumentException $e ) {} + } + + /** + * Test sets param when exists + */ + public function testSetRouteParamWhenExists() + { + // Prepare route + $requestUri = '/hello/mr/anderson'; + $route = new \Slim\Route('/hello/:first/:last', function () {}); + + // Parse route params + $this->assertTrue($route->matches($requestUri)); + + // Get param + $this->assertEquals('anderson', $route->getParam('last')); + + // Set param + $route->setParam('last', 'smith'); + + // Get new param + $this->assertEquals('smith', $route->getParam('last')); + } + + /** + * Test sets param when not exists + */ + public function testSetRouteParamWhenNotExists() + { + // Prepare route + $requestUri = '/hello/mr/anderson'; + $route = new \Slim\Route('/hello/:first/:last', function () {}); + + // Parse route params + $this->assertTrue($route->matches($requestUri)); + + // Get param + try { + $param = $route->setParam('foo', 'bar'); + $this->fail('Did not catch expected InvalidArgumentException'); + } catch ( \InvalidArgumentException $e ) {} + } + + /** + * If route matches a resource URI, param should be extracted. + */ + public function testRouteMatchesAndParamExtracted() + { + $resource = '/hello/Josh'; + $route = new \Slim\Route('/hello/:name', function () {}); + $result = $route->matches($resource); + $this->assertTrue($result); + $this->assertEquals(array('name' => 'Josh'), $route->getParams()); + } + + /** + * If route matches a resource URI, multiple params should be extracted. + */ + public function testRouteMatchesAndMultipleParamsExtracted() + { + $resource = '/hello/Josh/and/John'; + $route = new \Slim\Route('/hello/:first/and/:second', function () {}); + $result = $route->matches($resource); + $this->assertTrue($result); + $this->assertEquals(array('first' => 'Josh', 'second' => 'John'), $route->getParams()); + } + + /** + * If route does not match a resource URI, params remain an empty array + */ + public function testRouteDoesNotMatchAndParamsNotExtracted() + { + $resource = '/foo/bar'; + $route = new \Slim\Route('/hello/:name', function () {}); + $result = $route->matches($resource); + $this->assertFalse($result); + $this->assertEquals(array(), $route->getParams()); + } + + /** + * Route matches URI with trailing slash + * + */ + public function testRouteMatchesWithTrailingSlash() + { + $resource1 = '/foo/bar/'; + $resource2 = '/foo/bar'; + $route = new \Slim\Route('/foo/:one/', function () {}); + $this->assertTrue($route->matches($resource1)); + $this->assertTrue($route->matches($resource2)); + } + + /** + * Route matches URI with conditions + */ + public function testRouteMatchesResourceWithConditions() + { + $resource = '/hello/Josh/and/John'; + $route = new \Slim\Route('/hello/:first/and/:second', function () {}); + $route->conditions(array('first' => '[a-zA-Z]{3,}')); + $result = $route->matches($resource); + $this->assertTrue($result); + $this->assertEquals(array('first' => 'Josh', 'second' => 'John'), $route->getParams()); + } + + /** + * Route does not match URI with conditions + */ + public function testRouteDoesNotMatchResourceWithConditions() + { + $resource = '/hello/Josh/and/John'; + $route = new \Slim\Route('/hello/:first/and/:second', function () {}); + $route->conditions(array('first' => '[a-z]{3,}')); + $result = $route->matches($resource); + $this->assertFalse($result); + $this->assertEquals(array(), $route->getParams()); + } + + /* + * Route should match URI with valid path component according to rfc2396 + * + * "Uniform Resource Identifiers (URI): Generic Syntax" http://www.ietf.org/rfc/rfc2396.txt + * + * Excludes "+" which is valid but decodes into a space character + */ + public function testRouteMatchesResourceWithValidRfc2396PathComponent() + { + $symbols = ':@&=$,'; + $resource = '/rfc2386/' . $symbols; + $route = new \Slim\Route('/rfc2386/:symbols', function () {}); + $result = $route->matches($resource); + $this->assertTrue($result); + $this->assertEquals(array('symbols' => $symbols), $route->getParams()); + } + + /* + * Route should match URI including unreserved punctuation marks from rfc2396 + * + * "Uniform Resource Identifiers (URI): Generic Syntax" http://www.ietf.org/rfc/rfc2396.txt + */ + public function testRouteMatchesResourceWithUnreservedMarks() + { + $marks = "-_.!~*'()"; + $resource = '/marks/' . $marks; + $route = new \Slim\Route('/marks/:marks', function () {}); + $result = $route->matches($resource); + $this->assertTrue($result); + $this->assertEquals(array('marks' => $marks), $route->getParams()); + } + + /** + * Route optional parameters + * + * Pre-conditions: + * Route pattern requires :year, optionally accepts :month and :day + * + * Post-conditions: + * All: Year is 2010 + * Case A: Month and day default values are used + * Case B: Month is "05" and day default value is used + * Case C: Month is "05" and day is "13" + */ + public function testRouteOptionalParameters() + { + $pattern = '/archive/:year(/:month(/:day))'; + + //Case A + $routeA = new \Slim\Route($pattern, function () {}); + $resourceA = '/archive/2010'; + $resultA = $routeA->matches($resourceA); + $this->assertTrue($resultA); + $this->assertEquals(array('year' => '2010'), $routeA->getParams()); + + //Case B + $routeB = new \Slim\Route($pattern, function () {}); + $resourceB = '/archive/2010/05'; + $resultB = $routeB->matches($resourceB); + $this->assertTrue($resultB); + $this->assertEquals(array('year' => '2010', 'month' => '05'), $routeB->getParams()); + + //Case C + $routeC = new \Slim\Route($pattern, function () {}); + $resourceC = '/archive/2010/05/13'; + $resultC = $routeC->matches($resourceC); + $this->assertTrue($resultC); + $this->assertEquals(array('year' => '2010', 'month' => '05', 'day' => '13'), $routeC->getParams()); + } + + /** + * Test route default conditions + * + * Pre-conditions: + * Route class has default conditions; + * + * Post-conditions: + * Case A: Route instance has default conditions; + * Case B: Route instance has newly merged conditions; + */ + public function testRouteDefaultConditions() + { + \Slim\Route::setDefaultConditions(array('id' => '\d+')); + $r = new \Slim\Route('/foo', function () {}); + //Case A + $this->assertEquals(\Slim\Route::getDefaultConditions(), $r->getConditions()); + //Case B + $r->conditions(array('name' => '[a-z]{2,5}')); + $c = $r->getConditions(); + $this->assertArrayHasKey('id', $c); + $this->assertArrayHasKey('name', $c); + } + + /** + * Route matches URI with wildcard + */ + public function testRouteMatchesResourceWithWildcard() + { + $resource = '/hello/foo/bar/world'; + $route = new \Slim\Route('/hello/:path+/world', function () {}); + $result = $route->matches($resource); + $this->assertTrue($result); + $this->assertEquals(array('path'=>array('foo', 'bar')), $route->getParams()); + } + + /** + * Route matches URI with more than one wildcard + */ + public function testRouteMatchesResourceWithMultipleWildcards() + { + $resource = '/hello/foo/bar/world/2012/03/10'; + $route = new \Slim\Route('/hello/:path+/world/:date+', function () {}); + $result = $route->matches($resource); + $this->assertTrue($result); + $this->assertEquals(array('path'=>array('foo', 'bar'), 'date'=>array('2012', '03', '10')), $route->getParams()); + } + + /** + * Route matches URI with wildcards and parameters + */ + public function testRouteMatchesResourceWithWildcardsAndParams() + { + $resource = '/hello/foo/bar/world/2012/03/10/first/second'; + $route = new \Slim\Route('/hello/:path+/world/:year/:month/:day/:path2+', function () {}); + $result = $route->matches($resource); + $this->assertTrue($result); + $this->assertEquals(array('path'=>array('foo', 'bar'), 'year'=>'2012', 'month'=>'03', 'day'=>'10', 'path2'=>array('first', 'second')), $route->getParams()); + } + + /** + * Route matches URI with optional wildcard and parameter + */ + public function testRouteMatchesResourceWithOptionalWildcardsAndParams() + { + $resourceA = '/hello/world/foo/bar'; + $routeA = new \Slim\Route('/hello(/:world(/:path+))', function () {}); + $this->assertTrue($routeA->matches($resourceA)); + $this->assertEquals(array('world'=>'world', 'path'=>array('foo', 'bar')), $routeA->getParams()); + + $resourceB = '/hello/world'; + $routeB = new \Slim\Route('/hello(/:world(/:path))', function () {}); + $this->assertTrue($routeB->matches($resourceB)); + $this->assertEquals(array('world'=>'world'), $routeB->getParams()); + } + + /** + * Route does not match URI with wildcard + */ + public function testRouteDoesNotMatchResourceWithWildcard() + { + $resource = '/hello'; + $route = new \Slim\Route('/hello/:path+', function () {}); + $result = $route->matches($resource); + $this->assertFalse($result); + $this->assertEquals(array(), $route->getParams()); + } + + /** + * Test route sets and gets middleware + * + * Pre-conditions: + * Route instantiated + * + * Post-conditions: + * Case A: Middleware set as callable, not array + * Case B: Middleware set after other middleware already set + * Case C: Middleware set as array of callables + * Case D: Middleware set as a callable array + * Case E: Middleware is invalid; throws InvalidArgumentException + * Case F: Middleware is an array with one invalid callable; throws InvalidArgumentException + */ + public function testRouteMiddleware() + { + $callable1 = function () {}; + $callable2 = function () {}; + //Case A + $r1 = new \Slim\Route('/foo', function () {}); + $r1->setMiddleware($callable1); + $mw = $r1->getMiddleware(); + $this->assertInternalType('array', $mw); + $this->assertEquals(1, count($mw)); + //Case B + $r1->setMiddleware($callable2); + $mw = $r1->getMiddleware(); + $this->assertEquals(2, count($mw)); + //Case C + $r2 = new \Slim\Route('/foo', function () {}); + $r2->setMiddleware(array($callable1, $callable2)); + $mw = $r2->getMiddleware(); + $this->assertInternalType('array', $mw); + $this->assertEquals(2, count($mw)); + //Case D + $r3 = new \Slim\Route('/foo', function () {}); + $r3->setMiddleware(array($this, 'callableTestFunction')); + $mw = $r3->getMiddleware(); + $this->assertInternalType('array', $mw); + $this->assertEquals(1, count($mw)); + //Case E + try { + $r3->setMiddleware('sdjfsoi788'); + $this->fail('Did not catch InvalidArgumentException when setting invalid route middleware'); + } catch ( \InvalidArgumentException $e ) {} + //Case F + try { + $r3->setMiddleware(array($callable1, $callable2, 'sdjfsoi788')); + $this->fail('Did not catch InvalidArgumentException when setting an array with one invalid route middleware'); + } catch ( \InvalidArgumentException $e ) {} + } + + public function callableTestFunction() {} + + /** + * Test that a Route manages the HTTP methods that it supports + * + * Case A: Route initially supports no HTTP methods + * Case B: Route can set its supported HTTP methods + * Case C: Route can append supported HTTP methods + * Case D: Route can test if it supports an HTTP method + * Case E: Route can lazily declare supported HTTP methods with `via` + */ + public function testHttpMethods() + { + //Case A + $r = new \Slim\Route('/foo', function () {}); + $this->assertEmpty($r->getHttpMethods()); + //Case B + $r->setHttpMethods('GET'); + $this->assertEquals(array('GET'), $r->getHttpMethods()); + //Case C + $r->appendHttpMethods('POST', 'PUT'); + $this->assertEquals(array('GET', 'POST', 'PUT'), $r->getHttpMethods()); + //Case D + $this->assertTrue($r->supportsHttpMethod('GET')); + $this->assertFalse($r->supportsHttpMethod('DELETE')); + //Case E + $viaResult = $r->via('DELETE'); + $this->assertTrue($viaResult instanceof \Slim\Route); + $this->assertTrue($r->supportsHttpMethod('DELETE')); + } +} diff --git a/vendor/slim/slim/tests/RouterTest.php b/vendor/slim/slim/tests/RouterTest.php new file mode 100644 index 0000000000..cb5cc33f11 --- /dev/null +++ b/vendor/slim/slim/tests/RouterTest.php @@ -0,0 +1,602 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class RouterTest extends PHPUnit_Framework_TestCase +{ + protected $env; + protected $req; + protected $res; + + public function setUp() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $this->env = \Slim\Environment::getInstance(); + $this->req = new \Slim\Http\Request($this->env); + $this->res = new \Slim\Http\Response(); + } + + /** + * Router::urlFor should return a full route pattern + * even if no params data is provided. + */ + public function testUrlForNamedRouteWithoutParams() + { + $router = new \Slim\Router(); + $route = $router->map('/foo/bar', function () {})->via('GET'); + $router->addNamedRoute('foo', $route); + $this->assertEquals('/foo/bar', $router->urlFor('foo')); + } + + /** + * Router::urlFor should return a full route pattern if + * param data is provided. + */ + public function testUrlForNamedRouteWithParams() + { + $router = new \Slim\Router(); + $route = $router->map('/foo/:one/and/:two', function ($one, $two) {})->via('GET'); + $router->addNamedRoute('foo', $route); + $this->assertEquals('/foo/Josh/and/John', $router->urlFor('foo', array('one' => 'Josh', 'two' => 'John'))); + } + + /** + * Router::urlFor should throw an exception if Route with name + * does not exist. + * @expectedException \RuntimeException + */ + public function testUrlForNamedRouteThatDoesNotExist() + { + $router = new \Slim\Router(); + $route = $router->map('/foo/bar', function () {})->via('GET'); + $router->addNamedRoute('bar', $route); + $router->urlFor('foo'); + } + + /** + * Router::addNamedRoute should throw an exception if named Route + * with same name already exists. + */ + public function testNamedRouteWithExistingName() + { + $this->setExpectedException('\RuntimeException'); + $router = new \Slim\Router(); + $route1 = $router->map('/foo/bar', function () {})->via('GET'); + $route2 = $router->map('/foo/bar/2', function () {})->via('GET'); + $router->addNamedRoute('bar', $route1); + $router->addNamedRoute('bar', $route2); + } + + /** + * Test if named route exists + * + * Pre-conditions: + * Slim app instantiated; + * Named route created; + * + * Post-conditions: + * Named route found to exist; + * Non-existant route found not to exist; + */ + public function testHasNamedRoute() + { + $router = new \Slim\Router(); + $route = $router->map('/foo', function () {})->via('GET'); + $router->addNamedRoute('foo', $route); + $this->assertTrue($router->hasNamedRoute('foo')); + $this->assertFalse($router->hasNamedRoute('bar')); + } + + /** + * Test Router gets named route + * + * Pre-conditions; + * Slim app instantiated; + * Named route created; + * + * Post-conditions: + * Named route fetched by named; + * NULL is returned if named route does not exist; + */ + public function testGetNamedRoute() + { + $router = new \Slim\Router(); + $route1 = $router->map('/foo', function () {})->via('GET'); + $router->addNamedRoute('foo', $route1); + $this->assertSame($route1, $router->getNamedRoute('foo')); + $this->assertNull($router->getNamedRoute('bar')); + } + + /** + * Test external iterator for Router's named routes + * + * Pre-conditions: + * Slim app instantiated; + * Named routes created; + * + * Post-conditions: + * Array iterator returned for named routes; + */ + public function testGetNamedRoutes() + { + $router = new \Slim\Router(); + $route1 = $router->map('/foo', function () {})->via('GET'); + $route2 = $router->map('/bar', function () {})->via('POST'); + $router->addNamedRoute('foo', $route1); + $router->addNamedRoute('bar', $route2); + $namedRoutesIterator = $router->getNamedRoutes(); + $this->assertInstanceOf('ArrayIterator', $namedRoutesIterator); + $this->assertEquals(2, $namedRoutesIterator->count()); + } + + /** + * Router considers HEAD requests as GET requests + */ + public function testRouterConsidersHeadAsGet() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'HEAD', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $this->env = \Slim\Environment::getInstance(); + $this->req = new \Slim\Http\Request($this->env); + $this->res = new \Slim\Http\Response(); + $router = new \Slim\Router(); + $route = $router->map('/bar', function () {})->via('GET', 'HEAD'); + $numberOfMatchingRoutes = count($router->getMatchedRoutes($this->req->getMethod(), $this->req->getResourceUri())); + $this->assertEquals(1, $numberOfMatchingRoutes); + } + + /** + * Router::urlFor + */ + public function testRouterUrlFor() + { + $router = new \Slim\Router(); + $route1 = $router->map('/foo/bar', function () {})->via('GET'); + $route2 = $router->map('/foo/:one/:two', function () {})->via('GET'); + $route3 = $router->map('/foo/:one(/:two)', function () {})->via('GET'); + $route4 = $router->map('/foo/:one/(:two/)', function () {})->via('GET'); + $route5 = $router->map('/foo/:one/(:two/(:three/))', function () {})->via('GET'); + $route6 = $router->map('/foo/:path+/bar', function (){})->via('GET'); + $route7 = $router->map('/foo/:path+/:path2+/bar', function (){})->via('GET'); + $route8 = $router->map('/foo/:path+', function (){})->via('GET'); + $route9 = $router->map('/foo/:var/:var2', function (){})->via('GET'); + $route1->setName('route1'); + $route2->setName('route2'); + $route3->setName('route3'); + $route4->setName('route4'); + $route5->setName('route5'); + $route6->setName('route6'); + $route7->setName('route7'); + $route8->setName('route8'); + $route9->setName('route9'); + //Route + $this->assertEquals('/foo/bar', $router->urlFor('route1')); + //Route with params + $this->assertEquals('/foo/foo/bar', $router->urlFor('route2', array('one' => 'foo', 'two' => 'bar'))); + $this->assertEquals('/foo/foo/:two', $router->urlFor('route2', array('one' => 'foo'))); + $this->assertEquals('/foo/:one/bar', $router->urlFor('route2', array('two' => 'bar'))); + //Route with params and optional segments + $this->assertEquals('/foo/foo/bar', $router->urlFor('route3', array('one' => 'foo', 'two' => 'bar'))); + $this->assertEquals('/foo/foo', $router->urlFor('route3', array('one' => 'foo'))); + $this->assertEquals('/foo/:one/bar', $router->urlFor('route3', array('two' => 'bar'))); + $this->assertEquals('/foo/:one', $router->urlFor('route3')); + //Route with params and optional segments + $this->assertEquals('/foo/foo/bar/', $router->urlFor('route4', array('one' => 'foo', 'two' => 'bar'))); + $this->assertEquals('/foo/foo/', $router->urlFor('route4', array('one' => 'foo'))); + $this->assertEquals('/foo/:one/bar/', $router->urlFor('route4', array('two' => 'bar'))); + $this->assertEquals('/foo/:one/', $router->urlFor('route4')); + //Route with params and optional segments + $this->assertEquals('/foo/foo/bar/what/', $router->urlFor('route5', array('one' => 'foo', 'two' => 'bar', 'three' => 'what'))); + $this->assertEquals('/foo/foo/', $router->urlFor('route5', array('one' => 'foo'))); + $this->assertEquals('/foo/:one/bar/', $router->urlFor('route5', array('two' => 'bar'))); + $this->assertEquals('/foo/:one/bar/what/', $router->urlFor('route5', array('two' => 'bar', 'three' => 'what'))); + $this->assertEquals('/foo/:one/', $router->urlFor('route5')); + //Route with wildcard params + $this->assertEquals('/foo/bar/bar', $router->urlFor('route6', array('path'=>'bar'))); + $this->assertEquals('/foo/foo/bar/bar', $router->urlFor('route7', array('path'=>'foo', 'path2'=>'bar'))); + $this->assertEquals('/foo/bar', $router->urlFor('route8', array('path'=>'bar'))); + //Route with similar param names, test greedy matching + $this->assertEquals('/foo/1/2', $router->urlFor('route9', array('var2'=>'2', 'var'=>'1'))); + $this->assertEquals('/foo/1/2', $router->urlFor('route9', array('var'=>'1', 'var2'=>'2'))); + } + + /** + * Test that router returns no matches when neither HTTP method nor URI match. + */ + public function testRouterMatchesRoutesNone() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $this->env = \Slim\Environment::getInstance(); + $this->req = new \Slim\Http\Request($this->env); + $this->res = new \Slim\Http\Response(); + $router = new \Slim\Router(); + $router->map('/bar', function () {})->via('POST'); + $router->map('/foo', function () {})->via('POST'); + $router->map('/foo', function () {})->via('PUT'); + $router->map('/foo/bar/xyz', function () {})->via('DELETE'); + $this->assertEquals(0, count($router->getMatchedRoutes($this->req->getMethod(), $this->req->getResourceUri()))); + } + + /** + * Test that router returns no matches when HTTP method matches but URI does not. + */ + public function testRouterMatchesRoutesNoneWhenMethodMatchesUriDoesNot() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $this->env = \Slim\Environment::getInstance(); + $this->req = new \Slim\Http\Request($this->env); + $this->res = new \Slim\Http\Response(); + $router = new \Slim\Router(); + $router->map('/fooNOMATCH', function () {})->via('GET'); + $router->map('/foo', function () {})->via('POST'); + $router->map('/foo', function () {})->via('PUT'); + $router->map('/foo/bar/xyz', function () {})->via('DELETE'); + $this->assertEquals(0, count($router->getMatchedRoutes($this->req->getMethod(), $this->req->getResourceUri()))); + } + + /** + * Test that router returns no matches when HTTP method does not match but URI does. + */ + public function testRouterMatchesRoutesNoneWhenMethodDoesNotMatchUriMatches() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $this->env = \Slim\Environment::getInstance(); + $this->req = new \Slim\Http\Request($this->env); + $this->res = new \Slim\Http\Response(); + $router = new \Slim\Router(); + $router->map('/foo', function () {})->via('OPTIONS'); + $router->map('/foo', function () {})->via('POST'); + $router->map('/foo', function () {})->via('PUT'); + $router->map('/foo/bar/xyz', function () {})->via('DELETE'); + $this->assertEquals(0, count($router->getMatchedRoutes($this->req->getMethod(), $this->req->getResourceUri()))); + } + + /** + * Test that router returns matched routes based on HTTP method and URI. + */ + public function testRouterMatchesRoutes() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $this->env = \Slim\Environment::getInstance(); + $this->req = new \Slim\Http\Request($this->env); + $this->res = new \Slim\Http\Response(); + $router = new \Slim\Router(); + $router->map('/foo', function () {})->via('GET'); + $router->map('/foo', function () {})->via('POST'); + $router->map('/foo', function () {})->via('PUT'); + $router->map('/foo/bar/xyz', function () {})->via('DELETE'); + $this->assertEquals(1, count($router->getMatchedRoutes($this->req->getMethod(), $this->req->getResourceUri()))); + } + + /** + * Test get current route + */ + public function testGetCurrentRoute() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo' //<-- Virtual + )); + $app = new \Slim\Slim(); + $route1 = $app->get('/bar', function () { + echo "Bar"; + }); + $route2 = $app->get('/foo', function () { + echo "Foo"; + }); + $app->call(); + $this->assertSame($route2, $app->router()->getCurrentRoute()); + } + + /** + * Test calling get current route before routing doesn't cause errors + */ + public function testGetCurrentRouteBeforeRoutingDoesntError() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo' //<-- Virtual + )); + $app = new \Slim\Slim(); + $route1 = $app->get('/bar', function () { + echo "Bar"; + }); + $route2 = $app->get('/foo', function () { + echo "Foo"; + }); + + $app->router()->getCurrentRoute(); + + $app->call(); + } + + /** + * Test get current route before routing returns null + */ + public function testGetCurrentRouteBeforeRoutingReturnsNull() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo' //<-- Virtual + )); + $app = new \Slim\Slim(); + $route1 = $app->get('/bar', function () { + echo "Bar"; + }); + $route2 = $app->get('/foo', function () { + echo "Foo"; + }); + + $this->assertSame(null, $app->router()->getCurrentRoute()); + } + + /** + * Test get current route during slim.before.dispatch hook + */ + public function testGetCurrentRouteDuringBeforeDispatchHook() + { + $route = null; + + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo' //<-- Virtual + )); + $app = new \Slim\Slim(); + $app->hook('slim.before.dispatch', function() use(&$route, $app) { + $route = $app->router()->getCurrentRoute(); + }); + $route1 = $app->get('/bar', function () { + echo "Bar"; + }); + $route2 = $app->get('/foo', function () { + echo "Foo"; + }); + + $app->call(); + $this->assertSame($route2, $route); + } + + /** + * Test get current route during routing + */ + public function testGetCurrentRouteDuringRouting() + { + $route = null; + + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo' //<-- Virtual + )); + $app = new \Slim\Slim(); + $route1 = $app->get('/bar', function () { + echo "Bar"; + }); + $route2 = $app->get('/foo', function () use (&$route, $app) { + echo "Foo"; + $route = $app->router()->getCurrentRoute(); + }); + + $app->call(); + $this->assertSame($route2, $route); + } + + /** + * Test get current route after routing + */ + public function testGetCurrentRouteAfterRouting() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo' //<-- Virtual + )); + $app = new \Slim\Slim(); + $route1 = $app->get('/bar', function () { + echo "Bar"; + }); + $route2 = $app->get('/foo', function () { + echo "Foo"; + }); + $app->call(); + $this->assertSame($route2, $app->router()->getCurrentRoute()); + } + + public function testDispatch() + { + $this->expectOutputString('Hello josh'); + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/hello/josh', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $env = \Slim\Environment::getInstance(); + $req = new \Slim\Http\Request($env); + $router = new \Slim\Router(); + $route = new \Slim\Route('/hello/:name', function ($name) { echo "Hello $name"; }); + $route->matches($req->getResourceUri()); //<-- Extracts params from resource URI + $router->dispatch($route); + } + + public function testDispatchWithMiddlware() + { + $this->expectOutputString('First! Second! Hello josh'); + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/hello/josh', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $env = \Slim\Environment::getInstance(); + $req = new \Slim\Http\Request($env); + $router = new \Slim\Router(); + $route = new \Slim\Route('/hello/:name', function ($name) { echo "Hello $name"; }); + $route->setMiddleware(function () { + echo "First! "; + }); + $route->setMiddleware(function () { + echo "Second! "; + }); + $route->matches($req->getResourceUri()); //<-- Extracts params from resource URI + $router->dispatch($route); + } + + public function testRouteMiddlwareArguments() + { + $this->expectOutputString('foobar'); + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/foo' //<-- Virtual + )); + $env = \Slim\Environment::getInstance(); + $req = new \Slim\Http\Request($env); + $router = new \Slim\Router(); + $route = new \Slim\Route('/foo', function () { echo "bar"; }); + $route->setName('foo'); + $route->setMiddleware(function ($route) { + echo $route->getName(); + }); + $route->matches($req->getResourceUri()); //<-- Extracts params from resource URI + $router->dispatch($route); + } + + public function testDispatchWithoutCallable() + { + $this->setExpectedException('InvalidArgumentException'); + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '', //<-- Physical + 'PATH_INFO' => '/hello/josh', //<-- Virtual + 'QUERY_STRING' => 'one=1&two=2&three=3', + 'SERVER_NAME' => 'slim', + 'SERVER_PORT' => 80, + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => fopen('php://stderr', 'w'), + 'HTTP_HOST' => 'slim' + )); + $env = \Slim\Environment::getInstance(); + $req = new \Slim\Http\Request($env); + $router = new \Slim\Router(); + $route = new \Slim\Route('/hello/:name', 'foo'); // <-- Fail fast + } +} diff --git a/vendor/slim/slim/tests/SlimTest.php b/vendor/slim/slim/tests/SlimTest.php new file mode 100644 index 0000000000..a1aa3ad761 --- /dev/null +++ b/vendor/slim/slim/tests/SlimTest.php @@ -0,0 +1,1492 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +//Mock custom view +class CustomView extends \Slim\View +{ + public function render($template) { echo "Custom view"; } +} + +//Echo Logger +class EchoErrorLogger +{ + public function error($object) { echo get_class($object) .':'.$object->getMessage(); } +} + +//Mock extending class +class Derived extends \Slim\Slim +{ + public static function getDefaultSettings() + { + return array_merge( + array("late-static-binding" => true) + , parent::getDefaultSettings()); + } +} + +//Mock middleware +class CustomMiddleware extends \Slim\Middleware +{ + public function call() + { + $env = $this->app->environment(); + $res = $this->app->response(); + $env['slim.test'] = 'Hello'; + $this->next->call(); + $res->header('X-Slim-Test', 'Hello'); + $res->write('Hello'); + } +} + +class SlimTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + //Remove environment mode if set + unset($_ENV['SLIM_MODE']); + + //Reset session + $_SESSION = array(); + + //Prepare default environment variables + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'QUERY_STRING' => 'one=foo&two=bar', + 'SERVER_NAME' => 'slimframework.com', + )); + } + + /************************************************ + * INSTANTIATION + ************************************************/ + + /** + * Test version constant is string + */ + public function testHasVersionConstant() + { + $this->assertTrue(is_string(\Slim\Slim::VERSION)); + } + + /** + * Test default instance properties + */ + public function testDefaultInstanceProperties() + { + $s = new \Slim\Slim(); + $this->assertInstanceOf('\Slim\Http\Request', $s->request()); + $this->assertInstanceOf('\Slim\Http\Response', $s->response()); + $this->assertInstanceOf('\Slim\Router', $s->router()); + $this->assertInstanceOf('\Slim\View', $s->view()); + $this->assertInstanceOf('\Slim\Log', $s->getLog()); + $this->assertEquals(\Slim\Log::DEBUG, $s->getLog()->getLevel()); + $this->assertTrue($s->getLog()->getEnabled()); + $this->assertInstanceOf('\Slim\Environment', $s->environment()); + } + + /** + * Test get default instance + */ + public function testGetDefaultInstance() + { + $s = new \Slim\Slim(); + $s->setName('default'); //We must do this manually since a default app is already set in prev tests + $this->assertEquals('default', $s->getName()); + $this->assertInstanceOf('\Slim\Slim', \Slim\Slim::getInstance()); + $this->assertSame($s, \Slim\Slim::getInstance()); + } + + /** + * Test get named instance + */ + public function testGetNamedInstance() + { + $s = new \Slim\Slim(); + $s->setName('foo'); + $this->assertSame($s, \Slim\Slim::getInstance('foo')); + } + + /** + * Test Slim autoloader ignores non-Slim classes + * + * Pre-conditions: + * Instantiate a non-Slim class; + * + * Post-conditions: + * Slim autoloader returns without requiring a class file; + */ + public function testSlimAutoloaderIgnoresNonSlimClass() + { + $foo = new Foo(); + } + + /************************************************ + * SETTINGS + ************************************************/ + + /** + * Test get setting that exists + */ + public function testGetSettingThatExists() + { + $s = new \Slim\Slim(); + $this->assertEquals('./templates', $s->config('templates.path')); + } + + /** + * Test get setting that does not exist + */ + public function testGetSettingThatDoesNotExist() + { + $s = new \Slim\Slim(); + $this->assertNull($s->config('foo')); + } + + /** + * Test set setting + */ + public function testSetSetting() + { + $s = new \Slim\Slim(); + $this->assertEquals('./templates', $s->config('templates.path')); + $s->config('templates.path', './tmpl'); + $this->assertEquals('./tmpl', $s->config('templates.path')); + } + + /** + * Test batch set settings + */ + public function testBatchSetSettings() + { + $s = new \Slim\Slim(); + $this->assertEquals('./templates', $s->config('templates.path')); + $this->assertTrue($s->config('debug')); + $s->config(array( + 'templates.path' => './tmpl', + 'debug' => false + )); + $this->assertEquals('./tmpl', $s->config('templates.path')); + $this->assertFalse($s->config('debug')); + } + + /************************************************ + * MODES + ************************************************/ + + /** + * Test default mode + */ + public function testGetDefaultMode() + { + $s = new \Slim\Slim(); + $this->assertEquals('development', $s->getMode()); + } + + /** + * Test custom mode from environment + */ + public function testGetModeFromEnvironment() + { + $_ENV['SLIM_MODE'] = 'production'; + $s = new \Slim\Slim(); + $this->assertEquals('production', $s->getMode()); + } + + /** + * Test custom mode from app settings + */ + public function testGetModeFromSettings() + { + $s = new \Slim\Slim(array( + 'mode' => 'test' + )); + $this->assertEquals('test', $s->getMode()); + } + + /** + * Test mode configuration + */ + public function testModeConfiguration() + { + $flag = 0; + $configureTest = function () use (&$flag) { + $flag = 'test'; + }; + $configureProduction = function () use (&$flag) { + $flag = 'production'; + }; + $s = new \Slim\Slim(array('mode' => 'test')); + $s->configureMode('test', $configureTest); + $s->configureMode('production', $configureProduction); + $this->assertEquals('test', $flag); + } + + /** + * Test mode configuration when mode does not match + */ + public function testModeConfigurationWhenModeDoesNotMatch() + { + $flag = 0; + $configureTest = function () use (&$flag) { + $flag = 'test'; + }; + $s = new \Slim\Slim(array('mode' => 'production')); + $s->configureMode('test', $configureTest); + $this->assertEquals(0, $flag); + } + + /** + * Test mode configuration when not callable + */ + public function testModeConfigurationWhenNotCallable() + { + $flag = 0; + $s = new \Slim\Slim(array('mode' => 'production')); + $s->configureMode('production', 'foo'); + $this->assertEquals(0, $flag); + } + + /** + * Test custom mode from getenv() + */ + public function testGetModeFromGetEnv() + { + putenv('SLIM_MODE=production'); + $s = new \Slim\Slim(); + $this->assertEquals('production', $s->getMode()); + } + + /************************************************ + * ROUTING + ************************************************/ + + /** + * Test GENERIC route + */ + public function testGenericRoute() + { + $s = new \Slim\Slim(); + $callable = function () { echo "foo"; }; + $route = $s->map('/bar', $callable); + $this->assertInstanceOf('\Slim\Route', $route); + $this->assertEmpty($route->getHttpMethods()); + } + + /** + * Test GET routes also get mapped as a HEAD route + */ + public function testGetRouteIsAlsoMappedAsHead() + { + $s = new \Slim\Slim(); + $route = $s->get('/foo', function () {}); + $this->assertTrue($route->supportsHttpMethod(\Slim\Http\Request::METHOD_GET)); + $this->assertTrue($route->supportsHttpMethod(\Slim\Http\Request::METHOD_HEAD)); + } + + /** + * Test GET route + */ + public function testGetRoute() + { + $s = new \Slim\Slim(); + $mw1 = function () { echo "foo"; }; + $mw2 = function () { echo "bar"; }; + $callable = function () { echo "xyz"; }; + $route = $s->get('/bar', $mw1, $mw2, $callable); + $s->call(); + $this->assertEquals('foobarxyz', $s->response()->body()); + $this->assertEquals('/bar', $route->getPattern()); + $this->assertSame($callable, $route->getCallable()); + } + + /** + * Test POST route + */ + public function testPostRoute() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'POST', + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $mw1 = function () { echo "foo"; }; + $mw2 = function () { echo "bar"; }; + $callable = function () { echo "xyz"; }; + $route = $s->post('/bar', $mw1, $mw2, $callable); + $s->call(); + $this->assertEquals('foobarxyz', $s->response()->body()); + $this->assertEquals('/bar', $route->getPattern()); + $this->assertSame($callable, $route->getCallable()); + } + + /** + * Test PUT route + */ + public function testPutRoute() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'PUT', + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $mw1 = function () { echo "foo"; }; + $mw2 = function () { echo "bar"; }; + $callable = function () { echo "xyz"; }; + $route = $s->put('/bar', $mw1, $mw2, $callable); + $s->call(); + $this->assertEquals('foobarxyz', $s->response()->body()); + $this->assertEquals('/bar', $route->getPattern()); + $this->assertSame($callable, $route->getCallable()); + } + + /** + * Test DELETE route + */ + public function testDeleteRoute() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'DELETE', + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $mw1 = function () { echo "foo"; }; + $mw2 = function () { echo "bar"; }; + $callable = function () { echo "xyz"; }; + $route = $s->delete('/bar', $mw1, $mw2, $callable); + $s->call(); + $this->assertEquals('foobarxyz', $s->response()->body()); + $this->assertEquals('/bar', $route->getPattern()); + $this->assertSame($callable, $route->getCallable()); + } + + /** + * Test OPTIONS route + */ + public function testOptionsRoute() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'OPTIONS', + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $mw1 = function () { echo "foo"; }; + $mw2 = function () { echo "bar"; }; + $callable = function () { echo "xyz"; }; + $route = $s->options('/bar', $mw1, $mw2, $callable); + $s->call(); + $this->assertEquals('foobarxyz', $s->response()->body()); + $this->assertEquals('/bar', $route->getPattern()); + $this->assertSame($callable, $route->getCallable()); + } + + /** + * Test if route does NOT expect trailing slash and URL has one + */ + public function testRouteWithoutSlashAndUrlWithOne() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar/', //<-- Virtual + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () { echo "xyz"; }); + $s->call(); + $this->assertEquals(404, $s->response()->status()); + } + + /** + * Test if route contains URL encoded characters + */ + public function testRouteWithUrlEncodedCharacters() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar/jo%20hn/smi%20th', //<-- Virtual + )); + $s = new \Slim\Slim(); + $s->get('/bar/:one/:two', function ($one, $two) { echo $one . $two; }); + $s->call(); + $this->assertEquals('jo hnsmi th', $s->response()->body()); + } + + /************************************************ + * VIEW + ************************************************/ + + /** + * Test set view with string class name + */ + public function testSetSlimViewFromString() + { + $s = new \Slim\Slim(); + $this->assertInstanceOf('\Slim\View', $s->view()); + $s->view('CustomView'); + $this->assertInstanceOf('CustomView', $s->view()); + } + + /** + * Test set view with object instance + */ + public function testSetSlimViewFromInstance() + { + $s = new \Slim\Slim(); + $this->assertInstanceOf('\Slim\View', $s->view()); + $s->view(new CustomView()); + $this->assertInstanceOf('CustomView', $s->view()); + } + + /** + * Test view data is transferred to newer view + */ + public function testViewDataTransfer() + { + $data = array('foo' => 'bar'); + $s = new \Slim\Slim(); + $s->view()->setData($data); + $s->view('CustomView'); + $this->assertSame($data, $s->view()->getData()); + } + + /************************************************ + * RENDERING + ************************************************/ + + /** + * Test render with template and data + */ + public function testRenderTemplateWithData() + { + $s = new \Slim\Slim(array('templates.path' => dirname(__FILE__) . '/templates')); + $s->get('/bar', function () use ($s) { + $s->render('test.php', array('foo' => 'bar')); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertEquals(200, $status); + $this->assertEquals('test output bar', $body); + } + + /** + * Test render with template and data and status + */ + public function testRenderTemplateWithDataAndStatus() + { + $s = new \Slim\Slim(array('templates.path' => dirname(__FILE__) . '/templates')); + $s->get('/bar', function () use ($s) { + $s->render('test.php', array('foo' => 'bar'), 500); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertEquals(500, $status); + $this->assertEquals('test output bar', $body); + } + + /************************************************ + * LOG + ************************************************/ + + /** + * Test get log + * + * This asserts that a Slim app has a default Log + * upon instantiation. The Log itself is tested + * separately in another file. + */ + public function testGetLog() + { + $s = new \Slim\Slim(); + $this->assertInstanceOf('\Slim\Log', $s->getLog()); + } + + /************************************************ + * HTTP CACHING + ************************************************/ + + /** + * Test Last-Modified match + */ + public function testLastModifiedMatch() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'IF_MODIFIED_SINCE' => 'Sun, 03 Oct 2010 17:00:52 -0400', + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->lastModified(1286139652); + }); + $s->call(); + $this->assertEquals(304, $s->response()->status()); + } + + /** + * Test Last-Modified match + */ + public function testLastModifiedDoesNotMatch() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'IF_MODIFIED_SINCE' => 'Sun, 03 Oct 2010 17:00:52 -0400', + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->lastModified(1286139250); + }); + $s->call(); + $this->assertEquals(200, $s->response()->status()); + } + + public function testLastModifiedOnlyAcceptsIntegers() + { + $this->setExpectedException('\InvalidArgumentException'); + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->lastModified('Test'); + }); + $s->call(); + } + + /** + * Test ETag matches + */ + public function testEtagMatches() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'IF_NONE_MATCH' => '"abc123"', + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->etag('abc123'); + }); + $s->call(); + $this->assertEquals(304, $s->response()->status()); + } + + /** + * Test ETag does not match + */ + public function testEtagDoesNotMatch() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'IF_NONE_MATCH' => '"abc1234"', + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->etag('abc123'); + }); + $s->call(); + $this->assertEquals(200, $s->response()->status()); + } + + /** + * Test ETag with invalid type + */ + public function testETagWithInvalidType() + { + $this->setExpectedException('\InvalidArgumentException'); + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'IF_NONE_MATCH' => '"abc1234"', + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->etag('123','foo'); + }); + $s->call(); + } + + /** + * Test Expires + */ + public function testExpiresAsString() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $expectedDate = gmdate('D, d M Y', strtotime('5 days')); //Just the day, month, and year + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->expires('5 days'); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertTrue(isset($header['Expires'])); + $this->assertEquals(0, strpos($header['Expires'], $expectedDate)); + } + + /** + * Test Expires + */ + public function testExpiresAsInteger() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $fiveDaysFromNow = time() + (60 * 60 * 24 * 5); + $expectedDate = gmdate('D, d M Y', $fiveDaysFromNow); //Just the day, month, and year + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s, $fiveDaysFromNow) { + $s->expires($fiveDaysFromNow); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertTrue(isset($header['Expires'])); + $this->assertEquals(0, strpos($header['Expires'], $expectedDate)); + } + + /************************************************ + * COOKIES + ************************************************/ + + /** + * Set cookie + * + * This tests that the Slim application instance sets + * a cookie in the HTTP response header. This does NOT + * test the implementation of setting the cookie; that is + * tested in a separate file. + */ + public function testSetCookie() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->setCookie('foo', 'bar', '2 days'); + $s->setCookie('foo1', 'bar1', '2 days'); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $cookies = explode("\n", $header['Set-Cookie']); + $this->assertEquals(2, count($cookies)); + $this->assertEquals(1, preg_match('@foo=bar@', $cookies[0])); + $this->assertEquals(1, preg_match('@foo1=bar1@', $cookies[1])); + } + + /** + * Test get cookie + * + * This method ensures that the `Cookie:` HTTP request + * header is parsed if present, and made accessible via the + * Request object. + */ + public function testGetCookie() + { + \Slim\Environment::mock(array( + 'REQUEST_METHOD' => 'GET', + 'REMOTE_ADDR' => '127.0.0.1', + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'QUERY_STRING' => 'one=foo&two=bar', + 'SERVER_NAME' => 'slimframework.com', + 'SERVER_PORT' => 80, + 'COOKIE' => 'foo=bar; foo2=bar2', + 'slim.url_scheme' => 'http', + 'slim.input' => '', + 'slim.errors' => @fopen('php://stderr', 'w') + )); + $s = new \Slim\Slim(); + $this->assertEquals('bar', $s->getCookie('foo')); + $this->assertEquals('bar2', $s->getCookie('foo2')); + } + + /** + * Test get cookie when cookie does not exist + */ + public function testGetCookieThatDoesNotExist() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $this->assertNull($s->getCookie('foo')); + } + + /** + * Test delete cookie + * + * This method ensures that the `Set-Cookie:` HTTP response + * header is set. The implementation of setting the response + * cookie is tested separately in another file. + */ + public function testDeleteCookie() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + 'COOKIE' => 'foo=bar; foo2=bar2', + )); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->setCookie('foo', 'bar'); + $s->deleteCookie('foo'); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $cookies = explode("\n", $header['Set-Cookie']); + $this->assertEquals(1, count($cookies)); + $this->assertEquals(1, preg_match('@^foo=;@', $cookies[0])); + } + + /** + * Test set encrypted cookie + * + * This method ensures that the `Set-Cookie:` HTTP request + * header is set. The implementation is tested in a separate file. + */ + public function testSetEncryptedCookie() + { + $s = new \Slim\Slim(); + $s->setEncryptedCookie('foo', 'bar'); + $r = $s->response(); + $this->assertEquals(1, preg_match("@^foo=.+%7C.+%7C.+@", $r['Set-Cookie'])); //<-- %7C is a url-encoded pipe + } + + /** + * Test get encrypted cookie + * + * This only tests that this method runs without error. The implementation of + * fetching the encrypted cookie is tested separately. + */ + public function testGetEncryptedCookieAndDeletingIt() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $r = $s->response(); + $this->assertFalse($s->getEncryptedCookie('foo')); + $this->assertEquals(1, preg_match("@foo=;.*@", $r['Set-Cookie'])); + } + + /** + * Test get encrypted cookie WITHOUT deleting it + * + * This only tests that this method runs without error. The implementation of + * fetching the encrypted cookie is tested separately. + */ + public function testGetEncryptedCookieWithoutDeletingIt() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/bar', //<-- Virtual + )); + $s = new \Slim\Slim(); + $r = $s->response(); + $this->assertFalse($s->getEncryptedCookie('foo', false)); + $this->assertEquals(0, preg_match("@foo=;.*@", $r['Set-Cookie'])); + } + + /************************************************ + * HELPERS + ************************************************/ + + /** + * Test get filesystem path to Slim app root directory + */ + public function testGetRoot() + { + $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__); //<-- No trailing slash + $s = new \Slim\Slim(); + $this->assertEquals($_SERVER['DOCUMENT_ROOT'] . '/foo/', $s->root()); //<-- Appends physical app path with trailing slash + } + + /** + * Test stop + */ + public function testStop() + { + $this->setExpectedException('\Slim\Exception\Stop'); + $s = new \Slim\Slim(); + $s->stop(); + } + + /** + * Test stop with subsequent output + */ + public function testStopWithSubsequentOutput() + { + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + echo "Foo"; //<-- Should be in response body! + $s->stop(); + echo "Bar"; //<-- Should not be in response body! + }); + $s->call(); + $this->assertEquals('Foo', $s->response()->body()); + } + + /** + * Test stop with output buffer on and pre content + */ + public function testStopOutputWithOutputBufferingOnAndPreContent() + { + $this->expectOutputString('1.2.Foo.3'); //<-- PHP unit uses OB here + echo "1."; + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + echo "Foo"; + $s->stop(); + }); + echo "2."; + $s->run(); //<-- Needs to be run to actually echo body + echo ".3"; + } + + /** + * Test stop does not leave output buffers open + */ + public function testStopDoesNotLeaveOutputBuffersOpen() + { + $level_start = ob_get_level(); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->stop(); + }); + $s->run(); + $this->assertEquals($level_start, ob_get_level()); + } + + /** + * Test halt + */ + public function testHalt() + { + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + echo "Foo!"; //<-- Should not be in response body! + $s->halt(500, 'Something broke'); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertEquals(500, $status); + $this->assertEquals('Something broke', $body); + } + + /** + * Test halt with output buffering and pre content + */ + public function testHaltOutputWithOutputBufferingOnAndPreContent() + { + $this->expectOutputString('1.2.Something broke.3'); //<-- PHP unit uses OB here + echo "1."; + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + echo "Foo!"; //<-- Should not be in response body! + $s->halt(500, 'Something broke'); + }); + echo "2."; + $s->run(); + echo ".3"; + } + + /** + * Test halt does not leave output buffers open + */ + public function testHaltDoesNotLeaveOutputBuffersOpen() + { + $level_start = ob_get_level(); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->halt(500, ''); + }); + $s->run(); + $this->assertEquals($level_start, ob_get_level()); + } + + /** + * Test pass cleans buffer and throws exception + */ + public function testPass() + { + ob_start(); + $s = new \Slim\Slim(); + echo "Foo"; + try { + $s->pass(); + $this->fail('Did not catch Slim_Exception_Pass'); + } catch ( \Slim\Exception\Pass $e ) {} + $output = ob_get_clean(); + $this->assertEquals('', $output); + } + + /** + * Test pass when there is a subsequent fallback route + */ + public function testPassWithSubsequentRoute() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/name/Frank', //<-- Virtual + )); + $s = new \Slim\Slim(); + $s->get('/name/Frank', function () use ($s) { + echo "Fail"; //<-- Should not be in response body! + $s->pass(); + }); + $s->get('/name/:name', function ($name) { + echo $name; //<-- Should be in response body! + }); + $s->call(); + $this->assertEquals('Frank', $s->response()->body()); + } + + /** + * Test pass when there is not a subsequent fallback route + */ + public function testPassWithoutSubsequentRoute() + { + \Slim\Environment::mock(array( + 'SCRIPT_NAME' => '/foo', //<-- Physical + 'PATH_INFO' => '/name/Frank', //<-- Virtual + )); + $s = new \Slim\Slim(); + $s->get('/name/Frank', function () use ($s) { + echo "Fail"; //<-- Should not be in response body! + $s->pass(); + }); + $s->call(); + $this->assertEquals(404, $s->response()->status()); + } + + /** + * Test content type + */ + public function testContentType() + { + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->contentType('application/json'); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertEquals('application/json', $header['Content-Type']); + } + + /** + * Test status + */ + public function testStatus() + { + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->status(403); + }); + $s->call(); + $this->assertEquals(403, $s->response()->status()); + } + + /** + * Test URL for + */ + public function testSlimUrlFor() + { + $s = new \Slim\Slim(); + $s->get('/hello/:name', function () {})->name('hello'); + $this->assertEquals('/foo/hello/Josh', $s->urlFor('hello', array('name' => 'Josh'))); //<-- Prepends physical path! + } + + /** + * Test redirect sets status and header + */ + public function testRedirect() + { + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + echo "Foo"; //<-- Should not be in response body! + $s->redirect('/somewhere/else', 303); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertEquals(303, $status); + $this->assertEquals('/somewhere/else', $header['Location']); + $this->assertEquals('', $body); + } + + /************************************************ + * RUNNER + ************************************************/ + + /** + * Test that runner sends headers and body + */ + public function testRun() + { + $this->expectOutputString('Foo'); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + echo "Foo"; + }); + $s->run(); + } + + /** + * Test runner output with output buffering on and pre content + */ + public function testRunOutputWithOutputBufferingOnAndPreContent() + { + $this->expectOutputString('1.2.Foo.3'); //<-- PHP unit uses OB here + $s = new \Slim\Slim(); + echo "1."; + $s->get('/bar', function () use ($s) { + echo "Foo"; + }); + echo "2."; + $s->run(); + echo ".3"; + } + + /** + * Test that runner does not leave output buffers open + */ + public function testRunDoesNotLeaveAnyOutputBuffersOpen() + { + $level_start = ob_get_level(); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) {}); + $s->run(); + $this->assertEquals($level_start, ob_get_level()); + } + + /************************************************ + * MIDDLEWARE + ************************************************/ + + /** + * Test add middleware + * + * This asserts that middleware are queued and called + * in sequence. This also asserts that the environment + * variables are passed by reference. + */ + public function testAddMiddleware() + { + $this->expectOutputString('FooHello'); + $s = new \Slim\Slim(); + $s->add(new CustomMiddleware()); //<-- See top of this file for class definition + $s->get('/bar', function () { + echo 'Foo'; + }); + $s->run(); + $this->assertEquals('Hello', $s->response()->header('X-Slim-Test')); + } + + /************************************************ + * FLASH MESSAGING + ************************************************/ + + public function testSetFlashForNextRequest() + { + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->flash('info', 'bar'); + }); + $this->assertFalse(isset($_SESSION['slim.flash'])); + $s->run(); + $this->assertEquals('bar', $_SESSION['slim.flash']['info']); + } + + public function testSetFlashForCurrentRequest() + { + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->flashNow('info', 'bar'); + }); + $s->run(); + $env = $s->environment(); + $this->assertEquals('bar', $env['slim.flash']['info']); + } + + public function testKeepFlashForNextRequest() + { + $_SESSION['slim.flash'] = array('info' => 'Foo'); + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->flashKeep(); + }); + $s->run(); + $this->assertEquals('Foo', $_SESSION['slim.flash']['info']); + } + + /************************************************ + * NOT FOUND HANDLING + ************************************************/ + + /** + * Test custom Not Found handler + */ + public function testNotFound() + { + $s = new \Slim\Slim(); + $s->notFound(function () { + echo "Not Found"; + }); + $s->get('/foo', function () {}); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertEquals(404, $status); + $this->assertEquals('Not Found', $body); + } + + /************************************************ + * ERROR HANDLING + ************************************************/ + + /** + * Test default and custom error handlers + * + * Pre-conditions: + * Invoked app route calls default error handler; + * + * Post-conditions: + * Response status code is 500; + */ + public function testSlimError() + { + $s = new \Slim\Slim(); + $s->get('/bar', function () use ($s) { + $s->error(); + }); + $s->call(); + $this->assertEquals(500, $s->response()->status()); + } + + /** + * Test default error handler logs the error when debug is false. + * + * Pre-conditions: + * Invoked app route calls default error handler; + * + * Post-conditions: + * Error log is called + */ + public function testDefaultHandlerLogsTheErrorWhenDebugIsFalse() + { + $s = new \Slim\Slim(array('debug' => false)); + $s->get('/bar', function () use ($s) { + throw new \InvalidArgumentException('my specific error message'); + }); + + $env = $s->environment(); + $env['slim.log'] = new EchoErrorLogger(); // <-- inject the fake logger + + ob_start(); + $s->run(); + $output = ob_get_clean(); + $this->assertTrue(strpos($output, 'InvalidArgumentException:my specific error message') !== false); + } + + /** + * Test triggered errors are converted to ErrorExceptions + * + * Pre-conditions: + * Custom error handler defined; + * Invoked app route triggers error; + * + * Post-conditions: + * Response status is 500; + * Response body is equal to triggered error message; + * Error handler's argument is ErrorException instance; + */ + public function DISABLEDtestTriggeredErrorsAreConvertedToErrorExceptions() + { + $s = new \Slim\Slim(array( + 'debug' => false + )); + $s->error(function ( $e ) { + if ($e instanceof \ErrorException) { + echo $e->getMessage(); + } + }); + $s->get('/bar', function () { + trigger_error('Foo I say!'); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertEquals(500, $status); + $this->assertEquals('Foo I say!', $body); + } + + /** + * Test error triggered with multiple applications + * + * Pre-conditions: + * Multiple Slim apps are instantiated; + * Both apps are run; + * One app returns 200 OK; + * One app triggers an error; + * + * Post-conditions: + * One app returns 200 OK with no Exceptions; + * One app returns 500 Error; + * Error triggered does not affect other app; + */ + public function testErrorWithMultipleApps() + { + $s1 = new \Slim\Slim(array( + 'debug' => false + )); + $s2 = new \Slim\Slim(); + $s1->get('/bar', function () use ($s1) { + $s1->error(); + }); + $s2->get('/bar', function () { + echo 'success'; + }); + $s1->call(); + $s2->call(); + $this->assertEquals(500, $s1->response()->status()); + $this->assertEquals(200, $s2->response()->status()); + } + + /** + * Test custom error handler uses existing Response object + */ + public function testErrorHandlerUsesCurrentResponseObject() + { + $s = new \Slim\Slim(array( + 'debug' => false + )); + $s->error(function ( \Exception $e ) use ($s) { + $r = $s->response(); + $r->status(503); + $r->write('Foo'); + $r['X-Powered-By'] = 'Slim'; + echo 'Bar'; + }); + $s->get('/bar', function () { + throw new \Exception('Foo'); + }); + $s->call(); + list($status, $header, $body) = $s->response()->finalize(); + $this->assertEquals(503, $status); + $this->assertEquals('FooBar', $body); + $this->assertEquals('Slim', $header['X-Powered-By']); + } + + /** + * Test custom global error handler + */ + public function testHandleErrors() + { + $defaultErrorReporting = error_reporting(); + + // Assert Slim ignores E_NOTICE errors + error_reporting(E_ALL ^ E_NOTICE); // <-- Report all errors EXCEPT notices + try { + $this->assertTrue(\Slim\Slim::handleErrors(E_NOTICE, 'test error', 'Slim.php', 119)); + } catch (\ErrorException $e) { + $this->fail('Slim::handleErrors reported a disabled error level.'); + } + + // Assert Slim reports E_STRICT errors + error_reporting(E_ALL | E_STRICT); // <-- Report all errors, including E_STRICT + try { + \Slim\Slim::handleErrors(E_STRICT, 'test error', 'Slim.php', 119); + $this->fail('Slim::handleErrors didn\'t report a enabled error level'); + } catch (\ErrorException $e) { + $this->assertEquals('test error', $e->getMessage()); + } + + error_reporting($defaultErrorReporting); + } + + /** + * Slim should keep reference to a callable error callback + */ + public function testErrorHandler() { + $s = new \Slim\Slim(); + $errCallback = function () { echo "404"; }; + $s->error($errCallback); + $this->assertSame($errCallback, PHPUnit_Framework_Assert::readAttribute($s, 'error')); + } + + /** + * Slim should throw a Slim_Exception_Stop if error callback is not callable + */ + public function testErrorHandlerIfNotCallable() { + $this->setExpectedException('\Slim\Exception\Stop'); + $s = new \Slim\Slim(); + $errCallback = 'foo'; + $s->error($errCallback); + } + + /** + * Slim should keep reference to a callable NotFound callback + */ + public function testNotFoundHandler() { + $s = new \Slim\Slim(); + $notFoundCallback = function () { echo "404"; }; + $s->notFound($notFoundCallback); + $this->assertSame($notFoundCallback, PHPUnit_Framework_Assert::readAttribute($s, 'notFound')); + } + + /** + * Slim should throw a Slim_Exception_Stop if NotFound callback is not callable + */ + public function testNotFoundHandlerIfNotCallable() { + $this->setExpectedException('\Slim\Exception\Stop'); + $s = new \Slim\Slim(); + $notFoundCallback = 'foo'; + $s->notFound($notFoundCallback); + } + + /************************************************ + * HOOKS + ************************************************/ + + /** + * Test hook listener + * + * Pre-conditions: + * Slim app instantiated; + * Hook name does not exist; + * Listeners are callable objects; + * + * Post-conditions: + * Callables are invoked in expected order; + */ + public function testRegistersAndCallsHooksByPriority() + { + $this->expectOutputString('barfoo'); + $app = new \Slim\Slim(); + $callable1 = function () { echo "foo"; }; + $callable2 = function () { echo "bar"; }; + $app->hook('test.hook.one', $callable1); //default is 10 + $app->hook('test.hook.one', $callable2, 8); + $hooks = $app->getHooks(); + $this->assertEquals(7, count($hooks)); //6 default, 1 custom + $app->applyHook('test.hook.one'); + } + + /** + * Test hook listener if listener is not callable + * + * Pre-conditions: + * Slim app instantiated; + * Hook name does not exist; + * Listener is NOT a callable object; + * + * Post-conditions: + * Hook is created; + * Callable is NOT assigned to hook; + */ + public function testHookInvalidCallable() + { + $app = new \Slim\Slim(); + $callable = 'test'; //NOT callable + $app->hook('test.hook.one', $callable); + $this->assertEquals(array(array()), $app->getHooks('test.hook.one')); + } + + /** + * Test hook invocation if hook does not exist + * + * Pre-conditions: + * Slim app instantiated; + * Hook name does not exist; + * + * Post-conditions: + * Hook is created; + * Hook initialized with empty array; + */ + public function testHookInvocationIfNotExists() + { + $app = new \Slim\Slim(); + $app->applyHook('test.hook.one'); + $this->assertEquals(array(array()), $app->getHooks('test.hook.one')); + } + + /** + * Test clear hooks + * + * Pre-conditions: + * Slim app instantiated; + * Two hooks exist, each with one listener; + * + * Post-conditions: + * Case A: Listeners for 'test.hook.one' are cleared; + * Case B: Listeners for all hooks are cleared; + */ + public function testHookClear() + { + $app = new \Slim\Slim(); + $app->hook('test.hook.one', function () {}); + $app->hook('test.hook.two', function () {}); + $app->clearHooks('test.hook.two'); + $this->assertEquals(array(array()), $app->getHooks('test.hook.two')); + $hookOne = $app->getHooks('test.hook.one'); + $this->assertTrue(count($hookOne[10]) === 1); + $app->clearHooks(); + $this->assertEquals(array(array()), $app->getHooks('test.hook.one')); + } + + /** + * Test late static binding + * + * Pre-conditions: + * Slim app is extended by Derived class and instantiated; + * Derived class overrides the 'getDefaultSettings' function and adds an extra default config value + * Test that the new config value exists + * + * Post-conditions: + * Config value exists and is equal to expected value + */ + public function testDerivedClassCanOverrideStaticFunction() + { + $app = new Derived(); + $this->assertEquals($app->config("late-static-binding"), true); + } +} diff --git a/vendor/slim/slim/tests/ViewTest.php b/vendor/slim/slim/tests/ViewTest.php new file mode 100644 index 0000000000..d7f501cef8 --- /dev/null +++ b/vendor/slim/slim/tests/ViewTest.php @@ -0,0 +1,195 @@ + + * @copyright 2011 Josh Lockhart + * @link http://www.slimframework.com + * @license http://www.slimframework.com/license + * @version 2.2.0 + * + * MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +class ViewTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->view = new \Slim\View(); + } + + public function generateTestData() + { + return array('a' => 1, 'b' => 2, 'c' => 3); + } + + /** + * Test initial View data is an empty array + * + * Pre-conditions: + * None + * + * Post-conditions: + * The View object's data attribute is an empty array + */ + public function testViewIsConstructedWithDataArray() + { + $this->assertEquals(array(), $this->view->getData()); + } + + /** + * Test View sets and gets data + * + * Pre-conditions: + * Case A: Set view data key/value + * Case B: Set view data as array + * Case C: Set view data with one argument that is not an array + * + * Post-conditions: + * Case A: Data key/value are set + * Case B: Data is set to array + * Case C: An InvalidArgumentException is thrown + */ + public function testViewSetAndGetData() + { + //Case A + $this->view->setData('one', 1); + $this->assertEquals(1, $this->view->getData('one')); + + //Case B + $data = array('foo' => 'bar', 'a' => 'A'); + $this->view->setData($data); + $this->assertSame($data, $this->view->getData()); + + //Case C + try { + $this->view->setData('foo'); + $this->fail('Setting View data with non-array single argument did not throw exception'); + } catch ( \InvalidArgumentException $e ) {} + } + + /** + * Test View appends data + * + * Pre-conditions: + * Case A: Append data to View several times + * Case B: Append view data which is not an array + * + * Post-conditions: + * Case A: The View data contains all appended data + * Case B: An InvalidArgumentException is thrown + */ + public function testViewAppendsData() + { + //Case A + $this->view->appendData(array('a' => 'A')); + $this->view->appendData(array('b' => 'B')); + $this->assertEquals(array('a' => 'A', 'b' => 'B'), $this->view->getData()); + + //Case B + try { + $this->view->appendData('not an array'); + $this->fail('Appending View data with non-array argument did not throw exception'); + } catch ( \InvalidArgumentException $e ) {} + + } + + /** + * Test View templates directory + * + * Pre-conditions: + * View templates directory is set to an existing directory + * + * Post-conditions: + * The templates directory is set correctly. + */ + public function testSetsTemplatesDirectory() + { + $templatesDirectory = dirname(__FILE__) . '/templates'; + $this->view->setTemplatesDirectory($templatesDirectory); + $this->assertEquals($templatesDirectory, $this->view->getTemplatesDirectory()); + } + + /** + * Test View templates directory may have a trailing slash when set + * + * Pre-conditions: + * View templates directory is set to an existing directory with a trailing slash + * + * Post-conditions: + * The View templates directory is set correctly without a trailing slash + */ + public function testTemplatesDirectoryWithTrailingSlash() + { + $this->view->setTemplatesDirectory(dirname(__FILE__) . '/templates/'); + $this->assertEquals(dirname(__FILE__) . '/templates', $this->view->getTemplatesDirectory()); + } + + /** + * Test View renders template + * + * Pre-conditions: + * View templates directory is set to an existing directory. + * View data is set without errors + * Case A: View renders an existing template + * Case B: View renders a non-existing template + * + * Post-conditions: + * Case A: The rendered template is returned as a string + * Case B: A RuntimeException is thrown + */ + public function testRendersTemplateWithData() + { + $this->view->setTemplatesDirectory(dirname(__FILE__) . '/templates'); + $this->view->setData(array('foo' => 'bar')); + + //Case A + $output = $this->view->render('test.php'); + $this->assertEquals('test output bar', $output); + + //Case B + try { + $output = $this->view->render('foo.php'); + $this->fail('Rendering non-existent template did not throw exception'); + } catch ( \RuntimeException $e ) {} + } + + /** + * Test View displays template + * + * Pre-conditions: + * View templates directory is set to an existing directory. + * View data is set without errors + * View is displayed + * + * Post-conditions: + * The output buffer contains the rendered template + */ + public function testDisplaysTemplateWithData() + { + $this->expectOutputString('test output bar'); + $this->view->setTemplatesDirectory(dirname(__FILE__) . '/templates'); + $this->view->setData(array('foo' => 'bar')); + $this->view->display('test.php'); + } + +} diff --git a/vendor/slim/slim/tests/bootstrap.php b/vendor/slim/slim/tests/bootstrap.php new file mode 100644 index 0000000000..0705e54fec --- /dev/null +++ b/vendor/slim/slim/tests/bootstrap.php @@ -0,0 +1,19 @@ + diff --git a/vendor/symfony/console/Symfony/Component/Console/.gitignore b/vendor/symfony/console/Symfony/Component/Console/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Application.php b/vendor/symfony/console/Symfony/Component/Console/Application.php old mode 100755 new mode 100644 index 138248d87b..718aef46d4 --- a/vendor/symfony/console/Symfony/Component/Console/Application.php +++ b/vendor/symfony/console/Symfony/Component/Console/Application.php @@ -708,7 +708,7 @@ class Application /** * Renders a caught exception. * - * @param Exception $e An exception instance + * @param \Exception $e An exception instance * @param OutputInterface $output An OutputInterface instance */ public function renderException($e, $output) @@ -729,29 +729,29 @@ class Application $title = sprintf(' [%s] ', get_class($e)); $len = $strlen($title); $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX; + $formatter = $output->getFormatter(); $lines = array(); foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) { foreach (str_split($line, $width - 4) as $line) { - $lines[] = sprintf(' %s ', $line); - $len = max($strlen($line) + 4, $len); + // pre-format lines to get the right string length + $lineLength = $strlen(preg_replace('/\[[^m]*m/', '', $formatter->format($line))) + 4; + $lines[] = array($line, $lineLength); + + $len = max($lineLength, $len); } } - $messages = array(str_repeat(' ', $len), $title.str_repeat(' ', max(0, $len - $strlen($title)))); - + $messages = array('', ''); + $messages[] = $emptyLine = $formatter->format(sprintf('%s', str_repeat(' ', $len))); + $messages[] = $formatter->format(sprintf('%s%s', $title, str_repeat(' ', max(0, $len - $strlen($title))))); foreach ($lines as $line) { - $messages[] = $line.str_repeat(' ', $len - $strlen($line)); + $messages[] = $formatter->format(sprintf(' %s %s', $line[0], str_repeat(' ', $len - $line[1]))); } + $messages[] = $emptyLine; + $messages[] = ''; + $messages[] = ''; - $messages[] = str_repeat(' ', $len); - - $output->writeln(""); - $output->writeln(""); - foreach ($messages as $message) { - $output->writeln(''.$message.''); - } - $output->writeln(""); - $output->writeln(""); + $output->writeln($messages, OutputInterface::OUTPUT_RAW); if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->writeln('Exception trace:'); @@ -861,7 +861,7 @@ class Application $input->setInteractive(false); } elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) { $inputStream = $this->getHelperSet()->get('dialog')->getInputStream(); - if (!posix_isatty($inputStream)) { + if (!@posix_isatty($inputStream)) { $input->setInteractive(false); } } diff --git a/vendor/symfony/console/Symfony/Component/Console/CHANGELOG.md b/vendor/symfony/console/Symfony/Component/Console/CHANGELOG.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Command/Command.php b/vendor/symfony/console/Symfony/Component/Console/Command/Command.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Command/HelpCommand.php b/vendor/symfony/console/Symfony/Component/Console/Command/HelpCommand.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Command/ListCommand.php b/vendor/symfony/console/Symfony/Component/Console/Command/ListCommand.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/ConsoleEvents.php b/vendor/symfony/console/Symfony/Component/Console/ConsoleEvents.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleCommandEvent.php b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleCommandEvent.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleEvent.php b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleEvent.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleExceptionEvent.php b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleExceptionEvent.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleTerminateEvent.php b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleTerminateEvent.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php old mode 100755 new mode 100644 index db4a2fa37a..d3c8c061ad --- a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface /** * The pattern to phrase the format. */ - const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx'; + const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]*)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx'; private $decorated; private $styles = array(); @@ -45,11 +45,11 @@ class OutputFormatter implements OutputFormatterInterface * Initializes console output formatter. * * @param Boolean $decorated Whether this formatter should actually decorate strings - * @param FormatterStyle[] $styles Array of "name => FormatterStyle" instances + * @param OutputFormatterStyleInterface[] $styles Array of "name => FormatterStyle" instances * * @api */ - public function __construct($decorated = null, array $styles = array()) + public function __construct($decorated = false, array $styles = array()) { $this->decorated = (Boolean) $decorated; @@ -163,6 +163,8 @@ class OutputFormatter implements OutputFormatterInterface /** * Replaces style of the output. * + * All escaped tags and tags that reference unknown styles are kept as is. + * * @param array $match * * @return string The replaced style diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterInterface.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterInterface.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php old mode 100755 new mode 100644 index ec471699e0..f0bbd38372 --- a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php +++ b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php @@ -55,9 +55,9 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface /** * Initializes output formatter style. * - * @param string $foreground The style foreground color name - * @param string $background The style background color name - * @param array $options The style options + * @param string|null $foreground The style foreground color name + * @param string|null $background The style background color name + * @param array $options The style options * * @api */ @@ -77,7 +77,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface /** * Sets style foreground color. * - * @param string $color The color name + * @param string|null $color The color name * * @throws \InvalidArgumentException When the color name isn't defined * @@ -105,7 +105,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface /** * Sets style background color. * - * @param string $color The color name + * @param string|null $color The color name * * @throws \InvalidArgumentException When the color name isn't defined * diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php old mode 100755 new mode 100644 index 5915023c62..e63912ca7b --- a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php +++ b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php @@ -29,7 +29,7 @@ class OutputFormatterStyleStack /** * Constructor. * - * @param OutputFormatterStyleInterface $emptyStyle + * @param OutputFormatterStyleInterface|null $emptyStyle */ public function __construct(OutputFormatterStyleInterface $emptyStyle = null) { @@ -58,7 +58,7 @@ class OutputFormatterStyleStack /** * Pops a style from the stack. * - * @param OutputFormatterStyleInterface $style + * @param OutputFormatterStyleInterface|null $style * * @return OutputFormatterStyleInterface * diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/DescriptorHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/DescriptorHelper.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/DialogHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/DialogHelper.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/FormatterHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/FormatterHelper.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/Helper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/Helper.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/HelperInterface.php b/vendor/symfony/console/Symfony/Component/Console/Helper/HelperInterface.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/HelperSet.php b/vendor/symfony/console/Symfony/Component/Console/Helper/HelperSet.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php old mode 100755 new mode 100644 index f24b504a40..c3d6cb363c --- a/vendor/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php @@ -178,7 +178,7 @@ class ProgressHelper extends Helper * Starts the progress output. * * @param OutputInterface $output An Output instance - * @param integer $max Maximum steps + * @param integer|null $max Maximum steps */ public function start(OutputInterface $output, $max = null) { @@ -235,8 +235,12 @@ class ProgressHelper extends Helper $redraw = true; } + $prevPeriod = intval($this->current / $this->redrawFreq); + $this->current += $step; - if ($redraw || 0 === $this->current % $this->redrawFreq) { + + $currPeriod = intval($this->current / $this->redrawFreq); + if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) { $this->display(); } } @@ -265,8 +269,12 @@ class ProgressHelper extends Helper $redraw = true; } + $prevPeriod = intval($this->current / $this->redrawFreq); + $this->current = $current; - if ($redraw || 0 === $this->current % $this->redrawFreq) { + + $currPeriod = intval($this->current / $this->redrawFreq); + if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) { $this->display(); } } diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/TableHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/TableHelper.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php b/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php old mode 100755 new mode 100644 index e19f629550..0d6b327629 --- a/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php +++ b/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php @@ -84,7 +84,7 @@ class ArgvInput extends Input $parseOptions = false; } elseif ($parseOptions && 0 === strpos($token, '--')) { $this->parseLongOption($token); - } elseif ($parseOptions && '-' === $token[0]) { + } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) { $this->parseShortOption($token); } else { $this->parseArgument($token); @@ -284,9 +284,11 @@ class ArgvInput extends Input { $values = (array) $values; - foreach ($this->tokens as $v) { - if (in_array($v, $values)) { - return true; + foreach ($this->tokens as $token) { + foreach ($values as $value) { + if ($token === $value || 0 === strpos($token, $value.'=')) { + return true; + } } } @@ -311,7 +313,7 @@ class ArgvInput extends Input $tokens = $this->tokens; while ($token = array_shift($tokens)) { foreach ($values as $value) { - if (0 === strpos($token, $value)) { + if ($token === $value || 0 === strpos($token, $value.'=')) { if (false !== $pos = strpos($token, '=')) { return substr($token, $pos + 1); } diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php b/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/Input.php b/vendor/symfony/console/Symfony/Component/Console/Input/Input.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputArgument.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputArgument.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputDefinition.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputDefinition.php old mode 100755 new mode 100644 index 257d057ffc..93ca9167dc --- a/vendor/symfony/console/Symfony/Component/Console/Input/InputDefinition.php +++ b/vendor/symfony/console/Symfony/Component/Console/Input/InputDefinition.php @@ -11,6 +11,11 @@ namespace Symfony\Component\Console\Input; +if (!defined('JSON_UNESCAPED_UNICODE')) { + define('JSON_UNESCAPED_SLASHES', 64); + define('JSON_UNESCAPED_UNICODE', 256); +} + use Symfony\Component\Console\Descriptor\TextDescriptor; use Symfony\Component\Console\Descriptor\XmlDescriptor; diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputInterface.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputInterface.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputOption.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputOption.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/StringInput.php b/vendor/symfony/console/Symfony/Component/Console/Input/StringInput.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/LICENSE b/vendor/symfony/console/Symfony/Component/Console/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/Output.php b/vendor/symfony/console/Symfony/Component/Console/Output/Output.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php b/vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/README.md b/vendor/symfony/console/Symfony/Component/Console/README.md old mode 100755 new mode 100644 index fbf05fc853..bfc704427c --- a/vendor/symfony/console/Symfony/Component/Console/README.md +++ b/vendor/symfony/console/Symfony/Component/Console/README.md @@ -46,7 +46,7 @@ Tests You can run the unit tests with the following command: $ cd path/to/Symfony/Component/Console/ - $ composer.phar install --dev + $ composer.phar install $ phpunit Third Party diff --git a/vendor/symfony/console/Symfony/Component/Console/Resources/bin/hiddeninput.exe b/vendor/symfony/console/Symfony/Component/Console/Resources/bin/hiddeninput.exe old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Shell.php b/vendor/symfony/console/Symfony/Component/Console/Shell.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tester/ApplicationTester.php b/vendor/symfony/console/Symfony/Component/Console/Tester/ApplicationTester.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php b/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php old mode 100755 new mode 100644 index 23dae245d3..02715b00e3 --- a/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php +++ b/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php @@ -14,6 +14,8 @@ namespace Symfony\Component\Console\Tester; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\StreamOutput; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * Eases the testing of console commands. diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/ApplicationTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/ApplicationTest.php old mode 100755 new mode 100644 index a557261144..e45464a177 --- a/vendor/symfony/console/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/ApplicationTest.php @@ -455,6 +455,9 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $tester->run(array('command' => 'foo3:bar'), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); + $tester->run(array('command' => 'foo3:bar'), array('decorated' => true)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); + $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); $application->setAutoExit(false); $application->expects($this->any()) diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Command/CommandTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/CommandTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Command/HelpCommandTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/HelpCommandTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/ListCommandTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication1.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication1.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand1.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand1.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand2.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand2.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php old mode 100755 new mode 100644 index 7349bc355e..43a35076e3 --- a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php @@ -17,9 +17,13 @@ class Foo3Command extends Command protected function execute(InputInterface $input, OutputInterface $output) { try { - throw new \Exception("First exception"); + try { + throw new \Exception("First exception

this is html

"); + } catch (\Exception $e) { + throw new \Exception("Second exception comment", 0, $e); + } } catch (\Exception $e) { - throw new \Exception("Second exception", 0, $e); + throw new \Exception("Third exception comment", 0, $e); } } } diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/FooCommand.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/FooCommand.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/TestCommand.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/TestCommand.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_gethelp.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_gethelp.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt old mode 100755 new mode 100644 index c639924238..72a72867f3 --- a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt @@ -1,17 +1,25 @@ - - [Exception] - Second exception - + + [Exception] + Third exception comment + - - [Exception] - First exception - + + [Exception] + Second exception comment + + + + + + + [Exception] + First exception

this is html

+ foo3:bar diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt new file mode 100644 index 0000000000..eb4181c2b4 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt @@ -0,0 +1,27 @@ + + +  + [Exception]  + Third exception comment  +  + + + + +  + [Exception]  + Second exception comment  +  + + + + +  + [Exception]  + First exception 

this is html

 +  + + +foo3:bar + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run3.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run4.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run4.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_astext.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_astext.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_astext.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_astext.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_asxml.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_asxml.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.txt old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.xml old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php old mode 100755 new mode 100644 index 497630e87c..08bd02e852 --- a/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -113,7 +113,10 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase $this->assertEquals($style, $formatter->getStyle('test')); $this->assertNotEquals($style, $formatter->getStyle('info')); - $this->assertEquals("\033[34;47msome custom msg\033[0m", $formatter->format('some custom msg')); + $style = new OutputFormatterStyle('blue', 'white'); + $formatter->setStyle('b', $style); + + $this->assertEquals("\033[34;47msome \033[0m\033[34;47mcustom\033[0m\033[34;47m msg\033[0m", $formatter->format('some custom msg')); } public function testRedefineStyle() @@ -137,7 +140,7 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase public function testNonStyleTag() { $formatter = new OutputFormatter(true); - $this->assertEquals("\033[32msome \033[0m\033[32m styled\033[0m", $formatter->format('some styled')); + $this->assertEquals("\033[32msome \033[0m\033[32m styled \033[0m\033[32m

single-char tag\033[0m\033[32m

\033[0m", $formatter->format('some styled

single-char tag

')); } public function testNotDecoratedFormatter() diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php old mode 100755 new mode 100644 index 108f709bf4..118cc44dbb --- a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php @@ -94,6 +94,9 @@ class DialogHelperTest extends \PHPUnit_Framework_TestCase $this->assertEquals('FooBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); } + /** + * @group tty + */ public function testAskHiddenResponse() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/HelperSetTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php old mode 100755 new mode 100644 index 9f8ced1e00..266cc3d1c3 --- a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php @@ -136,6 +136,21 @@ class ProgressHelperTest extends \PHPUnit_Framework_TestCase $progress->setCurrent(10); } + public function testRedrawFrequency() + { + $progress = $this->getMock('Symfony\Component\Console\Helper\ProgressHelper', array('display')); + $progress->expects($this->exactly(4)) + ->method('display'); + + $progress->setRedrawFrequency(2); + + $progress->start($output = $this->getOutputStream(), 6); + $progress->setCurrent(1); + $progress->advance(2); + $progress->advance(2); + $progress->advance(1); + } + public function testMultiByteSupport() { if (!function_exists('mb_strlen') || (false === $encoding = mb_detect_encoding('■'))) { diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/TableHelperTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArgvInputTest.php old mode 100755 new mode 100644 index c6ad757e23..507990d2cf --- a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -273,6 +273,9 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase $input = new ArgvInput(array('cli.php', 'foo')); $this->assertFalse($input->hasParameterOption('--foo'), '->hasParameterOption() returns false if the given short option is not in the raw input'); + + $input = new ArgvInput(array('cli.php', '--foo=bar')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given option with provided value is in the raw input'); } public function testToString() @@ -300,6 +303,14 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase array(array('app/console', 'foo:bar', '--env=dev'), '--env', 'dev'), array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), 'dev'), array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), 'dev'), + array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), '1'), ); } + + public function testParseSingleDashAsArgument() + { + $input = new ArgvInput(array('cli.php', '-')); + $input->bind(new InputDefinition(array(new InputArgument('file')))); + $this->assertEquals(array('file' => '-'), $input->getArguments(), '->parse() parses single dash as an argument'); + } } diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArrayInputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArrayInputTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputArgumentTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputArgumentTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputOptionTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/StringInputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/StringInputTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Output/NullOutputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/NullOutputTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Output/OutputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/OutputTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Output/StreamOutputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/StreamOutputTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/composer.json b/vendor/symfony/console/Symfony/Component/Console/composer.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/console/Symfony/Component/Console/phpunit.xml.dist b/vendor/symfony/console/Symfony/Component/Console/phpunit.xml.dist old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore b/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md b/vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php old mode 100755 new mode 100644 index f77545db95..7409ebfe2c --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php @@ -71,7 +71,7 @@ class Escaper */ public static function requiresSingleQuoting($value) { - return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value); + return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value); } /** diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ExceptionInterface.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ExceptionInterface.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php old mode 100755 new mode 100644 index a27a005e6f..938097b8b3 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php @@ -11,6 +11,11 @@ namespace Symfony\Component\Yaml\Exception; +if (!defined('JSON_UNESCAPED_UNICODE')) { + define('JSON_UNESCAPED_SLASHES', 64); + define('JSON_UNESCAPED_UNICODE', 256); +} + /** * Exception class thrown when an error occurs during parsing. * @@ -32,9 +37,9 @@ class ParseException extends RuntimeException * @param integer $parsedLine The line where the error occurred * @param integer $snippet The snippet of code near the problem * @param string $parsedFile The file name where the error occurred - * @param Exception $previous The previous exception + * @param \Exception $previous The previous exception */ - public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, Exception $previous = null) + public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null) { $this->parsedFile = $parsedFile; $this->parsedLine = $parsedLine; @@ -125,7 +130,7 @@ class ParseException extends RuntimeException } if (null !== $this->parsedFile) { - $this->message .= sprintf(' in %s', json_encode($this->parsedFile)); + $this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } if ($this->parsedLine >= 0) { diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE b/vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php old mode 100755 new mode 100644 index 4905e71ac9..d852cbf9bc --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php @@ -19,6 +19,8 @@ use Symfony\Component\Yaml\Exception\ParseException; */ class Parser { + const FOLDED_SCALAR_PATTERN = '(?P\||>)(?P\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P +#.*)?'; + private $offset = 0; private $lines = array(); private $currentLineNb = -1; @@ -111,7 +113,7 @@ class Parser $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } - } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values)) { + } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'],' #')) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence'); } @@ -304,10 +306,15 @@ class Parser $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); - // We are in string block (ie. after a line ending with "|") - $removeComments = !preg_match('~(.*)\|[\s]*$~', $this->currentLine); + // Comments must not be removed inside a string block (ie. after a line ending with "|") + $removeCommentsPattern = '~'.self::FOLDED_SCALAR_PATTERN.'$~'; + $removeComments = !preg_match($removeCommentsPattern, $this->currentLine); while ($this->moveToNextLine()) { + if ($this->getCurrentLineIndentation() === $newIndent) { + $removeComments = !preg_match($removeCommentsPattern, $this->currentLine); + } + if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { $this->moveToPreviousLine(); break; @@ -391,7 +398,7 @@ class Parser return $this->refs[$value]; } - if (preg_match('/^(?P\||>)(?P\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P +#.*)?$/', $value, $matches)) { + if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) { $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/README.md b/vendor/symfony/yaml/Symfony/Component/Yaml/README.md old mode 100755 new mode 100644 index 0864e49dca..941a3460e3 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/README.md +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/README.md @@ -15,5 +15,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/Yaml/ - $ composer.phar install --dev + $ composer.phar install $ phpunit diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsAnchorAlias.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsAnchorAlias.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBlockMapping.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBlockMapping.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsErrorTests.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsErrorTests.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFlowCollections.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFlowCollections.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFoldedScalars.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFoldedScalars.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsNullsAndEmpties.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsNullsAndEmpties.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/index.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/index.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml old mode 100755 new mode 100644 index 34225e11e0..46addfcd3d --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml @@ -49,3 +49,17 @@ yaml: | foo: bar # a comment php: | array('foo' => 'bar') +--- +test: Comment containing a colon on a hash line +brief: > + Comment containing a colon on a scalar line +yaml: 'foo # comment: this is also part of the comment' +php: | + 'foo' +--- +test: 'Hash key containing a #' +brief: > + 'Hash key containing a #' +yaml: 'foo#bar: baz' +php: | + array('foo#bar' => 'baz') diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfCompact.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfCompact.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfObjects.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfObjects.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfQuotes.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfQuotes.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php old mode 100755 new mode 100644 index a93b91612d..af5018f202 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Yaml\Tests; -use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Inline; class InlineTest extends \PHPUnit_Framework_TestCase @@ -31,11 +30,11 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml)); } - foreach ($this->getTestsForParse() as $yaml => $value) { + foreach ($this->getTestsForParse() as $value) { $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); } - foreach ($testsForDump as $yaml => $value) { + foreach ($testsForDump as $value) { $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); } } @@ -205,6 +204,9 @@ class InlineTest extends \PHPUnit_Framework_TestCase "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', + "'-dash'" => '-dash', + "'-'" => '-', + // sequences '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php new file mode 100644 index 0000000000..289965e8d9 --- /dev/null +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Tests; + +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class ParseExceptionTest extends \PHPUnit_Framework_TestCase +{ + public function testGetMessage() + { + $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml'); + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")'; + } else { + $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")'; + } + + $this->assertEquals($message, $exception->getMessage()); + } +} diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php old mode 100755 new mode 100644 index a74bd3ee87..c7d3b071e6 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php @@ -551,7 +551,7 @@ EOF )); } - public function testNestedStringBlockWithComments() + public function testFoldedStringBlockWithComments() { $this->assertEquals(array(array('content' => << footer # comment3 +EOF + )); + } + + public function testNestedFoldedStringBlockWithComments() + { + $this->assertEquals(array(array( + 'title' => 'some title', + 'content' => << +

title

+ + +footer # comment3 +EOT + )), Yaml::parse(<< +

title

+ + + footer # comment3 EOF )); } diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php old mode 100755 new mode 100644 index 708f2a18f2..ac3a576b67 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php @@ -130,7 +130,7 @@ class Unescaper * * @return string The string with the new encoding * - * @throws RuntimeException if no suitable encoding function is found (iconv or mbstring) + * @throws \RuntimeException if no suitable encoding function is found (iconv or mbstring) */ private function convertEncoding($value, $to, $from) { @@ -140,6 +140,6 @@ class Unescaper return iconv($from, $to, $value); } - throw new RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); + throw new \RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); } } diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json b/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json old mode 100755 new mode 100644 diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist b/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist old mode 100755 new mode 100644