Skip to content

Commit f37eb40

Browse files
committed
remove phpunit 9.0 deprecations
1 parent 2b1ec11 commit f37eb40

22 files changed

+46
-74
lines changed

tests/Unit/Aggregation/Bucketing/ChildrenAggregationTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class ChildrenAggregationTest extends \PHPUnit\Framework\TestCase
2020
{
2121
/**
2222
* Tests if ChildrenAggregation#getArray throws exception when expected.
23-
*
24-
* @expectedException \LogicException
2523
*/
2624
public function testGetArrayException()
2725
{
26+
$this->expectException(\LogicException::class);
2827
$aggregation = new ChildrenAggregation('foo');
2928
$aggregation->getArray();
3029
}

tests/Unit/Aggregation/Bucketing/DateHistogramAggregationTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class DateHistogramAggregationTest extends \PHPUnit\Framework\TestCase
2020
{
2121
/**
2222
* Tests if ChildrenAggregation#getArray throws exception when expected.
23-
*
24-
* @expectedException \LogicException
2523
*/
2624
public function testGetArrayException()
2725
{
26+
$this->expectException(\LogicException::class);
2827
$aggregation = new DateHistogramAggregation('foo');
2928
$aggregation->getArray();
3029
}

tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,22 @@ class DateRangeAggregationTest extends \PHPUnit\Framework\TestCase
1717
{
1818
/**
1919
* Test if exception is thrown.
20-
*
21-
* @expectedException \LogicException
22-
* @expectedExceptionMessage Date range aggregation must have field, format set and range added.
2320
*/
2421
public function testIfExceptionIsThrownWhenNoParametersAreSet()
2522
{
23+
$this->expectException(\LogicException::class);
24+
$this->expectExceptionMessage('Date range aggregation must have field, format set and range added.');
2625
$agg = new DateRangeAggregation('test_agg');
2726
$agg->getArray();
2827
}
2928

3029
/**
3130
* Test if exception is thrown when both range parameters are null.
32-
*
33-
* @expectedException \LogicException
34-
* @expectedExceptionMessage Either from or to must be set. Both cannot be null.
3531
*/
3632
public function testIfExceptionIsThrownWhenBothRangesAreNull()
3733
{
34+
$this->expectException(\LogicException::class);
35+
$this->expectExceptionMessage('Either from or to must be set. Both cannot be null.');
3836
$agg = new DateRangeAggregation('test_agg');
3937
$agg->addRange(null, null);
4038
}

tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,24 +101,22 @@ public function testToArray($aggregation, $expectedResult)
101101

102102
/**
103103
* Test for setField().
104-
*
105-
* @expectedException \LogicException
106-
* @expectedExceptionMessage doesn't support `field` parameter
107104
*/
108105
public function testSetField()
109106
{
107+
$this->expectException(\LogicException::class);
108+
$this->expectExceptionMessage('doesn\'t support `field` parameter');
110109
$aggregation = new FilterAggregation('test_agg');
111110
$aggregation->setField('test_field');
112111
}
113112

114113
/**
115114
* Test for toArray() without setting a filter.
116-
*
117-
* @expectedException \LogicException
118-
* @expectedExceptionMessage has no filter added
119115
*/
120116
public function testToArrayNoFilter()
121117
{
118+
$this->expectException(\LogicException::class);
119+
$this->expectExceptionMessage('has no filter added');
122120
$aggregation = new FilterAggregation('test_agg');
123121
$result = $aggregation->toArray();
124122

tests/Unit/Aggregation/Bucketing/FiltersAggregationTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ class FiltersAggregationTest extends \PHPUnit\Framework\TestCase
2121
{
2222
/**
2323
* Test if exception is thrown when not anonymous filter is without name.
24-
*
25-
* @expectedException \LogicException
26-
* @expectedExceptionMessage In not anonymous filters filter name must be set.
2724
*/
2825
public function testIfExceptionIsThrown()
2926
{
27+
$this->expectException(\LogicException::class);
28+
$this->expectExceptionMessage('In not anonymous filters filter name must be set.');
3029
$mock = $this->getMockBuilder('ONGR\ElasticsearchDSL\BuilderInterface')->getMock();
3130
$aggregation = new FiltersAggregation('test_agg');
3231
$aggregation->addFilter($mock);

tests/Unit/Aggregation/Bucketing/GeoDistanceAggregationTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,35 @@ class GeoDistanceAggregationTest extends \PHPUnit\Framework\TestCase
1717
{
1818
/**
1919
* Test if exception is thrown when field is not set.
20-
*
21-
* @expectedException \LogicException
22-
* @expectedExceptionMessage Geo distance aggregation must have a field set.
2320
*/
2421
public function testGeoDistanceAggregationExceptionWhenFieldIsNotSet()
2522
{
23+
$this->expectException(\LogicException::class);
24+
$this->expectExceptionMessage('Geo distance aggregation must have a field set.');
2625
$agg = new GeoDistanceAggregation('test_agg');
2726
$agg->setOrigin('50, 70');
2827
$agg->getArray();
2928
}
3029

3130
/**
3231
* Test if exception is thrown when origin is not set.
33-
*
34-
* @expectedException \LogicException
35-
* @expectedExceptionMessage Geo distance aggregation must have an origin set.
3632
*/
3733
public function testGeoDistanceAggregationExceptionWhenOriginIsNotSet()
3834
{
35+
$this->expectException(\LogicException::class);
36+
$this->expectExceptionMessage('Geo distance aggregation must have an origin set.');
3937
$agg = new GeoDistanceAggregation('test_agg');
4038
$agg->setField('location');
4139
$agg->getArray();
4240
}
4341

4442
/**
4543
* Test if exception is thrown when field is not set.
46-
*
47-
* @expectedException \LogicException
48-
* @expectedExceptionMessage Either from or to must be set. Both cannot be null.
4944
*/
5045
public function testGeoDistanceAggregationAddRangeException()
5146
{
47+
$this->expectException(\LogicException::class);
48+
$this->expectExceptionMessage('Either from or to must be set. Both cannot be null.');
5249
$agg = new GeoDistanceAggregation('test_agg');
5350
$agg->addRange();
5451
}

tests/Unit/Aggregation/Bucketing/GeoHashGridAggregationTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class GeoHashGridAggregationTest extends \PHPUnit\Framework\TestCase
2020
{
2121
/**
2222
* Test if exception is thrown.
23-
*
24-
* @expectedException \LogicException
2523
*/
2624
public function testGeoHashGridAggregationException()
2725
{
26+
$this->expectException(\LogicException::class);
2827
$agg = new GeoHashGridAggregation('test_agg');
2928
$agg->getArray();
3029
}

tests/Unit/Aggregation/Bucketing/GlobalAggregationTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ public function testToArray($aggregation, $expectedResult)
7474

7575
/**
7676
* Test for setField method on global aggregation.
77-
*
78-
* @expectedException \LogicException
7977
*/
8078
public function testSetField()
8179
{
80+
$this->expectException(\LogicException::class);
8281
$aggregation = new GlobalAggregation('test_agg');
8382
$aggregation->setField('test_field');
8483
}

tests/Unit/Aggregation/Bucketing/Ipv4RangeAggregationTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ class Ipv4RangeAggregationTest extends \PHPUnit\Framework\TestCase
1717
{
1818
/**
1919
* Test exception when field and range are not set.
20-
*
21-
* @expectedException \LogicException
2220
*/
2321
public function testIfExceptionIsThrownWhenFieldAndRangeAreNotSet()
2422
{
23+
$this->expectException(\LogicException::class);
2524
$agg = new Ipv4RangeAggregation('foo');
2625
$agg->toArray();
2726
}

tests/Unit/Aggregation/Bucketing/MissingAggregationTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ class MissingAggregationTest extends \PHPUnit\Framework\TestCase
1717
{
1818
/**
1919
* Test if exception is thrown when field is not set.
20-
*
21-
* @expectedException \LogicException
22-
* @expectedExceptionMessage Missing aggregation must have a field set.
2320
*/
2421
public function testIfExceptionIsThrown()
2522
{
23+
$this->expectException(\LogicException::class);
24+
$this->expectExceptionMessage('Missing aggregation must have a field set.');
2625
$agg = new MissingAggregation('test_agg');
2726
$agg->getArray();
2827
}

0 commit comments

Comments
 (0)