Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
Platform
Commits
1635b977
Unverified
Commit
1635b977
authored
Jul 12, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using the abstract entity class and using its helper methods in tests
parent
37a00fef
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
158 deletions
+14
-158
FileIsCreating.php
Modules/Media/Events/FileIsCreating.php
+2
-41
FileIsUpdating.php
Modules/Media/Events/FileIsUpdating.php
+4
-36
EloquentFileRepositoryTest.php
Modules/Media/Tests/EloquentFileRepositoryTest.php
+2
-2
PageIsCreating.php
Modules/Page/Events/PageIsCreating.php
+2
-41
PageIsUpdating.php
Modules/Page/Events/PageIsUpdating.php
+3
-37
EloquentPageRepositoryTest.php
Modules/Page/Tests/EloquentPageRepositoryTest.php
+1
-1
No files found.
Modules/Media/Events/FileIsCreating.php
View file @
1635b977
...
@@ -2,48 +2,9 @@
...
@@ -2,48 +2,9 @@
namespace
Modules\Media\Events
;
namespace
Modules\Media\Events
;
use
Modules\Core\Abstracts\AbstractEntityHook
;
use
Modules\Core\Contracts\EntityIsChanging
;
use
Modules\Core\Contracts\EntityIsChanging
;
final
class
FileIsCreating
implements
EntityIsChanging
final
class
FileIsCreating
extends
AbstractEntityHook
implements
EntityIsChanging
{
{
/**
* Contains the attributes which can be changed by other listeners
* @var array
*/
private
$attributes
;
/**
* Contains the original attributes which cannot be changed
* @var array
*/
private
$original
;
public
function
__construct
(
array
$attributes
)
{
$this
->
attributes
=
$attributes
;
$this
->
original
=
$attributes
;
}
/**
* @return array
*/
public
function
getAttributes
()
{
return
$this
->
attributes
;
}
/**
* @param array $attributes
*/
public
function
setAttributes
(
array
$attributes
)
{
$this
->
attributes
=
array_replace_recursive
(
$this
->
attributes
,
$attributes
);
}
/**
* @return array
*/
public
function
getOriginal
()
{
return
$this
->
original
;
}
}
}
Modules/Media/Events/FileIsUpdating.php
View file @
1635b977
...
@@ -2,53 +2,21 @@
...
@@ -2,53 +2,21 @@
namespace
Modules\Media\Events
;
namespace
Modules\Media\Events
;
use
Modules\Core\Abstracts\AbstractEntityHook
;
use
Modules\Core\Contracts\EntityIsChanging
;
use
Modules\Core\Contracts\EntityIsChanging
;
use
Modules\Media\Entities\File
;
use
Modules\Media\Entities\File
;
final
class
FileIsUpdating
implements
EntityIsChanging
final
class
FileIsUpdating
extends
AbstractEntityHook
implements
EntityIsChanging
{
{
/**
/**
* @var File
* @var File
*/
*/
private
$file
;
private
$file
;
/**
* @var array
*/
private
$attributes
;
/**
* @var array
*/
private
$original
;
public
function
__construct
(
File
$file
,
array
$
data
)
public
function
__construct
(
File
$file
,
array
$
attributes
)
{
{
$this
->
file
=
$file
;
$this
->
file
=
$file
;
$this
->
attributes
=
$data
;
parent
::
__construct
(
$attributes
);
$this
->
original
=
$data
;
}
/**
* @return array
*/
public
function
getOriginal
()
{
return
$this
->
original
;
}
/**
* @return array
*/
public
function
getAttributes
()
{
return
$this
->
attributes
;
}
/**
* @param array $attributes
*/
public
function
setAttributes
(
array
$attributes
)
{
$this
->
attributes
=
array_replace_recursive
(
$this
->
attributes
,
$attributes
);
}
}
/**
/**
...
...
Modules/Media/Tests/EloquentFileRepositoryTest.php
View file @
1635b977
...
@@ -138,7 +138,7 @@ class EloquentFileRepositoryTest extends MediaTestCase
...
@@ -138,7 +138,7 @@ class EloquentFileRepositoryTest extends MediaTestCase
$file
=
$this
->
file
->
createFromFile
(
\Illuminate\Http\UploadedFile
::
fake
()
->
image
(
'myfile.jpg'
));
$file
=
$this
->
file
->
createFromFile
(
\Illuminate\Http\UploadedFile
::
fake
()
->
image
(
'myfile.jpg'
));
Event
::
assertDispatched
(
FileIsCreating
::
class
,
function
(
$e
)
use
(
$file
)
{
Event
::
assertDispatched
(
FileIsCreating
::
class
,
function
(
$e
)
use
(
$file
)
{
return
$e
->
getAttribute
s
()[
'filename'
]
===
$file
->
filename
;
return
$e
->
getAttribute
(
'filename'
)
===
$file
->
filename
;
});
});
}
}
...
@@ -183,7 +183,7 @@ class EloquentFileRepositoryTest extends MediaTestCase
...
@@ -183,7 +183,7 @@ class EloquentFileRepositoryTest extends MediaTestCase
Event
::
assertDispatched
(
FileIsUpdating
::
class
,
function
(
$e
)
use
(
$file
)
{
Event
::
assertDispatched
(
FileIsUpdating
::
class
,
function
(
$e
)
use
(
$file
)
{
return
$e
->
getFile
()
->
id
===
$file
->
id
&&
return
$e
->
getFile
()
->
id
===
$file
->
id
&&
$e
->
getAttribute
s
()[
'en'
][
'description'
]
===
'My cool file!'
;
$e
->
getAttribute
(
'en.description'
)
===
'My cool file!'
;
});
});
}
}
...
...
Modules/Page/Events/PageIsCreating.php
View file @
1635b977
...
@@ -2,48 +2,9 @@
...
@@ -2,48 +2,9 @@
namespace
Modules\Page\Events
;
namespace
Modules\Page\Events
;
use
Modules\Core\Abstracts\AbstractEntityHook
;
use
Modules\Core\Contracts\EntityIsChanging
;
use
Modules\Core\Contracts\EntityIsChanging
;
class
PageIsCreating
implements
EntityIsChanging
class
PageIsCreating
extends
AbstractEntityHook
implements
EntityIsChanging
{
{
/**
* Contains the attributes which can be changed by other listeners
* @var array
*/
private
$attributes
;
/**
* Contains the original attributes which cannot be changed
* @var array
*/
private
$original
;
public
function
__construct
(
array
$attributes
)
{
$this
->
attributes
=
$attributes
;
$this
->
original
=
$attributes
;
}
/**
* @return array
*/
public
function
getAttributes
()
{
return
$this
->
attributes
;
}
/**
* @param array $attributes
*/
public
function
setAttributes
(
array
$attributes
)
{
$this
->
attributes
=
array_replace_recursive
(
$this
->
attributes
,
$attributes
);
}
/**
* @return array
*/
public
function
getOriginal
()
{
return
$this
->
original
;
}
}
}
Modules/Page/Events/PageIsUpdating.php
View file @
1635b977
...
@@ -2,21 +2,12 @@
...
@@ -2,21 +2,12 @@
namespace
Modules\Page\Events
;
namespace
Modules\Page\Events
;
use
Modules\Core\Abstracts\AbstractEntityHook
;
use
Modules\Core\Contracts\EntityIsChanging
;
use
Modules\Core\Contracts\EntityIsChanging
;
use
Modules\Page\Entities\Page
;
use
Modules\Page\Entities\Page
;
class
PageIsUpdating
implements
EntityIsChanging
class
PageIsUpdating
extends
AbstractEntityHook
implements
EntityIsChanging
{
{
/**
* Contains the attributes which can be changed by other listeners
* @var array
*/
private
$attributes
;
/**
* Contains the original attributes which cannot be changed
* @var array
*/
private
$original
;
/**
/**
* @var Page
* @var Page
*/
*/
...
@@ -24,33 +15,8 @@ class PageIsUpdating implements EntityIsChanging
...
@@ -24,33 +15,8 @@ class PageIsUpdating implements EntityIsChanging
public
function
__construct
(
Page
$page
,
array
$attributes
)
public
function
__construct
(
Page
$page
,
array
$attributes
)
{
{
$this
->
attributes
=
$attributes
;
$this
->
original
=
$attributes
;
$this
->
page
=
$page
;
$this
->
page
=
$page
;
}
parent
::
__construct
(
$attributes
);
/**
* @return array
*/
public
function
getAttributes
()
{
return
$this
->
attributes
;
}
/**
* @param array $attributes
*/
public
function
setAttributes
(
array
$attributes
)
{
$this
->
attributes
=
array_replace_recursive
(
$this
->
attributes
,
$attributes
);
}
/**
* @return array
*/
public
function
getOriginal
()
{
return
$this
->
original
;
}
}
/**
/**
...
...
Modules/Page/Tests/EloquentPageRepositoryTest.php
View file @
1635b977
...
@@ -103,7 +103,7 @@ class EloquentPageRepositoryTest extends BasePageTest
...
@@ -103,7 +103,7 @@ class EloquentPageRepositoryTest extends BasePageTest
$page
=
$this
->
createPage
();
$page
=
$this
->
createPage
();
Event
::
assertDispatched
(
PageIsCreating
::
class
,
function
(
$e
)
use
(
$page
)
{
Event
::
assertDispatched
(
PageIsCreating
::
class
,
function
(
$e
)
use
(
$page
)
{
return
$e
->
getAttribute
s
()[
'template'
]
===
$page
->
template
;
return
$e
->
getAttribute
(
'template'
)
===
$page
->
template
;
});
});
}
}
...
...
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