refactor: Cleanup git state - commit all staged changes
Major refactoring cleanup: - Add new controller architecture (class-controller-*.php) - Add new settings-v2 UI (views/settings-v2/) - Add new CSS architecture (agentic-sidebar.css, tokens) - Add esbuild build pipeline (scripts/build.js, package.json) - Add composer dependencies (vendor/) - Add frontend src directory (assets/js/src/index.jsx) - Add documentation files - Remove old/obsolete files (class-settings.php, old CSS) This commits all pending changes from previous refactoring efforts.
This commit is contained in:
201
vendor/phpdocumentor/graphviz/tests/phpDocumentor/GraphViz/Test/AttributeTest.php
vendored
Normal file
201
vendor/phpdocumentor/graphviz/tests/phpDocumentor/GraphViz/Test/AttributeTest.php
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\GraphViz\Test;
|
||||
|
||||
use phpDocumentor\GraphViz\Attribute;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test for the the class representing a GraphViz attribute.
|
||||
*/
|
||||
class AttributeTest extends TestCase
|
||||
{
|
||||
/** @var Attribute */
|
||||
protected $fixture = null;
|
||||
|
||||
/**
|
||||
* Initializes the fixture for this test.
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->fixture = new Attribute('a', '1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the construct method
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::__construct
|
||||
* @returnn void
|
||||
*/
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$fixture = new Attribute('MyKey', 'MyValue');
|
||||
$this->assertInstanceOf(
|
||||
Attribute::class,
|
||||
$fixture
|
||||
);
|
||||
$this->assertSame('MyKey', $fixture->getKey());
|
||||
$this->assertSame('MyValue', $fixture->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getting and setting of the key.
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::getKey
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::setKey
|
||||
*/
|
||||
public function testKey(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture->getKey(),
|
||||
'a',
|
||||
'Expecting the key to match the initial state'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setKey('b'),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture->getKey(),
|
||||
'b',
|
||||
'Expecting the key to contain the new value'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getting and setting of the value.
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::getValue
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::setValue
|
||||
*/
|
||||
public function testValue(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture->getValue(),
|
||||
'1',
|
||||
'Expecting the value to match the initial state'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setValue('2'),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture->getValue(),
|
||||
'2',
|
||||
'Expecting the value to contain the new value'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether a string starting with a < is recognized as HTML.
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::isValueInHtml
|
||||
*/
|
||||
public function testIsValueInHtml(): void
|
||||
{
|
||||
$this->fixture->setValue('a');
|
||||
$this->assertFalse(
|
||||
$this->fixture->isValueInHtml(),
|
||||
'Expected value to not be a HTML code'
|
||||
);
|
||||
|
||||
$this->fixture->setValue('<a>test</a>');
|
||||
$this->assertTrue(
|
||||
$this->fixture->isValueInHtml(),
|
||||
'Expected value to be recognized as a HTML code'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the toString provides a valid GraphViz attribute string.
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::__toString
|
||||
*/
|
||||
public function testToString(): void
|
||||
{
|
||||
$this->fixture = new Attribute('a', 'b');
|
||||
$this->assertSame(
|
||||
'a="b"',
|
||||
(string) $this->fixture,
|
||||
'Strings should be surrounded with quotes'
|
||||
);
|
||||
|
||||
$this->fixture->setValue('a"a');
|
||||
$this->assertSame(
|
||||
'a="a\"a"',
|
||||
(string) $this->fixture,
|
||||
'Strings should be surrounded with quotes'
|
||||
);
|
||||
|
||||
$this->fixture->setKey('url');
|
||||
$this->assertSame(
|
||||
'URL="a\"a"',
|
||||
(string) $this->fixture,
|
||||
'The key named URL must be uppercased'
|
||||
);
|
||||
|
||||
$this->fixture->setValue('<a>test</a>');
|
||||
$this->assertSame(
|
||||
'URL=<a>test</a>',
|
||||
(string) $this->fixture,
|
||||
'HTML strings should not be surrounded with quotes'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the toString provides a valid GraphViz attribute string.
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::__toString
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::encodeSpecials
|
||||
*/
|
||||
public function testToStringWithSpecials(): void
|
||||
{
|
||||
$this->fixture = new Attribute('a', 'b');
|
||||
|
||||
$this->fixture->setValue('a\la');
|
||||
$this->assertSame(
|
||||
'a="a\la"',
|
||||
(string) $this->fixture,
|
||||
'Specials should not be escaped'
|
||||
);
|
||||
$this->fixture->setValue('a\l"a');
|
||||
$this->assertSame(
|
||||
'a="a\l\"a"',
|
||||
(string) $this->fixture,
|
||||
'Specials should not be escaped, but quotes should'
|
||||
);
|
||||
$this->fixture->setValue('a\\\\l"a');
|
||||
$this->assertSame(
|
||||
'a="a\\\\l\"a"',
|
||||
(string) $this->fixture,
|
||||
'Double backslashes should stay the same'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the isValueContainingSpecials function
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Attribute::isValueContainingSpecials
|
||||
*/
|
||||
public function testIsValueContainingSpecials(): void
|
||||
{
|
||||
$this->fixture->setValue('+ name : string\l+ home_country : string\l');
|
||||
$this->assertTrue($this->fixture->isValueContainingSpecials());
|
||||
|
||||
$this->fixture->setValue('+ ship(): boolean');
|
||||
$this->assertFalse($this->fixture->isValueContainingSpecials());
|
||||
}
|
||||
}
|
||||
153
vendor/phpdocumentor/graphviz/tests/phpDocumentor/GraphViz/Test/EdgeTest.php
vendored
Normal file
153
vendor/phpdocumentor/graphviz/tests/phpDocumentor/GraphViz/Test/EdgeTest.php
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\GraphViz\Test;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\GraphViz\AttributeNotFound;
|
||||
use phpDocumentor\GraphViz\Edge;
|
||||
use phpDocumentor\GraphViz\Node;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test for the the class representing a GraphViz edge (vertex).
|
||||
*/
|
||||
class EdgeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
m::close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the construct method
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Edge::__construct
|
||||
*/
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$fromNode = m::mock(Node::class);
|
||||
$toNode = m::mock(Node::class);
|
||||
$fixture = new Edge($fromNode, $toNode);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
Edge::class,
|
||||
$fixture
|
||||
);
|
||||
$this->assertSame(
|
||||
$fromNode,
|
||||
$fixture->getFrom()
|
||||
);
|
||||
$this->assertSame(
|
||||
$toNode,
|
||||
$fixture->getTo()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the create method
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Edge::create
|
||||
*/
|
||||
public function testCreate(): void
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
Edge::class,
|
||||
Edge::create(new Node('from'), new Node('to'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the getFrom method returns the same node as passed
|
||||
* in the create method
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Edge::getFrom
|
||||
*/
|
||||
public function testGetFrom(): void
|
||||
{
|
||||
$from = new Node('from');
|
||||
$edge = Edge::create($from, new Node('to'));
|
||||
$this->assertSame($from, $edge->getFrom());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getTo method returns the same node as passed
|
||||
* in the create method
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Edge::getTo
|
||||
*/
|
||||
public function testGetTo(): void
|
||||
{
|
||||
$to = new Node('to');
|
||||
$edge = Edge::create(new Node('from'), $to);
|
||||
$this->assertSame($to, $edge->getTo());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the magic __call method, to work as described, return the object
|
||||
* instance for a setX method, return the value for an getX method, and null
|
||||
* for the remaining method calls
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Edge::__call
|
||||
* @covers \phpDocumentor\GraphViz\Edge::setAttribute
|
||||
* @covers \phpDocumentor\GraphViz\Edge::getAttribute
|
||||
*/
|
||||
public function testCall(): void
|
||||
{
|
||||
$label = 'my label';
|
||||
$fixture = new Edge(new Node('from'), new Node('to'));
|
||||
$this->assertInstanceOf(Edge::class, $fixture->setLabel($label));
|
||||
$this->assertSame($label, $fixture->getLabel()->getValue());
|
||||
$this->assertNull($fixture->someNonExcistingMethod());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Edge::getAttribute
|
||||
* @covers \phpDocumentor\GraphViz\AttributeNotFound::__construct
|
||||
*/
|
||||
public function testGetNonExistingAttributeThrowsAttributeNotFound(): void
|
||||
{
|
||||
$fixture = new Edge(new Node('from'), new Node('to'));
|
||||
|
||||
$this->expectException(AttributeNotFound::class);
|
||||
$this->expectExceptionMessage('Attribute with name "label" was not found');
|
||||
|
||||
$fixture->getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the magic __toString method returns a well formatted string
|
||||
* as specified in the DOT standard
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Edge::__toString
|
||||
*/
|
||||
public function testToString(): void
|
||||
{
|
||||
$fixture = new Edge(new Node('from'), new Node('to'));
|
||||
$fixture->setLabel('MyLabel');
|
||||
$fixture->setWeight(45);
|
||||
|
||||
$dot = <<<DOT
|
||||
"from" -> "to" [
|
||||
label="MyLabel"
|
||||
weight="45"
|
||||
]
|
||||
DOT;
|
||||
|
||||
$this->assertSame($dot, (string) $fixture);
|
||||
}
|
||||
}
|
||||
430
vendor/phpdocumentor/graphviz/tests/phpDocumentor/GraphViz/Test/GraphTest.php
vendored
Normal file
430
vendor/phpdocumentor/graphviz/tests/phpDocumentor/GraphViz/Test/GraphTest.php
vendored
Normal file
@@ -0,0 +1,430 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\GraphViz\Test;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Mockery as m;
|
||||
use phpDocumentor\GraphViz\AttributeNotFound;
|
||||
use phpDocumentor\GraphViz\Edge;
|
||||
use phpDocumentor\GraphViz\Exception;
|
||||
use phpDocumentor\GraphViz\Graph;
|
||||
use phpDocumentor\GraphViz\Node;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
use function is_readable;
|
||||
use function preg_replace;
|
||||
use function sys_get_temp_dir;
|
||||
use function tempnam;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
* Test for the the class representing a GraphViz graph.
|
||||
*/
|
||||
class GraphTest extends TestCase
|
||||
{
|
||||
/** @var Graph */
|
||||
protected $fixture;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->fixture = new Graph();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
m::close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::create
|
||||
*/
|
||||
public function testCreate(): void
|
||||
{
|
||||
$fixture = Graph::create();
|
||||
$this->assertInstanceOf(
|
||||
Graph::class,
|
||||
$fixture
|
||||
);
|
||||
$this->assertSame(
|
||||
'G',
|
||||
$fixture->getName()
|
||||
);
|
||||
$this->assertSame(
|
||||
'digraph',
|
||||
$fixture->getType()
|
||||
);
|
||||
|
||||
$fixture = Graph::create('MyName', false);
|
||||
$this->assertSame(
|
||||
'MyName',
|
||||
$fixture->getName()
|
||||
);
|
||||
$this->assertSame(
|
||||
'graph',
|
||||
$fixture->getType()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::setName
|
||||
*/
|
||||
public function testSetName(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setName('otherName'),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::getName
|
||||
*/
|
||||
public function testGetName(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture->getName(),
|
||||
'G',
|
||||
'Expecting the name to match the initial state'
|
||||
);
|
||||
$this->fixture->setName('otherName');
|
||||
$this->assertSame(
|
||||
$this->fixture->getName(),
|
||||
'otherName',
|
||||
'Expecting the name to contain the new value'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::setType
|
||||
*/
|
||||
public function testSetType(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setType('digraph'),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setType('graph'),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setType('subgraph'),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::setType
|
||||
*/
|
||||
public function testSetTypeException(): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->fixture->setType('fakegraphg');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::getType
|
||||
*/
|
||||
public function testGetType(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture->getType(),
|
||||
'digraph'
|
||||
);
|
||||
$this->fixture->setType('graph');
|
||||
$this->assertSame(
|
||||
$this->fixture->getType(),
|
||||
'graph'
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetStrict(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setStrict(true),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setStrict(false),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsStrict(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture->isStrict(),
|
||||
false
|
||||
);
|
||||
$this->fixture->setStrict(true);
|
||||
$this->assertSame(
|
||||
$this->fixture->isStrict(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
public function testSetPath(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setPath(__DIR__),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::__call
|
||||
* @covers \phpDocumentor\GraphViz\Graph::getAttribute
|
||||
* @covers \phpDocumentor\GraphViz\Graph::setAttribute
|
||||
*/
|
||||
public function test__call(): void
|
||||
{
|
||||
$this->assertNull($this->fixture->MyMethod());
|
||||
$this->assertSame($this->fixture, $this->fixture->setBgColor('black'));
|
||||
$this->assertSame('black', $this->fixture->getBgColor()->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::getAttribute
|
||||
* @covers \phpDocumentor\GraphViz\AttributeNotFound::__construct
|
||||
*/
|
||||
public function testGetNonExistingAttributeThrowsAttributeNotFound(): void
|
||||
{
|
||||
$this->expectException(AttributeNotFound::class);
|
||||
$this->expectExceptionMessage('Attribute with name "notexisting" was not found');
|
||||
|
||||
$this->fixture->getNotExisting();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::addGraph
|
||||
*/
|
||||
public function testAddGraph(): void
|
||||
{
|
||||
$mock = m::mock(Graph::class);
|
||||
$mock->expects('setType');
|
||||
$mock->expects('getName');
|
||||
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->addGraph($mock)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::hasGraph
|
||||
*/
|
||||
public function testHasGraph(): void
|
||||
{
|
||||
$mock = m::mock(Graph::class);
|
||||
$mock->expects('getName')->andReturn('MyName');
|
||||
$mock->expects('setType');
|
||||
|
||||
$this->assertFalse($this->fixture->hasGraph('MyName'));
|
||||
$this->fixture->addGraph($mock);
|
||||
$this->assertTrue($this->fixture->hasGraph('MyName'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::getGraph
|
||||
*/
|
||||
public function testGetGraph(): void
|
||||
{
|
||||
$mock = m::mock(Graph::class);
|
||||
$mock->expects('setType');
|
||||
$mock->expects('getName')->andReturn('MyName');
|
||||
|
||||
$this->fixture->addGraph($mock);
|
||||
$this->assertSame(
|
||||
$mock,
|
||||
$this->fixture->getGraph('MyName')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::setNode
|
||||
*/
|
||||
public function testSetNode(): void
|
||||
{
|
||||
$mock = m::mock(Node::class);
|
||||
$mock->expects('getName')->andReturn('MyName');
|
||||
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setNode($mock)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::findNode
|
||||
*/
|
||||
public function testFindNode(): void
|
||||
{
|
||||
$this->assertNull($this->fixture->findNode('MyNode'));
|
||||
|
||||
$mock = m::mock(Node::class);
|
||||
$mock->expects('getName')->andReturn('MyName');
|
||||
|
||||
$this->fixture->setNode($mock);
|
||||
$this->assertSame(
|
||||
$mock,
|
||||
$this->fixture->findNode('MyName')
|
||||
);
|
||||
|
||||
$subGraph = Graph::create();
|
||||
$mock2 = m::mock(Node::class);
|
||||
$mock2->expects('getName')->andReturn('MyName2');
|
||||
|
||||
$subGraph->setNode($mock2);
|
||||
|
||||
$this->fixture->addGraph($subGraph);
|
||||
$this->assertSame(
|
||||
$mock2,
|
||||
$this->fixture->findNode('MyName2')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::__set
|
||||
*/
|
||||
public function test__set(): void
|
||||
{
|
||||
$mock = m::mock(Node::class);
|
||||
|
||||
$this->fixture->__set('myNode', $mock);
|
||||
|
||||
self::assertSame($mock, $this->fixture->myNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::__get
|
||||
*/
|
||||
public function test__get(): void
|
||||
{
|
||||
$mock = m::mock(Node::class);
|
||||
|
||||
$this->fixture->myNode = $mock;
|
||||
$this->assertSame(
|
||||
$mock,
|
||||
$this->fixture->myNode
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::link
|
||||
*/
|
||||
public function testLink(): void
|
||||
{
|
||||
$mock = m::mock(Edge::class);
|
||||
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->link($mock)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::export
|
||||
*/
|
||||
public function testExportException(): void
|
||||
{
|
||||
$graph = Graph::create('My First Graph');
|
||||
$filename = tempnam(sys_get_temp_dir(), 'tst');
|
||||
|
||||
if ($filename === false) {
|
||||
$this->assertFalse('Failed to create destination file');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$graph->export('fpd', $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::export
|
||||
*/
|
||||
public function testExport(): void
|
||||
{
|
||||
$graph = Graph::create('My First Graph');
|
||||
$filename = tempnam(sys_get_temp_dir(), 'tst');
|
||||
|
||||
if ($filename === false) {
|
||||
$this->assertFalse('Failed to create destination file');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->assertSame(
|
||||
$graph,
|
||||
$graph->export('pdf', $filename)
|
||||
);
|
||||
$this->assertTrue(is_readable($filename));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Graph::__toString
|
||||
*/
|
||||
public function test__toString(): void
|
||||
{
|
||||
$graph = Graph::create('My First Graph');
|
||||
$this->assertSame(
|
||||
$this->normalizeLineEndings((string) $graph),
|
||||
$this->normalizeLineEndings(('digraph "My First Graph" {' . PHP_EOL . PHP_EOL . '}'))
|
||||
);
|
||||
|
||||
$graph->setLabel('PigeonPost');
|
||||
$this->assertSame(
|
||||
$this->normalizeLineEndings((string) $graph),
|
||||
$this->normalizeLineEndings(('digraph "My First Graph" {' . PHP_EOL . 'label="PigeonPost"' . PHP_EOL . '}'))
|
||||
);
|
||||
|
||||
$graph->setStrict(true);
|
||||
$this->assertSame(
|
||||
$this->normalizeLineEndings((string) $graph),
|
||||
$this->normalizeLineEndings(
|
||||
('strict digraph "My First Graph" {' . PHP_EOL . 'label="PigeonPost"' . PHP_EOL . '}')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Help avoid issue of "#Warning: Strings contain different line endings!" on Windows.
|
||||
*/
|
||||
private function normalizeLineEndings(string $string): string
|
||||
{
|
||||
$result = preg_replace('~\R~u', "\r\n", $string);
|
||||
if ($result === null) {
|
||||
throw new RuntimeException('Normalize line endings failed');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
165
vendor/phpdocumentor/graphviz/tests/phpDocumentor/GraphViz/Test/NodeTest.php
vendored
Normal file
165
vendor/phpdocumentor/graphviz/tests/phpDocumentor/GraphViz/Test/NodeTest.php
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\GraphViz\Test;
|
||||
|
||||
use phpDocumentor\GraphViz\AttributeNotFound;
|
||||
use phpDocumentor\GraphViz\Node;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test for the the class representing a GraphViz node.
|
||||
*/
|
||||
class NodeTest extends TestCase
|
||||
{
|
||||
/** @var Node */
|
||||
protected $fixture = null;
|
||||
|
||||
/**
|
||||
* Initializes the fixture for this test.
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->fixture = new Node('name', 'label');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the construct method
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Node::__construct
|
||||
* @returnn void
|
||||
*/
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$fixture = new Node('MyName', 'MyLabel');
|
||||
$this->assertInstanceOf(
|
||||
Node::class,
|
||||
$fixture
|
||||
);
|
||||
$this->assertSame('MyName', $fixture->getName());
|
||||
$this->assertSame('MyLabel', $fixture->getLabel()->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the create method
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Node::create
|
||||
* @returnn void
|
||||
*/
|
||||
public function testCreate(): void
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
Node::class,
|
||||
Node::create('name', 'label')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getting and setting of the name.
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Node::getName
|
||||
* @covers \phpDocumentor\GraphViz\Node::setName
|
||||
*/
|
||||
public function testName(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$this->fixture->getName(),
|
||||
'name',
|
||||
'Expecting the name to match the initial state'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture,
|
||||
$this->fixture->setName('otherName'),
|
||||
'Expecting a fluent interface'
|
||||
);
|
||||
$this->assertSame(
|
||||
$this->fixture->getName(),
|
||||
'otherName',
|
||||
'Expecting the name to contain the new value'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the magic __call method, to work as described, return the object
|
||||
* instance for a setX method, return the value for an getX method, and null
|
||||
* for the remaining method calls
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Node::__call
|
||||
* @covers \phpDocumentor\GraphViz\Node::getAttribute
|
||||
* @covers \phpDocumentor\GraphViz\Node::setAttribute
|
||||
*/
|
||||
public function testCall(): void
|
||||
{
|
||||
$fontname = 'Bitstream Vera Sans';
|
||||
$this->assertInstanceOf(Node::class, $this->fixture->setfontname($fontname));
|
||||
$this->assertSame($fontname, $this->fixture->getfontname()->getValue());
|
||||
$this->assertNull($this->fixture->someNonExistingMethod());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\GraphViz\Node::getAttribute
|
||||
* @covers \phpDocumentor\GraphViz\AttributeNotFound::__construct
|
||||
*/
|
||||
public function testGetNonExistingAttributeThrowsAttributeNotFound(): void
|
||||
{
|
||||
$this->expectException(AttributeNotFound::class);
|
||||
$this->expectExceptionMessage('Attribute with name "fontname" was not found');
|
||||
|
||||
$this->fixture->getFontname();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the magic __toString method returns a well formatted string
|
||||
* as specified in the DOT standard
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Node::__toString
|
||||
*/
|
||||
public function testToString(): void
|
||||
{
|
||||
$this->fixture->setfontsize(12);
|
||||
$this->fixture->setfontname('Bitstream Vera Sans');
|
||||
|
||||
$dot = <<<DOT
|
||||
"name" [
|
||||
label="label"
|
||||
fontsize="12"
|
||||
fontname="Bitstream Vera Sans"
|
||||
]
|
||||
DOT;
|
||||
|
||||
$this->assertSame($dot, (string) $this->fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the magic __toString method returns a well formatted string
|
||||
* as specified in the DOT standard when the label contains slashes.
|
||||
*
|
||||
* @covers \phpDocumentor\GraphViz\Node::__toString
|
||||
*/
|
||||
public function testToStringWithLabelContainingSlashes(): void
|
||||
{
|
||||
$this->fixture->setfontsize(12);
|
||||
$this->fixture->setfontname('Bitstream Vera Sans');
|
||||
$this->fixture->setLabel('\phpDocumentor\Descriptor\ProjectDescriptor');
|
||||
|
||||
$dot = <<<DOT
|
||||
"name" [
|
||||
label="\\\\phpDocumentor\\\\Descriptor\\\\ProjectDescriptor"
|
||||
fontsize="12"
|
||||
fontname="Bitstream Vera Sans"
|
||||
]
|
||||
DOT;
|
||||
|
||||
$this->assertSame($dot, (string) $this->fixture);
|
||||
}
|
||||
}
|
||||
89
vendor/phpdocumentor/graphviz/tests/phpDocumentor/PHPStan/MethodReflectionExtensionTest.php
vendored
Normal file
89
vendor/phpdocumentor/graphviz/tests/phpDocumentor/PHPStan/MethodReflectionExtensionTest.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\GraphViz\PHPStan;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\GraphViz\Graph;
|
||||
use phpDocumentor\GraphViz\Node;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\FloatType;
|
||||
use PHPStan\Type\StringType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class MethodReflectionExtensionTest extends TestCase
|
||||
{
|
||||
/** @var MethodReflectionExtension */
|
||||
private $fixture;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->fixture = new MethodReflectionExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider existingMethodProvider
|
||||
*/
|
||||
public function testNodeHasMethodReturnsTrue(string $className, string $methodName): void
|
||||
{
|
||||
$classReflection = m::mock(ClassReflection::class);
|
||||
$classReflection->shouldReceive('getName')->andReturn($className);
|
||||
|
||||
$this->assertTrue($this->fixture->hasMethod($classReflection, $methodName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
public function existingMethodProvider(): array
|
||||
{
|
||||
return [
|
||||
'node::getLabel' => [
|
||||
'className' => Node::class,
|
||||
'methodName' => 'getLabel',
|
||||
],
|
||||
'node::setLabel' => [
|
||||
'className' => Node::class,
|
||||
'methodName' => 'setLabel',
|
||||
],
|
||||
'graph::setFontSize' => [
|
||||
'className' => Graph::class,
|
||||
'methodName' => 'setFontSize',
|
||||
],
|
||||
'graph::getFontSize' => [
|
||||
'className' => Graph::class,
|
||||
'methodName' => 'getFontSize',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testAttributeType(): void
|
||||
{
|
||||
$classReflection = m::mock(ClassReflection::class);
|
||||
$classReflection->shouldReceive('getName')->andReturn(Node::class);
|
||||
|
||||
$method = $this->fixture->getMethod($classReflection, 'setFontSize');
|
||||
|
||||
$this->assertInstanceOf(FloatType::class, $method->getVariants()[0]->getParameters()[0]->getType());
|
||||
}
|
||||
|
||||
public function testAttributeTypeOfNoneExisting(): void
|
||||
{
|
||||
$classReflection = m::mock(ClassReflection::class);
|
||||
$classReflection->shouldReceive('getName')->andReturn(Node::class);
|
||||
|
||||
$method = $this->fixture->getMethod($classReflection, 'setColor');
|
||||
|
||||
$this->assertInstanceOf(StringType::class, $method->getVariants()[0]->getParameters()[0]->getType());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user