Mage_nopobox - Version 1.1.1

Version Notes

Matt Nopobox extension Version 1.1.1 has Released!

Download this release

Release Info

Developer Matt
Extension Mage_nopobox
Version 1.1.1
Comparing to
See all releases


Code changes from version 1.1.0 to 1.1.1

app/code/community/Matt/Nopobox/etc/config.xml CHANGED
@@ -1,7 +1,7 @@
1
  <config>
2
  <modules>
3
  <Matt_Nopobox>
4
- <version>1.1.0</version>
5
  </Matt_Nopobox>
6
  </modules>
7
  <global>
1
  <config>
2
  <modules>
3
  <Matt_Nopobox>
4
+ <version>1.1.1</version>
5
  </Matt_Nopobox>
6
  </modules>
7
  <global>
app/etc/modules/Matt_Nopobox.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Matt_Nopobox>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Matt_Nopobox>
8
+ </modules>
9
+ </config>
package.xml CHANGED
@@ -1,32 +1,29 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_nopobox</name>
4
- <version>1.1.0</version>
5
  <stability>stable</stability>
6
- <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Check shipping address whether it contains POBOX.</summary>
10
- <description>The extension updates the Magento checkout fields to prevent shipping to a POBOX address. It also provides error message to inform customers that they must enter a valid shipping address before proceeding through checkout.&#xD;
11
  &#xD;
12
- &lt;h1 id="!how-to-install"&gt;How to install&lt;/h1&gt;&#xD;
13
  &lt;ol&gt;&lt;li&gt;install extension ,please follow this pdf &lt;a href="http://info.magento.com/rs/magentocommerce/images/InstallingMagentoConnectExtensions4%200.pdf"&gt;Magento Connect Installing Extensions (PDF)&lt;/a&gt; .&#xD;
14
- &lt;/li&gt;&lt;li&gt;Go to System-&amp;gt;Configuration-&amp;gt;Matt Module-&amp;gt;Matt Nopobox Setting-&amp;gt;Options, set Enabled to Yes and save config.&#xD;
15
  &lt;/li&gt;&lt;li&gt;it will works very well!&#xD;
16
  &lt;/li&gt;&lt;/ol&gt;&#xD;
17
- &lt;h1 id="!features"&gt;Features&lt;/h1&gt;&#xD;
 
18
  &lt;ul&gt;&lt;li&gt;add admin config option&#xD;
19
  &lt;/li&gt;&lt;li&gt;add allow country option&#xD;
20
  &lt;/li&gt;&lt;li&gt;add custom error message option&lt;/li&gt;&lt;/ul&gt;</description>
21
- <notes>Matt Nopobox extension 1.1.0 has release!&#xD;
22
- Features&#xD;
23
- 1. add admin config option&#xD;
24
- 2. add allow country option&#xD;
25
- 3. add custom error message option</notes>
26
  <authors><author><name>Matt</name><user>caijiamx</user><email>caijiamx@gmail.com</email></author></authors>
27
- <date>2012-11-06</date>
28
- <time>14:20:02</time>
29
- <contents><target name="magecommunity"><dir name="."><file name="Matt_Nopobox.xml" hash=""/></dir><dir name="Matt"><dir name="Nopobox"><dir name="Helper"><file name="Data.php" hash="7938eca0ac63785cb781de7f449b939b"/></dir><dir name="Model"><dir name="Quote"><file name="Address.php" hash="124031fbcf90c26a91f03bdf09683333"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="3cf3615c201fccd9f78cd516c2c2efe6"/><file name="config.xml" hash="e5d57d2c7820ca7cede168449b0b5cb9"/><file name="system.xml" hash="ad439be480877a1b7a503c2299e1bad0"/></dir></dir></dir></target></contents>
30
  <compatible/>
31
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
32
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_nopobox</name>
4
+ <version>1.1.1</version>
5
  <stability>stable</stability>
6
+ <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Check shipping address whether it contains POBOX.</summary>
10
+ <description>The extension updates the Magento checkout fields to prevent shipping to a PO box. It also provides error messaging to inform customers that they must enter a valid shipping address before proceeding through checkout.&#xD;
11
  &#xD;
12
+ &lt;h1&gt;How to install&lt;/h1&gt;&#xD;
13
  &lt;ol&gt;&lt;li&gt;install extension ,please follow this pdf &lt;a href="http://info.magento.com/rs/magentocommerce/images/InstallingMagentoConnectExtensions4%200.pdf"&gt;Magento Connect Installing Extensions (PDF)&lt;/a&gt; .&#xD;
14
+ &lt;/li&gt;&lt;li&gt;Go to System-&gt;Configuration-&gt;Matt Module-&gt;Matt Nopobox Setting-&gt;Options, set Enabled to Yes and save config.&#xD;
15
  &lt;/li&gt;&lt;li&gt;it will works very well!&#xD;
16
  &lt;/li&gt;&lt;/ol&gt;&#xD;
17
+ &#xD;
18
+ &lt;h1&gt;Features&lt;/h1&gt;&#xD;
19
  &lt;ul&gt;&lt;li&gt;add admin config option&#xD;
20
  &lt;/li&gt;&lt;li&gt;add allow country option&#xD;
21
  &lt;/li&gt;&lt;li&gt;add custom error message option&lt;/li&gt;&lt;/ul&gt;</description>
22
+ <notes>Matt Nopobox extension Version 1.1.1 has Released!</notes>
 
 
 
 
23
  <authors><author><name>Matt</name><user>caijiamx</user><email>caijiamx@gmail.com</email></author></authors>
24
+ <date>2013-06-06</date>
25
+ <time>08:48:27</time>
26
+ <contents><target name="mageetc"><dir name="modules"><file name="Matt_Nopobox.xml" hash="912bd655880b9f05869665fe257f1eed"/></dir></target><target name="magecommunity"><dir name="Matt"><dir name="Nopobox"><dir name="Helper"><file name="Data.php" hash="7938eca0ac63785cb781de7f449b939b"/></dir><dir name="Model"><dir name="Quote"><file name="Address.php" hash="124031fbcf90c26a91f03bdf09683333"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="3cf3615c201fccd9f78cd516c2c2efe6"/><file name="config.xml" hash="ad88a97de8a6613d5923798ddf93266e"/><file name="system.xml" hash="ad439be480877a1b7a503c2299e1bad0"/></dir></dir></dir></target><target name="mage"><dir name="shell"><file name="test.nopobox.php" hash="95efa28f9792d368d91d5f8932a0dc15"/></dir></target></contents>
27
  <compatible/>
28
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
29
  </package>
shell/test.nopobox.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Author: Matt
4
+ * URI:http://www.xbc.me
5
+ * Time:2012.10.30
6
+ * */
7
+ class Mage_Shell_Test extends PHPUnit_Framework_TestCase{
8
+ protected function setUp(){
9
+ $path =dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
10
+ $code = 'admin';
11
+ $type = 'store';
12
+ require_once $path . 'app' . DIRECTORY_SEPARATOR . 'Mage.php';
13
+ Mage::app($code, $type);
14
+ }
15
+ protected function _getTestModel($countryId = 'US' , $RegionId = 43){
16
+ $model = Mage::getModel('Matt_Nopobox_Model_Quote_Address');
17
+ $model->setFirstname('Jia');
18
+ $model->setLastname('Cai');
19
+ $model->setCity('Whaterveer');
20
+ $model->setTelephone('186');
21
+ $model->setCountryId($countryId);
22
+ $model->setPostcode('512443');
23
+ $model->setRegionId($RegionId);
24
+ return $model;
25
+ }
26
+ protected function _setField($field = 'active' , $value = 1){
27
+ $section = 'nopobox';
28
+ $groups = array(
29
+ 'option' => array(
30
+ 'fields' => array(
31
+ $field => array(
32
+ 'value' => $value
33
+ )
34
+ )
35
+ )
36
+ );
37
+ Mage::getModel('adminhtml/config_data')
38
+ ->setSection($section)
39
+ //->setWebsite($website)
40
+ //->setStore($store)
41
+ ->setGroups($groups)
42
+ ->save();
43
+ //$model = Mage::getModel('core/config');
44
+ //$model->saveConfig('nopobox/option/active' , $active);
45
+ // reinit configuration
46
+ Mage::getConfig()->reinit();
47
+ Mage::app()->reinitStores();
48
+ }
49
+ public function testNopoboxEnable(){
50
+ $this->_setField('active' , 0);
51
+ $active = Mage::getStoreConfig('nopobox/option/active');
52
+ $this->assertEquals(0, $active);
53
+ $this->_setField();
54
+ $active = Mage::getStoreConfig('nopobox/option/active');
55
+ $this->assertEquals(1, $active);
56
+ }
57
+
58
+ public function testHasPoboxNoCountry(){
59
+ $this->_setField('allowspecific' , 0);
60
+ $model = $this->_getTestModel();
61
+ $street = array();
62
+ $street[] = 'Futian street';
63
+ $street[] = 'pobox test';
64
+ $model->setStreet($street);
65
+ $errors = $model->validate();
66
+ $_errors =array();
67
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
68
+ $this->assertEquals($_errors, $errors);
69
+
70
+ $street = array();
71
+ $street[] = 'pobox test';
72
+ $street[] = 'Futian street';
73
+ $model->setStreet($street);
74
+ $errors = $model->validate();
75
+ $_errors =array();
76
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
77
+ $this->assertEquals($_errors, $errors);
78
+
79
+ $street = array();
80
+ $street[] = 'Pobox test';
81
+ $street[] = 'Futian street';
82
+ $model->setStreet($street);
83
+ $errors = $model->validate();
84
+ $_errors =array();
85
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
86
+ $this->assertEquals($_errors, $errors);
87
+
88
+ $street = array();
89
+ $street[] = 'POBOX test';
90
+ $street[] = 'Futian street';
91
+ $model->setStreet($street);
92
+ $errors = $model->validate();
93
+ $_errors =array();
94
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
95
+ $this->assertEquals($_errors, $errors);
96
+ }
97
+ public function testErrorMerge(){
98
+ $model = $this->_getTestModel();
99
+ $model->setFirstname('');
100
+ $errors = $model->validate();
101
+ $_errors =array();
102
+ $_errors[] = Mage::helper('customer')->__('Please enter the first name.');
103
+ $_errors[] = Mage::helper('customer')->__('Please enter the street.');
104
+ $this->assertEquals($_errors, $errors);
105
+
106
+ //join pobox validate
107
+ $street = array();
108
+ $street[] = 'Futian street';
109
+ $street[] = 'pobox test';
110
+ $model->setStreet($street);
111
+ $errors = $model->validate();
112
+ $_errors =array();
113
+ $_errors[] = Mage::helper('customer')->__('Please enter the first name.');
114
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
115
+ $this->assertEquals($_errors, $errors);
116
+ }
117
+ public function testHasPoboxHasCountry(){
118
+ $this->_setField('allowspecific');
119
+ $this->_setField('specificcountry' , array('DE' , 'US'));
120
+ $model = $this->_getTestModel('DE' , 80);
121
+ $street = array();
122
+ $street[] = 'Futian street';
123
+ $street[] = 'Pobox test';
124
+ $model->setStreet($street);
125
+ $errors = $model->validate();
126
+ $this->assertEquals(true, $errors);
127
+
128
+ $street = array();
129
+ $street[] = 'Pobox test';
130
+ $street[] = 'Futian street';
131
+ $model->setStreet($street);
132
+ $errors = $model->validate();
133
+ $this->assertEquals(true, $errors);
134
+
135
+ $street = array();
136
+ $street[] = 'Pobox test';
137
+ $street[] = 'Futian street';
138
+ $model->setStreet($street);
139
+ $errors = $model->validate();
140
+ $this->assertEquals(true, $errors);
141
+
142
+ $street = array();
143
+ $street[] = 'POBOX test';
144
+ $street[] = 'Futian street';
145
+ $model->setStreet($street);
146
+ $errors = $model->validate();
147
+ $this->assertEquals(true, $errors);
148
+
149
+
150
+ //can not use pobox
151
+ $model = $this->_getTestModel('FR' , 200);
152
+ $street = array();
153
+ $street[] = 'Futian street';
154
+ $street[] = 'Pobox test';
155
+ $model->setStreet($street);
156
+ $errors = $model->validate();
157
+ $_errors =array();
158
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/cerror'));
159
+ $this->assertEquals($_errors, $errors);
160
+
161
+ $street = array();
162
+ $street[] = 'Pobox test';
163
+ $street[] = 'Futian street';
164
+ $model->setStreet($street);
165
+ $errors = $model->validate();
166
+ $_errors =array();
167
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/cerror'));
168
+ $this->assertEquals($_errors, $errors);
169
+
170
+ $street = array();
171
+ $street[] = 'Pobox test';
172
+ $street[] = 'Futian street';
173
+ $model->setStreet($street);
174
+ $errors = $model->validate();
175
+ $_errors =array();
176
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/cerror'));
177
+ $this->assertEquals($_errors, $errors);
178
+
179
+ $street = array();
180
+ $street[] = 'POBOX test';
181
+ $street[] = 'Futian street';
182
+ $model->setStreet($street);
183
+ $errors = $model->validate();
184
+ $_errors =array();
185
+ $_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/cerror'));
186
+ $this->assertEquals($_errors, $errors);
187
+
188
+ $this->_setField('allowspecific' , 0);
189
+ $this->_setField('specificcountry' , array());
190
+ }
191
+ }
192
+ ?>