Skip to content

Commit

Permalink
// switched to the Phake mocking framework
Browse files Browse the repository at this point in the history
  • Loading branch information
djfm committed Apr 17, 2015
1 parent b60a422 commit 1be0118
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 136 deletions.
22 changes: 0 additions & 22 deletions tests/Helper/Mocks/CacheMock.php

This file was deleted.

31 changes: 0 additions & 31 deletions tests/Helper/Mocks/DbMock.php

This file was deleted.

22 changes: 14 additions & 8 deletions tests/TestCase/UnitTestCase.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php


namespace PrestaShop\PrestaShop\Tests\TestCase;

use Exception;

use Cache;
use Context;
Expand All @@ -12,6 +11,8 @@
use PrestaShop\PrestaShop\Tests\Helper\Mocks\DbMock;
use PrestaShop\PrestaShop\Tests\Helper\Mocks\CacheMock;

use Phake;

class UnitTestCase extends PHPUnit_Framework_TestCase
{
/**
Expand All @@ -29,19 +30,24 @@ class UnitTestCase extends PHPUnit_Framework_TestCase
*/
public $cache;

public function setUpCommonStaticMocks()
public function setupDatabaseMock()
{
$this->database = $this->getMockBuilder('PrestaShop\PrestaShop\Tests\Helper\Mocks\DbMock')->getMock();
$this->database = Phake::mock('Db');
Db::setInstanceForTesting($this->database);
}

public function setUpCommonStaticMocks()
{
$this->setupDatabaseMock();

$this->context = $this->getMockBuilder('Context')->getMock();
$this->context = Phake::mock('Context');

$this->context->method('cloneContext')->willReturn($this->context);
Phake::when($this->context)->cloneContext()->thenReturn($this->context);

$this->context->shop = $this->getMockBuilder('Shop')->getMock();
$this->context->shop = Phake::mock('Shop');
Context::setInstanceForTesting($this->context);

$this->cache = $this->getMockBuilder('PrestaShop\PrestaShop\Tests\Helper\Mocks\CacheMock')->getMock();
$this->cache = Phake::mock('Cache');
Cache::setInstanceForTesting($this->cache);
}

Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/classes/CartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Order;
use Tools;

use Phake;

class FakeConfiguration implements Core_Business_Configuration
{
private $keys;
Expand Down Expand Up @@ -89,11 +91,11 @@ public function setup()
$this->productPriceCalculator = new FakeProductPriceCalculator;
$this->container->bind('Adapter_ProductPriceCalculator', $this->productPriceCalculator);

$addressFactory = $this->getMockBuilder('Adapter_AddressFactory')->getMock();
$addressFactory = Phake::mock('Adapter_AddressFactory');
$address = new Address;
$address->id = 1;
$addressFactory->method('findOrCreate')->willReturn($address);

Phake::when($addressFactory)->findOrCreate()->thenReturn($address);
$this->container->bind('Adapter_AddressFactory', $addressFactory);

$this->cart = new Cart;
Expand Down
3 changes: 2 additions & 1 deletion tests/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
}
],
"require": {
"phpunit/phpunit": "~4.5"
"phpunit/phpunit": "~4.5",
"phake/phake": "@stable"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 1be0118

Please sign in to comment.