Completed
Push — master ( 6ade00...71d837 )
by
unknown
03:56 queued 01:58
created

testGetIndexNameWithPrefixAndSuffixFromEnvironment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 9
rs 9.6666
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace SilverStripe\FullTextSearch\Tests;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\Core\Environment;
7
use SilverStripe\Core\Injector\Injector;
8
use SilverStripe\Core\Kernel;
9
use SilverStripe\Dev\SapphireTest;
10
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_AmbiguousRelationIndex;
11
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_AmbiguousRelationInheritedIndex;
12
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_FakeIndex;
13
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_FakeIndex2;
14
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_BoostedIndex;
15
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Container;
16
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasOne;
17
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasMany;
18
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_ManyMany;
19
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_OtherContainer;
20
use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
21
use SilverStripe\FullTextSearch\Solr\Services\Solr3Service;
22
23
class SolrIndexTest extends SapphireTest
24
{
25 View Code Duplication
    public function testFieldDataHasOne()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        $index = new SolrIndexTest_FakeIndex();
28
        $data = $index->fieldData('HasOneObject.Field1');
29
30
        $data = $data[SearchUpdaterTest_Container::class . '_HasOneObject_Field1'];
31
32
        $this->assertEquals(SearchUpdaterTest_Container::class, $data['origin']);
33
        $this->assertEquals(SearchUpdaterTest_Container::class, $data['base']);
34
        $this->assertEquals(SearchUpdaterTest_HasOne::class, $data['class']);
35
    }
36
37 View Code Duplication
    public function testFieldDataHasMany()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $index = new SolrIndexTest_FakeIndex();
40
        $data = $index->fieldData('HasManyObjects.Field1');
41
        $data = $data[SearchUpdaterTest_Container::class . '_HasManyObjects_Field1'];
42
43
        $this->assertEquals(SearchUpdaterTest_Container::class, $data['origin']);
44
        $this->assertEquals(SearchUpdaterTest_Container::class, $data['base']);
45
        $this->assertEquals(SearchUpdaterTest_HasMany::class, $data['class']);
46
    }
47
48 View Code Duplication
    public function testFieldDataManyMany()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $index = new SolrIndexTest_FakeIndex();
51
        $data = $index->fieldData('ManyManyObjects.Field1');
52
        $data = $data[SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1'];
53
54
        $this->assertEquals(SearchUpdaterTest_Container::class, $data['origin']);
55
        $this->assertEquals(SearchUpdaterTest_Container::class, $data['base']);
56
        $this->assertEquals(SearchUpdaterTest_ManyMany::class, $data['class']);
57
    }
58
59 View Code Duplication
    public function testFieldDataAmbiguousHasMany()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
    {
61
        $index = new SolrIndexTest_AmbiguousRelationIndex();
62
        $data = $index->fieldData('HasManyObjects.Field1');
63
64
        $this->assertArrayHasKey(SearchUpdaterTest_Container::class . '_HasManyObjects_Field1', $data);
65
        $this->assertArrayHasKey(SearchUpdaterTest_OtherContainer::class . '_HasManyObjects_Field1', $data);
66
67
        $dataContainer = $data[SearchUpdaterTest_Container::class . '_HasManyObjects_Field1'];
68
        $this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
69
        $this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
70
        $this->assertEquals(SearchUpdaterTest_HasMany::class, $dataContainer['class']);
71
72
        $dataOtherContainer = $data[SearchUpdaterTest_OtherContainer::class . '_HasManyObjects_Field1'];
73
        $this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
74
        $this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
75
        $this->assertEquals(SearchUpdaterTest_HasMany::class, $dataOtherContainer['class']);
76
    }
77
78 View Code Duplication
    public function testFieldDataAmbiguousManyMany()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
79
    {
80
        $index = new SolrIndexTest_AmbiguousRelationIndex();
81
        $data = $index->fieldData('ManyManyObjects.Field1');
82
83
        $this->assertArrayHasKey(SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1', $data);
84
        $this->assertArrayHasKey(SearchUpdaterTest_OtherContainer::class . '_ManyManyObjects_Field1', $data);
85
86
        $dataContainer = $data[SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1'];
87
        $this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
88
        $this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
89
        $this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataContainer['class']);
90
91
        $dataOtherContainer = $data[SearchUpdaterTest_OtherContainer::class . '_ManyManyObjects_Field1'];
92
        $this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
93
        $this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
94
        $this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataOtherContainer['class']);
95
    }
96
97 View Code Duplication
    public function testFieldDataAmbiguousManyManyInherited()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
    {
99
        $index = new SolrIndexTest_AmbiguousRelationInheritedIndex();
100
        $data = $index->fieldData('ManyManyObjects.Field1');
101
102
        $this->assertArrayHasKey(SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1', $data);
103
        $this->assertArrayHasKey(SearchUpdaterTest_OtherContainer::class . '_ManyManyObjects_Field1', $data);
104
        $this->assertArrayNotHasKey(SearchUpdaterTest_ExtendedContainer::class . '_ManyManyObjects_Field1', $data);
105
106
        $dataContainer = $data[SearchUpdaterTest_Container::class . '_ManyManyObjects_Field1'];
107
        $this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['origin']);
108
        $this->assertEquals(SearchUpdaterTest_Container::class, $dataContainer['base']);
109
        $this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataContainer['class']);
110
111
        $dataOtherContainer = $data[SearchUpdaterTest_OtherContainer::class . '_ManyManyObjects_Field1'];
112
        $this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['origin']);
113
        $this->assertEquals(SearchUpdaterTest_OtherContainer::class, $dataOtherContainer['base']);
114
        $this->assertEquals(SearchUpdaterTest_ManyMany::class, $dataOtherContainer['class']);
115
    }
116
117
    /**
118
     * Test boosting on SearchQuery
119
     */
120
    public function testBoostedQuery()
121
    {
122
        /** @var Solr3Service|PHPUnit_Framework_MockObject_MockObject $serviceMock */
123
        $serviceMock = $this->getMockBuilder(Solr3Service::class)
124
            ->setMethods(['search'])
125
            ->getMock();
126
127
        $serviceMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<SilverStripe\Full...\Services\Solr3Service>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
128
            ->method('search')
129
            ->with(
130
                $this->equalTo('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)'),
131
                $this->anything(),
132
                $this->anything(),
133
                $this->anything(),
134
                $this->anything()
135
            )->willReturn($this->getFakeRawSolrResponse());
136
137
        $index = new SolrIndexTest_FakeIndex();
138
        $index->setService($serviceMock);
139
140
        $query = new SearchQuery();
141
        $query->search(
142
            'term',
143
            null,
144
            array('Field1' => 1.5, 'HasOneObject_Field1' => 3)
145
        );
146
        $index->search($query);
147
    }
148
149
    /**
150
     * Test boosting on field schema (via queried fields parameter)
151
     */
152
    public function testBoostedField()
153
    {
154
        /** @var Solr3Service|PHPUnit_Framework_MockObject_MockObject $serviceMock */
155
        $serviceMock = $this->getMockBuilder(Solr3Service::class)
156
            ->setMethods(['search'])
157
            ->getMock();
158
159
        $serviceMock->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<SilverStripe\Full...\Services\Solr3Service>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
160
            ->method('search')
161
            ->with(
162
                $this->equalTo('+term'),
163
                $this->anything(),
164
                $this->anything(),
165
                $this->equalTo(['qf' => SearchUpdaterTest_Container::class . '_Field1^1.5 ' . SearchUpdaterTest_Container::class . '_Field2^2.1 _text',
166
                    'fq' => '+(_versionedstage:"" (*:* -_versionedstage:[* TO *]))']),
167
                $this->anything()
168
            )->willReturn($this->getFakeRawSolrResponse());
169
170
        $index = new SolrIndexTest_BoostedIndex();
171
        $index->setService($serviceMock);
172
173
        $query = new SearchQuery();
174
        $query->search('term');
175
        $index->search($query);
176
    }
177
178
    public function testHighlightQueryOnBoost()
179
    {
180
        /** @var SilverStripe\FullTextSearch\Solr\Services\Solr3Service|ObjectProphecy $serviceMock */
181
        $serviceMock = $this->getMockBuilder(Solr3Service::class)
182
            ->setMethods(['search'])
183
            ->getMock();
184
185
        $serviceMock->expects($this->exactly(2))
186
            ->method('search')
187
            ->withConsecutive(
188
                [
189
                    $this->equalTo('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)'),
190
                    $this->anything(),
191
                    $this->anything(),
192
                    $this->logicalNot(
193
                        $this->arrayHasKey('hl.q')
194
                    ),
195
                    $this->anything()
196
                ],
197
                [
198
                    $this->equalTo('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)'),
199
                    $this->anything(),
200
                    $this->anything(),
201
                    $this->arrayHasKey('hl.q'),
202
                    $this->anything()
203
                ]
204
            )->willReturn($this->getFakeRawSolrResponse());
205
206
        $index = new SolrIndexTest_FakeIndex();
207
        $index->setService($serviceMock);
208
209
        // Search without highlighting
210
        $query = new SearchQuery();
211
        $query->search(
212
            'term',
213
            null,
214
            array('Field1' => 1.5, 'HasOneObject_Field1' => 3)
215
        );
216
        $index->search($query);
217
218
        // Search with highlighting
219
        $query = new SearchQuery();
220
        $query->search(
221
            'term',
222
            null,
223
            array('Field1' => 1.5, 'HasOneObject_Field1' => 3)
224
        );
225
        $index->search($query, -1, -1, array('hl' => true));
226
    }
227
228
    public function testIndexExcludesNullValues()
229
    {
230
        /** @var Solr3Service|ObjectProphecy $serviceMock */
231
        $serviceMock = $this->createMock(Solr3Service::class);
232
        $index = new SolrIndexTest_FakeIndex();
233
        $index->setService($serviceMock);
234
        $obj = new SearchUpdaterTest_Container();
235
236
        $obj->Field1 = 'Field1 val';
0 ignored issues
show
Documentation introduced by
The property Field1 does not exist on object<SilverStripe\Full...hUpdaterTest_Container>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
237
        $obj->Field2 = null;
0 ignored issues
show
Documentation introduced by
The property Field2 does not exist on object<SilverStripe\Full...hUpdaterTest_Container>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
238
        $obj->MyDate = null;
0 ignored issues
show
Documentation introduced by
The property MyDate does not exist on object<SilverStripe\Full...hUpdaterTest_Container>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
239
        $docs = $index->add($obj);
240
        $value = $docs[0]->getField(SearchUpdaterTest_Container::class . '_Field1');
241
        $this->assertEquals('Field1 val', $value['value'], 'Writes non-NULL string fields');
242
        $value = $docs[0]->getField(SearchUpdaterTest_Container::class . '_Field2');
243
        $this->assertFalse($value, 'Ignores string fields if they are NULL');
244
        $value = $docs[0]->getField(SearchUpdaterTest_Container::class . '_MyDate');
245
        $this->assertFalse($value, 'Ignores date fields if they are NULL');
246
247
        $obj->MyDate = '2010-12-30';
0 ignored issues
show
Documentation introduced by
The property MyDate does not exist on object<SilverStripe\Full...hUpdaterTest_Container>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
248
        $docs = $index->add($obj);
249
        $value = $docs[0]->getField(SearchUpdaterTest_Container::class . '_MyDate');
250
        $this->assertEquals('2010-12-30T00:00:00Z', $value['value'], 'Writes non-NULL dates');
251
    }
252
253
    public function testAddFieldExtraOptions()
254
    {
255
        Injector::inst()->get(Kernel::class)->setEnvironment('live');
256
257
        $index = new SolrIndexTest_FakeIndex();
258
259
        $defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
260
        $defField1 = $defs->xpath('field[@name="' . SearchUpdaterTest_Container::class . '_Field1"]');
261
        $this->assertEquals((string)$defField1[0]['stored'], 'false');
262
263
        $index->addFilterField('Field1', null, array('stored' => 'true'));
264
        $defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
265
        $defField1 = $defs->xpath('field[@name="' . SearchUpdaterTest_Container::class . '_Field1"]');
266
        $this->assertEquals((string)$defField1[0]['stored'], 'true');
267
    }
268
269
    public function testAddAnalyzer()
270
    {
271
        $index = new SolrIndexTest_FakeIndex();
272
273
        $defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
274
        $defField1 = $defs->xpath('field[@name="' . SearchUpdaterTest_Container::class . '_Field1"]');
275
        $analyzers = $defField1[0]->analyzer;
276
        $this->assertFalse((bool)$analyzers);
277
278
        $index->addAnalyzer('Field1', 'charFilter', array('class' => 'solr.HTMLStripCharFilterFactory'));
279
        $defs = simplexml_load_string('<fields>' . $index->getFieldDefinitions() . '</fields>');
280
        $defField1 = $defs->xpath('field[@name="' . SearchUpdaterTest_Container::class . '_Field1"]');
281
        $analyzers = $defField1[0]->analyzer;
282
        $this->assertTrue((bool)$analyzers);
283
        $this->assertEquals('solr.HTMLStripCharFilterFactory', $analyzers[0]->charFilter[0]['class']);
284
    }
285
286
    public function testAddCopyField()
287
    {
288
        $index = new SolrIndexTest_FakeIndex();
289
        $index->addCopyField('sourceField', 'destField');
290
291
        $defs = simplexml_load_string('<fields>' . $index->getCopyFieldDefinitions() . '</fields>');
292
        $copyField = $defs->xpath('copyField');
293
294
        $this->assertEquals('sourceField', $copyField[0]['source']);
295
        $this->assertEquals('destField', $copyField[0]['dest']);
296
    }
297
298
    /**
299
     * Tests the setting of the 'stored' flag
300
     */
301
    public function testStoredFields()
302
    {
303
        // Test two fields
304
        $index = new SolrIndexTest_FakeIndex2();
305
        $index->addStoredField('Field1');
306
        $index->addFulltextField('Field2');
307
        $schema = $index->getFieldDefinitions();
308
        $this->assertContains(
309
            "<field name='" . SearchUpdaterTest_Container::class . "_Field1' type='text' indexed='true' stored='true'",
310
            $schema
311
        );
312
        $this->assertContains(
313
            "<field name='" . SearchUpdaterTest_Container::class . "_Field2' type='text' indexed='true' stored='false'",
314
            $schema
315
        );
316
317
        // Test with addAllFulltextFields
318
        $index2 = new SolrIndexTest_FakeIndex2();
319
        $index2->addAllFulltextFields();
320
        $index2->addStoredField('Field2');
321
        $schema2 = $index2->getFieldDefinitions();
322
        $this->assertContains(
323
            "<field name='" . SearchUpdaterTest_Container::class . "_Field1' type='text' indexed='true' stored='false'",
324
            $schema2
325
        );
326
        $this->assertContains(
327
            "<field name='" . SearchUpdaterTest_Container::class . "_Field2' type='text' indexed='true' stored='true'",
328
            $schema2
329
        );
330
    }
331
332
    public function testSanitiseClassName()
333
    {
334
        $index = new SolrIndexTest_FakeIndex2;
335
        $this->assertSame(
336
            'SilverStripe\\\\FullTextSearch\\\\Tests\\\\SolrIndexTest',
337
            $index->sanitiseClassName(static::class)
338
        );
339
    }
340
341
    public function testGetIndexName()
342
    {
343
        $index = new SolrIndexTest_FakeIndex2;
344
        $this->assertSame(SolrIndexTest_FakeIndex2::class, $index->getIndexName());
345
    }
346
347
    public function testGetIndexNameWithPrefixAndSuffixFromEnvironment()
348
    {
349
        $index = new SolrIndexTest_FakeIndex2;
350
351
        Environment::putEnv('SS_SOLR_INDEX_PREFIX="foo_"');
0 ignored issues
show
Bug introduced by
The method putEnv() does not seem to exist on object<SilverStripe\Core\Environment>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
352
        Environment::putEnv('SS_SOLR_INDEX_SUFFIX="_bar"');
0 ignored issues
show
Bug introduced by
The method putEnv() does not seem to exist on object<SilverStripe\Core\Environment>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
353
354
        $this->assertSame('foo_' . SolrIndexTest_FakeIndex2::class . '_bar', $index->getIndexName());
355
    }
356
357
    protected function getFakeRawSolrResponse()
358
    {
359
        return new \Apache_Solr_Response(
360
            new \Apache_Solr_HttpTransport_Response(
361
                null,
362
                null,
363
                '{}'
364
            )
365
        );
366
    }
367
}
368