Skip to content

Commit 18e352c

Browse files
authored
Merge pull request #1145 from phalcon/3.2.x
v3.2.11
2 parents e57276b + 38a6b61 commit 18e352c

File tree

11 files changed

+374
-6
lines changed

11 files changed

+374
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ This command should display something similar to:
114114
```sh
115115
$ phalcon --help
116116

117-
Phalcon DevTools (3.2.10)
117+
Phalcon DevTools (3.2.11)
118118

119119
Help:
120120
Lists the commands available in Phalcon devtools

scripts/Phalcon/Builder/Model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ public function __construct(array $options)
7777
}
7878

7979
if (!isset($options['className'])) {
80-
$options['className'] = Text::camelize($options['name'], '_-');
80+
$options['className'] = Utils::lowerCamelizeWithDelimiter($options['name'], '_-');
8181
}
8282

8383
if (!isset($options['fileName'])) {
84-
$options['fileName'] = Text::camelize($options['name'], '_-');
84+
$options['fileName'] = Utils::lowerCamelizeWithDelimiter($options['name'], '_-');
8585
}
8686

8787
if (!isset($options['abstract'])) {

scripts/Phalcon/Devtools/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ class Version extends PhVersion
3939
*/
4040
protected static function _getVersion()
4141
{
42-
return [3, 2, 10, 4, 0];
42+
return [3, 2, 11, 4, 0];
4343
}
4444
}

scripts/Phalcon/Mvc/Model/Migration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ public function batchInsert($tableName, $fields)
862862
while (($line = fgetcsv($batchHandler)) !== false) {
863863
$values = array_map(
864864
function ($value) {
865-
return null === $value ? null : $value;
865+
return null === $value ? null : stripslashes($value);
866866
},
867867
$line
868868
);
@@ -893,7 +893,7 @@ public function batchDelete($tableName)
893893
while (($line = fgetcsv($batchHandler)) !== false) {
894894
$values = array_map(
895895
function ($value) {
896-
return null === $value ? null : $value;
896+
return null === $value ? null : stripslashes($value);
897897
},
898898
$line
899899
);
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
class TestModel extends \Phalcon\Mvc\Model
4+
{
5+
6+
/**
7+
*
8+
* @var integer
9+
* @Primary
10+
* @Identity
11+
* @Column(type="integer", length=10, nullable=false)
12+
*/
13+
public $id;
14+
15+
/**
16+
*
17+
* @var string
18+
* @Column(type="string", length=20, nullable=false)
19+
*/
20+
public $someCol;
21+
22+
/**
23+
*
24+
* @var string
25+
* @Column(type="string", length=20, nullable=false)
26+
*/
27+
public $someCol2;
28+
29+
/**
30+
*
31+
* @var string
32+
* @Column(type="string", length=20, nullable=false)
33+
*/
34+
public $someCol3;
35+
36+
/**
37+
* Initialize method for model.
38+
*/
39+
public function initialize()
40+
{
41+
$this->setSchema("devtools");
42+
$this->setSource("testModel");
43+
}
44+
45+
/**
46+
* Returns table name mapped in the model.
47+
*
48+
* @return string
49+
*/
50+
public function getSource()
51+
{
52+
return 'testModel';
53+
}
54+
55+
/**
56+
* Allows to query a set of records that match the specified conditions
57+
*
58+
* @param mixed $parameters
59+
* @return TestModel[]|TestModel|\Phalcon\Mvc\Model\ResultSetInterface
60+
*/
61+
public static function find($parameters = null)
62+
{
63+
return parent::find($parameters);
64+
}
65+
66+
/**
67+
* Allows to query the first record that match the specified conditions
68+
*
69+
* @param mixed $parameters
70+
* @return TestModel|\Phalcon\Mvc\Model\ResultInterface
71+
*/
72+
public static function findFirst($parameters = null)
73+
{
74+
return parent::findFirst($parameters);
75+
}
76+
77+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
class TestModel2 extends \Phalcon\Mvc\Model
4+
{
5+
6+
/**
7+
*
8+
* @var integer
9+
* @Primary
10+
* @Identity
11+
* @Column(type="integer", length=10, nullable=false)
12+
*/
13+
public $id;
14+
15+
/**
16+
*
17+
* @var string
18+
* @Column(type="string", length=45, nullable=false)
19+
*/
20+
public $name;
21+
22+
/**
23+
* Initialize method for model.
24+
*/
25+
public function initialize()
26+
{
27+
$this->setSchema("devtools");
28+
$this->setSource("test-model2");
29+
}
30+
31+
/**
32+
* Returns table name mapped in the model.
33+
*
34+
* @return string
35+
*/
36+
public function getSource()
37+
{
38+
return 'test-model2';
39+
}
40+
41+
/**
42+
* Allows to query a set of records that match the specified conditions
43+
*
44+
* @param mixed $parameters
45+
* @return TestModel2[]|TestModel2|\Phalcon\Mvc\Model\ResultSetInterface
46+
*/
47+
public static function find($parameters = null)
48+
{
49+
return parent::find($parameters);
50+
}
51+
52+
/**
53+
* Allows to query the first record that match the specified conditions
54+
*
55+
* @param mixed $parameters
56+
* @return TestModel2|\Phalcon\Mvc\Model\ResultInterface
57+
*/
58+
public static function findFirst($parameters = null)
59+
{
60+
return parent::findFirst($parameters);
61+
}
62+
63+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
class TestModel3 extends \Phalcon\Mvc\Model
4+
{
5+
6+
/**
7+
*
8+
* @var integer
9+
* @Primary
10+
* @Identity
11+
* @Column(type="integer", length=10, nullable=false)
12+
*/
13+
public $id;
14+
15+
/**
16+
*
17+
* @var string
18+
* @Column(type="string", length=45, nullable=false)
19+
*/
20+
public $name;
21+
22+
/**
23+
* Initialize method for model.
24+
*/
25+
public function initialize()
26+
{
27+
$this->setSchema("devtools");
28+
$this->setSource("test_model3");
29+
}
30+
31+
/**
32+
* Returns table name mapped in the model.
33+
*
34+
* @return string
35+
*/
36+
public function getSource()
37+
{
38+
return 'test_model3';
39+
}
40+
41+
/**
42+
* Allows to query a set of records that match the specified conditions
43+
*
44+
* @param mixed $parameters
45+
* @return TestModel3[]|TestModel3|\Phalcon\Mvc\Model\ResultSetInterface
46+
*/
47+
public static function find($parameters = null)
48+
{
49+
return parent::find($parameters);
50+
}
51+
52+
/**
53+
* Allows to query the first record that match the specified conditions
54+
*
55+
* @param mixed $parameters
56+
* @return TestModel3|\Phalcon\Mvc\Model\ResultInterface
57+
*/
58+
public static function findFirst($parameters = null)
59+
{
60+
return parent::findFirst($parameters);
61+
}
62+
63+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
class Testmodel4 extends \Phalcon\Mvc\Model
4+
{
5+
6+
/**
7+
*
8+
* @var integer
9+
* @Primary
10+
* @Identity
11+
* @Column(type="integer", length=10, nullable=false)
12+
*/
13+
public $id;
14+
15+
/**
16+
*
17+
* @var string
18+
* @Column(type="string", length=45, nullable=false)
19+
*/
20+
public $name;
21+
22+
/**
23+
* Initialize method for model.
24+
*/
25+
public function initialize()
26+
{
27+
$this->setSchema("devtools");
28+
$this->setSource("Testmodel4");
29+
}
30+
31+
/**
32+
* Returns table name mapped in the model.
33+
*
34+
* @return string
35+
*/
36+
public function getSource()
37+
{
38+
return 'Testmodel4';
39+
}
40+
41+
/**
42+
* Allows to query a set of records that match the specified conditions
43+
*
44+
* @param mixed $parameters
45+
* @return Testmodel4[]|Testmodel4|\Phalcon\Mvc\Model\ResultSetInterface
46+
*/
47+
public static function find($parameters = null)
48+
{
49+
return parent::find($parameters);
50+
}
51+
52+
/**
53+
* Allows to query the first record that match the specified conditions
54+
*
55+
* @param mixed $parameters
56+
* @return Testmodel4|\Phalcon\Mvc\Model\ResultInterface
57+
*/
58+
public static function findFirst($parameters = null)
59+
{
60+
return parent::findFirst($parameters);
61+
}
62+
63+
}

tests/_data/schemas/mysql/dump.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,32 @@ CREATE TABLE `issue595_2` (
6161
`name` varchar(45) NOT NULL,
6262
PRIMARY KEY (`id`)
6363
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
64+
65+
--
66+
-- Table structures for testing generating models
67+
--
68+
CREATE TABLE testModel (
69+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
70+
`some-col` varchar(20) NOT NULL,
71+
`someCol2` varchar(20) NOT NULL,
72+
`SomeCol3` varchar(20) NOT NULL,
73+
PRIMARY KEY (`id`)
74+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
75+
76+
CREATE TABLE `test-model2` (
77+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
78+
`name` varchar(45) NOT NULL,
79+
PRIMARY KEY (`id`)
80+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
81+
82+
CREATE TABLE `test_model3` (
83+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
84+
`name` varchar(45) NOT NULL,
85+
PRIMARY KEY (`id`)
86+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
87+
88+
CREATE TABLE `Testmodel4` (
89+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
90+
`name` varchar(45) NOT NULL,
91+
PRIMARY KEY (`id`)
92+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* @var Codeception\Scenario $scenario
5+
*/
6+
7+
$I = new ConsoleTester($scenario);
8+
9+
$I->wantToTest('Generating models');
10+
$I->amInPath(dirname(app_path()));
11+
mkdir(tests_path('_data/console/app/models/all_model_test'), 0777, true);
12+
13+
$I->runShellCommand('phalcon all-models --config=app/mysql/config.php --output=app/models/all_model_test');
14+
15+
$I->seeFileFound(app_path('models/all_model_test/TestModel.php'));
16+
$I->seeFileFound(app_path('models/all_model_test/TestModel2.php'));
17+
$I->seeFileFound(app_path('models/all_model_test/TestModel3.php'));
18+
$I->seeFileFound(app_path('models/all_model_test/Testmodel4.php'));
19+
20+
$file1 = file_get_contents(app_path('models/files/TestModel.php'));
21+
$file2 = file_get_contents(app_path('models/files/TestModel2.php'));
22+
$file3 = file_get_contents(app_path('models/files/TestModel3.php'));
23+
$file4 = file_get_contents(app_path('models/files/Testmodel4.php'));
24+
25+
$I->openFile(app_path('models/all_model_test/TestModel.php'));
26+
$I->seeFileContentsEqual($file1);
27+
28+
$I->openFile(app_path('models/all_model_test/TestModel2.php'));
29+
$I->seeFileContentsEqual($file2);
30+
31+
$I->openFile(app_path('models/all_model_test/TestModel3.php'));
32+
$I->seeFileContentsEqual($file3);
33+
34+
$I->openFile(app_path('models/all_model_test/Testmodel4.php'));
35+
$I->seeFileContentsEqual($file4);

0 commit comments

Comments
 (0)