<commit_before><?php

namespace UoMCS\OpenBadges\Backend;

class BadgeTest extends DatabaseTestCase
{
  const BADGE_EXISTS_ID = 1;
  const BADGE_DOES_NOT_EXIST_ID = 99999;
  const BADGE_COUNT = 1;

  public function testCreateBadgeDB()
  {
    $badge = Badge::get(self::BADGE_EXISTS_ID);

    // Set ID to null so we trigger an INSERT
    $badge->data['id'] = null;
    $badge->save();

    $this->assertNotNull($badge->data['id']);
    $this->assertInternalType('integer', $badge->data['id']);
  }

  public function testAllEarnersDB()
  {
    $badges = Badge::getAll();
    $this->assertInternalType('array', $badges);
    $this->assertCount(self::BADGE_COUNT, $badges);

    $this->assertContainsOnlyInstancesOf('UoMCS\\OpenBadges\\Backend\\Badge', $badges);
  }<commit_msg>Test updating badges<commit_after><?php

namespace UoMCS\OpenBadges\Backend;

class BadgeTest extends DatabaseTestCase
{
  const BADGE_EXISTS_ID = 1;
  const BADGE_DOES_NOT_EXIST_ID = 99999;
  const BADGE_COUNT = 1;

  public function testCreateBadgeDB()
  {
    $badge = Badge::get(self::BADGE_EXISTS_ID);

    // Set ID to null so we trigger an INSERT
    $badge->data['id'] = null;
    $badge->save();

    $this->assertNotNull($badge->data['id']);
    $this->assertInternalType('integer', $badge->data['id']);
  }

  public function testUpdateBadgeDB()
  {
    $badge_name = 'New badge name';
    $badge_description = 'New badge description';

    $badge_old = Badge::get(self::BADGE_EXISTS_ID);
    $this->assertInstanceOf('UoMCS\\OpenBadges\\Backend\\Badge', $badge_old);

    $badge_old->data['name'] = $badge_name;
    $badge_old->data['description'] = $badge_description;
    $badge_old->save();

    $badge_new = Badge::get(self::BADGE_EXISTS_ID);
    $this->assertEquals($badge_description, $badge_new->data['description']);
    $this->assertEquals($badge_name, $badge_new->data['name']);
  }

  public function testAllEarnersDB()
  {
    $badges = Badge::getAll();
    $this->assertInternalType('array', $badges);
    $this->assertCount(self::BADGE_COUNT, $badges);

    $this->assertContainsOnlyInstancesOf('UoMCS\\OpenBadges\\Backend\\Badge', $badges);
  }
{'fraction_non_alphanumeric': 0.16115510013972986, 'fraction_numerical': 0.006520726595249185, 'mean_word_length': 4.579220779220779, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '2088020', 'n_tokens_mistral': 803, 'n_tokens_neox': 770, 'n_words': 122}