PageRenderTime 48ms CodeModel.GetById 44ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/class/libraries/vendor/ircmaxell/security-lib/test/Unit/Core/AbstractFactoryTest.php

https://gitlab.com/VoyaTrax/vtCMS2
PHP | 67 lines | 44 code | 11 blank | 12 comment | 0 complexity | 26c327a59a4024c08b561d0e3f614636 MD5 | raw file
 1<?php
 2
 3use SecurityLibTest\Mocks\Factory;
 4
 5use org\bovigo\vfs\vfsStream;
 6
 7class Unit_Core_AbstractFactoryTest extends PHPUnit_Framework_TestCase {
 8
 9    protected function setUp() {
10        $root = vfsStream::setup('SecurityLibTest');
11        //Setup Folders
12        $core = vfsStream::newDirectory('Core')->at($root);
13        $af = vfsStream::newDirectory('AbstractFactory')->at($core);
14
15        // Create Files
16        vfsStream::newFile('test.php')->at($af);
17        vfsStream::newFile('Some234Foo234Bar98Name.php')->at($af);
18        vfsStream::newFile('Invalid.csv')->at($af);
19        vfsStream::newFile('badlocation.php')->at($core);
20    }
21
22    /**
23     * @covers SecurityLib\AbstractFactory::registerType
24     */
25    public function testRegisterType() {
26        $factory = new Factory;
27        $factory->registerType('test', 'iteratoraggregate', 'foo', 'ArrayObject', false);
28    }
29
30    /**
31     * @covers SecurityLib\AbstractFactory::registerType
32     * @expectedException InvalidArgumentException
33     */
34    public function testRegisterTypeFail() {
35        $factory = new Factory;
36        $factory->registerType('test', 'iterator', 'foo', 'ArrayObject', false);
37    }
38
39    /**
40     * @covers SecurityLib\AbstractFactory::registerType
41     */
42    public function testRegisterTypeInstantiate() {
43        $factory = new Factory;
44        $factory->registerType('test', 'iteratoraggregate', 'foo', 'ArrayObject', true);
45    }
46
47    public function testLoadFiles() {
48        $dir = vfsStream::url('SecurityLibTest/Core/AbstractFactory');
49
50        $result = array();
51        $callback = function($name, $class) use (&$result) {
52            $result[$name] = $class;
53        };
54
55        $factory = new Factory();
56        $factory->loadFiles($dir, 'foo\\', $callback);
57
58        $expect = array(
59            'test' => 'foo\\test',
60            'Some234Foo234Bar98Name' => 'foo\\Some234Foo234Bar98Name'
61        );
62
63        $this->assertEquals($expect, $result);
64    }
65
66
67}