This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class TableShippingMethodTest extends SapphireTest{ |
||
4 | |||
5 | static $fixture_file = array( |
||
6 | 'silvershop-shipping/tests/fixtures/TableShippingMethod.yml' |
||
7 | ); |
||
8 | |||
9 | protected $fixtureclass = "TableShippingMethod"; |
||
10 | |||
11 | public function setUp(){ |
||
12 | parent::setUp(); |
||
13 | $this->addressshipping = $this->objFromFixture($this->fixtureclass, "address"); |
||
0 ignored issues
–
show
|
|||
14 | $this->weightshipping = $this->objFromFixture($this->fixtureclass, "weight"); |
||
0 ignored issues
–
show
The property
weightshipping does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
15 | $this->volumeshipping = $this->objFromFixture($this->fixtureclass, "volume"); |
||
0 ignored issues
–
show
The property
volumeshipping does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
16 | $this->valueshipping = $this->objFromFixture($this->fixtureclass, "value"); |
||
0 ignored issues
–
show
The property
valueshipping does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
17 | $this->quantityshipping = $this->objFromFixture($this->fixtureclass, "quantity"); |
||
0 ignored issues
–
show
The property
quantityshipping does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
18 | |||
19 | $this->nzaddress = new Address(array( |
||
0 ignored issues
–
show
The property
nzaddress does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
20 | "Country" => "NZ", |
||
21 | "State" => "Wellington", |
||
22 | "PostalCode" => "6022" |
||
23 | )); |
||
24 | |||
25 | $this->internationaladdress = new Address(array( |
||
0 ignored issues
–
show
The property
internationaladdress does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
26 | "Company" => 'Nildram Ltd', |
||
27 | "Address" => 'Ardenham Court', |
||
28 | "Address2" => 'Oxford Road', |
||
29 | "City" => 'AYLESBURY', |
||
30 | "State" => 'BUCKINGHAMSHIRE', |
||
31 | "PostalCode" => 'HP19 3EQ', |
||
32 | "Country" => 'UK' |
||
33 | )); |
||
34 | |||
35 | //create some package fixtures |
||
36 | $this->p0 = new ShippingPackage(); |
||
0 ignored issues
–
show
The property
p0 does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
37 | $this->p1 = new ShippingPackage(2.34, array(0.5,1,2), array('value' => 2, 'quantity' => 3)); |
||
0 ignored issues
–
show
The property
p1 does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
38 | $this->p2 = new ShippingPackage(17, array(1,2,3), array('value' => 6, 'quantity' => 10)); |
||
0 ignored issues
–
show
The property
p2 does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
39 | $this->p3 = new ShippingPackage(100, array(12.33,51,30.1), array('value' => 1000, 'quantity' => 55)); |
||
0 ignored issues
–
show
The property
p3 does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
40 | $this->p4 = new ShippingPackage(1000, array(100,200,300), array('value' => 1000000, 'quantity' => 12412)); |
||
0 ignored issues
–
show
The property
p4 does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
41 | } |
||
42 | |||
43 | public function testAddressTable() { |
||
44 | $type = "address"; |
||
45 | |||
46 | $address = new Address(array( |
||
47 | 'Country' => 'NZ', |
||
48 | 'State' => 'Wellington' |
||
49 | )); |
||
50 | $this->assertMatch($type, $this->p0, $address, 30); |
||
51 | $this->assertMatch($type, $this->p2, $address, 30); |
||
52 | $this->assertMatch($type, $this->p4, $address, 30); |
||
53 | |||
54 | $address = new Address(array( |
||
55 | 'Country' => 'NZ', |
||
56 | 'PostalCode' => '6000' |
||
57 | )); |
||
58 | $this->assertMatch($type, $this->p0, $address, 45); |
||
59 | $this->assertMatch($type, $this->p2, $address, 45); |
||
60 | $this->assertMatch($type, $this->p4, $address, 45); |
||
61 | |||
62 | //empty package rate |
||
63 | $address = $this->internationaladdress; |
||
64 | |||
65 | $this->assertMatch($type, $this->p0, $address, 0); |
||
66 | $this->assertMatch($type, $this->p2, $address, 0); |
||
67 | $this->assertMatch($type, $this->p4, $address, 0); |
||
68 | } |
||
69 | |||
70 | public function testDefaultRate() { |
||
71 | $type = "address"; |
||
72 | $address = $this->internationaladdress; |
||
73 | $defaultrate = new TableShippingRate(array( |
||
74 | "Rate" => 100 |
||
75 | )); |
||
76 | $defaultrate->write(); |
||
77 | $this->addressshipping->Rates()->add($defaultrate); |
||
78 | |||
79 | $this->assertMatch($type, $this->p0, $address, 100); |
||
80 | $this->assertMatch($type, $this->p2, $address, 100); |
||
81 | $this->assertMatch($type, $this->p4, $address, 100); |
||
82 | } |
||
83 | |||
84 | public function testInternationalRates(){ |
||
85 | $address_int = $this->internationaladdress; |
||
86 | |||
87 | //weight based |
||
88 | $type = "weight"; |
||
89 | $this->assertMatch($type, $this->p0, $address_int, 8); //weight = 0kg |
||
90 | $this->assertMatch($type, $this->p1, $address_int, 8); //weight = 2.34kg |
||
91 | $this->assertMatch($type, $this->p2, $address_int, 96); //weight= 17kg, |
||
92 | $this->assertMatch($type, $this->p3, $address_int, 116); //weight = 100kg |
||
93 | $this->assertNoMatch($type, $this->p4, $address_int); //weight = 1000kg |
||
94 | |||
95 | //volume based |
||
96 | $type = "volume"; |
||
97 | $this->assertMatch($type, $this->p0, $address_int, 2); //volume = 0cm3 |
||
98 | $this->assertMatch($type, $this->p1, $address_int, 2); //volume = 1cm3 |
||
99 | $this->assertMatch($type, $this->p2, $address_int, 6); //volume = 6cm3 |
||
100 | $this->assertMatch($type, $this->p3, $address_int, 520); //volume = 18927.783cm3 |
||
101 | $this->assertNoMatch($type, $this->p4, $address_int); //volume = 2000000cm3 |
||
102 | |||
103 | //value based |
||
104 | $type = "value"; |
||
105 | $this->assertMatch($type, $this->p0, $address_int, 2); //value = $0 |
||
106 | $this->assertMatch($type, $this->p1, $address_int, 2); //value = $2 |
||
107 | $this->assertMatch($type, $this->p2, $address_int, 6); //value = $6 |
||
108 | $this->assertNoMatch($type, $this->p3, $address_int); //value = $1000 |
||
109 | $this->assertNoMatch($type, $this->p4, $address_int); //value = $1,000,000 |
||
110 | |||
111 | //quantity based |
||
112 | $type = "quantity"; |
||
113 | $this->assertNoMatch($type, $this->p0, $address_int); //quantity = 0 |
||
114 | $this->assertMatch($type, $this->p1, $address_int, 11); //quantity = 3 |
||
115 | $this->assertMatch($type, $this->p2, $address_int, 18.6); //quantity = 10 |
||
116 | $this->assertNoMatch($type, $this->p3, $address_int); //quantity = 155 |
||
117 | $this->assertNoMatch($type, $this->p4, $address_int); //quantity = 12412 |
||
118 | } |
||
119 | |||
120 | public function testLocalRates(){ |
||
121 | $address_loc = $this->nzaddress; |
||
122 | |||
123 | //weight based |
||
124 | $type = "weight"; |
||
125 | $this->assertMatch($type, $this->p0, $address_loc, 4); //weight = 0kg |
||
126 | $this->assertMatch($type, $this->p1, $address_loc, 4); //weight = 2.34kg |
||
127 | $this->assertMatch($type, $this->p2, $address_loc, 48); //weight= 17kg, |
||
128 | $this->assertMatch($type, $this->p3, $address_loc, 58); //weight = 100kg |
||
129 | $this->assertNoMatch($type, $this->p4, $address_loc); //weight = 1000kg |
||
130 | |||
131 | //volume based |
||
132 | $type = "volume"; |
||
133 | $this->assertMatch($type, $this->p0, $address_loc, 1); //volume = 0cm3 |
||
134 | $this->assertMatch($type, $this->p1, $address_loc, 1); //volume = 1cm3 |
||
135 | $this->assertMatch($type, $this->p2, $address_loc, 3); //volume = 6cm3 |
||
136 | $this->assertMatch($type, $this->p3, $address_loc, 520); //volume = 18927.783cm3 |
||
137 | $this->assertNoMatch($type, $this->p4, $address_loc); //volume = 2000000cm3 |
||
138 | |||
139 | //value based |
||
140 | $type = "value"; |
||
141 | $this->assertMatch($type, $this->p0, $address_loc, 1); //value = $0 |
||
142 | $this->assertMatch($type, $this->p1, $address_loc, 1); //value = $2 |
||
143 | $this->assertMatch($type, $this->p2, $address_loc, 3); //value = $6 |
||
144 | $this->assertNoMatch($type, $this->p3, $address_loc); //value = $1000 |
||
145 | $this->assertNoMatch($type, $this->p4, $address_loc); //value = $1,000,000 |
||
146 | |||
147 | //quantity based |
||
148 | $type = "quantity"; |
||
149 | $this->assertNoMatch($type, $this->p0, $address_loc); //quantity = 0 |
||
150 | $this->assertMatch($type, $this->p1, $address_loc, 5.5); //quantity = 3 |
||
151 | $this->assertMatch($type, $this->p2, $address_loc, 9.3); //quantity = 10 |
||
152 | $this->assertNoMatch($type, $this->p3, $address_loc); //quantity = 155 |
||
153 | $this->assertNoMatch($type, $this->p4, $address_loc); //quantity = 12412 |
||
154 | |||
155 | } |
||
156 | |||
157 | protected function assertMatch($type = "weight", $package, $address, $amount){ |
||
158 | $rate = $this->{$type."shipping"}->calculateRate($package, $address); |
||
159 | $this->assertEquals($amount, $rate, "Check rate for package $package is $amount"); |
||
0 ignored issues
–
show
The method
assertEquals() does not seem to exist on object<TableShippingMethodTest> .
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. ![]() |
|||
160 | } |
||
161 | |||
162 | protected function assertNoMatch($type = "weight", $package, $address){ |
||
163 | $rate = $this->{$type."shipping"}->calculateRate($package,$address); |
||
164 | $this->assertNull($rate,"Check rate for package $package is not found"); |
||
0 ignored issues
–
show
The method
assertNull() does not seem to exist on object<TableShippingMethodTest> .
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. ![]() |
|||
165 | } |
||
166 | |||
167 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: