| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Moip\Tests; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Moip\Auth\OAuth; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Moip\Moip; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Moip\Resource\Customer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Moip\Resource\Orders; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use PHPUnit_Framework_TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Requests_Response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * class TestCase. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | abstract class TestCase extends PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * Variables representing the test modes. On MOCK mode no http request will be made. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * In SANDBOX mode HTTP requests will be made to the Moip::SANDBOX_ENDPOINT, the authentication information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * is retrieved from the MOIP_TOKEN and MOIP_KEY environment variables. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     const MOCK = 'mock'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     const SANDBOX = 'sandbox'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * Intance of \Moip\Moip. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @var \Moip\Moip | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     protected $moip; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @var string current format for dates. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     protected $date_format = 'Y-m-d'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * @var string date used for testing. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     protected $date_string = '1989-06-01'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     //todo: add the ability to use the play(https://github.com/rodrigosaito/mockwebserver-player) files from the jada sdk | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     //the two responses below were based on the moip Java sdk's test files (https://github.com/moip/moip-sdk-java/) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @var string response from the client moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     protected $body_client; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @var string response from the order moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     protected $body_order; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     protected $body_cc_pay_pci; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     protected $body_cc_pay_pci_store; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     protected $body_cc_pay_pci_escrow; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     protected $body_release_escrow; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     protected $body_billet_pay; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     protected $body_refund_full_bankaccount; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     protected $body_refund_partial_bankaccount; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     protected $body_notification_preference; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     protected $body_moip_account_create; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     protected $body_moip_account_get; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     protected $body_order_list; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     protected $body_notification_list; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     protected $body_transfers_create; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     protected $body_transfers_list; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     protected $body_transfers_revert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     protected $body_bank_account_create; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     protected $body_bank_account_list; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * @var string response from moip API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     protected $body_bank_account_update; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |      * @var string holds the last generated customer ownId. In mock mode it'll be always the default, but it changes on sandbox mode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     protected $last_cus_id = 'meu_id_customer'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * @var string same as `$last_cus_id` but for orders. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      * @see $last_cus_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     protected $last_ord_id = 'meu_id_pedido'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     protected $sandbox_mock = self::MOCK; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         parent::__construct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         $this->body_client = $this->readJsonFile('jsons/customer/create'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         $this->body_order = $this->readJsonFile('jsons/order/create'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $this->body_cc_pay_pci = $this->readJsonFile('jsons/payment/create_cc_pci'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         $this->body_cc_pay_pci_store = $this->readJsonFile('jsons/payment/create_cc_pci_store'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         $this->body_cc_pay_pci_escrow = $this->readJsonFile('jsons/payment/create_cc_pci_escrow'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         $this->body_release_escrow = $this->readJsonFile('jsons/escrow/release'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         $this->body_billet_pay = $this->readJsonFile('jsons/payment/create_billet'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         $this->body_billet_multipay = $this->readJsonFile('jsons/multipayment/create_billet'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         $this->body_refund_full_bankaccount = $this->readJsonFile('jsons/refund/full_bankaccount'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         $this->body_cc_multipay = $this->readJsonFile('jsons/multipayment/create_cc'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $this->body_notification_preference = $this->readJsonFile('jsons/notification/create'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         $this->body_moip_account_create = $this->readJsonFile('jsons/account/create'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         $this->body_moip_account_get = $this->readJsonFile('jsons/account/get'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         $this->body_order_list = $this->readJsonFile('jsons/order/get_list'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         $this->body_add_credit_card = $this->readJsonFile('jsons/customer/add_credit_card'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         $this->body_list_webhook_no_filter = $this->readJsonFile('jsons/webhooks/get_no_filter'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         $this->body_list_webhook_pagination = $this->readJsonFile('jsons/webhooks/get_pagination'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         $this->body_list_webhook_all_filters = $this->readJsonFile('jsons/webhooks/get_all_filters'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         $this->body_notification_list = $this->readJsonFile('jsons/notification/list'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         $this->body_multiorder = $this->readJsonFile('jsons/multiorder/create'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $this->body_cc_delay_capture = $this->readJsonFile('jsons/payment/create_cc_delay_capture'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         $this->body_capture_pay = $this->readJsonFile('jsons/payment/capture'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $this->body_capture_multipay = $this->readJsonFile('jsons/multipayment/capture'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         $this->body_cancel_pay = $this->readJsonFile('jsons/payment/cancel_pre_authorized'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         $this->body_cancel_multipay = $this->readJsonFile('jsons/multipayment/cancel_pre_authorized'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         $this->body_get_pay = $this->readJsonFile('jsons/payment/get'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         $this->body_get_multipay = $this->readJsonFile('jsons/multipayment/get'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |         $this->body_keys = $this->readJsonFile('jsons/keys/get'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         $this->body_transfers_create = $this->readJsonFile('jsons/transfers/create'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         $this->body_transfers_list = $this->readJsonFile('jsons/transfers/list'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         $this->body_transfers_revert = $this->readJsonFile('jsons/transfers/revert'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $this->body_keys = $this->readJsonFile('jsons/keys/get'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $this->body_order_refund_full_bankaccount = $this->readJsonFile('jsons/refund/order_full_bankaccount'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         $this->body_payment_refund_full_bankaccount = $this->readJsonFile('jsons/refund/payment_full_bankaccount'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         $this->body_order_refund_partial_bankaccount = $this->readJsonFile('jsons/refund/order_partial_bankaccount'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         $this->body_payment_refund_partial_bankaccount = $this->readJsonFile('jsons/refund/payment_partial_bankaccount'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         $this->body_order_refund_full_cc = $this->readJsonFile('jsons/refund/order_full_cc'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         $this->body_payment_refund_full_cc = $this->readJsonFile('jsons/refund/payment_full_cc'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         $this->body_order_refund_partial_cc = $this->readJsonFile('jsons/refund/order_partial_cc'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         $this->body_payment_refund_partial_cc = $this->readJsonFile('jsons/refund/payment_partial_cc'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         $this->body_bank_account_create = $this->readJsonFile('jsons/bank_account/create'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         $this->body_bank_account_list = $this->readJsonFile('jsons/bank_account/list'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         $this->body_bank_account_update = $this->readJsonFile('jsons/bank_account/update'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      * Sets up the fixture, for example, open a network connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      * This method is called before a test is executed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |     public function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         // check if we can run the request on sandbox | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         $moip_access_token = getenv('MOIP_ACCESS_TOKEN'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         if ($moip_access_token) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |             $this->sandbox_mock = self::SANDBOX; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |             $auth = new OAuth($moip_access_token); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             $this->sandbox_mock = self::MOCK; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             $auth = $this->getMock('\Moip\Contracts\Authentication'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         $this->moip = new Moip($auth, Moip::ENDPOINT_SANDBOX); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |      * Method to read JSON from a file. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |      * @param string $filename location of file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |     public function readJsonFile($filename) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |         return file_get_contents($filename.'.json', FILE_USE_INCLUDE_PATH); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |      * If in MOCK mode returns a mocked Requests_Sessesion if in SANDBOX mode, creates a new session. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |      * @param string $body        what the request will return | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |      * @param int    $status_code what http code the request will return | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     public function mockHttpSession($body, $status_code = 200) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |         if ($this->sandbox_mock == self::SANDBOX) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             $this->moip->createNewSession(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         $resp = new Requests_Response(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         $resp->body = $body; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         $resp->status_code = $status_code; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |         $sess = $this->getMock('\Requests_Session'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |         $sess->expects($this->once())->method('request')->willReturn($resp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         $this->moip->setSession($sess); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |      * Creates a customer. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |      * @return Customer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |     public function createCustomer() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |         if ($this->sandbox_mock == self::SANDBOX) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |             $this->last_cus_id = uniqid('CUS-'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |             $this->last_cus_id = 'meu_id_sandbox'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |         $customer = $this->moip->customers()->setOwnId($this->last_cus_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |             ->setBirthDate(\DateTime::createFromFormat($this->date_format, $this->date_string)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |             ->setFullname('Jose Silva') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |             ->setEmail('[email protected]') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |             ->setTaxDocument('22222222222', 'CPF') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |             ->setPhone(11, 66778899, 55) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |             ->addAddress(Customer::ADDRESS_SHIPPING, 'Avenida Faria Lima', '2927', 'Itaim', 'Sao Paulo', 'SP', '01234000', '8'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |         return $customer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |      * Creates a account. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |      * @return Account | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |     public function createAccount() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         $moip = new Moip(new OAuth('1tldio91gi74r34zv30d4saz8yuuws5'), Moip::ENDPOINT_SANDBOX); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         $uniqEmail = 'fulano'.uniqid('MPA-').'@detal123.com.br'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |         $account = $moip->accounts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |             ->setEmail($uniqEmail) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |             ->setName('Fulano') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |             ->setLastName('de Tal') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |             ->setBirthDate('1987-11-27') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |             ->setTaxDocument('22222222222') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |             ->setPhone(11, 988888888) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |             ->addAddress('Av. Ibirapuera', '2035', 'Moema', 'Sao Paulo', 'SP', '04078010') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |             ->setIdentityDocument('411111115', 'SSP', '2000-05-06') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |             ->create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         return $account; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |      * Creates an order. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |      * @return Orders | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 350 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |     public function createOrder() | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |     { | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 353 |  | View Code Duplication |         if ($this->sandbox_mock == self::SANDBOX) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |             $this->last_ord_id = uniqid('ORD-'); | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  |             $this->last_ord_id = 'meu_id_pedido'; | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  |         $order = $this->moip->orders()->setCustomer($this->createCustomer()) | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  |             ->addItem('Nome do produto', 1, 'Mais info...', 100000) | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  |             ->addItem('abacaxi', 2, 'Abacaxi de terra de areia', 990) | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  |             ->setDiscount(1000) | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  |             ->setShippingAmount(1490) | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  |             ->setOwnId($this->last_ord_id); | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  |         return $order; | 
            
                                                                        
                            
            
                                    
            
            
                | 367 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |      * Creates a multiorder. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |      * @return Multiorders | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |     public function createMultiorder() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |     { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 376 |  | View Code Duplication |         if ($this->sandbox_mock == self::SANDBOX) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |             $this->last_ord_id = uniqid('MOR-'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |             $this->last_ord_id = 'meu_id_pedido'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |         $order = $this->moip->orders()->setOwnId(uniqid()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |             ->addItem('bicicleta 1', 1, 'sku1', 10000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |             ->addItem('bicicleta 2', 1, 'sku2', 11000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |             ->addItem('bicicleta 3', 1, 'sku3', 12000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |             ->addItem('bicicleta 4', 1, 'sku4', 13000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |             ->setShippingAmount(3000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |             ->setAddition(1000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |             ->setDiscount(5000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |             ->setCustomer($this->createCustomer()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |             ->addReceiver('MPA-VB5OGTVPCI52', 'PRIMARY', null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |         $order2 = $this->moip->orders()->setOwnId(uniqid()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |             ->addItem('bicicleta 1', 1, 'sku1', 10000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |             ->addItem('bicicleta 2', 1, 'sku2', 11000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |             ->addItem('bicicleta 3', 1, 'sku3', 12000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |             ->setShippingAmount(3000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |             ->setAddition(1000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |             ->setDiscount(5000) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |             ->setCustomer($this->createCustomer()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |             ->addReceiver('MPA-IFYRB1HBL73Z', 'PRIMARY', null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |         $multiorder = $this->moip->multiorders() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |                 ->setOwnId(uniqid()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |                 ->addOrder($order) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |                 ->addOrder($order2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |         return $multiorder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |      * Tears down the fixture, for example, close a network connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |      * This method is called after a test is executed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |     public function tearDown() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |         $this->moip = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 419 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 420 |  |  |  | 
            
                        
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: