Conditions | 3 |
Paths | 4 |
Total Lines | 40 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
36 | public function testRequiredFields() |
||
37 | { |
||
38 | // create address instance that lacks some required fields (Address) |
||
39 | $address = Address::create()->update( |
||
40 | [ |
||
41 | 'Country' => 'NZ', |
||
42 | 'State' => 'Wellington', |
||
43 | 'City' => 'TeAro', |
||
44 | ] |
||
45 | ); |
||
46 | |||
47 | $writeFailed = false; |
||
48 | try { |
||
49 | $address->write(); |
||
50 | } catch (Exception $ex) { |
||
51 | $writeFailed = true; |
||
52 | } |
||
53 | |||
54 | $this->assertTrue($writeFailed, "Address should not be writable, since it doesn't contain all required fields"); |
||
55 | |||
56 | // Create an Address that satisfies the baseline required fields, but not the ones that were added via subclass. |
||
57 | $address = ExtendedTestAddress::create()->update( |
||
58 | [ |
||
59 | 'Country' => 'NZ', |
||
60 | 'State' => 'Wellington', |
||
61 | 'City' => 'TeAro', |
||
62 | 'Address' => '23 Blah Street', |
||
63 | ] |
||
64 | ); |
||
65 | |||
66 | $writeFailed = false; |
||
67 | try { |
||
68 | $address->write(); |
||
69 | } catch (Exception $ex) { |
||
70 | $writeFailed = true; |
||
71 | } |
||
72 | |||
73 | $this->assertTrue( |
||
74 | $writeFailed, |
||
75 | "Address should not be writable, since it doesn't contain required fields added via subclass" |
||
76 | ); |
||
79 |