AddonStructure.php

<?php


namespace Lia\Test\Disabled;

class AddonStructure extends \Tlf\Tester {


    public function testServerPackage(){
        // these features changed & some disabled for v0.6
        // it's just so simple now i don't need all this testing
        // a cleaned up version of this test for v0.6 is in the Other/Documentation.php test class
        $this->disable();
        $lia = new \Lia();
        $server = new \Lia\Package\Server($lia);
        $main = new \Lia\Package\Server($lia, 'main', '/my/sites/dir/');
        $extra_addon = new \Lia\Addon\View($main, 'extra');

        $addons = [
            'server'=>[
                'package'=>$server,
                'autoload'=> $server->addons['autoload'],
                'cache'=> $server->addons['cache'],
                'error'=> $server->addons['error'],
                'hook'=> $server->addons['hook'],
                'resourcesorter'=> $server->addons['resourcesorter'],
                'resources'=> $server->addons['resources'],
                'router'=> $server->addons['router'],
                'server'=> $server->addons['server'],
                'seo'=> $server->addons['seo'],
                'view'=> $server->addons['view'],
            ],
            'main'=>[
                'package'=>$main,
                'extra'=>$extra_addon
            ]
        ];

        $router = $lia->addons['server']['router'];


        $this->compare($server->addons['router'],$router);
        $this->compare_arrays($addons, $lia->addons);
    }

    public function testInLiaison(){
        // these features changed & some disabled for v0.6
        // it's just so simple now i don't need all this testing
        $this->disable();
        return;
        $this->test("Liaison alone");
        $lia = new \Lia();
        $t_lia = [];
        $this->compare_arrays($t_lia, $lia->addons);


        $this->test("With One Package");
        $package = new \Lia\Package($lia, 'test');
        $t_pack = ['package'=>$package];
        $t_lia = [
            'test'=>[
                'package'=>$package
            ]
        ];
        $this->compare_arrays($t_pack, $package->addons);
        $this->compare_arrays($t_lia, $lia->addons);



        $this->test("With Two Packages");
        // with two packages
        $package2 = new \Lia\Package($lia, 'test2');
        $t_pack2 = ['package'=>$package2];
        $t_lia = [
            'test'=>['package'=>$package],
            'test2'=>['package'=>$package2]
        ];
        $this->compare_arrays($t_pack, $package->addons);
        $this->compare_arrays($t_pack2, $package2->addons);
        $this->compare_arrays($t_lia, $lia->addons);


        $this->test("With 2 addons in each package");
        // with two packages and some addons in each
        $view1 = new \Lia\Addon\View($package);
        $router1 = new \Lia\Addon\Router($package);
        $hook2 = new \Lia\Addon\Hook($package2);
        $autoload2 = new \Lia\Addon\Autoload($package2);


        $t_lia = [
            'test'=>['package'=>$package, 'view'=>$view1, 'router'=>$router1],
            'test2'=>['package'=>$package2, 'hook'=>$hook2, 'autoload'=>$autoload2],
        ];
        $this->compare_arrays($t_lia, $lia->addons);

        $t_pack1 = [
            'package'=>$package, 'view'=>$view1, 'router'=>$router1
        ];
        $t_pack2 = [
            'package'=>$package2, 'hook'=>$hook2, 'autoload'=>$autoload2
        ];

        $this->compare_arrays($t_pack1, $package->addons);
        $this->compare_arrays($t_pack2, $package2->addons);
    }

    /**
     *
     * @test package's addon array with no addons, with no liaison
     * @test package's addon array with two addons, with no liaison
     */
    public function testInPackage(){

        // these features changed/disabled for v0.6
        $this->disable();
        return;
        $package = new \Lia\Package(new \Lia(), 'whatever');

        $this->compare_arrays(['package'=>$package], $package->addons);

        $view = new \Lia\Addon\View($package);
        $this->compare_arrays(['package'=>$package, 'view'=>$view], $view->addons);
        $this->compare_arrays(['package'=>$package, 'view'=>$view], $package->addons);

        $hook= new \Lia\Addon\Hook($package);

        $this->compare_arrays(['package'=>$package, 'view'=>$view, 'hook'=>$hook], $view->addons);
        $this->compare_arrays(['package'=>$package, 'view'=>$view, 'hook'=>$hook], $hook->addons);
        $this->compare_arrays(['package'=>$package, 'view'=>$view, 'hook'=>$hook], $package->addons);
    }

    /** 
     * @test addon array when addon has no liaison
     * @test addon array when addon has an addon as its liaison
     */
    public function testStandalone(){
        // this feature disabled for v0.6
        $this->disable();
        return;
        $lia = new \Lia();
        $view = new \Lia\Addon\View($lia);

        $this->compare_arrays(['view'=>$view], $view->addons);

        $hook = new \Lia\Addon\Hook($view);

        $this->compare_arrays(['view'=>$view, 'hook'=>$hook], $view->addons, true);
    }

}