public function testLoadedExampleProducts()
 {
     $xmlContent = file_get_contents('../data/example1.xml');
     $products = Product::loadManyFromXmlDocument($xmlContent, VatTable::asAssociativeArray());
     $product = reset($products);
     $firstCategory = reset($product->getCategories());
     $this->assertEquals('First!', $product->getName());
     $this->assertEquals(100.0, $product->getPriceWithoutVat());
     $this->assertEquals(106.0, $product->getPriceWithVat());
     $this->assertEquals(3, count($product->getCategories()));
     $this->assertEquals('A category', $firstCategory->getName());
     $this->assertEquals(298, $firstCategory->getId());
     $this->assertTrue($product->hasCategories());
 }
Esempio n. 2
0
<?php

require '../vendor/autoload.php';
use AProductList\Product;
use AProductList\VatTable;
$xmlContent = file_get_contents('../../data/products.xml');
$products = Product::loadManyFromXmlDocument($xmlContent, VatTable::asAssociativeArray());
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>A Product List</title>
	<link href="https://fonts.googleapis.com/css?family=Amatic+SC:400,700|Open+Sans:400,700" rel="stylesheet">
	<link rel="stylesheet" href="main.css">
</head>
<body>

<div class="page-wrapper">

	<header>
		<h1>Produktlistan</h1>
	</header>

	<?php 
foreach ($products as $product) {
    ?>
		<?php 
    if ($product->isPublished()) {
        ?>
			<article class="product">