public function testExtract() { $pb = new \Fieg\PC\PropositionBuilder(); $pb->atom('light_1'); $pb->atom('light_1'); $pb->atom('light_2'); $this->assertFalse(isset($light_1)); extract($pb->getAtoms()); $this->assertInstanceOf('Fieg\\PC\\Proposition\\Atomic', $light_1); $this->assertFalse(isset($light_0)); }
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')); }