<commit_before><?php

namespace Saft\Store\Test;

class AbstractTriplePatternStoreUnitTest extends \PHPUnit_Framework_TestCase
{

    protected function setUp()
    {
        $this->store = $this->getMockForAbstractClass(
            '\Saft\Store\AbstractTriplePatternStore'
        );
    }

    public function testCreateStatement()
    {
        /*$statement1 = new \Saft\Rdf\TripleNEW('a1', 'b1', 'c1');
        $statement2 = new \Saft\Rdf\QuadNEW('a2', 'b2', 'c2', 'd2');

        $statements = array($statement1, $statement2);

        return $statements;*/
    }

    public function tearDown()
    {
        unset($this->store);
    }
}<commit_msg>create two simple test for AbstractTriplePatternStore<commit_after><?php

namespace Saft\Store\Test;

use Saft\TestCase;
use Saft\Rdf\StatementIterator;
use Saft\Rdf\LiteralImpl;
use Saft\Rdf\NamedNodeImpl;
use Saft\Rdf\VariableImpl;
use Saft\Rdf\Statement;
use Saft\Rdf\StatementImpl;

class AbstractTriplePatternStoreUnitTest extends TestCase
{

    protected function setUp()
    {
        parent::setUp();
        $this->fixture = $this->getMockForAbstractClass(
            '\Saft\Store\AbstractTriplePatternStore'
        );
    }

    public function getTestQuad()
    {
        $subject1 = new NamedNodeImpl('http://saft/test/s1');
        $predicate1 = new NamedNodeImpl('http://saft/test/p1');
        $object1 = new NamedNodeImpl('http://saft/test/o1');
        $graph1 = new NamedNodeImpl('http://saft/test/g1');
        $quad = new StatementImpl($subject1, $predicate1, $object1, $graph1);

        return $quad;
    }

    public function getTestTriple()
    {
        $subject2 = new NamedNodeImpl('http://saft/test/s2');
        $predicate2 = new NamedNodeImpl('http://saft/test/p2');
        $object2 = new NamedNodeImpl('http://saft/test/o2');
        $triple = new StatementImpl($subject2, $predicate2, $object2);

        return $triple;
    }

    public function testAddStatements()
    {
        $triple = $this->getTestTriple();
        $quad = $this->getTestQuad();
        $query = 'INSERT DATA { '.
            $triple->toSparqlFormat().
            $quad->toSparqlFormat().
            '}';
        $this->fixture->query($query);
        
        // Override abstract-methods: it will check the statements
        $this->fixture
        ->expects($this->once()) 
        ->method('addStatements')
        ->will($this->returnCallback(function(StatementIterator $statements, $graphUri = null, array $options = array()) {
            PHPUnit_Framework_Assert::assertEquals(
                $statements[0]->toSparqlFormat(),
                $triple->toSparqlFormat()
            );
            PHPUnit_Framework_Assert::assertEquals(
                $statements[1]->toSparqlFormat(),
                $quad->toSparqlFormat()
            );
        }));
    }

    public function testDeleteMatchingStatements()
    {
        $triple = $this->getTestTriple();
        $query = 'INSERT DATA { '.$triple->toSparqlFormat().'}';
        $this->fixture->query($query);
        
        $this->fixture
        ->expects($this->once()) 
        ->method('deleteMatchingStatements')
        ->will($this->returnCallback(function(Statement $statement, $graphUri = null, array $options = array()) {
            PHPUnit_Framework_Assert::assertEquals(
                $statement->toSparqlFormat(),
                $triple->toSparqlFormat()
            );
        }));
    }
}
{'fraction_non_alphanumeric': 0.14260819053151322, 'fraction_numerical': 0.009875108916642464, 'mean_word_length': 2.444, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6538574', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1036, 'n_words': 170}