Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
3e3ee870
Commit
3e3ee870
authored
Sep 26, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:laravel/laravel into develop
parents
d64d6c90
09500818
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
329 additions
and
18 deletions
+329
-18
driver.php
laravel/auth/drivers/driver.php
+2
-0
model.php
laravel/database/eloquent/model.php
+3
-3
laravel.php
laravel/laravel.php
+1
-1
str.php
laravel/str.php
+16
-11
model.php
laravel/tests/application/models/model.php
+15
-0
auth.test.php
laravel/tests/cases/auth.test.php
+0
-3
eloquent.test.php
laravel/tests/cases/eloquent.test.php
+292
-0
No files found.
laravel/auth/drivers/driver.php
View file @
3e3ee870
...
@@ -127,6 +127,8 @@ abstract class Driver {
...
@@ -127,6 +127,8 @@ abstract class Driver {
$this
->
cookie
(
$this
->
recaller
(),
null
,
-
2000
);
$this
->
cookie
(
$this
->
recaller
(),
null
,
-
2000
);
Session
::
forget
(
$this
->
token
());
Session
::
forget
(
$this
->
token
());
$this
->
token
=
null
;
}
}
/**
/**
...
...
laravel/database/eloquent/model.php
View file @
3e3ee870
...
@@ -528,7 +528,7 @@ abstract class Model {
...
@@ -528,7 +528,7 @@ abstract class Model {
foreach
(
$this
->
attributes
as
$key
=>
$value
)
foreach
(
$this
->
attributes
as
$key
=>
$value
)
{
{
if
(
!
isset
(
$this
->
original
[
$key
])
or
$value
!=
=
$this
->
original
[
$key
])
if
(
!
array_key_exists
(
$key
,
$this
->
original
)
or
$value
!
=
$this
->
original
[
$key
])
{
{
$dirty
[
$key
]
=
$value
;
$dirty
[
$key
]
=
$value
;
}
}
...
@@ -544,7 +544,7 @@ abstract class Model {
...
@@ -544,7 +544,7 @@ abstract class Model {
*/
*/
public
function
get_key
()
public
function
get_key
()
{
{
return
$this
->
get_attribute
(
static
::
$key
);
return
array_get
(
$this
->
original
,
static
::
$key
);
}
}
/**
/**
...
...
laravel/laravel.php
View file @
3e3ee870
...
@@ -137,7 +137,7 @@ $languages[] = Config::get('application.language');
...
@@ -137,7 +137,7 @@ $languages[] = Config::get('application.language');
foreach
(
$languages
as
$language
)
foreach
(
$languages
as
$language
)
{
{
if
(
starts_with
(
$uri
,
$language
))
if
(
preg_match
(
"#^
{
$language
}
(?:$|/)#i"
,
$uri
))
{
{
Config
::
set
(
'application.language'
,
$language
);
Config
::
set
(
'application.language'
,
$language
);
...
...
laravel/str.php
View file @
3e3ee870
...
@@ -10,15 +10,20 @@ class Str {
...
@@ -10,15 +10,20 @@ class Str {
public
static
$pluralizer
;
public
static
$pluralizer
;
/**
/**
* Get the default string encoding for the application
.
* Cache application encoding locally to save expensive calls to Config::get()
.
*
*
* This method is simply a short-cut to Config::get('application.encoding').
* @var string
*/
public
static
$encoding
=
null
;
/**
* Get the appliction.encoding without needing to request it from Config::get() each time.
*
*
* @return string
* @return string
*/
*/
public
static
function
encoding
()
protected
static
function
encoding
()
{
{
return
Config
::
get
(
'application.encoding'
);
return
static
::
$encoding
?:
static
::
$encoding
=
Config
::
get
(
'application.encoding'
);
}
}
/**
/**
...
...
laravel/tests/application/models/model.php
0 → 100644
View file @
3e3ee870
<?php
class
Model
extends
Laravel\Database\Eloquent\Model
{
public
function
set_setter
(
$setter
)
{
$this
->
set_attribute
(
'setter'
,
'setter: '
.
$setter
);
}
public
function
get_getter
()
{
return
'getter: '
.
$this
->
get_attribute
(
'getter'
);
}
}
\ No newline at end of file
laravel/tests/cases/auth.test.php
View file @
3e3ee870
...
@@ -294,9 +294,6 @@ class AuthTest extends PHPUnit_Framework_TestCase {
...
@@ -294,9 +294,6 @@ class AuthTest extends PHPUnit_Framework_TestCase {
Auth
::
logout
();
Auth
::
logout
();
// A workaround since Cookie will is only stored in memory, until Response class is called.
Auth
::
driver
()
->
token
=
null
;
$this
->
assertNull
(
Auth
::
user
());
$this
->
assertNull
(
Auth
::
user
());
$this
->
assertFalse
(
isset
(
Session
::
$instance
->
session
[
'data'
][
'laravel_auth_drivers_fluent_login'
]));
$this
->
assertFalse
(
isset
(
Session
::
$instance
->
session
[
'data'
][
'laravel_auth_drivers_fluent_login'
]));
...
...
laravel/tests/cases/eloquent.test.php
0 → 100644
View file @
3e3ee870
<?php
class
EloquentTest
extends
PHPUnit_Framework_TestCase
{
/**
* Test the Model constructor.
*
* @group laravel
*/
public
function
testAttributesAreSetByConstructor
()
{
$array
=
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
,
'setter'
=>
'foo'
);
$model
=
new
Model
(
$array
);
$this
->
assertEquals
(
'Taylor'
,
$model
->
name
);
$this
->
assertEquals
(
25
,
$model
->
age
);
$this
->
assertEquals
(
'setter: foo'
,
$model
->
setter
);
}
/**
* Test the Model::fill method.
*
* @group laravel
*/
public
function
testAttributesAreSetByFillMethod
()
{
$array
=
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
,
'setter'
=>
'foo'
);
$model
=
new
Model
();
$model
->
fill
(
$array
);
$this
->
assertEquals
(
'Taylor'
,
$model
->
name
);
$this
->
assertEquals
(
25
,
$model
->
age
);
$this
->
assertEquals
(
'setter: foo'
,
$model
->
setter
);
}
/**
* Test the Model::fill_raw method.
*
* @group laravel
*/
public
function
testAttributesAreSetByFillRawMethod
()
{
$array
=
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
,
'setter'
=>
'foo'
);
$model
=
new
Model
();
$model
->
fill_raw
(
$array
);
$this
->
assertEquals
(
$array
,
$model
->
attributes
);
}
/**
* Test the Model::fill method with accessible.
*
* @group laravel
*/
public
function
testAttributesAreSetByFillMethodWithAccessible
()
{
Model
::
$accessible
=
array
(
'name'
,
'age'
);
$array
=
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
,
'foo'
=>
'bar'
);
$model
=
new
Model
();
$model
->
fill
(
$array
);
$this
->
assertEquals
(
'Taylor'
,
$model
->
name
);
$this
->
assertEquals
(
25
,
$model
->
age
);
$this
->
assertNull
(
$model
->
foo
);
Model
::
$accessible
=
null
;
}
/**
* Test the Model::fill method with empty accessible array.
*
* @group laravel
*/
public
function
testAttributesAreSetByFillMethodWithEmptyAccessible
()
{
Model
::
$accessible
=
array
();
$array
=
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
,
'foo'
=>
'bar'
);
$model
=
new
Model
();
$model
->
fill
(
$array
);
$this
->
assertEquals
(
array
(),
$model
->
attributes
);
$this
->
assertNull
(
$model
->
name
);
$this
->
assertNull
(
$model
->
age
);
$this
->
assertNull
(
$model
->
foo
);
Model
::
$accessible
=
null
;
}
/**
* Test the Model::fill_raw method with accessible.
*
* @group laravel
*/
public
function
testAttributesAreSetByFillRawMethodWithAccessible
()
{
Model
::
$accessible
=
array
(
'name'
,
'age'
);
$array
=
array
(
'name'
=>
'taylor'
,
'age'
=>
25
,
'setter'
=>
'foo'
);
$model
=
new
Model
();
$model
->
fill_raw
(
$array
);
$this
->
assertEquals
(
$array
,
$model
->
attributes
);
Model
::
$accessible
=
null
;
}
/**
* Test the Model::__set method.
*
* @group laravel
*/
public
function
testAttributeMagicSetterMethodChangesAttribute
()
{
Model
::
$accessible
=
array
(
'setter'
);
$array
=
array
(
'setter'
=>
'foo'
,
'getter'
=>
'bar'
);
$model
=
new
Model
(
$array
);
$model
->
setter
=
'bar'
;
$model
->
getter
=
'foo'
;
$this
->
assertEquals
(
'setter: bar'
,
$model
->
get_attribute
(
'setter'
));
$this
->
assertEquals
(
'foo'
,
$model
->
get_attribute
(
'getter'
));
Model
::
$accessible
=
null
;
}
/**
* Test the Model::__get method.
*
* @group laravel
*/
public
function
testAttributeMagicGetterMethodReturnsAttribute
()
{
$array
=
array
(
'setter'
=>
'foo'
,
'getter'
=>
'bar'
);
$model
=
new
Model
(
$array
);
$this
->
assertEquals
(
'setter: foo'
,
$model
->
setter
);
$this
->
assertEquals
(
'getter: bar'
,
$model
->
getter
);
}
/**
* Test the Model::set_* method.
*
* @group laravel
*/
public
function
testAttributeSetterMethodChangesAttribute
()
{
Model
::
$accessible
=
array
(
'setter'
);
$array
=
array
(
'setter'
=>
'foo'
,
'getter'
=>
'bar'
);
$model
=
new
Model
(
$array
);
$model
->
set_setter
(
'bar'
);
$model
->
set_getter
(
'foo'
);
$this
->
assertEquals
(
'setter: bar'
,
$model
->
get_attribute
(
'setter'
));
$this
->
assertEquals
(
'foo'
,
$model
->
get_attribute
(
'getter'
));
Model
::
$accessible
=
null
;
}
/**
* Test the Model::get_* method.
*
* @group laravel
*/
public
function
testAttributeGetterMethodReturnsAttribute
()
{
$array
=
array
(
'setter'
=>
'foo'
,
'getter'
=>
'bar'
);
$model
=
new
Model
(
$array
);
$this
->
assertEquals
(
'setter: foo'
,
$model
->
get_setter
());
$this
->
assertEquals
(
'getter: bar'
,
$model
->
get_getter
());
}
/**
* Test determination of dirty/changed attributes.
*
* @group laravel
*/
public
function
testDeterminationOfChangedAttributes
()
{
$array
=
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
,
'foo'
=>
null
);
$model
=
new
Model
(
$array
,
true
);
$model
->
name
=
'Otwell'
;
$model
->
new
=
null
;
$this
->
assertTrue
(
$model
->
changed
(
'name'
));
$this
->
assertFalse
(
$model
->
changed
(
'age'
));
$this
->
assertFalse
(
$model
->
changed
(
'foo'
));
$this
->
assertFalse
(
$model
->
changed
(
'new'
));
$this
->
assertTrue
(
$model
->
dirty
());
$this
->
assertEquals
(
array
(
'name'
=>
'Otwell'
,
'new'
=>
null
),
$model
->
get_dirty
());
$model
->
sync
();
$this
->
assertFalse
(
$model
->
changed
(
'name'
));
$this
->
assertFalse
(
$model
->
changed
(
'age'
));
$this
->
assertFalse
(
$model
->
changed
(
'foo'
));
$this
->
assertFalse
(
$model
->
changed
(
'new'
));
$this
->
assertFalse
(
$model
->
dirty
());
$this
->
assertEquals
(
array
(),
$model
->
get_dirty
());
}
/**
* Test the Model::purge method.
*
* @group laravel
*/
public
function
testAttributePurge
()
{
$array
=
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
);
$model
=
new
Model
(
$array
);
$model
->
name
=
'Otwell'
;
$model
->
age
=
26
;
$model
->
purge
(
'name'
);
$this
->
assertFalse
(
$model
->
changed
(
'name'
));
$this
->
assertNull
(
$model
->
name
);
$this
->
assertTrue
(
$model
->
changed
(
'age'
));
$this
->
assertEquals
(
26
,
$model
->
age
);
$this
->
assertEquals
(
array
(
'age'
=>
26
),
$model
->
get_dirty
());
}
/**
* Test the Model::table method.
*
* @group laravel
*/
public
function
testTableMethodReturnsCorrectName
()
{
$model
=
new
Model
();
$this
->
assertEquals
(
'models'
,
$model
->
table
());
Model
::
$table
=
'table'
;
$this
->
assertEquals
(
'table'
,
$model
->
table
());
Model
::
$table
=
null
;
$this
->
assertEquals
(
'models'
,
$model
->
table
());
}
/**
* Test the Model::to_array method.
*
* @group laravel
*/
public
function
testConvertingToArray
()
{
Model
::
$hidden
=
array
(
'password'
,
'hidden'
);
$array
=
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
,
'password'
=>
'laravel'
,
'null'
=>
null
);
$model
=
new
Model
(
$array
);
$first
=
new
Model
(
array
(
'first'
=>
'foo'
,
'password'
=>
'hidden'
));
$second
=
new
Model
(
array
(
'second'
=>
'bar'
,
'password'
=>
'hidden'
));
$third
=
new
Model
(
array
(
'third'
=>
'baz'
,
'password'
=>
'hidden'
));
$model
->
relationships
[
'one'
]
=
new
Model
(
array
(
'foo'
=>
'bar'
,
'password'
=>
'hidden'
));
$model
->
relationships
[
'many'
]
=
array
(
$first
,
$second
,
$third
);
$model
->
relationships
[
'hidden'
]
=
new
Model
(
array
(
'should'
=>
'visible'
));
$model
->
relationships
[
'null'
]
=
null
;
$this
->
assertEquals
(
array
(
'name'
=>
'Taylor'
,
'age'
=>
25
,
'null'
=>
null
,
'one'
=>
array
(
'foo'
=>
'bar'
),
'many'
=>
array
(
array
(
'first'
=>
'foo'
),
array
(
'second'
=>
'bar'
),
array
(
'third'
=>
'baz'
),
),
'hidden'
=>
array
(
'should'
=>
'visible'
),
'null'
=>
null
,
),
$model
->
to_array
());
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment