<?php

namespace ActivityPhpTest\Type;

use ActivityPhpTest\MyCustomOntology;
use ActivityPhp\Type;
use ActivityPhp\Type\Ontology;
use Exception;
use PHPUnit\Framework\TestCase;

abstract class MyNotwellDefinedOntology
{
	/**
	 * A definition of custom's ontology to overload Activity
	 * Streams vocabulary.
	 *
	 * @var array
	 */
	protected static $definitions = [
	    'Person|Group' => ['myOntologyField'],
	];
}

class OntologyTest extends TestCase
{
	/**
	 * Add a new ontology
	 */
	public function testAddNewOne()
	{
		Ontology::clear();

		// Add and load this dialect
		Ontology::add('custom-ontology', MyCustomOntology::class);

		// Set this dialect property for one type
		$type = Type::create('Person', ['myOntologyField' => 1]);

		$this->assertEquals(
		    1,
		    $type->myOntologyField
		);

		Ontology::clear();
	}


	/**
	 * Should throw an Exception when ontology name is not allowed
	 */
	public function testNotAllowedOntologyName()
	{
		$this->expectException(Exception::class);

		Ontology::clear();

		$ontology = 'MyClass';

		// Add and load this dialect
		Ontology::add('*', $ontology);
	}


	/**
	 * Should throw an Exception when ontology class does not exist
	 */
	public function testNotExistingOntology()
	{
		$this->expectException(Exception::class);

		Ontology::clear();

		$ontology = 'MyClass';

		// Add and load this dialect
		Ontology::add('cus-ontology', $ontology);
	}


	/**
	 * Should throw an Exception when ontology cdoes not implement
	 * its interface
	 */
	public function testNotWellDefinedOntology()
	{
		$this->expectException(Exception::class);

		Ontology::clear();

		// Add and load this dialect
		Ontology::add('cus-ontology', MyNotwellDefinedOntology::class);
	}
}
__halt_compiler();----SIGNATURE:----LgBpr7EEDAGXpgyPKrqEqC1XXhkGmRB6EPTbdeUD3Y8MKwfx70knOnKNjCqa3gM43Kng+4rmsgZR7FsnANeYNSqgy4SYPBmu1o3BTg/1U3T04gpDJuPuHbgWd70CxQ7ssVcUpbtC7fB8vRuoQFvm0Af1UgI4pgr461iBWt99rQjzfUylB0hY3/rnUf9H3q2pXpS3UyHjkrRkyYBtfQ+UgWKyvqZccetnnD8oEaW/fLKm9zw0gFvwyCZp5MWZq5/uML68Cmy6YKPPMrPDus3sj8WnzmyQXrQnXREin7iJwpd38dQX+8QLCGtoDceGZgjLYIpcwxhqwx/xN0U3plICyFlltW8p4/C/9iGWIQMmr+/R8zvI3CCeotAbqUSQ0/jwSc47Zjr46BpVUcwQuBN38AaCUdoEdiy00rel6UnSciPebbWIp0b9UhJlXx5eAq2WwBPpPN+4sSizSfHJV4cHAhVf++BjVV19IaA0Ya4xyS4Ed0PDMOjA6/hXvJSGupXm+2ZLI072P5QjPQx08BYZURuBTSzF7Tno906CjiR8kdogdZQ2J44/HtlZqntLTAXpygCrB58AyfqIf0wb18pwCBoP9ToLU1UgddoVEFzzEMYCNAFjPOz5sLnnDPOtX+zvPgIJj2q9DkJQNTzgr30lj1FYkGchlo+RRzpGNsS+gGw=----ATTACHMENT:----OTI4Mzk4ODI2MTcyMjQyOSA1NTgzMjcxMTIyMzc3NTc2IDUzODE2OTY0NTgwMzUwNjE=