~ubuntu-branches/ubuntu/wily/php-doctrine-common/wily-proposed

« back to all changes in this revision

Viewing changes to tests/Doctrine/Tests/Common/Proxy/LazyLoadableObjectClassMetadata.php

  • Committer: Package Import Robot
  • Author(s): David Prévot
  • Date: 2014-06-15 11:26:00 UTC
  • mfrom: (2.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140615112600-sg4mgpwq9sfg4mre
Tags: 2.4.2-2
* Upload to unstable
* No tests if DEB_BUILD_OPTIONS contains nocheck

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
14
 *
 
15
 * This software consists of voluntary contributions made by many individuals
 
16
 * and is licensed under the MIT license. For more information, see
 
17
 * <http://www.doctrine-project.org>.
 
18
 */
 
19
 
 
20
namespace Doctrine\Tests\Common\Proxy;
 
21
 
 
22
use ReflectionClass;
 
23
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
 
24
 
 
25
/**
 
26
 * Class metadata test asset for @see LazyLoadableObject
 
27
 *
 
28
 * @author Marco Pivetta <ocramius@gmail.com>
 
29
 * @since  2.4
 
30
 */
 
31
class LazyLoadableObjectClassMetadata implements ClassMetadata
 
32
{
 
33
    /**
 
34
     * @var ReflectionClass
 
35
     */
 
36
    protected $reflectionClass;
 
37
 
 
38
    /**
 
39
     * @var array
 
40
     */
 
41
    protected $identifier = array(
 
42
        'publicIdentifierField'    => true,
 
43
        'protectedIdentifierField' => true,
 
44
    );
 
45
 
 
46
    /**
 
47
     * @var array
 
48
     */
 
49
    protected $fields = array(
 
50
        'publicIdentifierField'    => true,
 
51
        'protectedIdentifierField' => true,
 
52
        'publicPersistentField'    => true,
 
53
        'protectedPersistentField' => true,
 
54
    );
 
55
 
 
56
    /**
 
57
     * @var array
 
58
     */
 
59
    protected $associations = array(
 
60
        'publicAssociation'        => true,
 
61
        'protectedAssociation'     => true,
 
62
    );
 
63
 
 
64
    /**
 
65
     * {@inheritDoc}
 
66
     */
 
67
    public function getName()
 
68
    {
 
69
        return $this->getReflectionClass()->getName();
 
70
    }
 
71
 
 
72
    /**
 
73
     * {@inheritDoc}
 
74
     */
 
75
    public function getIdentifier()
 
76
    {
 
77
        return array_keys($this->identifier);
 
78
    }
 
79
 
 
80
    /**
 
81
     * {@inheritDoc}
 
82
     */
 
83
    public function getReflectionClass()
 
84
    {
 
85
        if (null === $this->reflectionClass) {
 
86
            $this->reflectionClass = new \ReflectionClass(__NAMESPACE__ . '\LazyLoadableObject');
 
87
        }
 
88
 
 
89
        return $this->reflectionClass;
 
90
    }
 
91
 
 
92
    /**
 
93
     * {@inheritDoc}
 
94
     */
 
95
    public function isIdentifier($fieldName)
 
96
    {
 
97
        return isset($this->identifier[$fieldName]);
 
98
    }
 
99
 
 
100
    /**
 
101
     * {@inheritDoc}
 
102
     */
 
103
    public function hasField($fieldName)
 
104
    {
 
105
        return isset($this->fields[$fieldName]);
 
106
    }
 
107
 
 
108
    /**
 
109
     * {@inheritDoc}
 
110
     */
 
111
    public function hasAssociation($fieldName)
 
112
    {
 
113
        return isset($this->associations[$fieldName]);
 
114
    }
 
115
 
 
116
    /**
 
117
     * {@inheritDoc}
 
118
     */
 
119
    public function isSingleValuedAssociation($fieldName)
 
120
    {
 
121
        throw new \BadMethodCallException('not implemented');
 
122
    }
 
123
 
 
124
    /**
 
125
     * {@inheritDoc}
 
126
     */
 
127
    public function isCollectionValuedAssociation($fieldName)
 
128
    {
 
129
        throw new \BadMethodCallException('not implemented');
 
130
    }
 
131
 
 
132
    /**
 
133
     * {@inheritDoc}
 
134
     */
 
135
    public function getFieldNames()
 
136
    {
 
137
        return array_keys($this->fields);
 
138
    }
 
139
 
 
140
    /**
 
141
     * {@inheritDoc}
 
142
     */
 
143
    public function getIdentifierFieldNames()
 
144
    {
 
145
        return $this->getIdentifier();
 
146
    }
 
147
 
 
148
    /**
 
149
     * {@inheritDoc}
 
150
     */
 
151
    public function getAssociationNames()
 
152
    {
 
153
        return array_keys($this->associations);
 
154
    }
 
155
 
 
156
    /**
 
157
     * {@inheritDoc}
 
158
     */
 
159
    public function getTypeOfField($fieldName)
 
160
    {
 
161
        return 'string';
 
162
    }
 
163
 
 
164
    /**
 
165
     * {@inheritDoc}
 
166
     */
 
167
    public function getAssociationTargetClass($assocName)
 
168
    {
 
169
        throw new \BadMethodCallException('not implemented');
 
170
    }
 
171
 
 
172
    /**
 
173
     * {@inheritDoc}
 
174
     */
 
175
    public function isAssociationInverseSide($assocName)
 
176
    {
 
177
        throw new \BadMethodCallException('not implemented');
 
178
    }
 
179
 
 
180
    /**
 
181
     * {@inheritDoc}
 
182
     */
 
183
    public function getAssociationMappedByTargetField($assocName)
 
184
    {
 
185
        throw new \BadMethodCallException('not implemented');
 
186
    }
 
187
 
 
188
    /**
 
189
     * {@inheritDoc}
 
190
     */
 
191
    public function getIdentifierValues($object)
 
192
    {
 
193
        throw new \BadMethodCallException('not implemented');
 
194
    }
 
195
}