Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EcomDev_PHPUnit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Open
EcomDev_PHPUnit
Commits
5cf27c31
Commit
5cf27c31
authored
Sep 22, 2013
by
Ivan Chepurnyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Observer generation helper
parent
0188c388
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
2 deletions
+100
-2
.travis.yml
.travis.yml
+0
-2
app/code/community/EcomDev/PHPUnit/Test/Case.php
app/code/community/EcomDev/PHPUnit/Test/Case.php
+1
-0
app/code/community/EcomDev/PHPUnit/Test/Case/Helper/Observer.php
...e/community/EcomDev/PHPUnit/Test/Case/Helper/Observer.php
+49
-0
app/code/community/EcomDev/PHPUnit/etc/config.xml
app/code/community/EcomDev/PHPUnit/etc/config.xml
+1
-0
app/code/community/EcomDev/PHPUnitTest/Test/Helper/Observer.php
...de/community/EcomDev/PHPUnitTest/Test/Helper/Observer.php
+49
-0
No files found.
.travis.yml
View file @
5cf27c31
...
@@ -20,8 +20,6 @@ before_script:
...
@@ -20,8 +20,6 @@ before_script:
-
bin/mage-ci shell $MAGE_DIR ecomdev-phpunit.php -a magento-config --db-name magento --same-db 1 --base_url http://test.magento.com/
-
bin/mage-ci shell $MAGE_DIR ecomdev-phpunit.php -a magento-config --db-name magento --same-db 1 --base_url http://test.magento.com/
# Configuring test suite
# Configuring test suite
-
bin/mage-ci shell $MAGE_DIR ecomdev-phpunit.php -a change-status --enable
-
bin/mage-ci shell $MAGE_DIR ecomdev-phpunit.php -a change-status --enable
# Fix Magento autoloader to run test
-
bin/mage-ci shell $MAGE_DIR ecomdev-phpunit.php -a fix-autoloader
# Copying phpunit.xml for travis builds
# Copying phpunit.xml for travis builds
-
cp .travis/phpunit.xml $MAGE_DIR/phpunit.xml
-
cp .travis/phpunit.xml $MAGE_DIR/phpunit.xml
script
:
script
:
...
...
app/code/community/EcomDev/PHPUnit/Test/Case.php
View file @
5cf27c31
...
@@ -30,6 +30,7 @@ use EcomDev_PHPUnit_Helper as TestHelper;
...
@@ -30,6 +30,7 @@ use EcomDev_PHPUnit_Helper as TestHelper;
* @method EcomDev_PHPUnit_Mock_Proxy adminSession(array $resources = array())
* @method EcomDev_PHPUnit_Mock_Proxy adminSession(array $resources = array())
* @method EcomDev_PHPUnit_Mock_Proxy customerSession(int $customerId)
* @method EcomDev_PHPUnit_Mock_Proxy customerSession(int $customerId)
* @method EcomDev_PHPUnit_Mock_Proxy guestSession()
* @method EcomDev_PHPUnit_Mock_Proxy guestSession()
* @method Varien_Event_Observer generateObserver(array $eventData, string $eventName = null)
*/
*/
abstract
class
EcomDev_PHPUnit_Test_Case
extends
PHPUnit_Framework_TestCase
abstract
class
EcomDev_PHPUnit_Test_Case
extends
PHPUnit_Framework_TestCase
{
{
...
...
app/code/community/EcomDev/PHPUnit/Test/Case/Helper/Observer.php
0 → 100644
View file @
5cf27c31
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Helper for stubbing event observer in Magento
*
*
*/
class
EcomDev_PHPUnit_Test_Case_Helper_Observer
extends
EcomDev_PHPUnit_Helper_Abstract
{
/**
* Generates observer object
*
* @param array $eventData
* @param string $eventName
*
* @return Varien_Event_Observer
*/
public
function
helperGenerateObserver
(
$eventData
,
$eventName
=
null
)
{
$event
=
new
Varien_Event
(
$eventData
);
$observer
=
new
Varien_Event_Observer
();
$observer
->
setEvent
(
$event
);
if
(
$eventName
)
{
$event
->
setName
(
$event
);
$observer
->
setEventName
(
$eventName
);
}
$observer
->
addData
(
$eventData
);
return
$observer
;
}
}
app/code/community/EcomDev/PHPUnit/etc/config.xml
View file @
5cf27c31
...
@@ -147,6 +147,7 @@
...
@@ -147,6 +147,7 @@
<session>
EcomDev_PHPUnit_Test_Case_Helper_Session
</session>
<session>
EcomDev_PHPUnit_Test_Case_Helper_Session
</session>
<customer>
EcomDev_PHPUnit_Test_Case_Helper_Customer
</customer>
<customer>
EcomDev_PHPUnit_Test_Case_Helper_Customer
</customer>
<guest>
EcomDev_PHPUnit_Test_Case_Helper_Guest
</guest>
<guest>
EcomDev_PHPUnit_Test_Case_Helper_Guest
</guest>
<observer>
EcomDev_PHPUnit_Test_Case_Helper_Observer
</observer>
</helpers>
</helpers>
</suite>
</suite>
</phpunit>
</phpunit>
...
...
app/code/community/EcomDev/PHPUnitTest/Test/Helper/Observer.php
0 → 100644
View file @
5cf27c31
<?php
class
EcomDev_PHPUnitTest_Test_Helper_Observer
extends
EcomDev_PHPUnit_Test_Case
{
public
function
testItStubsObserver
()
{
$eventData
=
array
(
'some_key'
=>
'some_value'
,
'another_key'
=>
'another_value'
);
$observer
=
$this
->
generateObserver
(
$eventData
);
$this
->
assertEventData
(
$eventData
,
$observer
);
$this
->
assertNull
(
$observer
->
getEventName
());
$this
->
assertNull
(
$observer
->
getEvent
()
->
getName
());
}
public
function
testItStubsObserverWithEventName
()
{
$eventData
=
array
(
'some_key'
=>
'some_value'
,
'another_key'
=>
'another_value'
);
$observer
=
$this
->
generateObserver
(
$eventData
,
'my_event_name'
);
$this
->
assertInstanceOf
(
'Varien_Event_Observer'
,
$observer
);
$this
->
assertEventData
(
$eventData
,
$observer
);
$this
->
assertEquals
(
'my_event_name'
,
$observer
->
getEventName
());
$this
->
assertEquals
(
'my_event_name'
,
$observer
->
getEvent
()
->
getName
());
}
protected
function
assertEventData
(
$eventData
,
$observer
)
{
foreach
(
$eventData
as
$key
=>
$value
)
{
$this
->
assertEquals
(
$value
,
$observer
->
getDataUsingMethod
(
$key
)
);
$this
->
assertEquals
(
$value
,
$observer
->
getEvent
()
->
getDataUsingMethod
(
$key
)
);
}
}
}
\ 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