Skip to content

Commit

Permalink
redo tests without using full zf2 as require-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fagundes committed Dec 28, 2015
1 parent 3c24382 commit 7e115fa
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 174 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If you want to help check the contribuing instructions [here](CONTRIBUTING.md).
## TODO

- [x] Bump the PHP minimum version to 5.4+
- [ ] Create more unit tests
- [x] Create more unit tests
- [ ] Rewrite html2pdf examples using `Zff\Html2Pdf`
- [ ] Create a way to easily change params from HTML2PDF's constructor, called on `Html2PdfRenderer` class, on controller, view or config file.

Expand Down
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
"spipu/html2pdf":"~4.4"
},
"require-dev": {
"zendframework/zendframework":"~2.4.0",
"zendframework/zend-servicemanager":"~2.4",
"zendframework/zend-modulemanager":"~2.4",
"zendframework/zend-mvc":"~2.4",
"zendframework/zend-filter":"~2.4",
"zendframework/zend-serializer":"~2.4",
"zendframework/zend-log":"~2.4",
"zendframework/zend-i18n":"~2.4",
"zendframework/zend-console":"~2.4",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2",
"thomasbachem/php-short-array-syntax-converter": "dev-master"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./test/Bootstrap.php"
bootstrap="./vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="zff-html2pdf Test Suite">
Expand Down
134 changes: 0 additions & 134 deletions test/Bootstrap.php

This file was deleted.

32 changes: 14 additions & 18 deletions test/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace ZffTest\Html2Pdf;

use PHPUnit_Framework_TestCase as TestCase;
use Zff\Html2Pdf\Module;

/**
* @author Vinicius Fagundes <mvlacerda@gmail.com>
Expand All @@ -15,30 +16,25 @@ class ModuleTest extends TestCase
{

/**
* Scans service manager configuration, returning all services created by factories and invokables
* @return array
* @var Module
*/
public function provideServiceList()
protected $module;

public function setUp()
{
return [
[
'service' => 'ViewHtml2PdfStrategy',
'class' => '\Zff\Html2Pdf\View\Strategy\Html2PdfStrategy'
]
];
$this->module = new Module;
}

/**
* @dataProvider provideServiceList
*/
public function testService($service, $class)
public function testConfig()
{
$sm = Bootstrap::getServiceManager();
$this->assertNotEmpty($this->module->getConfig());

// test if service is available in SM
$this->assertTrue($sm->has($service));
$configArr = include __DIR__.'/../config/module.config.php';

$this->assertEquals($configArr, $this->module->getConfig());
}

// test if correct instance is created
$this->assertInstanceOf($class, $sm->get($service));
public function testAutoloader() {
$this->assertNotEmpty($this->module->getAutoloaderConfig());
}
}
46 changes: 46 additions & 0 deletions test/Mvc/Service/ViewHtml2PdfStrategyFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* @license http://opensource.org/licenses/MIT MIT
* @copyright Copyright (c) 2015 Vinicius Fagundes
*/

namespace ZffTest\Html2Pdf\Mvc\Service;

use PHPUnit_Framework_TestCase as TestCase;
use Zff\Html2Pdf\Mvc\Service\ViewHtml2PdfStrategyFactory;
use Zend\ServiceManager\ServiceManager;
use Zend\Mvc\Service\ServiceManagerConfig;
use Zend\Mvc\Application;

class ViewHtml2PdfStrategyFactoryTest extends TestCase
{
/**
* @var ServiceManager
*/
protected $serviceManager;

public function setUp()
{
$config = ['modules' => ['Zff\\Html2Pdf'], 'module_listener_options' => []];

$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();

$application = new Application($config, $serviceManager);
$application->bootstrap();

$this->serviceManager = $serviceManager;
}

public function testCanCreateHtml2PdfStrategyFromNewFactoryInstance()
{
$factory = new ViewHtml2PdfStrategyFactory;
$this->assertInstanceOf('\Zff\Html2Pdf\View\Strategy\Html2PdfStrategy', $factory->createService($this->serviceManager));
}

public function testCanCreateHtml2PdfStrategyFromServiceManager()
{
$this->assertInstanceOf('\Zff\Html2Pdf\View\Strategy\Html2PdfStrategy', $this->serviceManager->get('ViewHtml2PdfStrategy'));
}
}
19 changes: 0 additions & 19 deletions test/TestConfig.php

This file was deleted.

0 comments on commit 7e115fa

Please sign in to comment.