File: InvocationTest.php

package info (click to toggle)
php-mock 2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 340 kB
  • sloc: php: 1,740; makefile: 18; xml: 17; sh: 7
file content (41 lines) | stat: -rw-r--r-- 1,237 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

namespace phpmock\spy;

use PHPUnit\Framework\TestCase;

/**
 * Tests the Invocation.
 *
 * @author Markus Malkusch <markus@malkusch.de>
 * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations
 * @license http://www.wtfpl.net/txt/copying/ WTFPL
 * @see Invocation
 */
class InvocationTest extends TestCase
{
    public function testInvocationWithoutException()
    {
        $arguments = [1, 2];
        $return = 3;
        $invocation = new Invocation($arguments, $return);

        self::assertSame($arguments, $invocation->getArguments());
        self::assertSame($return, $invocation->getReturn());
        self::assertNull($invocation->getException());
        self::assertFalse($invocation->isExceptionThrown());
    }

    public function testInvocationWithException()
    {
        $arguments = [1, 2];
        $return = 3;
        $exception = new \Exception('Test exception');
        $invocation = new Invocation($arguments, $return, $exception);

        self::assertSame($arguments, $invocation->getArguments());
        self::assertSame($return, $invocation->getReturn());
        self::assertSame($exception, $invocation->getException());
        self::assertTrue($invocation->isExceptionThrown());
    }
}