403Webshell
Server IP : 202.61.199.114  /  Your IP : 216.73.217.139
Web Server : nginx/1.22.1
System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
User : web20 ( 1018)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/clients/client2/api.pacim.de/web/vendor/psx/sql/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/clients/client2/api.pacim.de/web/vendor/psx/sql/tests/ViewAbstractTest.php
<?php
/*
 * PSX is a open source PHP framework to develop RESTful APIs.
 * For the current version and informations visit <http://phpsx.org>
 *
 * Copyright 2010-2017 Christoph Kappestein <christoph.kappestein@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace PSX\Sql\Tests;

use PSX\Sql\TableManager;

/**
 * ViewAbstractTest
 *
 * @author  Christoph Kappestein <christoph.kappestein@gmail.com>
 * @license http://www.apache.org/licenses/LICENSE-2.0
 * @link    http://phpsx.org
 */
class ViewAbstractTest extends \PHPUnit_Extensions_Database_TestCase
{
    /**
     * @var \Doctrine\DBAL\Connection
     */
    protected $connection;

    /**
     * @var \PSX\Sql\TableManagerInterface
     */
    protected $manager;

    protected function setUp()
    {
        parent::setUp();

        $this->connection = getConnection();
        $this->manager    = new TableManager($this->connection);
    }

    public function getDataSet()
    {
        return $this->createFlatXMLDataSet(__DIR__ . '/table_fixture.xml');
    }

    public function getConnection()
    {
        return $this->createDefaultDBConnection(getConnection()->getWrappedConnection(), '');
    }

    /**
     * @return TestView
     */
    protected function getTable()
    {
        return $this->manager->getTable(TestView::class);
    }

    public function testGetNestedResult()
    {
        $result = $this->getTable()->getNestedResult();
        $actual = json_encode($result, JSON_PRETTY_PRINT);
        $expect = <<<JSON
[
    {
        "id": 4,
        "title": "Blub",
        "author": {
            "id": "urn:profile:3",
            "date": "2013-04-29T16:56:32Z"
        },
        "count": 4,
        "tags": [
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32"
        ]
    },
    {
        "id": 3,
        "title": "Test",
        "author": {
            "id": "urn:profile:2",
            "date": "2013-04-29T16:56:32Z"
        },
        "count": 4,
        "tags": [
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32"
        ]
    },
    {
        "id": 2,
        "title": "Bar",
        "author": {
            "id": "urn:profile:1",
            "date": "2013-04-29T16:56:32Z"
        },
        "count": 4,
        "tags": [
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32"
        ]
    },
    {
        "id": 1,
        "title": "Foo",
        "author": {
            "id": "urn:profile:1",
            "date": "2013-04-29T16:56:32Z"
        },
        "note": {
            "comments": true,
            "title": "foobar"
        },
        "count": 4,
        "tags": [
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32",
            "2013-04-29 16:56:32"
        ]
    }
]
JSON;

        $this->assertJsonStringEqualsJsonString($expect, $actual, $actual);
    }

    public function testGetNestedResultKey()
    {
        $result = $this->getTable()->getNestedResultKey();
        $actual = json_encode($result, JSON_PRETTY_PRINT);
        $expect = <<<JSON
{
    "eccbc87e": {
        "id": 4,
        "title": "Blub",
        "author": {
            "id": "urn:profile:3",
            "date": "2013-04-29T16:56:32Z"
        }
    },
    "c81e728d": {
        "id": 3,
        "title": "Test",
        "author": {
            "id": "urn:profile:2",
            "date": "2013-04-29T16:56:32Z"
        }
    },
    "c4ca4238": {
        "id": 1,
        "title": "Foo",
        "author": {
            "id": "urn:profile:1",
            "date": "2013-04-29T16:56:32Z"
        },
        "note": {
            "comments": true,
            "title": "foobar"
        }
    }
}
JSON;

        $this->assertJsonStringEqualsJsonString($expect, $actual, $actual);
    }

    public function testGetNestedResultFilter()
    {
        $result = $this->getTable()->getNestedResultFilter();
        $actual = json_encode($result, JSON_PRETTY_PRINT);
        $expect = <<<JSON
[
    {
        "id": 2,
        "title": "Bar",
        "author": {
            "id": "urn:profile:1",
            "date": "2013-04-29T16:56:32Z"
        }
    },
    {
        "id": 1,
        "title": "Foo",
        "author": {
            "id": "urn:profile:1",
            "date": "2013-04-29T16:56:32Z"
        },
        "note": {
            "comments": true,
            "title": "foobar"
        }
    }
]
JSON;

        $this->assertJsonStringEqualsJsonString($expect, $actual, $actual);
    }

    public function testGetNestedResultFields()
    {
        $result = $this->getTable()->getNestedResultFields();
        $actual = json_encode($result, JSON_PRETTY_PRINT);
        $expect = <<<JSON
{
    "boolean": true,
    "callback": "bar",
    "csv": [
        "foo",
        "bar"
    ],
    "dateTime": "2017-03-05T00:00:00Z",
    "integer": 1,
    "json": {
        "foo": "bar"
    },
    "number": 12.34,
    "replace": "http:\/\/foo.com\/foo",
    "type": 1,
    "value": "bar"
}
JSON;

        $this->assertJsonStringEqualsJsonString($expect, $actual, $actual);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit