CartTest
extends TestCase
in package
Uses
WithConsecutiveTrait
Cart Test Class
Tags
Table of Contents
- $loader : MockObject|Loader
- Mock record loader
- setUp() : void
- Standard setup method.
- testActiveCart() : void
- Test an active cart.
- testCartCanBeEmptied() : void
- Test the "empty cart" method.
- testContains() : void
- Test the contains method.
- testCookieDomain() : void
- Test cookie domain setting.
- testCookieWrite() : void
- Test that the save method writes the expected cookies.
- testDisabledCart() : void
- Test a disabled cart.
- testEmptyCart() : void
- Check that the cart is empty by default.
- testFullCart() : void
- Test that the cart can fill up.
- testGetRecordDetails() : void
- Test the "get record details" method.
- testMaxSize() : void
- Check that the cart correctly registers a maximum size.
- testRemoveItems() : void
- Test the "remove items" method.
- testVF1Cookie() : void
- Test loading values from a VuFind 1.x-style cookie.
- testVF2Cookie() : void
- Test loading values from a VuFind 2.x-style cookie.
- expectConsecutiveCalls() : InvocationStubber
- Expect consecutive calls to a mock.
- getCart() : Cart
- Build a mock cart object.
- getMockCookieManager() : CookieManager
- Build a mock cookie manager.
Properties
$loader
Mock record loader
protected
MockObject|Loader
$loader
Methods
setUp()
Standard setup method.
public
setUp() : void
Return values
void —testActiveCart()
Test an active cart.
public
testActiveCart() : void
Return values
void —testCartCanBeEmptied()
Test the "empty cart" method.
public
testCartCanBeEmptied() : void
Return values
void —testContains()
Test the contains method.
public
testContains() : void
Return values
void —testCookieDomain()
Test cookie domain setting.
public
testCookieDomain() : void
Return values
void —testCookieWrite()
Test that the save method writes the expected cookies.
public
testCookieWrite() : void
Return values
void —testDisabledCart()
Test a disabled cart.
public
testDisabledCart() : void
Return values
void —testEmptyCart()
Check that the cart is empty by default.
public
testEmptyCart() : void
Return values
void —testFullCart()
Test that the cart can fill up.
public
testFullCart() : void
Return values
void —testGetRecordDetails()
Test the "get record details" method.
public
testGetRecordDetails() : void
Return values
void —testMaxSize()
Check that the cart correctly registers a maximum size.
public
testMaxSize() : void
Return values
void —testRemoveItems()
Test the "remove items" method.
public
testRemoveItems() : void
Return values
void —testVF1Cookie()
Test loading values from a VuFind 1.x-style cookie.
public
testVF1Cookie() : void
Return values
void —testVF2Cookie()
Test loading values from a VuFind 2.x-style cookie.
public
testVF2Cookie() : void
Return values
void —expectConsecutiveCalls()
Expect consecutive calls to a mock.
protected
expectConsecutiveCalls(MockObject $mock, string $method, array<string|int, mixed> $expectedCalls[, mixed $returnValues = null ]) : InvocationStubber
Parameters
- $mock : MockObject
-
Mock object
- $method : string
-
Method expecting calls
- $expectedCalls : array<string|int, mixed>
-
Expected input parameters
- $returnValues : mixed = null
-
Return values to mock (either an array indexed parallel to $expectedCalls to return different values, or a single value to always return the same thing)
Return values
InvocationStubber —getCart()
Build a mock cart object.
protected
getCart([int $maxSize = 100 ][, bool $active = true ][, array<string|int, mixed>|CookieManager $cookies = [] ]) : Cart
Parameters
- $maxSize : int = 100
-
Maximum size of cart contents
- $active : bool = true
-
Is cart enabled?
- $cookies : array<string|int, mixed>|CookieManager = []
-
Current cookie values (or ready-to-use cookie manager)
Return values
Cart —getMockCookieManager()
Build a mock cookie manager.
protected
getMockCookieManager([array<string|int, mixed> $cookies = [] ][, string $path = '/' ][, string $domain = null ][, bool $secure = false ][, bool $httpOnly = false ]) : CookieManager
Parameters
- $cookies : array<string|int, mixed> = []
-
Current cookie values
- $path : string = '/'
-
Cookie base path (default = /)
- $domain : string = null
-
Cookie domain
- $secure : bool = false
-
Are cookies secure only? (default = false)
- $httpOnly : bool = false
-
Are cookies HTTP only? (default = false)