Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Jan 15, 2019
1 parent e3f3f37 commit 0399fb5
Show file tree
Hide file tree
Showing 24 changed files with 1,021 additions and 1,017 deletions.
2 changes: 1 addition & 1 deletion phive.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phploc" version="^3.0.1" installed="3.0.1" location="./tools/phploc"/>
<phar name="phpunit" version="^6.0" installed="6.5.8" location="./tools/phpunit"/>
<phar name="phpunit" version="^7.0" installed="7.5.1" location="./tools/phpunit" copy="false"/>
<phar name="phpab" version="^1.23.0" installed="1.24.1" location="./tools/phpab"/>
</phive>
57 changes: 29 additions & 28 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by PHP Project Wizard (PPW) 1.0.4 on Fri Mar 11 16:37:31 CET 2011 -->

<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
strict="true"
verbose="true"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="phpDox">
<directory suffix="Test.php">tests/Unit</directory>
<directory suffix="Test.php">tests/Integration</directory>
</testsuite>
</testsuites>
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
beStrictAboutChangesToGlobalState="true"
bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="phpDox">
<directory suffix="Test.php">tests/Unit</directory>
<directory suffix="Test.php">tests/Integration</directory>
</testsuite>
</testsuites>

<logging>
<log type="coverage-html" target="build/logs/coverage/html" title="phpDox"
charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-xml" target="build/logs/coverage/xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
<logging>
<log type="coverage-html" showUncoveredFiles="true" target="build/logs/coverage/html" lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-xml" target="build/logs/coverage/xml"/>
<log type="junit" target="build/logs/junit.xml"/>
</logging>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/bootstrap</directory>
</exclude>
</whitelist>
</filter>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/bootstrap</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
162 changes: 162 additions & 0 deletions tests/Integration/FactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<?php
/**
* Copyright (c) 2010-2015 Arne Blankerts <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Arne Blankerts nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package phpDox
* @subpackage Tests
* @author Bastian Feder <[email protected]>
* @copyright Arne Blankerts <[email protected]>, All rights reserved.
* @license BSD License
*/
namespace TheSeer\phpDox\Tests\Integration;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use TheSeer\phpDox\Application;
use TheSeer\phpDox\Collector\Collector;
use TheSeer\phpDox\CollectorConfig;
use TheSeer\phpDox\DocBlock\Parser;
use TheSeer\phpDox\ErrorHandler;
use TheSeer\phpDox\Factory;
use TheSeer\phpDox\FileInfo;
use TheSeer\phpDox\Generator\Generator;
use TheSeer\phpDox\Version;

/**
* Class FactoryTest
*
* @covers \TheSeer\phpDox\Factory
* @uses \TheSeer\phpDox\version
*/
class FactoryTest extends TestCase {

/**
* @var Factory
*/
private $factory;

protected function setUp() {
$this->factory = new Factory(new FileInfo(__DIR__), new Version('0.0'));
}

/**
* @covers \TheSeer\phpDox\Factory::getApplication
* @uses \TheSeer\phpDox\Application
* @uses \TheSeer\phpDox\ShellProgressLogger
*/
public function testGetApplication() {
$this->assertInstanceOf(
Application::class,
$this->factory->getApplication()
);
}

/**
* @covers \TheSeer\phpDox\Factory::getCollector
* @uses \TheSeer\phpDox\ShellProgressLogger
* @uses \TheSeer\phpDox\FileInfo
* @uses \TheSeer\phpDox\Collector\Collector
* @uses \TheSeer\phpDox\Collector\IndexCollection
* @uses \TheSeer\phpDox\Collector\SourceCollection
* @uses \TheSeer\phpDox\Collector\Project
* @uses \TheSeer\phpDox\Collector\Backend\Factory
* @uses \TheSeer\phpDox\Collector\Backend\PHPParser
* @uses \TheSeer\phpDox\DocBlock\Parser
* @uses \TheSeer\phpDox\ErrorHandler
*/
public function testGetCollector() {
/** @var CollectorConfig|MockObject $config */
$config = $this->getMockBuilder(CollectorConfig::class)
->disableOriginalConstructor()
->getMock();

$config->expects($this->once())
->method('getSourceDirectory')
->willReturn(new FileInfo(''));

$config->expects($this->once())
->method('getWorkDirectory')
->willReturn(new FileInfo(''));

$config->expects($this->once())
->method('getBackend')
->willReturn('parser');

$this->assertInstanceOf(
Collector::class,
$this->factory->getCollector($config)
);
}

/**
* @covers \TheSeer\phpDox\Factory::getGenerator
* @uses \TheSeer\phpDox\Generator\Generator
* @uses \TheSeer\phpDox\ShellProgressLogger
*/
public function testGetGenerator() {
$this->assertInstanceOf(
Generator::class,
$this->factory->getGenerator()
);
}

/**
* @covers \TheSeer\phpDox\Factory::getDocblockFactory
* @uses \TheSeer\phpDox\DocBlock\Factory
*/
public function testgetDoclockFactory() {
$docBlock = $this->factory->getDocblockFactory();

// lazy initialization included
$this->assertInstanceOf(
\TheSeer\phpDox\DocBlock\Factory::class,
$docBlock
);

$this->assertSame($docBlock, $this->factory->getDocblockFactory());
}

/**
* @covers \TheSeer\phpDox\Factory::getDocblockParser
* @uses \TheSeer\phpDox\DocBlock\Parser
*/
public function testgetDoclockParser() {
$docBlock = $this->factory->getDocblockParser();

// lazy initialization included
$this->assertInstanceOf(
Parser::class,
$docBlock
);

$this->assertSame($docBlock, $this->factory->getDocblockParser());
}

}
Loading

0 comments on commit 0399fb5

Please sign in to comment.