public function testBuilder() { $pb = new \Fieg\PC\PropositionBuilder(); $a = new \Fieg\PC\Proposition\Atomic('a'); $b = new \Fieg\PC\Proposition\Atomic('b'); $this->assertInstanceOf('Fieg\\PC\\Proposition\\Implies', $pb->implies($a, $b)); $this->assertInstanceOf('Fieg\\PC\\Proposition\\AndX', $pb->andX($a, $b)); $this->assertInstanceOf('Fieg\\PC\\Proposition\\OrX', $pb->orX($a, $b)); $this->assertInstanceOf('Fieg\\PC\\Proposition\\Atomic', $pb->atom('thingy')); $this->assertInstanceOf('Fieg\\PC\\Proposition\\NotX', $pb->notX($a)); }
public function testGetAtomByName() { $pb = new \Fieg\PC\PropositionBuilder(); $kb = new \Fieg\PC\KnowledgeBase(); $kb->addProposition($pb->atom('ok_cb1')); $kb->addProposition($pb->atom('ok_cb2')); $kb->addProposition($pb->implies($pb->atom('live_l1'), $pb->atom('live_w0'))); $kb->addProposition($pb->implies($pb->atom('live_w0'), $pb->andX($pb->atom('live_w1'), $pb->atom('up_s2')))); $kb->addProposition($pb->implies($pb->atom('live_w0'), $pb->andX($pb->atom('live_w2'), $pb->atom('down_s2')))); $this->assertSame($pb->atom('live_w0'), $kb->getAtomByName('live_w0')); $this->assertSame($pb->atom('ok_cb1'), $kb->getAtomByName('ok_cb1')); $this->assertNull($kb->getAtomByName('atom_does_not_exist')); }