Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Commit

Permalink
Added integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Apr 24, 2017
1 parent 6f87a70 commit a399a7f
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ coverage: install
open-coverage:
open coverage/index.html

integration: install
test/integration/run

lint: test/bin/php-cs-fixer
test/bin/php-cs-fixer fix --using-cache no

Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"Eloquent\\Phony\\Peridot\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Eloquent\\Phony\\Peridot\\": "test/src"
}
},
"config": {
"platform": {
"php": "5.4.99999"
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions test/integration/Phony.spec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* This file is part of the Phony package.
*
* Copyright © 2017 Erin Millard
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/

use Eloquent\Phony\Phony;

error_reporting(-1);

describe('Phony', function () {
beforeEach(function () {
$this->handle = Phony::mock('Eloquent\Phony\Peridot\Test\TestClassA');
$this->mock = $this->handle->get();
});

it('should record passing mock assertions', function () {
$this->mock->testClassAMethodA('aardvark', 'bonobo');

$this->handle->testClassAMethodA->calledWith('aardvark', 'bonobo');
});

it('should record failing mock assertions', function () {
$this->mock->testClassAMethodA('aardvark', ['bonobo', 'capybara', 'dugong']);
$this->mock->testClassAMethodA('armadillo', ['bonobo', 'chameleon', 'dormouse']);

$this->handle->testClassAMethodA->calledWith('aardvark', ['bonobo', 'chameleon', 'dugong']);
});
});
8 changes: 8 additions & 0 deletions test/integration/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

echo
echo ===========================================================================
echo Peridot
echo ===========================================================================

vendor/bin/peridot test/integration
75 changes: 75 additions & 0 deletions test/src/Test/TestClassA.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

/*
* This file is part of the Phony package.
*
* Copyright © 2016 Erin Millard
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/

namespace Eloquent\Phony\Peridot\Test;

class TestClassA
{
public static function testClassAStaticMethodA()
{
return implode(func_get_args());
}

public static function testClassAStaticMethodB($first, $second)
{
return implode(func_get_args());
}

public function __construct(&$first = null, &$second = null)
{
$this->constructorArguments = func_get_args();

$first = 'first';
$second = 'second';
}

public function testClassAMethodA()
{
return implode(func_get_args());
}

public function testClassAMethodB($first, $second)
{
return implode(func_get_args());
}

protected static function testClassAStaticMethodC()
{
return 'protected ' . implode(func_get_args());
}

protected static function testClassAStaticMethodD($first, $second)
{
return 'protected ' . implode(func_get_args());
}

protected function testClassAMethodC()
{
return 'protected ' . implode(func_get_args());
}

protected function testClassAMethodD(&$first, &$second)
{
return 'protected ' . implode(func_get_args());
}

private static function testClassAStaticMethodE()
{
return 'private ' . implode(func_get_args());
}

private function testClassAMethodE()
{
return 'private ' . implode(func_get_args());
}

public $constructorArguments;
}

0 comments on commit a399a7f

Please sign in to comment.