Skip to content

Commit 3b780c1

Browse files
committed
bump PHP requirement now to atleast 7.1 .. fix failing tests due to phpunit version 7+ needs php version 7.1+ and require return types on test cases
1 parent 5c99a0d commit 3b780c1

10 files changed

+26
-31
lines changed

.phpunit.result.cache

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:37:"PHPUnit\Runner\DefaultTestResultCache":4952:{a:2:{s:7:"defects";a:7:{s:71:"CartConditionTest::test_add_cart_condition_without_condition_attributes";i:6;s:68:"CartConditionTest::test_add_cart_condition_with_condition_attributes";i:6;s:65:"CartTest::test_item_price_should_be_normalized_when_added_to_cart";i:6;s:79:"CartTest::test_should_throw_exception_when_provided_invalid_values_scenario_one";i:6;s:79:"CartTest::test_should_throw_exception_when_provided_invalid_values_scenario_two";i:6;s:81:"CartTest::test_should_throw_exception_when_provided_invalid_values_scenario_three";i:4;s:38:"CartTest::test_cart_get_total_quantity";i:6;}s:5:"times";a:61:{s:32:"CartConditionTest::test_subtotal";d:0.025;s:47:"CartConditionTest::test_total_without_condition";d:0.001;s:44:"CartConditionTest::test_total_with_condition";d:0.001;s:73:"CartConditionTest::test_total_with_multiple_conditions_added_scenario_one";d:0.001;s:73:"CartConditionTest::test_total_with_multiple_conditions_added_scenario_two";d:0.001;s:75:"CartConditionTest::test_total_with_multiple_conditions_added_scenario_three";d:0.001;s:75:"CartConditionTest::test_cart_multiple_conditions_can_be_added_once_by_array";d:0.001;s:74:"CartConditionTest::test_total_with_multiple_conditions_added_scenario_four";d:0.001;s:47:"CartConditionTest::test_add_item_with_condition";d:0;s:93:"CartConditionTest::test_add_item_with_multiple_item_conditions_in_multiple_condition_instance";d:0;s:82:"CartConditionTest::test_add_item_with_multiple_item_conditions_with_target_omitted";d:0;s:42:"CartConditionTest::test_add_item_condition";d:0.001;s:66:"CartConditionTest::test_add_item_condition_restrict_negative_price";d:0;s:60:"CartConditionTest::test_get_cart_condition_by_condition_name";d:0;s:63:"CartConditionTest::test_remove_cart_condition_by_condition_name";d:0;s:63:"CartConditionTest::test_remove_item_condition_by_condition_name";d:0;s:76:"CartConditionTest::test_remove_item_condition_by_condition_name_scenario_two";d:0.001;s:45:"CartConditionTest::test_clear_item_conditions";d:0;s:45:"CartConditionTest::test_clear_cart_conditions";d:0;s:59:"CartConditionTest::test_get_calculated_value_of_a_condition";d:0;s:46:"CartConditionTest::test_get_conditions_by_type";d:0;s:49:"CartConditionTest::test_remove_conditions_by_type";d:0;s:71:"CartConditionTest::test_add_cart_condition_without_condition_attributes";d:0.001;s:68:"CartConditionTest::test_add_cart_condition_with_condition_attributes";d:0.001;s:48:"CartConditionTest::test_get_order_from_condition";d:0;s:42:"CartConditionTest::test_condition_ordering";d:0.001;s:32:"CartTest::test_cart_can_add_item";d:0.001;s:42:"CartTest::test_cart_can_add_items_as_array";d:0;s:61:"CartTest::test_cart_can_add_items_with_multidimensional_array";d:0.001;s:51:"CartTest::test_cart_can_add_item_without_attributes";d:0;s:109:"CartTest::test_cart_update_with_attribute_then_attributes_should_be_still_instance_of_ItemAttributeCollection";d:0.001;s:36:"CartTest::test_cart_items_attributes";d:0;s:40:"CartTest::test_cart_update_existing_item";d:0;s:80:"CartTest::test_cart_update_existing_item_with_quantity_as_array_and_not_relative";d:0;s:65:"CartTest::test_item_price_should_be_normalized_when_added_to_cart";d:0;s:52:"CartTest::test_it_removes_an_item_on_cart_by_item_id";d:0.001;s:29:"CartTest::test_cart_sub_total";d:0.001;s:54:"CartTest::test_sub_total_when_item_quantity_is_updated";d:0.001;s:65:"CartTest::test_sub_total_when_item_quantity_is_updated_by_reduced";d:0;s:96:"CartTest::test_item_quantity_update_by_reduced_should_not_reduce_if_quantity_will_result_to_zero";d:0;s:79:"CartTest::test_should_throw_exception_when_provided_invalid_values_scenario_one";d:0.001;s:79:"CartTest::test_should_throw_exception_when_provided_invalid_values_scenario_two";d:0;s:81:"CartTest::test_should_throw_exception_when_provided_invalid_values_scenario_three";d:0;s:28:"CartTest::test_clearing_cart";d:0;s:38:"CartTest::test_cart_get_total_quantity";d:0;s:39:"CartTestEvents::test_event_cart_created";d:0.001;s:38:"CartTestEvents::test_event_cart_adding";d:0.002;s:53:"CartTestEvents::test_event_cart_adding_multiple_times";d:0.001;s:66:"CartTestEvents::test_event_cart_adding_multiple_times_scenario_two";d:0.001;s:43:"CartTestEvents::test_event_cart_remove_item";d:0.001;s:37:"CartTestEvents::test_event_cart_clear";d:0.001;s:55:"CartTestMultipleInstances::test_cart_multiple_instances";d:0.001;s:40:"CartTestOtherFormat::test_cart_sub_total";d:0.001;s:65:"CartTestOtherFormat::test_sub_total_when_item_quantity_is_updated";d:0;s:76:"CartTestOtherFormat::test_sub_total_when_item_quantity_is_updated_by_reduced";d:0;s:48:"ItemTest::test_item_get_sum_price_using_property";d:0;s:51:"ItemTest::test_item_get_sum_price_using_array_style";d:0;s:40:"ItemTest::test_item_get_conditions_empty";d:0;s:50:"ItemTest::test_item_get_conditions_with_conditions";d:0;s:59:"ItemTestOtherFormat::test_item_get_sum_price_using_property";d:0;s:62:"ItemTestOtherFormat::test_item_get_sum_price_using_array_style";d:0;}}}

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
64
- 7.1
75
- 7.2
6+
- 7.3
7+
- 7.4
88

99
before_script:
1010
- travis_retry composer self-update

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.4.0",
13+
"php": ">=7.1",
1414
"illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0",
1515
"illuminate/validation": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0",
1616
"illuminate/translation": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0"
1717
},
1818
"require-dev": {
1919
"mockery/mockery": "^1.0",
20-
"phpunit/phpunit": "^5.0",
20+
"phpunit/phpunit": "^8.0.0",
2121
"symfony/var-dumper": "2.7.*@dev"
2222
},
2323
"autoload": {

tests/CartConditionsTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CartConditionTest extends PHPUnit\Framework\TestCase {
1919
*/
2020
protected $cart;
2121

22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
$events = m::mock('Illuminate\Contracts\Events\Dispatcher');
2525
$events->shouldReceive('dispatch');
@@ -33,7 +33,7 @@ public function setUp()
3333
);
3434
}
3535

36-
public function tearDown()
36+
public function tearDown(): void
3737
{
3838
m::close();
3939
}
@@ -770,7 +770,7 @@ public function test_add_cart_condition_without_condition_attributes()
770770
// when get attribute is called and there is no attributes added,
771771
// it should return an empty array
772772
$conditionAttribute = $contition->getAttributes();
773-
$this->assertInternalType('array', $conditionAttribute);
773+
$this->assertIsArray($conditionAttribute);
774774
}
775775

776776
public function test_add_cart_condition_with_condition_attributes()
@@ -806,7 +806,7 @@ public function test_add_cart_condition_with_condition_attributes()
806806
// when get attribute is called and there is no attributes added,
807807
// it should return an empty array
808808
$conditionAttributes = $contition->getAttributes();
809-
$this->assertInternalType('array', $conditionAttributes);
809+
$this->assertIsArray($conditionAttributes);
810810
$this->assertArrayHasKey('description',$conditionAttributes);
811811
$this->assertArrayHasKey('sale_start_date',$conditionAttributes);
812812
$this->assertArrayHasKey('sale_end_date',$conditionAttributes);

tests/CartTest.php

+7-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CartTest extends PHPUnit\Framework\TestCase {
1818
*/
1919
protected $cart;
2020

21-
public function setUp()
21+
public function setUp(): void
2222
{
2323
$events = m::mock('Illuminate\Contracts\Events\Dispatcher');
2424
$events->shouldReceive('dispatch');
@@ -32,7 +32,7 @@ public function setUp()
3232
);
3333
}
3434

35-
public function tearDown()
35+
public function tearDown(): void
3636
{
3737
m::close();
3838
}
@@ -242,7 +242,7 @@ public function test_item_price_should_be_normalized_when_added_to_cart()
242242
// add a price in a string format should be converted to float
243243
$this->cart->add(455, 'Sample Item', '100.99', 2, array());
244244

245-
$this->assertInternalType('float',$this->cart->getContent()->first()['price'], 'Cart price should be a float');
245+
$this->assertIsFloat($this->cart->getContent()->first()['price'], 'Cart price should be a float');
246246
}
247247

248248
public function test_it_removes_an_item_on_cart_by_item_id()
@@ -413,27 +413,21 @@ public function test_item_quantity_update_by_reduced_should_not_reduce_if_quanti
413413
$this->assertEquals(3, $item['quantity'], 'Item quantity of with item ID of 456 should now be reduced to 2');
414414
}
415415

416-
/**
417-
* @expectedException Darryldecode\Cart\Exceptions\InvalidItemException
418-
*/
419416
public function test_should_throw_exception_when_provided_invalid_values_scenario_one()
420417
{
418+
$this->expectException('Darryldecode\Cart\Exceptions\InvalidItemException');
421419
$this->cart->add(455, 'Sample Item', 100.99, 0, array());
422420
}
423421

424-
/**
425-
* @expectedException Darryldecode\Cart\Exceptions\InvalidItemException
426-
*/
427422
public function test_should_throw_exception_when_provided_invalid_values_scenario_two()
428423
{
424+
$this->expectException('Darryldecode\Cart\Exceptions\InvalidItemException');
429425
$this->cart->add('', 'Sample Item', 100.99, 2, array());
430426
}
431427

432-
/**
433-
* @expectedException Darryldecode\Cart\Exceptions\InvalidItemException
434-
*/
435428
public function test_should_throw_exception_when_provided_invalid_values_scenario_three()
436429
{
430+
$this->expectException('Darryldecode\Cart\Exceptions\InvalidItemException');
437431
$this->cart->add(523, '', 100.99, 2, array());
438432
}
439433

@@ -490,7 +484,7 @@ public function test_cart_get_total_quantity()
490484
$this->assertFalse($this->cart->isEmpty(),'prove first cart is not empty');
491485

492486
// now let's count the cart's quantity
493-
$this->assertInternalType("int", $this->cart->getTotalQuantity(), 'Return type should be INT');
487+
$this->assertIsInt($this->cart->getTotalQuantity(), 'Return type should be INT');
494488
$this->assertEquals(4, $this->cart->getTotalQuantity(),'Cart\'s quantity should be 4.');
495489
}
496490
}

tests/CartTestEvents.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class CartTestEvents extends PHPUnit\Framework\TestCase {
1515

1616
const CART_INSTANCE_NAME = 'shopping';
1717

18-
public function setUp()
18+
public function setUp(): void
1919
{
2020
}
2121

22-
public function tearDown()
22+
public function tearDown(): void
2323
{
2424
m::close();
2525
}

tests/CartTestMultipleInstances.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CartTestMultipleInstances extends PHPUnit\Framework\TestCase {
2323
*/
2424
protected $cart2;
2525

26-
public function setUp()
26+
public function setUp(): void
2727
{
2828
$events = m::mock('Illuminate\Contracts\Events\Dispatcher');
2929
$events->shouldReceive('dispatch');
@@ -45,7 +45,7 @@ public function setUp()
4545
);
4646
}
4747

48-
public function tearDown()
48+
public function tearDown(): void
4949
{
5050
m::close();
5151
}

tests/CartTestOtherFormat.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CartTestOtherFormat extends PHPUnit\Framework\TestCase {
1818
*/
1919
protected $cart;
2020

21-
public function setUp()
21+
public function setUp(): void
2222
{
2323
$events = m::mock('Illuminate\Contracts\Events\Dispatcher');
2424
$events->shouldReceive('dispatch');
@@ -32,7 +32,7 @@ public function setUp()
3232
);
3333
}
3434

35-
public function tearDown()
35+
public function tearDown(): void
3636
{
3737
m::close();
3838
}

tests/ItemTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ItemTest extends PHPUnit\Framework\TestCase
2020
*/
2121
protected $cart;
2222

23-
public function setUp()
23+
public function setUp(): void
2424
{
2525
$events = m::mock('Illuminate\Contracts\Events\Dispatcher');
2626
$events->shouldReceive('dispatch');
@@ -34,7 +34,7 @@ public function setUp()
3434
);
3535
}
3636

37-
public function tearDown()
37+
public function tearDown(): void
3838
{
3939
m::close();
4040
}

tests/ItemTestOtherFormat.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ItemTestOtherFormat extends PHPUnit\Framework\TestCase
1919
*/
2020
protected $cart;
2121

22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
$events = m::mock('Illuminate\Contracts\Events\Dispatcher');
2525
$events->shouldReceive('dispatch');
@@ -33,7 +33,7 @@ public function setUp()
3333
);
3434
}
3535

36-
public function tearDown()
36+
public function tearDown(): void
3737
{
3838
m::close();
3939
}

0 commit comments

Comments
 (0)